Skip to content
Permalink
Browse files
Refactor RenderMathMLRoot layout function to avoid using flexbox
https://bugs.webkit.org/show_bug.cgi?id=153987

Patch by Frederic Wang <fwang@igalia.com> on 2016-06-17
Reviewed by Brent Fulgham.

Source/WebCore:

No new tests, already covered by existing tests.
A case for RTL root has been added to roots.xhtml.

We reimplement RenderMathMLRoot without any flexbox or anonymous.
The anonymous RenderMathMLRadicalOperator used to draw the radical sign is replaced with
the MathOperator class introduced in bug 152244.
msqrt (row of children under a square root) is now implemented directly in RenderMathMLRoot,
so RenderMathMLSquareRoot is removed and RenderMathMLRoot now inherits from RenderMathMLRow.

* CMakeLists.txt: Remove files for RenderMathMLRadicalOperator and RenderMathMLSquareRoot.
* WebCore.xcodeproj/project.pbxproj: ditto.
* accessibility/AccessibilityRenderObject.cpp: Update code now that we do not use any
radical wrappers.
(WebCore::AccessibilityRenderObject::isMathRow): Now that RenderMathMLRoot inherits from
RenderMathMLRow, we must exclude MathRoot or otherwise some accessibility code may treat
roots as rows.
(WebCore::AccessibilityRenderObject::mathRadicandObject): Return the first child for
Root/SquareRoot or nullptr.
(WebCore::AccessibilityRenderObject::mathRootIndexObject): Return the second child for
Root and nullptr for SquareRoot.
* mathml/MathMLInlineContainerElement.cpp:
(WebCore::MathMLInlineContainerElement::childrenChanged): We no longer need a special case
for msqrt, it is treated as a normal RenderMathMLRow.
(WebCore::MathMLInlineContainerElement::createElementRenderer): Make msqrt create a
RenderMathMLRoot object.
* rendering/RenderObject.h:
(WebCore::RenderObject::isRenderMathMLRadicalOperator): Deleted.
* rendering/mathml/RenderMathMLBlock.cpp:
(WebCore::RenderMathMLBlock::mirrorIfNeeded): New function to mirror a child horizontal
offset according to the parent width.
(WebCore::RenderMathMLBlock::renderName):
* rendering/mathml/RenderMathMLBlock.h:
(WebCore::RenderMathMLBlock::mirrorIfNeeded): Moved from RenderMathMLScripts, just forward
call to the other mirrorIfNeeded function.
* rendering/mathml/RenderMathMLOperator.cpp: We no longer need this trailingSpaceError hack.
(WebCore::RenderMathMLOperator::trailingSpaceError): Deleted.
* rendering/mathml/RenderMathMLOperator.h: ditto.
* rendering/mathml/RenderMathMLRadicalOperator.cpp: Removed. The radical sign is now drawn
with a MathOperator.
* rendering/mathml/RenderMathMLRadicalOperator.h: Removed.
* rendering/mathml/RenderMathMLRoot.cpp: Complete refactoring to avoid using flexbox and
anonymous wrappers.
(WebCore::RenderMathMLRoot::RenderMathMLRoot): Set m_kind parameters to distinguish between
square root and general root and set the MathOperator member to draw the radical sign.
(WebCore::RenderMathMLRoot::isValid): Helper function to verify whether the child list is valid.
(WebCore::RenderMathMLRoot::getBase): Get the base of an mroot.
(WebCore::RenderMathMLRoot::getIndex): Get the index of an mroot.
(WebCore::RenderMathMLRoot::styleDidChange): Be sure to keep the style of the
MathOperator in sync with ours ; no need to skip empty roots.
(WebCore::RenderMathMLRoot::updateFromElement): Call the function from the new parent class ;
no need to skip empty roots.
(WebCore::RenderMathMLRoot::updateStyle): Remove the isEmpty ASSERT as it is valid to have
empty square root. Set the m_kernBeforeDegree, m_kernBeforeDegree members.
No need to set style for anonymous.
(WebCore::RenderMathMLRoot::computePreferredLogicalWidths): Implement this function.
(WebCore::RenderMathMLRoot::layoutBlock): Implement this function.
(WebCore::RenderMathMLRoot::paintChildren): Implement this function.
(WebCore::RenderMathMLRoot::paint): Remove the trailingSpaceError hack ;
paint the radical sign via MathOperator::paint
(WebCore::RenderMathMLRoot::baseWrapper): Deleted.
(WebCore::RenderMathMLRoot::radicalWrapper): Deleted.
(WebCore::RenderMathMLRoot::indexWrapper): Deleted.
(WebCore::RenderMathMLRoot::radicalOperator): Deleted.
(WebCore::RenderMathMLRoot::restructureWrappers): Deleted.
(WebCore::RenderMathMLRoot::addChild): Deleted.
(WebCore::RenderMathMLRoot::firstLineBaseline): Deleted.
(WebCore::RenderMathMLRoot::layout): Deleted.
(WebCore::RenderMathMLRootWrapper::createAnonymousWrapper): Deleted.
(WebCore::RenderMathMLRootWrapper::removeChildWithoutRestructuring): Deleted.
(WebCore::RenderMathMLRootWrapper::removeChild): Deleted.
* rendering/mathml/RenderMathMLRoot.h: Make RenderMathMLRoot inherit from RenderMathMLRow.
Make RenderMathMLRoot support <msqrt>.
Remove all the anonymous wrapper stuff and instead use a MathOperator for the radical symbol.
Update function declaration to implement layout without flexbox and add some helper functions.
* rendering/mathml/RenderMathMLRow.cpp: Allow to get the exact metrics of the chid row,
for use in RenderMathMLRoot.
(WebCore::RenderMathMLRow::computeLineVerticalStretch): rename parameters.
(WebCore::RenderMathMLRow::layoutRowItems): Set parameters to the final ascent, descent and
logical width of the chid row. Set the temporary logical width for RenderMathRoot before
laying the children out.
(WebCore::RenderMathMLRow::layoutBlock): Rename parameters ; add a dummy logicalWidth
parameter.
* rendering/mathml/RenderMathMLRow.h: Make some functions accessible or overridable by
RenderMathMLRoot. Make layoutRowItems return the final ascent, descent and logical width
after the chid row is laid out.
* rendering/mathml/RenderMathMLScripts.cpp: Move mirrorIfNeeded to RenderMathMLBlock.
(WebCore::RenderMathMLScripts::mirrorIfNeeded): Deleted.
* rendering/mathml/RenderMathMLScripts.h: Move mirrorIfNeeded to RenderMathMLBlock.
* rendering/mathml/RenderMathMLSquareRoot.cpp: Removed.
* rendering/mathml/RenderMathMLSquareRoot.h: Removed.
* rendering/mathml/MathOperator.cpp:
(WebCore::MathOperator::paint): Apply a mirroring scale transform to radical symbol
in RTL direction.

