Skip to content

Commit

Permalink
Merge r174540 - RenderMathMLUnderOver adds spacing to the child opera…
Browse files Browse the repository at this point in the history
…tor indefinitely when resizing the window.

https://bugs.webkit.org/show_bug.cgi?id=137330

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2014-10-09
Reviewed by Darin Adler.

The layout for the <mundercover> math object happens in two separate passes. The first pass runs
the layout for the two children and then calculates the maximum child width.  It then sets the
stretch size for the math operator child.  And finally it runs the second layout pass by calling
the base class layout() function. The base class function then runs the layout for the children
rendering blocks.  In the operator child function computePreferredLogicalWidths(), the stretch
size is used to adjust the width (or the height) of the operator. Then it adds the leading and
trailing spaces and the total will be the operator child width.

When resizing or zooming the window, the render objects are just invalidated but marked as 'needs-
Layout'.  The problem is happening because the stretch size of the math operator is not reset
before running the layout.  The old logical width (or height) of the the math operator child which
is equal to the stretch size plus the leading and trailing spaces for is compared with the glyph
size if the old logical width ( or height) is larger, it is set to be the stretch size.  When it
is used again because of invalidation, new leading and trailing spaces are included in the new
logical width.  So with every zooming-in or out or window resizing, new leading and trailing
spaces are added to the logical width of the math operator child or the math <munderober> object.

Ensure the stretch size of the math operator render object is reset before running its layout.
Running the layout means either the page is just loaded or it's invalidated which means, no
layout stall data should be used.

Test: mathml/opentype/munderover-window-resize.html

* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::resetStretchSize):
* rendering/mathml/RenderMathMLOperator.h:
resetStretchSize() sets the stretch size to its original value when the class is created.
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::layout):
Make sure the operator stretch size is reset before calling its layout. Also make sure the new
maximum stretch size to the operator objects that were invalid and needsLayout.

LayoutTests:
RenderMathMLUnderOver adds spacing to the child operator indefinitely when zooming or resizing the window.
https://bugs.webkit.org/show_bug.cgi?id=137330

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2014-10-09
Reviewed by Darin Adler, Daniel Bates.

When the alignment is center, which is the common case for math, changing the size of
an object affects the position of this object also.  We need to confirm that zooming or
resizing the window should not affect the rectangle of the over/under math object operator.

* mathml/opentype/munderover-window-resize-expected.txt: Added.
* mathml/opentype/munderover-window-resize.html: Added.
New test with many under and over math objects.  After loading the page, the window is resized and
the view is zoomed in and out to make sure the layout of these under and over objects were not changed.
* platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt:
This test was wrong because of the spacing issue. The page has two <mover> math objects at the beginning.
Each of them has an <mspace> child. The width of the first <mspace> is 1em while the width of the second
<mspace> is 2em. The font size is 10pt. So it is expected to have the first one 10 pixels and the second
to be 20 pixels. In the test, the width of the first is 22 and the width of the second is 32.
I do expect this test to fail on other platforms since they have the same mistake which is now fixed. I am
going to submit the mac expected version only and when it fails I am going to collect the result and submit
another patch for the other platforms expected files.

Canonical link: https://commits.webkit.org/154760.134@webkitgtk/2.6
git-svn-id: https://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.6@175883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Said Abou-Hallawa authored and carlosgcampos committed Nov 11, 2014
1 parent 954388f commit 63c2c44
Show file tree
Hide file tree
Showing 8 changed files with 423 additions and 11 deletions.
24 changes: 24 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,27 @@
2014-10-09 Said Abou-Hallawa <sabouhallawa@apple.com>

RenderMathMLUnderOver adds spacing to the child operator indefinitely when zooming or resizing the window.
https://bugs.webkit.org/show_bug.cgi?id=137330

Reviewed by Darin Adler, Daniel Bates.

When the alignment is center, which is the common case for math, changing the size of
an object affects the position of this object also. We need to confirm that zooming or
resizing the window should not affect the rectangle of the over/under math object operator.

* mathml/opentype/munderover-window-resize-expected.txt: Added.
* mathml/opentype/munderover-window-resize.html: Added.
New test with many under and over math objects. After loading the page, the window is resized and
the view is zoomed in and out to make sure the layout of these under and over objects were not changed.
* platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt:
This test was wrong because of the spacing issue. The page has two <mover> math objects at the beginning.
Each of them has an <mspace> child. The width of the first <mspace> is 1em while the width of the second
<mspace> is 2em. The font size is 10pt. So it is expected to have the first one 10 pixels and the second
to be 20 pixels. In the test, the width of the first is 22 and the width of the second is 32.
I do expect this test to fail on other platforms since they have the same mistake which is now fixed. I am
going to submit the mac expected version only and when it fails I am going to collect the result and submit
another patch for the other platforms expected files.

