Title: [202960] trunk
Revision
202960
Author
fred.w...@free.fr
Date
2016-07-07 22:40:20 -0700 (Thu, 07 Jul 2016)

Log Message

Implement an internal style property for displaystyle.
https://bugs.webkit.org/show_bug.cgi?id=133845

Patch by Frederic Wang <fw...@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 <a...@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 <a...@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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202959 => 202960)


--- trunk/LayoutTests/ChangeLog	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/LayoutTests/ChangeLog	2016-07-08 05:40:20 UTC (rev 202960)
@@ -1,5 +1,28 @@
 2016-07-07  Frederic Wang  <fw...@igalia.com>
 
+        Implement an internal style property for displaystyle.
+        https://bugs.webkit.org/show_bug.cgi?id=133845
+
+        Reviewed by Brent Fulgham.
+
+        This is based on a patch by Alejandro G. Castro <a...@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.
+
+2016-07-07  Frederic Wang  <fw...@igalia.com>
+
         Rebaseline some MathML tests on Windows after r202934
 
         Unreviewed test gardening.

Added: trunk/LayoutTests/imported/mathml-in-html5/fonts/math/largeop-displayoperatorminheight5000.woff (0 => 202960)


--- trunk/LayoutTests/imported/mathml-in-html5/fonts/math/largeop-displayoperatorminheight5000.woff	                        (rev 0)
+++ trunk/LayoutTests/imported/mathml-in-html5/fonts/math/largeop-displayoperatorminheight5000.woff	2016-07-08 05:40:20 UTC (rev 202960)
@@ -0,0 +1,9 @@
+wOFFOTTO	\x94CFF X
+`\xF2Ű1FFTMdz\xE8jMATH\x80h-;yOS/2\@`:\xE9cmap@JU\xF0\xD8\xF9head.6
+ghhea8$=\xEBhmtx\xD0maxpTPname\x9Cd\xB7\xAA\xFEpost@ \xFF\x863x\x9Cc`d``\xE2/S\x8F\xB7\xC7\xF3\xDB|e\xE0f~a\xB8\\xFB\xA0\x99f~!\xDC\xA48\x98@<x\xACYx\x9Cc`d``~\xC1\xC0\xC0\x90&AlFT\xC0P\xA02Px\x9Cc`a~\xC18\x81\x81\x95\x81\x81\x99\x87ك\x81\x81a\x84fr`\xB0f4\xD2\xAC\x9C0\xC0\xC4Ƞ\x81AA\xEB?\xF3 +I+(!#\x92lIx\x9C\xBD\x92\xB1j\xC30\x869I\xA1K\xE9\xDERH;c\xB2\x944BI\xD6\xEC&1\xB6 \xB1\x8C\xED%K\xF7\xBEB\xA2s\x87\xBEL\xA1ѱ\xBFd\xB5c)\xA5\xC4\xC2ܧ\xD3ݯ;I.\xF0\x81\xF6\xBB\xC1ʱ@\xAF\x8E=\\x8B+\xC7܊\xC7]\xF4\xBD;\xC7=\z\x8F\x8E\xCF\xE8g\xA4\xE8\x9Esvo\xB3,Q9\xF6\xE3\xCDq"v\xDC\xC5R|8\xEEAz\x99\xE33,\xBD'̡Q\xE2H\x859H\xB0Őv\x8C!"\xD2	Wr\xDAg3\xD4\x9AQ\xCA\xFA\xB9\xE6\xBA<V*\xCB9\xD8\xE58#\xB9N\x9A|\xBD\x92\xB3\xBA\xD6[\x954J3lϜ\x8A{\xA5vg;\xE6\xD7$\xE3?Z_\xCAu\xA3\xABi\-\xB8s\xFA]߄U\x99\x81}Re\xA9.\xFD\x9D\xAA\xCB}
 r\xD4eZ%\x8D\xAE\xAA\xC8SS\xC6$\xF5g\xF9\x9Fe\xB6\xE7\xC6ڶs^#&JL\xF9\xFFW\x97\xADZL\x85\x88\xFF׍`\xA1\x8Bf\xA1ٿ\x8F9\x95\xBF9\x86\xC5~䛋9\xF9-l\xAC\힊\xB4\xA9\xA1=\xAE\xB6IlҪ\xE6\xF3\x90A\x8EL\xAD\xA7\xAE\xF0+\x89\xC0)x\x9Cc```f\x80`Fp\xF2\xC1|+ \xCD\xA4\x98\xB4\xFE\xFF\xFF\xE4\x83\xE9\xFF\xAF2C\xD5#\x82\x83\x92\xEA\xA6
+x\x9Cc`f\x83\xFF\xCDF@\x8A\x91+(U\xB9x\x9Ccd`aa`ddT\xCDI,JO\xCD/\xD0M\xC9,.\xC8I\xAC\xCC/H-J,\xC9/\xCA\xCD\xCC\xCBH\xCDL\xCF(1500``db`d\xD0\xFB\xC1\xCF\xF0C\x96\xF1\x87\xD3y\xE6,=<\x8C\xDDݿjd\x84;Xe\xBE\xF2\xCB00\xC80\xFC\x94a\x93a\xF4b`\xE9\xE1`g\xB0aH`h)\xCD\xCB4rts\x83RzPۜ\xF3*\x8B@\xB6(h$k*\x9A)\xF8&\x96d\xF8\xFA(8\xE7'g&\x96d\xE6\xE7\xE3B\xA2|\x8C\x8C\xED\x8C,\x8C\x8CJʦ\xEE\xDD{\x9C\xDA˸w\xEF\xCF-{\x99\xF7\x8A\xFD\x92\xF8\xA9\xF7O\x82m\xEF\x9F?\xA2?N\xFD\xDC\xF2\xE7;\xD0{\x8C@\xCC\xDC\xCD\xF2\xAB\xE6WͿ6\xBEep\xA0\xC7A"\xBFjD\xBAE\xBBy\xB8~\xD5ϯn \xC5\x87R{?x\x9Cc```d\x82\xCB"\xEA\xF9`\xBA\xF6A-\x8C?\xB2\xD9x\x9Cc`d``\xE0bx\xC0\xA8\xC7\xC0`\xC3zG\xB8\x83\x81pJk\xA1vc\xEA\x8C j\xC14\x8C\x8Dd\x8A\xB8v\xCC(\xCA\xC0\xF0\xF7*\x90m\xC3\xC0\xC1 \xA4U\x804#\xD8F0D\xE5\xA91\x83\x83\x83NWAT\x8A0\xE80\x9800Y@\xD5*pq\xA0\xF3Kf\xE1N\xB8#X\x84+Z\xE4\xE2\xE8\xE8
\ No newline at end of file

Added: trunk/LayoutTests/imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1-expected.txt (0 => 202960)


--- trunk/LayoutTests/imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1-expected.txt	2016-07-08 05:40:20 UTC (rev 202960)
@@ -0,0 +1,56 @@
+⫿
+ 
+⫿
+⫿
+⫿
+ 
+⫿
+ 
+⫿
+ 
+⫿
+  ⫿   ⫿   ⫿  
+⫿
+⫿
+ 
+⫿
+⫿
+ 
+⫿
+⫿
+ 
+⫿
+⫿
+ 
+⫿
+⫿
+⫿
+ 
+⫿
+⫿
+⫿
+⫿
+⫿
+ 
+⫿
+⫿
+ 
+⫿
+⫿
+ 
+⫿
+⫿
+⫿
+
+PASS math element 
+PASS mstyle element 
+PASS mtable element 
+PASS mfrac element 
+PASS mroot element 
+PASS msub element 
+PASS msup element 
+PASS msubsup element 
+PASS munder element 
+PASS mover element 
+PASS munderover element 
+
Property changes on: trunk/LayoutTests/imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1-expected.txt
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: trunk/LayoutTests/imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1.html (0 => 202960)


--- trunk/LayoutTests/imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1.html	                        (rev 0)
+++ trunk/LayoutTests/imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1.html	2016-07-08 05:40:20 UTC (rev 202960)
@@ -0,0 +1,116 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>displaystyle</title>
+<link rel="help" href=""
+<meta name="assert" content="Verify that the correct inheritance of the displaystyle value by measuring the size of large operators.">
+<style>
+  @font-face {
+    font-family: TestFont;
+    src: url("../../../fonts/math/largeop-displayoperatorminheight5000.woff");
+  }
+  math  {
+    font-family: TestFont;
+    font-size: 10px;
+  }
+</style>
+<script src=""
+<script src=""
+<script>
+  setup({ explicit_done: true });
+  var emToPx = 10 / 1000; // font-size: 10px, font.em = 1000
+  var epsilon = 5;
+  function verify_displaystyle(element, displaystyle, description) {
+    if (typeof element === "string")
+      element = document.getElementById(element);
+    var elementSize = element.getBoundingClientRect().height;
+    if (displaystyle)
+      assert_approx_equals(elementSize, 5000 * emToPx, epsilon, description);
+    else
+      assert_approx_equals(elementSize, 1000 * emToPx, epsilon, description);
+  }
+
+  window.addEventListener("load", function() {
+    document.fonts.ready.then(function() {
+      window.setTimeout(runTests, 250);
+    });
+  });
+
+  function runTests() {
+    test(function() {
+      verify_displaystyle("math_default", false, "default");
+      verify_displaystyle("math_inline", false, "explicit display inline");
+      verify_displaystyle("math_block", true, "explicit display block");
+      verify_displaystyle("math_false", false, "explicit displaystyle false");
+      verify_displaystyle("math_true", true, "explicit displaystyle true");
+    }, "math element");
+    test(function() {
+      verify_displaystyle("mstyle_false", false, "explicit displaystyle false");
+      verify_displaystyle("mstyle_true", true, "explicit displaystyle true");
+    }, "mstyle element");
+    test(function() {
+      verify_displaystyle("mtable_default", false, "default");
+      verify_displaystyle("mtable_false", false, "explicit displaystyle false");
+      verify_displaystyle("mtable_true", true, "explicit displaystyle true");
+    }, "mtable element");
+    test(function() {
+      verify_displaystyle("mfrac_numerator", false, "numerator");
+      verify_displaystyle("mfrac_denominator", false, "denominator");
+    }, "mfrac element");
+    test(function() {
+      verify_displaystyle("mroot_base", true, "base");
+      verify_displaystyle("mroot_index", false, "index");
+    }, "mroot element");
+    test(function() {
+      verify_displaystyle("msub_base", true, "base");
+      verify_displaystyle("msub_subscript", false, "subscript");
+    }, "msub element");
+    test(function() {
+      verify_displaystyle("msup_base", true, "base");
+      verify_displaystyle("msup_supscript", false, "supscript");
+    }, "msup element");
+    test(function() {
+      verify_displaystyle("msubsup_base", true, "base");
+      verify_displaystyle("msubsup_subscript", false, "subscript");
+      verify_displaystyle("msubsup_supscript", false, "supscript");
+    }, "msubsup element");
+    test(function() {
+      verify_displaystyle("munder_base", true, "base");
+      verify_displaystyle("munder_underscript", false, "underscript");
+    }, "munder element");
+    test(function() {
+      verify_displaystyle("mover_base", true, "base");
+      verify_displaystyle("mover_overscript", false, "overscript");
+    }, "mover element");
+    test(function() {
+      verify_displaystyle("munderover_base", true, "base");
+      verify_displaystyle("munderover_underscript", false, "underscript");
+      verify_displaystyle("munderover_overscript", false, "overscript");
+    }, "munderover element");
+    done();
+  }
+</script>
+</head>
+<body>
+  <math><mo id="math_default">&#x2AFF;</mo></math>
+  <math display="inline"><mo id="math_inline">&#x2AFF;</mo></math>
+  <math display="block"><mo id="math_block">&#x2AFF;</mo></math>
+  <math displaystyle="false"><mo id="math_false">&#x2AFF;</mo></math>
+  <math displaystyle="true"><mo id="math_true">&#x2AFF;</mo></math>
+  <math><mstyle displaystyle="false"><mo id="mstyle_false">&#x2AFF;</mo></mstyle></math>
+  <math><mstyle displaystyle="true"><mo id="mstyle_true">&#x2AFF;</mo></mstyle></math>
+  <math displaystyle="true"><mtable><mtr><mtd><mo id="mtable_default">&#x2AFF;</mo></mtd></mtr></mtable></math>
+  <math><mtable displaystyle="true"><mtr><mtd><mo id="mtable_true">&#x2AFF;</mo></mtd></mtr></mtable></math>
+  <math displaystyle="true"><mtable displaystyle="false"><mtr><mtd><mo id="mtable_false">&#x2AFF;</mo></mtd></mtr></mtable></math>
+  <math displaystyle="true"><mfrac><mo id="mfrac_numerator">&#x2AFF;</mo><mo id="mfrac_denominator">&#x2AFF;</mo></mfrac></math>
+  <math displaystyle="true"><mroot><mo id="mroot_base">&#x2AFF;</mo><mo id="mroot_index">&#x2AFF;</mo></mroot></math>
+  <math displaystyle="true"><msub><mo id="msub_base">&#x2AFF;</mo><mo id="msub_subscript">&#x2AFF;</mo></msub></math>
+  <math displaystyle="true"><msup><mo id="msup_base">&#x2AFF;</mo><mo id="msup_supscript">&#x2AFF;</mo></msup></math>
+  <math displaystyle="true"><msubsup><mo id="msubsup_base">&#x2AFF;</mo><mo id="msubsup_subscript">&#x2AFF;</mo><mo id="msubsup_supscript">&#x2AFF;</mo></msubsup></math>
+  <math displaystyle="true"><mmultiscripts><mo id="mmultiscripts_base">&#x2AFF;</mo><mo id="mmultiscripts_subscript">&#x2AFF;</mo><mo id="mmultiscripts_supscript">&#x2AFF;</mo><mprescripts/><mo id="mmultiscripts_presubscript">&#x2AFF;</mo><mo id="mmultiscripts_presupscript">&#x2AFF;</mo></mmultiscripts></math>
+  <math displaystyle="true"><munder><mo id="munder_base">&#x2AFF;</mo><mo id="munder_underscript">&#x2AFF;</mo></munder></math>
+  <math displaystyle="true"><mover><mo id="mover_base">&#x2AFF;</mo><mo id="mover_overscript">&#x2AFF;</mo></mover></math>
+  <math displaystyle="true"><munderover><mo id="munderover_base">&#x2AFF;</mo><mo id="munderover_underscript">&#x2AFF;</mo><mo id="munderover_overscript">&#x2AFF;</mo></munderover></math>
+</body>
+</html>
Property changes on: trunk/LayoutTests/imported/mathml-in-html5/mathml/relations/css-styling/displaystyle-1.html
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Added: trunk/LayoutTests/mathml/opentype/large-operators-displaystyle-dynamic-expected.html (0 => 202960)


--- trunk/LayoutTests/mathml/opentype/large-operators-displaystyle-dynamic-expected.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/opentype/large-operators-displaystyle-dynamic-expected.html	2016-07-08 05:40:20 UTC (rev 202960)
@@ -0,0 +1,39 @@
+<!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 display="inline"><mo>&#x2A1B;</mo></math>
+      <math display="block"><mo>&#x2A1B;</mo></math>
+      <math displaystyle="false"><mo>&#x2A1B;</mo></math>
+      <math displaystyle="true"><mo>&#x2A1B;</mo></math>
+      <math><mstyle displaystyle="false"><mo>&#x2A1B;</mo></mstyle></math>
+      <math><mstyle displaystyle="true"><mo>&#x2A1B;</mo></mstyle></math>
+      <math displaystyle="true"><mtable><mtr><mtd><mo>&#x2A1B;</mo></mtd></mtr></mtable></math>
+      <math><mtable displaystyle="true"><mtr><mtd><mo>&#x2A1B;</mo></mtd></mtr></mtable></math>
+      <math displaystyle="true"><mtable displaystyle="false"><mtr><mtd><mo>&#x2A1B;</mo></mtd></mtr></mtable></math>
+      <math displaystyle="true"><mfrac><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></mfrac></math>
+      <math displaystyle="true"><mroot><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></mroot></math>
+      <math displaystyle="true"><msub><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></msub></math>
+      <math displaystyle="true"><msup><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></msup></math>
+      <math displaystyle="true"><msubsup><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></msubsup></math>
+      <math displaystyle="true"><mmultiscripts><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo><mprescripts/><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></mmultiscripts></math>
+      <math displaystyle="true"><munder><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></munder></math>
+      <math displaystyle="true"><mover><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></mover></math>
+      <math displaystyle="true"><munderover><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo><mo>&#x2A1B;</mo></munderover></math>
+    </div>
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/opentype/large-operators-displaystyle-dynamic-expected.html
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Added: trunk/LayoutTests/mathml/opentype/large-operators-displaystyle-dynamic.html (0 => 202960)


--- trunk/LayoutTests/mathml/opentype/large-operators-displaystyle-dynamic.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/opentype/large-operators-displaystyle-dynamic.html	2016-07-08 05:40:20 UTC (rev 202960)
@@ -0,0 +1,63 @@
+<!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()
+        {
+            setTimeout(function()
+                {
+                    // 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");
+                    }
+                    if (window.testRunner)
+                      testRunner.notifyDone();
+                }, 50);
+        }
+
+        addEventListener('load', updatePageAfterRendering, false);
+    </script>
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/opentype/large-operators-displaystyle-dynamic.html
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Added: trunk/LayoutTests/platform/ios-simulator/mathml/opentype/large-operators-displaystyle-expected.txt (0 => 202960)


