Changeset 205099 in webkit


Ignore:
Timestamp:
Aug 28, 2016 1:41:13 AM (8 years ago)
Author:
fred.wang@free.fr
Message:

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

Patch by Frederic Wang <fwang@igalia.com> 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.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r205098 r205099  
     12016-08-28  Frederic Wang  <fwang@igalia.com>
     2
     3        RenderMathMLRow::firstLineBaseline does not need to be overridden in RenderMathMLMenclose
     4        https://bugs.webkit.org/show_bug.cgi?id=161127
     5
     6        Reviewed by Darin Adler.
     7
     8        RenderMathMLRow::firstLineBaseline already provides the correct calculation of ascent for
     9        non-empty menclose elements. Empty menclose elements are not used in practice so the
     10        calculated value is irrelevant. Aligning on mrow (i.e. leaving firstLineBaseline to 0)
     11        is fine. This change allows to get rid of the m_ascent member and helps to keep good baseline
     12        alignment when the zoom level changes (bug 161126).
     13
     14        No new tests, already covered by existing tests.
     15
     16        * rendering/mathml/RenderMathMLMenclose.cpp:
     17        (WebCore::RenderMathMLMenclose::RenderMathMLMenclose): Remove initialization of m_ascent.
     18        (WebCore::RenderMathMLMenclose::layoutBlock): No need to calculate m_ascent. The height and
     19        content location can be determined without introducing local variables ascent or descent.
     20        (WebCore::RenderMathMLMenclose::firstLineBaseline): Deleted. We just use the implementation
     21        from RenderMathMLRow.
     22        * rendering/mathml/RenderMathMLMenclose.h: Delete m_ascent and do not override
     23        firstLineBaseline.
     24
    1252016-08-28  Frederic Wang  <fwang@igalia.com>
    226
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp

    r204885 r205099  
    4545RenderMathMLMenclose::RenderMathMLMenclose(MathMLMencloseElement& element, RenderStyle&& style)
    4646    : RenderMathMLRow(element, WTFMove(style))
    47     , m_ascent(0)
    4847{
    4948}
     
    176175    getSpaceAroundContent(contentWidth, contentAscent + contentDescent, leftSpace, rightSpace, topSpace, bottomSpace);
    177176    setLogicalWidth(leftSpace + contentWidth + rightSpace);
    178     m_ascent = topSpace + contentAscent;
    179     LayoutUnit descent = contentDescent + bottomSpace;
    180     LayoutPoint contentLocation(leftSpace, m_ascent - contentAscent);
     177    setLogicalHeight(topSpace + contentAscent + contentDescent + bottomSpace);
     178
     179    LayoutPoint contentLocation(leftSpace, topSpace);
    181180    for (auto* child = firstChildBox(); child; child = child->nextSiblingBox())
    182181        child->setLocation(child->location() + contentLocation);
    183182
    184     setLogicalHeight(m_ascent + descent);
    185 
    186183    m_contentRect = LayoutRect(leftSpace, topSpace, contentWidth, contentAscent + contentDescent);
    187184
    188185    clearNeedsLayout();
    189 }
    190 
    191 Optional<int> RenderMathMLMenclose::firstLineBaseline() const
    192 {
    193     return Optional<int>(static_cast<int>(lroundf(m_ascent)));
    194186}
    195187
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLMenclose.h

    r204885 r205099  
    4242    void computePreferredLogicalWidths() final;
    4343    void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
    44     Optional<int> firstLineBaseline() const final;
    4544    void paint(PaintInfo&, const LayoutPoint&) final;
    4645
     
    5049    void getSpaceAroundContent(LayoutUnit contentWidth, LayoutUnit contentHeight, LayoutUnit& leftSpace, LayoutUnit& rightSpace, LayoutUnit& topSpace, LayoutUnit& bottomSpace) const;
    5150
    52     LayoutUnit m_ascent;
    5351    LayoutRect m_contentRect;
    5452};
Note: See TracChangeset for help on using the changeset viewer.