Title: [240666] trunk/Source/WebCore
Revision
240666
Author
[email protected]
Date
2019-01-29 11:39:55 -0800 (Tue, 29 Jan 2019)

Log Message

[MathML] Move enum class ScriptType to MathMLScriptsElement.
https://bugs.webkit.org/show_bug.cgi?id=193969

Reviewed by Antti Koivisto.

* mathml/MathMLScriptsElement.cpp:
(WebCore::scriptTypeOf):
* mathml/MathMLScriptsElement.h:
* rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::scriptType const):
(WebCore::RenderMathMLScripts::validateAndGetReferenceChildren):
(WebCore::RenderMathMLScripts::computePreferredLogicalWidths):
(WebCore::RenderMathMLScripts::verticalMetrics):
(WebCore::RenderMathMLScripts::layoutBlock):
* rendering/mathml/RenderMathMLScripts.h:
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::isValid const):
(WebCore::RenderMathMLUnderOver::under const):
(WebCore::RenderMathMLUnderOver::over const):
(WebCore::RenderMathMLUnderOver::computePreferredLogicalWidths):
(WebCore::RenderMathMLUnderOver::hasAccent const):
(WebCore::RenderMathMLUnderOver::layoutBlock):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (240665 => 240666)


--- trunk/Source/WebCore/ChangeLog	2019-01-29 19:13:25 UTC (rev 240665)
+++ trunk/Source/WebCore/ChangeLog	2019-01-29 19:39:55 UTC (rev 240666)
@@ -1,3 +1,28 @@
+2019-01-29  Zalan Bujtas  <[email protected]>
+
+        [MathML] Move enum class ScriptType to MathMLScriptsElement.
+        https://bugs.webkit.org/show_bug.cgi?id=193969
+
+        Reviewed by Antti Koivisto.
+
+        * mathml/MathMLScriptsElement.cpp:
+        (WebCore::scriptTypeOf):
+        * mathml/MathMLScriptsElement.h:
+        * rendering/mathml/RenderMathMLScripts.cpp:
+        (WebCore::RenderMathMLScripts::scriptType const):
+        (WebCore::RenderMathMLScripts::validateAndGetReferenceChildren):
+        (WebCore::RenderMathMLScripts::computePreferredLogicalWidths):
+        (WebCore::RenderMathMLScripts::verticalMetrics):
+        (WebCore::RenderMathMLScripts::layoutBlock):
+        * rendering/mathml/RenderMathMLScripts.h:
+        * rendering/mathml/RenderMathMLUnderOver.cpp:
+        (WebCore::RenderMathMLUnderOver::isValid const):
+        (WebCore::RenderMathMLUnderOver::under const):
+        (WebCore::RenderMathMLUnderOver::over const):
+        (WebCore::RenderMathMLUnderOver::computePreferredLogicalWidths):
+        (WebCore::RenderMathMLUnderOver::hasAccent const):
+        (WebCore::RenderMathMLUnderOver::layoutBlock):
+
 2019-01-29  Chris Dumez  <[email protected]>
 
         Make sure WTF::generateObjectIdentifier() internal counter does not get duplicated

Modified: trunk/Source/WebCore/mathml/MathMLScriptsElement.cpp (240665 => 240666)


--- trunk/Source/WebCore/mathml/MathMLScriptsElement.cpp	2019-01-29 19:13:25 UTC (rev 240665)
+++ trunk/Source/WebCore/mathml/MathMLScriptsElement.cpp	2019-01-29 19:39:55 UTC (rev 240666)
@@ -38,22 +38,22 @@
 
 using namespace MathMLNames;
 
-static ScriptType scriptTypeOf(const QualifiedName& tagName)
+static MathMLScriptsElement::ScriptType scriptTypeOf(const QualifiedName& tagName)
 {
     if (tagName == msubTag)
-        return ScriptType::Sub;
+        return MathMLScriptsElement::ScriptType::Sub;
     if (tagName == msupTag)
-        return ScriptType::Super;
+        return MathMLScriptsElement::ScriptType::Super;
     if (tagName == msubsupTag)
-        return ScriptType::SubSup;
+        return MathMLScriptsElement::ScriptType::SubSup;
     if (tagName == munderTag)
-        return ScriptType::Under;
+        return MathMLScriptsElement::ScriptType::Under;
     if (tagName == moverTag)
-        return ScriptType::Over;
+        return MathMLScriptsElement::ScriptType::Over;
     if (tagName == munderoverTag)
-        return ScriptType::UnderOver;
+        return MathMLScriptsElement::ScriptType::UnderOver;
     ASSERT(tagName == mmultiscriptsTag);
-    return ScriptType::Multiscripts;
+    return MathMLScriptsElement::ScriptType::Multiscripts;
 }
 
 MathMLScriptsElement::MathMLScriptsElement(const QualifiedName& tagName, Document& document)