--- trunk/LayoutTests/platform/ios-simulator/mathml/opentype/large-operators-displaystyle-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/mathml/opentype/large-operators-displaystyle-expected.txt	2016-07-08 05:40:20 UTC (rev 202960)
@@ -0,0 +1,55 @@
+⨛
+ 
+⨛
+⨛
+⨛
+ 
+⨛
+ 
+⨛
+ 
+⨛
+  ⨛   ⨛   ⨛  
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+⨛
+⨛
+⨛
+⨛
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+⨛
+
+PASS math element 
+PASS mstyle element 
+PASS mtable element 
+PASS mfrac element 
+PASS mroot element 
+PASS msub element 
+PASS msup element 
+PASS msubsup element 
+PASS munder element 
+PASS mover element 
+PASS munderover element 
+
Property changes on: trunk/LayoutTests/platform/ios-simulator/mathml/opentype/large-operators-displaystyle-expected.txt
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: trunk/LayoutTests/platform/mac/mathml/opentype/large-operators-displaystyle-expected.txt (0 => 202960)


--- trunk/LayoutTests/platform/mac/mathml/opentype/large-operators-displaystyle-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/mathml/opentype/large-operators-displaystyle-expected.txt	2016-07-08 05:40:20 UTC (rev 202960)
@@ -0,0 +1,55 @@
+⨛
+ 
+⨛
+⨛
+⨛
+ 
+⨛
+ 
+⨛
+ 
+⨛
+  ⨛   ⨛   ⨛  
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+⨛
+⨛
+⨛
+⨛
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+ 
+⨛
+⨛
+⨛
+
+PASS math element 
+PASS mstyle element 
+PASS mtable element 
+PASS mfrac element 
+PASS mroot element 
+PASS msub element 
+PASS msup element 
+PASS msubsup element 
+PASS munder element 
+PASS mover element 
+PASS munderover element 
+
Property changes on: trunk/LayoutTests/platform/mac/mathml/opentype/large-operators-displaystyle-expected.txt
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Modified: trunk/Source/WebCore/CMakeLists.txt (202959 => 202960)