LayoutTests:

Update expectations for some MathML tests containing radical operators.

* TestExpectations: mathml/roots-removeChild.html works as expected now
that we do not manage anonymous wrappers anymore.
* mathml/presentation/roots.xhtml: Add one test for RTL roots.
* platform/gtk/mathml/presentation/mo-stretch-expected.txt: Update expectation to
take into change in the render tree.
* platform/gtk/mathml/presentation/roots-expected.txt: Ditto.
* platform/gtk/mathml/presentation/roots-expected.png: Update expectation to take
into account small rendering changes.
* platform/ios-simulator/mathml/presentation/roots-expected.txt: Ditto.
* platform/gtk/mathml/radical-fallback-expected.txt: Ditto.
* platform/gtk/mathml/radical-fallback-expected.png: Ditto.
* platform/mac/mathml/radical-fallback-expected.txt: Ditto.
* platform/mac/mathml/radical-fallback-expected.png: Ditto.
* platform/ios-simulator/mathml/radical-fallback-expected.txt: Ditto.
* platform/ios-simulator/mathml/radical-fallback-expected.png: Added.

Canonical link: https://commits.webkit.org/176946@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202168 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
fred-wang committed Jun 17, 2016
1 parent bee6b94 commit 030b99e43dce303320d5a0dbab5f4e4867fa444f
Showing 32 changed files with 1,610 additions and 1,903 deletions.
@@ -1,3 +1,28 @@
2016-06-17 Frederic Wang <fwang@igalia.com>

Refactor RenderMathMLRoot layout function to avoid using flexbox
https://bugs.webkit.org/show_bug.cgi?id=153987

Reviewed by Brent Fulgham.

Update expectations for some MathML tests containing radical operators.

* TestExpectations: mathml/roots-removeChild.html works as expected now
that we do not manage anonymous wrappers anymore.
* mathml/presentation/roots.xhtml: Add one test for RTL roots.
* platform/gtk/mathml/presentation/mo-stretch-expected.txt: Update expectation to
take into change in the render tree.
* platform/gtk/mathml/presentation/roots-expected.txt: Ditto.
* platform/gtk/mathml/presentation/roots-expected.png: Update expectation to take
into account small rendering changes.
* platform/ios-simulator/mathml/presentation/roots-expected.txt: Ditto.
* platform/gtk/mathml/radical-fallback-expected.txt: Ditto.
* platform/gtk/mathml/radical-fallback-expected.png: Ditto.
* platform/mac/mathml/radical-fallback-expected.txt: Ditto.
* platform/mac/mathml/radical-fallback-expected.png: Ditto.
* platform/ios-simulator/mathml/radical-fallback-expected.txt: Ditto.
* platform/ios-simulator/mathml/radical-fallback-expected.png: Added.

