haikuwebkit/LayoutTests/mathml/opentype/large-operators-displaystyl...

63 lines
3.3 KiB
HTML
Raw Permalink Normal View History

Implement an internal style property for displaystyle. https://bugs.webkit.org/show_bug.cgi?id=133845 Patch by Frederic Wang <fwang@igalia.com> on 2016-07-07 Reviewed by Brent Fulgham. Source/WebCore: Tests: mathml/opentype/large-operators-displaystyle-dynamic.html mathml/opentype/large-operators-displaystyle.html This is based on a patch by Alejandro G. Castro <alex@igalia.com> * CMakeLists.txt: Add MathMLStyle to the build system. * WebCore.xcodeproj/project.pbxproj: ditto. * mathml/MathMLInlineContainerElement.cpp: (WebCore::MathMLInlineContainerElement::parseAttribute): Resolve the mathml style when the displaystyle attribute changes on the mtable or mstyle elements. * mathml/MathMLInlineContainerElement.h: Define parseAttribute. * mathml/MathMLMathElement.cpp: (WebCore::MathMLMathElement::MathMLMathElement): Indicate that we have custom style. (WebCore::MathMLMathElement::parseAttribute): Resolve the mathml style when the display or displaystyle attributes change on the math element. (WebCore::MathMLMathElement::didAttachRenderers): Resolve the mathml style when one renderer is attached. * mathml/MathMLMathElement.h: Declare parseAttribute and didAttachRenderers. * mathml/mathattrs.in: Declare the display and displaystyle attributes. * rendering/mathml/MathMLStyle.cpp: Added. (WebCore::MathMLStyle::MathMLStyle): New class to handle custom MathML style. (WebCore::MathMLStyle::create): (WebCore::MathMLStyle::setDisplayStyle): Helper function to take the displaystyle from the specified rendered. (WebCore::MathMLStyle::resolveMathMLStyleTree): Helper function to resolve the custom MathML style in renderer subtree. (WebCore::MathMLStyle::getMathMLParentNode): Helper function to get a MathML ancestor of the specified renderer. (WebCore::MathMLStyle::updateStyleIfNeeded): Helper function to update the style of the specified renderer if needed. (WebCore::MathMLStyle::resolveMathMLStyle): Resolve the MathML style of a given renderer. For displaystyle, we inherit the value of the parent except for the cases mentioned in the MathML recommendation. * rendering/mathml/MathMLStyle.h: New class header for custom MathML style. Only displaystyle is supported for now. * rendering/mathml/RenderMathMLBlock.cpp: Add a member and getter for custom MathML style. (WebCore::RenderMathMLBlock::RenderMathMLBlock): * rendering/mathml/RenderMathMLBlock.h: ditto. (WebCore::RenderMathMLBlock::mathMLStyle): * rendering/mathml/RenderMathMLMath.h: Add definition to use the syntax is<RenderMathMLMath>. * rendering/mathml/RenderMathMLOperator.h: (WebCore::RenderMathMLOperator::isLargeOperatorInDisplayStyle): Do not rerturn true when the operator is not in displaystyle. * rendering/mathml/RenderMathMLRoot.h: Make updateStyle public, so that it can be called by MathMLStyle::updateStyleIfNeeded. * rendering/mathml/RenderMathMLUnderOver.h: Add definition to use the syntax is<RenderMathMLUnderOver>. LayoutTests: This is based on a patch by Alejandro G. Castro <alex@igalia.com> Add two new tests to verify that the displaystyle property is correctly inherited on various MathML elements. large-operators-displaystyle verifies that large operators are only drawn bigger when the displaystyle is true. large-operators-displaystyle-dynamic verifies the same displaystyle is calculated when the display and displaystyle attributes are changed dynamically. * mathml/opentype/large-operators-displaystyle-dynamic-expected.html: Added. * mathml/opentype/large-operators-displaystyle-dynamic.html: Added. * mathml/opentype/large-operators-displaystyle-expected.txt: Added. * imported/mathml-in-html5/fonts/math/largeop-displayoperatorminheight5000.woff: Added. * imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1.html: Added. * imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1-expected.txt: Added. Canonical link: https://commits.webkit.org/177684@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-08 05:40:20 +00:00
<!doctype html>
<html>
<head>
<title>Open Type MATH - large operators - displaystyle</title>
<meta charset="utf-8"/>
<style type="text/css">
@font-face {
font-family: stretchy;
src: url("stretchy.woff");
}
div.largeop_test * {
font-family: stretchy;
font-size: 10px;
}
</style>
</head>
<body>
<div class="largeop_test">
<math class="update" display="block"><mo>&#x2A1B;</mo></math>
<math class="update" display="inline"><mo>&#x2A1B;</mo></math>
<math class="update" displaystyle="true"><mo>&#x2A1B;</mo></math>
<math class="update" displaystyle="false"><mo>&#x2A1B;</mo></math>
<math class="update"><mstyle class="update" displaystyle="true"><mo>&#x2A1B;</mo></mstyle></math>
<math class="update"><mstyle class="update" displaystyle="false"><mo>&#x2A1B;</mo></mstyle></math>
<math class="update" displaystyle="false"><mtable><mtr><mtd><mo>&#x2A1B;</mo></mtd></mtr></mtable></math>
<math class="update"><mtable class="update" displaystyle="false"><mtr><mtd><mo>&#x2A1B;</mo></mtd></mtr></mtable></math>
<math class="update" displaystyle="false"><mtable class="update" displaystyle="true"><mtr><mtd><mo>&#x2A1B;</mo></mtd></mtr></mtable></math>
<math class="update" displaystyle="false"><mfrac><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></mfrac></math>
<math class="update" displaystyle="false"><mroot><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></mroot></math>
<math class="update" displaystyle="false"><msub><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></msub></math>
<math class="update" displaystyle="false"><msup><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></msup></math>
<math class="update" displaystyle="false"><msubsup><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></msubsup></math>
<math class="update" displaystyle="false"><mmultiscripts><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo><mprescripts/><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></mmultiscripts></math>
<math class="update" displaystyle="false"><munder><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></munder></math>
<math class="update" displaystyle="false"><mover><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></mover></math>
<math class="update" displaystyle="false"><munderover><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></munderover></math>
</div>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
function updatePageAfterRendering()
{
Bug 216702 - Implement the CSS math-style property https://bugs.webkit.org/show_bug.cgi?id=216702 Patch by Frederic Wang <fwang@igalia.com> on 2020-09-25 Reviewed by Rob Buis. LayoutTests/imported/w3c: Rebaseline tests to take into account new PASS results. * web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt: * web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt: * web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: * web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt: * web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt: * web-platform-tests/mathml/relations/css-styling/displaystyle-1-expected.txt: * web-platform-tests/mathml/relations/css-styling/displaystyle-2-expected.txt: * web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt: Added. Source/WebCore: This patch implements the math-style property [1][2] and uses it to map MathML's displaystyle attribute to style, instead of using an internal inheritance mechanism. In addition, four changes are made to improve the MathML implementation: - Support for the displaystyle attribute on all the MathML elements. - Better handling of dynamic update of displaystyle. - RenderMathMLUnderOver uses its own displaystyle (rather than the one of the core operator at its base in order) to determine whether to move its under/over scripts. - display/displaystyle are made case-insensitive. [1] https://mathml-refresh.github.io/mathml-core/#the-math-style-property [2] https://github.com/w3c/csswg-drafts/issues/5387 No new tests, already covered by existing tests. * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator MathStyle const): * css/CSSProperties.json: * css/CSSValueKeywords.in: * css/mathml.css: Implement displaystyle rules using math-style. * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): (WebCore::CSSParserFastPaths::isKeywordPropertyID): * mathml/MathMLElement.cpp: (WebCore::MathMLElement::isPresentationAttribute const): (WebCore::MathMLElement::collectStyleForPresentationAttribute): * mathml/MathMLElement.h: * mathml/MathMLMathElement.cpp: (WebCore::MathMLMathElement::parseAttribute): * mathml/MathMLMathElement.h: * mathml/MathMLPresentationElement.cpp: (WebCore::MathMLPresentationElement::parseAttribute): * mathml/MathMLPresentationElement.h: * mathml/MathMLRowElement.cpp: * mathml/MathMLRowElement.h: * mathml/MathMLSpaceElement.h: * mathml/MathMLTokenElement.h: * rendering/mathml/MathMLStyle.cpp: (WebCore::MathMLStyle::updateStyleIfNeeded): (WebCore::MathMLStyle::resolveMathMLStyle): * rendering/mathml/MathMLStyle.h: * rendering/mathml/RenderMathMLBlock.cpp: (WebCore::RenderMathMLBlock::styleDidChange): * rendering/mathml/RenderMathMLBlock.h: * rendering/mathml/RenderMathMLFraction.cpp: (WebCore::RenderMathMLFraction::fractionParameters const): (WebCore::RenderMathMLFraction::stackParameters const): * rendering/mathml/RenderMathMLOperator.cpp: (WebCore::RenderMathMLOperator::styleDidChange): * rendering/mathml/RenderMathMLOperator.h: (WebCore::RenderMathMLOperator::isLargeOperatorInDisplayStyle const): (WebCore::RenderMathMLOperator::shouldMoveLimits const): * rendering/mathml/RenderMathMLRoot.cpp: (WebCore::RenderMathMLRoot::verticalParameters): * rendering/mathml/RenderMathMLUnderOver.cpp: (WebCore::RenderMathMLUnderOver::shouldMoveLimits): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::mathStyle const): (WebCore::RenderStyle::setMathStyle): (WebCore::RenderStyle::initialMathStyle): * rendering/style/RenderStyleConstants.cpp: (WebCore::operator<<): * rendering/style/RenderStyleConstants.h: * rendering/style/StyleRareInheritedData.cpp: (WebCore::StyleRareInheritedData::StyleRareInheritedData): (WebCore::StyleRareInheritedData::operator== const): * rendering/style/StyleRareInheritedData.h: LayoutTests: Rebaseline tests to take into account new PASS results. * TestExpectations: * mathml/opentype/large-operators-displaystyle-dynamic.html: Do the dynamic change directly after page load but do a requestAnimationFrame before completing the test. * platform/glib/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt: Removed. * platform/glib/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt: Removed. * platform/glib/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt: Removed. * platform/glib/imported/w3c/web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt: Removed. * platform/gtk/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: * platform/gtk/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt: Copied from LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt. * platform/gtk/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt: Copied from LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt. * platform/ios-13/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt: * platform/ios-wk2/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt: Removed. * platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: * platform/ios-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt: Removed. * platform/ios-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt: Removed. * platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt: * platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt: * platform/ios-wk2/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt: * platform/ios/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt: * platform/mac-wk1/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt: Removed. * platform/mac-wk1/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt: Removed. * platform/mac-wk1/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt: Removed. * platform/mac-wk1/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt: * platform/mac-wk1/imported/w3c/web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt: Removed. * platform/mac-wk1/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt: * platform/mac-wk2/imported/w3c/web-platform-tests/css/css-fonts/math-script-level-and-math-style/math-style-001.tentative-expected.txt: Removed. * platform/mac-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-1-expected.txt: Removed. * platform/mac-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/fractions/frac-parameters-2-expected.txt: Removed. * platform/mac-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/operator-dictionary-stretchy-006-expected.txt: Added. * platform/mac-wk2/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/operator-dictionary-symmetric-001-expected.txt: Added. * platform/mac-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/attribute-mapping-002-expected.txt: * platform/mac-wk2/imported/w3c/web-platform-tests/mathml/relations/css-styling/displaystyle-3-expected.txt: Removed. * platform/mac-wk2/imported/w3c/web-platform-tests/mathml/relations/html5-tree/display-1-expected.txt: * platform/wpe/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-csstext-expected.txt: Canonical link: https://commits.webkit.org/229757@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267578 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-25 17:47:30 +00:00
// Switch the value of display/displaystyle attributes.
var mathmlElements = document.getElementsByClassName("update");
for (var i = 0; i < mathmlElements.length; i++) {
var e = mathmlElements[i];
if (e.hasAttribute("displaystyle"))
e.setAttribute("displaystyle", e.getAttribute("displaystyle") == "true" ? "false" : "true");
if (e.hasAttribute("display"))
e.setAttribute("display", e.getAttribute("display") == "block" ? "inline" : "block");
}
window.requestAnimationFrame(function() {
if (window.testRunner)
testRunner.notifyDone();
});
Implement an internal style property for displaystyle. https://bugs.webkit.org/show_bug.cgi?id=133845 Patch by Frederic Wang <fwang@igalia.com> on 2016-07-07 Reviewed by Brent Fulgham. Source/WebCore: Tests: mathml/opentype/large-operators-displaystyle-dynamic.html mathml/opentype/large-operators-displaystyle.html This is based on a patch by Alejandro G. Castro <alex@igalia.com> * CMakeLists.txt: Add MathMLStyle to the build system. * WebCore.xcodeproj/project.pbxproj: ditto. * mathml/MathMLInlineContainerElement.cpp: (WebCore::MathMLInlineContainerElement::parseAttribute): Resolve the mathml style when the displaystyle attribute changes on the mtable or mstyle elements. * mathml/MathMLInlineContainerElement.h: Define parseAttribute. * mathml/MathMLMathElement.cpp: (WebCore::MathMLMathElement::MathMLMathElement): Indicate that we have custom style. (WebCore::MathMLMathElement::parseAttribute): Resolve the mathml style when the display or displaystyle attributes change on the math element. (WebCore::MathMLMathElement::didAttachRenderers): Resolve the mathml style when one renderer is attached. * mathml/MathMLMathElement.h: Declare parseAttribute and didAttachRenderers. * mathml/mathattrs.in: Declare the display and displaystyle attributes. * rendering/mathml/MathMLStyle.cpp: Added. (WebCore::MathMLStyle::MathMLStyle): New class to handle custom MathML style. (WebCore::MathMLStyle::create): (WebCore::MathMLStyle::setDisplayStyle): Helper function to take the displaystyle from the specified rendered. (WebCore::MathMLStyle::resolveMathMLStyleTree): Helper function to resolve the custom MathML style in renderer subtree. (WebCore::MathMLStyle::getMathMLParentNode): Helper function to get a MathML ancestor of the specified renderer. (WebCore::MathMLStyle::updateStyleIfNeeded): Helper function to update the style of the specified renderer if needed. (WebCore::MathMLStyle::resolveMathMLStyle): Resolve the MathML style of a given renderer. For displaystyle, we inherit the value of the parent except for the cases mentioned in the MathML recommendation. * rendering/mathml/MathMLStyle.h: New class header for custom MathML style. Only displaystyle is supported for now. * rendering/mathml/RenderMathMLBlock.cpp: Add a member and getter for custom MathML style. (WebCore::RenderMathMLBlock::RenderMathMLBlock): * rendering/mathml/RenderMathMLBlock.h: ditto. (WebCore::RenderMathMLBlock::mathMLStyle): * rendering/mathml/RenderMathMLMath.h: Add definition to use the syntax is<RenderMathMLMath>. * rendering/mathml/RenderMathMLOperator.h: (WebCore::RenderMathMLOperator::isLargeOperatorInDisplayStyle): Do not rerturn true when the operator is not in displaystyle. * rendering/mathml/RenderMathMLRoot.h: Make updateStyle public, so that it can be called by MathMLStyle::updateStyleIfNeeded. * rendering/mathml/RenderMathMLUnderOver.h: Add definition to use the syntax is<RenderMathMLUnderOver>. LayoutTests: This is based on a patch by Alejandro G. Castro <alex@igalia.com> Add two new tests to verify that the displaystyle property is correctly inherited on various MathML elements. large-operators-displaystyle verifies that large operators are only drawn bigger when the displaystyle is true. large-operators-displaystyle-dynamic verifies the same displaystyle is calculated when the display and displaystyle attributes are changed dynamically. * mathml/opentype/large-operators-displaystyle-dynamic-expected.html: Added. * mathml/opentype/large-operators-displaystyle-dynamic.html: Added. * mathml/opentype/large-operators-displaystyle-expected.txt: Added. * imported/mathml-in-html5/fonts/math/largeop-displayoperatorminheight5000.woff: Added. * imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1.html: Added. * imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1-expected.txt: Added. Canonical link: https://commits.webkit.org/177684@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-08 05:40:20 +00:00
}
addEventListener('load', updatePageAfterRendering, false);
</script>
</body>
</html>