--- trunk/Source/WebCore/CMakeLists.txt	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-07-08 05:40:20 UTC (rev 202960)
@@ -2523,6 +2523,7 @@
     rendering/line/TrailingObjects.cpp
 
     rendering/mathml/MathMLOperatorDictionary.cpp
+    rendering/mathml/MathMLStyle.cpp
     rendering/mathml/MathOperator.cpp
     rendering/mathml/RenderMathMLBlock.cpp
     rendering/mathml/RenderMathMLFenced.cpp

Modified: trunk/Source/WebCore/ChangeLog (202959 => 202960)


--- trunk/Source/WebCore/ChangeLog	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/ChangeLog	2016-07-08 05:40:20 UTC (rev 202960)
@@ -1,3 +1,58 @@
+2016-07-07  Frederic Wang  <fw...@igalia.com>
+
+        Implement an internal style property for displaystyle.
+        https://bugs.webkit.org/show_bug.cgi?id=133845
+
+        Reviewed by Brent Fulgham.
+
+        Tests: mathml/opentype/large-operators-displaystyle-dynamic.html
+               mathml/opentype/large-operators-displaystyle.html
+
+        This is based on a patch by Alejandro G. Castro <a...@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>.
+
 2016-07-07  Ryosuke Niwa  <rn...@webkit.org>
 
         Replace scoped flag in Event by composed flag

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202959 => 202960)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-07-08 05:40:20 UTC (rev 202960)
@@ -1695,8 +1695,10 @@
 		439046DD12DA25E800AF80A2 /* RenderMathMLMath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046C912DA25E800AF80A2 /* RenderMathMLMath.cpp */; };
 		439046DE12DA25E800AF80A2 /* RenderMathMLMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046CA12DA25E800AF80A2 /* RenderMathMLMath.h */; };
 		439046DF12DA25E17BAF80A2 /* MathMLOperatorDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046CB12DA25E17BAF80A2 /* MathMLOperatorDictionary.cpp */; };
