haikuwebkit/LayoutTests/mathml/opentype/munderover-stretch-width.html

157 lines
6.1 KiB
HTML
Raw Permalink Normal View History

Incorrect bounds inside <mover>/<munder> when a stretchy operator is present https://bugs.webkit.org/show_bug.cgi?id=179682 Patch by Minsheng Liu <lambda@liu.ms> on 2017-12-10 Reviewed by Frédéric Wang. Source/WebCore: Currently a stretchy operator inside <mover>/<munder>/<munderover> is stretched during paint() rather than layout(), which leads to both end user confusion and many unexpected behaviors. This patch rewrites RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren() to both eliminate the issue and make operator stretching more standard conforming. A test is added to check the stretch width of stretchy operators in various scenarios: mathml/opentype/munderover-stretch-width.html A previous test is updated: mathml/opentype/opentype-stretchy-horizontal.html * rendering/mathml/RenderMathMLOperator.cpp: (WebCore::RenderMathMLOperator::stretchTo): (WebCore::RenderMathMLOperator::resetStretchSize): (WebCore::RenderMathMLOperator::paint): * rendering/mathml/RenderMathMLOperator.h: (WebCore::RenderMathMLOperator::setStretchWidthLocked): (WebCore::RenderMathMLOperator::isStretchWidthLocked const): * rendering/mathml/RenderMathMLUnderOver.cpp: (WebCore::toHorizontalStretchyOperator): (WebCore::fixLayoutAfterStretch): (WebCore::RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren): LayoutTests: Added test case: mathml/opentype/munderover-stretch-width.html Updated test case: mathml/opentype/opentype-stretchy-horizontal We update the test file to make sure the stretchy <mo> has zero lspace/rspace. Expected results for macOS and iOS are included. * mathml/opentype/munderover-stretch-width-expected.txt: Added. * mathml/opentype/munderover-stretch-width.html: Added. * mathml/opentype/opentype-stretchy-horizontal.html: * platform/gtk/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Removed. * platform/ios/mathml/opentype/opentype-stretchy-horizontal-expected.png: * platform/ios/mathml/opentype/opentype-stretchy-horizontal-expected.txt: * platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.png: * platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt: * platform/win/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Removed. Canonical link: https://commits.webkit.org/196552@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-11 03:10:41 +00:00
<!doctype html>
<html>
<head>
<title>&lt;munderover&gt; stretch width</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;
}
</style>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
setup({ "explicit_done": true });
function assertApproxEquals(description, widths) {
function checkWidths() {
let epsilon = 1;
for (let i = 1; i < widths.length; i ++)
assert_approx_equals(widths[i - 1], widths[i], epsilon);
}
test(checkWidths, description);
}
function getWidths(caseNo, names) {
let widths = []
for (let name of names)
widths.push(document.getElementById(`${caseNo}-${name}`)
.getBoundingClientRect()
.width);
return widths;
}
function runCase(caseNo, description, ...names) {
let widths = getWidths(caseNo, names);
assertApproxEquals(description, widths);
}
function run() {
runCase(1, 'simple stretchy over', 'red', 'op');
runCase(2, 'simple stretchy under', 'red', 'op');
runCase(3, 'embellished op over with wide base', 'red', 'op');
runCase(4, 'embellished op over with narrow base', 'red', 'op');
runCase(5, 'unembellished op under with plain op over', 'red', 'op1', 'op2');
runCase(6, 'nested embellished op', 'red', 'op');
runCase(7, 'nested non-munderover embellished op', 'red', 'op');
runCase(8, 'simple stretchy under should equal over', 'red', 'op');
Add comments and improve code styles for RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren() and related functions https://bugs.webkit.org/show_bug.cgi?id=180923 Patch by Minsheng Liu <lambda@liu.ms> on 2017-12-23 Reviewed by Frédéric Wang. Source/WebCore: The patch improves the code for RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren() and related function, incorporating the following suggestions from bug 179682: - Remove several lines of trailing spaces. - Change several pointers to references. - Rewrite horizontalStretchyOperator() (formerly toHorizontalStretchyOperator()) to make it more conforming to WebKit's coding style. - Make unembellishedOperator() a const method. - Add comments for stretchHorizontalOperatorsAndLayoutChildren(). - Eliminate an unnecessary call to fixLayoutAfterStretch() in stretchHorizontalOperatorsAndLayoutChildren(). Add one more case for the test "mathml/opentype/munderover-stretch-width.html" to handle the corner case where all components of <munderover>/<munder>/<mover> are stretchy. Since there is no behavior change, no new test is required. * rendering/mathml/RenderMathMLBlock.h: (WebCore::RenderMathMLBlock::unembellishedOperator const): (WebCore::RenderMathMLBlock::unembellishedOperator): Deleted. * rendering/mathml/RenderMathMLFraction.cpp: (WebCore::RenderMathMLFraction::unembellishedOperator const): (WebCore::RenderMathMLFraction::unembellishedOperator): Deleted. * rendering/mathml/RenderMathMLFraction.h: * rendering/mathml/RenderMathMLOperator.cpp: (WebCore::RenderMathMLOperator::resetStretchSize): * rendering/mathml/RenderMathMLOperator.h: * rendering/mathml/RenderMathMLScripts.cpp: (WebCore::RenderMathMLScripts::unembellishedOperator const): (WebCore::RenderMathMLScripts::unembellishedOperator): Deleted. * rendering/mathml/RenderMathMLScripts.h: * rendering/mathml/RenderMathMLUnderOver.cpp: (WebCore::horizontalStretchyOperator): (WebCore::fixLayoutAfterStretch): (WebCore::RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren): (WebCore::RenderMathMLUnderOver::layoutBlock): (WebCore::toHorizontalStretchyOperator): Deleted. LayoutTests: Add one more case for the test "mathml/opentype/munderover-stretch-width.html" to handle the corner case where all components of <munderover>/<munder>/<mover> are stretchy. Since there is no behavior change, no new test is required. * mathml/opentype/munderover-stretch-width-expected.txt: * mathml/opentype/munderover-stretch-width.html: Canonical link: https://commits.webkit.org/197011@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226287 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-23 16:05:41 +00:00
runCase(9, 'all stretchy embellished op', 'red', 'blue', 'bar');
Incorrect bounds inside <mover>/<munder> when a stretchy operator is present https://bugs.webkit.org/show_bug.cgi?id=179682 Patch by Minsheng Liu <lambda@liu.ms> on 2017-12-10 Reviewed by Frédéric Wang. Source/WebCore: Currently a stretchy operator inside <mover>/<munder>/<munderover> is stretched during paint() rather than layout(), which leads to both end user confusion and many unexpected behaviors. This patch rewrites RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren() to both eliminate the issue and make operator stretching more standard conforming. A test is added to check the stretch width of stretchy operators in various scenarios: mathml/opentype/munderover-stretch-width.html A previous test is updated: mathml/opentype/opentype-stretchy-horizontal.html * rendering/mathml/RenderMathMLOperator.cpp: (WebCore::RenderMathMLOperator::stretchTo): (WebCore::RenderMathMLOperator::resetStretchSize): (WebCore::RenderMathMLOperator::paint): * rendering/mathml/RenderMathMLOperator.h: (WebCore::RenderMathMLOperator::setStretchWidthLocked): (WebCore::RenderMathMLOperator::isStretchWidthLocked const): * rendering/mathml/RenderMathMLUnderOver.cpp: (WebCore::toHorizontalStretchyOperator): (WebCore::fixLayoutAfterStretch): (WebCore::RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren): LayoutTests: Added test case: mathml/opentype/munderover-stretch-width.html Updated test case: mathml/opentype/opentype-stretchy-horizontal We update the test file to make sure the stretchy <mo> has zero lspace/rspace. Expected results for macOS and iOS are included. * mathml/opentype/munderover-stretch-width-expected.txt: Added. * mathml/opentype/munderover-stretch-width.html: Added. * mathml/opentype/opentype-stretchy-horizontal.html: * platform/gtk/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Removed. * platform/ios/mathml/opentype/opentype-stretchy-horizontal-expected.png: * platform/ios/mathml/opentype/opentype-stretchy-horizontal-expected.txt: * platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.png: * platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt: * platform/win/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Removed. Canonical link: https://commits.webkit.org/196552@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-11 03:10:41 +00:00
done();
}
</script>
</head>
<body onload="run()">
<p>This test passes if you see the black thing has the same width as the red bar.</p>
<math display="block">
<mover>
<mspace id="1-red" width="200px" height="10px" depth="10px" mathbackground="red"/>
<mo id="1-op" lspace="0px" rspace="0px" stretchy="true">&#x219C;</mo>
</mover>
</math>
<p>This test passes if you see the black thing has the same width as the red bar.</p>
<math display="block">
<munder>
<mspace id="2-red" width="200px" height="10px" depth="10px" mathbackground="red"/>
<mo id="2-op" lspace="0px" rspace="0px" stretchy="true">&#x219C;</mo>
</munder>
</math>
<p>This test passes if you see the black thing has the same width as the red bar below and wider than the green bar above.</p>
<math display="block">
<mover>
<mspace id="3-red" width="300px" height="10px" depth="10px" mathbackground="red"/>
<mover>
<mo id="3-op" lspace="0px" rspace="0px" stretchy="true">&#x219C;</mo>
<mspace id="3-green" width="200px" height="10px" depth="10px" mathbackground="green"/>
</mover>
</mover>
</math>
<p>This test passes if you see the black thing has the same width as the red bar below and narrower than the green bar above.</p>
<math display="block">
<mover>
<mspace id="4-red" width="200px" height="10px" depth="10px" mathbackground="red"/>
<mover>
<mo id="4-op" lspace="0px" rspace="0px" stretchy="true">&#x219C;</mo>
<mspace id="4-green" width="300px" height="10px" depth="10px" mathbackground="green"/>
</mover>
</mover>
</math>
<p>This test passes if you see all three things have the same width.</p>
<math display="block">
<mover>
<munder>
<mspace id="5-red" width="200px" height="10px" depth="10px" mathbackground="red"/>
<mo id="5-op1" lspace="0px" rspace="0px" stretchy="true">&#x219C;</mo>
</munder>
<mo id="5-op2" lspace="0px" rspace="0px" stretchy="true">&#x219C;</mo>
</mover>
</math>
<p>This test passes if you see the black thing has the same width as the red bar.</p>
<math display="block">
<munder>
<mspace id="6-red" width="200px" height="10px" depth="10px" mathbackground="red"/>
<munder>
<munder>
<mo id="6-op" lspace="0px" rspace="0px" stretchy="true">&#x219C;</mo>
<mspace id="6-green" width="150px" height="10px" depth="10px" mathbackground="green"/>
</munder>
<mspace id="6-blue" width="100px" height="10px" depth="10px" mathbackground="blue"/>
</munder>
</munder>
</math>
<p>This test passes if you see the black thing has the same width as the red bar.</p>
<math display="block">
<munder>
<mspace id="7-red" width="200px" height="10px" depth="10px" mathbackground="red"/>
<mfrac>
<mfrac>
<mo id="7-op" lspace="0px" rspace="0px" stretchy="true">&#x219C;</mo>
<mspace id="7-green" width="150px" height="10px" depth="10px" mathbackground="green"/>
</mfrac>
<mspace id="7-blue" width="100px" height="10px" depth="10px" mathbackground="blue"/>
</mfrac>
</munder>
</math>
<p>This test passes if you see the black thing has the same width as the red bar.</p>
<math display="block">
<munderover>
<mspace id="8-blue" width="100px" height="10px" depth="10px" mathbackground="blue"></mspace>
<mo id="8-op" lspace="0px" rspace="0px" stretchy="true">&#x219C;</mo>
<mspace id="8-red" width="200px" height="10px" depth="10px" mathbackground="red"></mspace>
</munderover>
</math>
Add comments and improve code styles for RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren() and related functions https://bugs.webkit.org/show_bug.cgi?id=180923 Patch by Minsheng Liu <lambda@liu.ms> on 2017-12-23 Reviewed by Frédéric Wang. Source/WebCore: The patch improves the code for RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren() and related function, incorporating the following suggestions from bug 179682: - Remove several lines of trailing spaces. - Change several pointers to references. - Rewrite horizontalStretchyOperator() (formerly toHorizontalStretchyOperator()) to make it more conforming to WebKit's coding style. - Make unembellishedOperator() a const method. - Add comments for stretchHorizontalOperatorsAndLayoutChildren(). - Eliminate an unnecessary call to fixLayoutAfterStretch() in stretchHorizontalOperatorsAndLayoutChildren(). Add one more case for the test "mathml/opentype/munderover-stretch-width.html" to handle the corner case where all components of <munderover>/<munder>/<mover> are stretchy. Since there is no behavior change, no new test is required. * rendering/mathml/RenderMathMLBlock.h: (WebCore::RenderMathMLBlock::unembellishedOperator const): (WebCore::RenderMathMLBlock::unembellishedOperator): Deleted. * rendering/mathml/RenderMathMLFraction.cpp: (WebCore::RenderMathMLFraction::unembellishedOperator const): (WebCore::RenderMathMLFraction::unembellishedOperator): Deleted. * rendering/mathml/RenderMathMLFraction.h: * rendering/mathml/RenderMathMLOperator.cpp: (WebCore::RenderMathMLOperator::resetStretchSize): * rendering/mathml/RenderMathMLOperator.h: * rendering/mathml/RenderMathMLScripts.cpp: (WebCore::RenderMathMLScripts::unembellishedOperator const): (WebCore::RenderMathMLScripts::unembellishedOperator): Deleted. * rendering/mathml/RenderMathMLScripts.h: * rendering/mathml/RenderMathMLUnderOver.cpp: (WebCore::horizontalStretchyOperator): (WebCore::fixLayoutAfterStretch): (WebCore::RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren): (WebCore::RenderMathMLUnderOver::layoutBlock): (WebCore::toHorizontalStretchyOperator): Deleted. LayoutTests: Add one more case for the test "mathml/opentype/munderover-stretch-width.html" to handle the corner case where all components of <munderover>/<munder>/<mover> are stretchy. Since there is no behavior change, no new test is required. * mathml/opentype/munderover-stretch-width-expected.txt: * mathml/opentype/munderover-stretch-width.html: Canonical link: https://commits.webkit.org/197011@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226287 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-23 16:05:41 +00:00
<p>This test passes if you see both the red and blue things have the same width as the black bar.</p>
<math display="block">
<mover>
<mo id="9-blue" lspace="0px" rspace="0px" stretchy="true" mathbackground="blue">&#x219C;</mo>
<munder>
<mo id="9-red" lspace="0px" rspace="0px" stretchy="true" mathbackground="red">&#x219C;</mo>
<mspace id="9-bar" width="200px" height="10px" depth="10px" mathbackground="black"></mspace>
</munder>
</mover>
</math>
Incorrect bounds inside <mover>/<munder> when a stretchy operator is present https://bugs.webkit.org/show_bug.cgi?id=179682 Patch by Minsheng Liu <lambda@liu.ms> on 2017-12-10 Reviewed by Frédéric Wang. Source/WebCore: Currently a stretchy operator inside <mover>/<munder>/<munderover> is stretched during paint() rather than layout(), which leads to both end user confusion and many unexpected behaviors. This patch rewrites RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren() to both eliminate the issue and make operator stretching more standard conforming. A test is added to check the stretch width of stretchy operators in various scenarios: mathml/opentype/munderover-stretch-width.html A previous test is updated: mathml/opentype/opentype-stretchy-horizontal.html * rendering/mathml/RenderMathMLOperator.cpp: (WebCore::RenderMathMLOperator::stretchTo): (WebCore::RenderMathMLOperator::resetStretchSize): (WebCore::RenderMathMLOperator::paint): * rendering/mathml/RenderMathMLOperator.h: (WebCore::RenderMathMLOperator::setStretchWidthLocked): (WebCore::RenderMathMLOperator::isStretchWidthLocked const): * rendering/mathml/RenderMathMLUnderOver.cpp: (WebCore::toHorizontalStretchyOperator): (WebCore::fixLayoutAfterStretch): (WebCore::RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren): LayoutTests: Added test case: mathml/opentype/munderover-stretch-width.html Updated test case: mathml/opentype/opentype-stretchy-horizontal We update the test file to make sure the stretchy <mo> has zero lspace/rspace. Expected results for macOS and iOS are included. * mathml/opentype/munderover-stretch-width-expected.txt: Added. * mathml/opentype/munderover-stretch-width.html: Added. * mathml/opentype/opentype-stretchy-horizontal.html: * platform/gtk/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Removed. * platform/ios/mathml/opentype/opentype-stretchy-horizontal-expected.png: * platform/ios/mathml/opentype/opentype-stretchy-horizontal-expected.txt: * platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.png: * platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt: * platform/win/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Removed. Canonical link: https://commits.webkit.org/196552@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-11 03:10:41 +00:00
</body>
</html>