2016-06-17 Romain Bellessort <romain.bellessort@crf.canon.fr>

Update test-expected file for failing fullscreen test
@@ -115,9 +115,6 @@ webkit.org/b/126166 [ Debug ] js/dfg-uint32array-overflow-values.html [ Skip ]

webkit.org/b/127860 [ Debug ] js/function-apply-aliased.html [ Skip ]

# This test verifies dynamic manipulation of the mroot and msqrt elements.
mathml/roots-removeChild.html [ ImageOnlyFailure ]

# For now we ignore margin/padding/border properties of MathML renderers.
mathml/presentation/bug97990.html [ Skip ]

@@ -171,6 +171,70 @@
</mroot>
</math>
</p>
<p id='t10'>RTL roots:
<math xmlns="http://www.w3.org/1998/Math/MathML" dir="rtl">
<mroot>
<mrow>
<mn>1</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>2</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>3</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>4</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>5</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>6</mn>
<mo>+</mo>
<mroot>
<mrow>
<mn>7</mn>
<mo>+</mo>
<mroot>
<mi>A</mi>
<mfrac>
<mrow>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
</mrow>
<mi>z</mi>
</mfrac>
</mroot>
</mrow>
<mn>9</mn>
</mroot>
</mrow>
<mn>8</mn>
</mroot>
</mrow>
<mn>7</mn>
</mroot>
</mrow>
<mn>6</mn>
</mroot>
</mrow>
<mn>5</mn>
</mroot>
</mrow>
<mn>4</mn>
</mroot>
</mrow>
<mn>3</mn>
</mroot>
</math>
</p>