+		439176DF12DA25E17BAF80A2 /* MathMLStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439176CB12DA25E17BAF80A2 /* MathMLStyle.cpp */; };
 		439046DF12DA25E800AF80A2 /* RenderMathMLOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046CB12DA25E800AF80A2 /* RenderMathMLOperator.cpp */; };
 		439046E012DA25E17BAF80A2 /* MathMLOperatorDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046CC12DA25E17BAF80A2 /* MathMLOperatorDictionary.h */; };
+		439176E012DA25E17BAF80A2 /* MathMLStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 439176CC12DA25E17BAF80A2 /* MathMLStyle.h */; };
 		439046E012DA25E800AF80A2 /* RenderMathMLOperator.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046CC12DA25E800AF80A2 /* RenderMathMLOperator.h */; };
 		439046E112DA25E800AF80A2 /* RenderMathMLRoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046CD12DA25E800AF80A2 /* RenderMathMLRoot.cpp */; };
 		439046E212DA25E800AF80A2 /* RenderMathMLRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046CE12DA25E800AF80A2 /* RenderMathMLRoot.h */; };
@@ -9307,8 +9309,10 @@
 		439046C912DA25E800AF80A2 /* RenderMathMLMath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLMath.cpp; sourceTree = "<group>"; };
 		439046CA12DA25E800AF80A2 /* RenderMathMLMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLMath.h; sourceTree = "<group>"; };
 		439046CB12DA25E17BAF80A2 /* MathMLOperatorDictionary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLOperatorDictionary.cpp; sourceTree = "<group>"; };
+		439176CB12DA25E17BAF80A2 /* MathMLStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLStyle.cpp; sourceTree = "<group>"; };
 		439046CB12DA25E800AF80A2 /* RenderMathMLOperator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLOperator.cpp; sourceTree = "<group>"; };
 		439046CC12DA25E17BAF80A2 /* MathMLOperatorDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLOperatorDictionary.h; sourceTree = "<group>"; };
+		439176CC12DA25E17BAF80A2 /* MathMLStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLStyle.h; sourceTree = "<group>"; };
 		439046CC12DA25E800AF80A2 /* RenderMathMLOperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLOperator.h; sourceTree = "<group>"; };
 		439046CD12DA25E800AF80A2 /* RenderMathMLRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLRoot.cpp; sourceTree = "<group>"; };
 		439046CE12DA25E800AF80A2 /* RenderMathMLRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLRoot.h; sourceTree = "<group>"; };
@@ -17114,6 +17118,8 @@
 				439046CC12DA25E17BAF80A2 /* MathMLOperatorDictionary.h */,
 				439046D512DA25E812AF80AC /* MathOperator.cpp */,
 				439046D612DA25E812AF80AC /* MathOperator.h */,
