/webkit/Source/WebCore/mathml/MathMLMencloseElement.cpp

https://github.com/naver/sling · C++ · 112 lines · 76 code · 10 blank · 26 comment · 51 complexity · 6276158a9fdad3903ed9ec41649ab0a0 MD5 · raw file

  1. /*
  2. * Copyright (C) 2014 Gurpreet Kaur (k.gurpreet@samsung.com). All rights reserved.
  3. * Copyright (C) 2016 Igalia S.L.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  20. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include "config.h"
  27. #if ENABLE(MATHML)
  28. #include "MathMLMencloseElement.h"
  29. #include "MathMLNames.h"
  30. #include "RenderMathMLMenclose.h"
  31. namespace WebCore {
  32. MathMLMencloseElement::MathMLMencloseElement(const QualifiedName& tagName, Document& document)
  33. : MathMLInlineContainerElement(tagName, document)
  34. {
  35. // By default we draw a longdiv.
  36. clearNotations();
  37. addNotation(LongDiv);
  38. }
  39. Ref<MathMLMencloseElement> MathMLMencloseElement::create(const QualifiedName& tagName, Document& document)
  40. {
  41. return adoptRef(*new MathMLMencloseElement(tagName, document));
  42. }
  43. RenderPtr<RenderElement> MathMLMencloseElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
  44. {
  45. return createRenderer<RenderMathMLMenclose>(*this, WTFMove(style));
  46. }
  47. void MathMLMencloseElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
  48. {
  49. if (name == MathMLNames::notationAttr) {
  50. clearNotations();
  51. if (!hasAttribute(name)) {
  52. addNotation(LongDiv); // default value is longdiv
  53. return;
  54. }
  55. Vector<String> notationsList;
  56. String(value).split(' ', notationsList);
  57. for (auto& notation : notationsList) {
  58. if (notation == "longdiv") {
  59. addNotation(LongDiv);
  60. } else if (notation == "roundedbox") {
  61. addNotation(RoundedBox);
  62. } else if (notation == "circle") {
  63. addNotation(Circle);
  64. } else if (notation == "left") {
  65. addNotation(Left);
  66. } else if (notation == "right") {
  67. addNotation(Right);
  68. } else if (notation == "top") {
  69. addNotation(Top);
  70. } else if (notation == "bottom") {
  71. addNotation(Bottom);
  72. } else if (notation == "updiagonalstrike") {
  73. addNotation(UpDiagonalStrike);
  74. } else if (notation == "downdiagonalstrike") {
  75. addNotation(DownDiagonalStrike);
  76. } else if (notation == "verticalstrike") {
  77. addNotation(VerticalStrike);
  78. } else if (notation == "horizontalstrike") {
  79. addNotation(HorizontalStrike);
  80. } else if (notation == "updiagonalarrow") {
  81. addNotation(UpDiagonalArrow);
  82. } else if (notation == "phasorangle") {
  83. addNotation(PhasorAngle);
  84. } else if (notation == "box") {
  85. addNotation(Left);
  86. addNotation(Right);
  87. addNotation(Top);
  88. addNotation(Bottom);
  89. } else if (notation == "actuarial") {
  90. addNotation(Right);
  91. addNotation(Top);
  92. } else if (notation == "madruwb") {
  93. addNotation(Right);
  94. addNotation(Bottom);
  95. }
  96. }
  97. return;
  98. }
  99. MathMLInlineContainerElement::parseAttribute(name, value);
  100. }
  101. }
  102. #endif // ENABLE(MATHML)