Modified: trunk/Source/WebCore/mathml/MathMLScriptsElement.h (240665 => 240666)


--- trunk/Source/WebCore/mathml/MathMLScriptsElement.h	2019-01-29 19:13:25 UTC (rev 240665)
+++ trunk/Source/WebCore/mathml/MathMLScriptsElement.h	2019-01-29 19:39:55 UTC (rev 240666)
@@ -31,12 +31,12 @@
 
 namespace WebCore {
 
-enum class ScriptType;
-
 class MathMLScriptsElement : public MathMLPresentationElement {
     WTF_MAKE_ISO_ALLOCATED(MathMLScriptsElement);
 public:
     static Ref<MathMLScriptsElement> create(const QualifiedName& tagName, Document&);
+
+    enum class ScriptType { Sub, Super, SubSup, Multiscripts, Under, Over, UnderOver };
     ScriptType scriptType() const { return m_scriptType; }
     const Length& subscriptShift();
     const Length& superscriptShift();

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp (240665 => 240666)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2019-01-29 19:13:25 UTC (rev 240665)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2019-01-29 19:39:55 UTC (rev 240666)
@@ -54,7 +54,7 @@
     return static_cast<MathMLScriptsElement&>(nodeForNonAnonymous());
 }
 
-ScriptType RenderMathMLScripts::scriptType() const
+MathMLScriptsElement::ScriptType RenderMathMLScripts::scriptType() const
 {
     return element().scriptType();
 }
@@ -82,10 +82,10 @@
     reference.prescriptDelimiter = nullptr;
 
     switch (scriptType()) {
-    case ScriptType::Sub:
-    case ScriptType::Super:
-    case ScriptType::Under:
-    case ScriptType::Over: {
+    case MathMLScriptsElement::ScriptType::Sub:
+    case MathMLScriptsElement::ScriptType::Super:
+    case MathMLScriptsElement::ScriptType::Under:
+    case MathMLScriptsElement::ScriptType::Over: {
         // These elements must have exactly two children.
         // The second child is a postscript and there are no prescripts.
         // <msub> base subscript </msub>
@@ -98,8 +98,8 @@
         reference.firstPostScript = script;
         return reference;
     }
-    case ScriptType::SubSup:
-    case ScriptType::UnderOver: {
+    case MathMLScriptsElement::ScriptType::SubSup:
+    case MathMLScriptsElement::ScriptType::UnderOver: {
         // These elements must have exactly three children.
         // The second and third children are postscripts and there are no prescripts.
         // <msubsup> base subscript superscript </msubsup>
@@ -113,7 +113,7 @@
         reference.firstPostScript = subScript;
         return reference;
     }
-    case ScriptType::Multiscripts: {
+    case MathMLScriptsElement::ScriptType::Multiscripts: {
         // This element accepts the following syntax:
         //
         // <mmultiscripts>
@@ -189,19 +189,19 @@
     LayoutUnit space = spaceAfterScript();
 
     switch (scriptType()) {
-    case ScriptType::Sub:
-    case ScriptType::Under:
+    case MathMLScriptsElement::ScriptType::Sub:
+    case MathMLScriptsElement::ScriptType::Under:
         m_maxPreferredLogicalWidth += reference.base->maxPreferredLogicalWidth();
         m_maxPreferredLogicalWidth += std::max(0_lu, reference.firstPostScript->maxPreferredLogicalWidth() - baseItalicCorrection + space);
         break;
-    case ScriptType::Super:
-    case ScriptType::Over:
+    case MathMLScriptsElement::ScriptType::Super:
+    case MathMLScriptsElement::ScriptType::Over:
         m_maxPreferredLogicalWidth += reference.base->maxPreferredLogicalWidth();
         m_maxPreferredLogicalWidth += std::max(0_lu, reference.firstPostScript->maxPreferredLogicalWidth() + space);
         break;
-    case ScriptType::SubSup:
-    case ScriptType::UnderOver:
-    case ScriptType::Multiscripts: {
+    case MathMLScriptsElement::ScriptType::SubSup:
+    case MathMLScriptsElement::ScriptType::UnderOver:
+    case MathMLScriptsElement::ScriptType::Multiscripts: {
         auto subScript = reference.firstPreScript;
         while (subScript) {
             auto supScript = subScript->nextSiblingBox();
@@ -261,7 +261,7 @@
 
     LayoutUnit baseAscent = ascentForChild(*reference.base);
     LayoutUnit baseDescent = reference.base->logicalHeight() - baseAscent;
-    if (scriptType() == ScriptType::Sub || scriptType() == ScriptType::SubSup || scriptType() == ScriptType::Multiscripts || scriptType() == ScriptType::Under || scriptType() == ScriptType::UnderOver) {
+    if (scriptType() == MathMLScriptsElement::ScriptType::Sub || scriptType() == MathMLScriptsElement::ScriptType::SubSup || scriptType() == MathMLScriptsElement::ScriptType::Multiscripts || scriptType() == MathMLScriptsElement::ScriptType::Under || scriptType() == MathMLScriptsElement::ScriptType::UnderOver) {
         metrics.subShift = std::max(parameters.subscriptShiftDown, baseDescent + parameters.subscriptBaselineDropMin);
         if (!isRenderMathMLUnderOver()) {
             // It is not clear how to interpret the default shift and it is not available yet anyway.
@@ -270,7 +270,7 @@
             metrics.subShift = std::max(metrics.subShift, specifiedMinSubShift);
         }
     }
-    if (scriptType() == ScriptType::Super || scriptType() == ScriptType::SubSup || scriptType() == ScriptType::Multiscripts  || scriptType() == ScriptType::Over || scriptType() == ScriptType::UnderOver) {
+    if (scriptType() == MathMLScriptsElement::ScriptType::Super || scriptType() == MathMLScriptsElement::ScriptType::SubSup || scriptType() == MathMLScriptsElement::ScriptType::Multiscripts  || scriptType() == MathMLScriptsElement::ScriptType::Over || scriptType() == MathMLScriptsElement::ScriptType::UnderOver) {
         metrics.supShift = std::max(parameters.superscriptShiftUp, baseAscent - parameters.superScriptBaselineDropMax);
         if (!isRenderMathMLUnderOver()) {
             // It is not clear how to interpret the default shift and it is not available yet anyway.
@@ -281,8 +281,8 @@
     }
 
     switch (scriptType()) {
-    case ScriptType::Sub:
-    case ScriptType::Under: {
+    case MathMLScriptsElement::ScriptType::Sub:
+    case MathMLScriptsElement::ScriptType::Under: {
         LayoutUnit subAscent = ascentForChild(*reference.firstPostScript);
         LayoutUnit subDescent = reference.firstPostScript->logicalHeight() - subAscent;
         metrics.descent = subDescent;
@@ -289,8 +289,8 @@
         metrics.subShift = std::max(metrics.subShift, subAscent - parameters.subscriptTopMax);
     }
         break;
-    case ScriptType::Super:
-    case ScriptType::Over: {
+    case MathMLScriptsElement::ScriptType::Super:
+    case MathMLScriptsElement::ScriptType::Over: {
         LayoutUnit supAscent = ascentForChild(*reference.firstPostScript);
         LayoutUnit supDescent = reference.firstPostScript->logicalHeight() - supAscent;
         metrics.ascent = supAscent;
@@ -297,9 +297,9 @@
         metrics.supShift = std::max(metrics.supShift, parameters.superscriptBottomMin + supDescent);
     }
         break;
-    case ScriptType::SubSup:
-    case ScriptType::UnderOver:
-    case ScriptType::Multiscripts: {
+    case MathMLScriptsElement::ScriptType::SubSup:
+    case MathMLScriptsElement::ScriptType::UnderOver:
+    case MathMLScriptsElement::ScriptType::Multiscripts: {
         // FIXME: We should move the code updating VerticalMetrics for each sub/sup pair in a helper
         // function. That way, SubSup/UnderOver can just make one call and the loop for Multiscripts
         // can be rewritten in a more readable.
@@ -378,8 +378,8 @@
     setLogicalHeight(ascent + descent);
 
     switch (scriptType()) {
-    case ScriptType::Sub:
-    case ScriptType::Under: {
+    case MathMLScriptsElement::ScriptType::Sub:
+    case MathMLScriptsElement::ScriptType::Under: {
         setLogicalWidth(reference.base->logicalWidth() + std::max(0_lu, reference.firstPostScript->logicalWidth() - baseItalicCorrection + space));
         LayoutPoint baseLocation(mirrorIfNeeded(horizontalOffset, *reference.base), ascent - baseAscent);
         reference.base->setLocation(baseLocation);
@@ -389,8 +389,8 @@
         reference.firstPostScript->setLocation(scriptLocation);
     }
         break;
-    case ScriptType::Super:
-    case ScriptType::Over: {
+    case MathMLScriptsElement::ScriptType::Super:
+    case MathMLScriptsElement::ScriptType::Over: {
         setLogicalWidth(reference.base->logicalWidth() + std::max(0_lu, reference.firstPostScript->logicalWidth() + space));
         LayoutPoint baseLocation(mirrorIfNeeded(horizontalOffset, *reference.base), ascent - baseAscent);
         reference.base->setLocation(baseLocation);
@@ -400,9 +400,9 @@
         reference.firstPostScript->setLocation(scriptLocation);
     }
         break;
-    case ScriptType::SubSup:
-    case ScriptType::UnderOver:
-    case ScriptType::Multiscripts: {
+    case MathMLScriptsElement::ScriptType::SubSup:
+    case MathMLScriptsElement::ScriptType::UnderOver:
+    case MathMLScriptsElement::ScriptType::Multiscripts: {
         // Calculate the logical width.
         LayoutUnit logicalWidth;
         auto subScript = reference.firstPreScript;

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h (240665 => 240666)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h	2019-01-29 19:13:25 UTC (rev 240665)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h	2019-01-29 19:39:55 UTC (rev 240666)
@@ -29,14 +29,11 @@
 
 #if ENABLE(MATHML)
 
+#include "MathMLScriptsElement.h"
 #include "RenderMathMLBlock.h"
 
 namespace WebCore {
 
-class MathMLScriptsElement;
-
-enum class ScriptType { Sub, Super, SubSup, Multiscripts, Under, Over, UnderOver };
-
 // Render a base with scripts.
 class RenderMathMLScripts : public RenderMathMLBlock {
     WTF_MAKE_ISO_ALLOCATED(RenderMathMLScripts);
@@ -47,7 +44,7 @@
 protected:
     bool isRenderMathMLScripts() const override { return true; }
     const char* renderName() const override { return "RenderMathMLScripts"; }
-    ScriptType scriptType() const;
+    MathMLScriptsElement::ScriptType scriptType() const;
     void computePreferredLogicalWidths() override;
     void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0_lu) override;
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp (240665 => 240666)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp	2019-01-29 19:13:25 UTC (rev 240665)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp	2019-01-29 19:39:55 UTC (rev 240666)
@@ -135,10 +135,10 @@
         return false;
     child = child->nextSiblingBox();
     switch (scriptType()) {
-    case ScriptType::Over:
-    case ScriptType::Under:
+    case MathMLScriptsElement::ScriptType::Over:
+    case MathMLScriptsElement::ScriptType::Under:
         return !child;
-    case ScriptType::UnderOver:
+    case MathMLScriptsElement::ScriptType::UnderOver:
         return child && !child->nextSiblingBox();
     default:
         ASSERT_NOT_REACHED();
@@ -162,7 +162,7 @@
 RenderBox& RenderMathMLUnderOver::under() const
 {
     ASSERT(isValid());
-    ASSERT(scriptType() == ScriptType::Under || scriptType() == ScriptType::UnderOver);
+    ASSERT(scriptType() == MathMLScriptsElement::ScriptType::Under || scriptType() == MathMLScriptsElement::ScriptType::UnderOver);
     return *firstChildBox()->nextSiblingBox();
 }
 
@@ -169,9 +169,9 @@
 RenderBox& RenderMathMLUnderOver::over() const
 {
     ASSERT(isValid());
-    ASSERT(scriptType() == ScriptType::Over || scriptType() == ScriptType::UnderOver);
+    ASSERT(scriptType() == MathMLScriptsElement::ScriptType::Over || scriptType() == MathMLScriptsElement::ScriptType::UnderOver);
     auto* secondChild = firstChildBox()->nextSiblingBox();
-    return scriptType() == ScriptType::Over ? *secondChild : *secondChild->nextSiblingBox();
+    return scriptType() == MathMLScriptsElement::ScriptType::Over ? *secondChild : *secondChild->nextSiblingBox();
 }
 
 
@@ -192,10 +192,10 @@
 
     LayoutUnit preferredWidth = base().maxPreferredLogicalWidth();
 
-    if (scriptType() == ScriptType::Under || scriptType() == ScriptType::UnderOver)
+    if (scriptType() == MathMLScriptsElement::ScriptType::Under || scriptType() == MathMLScriptsElement::ScriptType::UnderOver)
         preferredWidth = std::max(preferredWidth, under().maxPreferredLogicalWidth());
 
-    if (scriptType() == ScriptType::Over || scriptType() == ScriptType::UnderOver)
+    if (scriptType() == MathMLScriptsElement::ScriptType::Over || scriptType() == MathMLScriptsElement::ScriptType::UnderOver)
         preferredWidth = std::max(preferredWidth, over().maxPreferredLogicalWidth());
 
     m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = preferredWidth;
@@ -210,7 +210,7 @@
 
 bool RenderMathMLUnderOver::hasAccent(bool accentUnder) const
 {
-    ASSERT(scriptType() == ScriptType::UnderOver || (accentUnder && scriptType() == ScriptType::Under) || (!accentUnder && scriptType() == ScriptType::Over));
+    ASSERT(scriptType() == MathMLScriptsElement::ScriptType::UnderOver || (accentUnder && scriptType() == MathMLScriptsElement::ScriptType::Under) || (!accentUnder && scriptType() == MathMLScriptsElement::ScriptType::Over));
 
     const MathMLElement::BooleanValue& attributeValue = accentUnder ? element().accentUnder() : element().accent();
     if (attributeValue == MathMLElement::BooleanValue::True)
@@ -306,19 +306,19 @@
     stretchHorizontalOperatorsAndLayoutChildren();
 
     ASSERT(!base().needsLayout());
-    ASSERT(scriptType() == ScriptType::Over || !under().needsLayout());
-    ASSERT(scriptType() == ScriptType::Under || !over().needsLayout());
+    ASSERT(scriptType() == MathMLScriptsElement::ScriptType::Over || !under().needsLayout());
+    ASSERT(scriptType() == MathMLScriptsElement::ScriptType::Under || !over().needsLayout());
 
     LayoutUnit logicalWidth = base().logicalWidth();
-    if (scriptType() == ScriptType::Under || scriptType() == ScriptType::UnderOver)
+    if (scriptType() == MathMLScriptsElement::ScriptType::Under || scriptType() == MathMLScriptsElement::ScriptType::UnderOver)
         logicalWidth = std::max(logicalWidth, under().logicalWidth());
-    if (scriptType() == ScriptType::Over || scriptType() == ScriptType::UnderOver)
+    if (scriptType() == MathMLScriptsElement::ScriptType::Over || scriptType() == MathMLScriptsElement::ScriptType::UnderOver)
         logicalWidth = std::max(logicalWidth, over().logicalWidth());
     setLogicalWidth(logicalWidth);
 
     VerticalParameters parameters = verticalParameters();
     LayoutUnit verticalOffset;
-    if (scriptType() == ScriptType::Over || scriptType() == ScriptType::UnderOver) {
+    if (scriptType() == MathMLScriptsElement::ScriptType::Over || scriptType() == MathMLScriptsElement::ScriptType::UnderOver) {
         verticalOffset += parameters.overExtraAscender;
         over().setLocation(LayoutPoint(horizontalOffset(over()), verticalOffset));
         if (parameters.useUnderOverBarFallBack) {
@@ -336,7 +336,7 @@
     }
     base().setLocation(LayoutPoint(horizontalOffset(base()), verticalOffset));
     verticalOffset += base().logicalHeight();
-    if (scriptType() == ScriptType::Under || scriptType() == ScriptType::UnderOver) {
+    if (scriptType() == MathMLScriptsElement::ScriptType::Under || scriptType() == MathMLScriptsElement::ScriptType::UnderOver) {
         if (parameters.useUnderOverBarFallBack) {
             if (!hasAccentUnder())
                 verticalOffset += parameters.underGapMin;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to