+				439176CB12DA25E17BAF80A2 /* MathMLStyle.cpp */,
+				439176CC12DA25E17BAF80A2 /* MathMLStyle.h */,
 				439046C312DA25E800AF80A2 /* RenderMathMLBlock.cpp */,
 				439046C412DA25E800AF80A2 /* RenderMathMLBlock.h */,
 				439046C512DA25E800AF80A2 /* RenderMathMLFenced.cpp */,
@@ -27419,6 +27425,7 @@
 				FABE72F91059C1EB00D999DD /* MathMLMathElement.h in Headers */,
 				44A28AAF12DFB8BF00AE923B /* MathMLNames.h in Headers */,
 				439046E012DA25E17BAF80A2 /* MathMLOperatorDictionary.h in Headers */,
+				439176E012DA25E17BAF80A2 /* MathMLStyle.h in Headers */,
 				FA654A6C1108ABED002615E0 /* MathMLTextElement.h in Headers */,
 				439046EA12DA25E812AF80AC /* MathOperator.h in Headers */,
 				49D5DC2C0F423A73008F20FD /* Matrix3DTransformOperation.h in Headers */,
@@ -31244,6 +31251,7 @@
 				05D913CEEAB2A60534218ACF /* MathMLMencloseElement.cpp in Sources */,
 				FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */,
 				439046DF12DA25E17BAF80A2 /* MathMLOperatorDictionary.cpp in Sources */,