2014-09-22 Simon Fraser <simon.fraser@apple.com>

Move nodeFromPoint() back to Document where it belongs
Expand Down
220 changes: 220 additions & 0 deletions LayoutTests/mathml/opentype/munderover-window-resize-expected.txt
@@ -0,0 +1,220 @@
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x40
RenderBlock {HTML} at (0,0) size 800x40
RenderBody {BODY} at (8,8) size 784x22
RenderBlock {DIV} at (0,0) size 784x22
RenderMathMLMath {math} at (0,0) size 784x22 [padding: 0 1 0 1]
RenderMathMLRow {mrow} at (268,4) size 26x16
RenderMathMLScripts {mmultiscripts} at (0,0) size 26x16
Base Wrapper at (8,0) size 9x16 [padding: 2 0 4 0]
RenderMathMLToken {mi} at (0,2) size 8x9 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x9
RenderBlock (anonymous) at (0,0) size 7x9
RenderText {#text} at (0,3) size 7x10
text run at (0,3) width 7: "C"
SubSupPair Wrapper at (16,0) size 10x16
RenderMathMLBlock (flex) {none} at (0,15) size 0x0
RenderMathMLToken {mi} at (0,0) size 9x7 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 8x7
RenderBlock (anonymous) at (0,0) size 8x7
RenderText {#text} at (0,2) size 8x8
text run at (0,2) width 8: "16"
RenderMathMLBlock (flex) {mprescripts} at (25,0) size 0x16
SubSupPair Wrapper at (0,0) size 9x16
RenderMathMLToken {mi} at (4,8) size 5x8 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 4x7
RenderBlock (anonymous) at (0,0) size 4x7
RenderText {#text} at (0,2) size 4x8
text run at (0,2) width 4: "5"
RenderMathMLToken {mi} at (0,0) size 9x7 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 8x7
RenderBlock (anonymous) at (0,0) size 8x7
RenderText {#text} at (0,2) size 8x8
text run at (0,2) width 8: "10"
RenderMathMLSpace {mspace} at (293,14) size 6x0
RenderMathMLRow {mrow} at (298,6) size 40x14
RenderMathMLToken {mn} at (0,0) size 6x9
RenderMathMLBlock (anonymous, flex) at (0,0) size 6x9
RenderBlock (anonymous) at (0,0) size 6x9
RenderText {#text} at (0,3) size 6x10
text run at (0,3) width 6: "2"
RenderMathMLOperator {mo} at (6,8) size 0x1
RenderMathMLBlock (anonymous, flex) at (0,0) size 0x1
RenderBlock (anonymous) at (0,0) size 0x1
RenderText at (0,-5) size 0x10
text run at (0,-5) width 0: "\x{2062}"
RenderMathMLScripts {msub} at (6,0) size 11x14
Base Wrapper at (0,0) size 7x14 [padding: 0 0 4 0]
RenderMathMLToken {mi} at (0,0) size 7x9
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x9
RenderBlock (anonymous) at (0,0) size 7x9
RenderText {#text} at (0,3) size 7x10
text run at (0,3) width 7: "H"
SubSupPair Wrapper at (7,0) size 4x14
RenderMathMLToken {mn} at (0,6) size 4x8
RenderMathMLBlock (anonymous, flex) at (0,0) size 4x7
RenderBlock (anonymous) at (0,0) size 4x7
RenderText {#text} at (0,2) size 4x8
text run at (0,2) width 4: "2"
RenderMathMLOperator {mo} at (17,2) size 11x7
RenderMathMLBlock (anonymous, flex) at (2,0) size 7x7
RenderBlock (anonymous) at (0,0) size 6x7
RenderText at (0,1) size 6x10
text run at (0,1) width 6: "+"
RenderMathMLScripts {msub} at (27,0) size 13x14
Base Wrapper at (0,0) size 8x14 [padding: 0 0 4 0]
RenderMathMLToken {mi} at (0,0) size 8x9
RenderMathMLBlock (anonymous, flex) at (0,0) size 8x9
RenderBlock (anonymous) at (0,0) size 8x9
RenderText {#text} at (0,3) size 8x10
text run at (0,3) width 8: "O"
SubSupPair Wrapper at (8,0) size 4x14
RenderMathMLToken {mn} at (0,6) size 4x8
RenderMathMLBlock (anonymous, flex) at (0,0) size 4x7
RenderBlock (anonymous) at (0,0) size 4x7
RenderText {#text} at (0,2) size 4x8
text run at (0,2) width 4: "2"
RenderMathMLUnderOver {mover} at (338,1) size 22x14
RenderMathMLOperator {mo} at (0,7) size 22x7
RenderMathMLBlock (anonymous, flex) at (2,0) size 17x7
RenderBlock (anonymous) at (0,0) size 10x7
RenderText at (0,1) size 10x10
text run at (0,1) width 10: "\x{2192}"
RenderMathMLRow {mrow} at (2,0) size 17x7
RenderMathMLToken {mi} at (0,0) size 8x6 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x6
RenderBlock (anonymous) at (0,0) size 7x6
RenderText {#text} at (0,1) size 7x8
text run at (0,1) width 7: "m"
RenderMathMLOperator {mo} at (7,4) size 4x3
RenderMathMLBlock (anonymous, flex) at (0,0) size 2x3
RenderBlock (anonymous) at (0,0) size 2x3
RenderText at (0,-3) size 2x8
text run at (0,-3) width 2: ","
RenderMathMLToken {mi} at (11,0) size 5x6 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 4x6
RenderBlock (anonymous) at (0,0) size 4x6
RenderText {#text} at (0,1) size 4x8
text run at (0,1) width 4: "n"
RenderMathMLRow {mrow} at (359,6) size 27x14
RenderMathMLToken {mn} at (0,0) size 6x9
RenderMathMLBlock (anonymous, flex) at (0,0) size 6x9
RenderBlock (anonymous) at (0,0) size 6x9
RenderText {#text} at (0,3) size 6x10
text run at (0,3) width 6: "2"
RenderMathMLOperator {mo} at (6,8) size 0x1
RenderMathMLBlock (anonymous, flex) at (0,0) size 0x1
RenderBlock (anonymous) at (0,0) size 0x1
RenderText at (0,-5) size 0x10
text run at (0,-5) width 0: "\x{2062}"
RenderMathMLScripts {msub} at (6,0) size 11x14
Base Wrapper at (0,0) size 7x14 [padding: 0 0 4 0]
RenderMathMLToken {mi} at (0,0) size 7x9
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x9
RenderBlock (anonymous) at (0,0) size 7x9
RenderText {#text} at (0,3) size 7x10
text run at (0,3) width 7: "H"
SubSupPair Wrapper at (7,0) size 4x14
RenderMathMLToken {mn} at (0,6) size 4x8
RenderMathMLBlock (anonymous, flex) at (0,0) size 4x7
RenderBlock (anonymous) at (0,0) size 4x7
RenderText {#text} at (0,2) size 4x8
text run at (0,2) width 4: "2"
RenderMathMLOperator {mo} at (17,8) size 0x1
RenderMathMLBlock (anonymous, flex) at (0,0) size 0x1
RenderBlock (anonymous) at (0,0) size 0x1
RenderText at (0,-5) size 0x10
text run at (0,-5) width 0: "\x{2062}"
RenderMathMLToken {mi} at (17,0) size 9x9 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 8x9
RenderBlock (anonymous) at (0,0) size 8x9
RenderText {#text} at (0,3) size 8x10
text run at (0,3) width 8: "O"
RenderMathMLSpace {mspace} at (385,14) size 6x0
RenderMathMLRow {mrow} at (390,6) size 9x9
RenderMathMLToken {mi} at (0,0) size 8x9 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x9
RenderBlock (anonymous) at (0,0) size 7x9
RenderText {#text} at (0,3) size 7x10
text run at (0,3) width 7: "A"
RenderMathMLUnderOver {munderover} at (398,3) size 21x19
RenderMathMLOperator {mo} at (0,6) size 21x6
RenderMathMLBlock (anonymous, flex) at (2,0) size 16x6
RenderBlock (anonymous) at (0,0) size 9x6
RenderText at (0,0) size 9x10
text run at (0,0) width 9: "\x{2194}"
RenderMathMLToken {mi} at (7,12) size 6x7 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 4x7
RenderBlock (anonymous) at (0,0) size 4x7
RenderText {#text} at (0,2) size 4x8
text run at (0,2) width 4: "b"
RenderMathMLToken {mn} at (8,0) size 5x6
RenderMathMLBlock (anonymous, flex) at (0,0) size 4x6
RenderBlock (anonymous) at (0,0) size 4x6
RenderText {#text} at (0,1) size 4x8
text run at (0,1) width 4: "a"
RenderMathMLRow {mrow} at (418,6) size 9x9
RenderMathMLToken {mi} at (0,0) size 8x9 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x9
RenderBlock (anonymous) at (0,0) size 7x9
RenderText {#text} at (0,3) size 7x10
text run at (0,3) width 7: "B"
RenderMathMLSpace {mspace} at (426,14) size 6x0
RenderMathMLRow {mrow} at (431,6) size 9x9
RenderMathMLToken {mi} at (0,0) size 8x9 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x9
RenderBlock (anonymous) at (0,0) size 7x9
RenderText {#text} at (0,3) size 7x10
text run at (0,3) width 7: "A"
RenderMathMLUnderOver {munderover} at (439,1) size 22x21
RenderMathMLOperator {mo} at (0,6) size 22x8
RenderMathMLBlock (anonymous, flex) at (2,0) size 17x8
RenderBlock (anonymous) at (0,0) size 10x8
RenderText at (0,2) size 10x10
text run at (0,2) width 10: "\x{21C4}"
RenderMathMLToken {mi} at (8,14) size 5x7 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 4x7
RenderBlock (anonymous) at (0,0) size 4x7
RenderText {#text} at (0,2) size 4x8
text run at (0,2) width 4: "0"
RenderMathMLToken {mn} at (8,0) size 5x6
RenderMathMLBlock (anonymous, flex) at (0,0) size 4x6
RenderBlock (anonymous) at (0,0) size 4x6
RenderText {#text} at (0,1) size 4x8
text run at (0,1) width 4: "a"
RenderMathMLRow {mrow} at (460,6) size 9x9
RenderMathMLToken {mi} at (0,0) size 8x9 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x9
RenderBlock (anonymous) at (0,0) size 7x9
RenderText {#text} at (0,3) size 7x10
text run at (0,3) width 7: "B"
RenderMathMLSpace {mspace} at (468,14) size 6x0
RenderMathMLRow {mrow} at (473,6) size 9x9
RenderMathMLToken {mi} at (0,0) size 8x9 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x9
RenderBlock (anonymous) at (0,0) size 7x9
RenderText {#text} at (0,3) size 7x10
text run at (0,3) width 7: "A"
RenderMathMLUnderOver {munderover} at (481,0) size 27x22
RenderMathMLOperator {mo} at (0,7) size 27x8
RenderMathMLBlock (anonymous, flex) at (2,0) size 22x8
RenderBlock (anonymous) at (0,0) size 10x8
RenderText at (0,2) size 10x10
text run at (0,2) width 10: "\x{21C4}"
RenderMathMLToken {mn} at (6,15) size 14x7
RenderMathMLBlock (anonymous, flex) at (0,0) size 13x7
RenderBlock (anonymous) at (0,0) size 13x7
RenderText {#text} at (0,2) size 13x8
text run at (0,2) width 13: "0\x{B0}C"
RenderMathMLToken {mn} at (2,0) size 22x7
RenderMathMLBlock (anonymous, flex) at (0,0) size 21x7
RenderBlock (anonymous) at (0,0) size 21x7
RenderText {#text} at (0,2) size 21x8
text run at (0,2) width 21: "100\x{B0}C"
RenderMathMLRow {mrow} at (507,6) size 9x9
RenderMathMLToken {mi} at (0,0) size 8x9 [padding: 0 1 0 0]
RenderMathMLBlock (anonymous, flex) at (0,0) size 7x9
RenderBlock (anonymous) at (0,0) size 7x9
RenderText {#text} at (0,3) size 7x10
text run at (0,3) width 7: "B"
110 changes: 110 additions & 0 deletions LayoutTests/mathml/opentype/munderover-window-resize.html
@@ -0,0 +1,110 @@
<!DOCTYPE html>
<html>
<head>
<title>Open Type MATH - under-over operator</title>
<meta charset="utf-8">
<style type="text/css">
/* This font is taken from Mozilla's test suite. */
@font-face {
font-family: stretchy;
src: url("stretchy.woff");
}
math {
font-family: stretchy;
font-size: 10px;
}
</style>
<body>
<div>
<math display='block'>
<mrow>
<mmultiscripts>
<mi>C</mi>
<none/>
<mi>16</mi>
<mprescripts/>
<mi>5</mi>
<mi>10</mi>
</mmultiscripts>
</mrow>
<mspace width="0.5em"/>
<mrow>
<mn>2</mn>
<mo>&InvisibleTimes;</mo>
<msub>
<mi>H</mi>
<mn>2</mn>
</msub>
<mo>+</mo>
<msub>
<mi>O</mi>
<mn>2</mn>
</msub>
</mrow>
<mover>
<mo>&#x02192;</mo>
<mrow>
<mi>m</mi>
<mo>,</mo>
<mi>n</mi>
</mrow>
</mover>
<mrow>
<mn>2</mn>
<mo>&InvisibleTimes;</mo>
<msub>
<mi>H</mi>
<mn>2</mn>
</msub>
<mo>&InvisibleTimes;</mo>
<mi>O</mi>
</mrow>
<mspace width="0.5em"/>
<mrow>
<mi>A</mi>
</mrow>
<munderover>
<mo>&#x02194;</mo>
<mi>b</mi>
<mn>a</mn>
</munderover>
<mrow>
<mi>B</mi>
</mrow>
<mspace width="0.5em"/>
<mrow>
<mi>A</mi>
</mrow>
<munderover>
<mo>&#x021C4;</mo>
<mi>0</mi>
<mn>a</mn>
</munderover>
<mrow>
<mi>B</mi>
</mrow>
<mspace width="0.5em"/>
<mrow>
<mi>A</mi>
</mrow>
<munderover>
<mo>&#x021C4;</mo>
<mn>0&#x000B0;C</mn>
<mn>100&#x000B0;C</mn>
</munderover>
<mrow>
<mi>B</mi>
</mrow>
</math>
</div>
<script>
for (var zoom = 110; zoom <= 200; zoom += 10) {
document.body.style.zoom = zoom + "%";
}
document.body.style.zoom="100%";
var width = window.outerWidth;
window.resizeTo(250, window.outerHeight);
window.resizeTo(width, window.outerHeight);
</script>
</body>
</html>
Expand Up @@ -7,8 +7,8 @@ layer at (0,0) size 800x153
RenderMathMLMath {math} at (0,3) size 18x22 [padding: 0 1 0 1]
RenderMathMLRow {mstyle} at (1,0) size 16x22
RenderMathMLUnderOver {mover} at (0,0) size 16x22
RenderMathMLOperator {mo} at (-6,1) size 27x21
RenderMathMLBlock (anonymous, flex) at (2,0) size 22x4
RenderMathMLOperator {mo} at (0,1) size 16x21
RenderMathMLBlock (anonymous, flex) at (2,0) size 11x4
RenderBlock (anonymous) at (0,0) size 2x4
RenderText at (0,-3) size 2x10
text run at (0,-3) width 2: "\x{219C}"
Expand All @@ -18,8 +18,8 @@ layer at (0,0) size 800x153
RenderMathMLMath {math} at (0,3) size 28x22 [padding: 0 1 0 1]
RenderMathMLRow {mstyle} at (1,0) size 26x22
RenderMathMLUnderOver {mover} at (0,0) size 26x22
RenderMathMLOperator {mo} at (-6,1) size 38x21
RenderMathMLBlock (anonymous, flex) at (2,0) size 32x4
RenderMathMLOperator {mo} at (0,1) size 26x21
RenderMathMLBlock (anonymous, flex) at (2,0) size 22x4
RenderBlock (anonymous) at (0,0) size 2x4
RenderText at (0,-3) size 2x10
text run at (0,-3) width 2: "\x{219C}"
Expand All @@ -29,8 +29,8 @@ layer at (0,0) size 800x153
RenderMathMLMath {math} at (0,0) size 158x42 [padding: 0 1 0 1]
RenderMathMLRow {mstyle} at (1,0) size 156x42
RenderMathMLUnderOver {mover} at (0,0) size 156x42
RenderMathMLOperator {mo} at (-3,1) size 162x41
RenderMathMLBlock (anonymous, flex) at (2,0) size 157x4
RenderMathMLOperator {mo} at (0,1) size 156x41
RenderMathMLBlock (anonymous, flex) at (2,0) size 151x4
RenderBlock (anonymous) at (0,0) size 2x4
RenderText at (0,-3) size 2x10
text run at (0,-3) width 2: "\x{219C}"
Expand Down

0 comments on commit 63c2c44

Please sign in to comment.