Changeset 199544 in webkit


Ignore:
Timestamp:
Apr 14, 2016 11:04:44 AM (8 years ago)
Author:
fred.wang@free.fr
Message:

Ensure that RenderMathMLOperator::stretchTo functions are called with stretchy operators that have the correct direction
https://bugs.webkit.org/show_bug.cgi?id=156542

Patch by Frederic Wang <fwang@igalia.com> on 2016-04-14
Reviewed by Darin Adler.

Source/WebCore:

In the RenderMathMLUnderOver refactoring (r199293), we avoided doing a
horizontal stretchTo call for non-stretchy operators. Here we do the
same for RenderMathMLRow and avoid doing a vertical stretchTo call for
horizontal or non-stretchy operators. We also add appropriate ASSERT in
the RenderMathMLOperator::stretchTo functions. To avoid failing tests
with DOM/style update, we make our updates a bit stricter. Hopefully,
we could manage such things better in the future (bug 156536).

Tests: mathml/presentation/row-nonstretchy-or-horizontal.html

mathml/presentation/underover-nonstretchy-or-vertical.html

  • mathml/MathMLTextElement.cpp:

(WebCore::MathMLTextElement::parseAttribute): Replace setOperatorFlagAndScheduleLayoutIfNeeded with a stronger rendering update.
Also ensure that this is done when the lspace/rspace attributes change.
This avoids breaking mathml/presentation/mo-lspace-rspace-dynamic.html

  • rendering/mathml/RenderMathMLOperator.cpp:

(WebCore::RenderMathMLOperator::stretchTo): Add ASSERT to ensure that it is only called with stretchy operators that have the correct direction.
(WebCore::RenderMathMLOperator::styleDidChange): Do a stronger rendering update when the style changes.
This avoids breaking mathml/presentation/style-changed.html
(WebCore::RenderMathMLOperator::setOperatorFlagAndScheduleLayoutIfNeeded): Deleted.

  • rendering/mathml/RenderMathMLOperator.h: Make updateFromElement public so that it can be called from MathMLTextElement::parseAttribute

Remove setOperatorFlagAndScheduleLayoutIfNeeded and declare styleDidChange.

  • rendering/mathml/RenderMathMLRow.cpp:

(WebCore::RenderMathMLRow::layoutRowItems): Only call stretchTo for vertical stretchy operators.

LayoutTests:

Add a test to ensure that nonstretchy or horizontal operators in a
RenderMathMLRow do not stretch. This is similar to the existing test
for munderover and we improve a bit that one too.
Besides the verification of the rendering, these two tests will also
check that the RenderMathMLOperator::stretchTo calls are not done in a
way that violates the ASSERT at the top of stretchTo.

  • mathml/presentation/row-nonstretchy-or-horizontal.html: Added.
  • mathml/presentation/row-nonstretchy-or-horizontal-expected.html: Added.
  • mathml/presentation/underover-nonstretchy-horizontal.html: Removed.
  • mathml/presentation/underover-nonstretchy-horizontal-expected.html: Removed.
  • mathml/presentation/underover-nonstretchy-or-vertical.html: Renamed from LayoutTests/mathml/presentation/underover-nonstretchy-horizontal.html.

We now also test the case of vertical operators in munderover.

  • mathml/presentation/underover-nonstretchy-or-vertical-expected.html: Renamed from LayoutTests/mathml/presentation/underover-nonstretchy-horizontal-expected.html.