+				439176DF12DA25E17BAF80A2 /* MathMLStyle.cpp in Sources */,
 				FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */,
 				FA654A6B1108ABED002615E0 /* MathMLTextElement.cpp in Sources */,
 				439046E912DA25E812AF80AC /* MathOperator.cpp in Sources */,

Modified: trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp (202959 => 202960)


--- trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp	2016-07-08 05:40:20 UTC (rev 202960)
@@ -83,6 +83,14 @@
     return createRenderer<RenderMathMLBlock>(*this, WTFMove(style));
 }
 
+void MathMLInlineContainerElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
+{
+    if (name == displaystyleAttr && (hasTagName(mstyleTag) || hasTagName(mtableTag)) && renderer())
+        MathMLStyle::resolveMathMLStyleTree(renderer());
+
+    MathMLElement::parseAttribute(name, value);
 }
 
+}
+
 #endif // ENABLE(MATHML)

Modified: trunk/Source/WebCore/mathml/MathMLInlineContainerElement.h (202959 => 202960)


--- trunk/Source/WebCore/mathml/MathMLInlineContainerElement.h	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/mathml/MathMLInlineContainerElement.h	2016-07-08 05:40:20 UTC (rev 202960)
@@ -41,6 +41,7 @@
 protected:
     MathMLInlineContainerElement(const QualifiedName& tagName, Document&);
     void childrenChanged(const ChildChange&) override;
+    void parseAttribute(const QualifiedName&, const AtomicString&) override;
 
 private:
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;

Modified: trunk/Source/WebCore/mathml/MathMLMathElement.cpp (202959 => 202960)


--- trunk/Source/WebCore/mathml/MathMLMathElement.cpp	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/mathml/MathMLMathElement.cpp	2016-07-08 05:40:20 UTC (rev 202960)
@@ -29,13 +29,18 @@
 #if ENABLE(MATHML)
 
 #include "MathMLMathElement.h"
+
+#include "MathMLNames.h"
 #include "RenderMathMLMath.h"
 
 namespace WebCore {
 
+using namespace MathMLNames;
+
 inline MathMLMathElement::MathMLMathElement(const QualifiedName& tagName, Document& document)
     : MathMLInlineContainerElement(tagName, document)
 {
+    setHasCustomStyleResolveCallbacks();
 }
 
 Ref<MathMLMathElement> MathMLMathElement::create(const QualifiedName& tagName, Document& document)
@@ -48,6 +53,21 @@
     return createRenderer<RenderMathMLMath>(*this, WTFMove(style));
 }
 
+void MathMLMathElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
+{
+    if ((name == displaystyleAttr || name == displayAttr) && hasTagName(mathTag) && renderer())
+        MathMLStyle::resolveMathMLStyleTree(renderer());
+
+    MathMLInlineContainerElement::parseAttribute(name, value);
 }
 
+void MathMLMathElement::didAttachRenderers()
+{
+    MathMLInlineContainerElement::didAttachRenderers();
+
+    MathMLStyle::resolveMathMLStyleTree(renderer());
+}
+
+}
+
 #endif // ENABLE(MATHML)

Modified: trunk/Source/WebCore/mathml/MathMLMathElement.h (202959 => 202960)


--- trunk/Source/WebCore/mathml/MathMLMathElement.h	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/mathml/MathMLMathElement.h	2016-07-08 05:40:20 UTC (rev 202960)
@@ -36,8 +36,12 @@
 public:
     static Ref<MathMLMathElement> create(const QualifiedName& tagName, Document&);
 
+protected:
+    void didAttachRenderers() final;
+
 private:
     MathMLMathElement(const QualifiedName& tagName, Document&);
+    void parseAttribute(const QualifiedName&, const AtomicString&) final;
 
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
 };

Modified: trunk/Source/WebCore/mathml/mathattrs.in (202959 => 202960)


--- trunk/Source/WebCore/mathml/mathattrs.in	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/mathml/mathattrs.in	2016-07-08 05:40:20 UTC (rev 202960)
@@ -14,6 +14,8 @@
 denomalign
 depth
 dir
+display
+displaystyle
 encoding
 fence
 fontfamily

Added: trunk/Source/WebCore/rendering/mathml/MathMLStyle.cpp (0 => 202960)


