Title: [205099] trunk/Source/WebCore
Revision
205099
Author
[email protected]
Date
2016-08-28 01:41:13 -0700 (Sun, 28 Aug 2016)

Log Message

RenderMathMLRow::firstLineBaseline does not need to be overridden in RenderMathMLMenclose
https://bugs.webkit.org/show_bug.cgi?id=161127

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

RenderMathMLRow::firstLineBaseline already provides the correct calculation of ascent for
non-empty menclose elements. Empty menclose elements are not used in practice so the
calculated value is irrelevant. Aligning on mrow (i.e. leaving firstLineBaseline to 0)
is fine. This change allows to get rid of the m_ascent member and helps to keep good baseline
alignment when the zoom level changes (bug 161126).

No new tests, already covered by existing tests.

* rendering/mathml/RenderMathMLMenclose.cpp:
(WebCore::RenderMathMLMenclose::RenderMathMLMenclose): Remove initialization of m_ascent.
(WebCore::RenderMathMLMenclose::layoutBlock): No need to calculate m_ascent. The height and
content location can be determined without introducing local variables ascent or descent.
(WebCore::RenderMathMLMenclose::firstLineBaseline): Deleted. We just use the implementation
from RenderMathMLRow.
* rendering/mathml/RenderMathMLMenclose.h: Delete m_ascent and do not override
firstLineBaseline.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (205098 => 205099)


--- trunk/Source/WebCore/ChangeLog	2016-08-28 08:26:07 UTC (rev 205098)
+++ trunk/Source/WebCore/ChangeLog	2016-08-28 08:41:13 UTC (rev 205099)
@@ -1,5 +1,29 @@
 2016-08-28  Frederic Wang  <[email protected]>
 
+        RenderMathMLRow::firstLineBaseline does not need to be overridden in RenderMathMLMenclose
+        https://bugs.webkit.org/show_bug.cgi?id=161127
+
+        Reviewed by Darin Adler.
+
+        RenderMathMLRow::firstLineBaseline already provides the correct calculation of ascent for
+        non-empty menclose elements. Empty menclose elements are not used in practice so the
+        calculated value is irrelevant. Aligning on mrow (i.e. leaving firstLineBaseline to 0)
+        is fine. This change allows to get rid of the m_ascent member and helps to keep good baseline
+        alignment when the zoom level changes (bug 161126).
+
+        No new tests, already covered by existing tests.
+
+        * rendering/mathml/RenderMathMLMenclose.cpp:
+        (WebCore::RenderMathMLMenclose::RenderMathMLMenclose): Remove initialization of m_ascent.
+        (WebCore::RenderMathMLMenclose::layoutBlock): No need to calculate m_ascent. The height and
+        content location can be determined without introducing local variables ascent or descent.
+        (WebCore::RenderMathMLMenclose::firstLineBaseline): Deleted. We just use the implementation
+        from RenderMathMLRow.
+        * rendering/mathml/RenderMathMLMenclose.h: Delete m_ascent and do not override
+        firstLineBaseline.
+
+2016-08-28  Frederic Wang  <[email protected]>
+
         More cleanup for the mpadded implementation
         https://bugs.webkit.org/show_bug.cgi?id=161136
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp (205098 => 205099)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp	2016-08-28 08:26:07 UTC (rev 205098)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp	2016-08-28 08:41:13 UTC (rev 205099)
@@ -44,7 +44,6 @@
 
 RenderMathMLMenclose::RenderMathMLMenclose(MathMLMencloseElement& element, RenderStyle&& style)
     : RenderMathMLRow(element, WTFMove(style))
-    , m_ascent(0)
 {
 }
 
@@ -175,24 +174,17 @@
     LayoutUnit leftSpace, rightSpace, topSpace, bottomSpace;
     getSpaceAroundContent(contentWidth, contentAscent + contentDescent, leftSpace, rightSpace, topSpace, bottomSpace);
     setLogicalWidth(leftSpace + contentWidth + rightSpace);
-    m_ascent = topSpace + contentAscent;
-    LayoutUnit descent = contentDescent + bottomSpace;
-    LayoutPoint contentLocation(leftSpace, m_ascent - contentAscent);
+    setLogicalHeight(topSpace + contentAscent + contentDescent + bottomSpace);
+
+    LayoutPoint contentLocation(leftSpace, topSpace);
     for (auto* child = firstChildBox(); child; child = child->nextSiblingBox())
         child->setLocation(child->location() + contentLocation);
 
-    setLogicalHeight(m_ascent + descent);
-
     m_contentRect = LayoutRect(leftSpace, topSpace, contentWidth, contentAscent + contentDescent);
 
     clearNeedsLayout();
 }
 
-Optional<int> RenderMathMLMenclose::firstLineBaseline() const
-{
-    return Optional<int>(static_cast<int>(lroundf(m_ascent)));
-}
-
 // GraphicsContext::drawLine does not seem appropriate to draw menclose lines.
 // To avoid unexpected behaviors and inconsistency with other notations, we just use strokePath.
 static void drawLine(PaintInfo& info, const LayoutUnit& xStart, const LayoutUnit& yStart, const LayoutUnit& xEnd, const LayoutUnit& yEnd)

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLMenclose.h (205098 => 205099)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLMenclose.h	2016-08-28 08:26:07 UTC (rev 205098)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLMenclose.h	2016-08-28 08:41:13 UTC (rev 205099)
@@ -41,7 +41,6 @@
     const char* renderName() const final { return "RenderMathMLMenclose"; }
     void computePreferredLogicalWidths() final;
     void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
-    Optional<int> firstLineBaseline() const final;
     void paint(PaintInfo&, const LayoutPoint&) final;
 
     LayoutUnit ruleThickness() const;
@@ -49,7 +48,6 @@
 
     void getSpaceAroundContent(LayoutUnit contentWidth, LayoutUnit contentHeight, LayoutUnit& leftSpace, LayoutUnit& rightSpace, LayoutUnit& topSpace, LayoutUnit& bottomSpace) const;
 
-    LayoutUnit m_ascent;
     LayoutRect m_contentRect;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to