</body>
</html>
@@ -305,83 +305,76 @@ layer at (0,0) size 800x270
text run at (524,97) width 5: " "
RenderBR {BR} at (0,0) size 0x0
RenderMathMLMath {math} at (0,179) size 190x76 [padding: 0 1 0 1]
RenderMathMLSquareRoot {msqrt} at (1,0) size 188x76
RenderMathMLBlock (anonymous, flex) at (0,0) size 17x76
RenderMathMLRadicalOperator (anonymous) at (0,0) size 17x76
RenderMathMLBlock (anonymous, flex) at (0,0) size 13x75
RenderBlock (anonymous) at (0,0) size 13x75
RenderText at (0,-56) size 13x106
text run at (0,-56) width 13: "\x{221A}"
RenderMathMLRootWrapper at (17,2) size 171x74
RenderMathMLOperator {mo} at (0,0) size 14x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 14x16
RenderBlock (anonymous) at (0,0) size 6x16
RenderText at (0,-45) size 6x106
text run at (0,-45) width 6: "("
RenderMathMLOperator {mo} at (14,0) size 14x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 14x16
RenderBlock (anonymous) at (0,0) size 6x16
RenderText at (0,-45) size 6x106
text run at (0,-45) width 6: ")"
RenderMathMLOperator {mo} at (28,0) size 14x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 14x16
RenderBlock (anonymous) at (0,0) size 8x16
RenderText at (0,-45) size 8x106
text run at (0,-45) width 8: "{"
RenderMathMLOperator {mo} at (42,0) size 14x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 14x16
RenderBlock (anonymous) at (0,0) size 8x16
RenderText at (0,-45) size 8x106
text run at (0,-45) width 8: "}"
RenderMathMLOperator {mo} at (56,0) size 11x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 4x16
RenderText at (0,-45) size 4x106
text run at (0,-45) width 4: "["
RenderMathMLOperator {mo} at (67,0) size 11x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 4x16
RenderText at (0,-45) size 4x106
text run at (0,-45) width 4: "]"
RenderMathMLOperator {mo} at (78,0) size 11x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 7x16
RenderText at (0,-45) size 7x106
text run at (0,-45) width 7: "\x{2308}"
RenderMathMLOperator {mo} at (89,0) size 11x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 7x16
RenderText at (0,-45) size 7x106
text run at (0,-45) width 7: "\x{2309}"
RenderMathMLOperator {mo} at (100,0) size 11x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 7x16
RenderText at (0,-45) size 7x106
text run at (0,-45) width 7: "\x{230A}"
RenderMathMLOperator {mo} at (111,0) size 11x73
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 7x16
RenderText at (0,-45) size 7x106
text run at (0,-45) width 7: "\x{230B}"
RenderMathMLOperator {mo} at (122,18) size 17x36
RenderMathMLBlock (anonymous, flex) at (0,0) size 16x18
RenderBlock (anonymous) at (0,0) size 11x18
RenderText at (0,-44) size 11x106
text run at (0,-44) width 11: "\x{222B}"
RenderMathMLOperator {mo} at (138,0) size 9x73
RenderMathMLBlock (anonymous, flex) at (1,0) size 5x16
RenderBlock (anonymous) at (0,0) size 4x16
RenderText at (0,-45) size 4x106
text run at (0,-45) width 4: "|"
RenderMathMLOperator {mo} at (146,15) size 8x42
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x16
RenderBlock (anonymous) at (0,0) size 6x16
RenderText at (0,-45) size 6x106
text run at (0,-45) width 6: "\x{2016}"
RenderMathMLOperator {mo} at (153,15) size 18x42
RenderMathMLBlock (anonymous, flex) at (4,0) size 9x16
RenderBlock (anonymous) at (0,0) size 8x16
RenderText at (0,-45) size 8x106
text run at (0,-45) width 8: "\x{2225}"
RenderMathMLSpace {mspace} at (170,0) size 0x41
RenderMathMLRoot {msqrt} at (1,0) size 188x76
RenderMathMLOperator {mo} at (17,2) size 14x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 14x16
RenderBlock (anonymous) at (0,0) size 6x16
RenderText at (0,-45) size 6x106
text run at (0,-45) width 6: "("
RenderMathMLOperator {mo} at (31,2) size 14x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 14x16
RenderBlock (anonymous) at (0,0) size 6x16
RenderText at (0,-45) size 6x106
text run at (0,-45) width 6: ")"
RenderMathMLOperator {mo} at (45,2) size 14x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 14x16
RenderBlock (anonymous) at (0,0) size 8x16
RenderText at (0,-45) size 8x106
text run at (0,-45) width 8: "{"
RenderMathMLOperator {mo} at (59,2) size 14x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 14x16
RenderBlock (anonymous) at (0,0) size 8x16
RenderText at (0,-45) size 8x106
text run at (0,-45) width 8: "}"
RenderMathMLOperator {mo} at (73,2) size 11x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 4x16
RenderText at (0,-45) size 4x106
text run at (0,-45) width 4: "["
RenderMathMLOperator {mo} at (84,2) size 11x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 4x16
RenderText at (0,-45) size 4x106
text run at (0,-45) width 4: "]"
RenderMathMLOperator {mo} at (95,2) size 11x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 7x16
RenderText at (0,-45) size 7x106
text run at (0,-45) width 7: "\x{2308}"
RenderMathMLOperator {mo} at (106,2) size 11x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 7x16
RenderText at (0,-45) size 7x106
text run at (0,-45) width 7: "\x{2309}"
RenderMathMLOperator {mo} at (117,2) size 11x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 7x16
RenderText at (0,-45) size 7x106
text run at (0,-45) width 7: "\x{230A}"
RenderMathMLOperator {mo} at (128,2) size 11x74
RenderMathMLBlock (anonymous, flex) at (0,0) size 11x16
RenderBlock (anonymous) at (0,0) size 7x16
RenderText at (0,-45) size 7x106
text run at (0,-45) width 7: "\x{230B}"
RenderMathMLOperator {mo} at (139,20) size 17x37
RenderMathMLBlock (anonymous, flex) at (0,0) size 16x18
RenderBlock (anonymous) at (0,0) size 11x18
RenderText at (0,-44) size 11x106
text run at (0,-44) width 11: "\x{222B}"
RenderMathMLOperator {mo} at (155,2) size 9x74
RenderMathMLBlock (anonymous, flex) at (1,0) size 5x16
RenderBlock (anonymous) at (0,0) size 4x16
RenderText at (0,-45) size 4x106
text run at (0,-45) width 4: "|"
RenderMathMLOperator {mo} at (163,17) size 8x43
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x16
RenderBlock (anonymous) at (0,0) size 6x16
RenderText at (0,-45) size 6x106
text run at (0,-45) width 6: "\x{2016}"
RenderMathMLOperator {mo} at (170,17) size 18x43
RenderMathMLBlock (anonymous, flex) at (4,0) size 9x16
RenderBlock (anonymous) at (0,0) size 8x16
RenderText at (0,-45) size 8x106
text run at (0,-45) width 8: "\x{2225}"
RenderMathMLSpace {mspace} at (187,2) size 0x42
RenderText {#text} at (0,0) size 0x0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 030b99e

Please sign in to comment.