Title: [201418] trunk/Source/WebCore
Revision
201418
Author
[email protected]
Date
2016-05-26 02:14:20 -0700 (Thu, 26 May 2016)

Log Message

Small improvements to RenderBox/LayoutUnit casting in MathML
https://bugs.webkit.org/show_bug.cgi?id=157943

Patch by Frederic Wang <[email protected]> on 2016-05-26
Reviewed by Darin Adler.

This is a small follow-up of the RenderMathMLRow/RenderMathMLUnderOver/RenderMathMLFraction
refactoring. Since these MathML renderers can only contain other MathML renderers, we can
just considerer RenderBox children and avoid unnecessary casts. Similarly, when the two
arguments of std::max are LayoutUnit's, we do not need to specialize to std::max<LayoutUnit>.

No new tests, behavior is not changed.

* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::layoutBlock): Do not to specialize to std::max<LayoutUnit>.
* rendering/mathml/RenderMathMLRow.cpp:
(WebCore::RenderMathMLRow::updateOperatorProperties): Browse the list of RenderBox children
and use auto*.
(WebCore::RenderMathMLRow::computeLineVerticalStretch): Do not to specialize to std::max<LayoutUnit>.
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::unembellishedOperator): Get the RenderBox child and use auto*.
(WebCore::RenderMathMLUnderOver::computeOperatorsHorizontalStretch): Browse the list of
RenderBox children, use auto* and remove unnecessary casts. Do not to specialize to
std::max<LayoutUnit>.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (201417 => 201418)


--- trunk/Source/WebCore/ChangeLog	2016-05-26 07:54:41 UTC (rev 201417)
+++ trunk/Source/WebCore/ChangeLog	2016-05-26 09:14:20 UTC (rev 201418)
@@ -1,3 +1,29 @@
+2016-05-26  Frederic Wang  <[email protected]>
+
+        Small improvements to RenderBox/LayoutUnit casting in MathML
+        https://bugs.webkit.org/show_bug.cgi?id=157943
+
+        Reviewed by Darin Adler.
+
+        This is a small follow-up of the RenderMathMLRow/RenderMathMLUnderOver/RenderMathMLFraction
+        refactoring. Since these MathML renderers can only contain other MathML renderers, we can
+        just considerer RenderBox children and avoid unnecessary casts. Similarly, when the two
+        arguments of std::max are LayoutUnit's, we do not need to specialize to std::max<LayoutUnit>.
+
+        No new tests, behavior is not changed.
+
+        * rendering/mathml/RenderMathMLFraction.cpp:
+        (WebCore::RenderMathMLFraction::layoutBlock): Do not to specialize to std::max<LayoutUnit>.
+        * rendering/mathml/RenderMathMLRow.cpp:
+        (WebCore::RenderMathMLRow::updateOperatorProperties): Browse the list of RenderBox children
+        and use auto*.
+        (WebCore::RenderMathMLRow::computeLineVerticalStretch): Do not to specialize to std::max<LayoutUnit>.
+        * rendering/mathml/RenderMathMLUnderOver.cpp:
+        (WebCore::RenderMathMLUnderOver::unembellishedOperator): Get the RenderBox child and use auto*.
+        (WebCore::RenderMathMLUnderOver::computeOperatorsHorizontalStretch): Browse the list of
+        RenderBox children, use auto* and remove unnecessary casts. Do not to specialize to
+        std::max<LayoutUnit>.
+
 2016-05-26  Chris Fleizach  <[email protected]>
 
         AX: crash at AccessibilityRenderObject::remoteSVGRootElement const

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp (201417 => 201418)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp	2016-05-26 07:54:41 UTC (rev 201417)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp	2016-05-26 09:14:20 UTC (rev 201418)
@@ -187,7 +187,7 @@
     numerator().layoutIfNeeded();
     denominator().layoutIfNeeded();
 
-    setLogicalWidth(std::max<LayoutUnit>(numerator().logicalWidth(), denominator().logicalWidth()));
+    setLogicalWidth(std::max(numerator().logicalWidth(), denominator().logicalWidth()));
 
     LayoutPoint numeratorLocation(horizontalOffset(numerator(), m_numeratorAlign), verticalOffset);
     numerator().setLocation(numeratorLocation);

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp (201417 => 201418)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp	2016-05-26 07:54:41 UTC (rev 201417)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp	2016-05-26 09:14:20 UTC (rev 201418)
@@ -51,7 +51,7 @@
 
 void RenderMathMLRow::updateOperatorProperties()
 {
-    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
+    for (auto* child = firstChildBox(); child; child = child->nextSiblingBox()) {
         if (is<RenderMathMLBlock>(*child)) {
             if (auto* renderOperator = downcast<RenderMathMLBlock>(*child).unembellishedOperator())
                 renderOperator->updateOperatorProperties();
@@ -84,8 +84,8 @@
         LayoutUnit childHeightAboveBaseline = ascentForChild(*child);
         LayoutUnit childDepthBelowBaseline = child->logicalHeight() - childHeightAboveBaseline;
 
-        ascent = std::max<LayoutUnit>(ascent, childHeightAboveBaseline);
-        descent = std::max<LayoutUnit>(descent, childDepthBelowBaseline);
+        ascent = std::max(ascent, childHeightAboveBaseline);
+        descent = std::max(descent, childDepthBelowBaseline);
     }
 
     // We ensure a minimal stretch size.

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp (201417 => 201418)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp	2016-05-26 07:54:41 UTC (rev 201417)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp	2016-05-26 09:14:20 UTC (rev 201418)
@@ -55,7 +55,7 @@
 
 RenderMathMLOperator* RenderMathMLUnderOver::unembellishedOperator()
 {
-    RenderObject* base = firstChild();
+    auto* base = firstChildBox();
     if (!is<RenderMathMLBlock>(base))
         return nullptr;
     return downcast<RenderMathMLBlock>(*base).unembellishedOperator();
@@ -75,7 +75,7 @@
     LayoutUnit stretchWidth = 0;
     Vector<RenderMathMLOperator*, 2> renderOperators;
 
-    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
+    for (auto* child = firstChildBox(); child; child = child->nextSiblingBox()) {
         if (child->needsLayout()) {
             if (is<RenderMathMLBlock>(child)) {
                 if (auto renderOperator = downcast<RenderMathMLBlock>(*child).unembellishedOperator()) {
@@ -86,13 +86,12 @@
                 }
             }
 
-            downcast<RenderElement>(*child).layout();
+            child->layout();
         }
 
         // Skipping the embellished op does not work for nested structures like
         // <munder><mover><mo>_</mo>...</mover> <mo>_</mo></munder>.
-        if (is<RenderBox>(*child))
-            stretchWidth = std::max<LayoutUnit>(stretchWidth, downcast<RenderBox>(*child).logicalWidth());
+        stretchWidth = std::max(stretchWidth, child->logicalWidth());
     }
 
     // Set the sizes of (possibly embellished) stretchy operator children.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to