--- trunk/Source/WebCore/rendering/mathml/MathMLStyle.cpp	                        (rev 0)
+++ trunk/Source/WebCore/rendering/mathml/MathMLStyle.cpp	2016-07-08 05:40:20 UTC (rev 202960)
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2016 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(MATHML)
+#include "MathMLStyle.h"
+
+#include "MathMLElement.h"
+#include "MathMLNames.h"
+#include "RenderMathMLBlock.h"
+#include "RenderMathMLFraction.h"
+#include "RenderMathMLMath.h"
+#include "RenderMathMLRoot.h"
+#include "RenderMathMLScripts.h"
+#include "RenderMathMLToken.h"
+#include "RenderMathMLUnderOver.h"
+
+namespace WebCore {
+
+using namespace MathMLNames;
+
+Ref<MathMLStyle> MathMLStyle::create()
+{
+    return adoptRef(*new MathMLStyle());
+}
+
+void MathMLStyle::setDisplayStyle(RenderObject* renderer)
+{
+    if (!renderer)
+        return;
+
+    // FIXME: Should we make RenderMathMLTable derive from RenderMathMLBlock in order to simplify this?
+    if (is<RenderMathMLTable>(renderer))
+        m_displayStyle = downcast<RenderMathMLTable>(renderer)->mathMLStyle()->displayStyle();
+    else if (is<RenderMathMLBlock>(renderer))
+        m_displayStyle = downcast<RenderMathMLBlock>(renderer)->mathMLStyle()->displayStyle();
+}
+
+void MathMLStyle::resolveMathMLStyleTree(RenderObject* renderer)
+{
+    for (auto* child = renderer; child; child = child->nextInPreOrder(renderer)) {
+        // FIXME: Should we make RenderMathMLTable derive from RenderMathMLBlock in order to simplify this?
+        if (is<RenderMathMLTable>(child))
+            downcast<RenderMathMLTable>(child)->mathMLStyle()->resolveMathMLStyle(child);
+        else if (is<RenderMathMLBlock>(child))
+            downcast<RenderMathMLBlock>(child)->mathMLStyle()->resolveMathMLStyle(child);
+    }
+}
+
+RenderObject* MathMLStyle::getMathMLParentNode(RenderObject* renderer)
+{
+    auto* parentRenderer = renderer->parent();
+
+    while (parentRenderer && !(is<RenderMathMLTable>(parentRenderer) || is<RenderMathMLBlock>(parentRenderer)))
+        parentRenderer = parentRenderer->parent();
+
+    return parentRenderer;
+}
+
+void MathMLStyle::updateStyleIfNeeded(RenderObject* renderer, bool oldDisplayStyle)
+{
+    if (oldDisplayStyle != m_displayStyle) {
+        if (is<RenderMathMLToken>(renderer))
+            downcast<RenderMathMLToken>(renderer)->updateTokenContent();
+        else if (is<RenderMathMLRoot>(renderer))
+            downcast<RenderMathMLRoot>(renderer)->updateStyle();
+    }
+}
+
+void MathMLStyle::resolveMathMLStyle(RenderObject* renderer)
+{
+    ASSERT(renderer);
+
+    bool oldDisplayStyle = m_displayStyle;
+
+    // For anonymous renderers, we just inherit the style from our parent.
+    if (renderer->isAnonymous()) {
+        setDisplayStyle(getMathMLParentNode(renderer));
+        updateStyleIfNeeded(renderer, oldDisplayStyle);
+        return;
+    }
+
+    if (is<RenderMathMLMath>(renderer))
+        m_displayStyle = downcast<RenderElement>(renderer)->element()->fastGetAttribute(displayAttr) == "block"; // The default displaystyle of the <math> element depends on its display attribute.
+    else if (is<RenderMathMLTable>(renderer))
+        m_displayStyle = false; // The default displaystyle of <mtable> is false.
+    else if (auto* parentRenderer = getMathMLParentNode(renderer)) {
+        setDisplayStyle(parentRenderer); // The default displaystyle is inherited from our parent.
+        if (is<RenderMathMLFraction>(parentRenderer))
+            m_displayStyle = false; // <mfrac> sets displaystyle to false within its numerator and denominator.
+        else if ((is<RenderMathMLRoot>(parentRenderer) && !parentRenderer->isRenderMathMLSquareRoot()) || is<RenderMathMLScripts>(parentRenderer) || is<RenderMathMLUnderOver>(parentRenderer)) {
+            // <mroot>, <msub>, <msup>, <msubsup>, <mmultiscripts>, <munder>, <mover> and <munderover> elements set displaystyle to false within their scripts.
+            auto* base = downcast<RenderBox>(parentRenderer)->firstChildBox();
+            if (renderer != base)
+                m_displayStyle = false;
+        }
+    }
+
+    // The displaystyle attribute on the <math>, <mtable> or <mstyle> elements override the default behavior.
+    const auto* element = downcast<RenderElement>(renderer)->element();
+    const QualifiedName& tagName = element->tagQName();
+    if (tagName == mathTag || tagName == mtableTag || tagName == mstyleTag) {
+        // We only modify the value of displaystyle if there is an explicit and valid attribute.
+        const AtomicString& attributeValue = element->fastGetAttribute(displaystyleAttr);
+        if (attributeValue == "true")
+            m_displayStyle = true;
+        else if (attributeValue == "false")
+            m_displayStyle = false;
+    }
+
+    updateStyleIfNeeded(renderer, oldDisplayStyle);
+}
+
+}
+
+#endif // ENABLE(MATHML)
Property changes on: trunk/Source/WebCore/rendering/mathml/MathMLStyle.cpp
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Copied: trunk/Source/WebCore/rendering/mathml/MathMLStyle.h (from rev 202959, trunk/Source/WebCore/mathml/MathMLInlineContainerElement.h) (0 => 202960)