Location:
trunk
Files:
3 added
1 deleted
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r199539 r199544  
     12016-04-14  Frederic Wang  <fwang@igalia.com>
     2
     3        Ensure that RenderMathMLOperator::stretchTo functions are called with stretchy operators that have the correct direction
     4        https://bugs.webkit.org/show_bug.cgi?id=156542
     5
     6        Reviewed by Darin Adler.
     7
     8        Add a test to ensure that nonstretchy or horizontal operators in a
     9        RenderMathMLRow do not stretch. This is similar to the existing test
     10        for munderover and we improve a bit that one too.
     11        Besides the verification of the rendering, these two tests will also
     12        check that the RenderMathMLOperator::stretchTo calls are not done in a
     13        way that violates the ASSERT at the top of stretchTo.
     14
     15        * mathml/presentation/row-nonstretchy-or-horizontal.html: Added.
     16        * mathml/presentation/row-nonstretchy-or-horizontal-expected.html: Added.
     17        * mathml/presentation/underover-nonstretchy-horizontal.html: Removed.
     18        * mathml/presentation/underover-nonstretchy-horizontal-expected.html: Removed.
     19        * mathml/presentation/underover-nonstretchy-or-vertical.html: Renamed from LayoutTests/mathml/presentation/underover-nonstretchy-horizontal.html.
     20        We now also test the case of vertical operators in munderover.
     21        * mathml/presentation/underover-nonstretchy-or-vertical-expected.html: Renamed from LayoutTests/mathml/presentation/underover-nonstretchy-horizontal-expected.html.
     22
    1232016-04-14  Darin Adler  <darin@apple.com>
    224
  • trunk/LayoutTests/mathml/presentation/underover-nonstretchy-or-vertical-expected.html

    r199543 r199544  
    11<!DOCTYPE html>
     2<p>Vertical or non-stretchy operators inside an munderover element should not stretch.</p>
    23<math>
    34  <munderover>
    45    <mspace width="100px" height="10px" mathbackground="red"/>
    5     <mtext>_</mtext>
     6    <mtext>|</mtext>
    67    <mtext>_</mtext>
    78  </munderover>
  • trunk/Source/WebCore/ChangeLog

    r199540 r199544  
     12016-04-14  Frederic Wang  <fwang@igalia.com>
     2
     3        Ensure that RenderMathMLOperator::stretchTo functions are called with stretchy operators that have the correct direction
     4        https://bugs.webkit.org/show_bug.cgi?id=156542
     5
     6        Reviewed by Darin Adler.
     7
     8        In the RenderMathMLUnderOver refactoring (r199293), we avoided doing a
     9        horizontal stretchTo call for non-stretchy operators. Here we do the
     10        same for RenderMathMLRow and avoid doing a vertical stretchTo call for
     11        horizontal or non-stretchy operators. We also add appropriate ASSERT in
     12        the RenderMathMLOperator::stretchTo functions. To avoid failing tests
     13        with DOM/style update, we make our updates a bit stricter. Hopefully,
     14        we could manage such things better in the future (bug 156536).
     15
     16        Tests: mathml/presentation/row-nonstretchy-or-horizontal.html
     17               mathml/presentation/underover-nonstretchy-or-vertical.html
     18
     19        * mathml/MathMLTextElement.cpp:
     20        (WebCore::MathMLTextElement::parseAttribute): Replace setOperatorFlagAndScheduleLayoutIfNeeded with a stronger rendering update.
     21        Also ensure that this is done when the lspace/rspace attributes change.
     22        This avoids breaking mathml/presentation/mo-lspace-rspace-dynamic.html
     23        * rendering/mathml/RenderMathMLOperator.cpp:
     24        (WebCore::RenderMathMLOperator::stretchTo): Add ASSERT to ensure that it is only called with stretchy operators that have the correct direction.
     25        (WebCore::RenderMathMLOperator::styleDidChange): Do a stronger rendering update when the style changes.
     26        This avoids breaking mathml/presentation/style-changed.html
     27        (WebCore::RenderMathMLOperator::setOperatorFlagAndScheduleLayoutIfNeeded): Deleted.
     28        * rendering/mathml/RenderMathMLOperator.h: Make updateFromElement public so that it can be called from MathMLTextElement::parseAttribute
     29        Remove setOperatorFlagAndScheduleLayoutIfNeeded and declare styleDidChange.
     30        * rendering/mathml/RenderMathMLRow.cpp:
     31        (WebCore::RenderMathMLRow::layoutRowItems): Only call stretchTo for vertical stretchy operators.
     32
    1332016-04-14  Anders Carlsson  <andersca@apple.com>
    234
  • trunk/Source/WebCore/mathml/MathMLTextElement.cpp

    r194496 r199544  
    6767void MathMLTextElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
    6868{
    69     if (name == stretchyAttr) {
     69    if (name == stretchyAttr || name == lspaceAttr || name == rspaceAttr) {
    7070        if (is<RenderMathMLOperator>(renderer()))
    71             downcast<RenderMathMLOperator>(*renderer()).setOperatorFlagAndScheduleLayoutIfNeeded(MathMLOperatorDictionary::Stretchy, value);
     71            downcast<RenderMathMLOperator>(*renderer()).updateFromElement();
    7272        return;
    7373    }
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r194496 r199544  
    9595}
    9696
    97 void RenderMathMLOperator::setOperatorFlagAndScheduleLayoutIfNeeded(MathMLOperatorDictionary::Flag flag, const AtomicString& attributeValue)
    98 {
    99     unsigned short oldOperatorFlags = m_operatorFlags;
    100 
    101     setOperatorFlagFromAttributeValue(flag, attributeValue);
    102 
    103     if (oldOperatorFlags != m_operatorFlags)
    104         setNeedsLayoutAndPrefWidthsRecalc();
    105 }
    106 
    10797void RenderMathMLOperator::setOperatorFlagFromAttribute(MathMLOperatorDictionary::Flag flag, const QualifiedName& name)
    10898{
     
    216206void RenderMathMLOperator::stretchTo(LayoutUnit heightAboveBaseline, LayoutUnit depthBelowBaseline)
    217207{
     208    ASSERT(hasOperatorFlag(MathMLOperatorDictionary::Stretchy));
     209    ASSERT(m_isVertical);
     210
    218211    if (!m_isVertical || (heightAboveBaseline == m_stretchHeightAboveBaseline && depthBelowBaseline == m_stretchDepthBelowBaseline))
    219212        return;
     
    248241void RenderMathMLOperator::stretchTo(LayoutUnit width)
    249242{
     243    ASSERT(hasOperatorFlag(MathMLOperatorDictionary::Stretchy));
     244    ASSERT(!m_isVertical);
     245
    250246    if (m_isVertical || m_stretchWidth == width)
    251247        return;
     
    372368{
    373369    return m_textContent && (hasOperatorFlag(MathMLOperatorDictionary::Stretchy) || isLargeOperatorInDisplayStyle());
     370}
     371
     372void RenderMathMLOperator::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
     373{
     374    RenderMathMLBlock::styleDidChange(diff, oldStyle);
     375    updateOperatorProperties();
    374376}
    375377
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h

    r197566 r199544  
    5353    bool isVertical() const { return m_isVertical; }
    5454
     55    void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
    5556    void updateStyle() final;
    5657
     
    6061    void updateTokenContent() final;
    6162    void updateOperatorProperties();
    62     void setOperatorFlagAndScheduleLayoutIfNeeded(MathMLOperatorDictionary::Flag, const AtomicString& attributeValue);
     63    void updateFromElement() final;
    6364    LayoutUnit trailingSpaceError();
    6465
     
    138139    RenderMathMLOperator* unembellishedOperator() override { return this; }
    139140    void rebuildTokenContent(const String& operatorString);
    140     void updateFromElement() override;
    141141
    142142    bool shouldAllowStretching() const;
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp

    r198998 r199544  
    121121
    122122        if (is<RenderMathMLBlock>(child)) {
    123             if (auto renderOperator = downcast<RenderMathMLBlock>(child)->unembellishedOperator())
     123            auto renderOperator = downcast<RenderMathMLBlock>(child)->unembellishedOperator();
     124            if (renderOperator && renderOperator->hasOperatorFlag(MathMLOperatorDictionary::Stretchy) && renderOperator->isVertical())
    124125                renderOperator->stretchTo(stretchHeightAboveBaseline, stretchDepthBelowBaseline);
    125126        }
Note: See TracChangeset for help on using the changeset viewer.