--- trunk/Source/WebCore/rendering/mathml/MathMLStyle.h	                        (rev 0)
+++ trunk/Source/WebCore/rendering/mathml/MathMLStyle.h	2016-07-08 05:40:20 UTC (rev 202960)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MathMLStyle_h
+#define MathMLStyle_h
+#pragma once
+
+#if ENABLE(MATHML)
+
+#include "Element.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class MathMLStyle: public RefCounted<MathMLStyle> {
+public:
+    MathMLStyle() { }
+    static Ref<MathMLStyle> create();
+
+    bool displayStyle() const { return m_displayStyle; }
+    void setDisplayStyle(bool displayStyle) { m_displayStyle = displayStyle; }
+
+    void resolveMathMLStyle(RenderObject*);
+    static void resolveMathMLStyleTree(RenderObject*);
+
+private:
+    bool isDisplayStyleAlwaysFalse(RenderObject*);
+    void setDisplayStyle(RenderObject*);
+    RenderObject* getMathMLParentNode(RenderObject*);
+    void updateStyleIfNeeded(RenderObject*, bool);
+
+    bool m_displayStyle = false;
+};
+
+}
+
+#endif // ENABLE(MATHML)
+#endif // MathMLStyle_h

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp (202959 => 202960)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2016-07-08 05:40:20 UTC (rev 202960)
@@ -46,6 +46,7 @@
 
 RenderMathMLBlock::RenderMathMLBlock(Element& container, RenderStyle&& style)
     : RenderBlock(container, WTFMove(style), 0)
+    , m_mathMLStyle(MathMLStyle::create())
 {
     setChildrenInline(false); // All of our children must be block-level.
 }
@@ -52,6 +53,7 @@
 
 RenderMathMLBlock::RenderMathMLBlock(Document& document, RenderStyle&& style)
     : RenderBlock(document, WTFMove(style), 0)
+    , m_mathMLStyle(MathMLStyle::create())
 {
     setChildrenInline(false); // All of our children must be block-level.
 }

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h (202959 => 202960)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h	2016-07-08 05:40:20 UTC (rev 202960)
@@ -29,6 +29,7 @@
 
 #if ENABLE(MATHML)
 
+#include "MathMLStyle.h"
 #include "RenderBlock.h"
 #include "RenderTable.h"
 #include "StyleInheritedData.h"
@@ -45,6 +46,8 @@
     RenderMathMLBlock(Document&, RenderStyle&&);
     virtual ~RenderMathMLBlock();
 
+    MathMLStyle* mathMLStyle() const { return const_cast<MathMLStyle*>(&m_mathMLStyle.get()); }
+
     bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
 
     // MathML defines an "embellished operator" as roughly an <mo> that may have subscripts,
@@ -80,6 +83,8 @@
     bool avoidsFloats() const final { return true; }
     bool canDropAnonymousBlockChild() const final { return false; }
     void layoutItems(bool relayoutChildren);
+
+    Ref<MathMLStyle> m_mathMLStyle;
 };
 
 class RenderMathMLTable final : public RenderTable {
@@ -86,14 +91,19 @@
 public:
     explicit RenderMathMLTable(Element& element, RenderStyle&& style)
         : RenderTable(element, WTFMove(style))
+        , m_mathMLStyle(MathMLStyle::create())
     {
     }
 
     Optional<int> firstLineBaseline() const override;
 
+    MathMLStyle* mathMLStyle() const { return const_cast<MathMLStyle*>(&m_mathMLStyle.get()); }
+
 private:
     bool isRenderMathMLTable() const override { return true; }
     const char* renderName() const override { return "RenderMathMLTable"; }
+
+    Ref<MathMLStyle> m_mathMLStyle;
 };
 
 // Parsing functions for MathML Length values

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h (202959 => 202960)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h	2016-07-08 05:40:20 UTC (rev 202960)
@@ -49,8 +49,7 @@
     void resetStretchSize();
 
     bool hasOperatorFlag(MathMLOperatorDictionary::Flag flag) const { return m_operatorFlags & flag; }
-    // FIXME: The displaystyle property is not implemented (https://bugs.webkit.org/show_bug.cgi?id=118737).
-    bool isLargeOperatorInDisplayStyle() const { return !hasOperatorFlag(MathMLOperatorDictionary::Stretchy) && hasOperatorFlag(MathMLOperatorDictionary::LargeOp); }
+    bool isLargeOperatorInDisplayStyle() const { return !hasOperatorFlag(MathMLOperatorDictionary::Stretchy) && hasOperatorFlag(MathMLOperatorDictionary::LargeOp) && mathMLStyle()->displayStyle(); }
     bool isVertical() const { return m_isVertical; }
     LayoutUnit italicCorrection() const { return m_mathOperator.italicCorrection(); }
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h (202959 => 202960)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h	2016-07-08 05:40:20 UTC (rev 202960)
@@ -49,6 +49,7 @@
 
     void computePreferredLogicalWidths() final;
     void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
+    void updateStyle();
 
 protected:
     void paint(PaintInfo&, const LayoutPoint&) final;
@@ -59,7 +60,6 @@
     RenderBox& getIndex() const;
     bool isRenderMathMLRoot() const final { return true; }
     const char* renderName() const final { return "RenderMathMLRoot"; }
-    void updateStyle();
 
     MathOperator m_radicalOperator;
     LayoutUnit m_verticalGap;

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h (202959 => 202960)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h	2016-07-08 05:20:48 UTC (rev 202959)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h	2016-07-08 05:40:20 UTC (rev 202960)
@@ -61,6 +61,8 @@
 
 }
 
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLUnderOver, isRenderMathMLUnderOver())
+
 #endif // ENABLE(MATHML)
 
 #endif // RenderMathMLUnderOver_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to