Title: [202970] trunk
Revision
202970
Author
[email protected]
Date
2016-07-08 00:15:24 -0700 (Fri, 08 Jul 2016)

Log Message

Add support for movablelimits.
https://bugs.webkit.org/show_bug.cgi?id=155542

Patch by Frederic Wang <[email protected]> on 2016-07-08
Reviewed by Brent Fulgham.

Source/WebCore:

Tests: mathml/presentation/displaystyle-1.html
       mathml/presentation/displaystyle-2.html
       mathml/presentation/displaystyle-3.html
       mathml/presentation/mo-movablelimits-default.html
       mathml/presentation/mo-movablelimits-dynamic.html
       mathml/presentation/mo-movablelimits.html

* mathml/MathMLTextElement.cpp:
(WebCore::MathMLTextElement::parseAttribute): Take into account change of movablelimits.
* rendering/mathml/MathMLOperatorDictionary.h: Remove FIXME comment.
* rendering/mathml/MathMLStyle.cpp:
(WebCore::MathMLStyle::updateStyleIfNeeded): Force relayout and width computation when a
displaystyle value change.
* rendering/mathml/RenderMathMLOperator.h:
(WebCore::RenderMathMLOperator::shouldMoveLimits): Helper function to test if the operator
should have his limits moved when used as a base of munder/mover/munderover.
* rendering/mathml/RenderMathMLScripts.cpp: Allow munderover/munder/mover elements to use
this class and take the same behavior as the corresponding msubsup/msub/sup except for
the *scriptshift attributes.
(WebCore::RenderMathMLScripts::RenderMathMLScripts):
(WebCore::RenderMathMLScripts::getBaseAndScripts):
(WebCore::RenderMathMLScripts::computePreferredLogicalWidths):
(WebCore::RenderMathMLScripts::getScriptMetricsAndLayoutIfNeeded):
(WebCore::RenderMathMLScripts::layoutBlock):
* rendering/mathml/RenderMathMLScripts.h: Allow some members to be accessible/overridden
by RenderMathMLUnderOver and add munderover/munder/mover in the kind.
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::RenderMathMLUnderOver): We use the code from
RenderMathMLScripts to initialize m_kind.
(WebCore::RenderMathMLUnderOver::shouldMoveLimits): New function to determine if the base
should move its limits.
(WebCore::RenderMathMLUnderOver::computePreferredLogicalWidths): We use the code from
RenderMathMLScripts when the base should move its limits.
(WebCore::RenderMathMLUnderOver::layoutBlock): We use the code from RenderMathMLScripts when
the base should move its limits. Also improve the early return for invalid markup.
(WebCore::RenderMathMLUnderOver::unembellishedOperator): Deleted. We use the code from RenderMathMLScripts.
(WebCore::RenderMathMLUnderOver::firstLineBaseline): Deleted. We use the code from RenderMathMLScripts.
* rendering/mathml/RenderMathMLUnderOver.h: We now inherit from RenderMathMLScripts and can
just remove members that exist in the parent. We define shouldMoveLimits() to determine
when the layout should be done the same as RenderMathMLScripts. For now, we try and be
safe with the rest of the code by continuing to claim that we are not a RenderMathMLScripts.

LayoutTests:

We import some reftests from Mozilla and write more tests in order to verify the effect of
movablelimits. We also adjust one existing test due to change in how munderover handles
invalid markup.

* mathml/presentation/displaystyle-1.html: Added. Imported from Mozilla. This verifies the
inheritance of displaystyle via its effect on movablelimits.
* mathml/presentation/displaystyle-1-expected.html: Added.
* mathml/presentation/displaystyle-2.html: Added. Imported from Mozilla. Test the effect of
displaystyle on munder, mover and munderover with a movablelimits base.
* mathml/presentation/displaystyle-2-expected.html: Added.
* mathml/presentation/displaystyle-3.html: Added. Imported from Mozilla. Test dynamic change
of displaystyle via its effect on movablelimits.
* mathml/presentation/displaystyle-3-expected.html: Added.
* mathml/presentation/mo-movablelimits-default.html: Added. Test that the default
movablelimits value from the operator dictionary is correctly read.
* mathml/presentation/mo-movablelimits-default-expected.html: Added.
* mathml/presentation/mo-movablelimits-dynamic.html: Added. Imported from Mozilla.
Test dynamic change of movablelimits.
* mathml/presentation/mo-movablelimits-dynamic-expected.html: Added.
* mathml/presentation/mo-movablelimits.html: Added. Basic test to check the effect of
movablelimits on munder.
* mathml/presentation/mo-movablelimits-expected.html: Added.
* mathml/presentation/underover-scriptshifts.html: Added. This verifies that script shifts
do not have any effect on munderover/mover/munder elements when their limits are rendered
as postscripts.
* mathml/presentation/underover-scriptshifts-expected.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202969 => 202970)


--- trunk/LayoutTests/ChangeLog	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/LayoutTests/ChangeLog	2016-07-08 07:15:24 UTC (rev 202970)
@@ -1,3 +1,37 @@
+2016-07-08  Frederic Wang  <[email protected]>
+
+        Add support for movablelimits.
+        https://bugs.webkit.org/show_bug.cgi?id=155542
+
+        Reviewed by Brent Fulgham.
+
+        We import some reftests from Mozilla and write more tests in order to verify the effect of
+        movablelimits. We also adjust one existing test due to change in how munderover handles
+        invalid markup.
+
+        * mathml/presentation/displaystyle-1.html: Added. Imported from Mozilla. This verifies the
+        inheritance of displaystyle via its effect on movablelimits.
+        * mathml/presentation/displaystyle-1-expected.html: Added.
+        * mathml/presentation/displaystyle-2.html: Added. Imported from Mozilla. Test the effect of
+        displaystyle on munder, mover and munderover with a movablelimits base.
+        * mathml/presentation/displaystyle-2-expected.html: Added.
+        * mathml/presentation/displaystyle-3.html: Added. Imported from Mozilla. Test dynamic change
+        of displaystyle via its effect on movablelimits.
+        * mathml/presentation/displaystyle-3-expected.html: Added.
+        * mathml/presentation/mo-movablelimits-default.html: Added. Test that the default
+        movablelimits value from the operator dictionary is correctly read.
+        * mathml/presentation/mo-movablelimits-default-expected.html: Added.
+        * mathml/presentation/mo-movablelimits-dynamic.html: Added. Imported from Mozilla.
+        Test dynamic change of movablelimits.
+        * mathml/presentation/mo-movablelimits-dynamic-expected.html: Added.
+        * mathml/presentation/mo-movablelimits.html: Added. Basic test to check the effect of
+        movablelimits on munder.
+        * mathml/presentation/mo-movablelimits-expected.html: Added.
+        * mathml/presentation/underover-scriptshifts.html: Added. This verifies that script shifts
+        do not have any effect on munderover/mover/munder elements when their limits are rendered
+        as postscripts.
+        * mathml/presentation/underover-scriptshifts-expected.html: Added.
+
 2016-07-07  Joseph Pecoraro  <[email protected]>
 
         padStart/padEnd with Infinity produces unexpected result

Added: trunk/LayoutTests/mathml/presentation/displaystyle-1-expected.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/displaystyle-1-expected.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/displaystyle-1-expected.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,149 @@
+<!doctype html>
+<html>
+  <head>
+    <title>displaystyle</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+
+    <!-- Test displaystyle on mstyle -->
+    <math>
+      <mstyle displaystyle="true">
+        <munder><mo>O</mo><mo>O</mo></munder>
+      </mstyle>
+      <mstyle displaystyle="false">
+        <msub><mo>O</mo><mo>O</mo></munder>
+      </mstyle>
+    </math>
+
+    <!-- The mfrac element sets displaystyle to "false", or if it was already
+         false increments scriptlevel by 1, within numerator and denominator.
+      -->
+    <math>
+      <mstyle displaystyle="true">
+        <mfrac>
+          <msub><mo>O</mo><mo>O</mo></msub>
+          <msub><mo>O</mo><mo>O</mo></msub>
+        </mfrac>
+      </mstyle>
+    </math>
+
+    <!--    The mroot element increments scriptlevel by 2, and sets
+            displaystyle to "false", within index, but leaves both attributes
+            unchanged within base.
+            The msqrt element leaves both attributes unchanged within its
+            argument. -->
+    <math>
+      <mstyle displaystyle="true">
+        <mroot>
+          <munder><mo>O</mo><mo>O</mo></munder>
+          <msub><mo>O</mo><mo>O</mo></msub>
+        </mroot>
+        <msqrt>
+          <munder><mo>O</mo><mo>O</mo></munder>
+        </msqrt>
+      </mstyle>
+    </math>
+
+<!--
+    The msub element [...] increments scriptlevel by 1, and sets displaystyle to
+   "false", within subscript, but leaves both attributes unchanged within base.
+
+   The msup element [...] increments scriptlevel by 1, and sets displaystyle to
+   "false", within superscript, but leaves both attributes unchanged within
+   base.
+
+   The msubsup element [...] increments scriptlevel by 1, and sets displaystyle
+   to "false", within subscript and superscript, but leaves both attributes
+   unchanged within base.
+
+   The mmultiscripts element increments scriptlevel by 1, and sets displaystyle
+   to "false", within each of its arguments except base, but leaves both
+   attributes unchanged within base.
+   -->
+    <math>
+      <mstyle displaystyle="true">
+        <msub>
+          <munder><mo>O</mo><mo>O</mo></munder>
+          <msub><mo>O</mo><mo>O</mo></msub>
+        </msub>
+        <msup>
+          <munder><mo>O</mo><mo>O</mo></munder>
+          <msub><mo>O</mo><mo>O</mo></msub>
+        </msup>
+        <msubsup>
+          <munder><mo>O</mo><mo>O</mo></munder>
+          <msub><mo>O</mo><mo>O</mo></msub>
+          <msub><mo>O</mo><mo>O</mo></msub>
+        </msubsup>
+        <mmultiscripts>
+          <munder><mo>O</mo><mo>O</mo></munder>
+          <msub><mo>O</mo><mo>O</mo></msub>
+          <msub><mo>O</mo><mo>O</mo></msub>
+          <mprescripts/>
+          <msub><mo>O</mo><mo>O</mo></msub>
+          <msub><mo>O</mo><mo>O</mo></msub>
+        </mmultiscripts>
+      </mstyle>
+    </math>
+
+<!--
+   The munder element [...] always sets displaystyle to "false" within the
+   underscript, but increments scriptlevel by 1 only when accentunder is
+   "false". Within base, it always leaves both attributes unchanged.
+
+   The mover element [...] always sets displaystyle to "false" within
+   overscript, but increments scriptlevel by 1 only when accent is "false".
+   Within base, it always leaves both attributes unchanged.
+
+   The munderover [..] always sets displaystyle to "false" within underscript
+   and overscript, but increments scriptlevel by 1 only when accentunder or
+   accent, respectively, are "false". Within base, it always leaves both
+   attributes unchanged.
+-->
+    <math>
+      <mstyle displaystyle="true">
+        <munder>
+          <munder><mo>O</mo><mo>O</mo></munder>
+          <msub><mo>O</mo><mo>O</mo></msub>
+        </munder>
+        <mover>
+          <munder><mo>O</mo><mo>O</mo></munder>
+          <msub><mo>O</mo><mo>O</mo></msub>
+        </mover>
+        <munderover>
+          <munder><mo>O</mo><mo>O</mo></munder>
+          <msub><mo>O</mo><mo>O</mo></msub>
+          <msub><mo>O</mo><mo>O</mo></msub>
+        </munderover>
+      </mstyle>
+    </math>
+
+<!--
+   The displaystyle attribute is allowed on the mtable element to set the
+   inherited value of the attribute. If the attribute is not present, the
+   mtable element sets displaystyle to "false" within the table elements.
+-->
+    <math>
+      <mstyle displaystyle="false">
+        <mtable displaystyle="true">
+          <mtr>
+            <mtd>
+              <munder><mo>O</mo><mo>O</mo></munder>
+            </mtd>
+          </mtr>
+        </mtable>
+      </mstyle>
+      <mstyle displaystyle="true">
+        <mtable>
+          <mtr>
+            <mtd>
+              <msub><mo>O</mo><mo>O</mo></msub>
+            </mtd>
+          </mtr>
+        </mtable>
+      </mstyle>
+    </math>
+
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/displaystyle-1-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/presentation/displaystyle-1.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/displaystyle-1.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/displaystyle-1.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,149 @@
+<!doctype html>
+<html>
+  <head>
+    <title>displaystyle</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+
+    <!-- Test displaystyle on mstyle -->
+    <math>
+      <mstyle displaystyle="true">
+        <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+      </mstyle>
+      <mstyle displaystyle="false">
+        <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+      </mstyle>
+    </math>
+
+    <!-- The mfrac element sets displaystyle to "false", or if it was already
+         false increments scriptlevel by 1, within numerator and denominator.
+      -->
+    <math>
+      <mstyle displaystyle="true">
+        <mfrac>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </mfrac>
+      </mstyle>
+    </math>
+
+    <!--    The mroot element increments scriptlevel by 2, and sets
+            displaystyle to "false", within index, but leaves both attributes
+            unchanged within base.
+            The msqrt element leaves both attributes unchanged within its
+            argument. -->
+    <math>
+      <mstyle displaystyle="true">
+        <mroot>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </mroot>
+        <msqrt>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </msqrt>
+      </mstyle>
+    </math>
+
+<!--
+    The msub element [...] increments scriptlevel by 1, and sets displaystyle to
+   "false", within subscript, but leaves both attributes unchanged within base.
+
+   The msup element [...] increments scriptlevel by 1, and sets displaystyle to
+   "false", within superscript, but leaves both attributes unchanged within
+   base.
+
+   The msubsup element [...] increments scriptlevel by 1, and sets displaystyle
+   to "false", within subscript and superscript, but leaves both attributes
+   unchanged within base.
+
+   The mmultiscripts element increments scriptlevel by 1, and sets displaystyle
+   to "false", within each of its arguments except base, but leaves both
+   attributes unchanged within base.
+   -->
+    <math>
+      <mstyle displaystyle="true">
+        <msub>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </msub>
+        <msup>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </msup>
+        <msubsup>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </msubsup>
+        <mmultiscripts>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <mprescripts/>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </mmultiscripts>
+      </mstyle>
+    </math>
+
+<!--
+   The munder element [...] always sets displaystyle to "false" within the
+   underscript, but increments scriptlevel by 1 only when accentunder is
+   "false". Within base, it always leaves both attributes unchanged.
+
+   The mover element [...] always sets displaystyle to "false" within
+   overscript, but increments scriptlevel by 1 only when accent is "false".
+   Within base, it always leaves both attributes unchanged.
+
+   The munderover [..] always sets displaystyle to "false" within underscript
+   and overscript, but increments scriptlevel by 1 only when accentunder or
+   accent, respectively, are "false". Within base, it always leaves both
+   attributes unchanged.
+-->
+    <math>
+      <mstyle displaystyle="true">
+        <munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </munder>
+        <mover>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </mover>
+        <munderover>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+          <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        </munderover>
+      </mstyle>
+    </math>
+
+<!--
+   The displaystyle attribute is allowed on the mtable element to set the
+   inherited value of the attribute. If the attribute is not present, the
+   mtable element sets displaystyle to "false" within the table elements.
+-->
+    <math>
+      <mstyle displaystyle="false">
+        <mtable displaystyle="true">
+          <mtr>
+            <mtd>
+              <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+            </mtd>
+          </mtr>
+        </mtable>
+      </mstyle>
+      <mstyle displaystyle="true">
+        <mtable>
+          <mtr>
+            <mtd>
+              <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+            </mtd>
+          </mtr>
+        </mtable>
+      </mstyle>
+    </math>
+
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/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/presentation/displaystyle-2-expected.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/displaystyle-2-expected.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/displaystyle-2-expected.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,24 @@
+<!doctype html>
+<html>
+  <head>
+    <title>displaystyle</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+
+    <!-- Test the effect of displaystyle on munder, mover and munderover -->
+    <math>
+      <mstyle displaystyle="true">
+        <munder><mo>O</mo><mo>O</mo></munder>
+        <mover><mo>O</mo><mo>O</mo></mover>
+        <munderover><mo>O</mo><mo>O</mo><mo>O</mo></munderover>
+      </mstyle>
+      <mstyle displaystyle="false">
+        <msub><mo>O</mo><mo>O</mo></msub>
+        <msup><mo>O</mo><mo>O</mo></msup>
+        <msubsup><mo>O</mo><mo>O</mo><mo>O</mo></msubsup>
+      </mstyle>
+    </math>
+
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/displaystyle-2-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/presentation/displaystyle-2.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/displaystyle-2.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/displaystyle-2.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,24 @@
+<!doctype html>
+<html>
+  <head>
+    <title>displaystyle</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+
+    <!-- Test the effect of displaystyle on munder, mover and munderover -->
+    <math>
+      <mstyle displaystyle="true">
+        <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        <mover><mo movablelimits="true">O</mo><mo>O</mo></mover>
+        <munderover><mo movablelimits="true">O</mo><mo>O</mo><mo>O</mo></munderover>
+      </mstyle>
+      <mstyle displaystyle="false">
+        <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        <mover><mo movablelimits="true">O</mo><mo>O</mo></mover>
+        <munderover><mo movablelimits="true">O</mo><mo>O</mo><mo>O</mo></munderover>
+      </mstyle>
+    </math>
+
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/displaystyle-2.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/presentation/displaystyle-3-expected.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/displaystyle-3-expected.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/displaystyle-3-expected.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,52 @@
+<!doctype html>
+<html>
+  <head>
+    <title>displaystyle</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+
+    <!-- Test dynamic change of displaystyle -->
+    <math id="m1" displaystyle="true">
+      <munder><mo>O</mo><mo>O</mo></munder>
+      <mfrac><mi>x</mi><mi>y</mi></mfrac>
+    </math>
+    <math>
+      <mstyle id="m2" displaystyle="true">
+        <munder><mo>O</mo><mo>O</mo></munder>
+        <mfrac><mi>x</mi><mi>y</mi></mfrac>
+      </mstyle>
+    </math>
+    <math>
+      <mtable id="m3" displaystyle="true">
+        <mtr>
+          <mtd>
+            <munder><mo>O</mo><mo>O</mo></munder>
+            <mfrac><mi>x</mi><mi>y</mi></mfrac>
+          </mtd>
+        </mtr>
+      </mtable>
+    </math>
+    <math id="m4" displaystyle="false">
+      <msub><mo>O</mo><mo>O</mo></msub>
+      <mfrac><mi>x</mi><mi>y</mi></mfrac>
+    </math>
+    <math>
+      <mstyle id="m5" displaystyle="false">
+        <msub><mo>O</mo><mo>O</mo></msub>
+        <mfrac><mi>x</mi><mi>y</mi></mfrac>
+      </mstyle>
+    </math>
+    <math>
+      <mtable id="m6" displaystyle="false">
+        <mtr>
+          <mtd>
+            <msub><mo>O</mo><mo>O</mo></msub>
+            <mfrac><mi>x</mi><mi>y</mi></mfrac>
+          </mtd>
+        </mtr>
+      </mtable>
+    </math>
+
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/displaystyle-3-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/presentation/displaystyle-3.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/displaystyle-3.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/displaystyle-3.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,64 @@
+<!doctype html>
+<html class="reftest-wait">
+  <head>
+    <title>displaystyle</title>
+    <meta charset="utf-8"/>
+    <script type="text/_javascript_">
+      function doTest() {
+        document.getElementById("m1").setAttribute("displaystyle", "true");
+        document.getElementById("m2").setAttribute("displaystyle", "true");
+        document.getElementById("m3").setAttribute("displaystyle", "true");
+        document.getElementById("m4").removeAttribute("displaystyle");
+        document.getElementById("m5").removeAttribute("displaystyle");
+        document.getElementById("m6").removeAttribute("displaystyle");
+        document.documentElement.removeAttribute("class");
+      }
+      window.addEventListener("load", doTest, false);
+    </script>
+  </head>
+  <body>
+
+    <!-- Test dynamic change of displaystyle -->
+    <math id="m1">
+      <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+      <mfrac><mi>x</mi><mi>y</mi></mfrac>
+    </math>
+    <math>
+      <mstyle id="m2">
+        <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        <mfrac><mi>x</mi><mi>y</mi></mfrac>
+      </mstyle>
+    </math>
+    <math>
+      <mtable id="m3">
+        <mtr>
+          <mtd>
+            <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+            <mfrac><mi>x</mi><mi>y</mi></mfrac>
+          </mtd>
+        </mtr>
+      </mtable>
+    </math>
+    <math id="m4" displaystyle="true">
+      <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+      <mfrac><mi>x</mi><mi>y</mi></mfrac>
+    </math>
+    <math>
+      <mstyle id="m5" displaystyle="true">
+        <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+        <mfrac><mi>x</mi><mi>y</mi></mfrac>
+      </mstyle>
+    </math>
+    <math>
+      <mtable id="m6" displaystyle="true">
+        <mtr>
+          <mtd>
+            <munder><mo movablelimits="true">O</mo><mo>O</mo></munder>
+            <mfrac><mi>x</mi><mi>y</mi></mfrac>
+          </mtd>
+        </mtr>
+      </mtable>
+    </math>
+
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/displaystyle-3.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/presentation/mo-movablelimits-default-expected.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/mo-movablelimits-default-expected.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mo-movablelimits-default-expected.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>mo movablelimits default value</title>
+  <meta charset="utf-8"/></head>
+<body>
+  <math>
+    <munder>
+      <mo movablelimits="true">∑</mo>
+      <mi>x</mi>
+    </munder>
+    <munder>
+      <mo movablelimits="false">∫</mo>
+      <mi>x</mi>
+    </munder>
+  </math>
+</body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/mo-movablelimits-default-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/presentation/mo-movablelimits-default.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/mo-movablelimits-default.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mo-movablelimits-default.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>mo movablelimits default value</title>
+  <meta charset="utf-8"/>
+</head>
+<body>
+  <math>
+    <munder>
+      <mo>∑</mo> <!-- This has movablelimits="true" in the operator dictionary -->
+      <mi>x</mi>
+    </munder>
+    <munder>
+      <mo>∫</mo> <!-- This has movablelimits="false" in the operator dictionary -->
+      <mi>x</mi>
+    </munder>
+  </math>
+</body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/mo-movablelimits-default.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/presentation/mo-movablelimits-dynamic-expected.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/mo-movablelimits-dynamic-expected.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mo-movablelimits-dynamic-expected.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+   <head>
+     <title>mo@movablelimits</title>
+     <meta charset="utf-8"/>
+   </head>
+   <body>
+    <math>
+      <munder>
+          <mo>∑</mo>
+          <mi>x</mi>
+      </munder>
+    </math>
+   </body>
+ </html>
Property changes on: trunk/LayoutTests/mathml/presentation/mo-movablelimits-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/presentation/mo-movablelimits-dynamic.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/mo-movablelimits-dynamic.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mo-movablelimits-dynamic.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+   <head>
+     <title>mo@movablelimits</title>
+     <meta charset="utf-8"/>
+     <script type="text/_javascript_">
+       function doTest() {
+         document.getElementById('a').removeAttribute('movablelimits');
+         document.documentElement.removeAttribute("class");
+       }
+       window.addEventListener("load",doTest, false);
+     </script>
+    </head>
+    <body>
+    <math>
+      <munder>
+          <mo id="a" movablelimits="false">∑</mo>
+          <mi>x</mi>
+      </munder>
+    </math>
+    </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/mo-movablelimits-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/mathml/presentation/mo-movablelimits-expected.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/mo-movablelimits-expected.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mo-movablelimits-expected.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>mo movablelimits</title>
+  <meta charset="utf-8"/>
+</head>
+<body>
+  <math>
+    <msub>
+      <mtext>A</mtext>
+      <mi>B</mi>
+    </msub>
+    <munder>
+      <mtext>A</mtext>
+      <mi>B</mi>
+    </munder>
+  </math>
+  <math displaystyle="true">
+    <munder>
+      <mtext>A</mtext>
+      <mi>B</mi>
+    </munder>
+    <munder>
+      <mtext>A</mtext>
+      <mi>B</mi>
+    </munder>
+  </math>
+</body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/mo-movablelimits-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/presentation/mo-movablelimits.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/mo-movablelimits.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mo-movablelimits.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>mo movablelimits</title>
+  <meta charset="utf-8"/>
+</head>
+<body>
+  <math>
+    <munder>
+      <mo lspace="0px" rspace="0px" movablelimits="true">A</mo>
+      <mi>B</mi>
+    </munder>
+    <munder>
+      <mo lspace="0px" rspace="0px" movablelimits="false">A</mo>
+      <mi>B</mi>
+    </munder>
+  </math>
+  <math displaystyle="true">
+    <munder>
+      <mo lspace="0px" rspace="0px" movablelimits="true">A</mo>
+      <mi>B</mi>
+    </munder>
+    <munder>
+      <mo lspace="0px" rspace="0px" movablelimits="false">A</mo>
+      <mi>B</mi>
+    </munder>
+  </math>
+</body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/mo-movablelimits.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/presentation/underover-scriptshifts-expected.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/underover-scriptshifts-expected.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/underover-scriptshifts-expected.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+  <head>
+    <title>subscriptshift/superscriptshift underover</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+
+    <math>
+      <munder>
+        <mo>&sum;</mo>
+        <mspace width="10px" height="10px" mathbackground="red"/>
+      </munder>
+      <mover>
+        <mo>&sum;</mo>
+        <mspace width="10px" height="10px" mathbackground="red"/>
+      </mover>
+      <munderover>
+        <mo>&sum;</mo>
+        <mspace width="10px" height="10px" mathbackground="red"/>
+        <mspace width="10px" height="10px" mathbackground="red"/>
+      </munderover>
+    </math>
+
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/underover-scriptshifts-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/presentation/underover-scriptshifts.html (0 => 202970)


--- trunk/LayoutTests/mathml/presentation/underover-scriptshifts.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/underover-scriptshifts.html	2016-07-08 07:15:24 UTC (rev 202970)
@@ -0,0 +1,27 @@
+<!doctype html>
+<html>
+  <head>
+    <title>subscriptshift/superscriptshift underover</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+
+    <!-- This test passes if the subscriptshift and superscriptshift attributes are ignored -->
+    <math>
+      <munder subscriptshift="100px">
+        <mo>&sum;</mo>
+        <mspace width="10px" height="10px" mathbackground="red"/>
+      </munder>
+      <mover superscriptshift="100px">
+        <mo>&sum;</mo>
+        <mspace width="10px" height="10px" mathbackground="red"/>
+      </mover>
+      <munderover subscriptshift="100px" superscriptshift="100px">
+        <mo>&sum;</mo>
+        <mspace width="10px" height="10px" mathbackground="red"/>
+        <mspace width="10px" height="10px" mathbackground="red"/>
+      </munderover>
+    </math>
+
+  </body>
+</html>
Property changes on: trunk/LayoutTests/mathml/presentation/underover-scriptshifts.html
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Modified: trunk/Source/WebCore/ChangeLog (202969 => 202970)


--- trunk/Source/WebCore/ChangeLog	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/Source/WebCore/ChangeLog	2016-07-08 07:15:24 UTC (rev 202970)
@@ -1,3 +1,52 @@
+2016-07-08  Frederic Wang  <[email protected]>
+
+        Add support for movablelimits.
+        https://bugs.webkit.org/show_bug.cgi?id=155542
+
+        Reviewed by Brent Fulgham.
+
+        Tests: mathml/presentation/displaystyle-1.html
+               mathml/presentation/displaystyle-2.html
+               mathml/presentation/displaystyle-3.html
+               mathml/presentation/mo-movablelimits-default.html
+               mathml/presentation/mo-movablelimits-dynamic.html
+               mathml/presentation/mo-movablelimits.html
+
+        * mathml/MathMLTextElement.cpp:
+        (WebCore::MathMLTextElement::parseAttribute): Take into account change of movablelimits.
+        * rendering/mathml/MathMLOperatorDictionary.h: Remove FIXME comment.
+        * rendering/mathml/MathMLStyle.cpp:
+        (WebCore::MathMLStyle::updateStyleIfNeeded): Force relayout and width computation when a
+        displaystyle value change.
+        * rendering/mathml/RenderMathMLOperator.h:
+        (WebCore::RenderMathMLOperator::shouldMoveLimits): Helper function to test if the operator
+        should have his limits moved when used as a base of munder/mover/munderover.
+        * rendering/mathml/RenderMathMLScripts.cpp: Allow munderover/munder/mover elements to use
+        this class and take the same behavior as the corresponding msubsup/msub/sup except for
+        the *scriptshift attributes.
+        (WebCore::RenderMathMLScripts::RenderMathMLScripts):
+        (WebCore::RenderMathMLScripts::getBaseAndScripts):
+        (WebCore::RenderMathMLScripts::computePreferredLogicalWidths):
+        (WebCore::RenderMathMLScripts::getScriptMetricsAndLayoutIfNeeded):
+        (WebCore::RenderMathMLScripts::layoutBlock):
+        * rendering/mathml/RenderMathMLScripts.h: Allow some members to be accessible/overridden
+        by RenderMathMLUnderOver and add munderover/munder/mover in the kind.
+        * rendering/mathml/RenderMathMLUnderOver.cpp:
+        (WebCore::RenderMathMLUnderOver::RenderMathMLUnderOver): We use the code from
+        RenderMathMLScripts to initialize m_kind.
+        (WebCore::RenderMathMLUnderOver::shouldMoveLimits): New function to determine if the base
+        should move its limits.
+        (WebCore::RenderMathMLUnderOver::computePreferredLogicalWidths): We use the code from
+        RenderMathMLScripts when the base should move its limits.
+        (WebCore::RenderMathMLUnderOver::layoutBlock): We use the code from RenderMathMLScripts when
+        the base should move its limits. Also improve the early return for invalid markup.
+        (WebCore::RenderMathMLUnderOver::unembellishedOperator): Deleted. We use the code from RenderMathMLScripts.
+        (WebCore::RenderMathMLUnderOver::firstLineBaseline): Deleted. We use the code from RenderMathMLScripts.
+        * rendering/mathml/RenderMathMLUnderOver.h: We now inherit from RenderMathMLScripts and can
+        just remove members that exist in the parent. We define shouldMoveLimits() to determine
+        when the layout should be done the same as RenderMathMLScripts. For now, we try and be
+        safe with the rest of the code by continuing to claim that we are not a RenderMathMLScripts.
+
 2016-07-07  Gyuyoung Kim  <[email protected]>
 
         Clean up PassRefPtr in Modules/webaudio

Modified: trunk/Source/WebCore/mathml/MathMLTextElement.cpp (202969 => 202970)


--- trunk/Source/WebCore/mathml/MathMLTextElement.cpp	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/Source/WebCore/mathml/MathMLTextElement.cpp	2016-07-08 07:15:24 UTC (rev 202970)
@@ -66,7 +66,7 @@
 
 void MathMLTextElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
-    if (name == stretchyAttr || name == lspaceAttr || name == rspaceAttr) {
+    if (name == stretchyAttr || name == lspaceAttr || name == rspaceAttr || name == movablelimitsAttr) {
         if (is<RenderMathMLOperator>(renderer()))
             downcast<RenderMathMLOperator>(*renderer()).updateFromElement();
         return;

Modified: trunk/Source/WebCore/rendering/mathml/MathMLOperatorDictionary.h (202969 => 202970)


--- trunk/Source/WebCore/rendering/mathml/MathMLOperatorDictionary.h	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/Source/WebCore/rendering/mathml/MathMLOperatorDictionary.h	2016-07-08 07:15:24 UTC (rev 202970)
@@ -38,7 +38,7 @@
     Accent = 0x1, // FIXME: This must be used to implement accentunder/accent on munderover (https://bugs.webkit.org/show_bug.cgi?id=124826).
     Fence = 0x2, // This has no visual effect but allows to expose semantic information via the accessibility tree.
     LargeOp = 0x4,
-    MovableLimits = 0x8, // FIXME: This must be used to implement displaystyle  (https://bugs.webkit.org/show_bug.cgi?id=118737).
+    MovableLimits = 0x8,
     Separator = 0x10, // This has no visual effect but allows to expose semantic information via the accessibility tree.
     Stretchy = 0x20,
     Symmetric = 0x40

Modified: trunk/Source/WebCore/rendering/mathml/MathMLStyle.cpp (202969 => 202970)


--- trunk/Source/WebCore/rendering/mathml/MathMLStyle.cpp	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/Source/WebCore/rendering/mathml/MathMLStyle.cpp	2016-07-08 07:15:24 UTC (rev 202970)
@@ -83,6 +83,7 @@
 void MathMLStyle::updateStyleIfNeeded(RenderObject* renderer, bool oldDisplayStyle)
 {
     if (oldDisplayStyle != m_displayStyle) {
+        renderer->setPreferredLogicalWidthsDirty(true);
         if (is<RenderMathMLToken>(renderer))
             downcast<RenderMathMLToken>(renderer)->updateTokenContent();
         else if (is<RenderMathMLRoot>(renderer))

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h (202969 => 202970)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h	2016-07-08 07:15:24 UTC (rev 202970)
@@ -50,6 +50,7 @@
 
     bool hasOperatorFlag(MathMLOperatorDictionary::Flag flag) const { return m_operatorFlags & flag; }
     bool isLargeOperatorInDisplayStyle() const { return !hasOperatorFlag(MathMLOperatorDictionary::Stretchy) && hasOperatorFlag(MathMLOperatorDictionary::LargeOp) && mathMLStyle()->displayStyle(); }
+    bool shouldMoveLimits() const { return hasOperatorFlag(MathMLOperatorDictionary::MovableLimits) && !mathMLStyle()->displayStyle(); }
     bool isVertical() const { return m_isVertical; }
     LayoutUnit italicCorrection() const { return m_mathOperator.italicCorrection(); }
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp (202969 => 202970)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2016-07-08 07:15:24 UTC (rev 202970)
@@ -53,6 +53,12 @@
         m_scriptType = Super;
     else if (element.hasTagName(MathMLNames::msubsupTag))
         m_scriptType = SubSup;
+    else if (element.hasTagName(MathMLNames::munderTag))
+        m_scriptType = Under;
+    else if (element.hasTagName(MathMLNames::moverTag))
+        m_scriptType = Over;
+    else if (element.hasTagName(MathMLNames::munderoverTag))
+        m_scriptType = UnderOver;
     else {
         ASSERT(element.hasTagName(MathMLNames::mmultiscriptsTag));
         m_scriptType = Multiscripts;
@@ -80,16 +86,22 @@
     switch (m_scriptType) {
     case Sub:
     case Super:
+    case Under:
+    case Over:
         // These elements must have exactly two children.
         // The second child is a postscript and there are no prescripts.
         // <msub> base subscript </msub>
         // <msup> base superscript </msup>
+        // <munder> base underscript </munder>
+        // <mover> base overscript </mover>
         firstPostScript = base->nextSiblingBox();
         return firstPostScript && !isPrescriptDelimiter(*firstPostScript) && !firstPostScript->nextSiblingBox();
-    case SubSup: {
-        // This element must have exactly three children.
+    case SubSup:
+    case UnderOver: {
+        // These elements must have exactly three children.
         // The second and third children are postscripts and there are no prescripts.
         // <msubsup> base subscript superscript </msubsup>
+        // <munderover> base subscript superscript </munderover>
         firstPostScript = base->nextSiblingBox();
         if (!firstPostScript || isPrescriptDelimiter(*firstPostScript))
             return false;
@@ -169,14 +181,17 @@
 
     switch (m_scriptType) {
     case Sub:
+    case Under:
         m_maxPreferredLogicalWidth += base->maxPreferredLogicalWidth();
         m_maxPreferredLogicalWidth += std::max(LayoutUnit(0), firstPostScript->maxPreferredLogicalWidth() - baseItalicCorrection + space);
         break;
     case Super:
+    case Over:
         m_maxPreferredLogicalWidth += base->maxPreferredLogicalWidth();
         m_maxPreferredLogicalWidth += std::max(LayoutUnit(0), firstPostScript->maxPreferredLogicalWidth() + space);
         break;
     case SubSup:
+    case UnderOver:
     case Multiscripts: {
         RenderBox* supScript;
         for (auto* subScript = firstPreScript; subScript; subScript = supScript->nextSiblingBox()) {
@@ -233,21 +248,26 @@
         superscriptBottomMaxWithSubscript = 4 * style().fontMetrics().xHeight() / 5;
     }
 
-    if (m_scriptType == Sub || m_scriptType == SubSup || m_scriptType == Multiscripts) {
-        LayoutUnit specifiedMinSubShift = 0;
-        parseMathMLLength(element()->fastGetAttribute(MathMLNames::subscriptshiftAttr), specifiedMinSubShift, &style(), false);
+    if (m_scriptType == Sub || m_scriptType == SubSup || m_scriptType == Multiscripts || m_scriptType == Under || m_scriptType == UnderOver) {
         minSubScriptShift = std::max(subscriptShiftDown, baseDescent + subscriptBaselineDropMin);
-        minSubScriptShift = std::max(minSubScriptShift, specifiedMinSubShift);
+        if (!isRenderMathMLUnderOver()) {
+            LayoutUnit specifiedMinSubShift = 0;
+            parseMathMLLength(element()->fastGetAttribute(MathMLNames::subscriptshiftAttr), specifiedMinSubShift, &style(), false);
+            minSubScriptShift = std::max(minSubScriptShift, specifiedMinSubShift);
+        }
     }
-    if (m_scriptType == Super || m_scriptType == SubSup || m_scriptType == Multiscripts) {
-        LayoutUnit specifiedMinSupShift = 0;
-        parseMathMLLength(element()->fastGetAttribute(MathMLNames::superscriptshiftAttr), specifiedMinSupShift, &style(), false);
+    if (m_scriptType == Super || m_scriptType == SubSup || m_scriptType == Multiscripts  || m_scriptType == Over || m_scriptType == UnderOver) {
         minSupScriptShift = std::max(superscriptShiftUp, baseAscent - superScriptBaselineDropMax);
-        minSupScriptShift = std::max(minSupScriptShift, specifiedMinSupShift);
+        if (!isRenderMathMLUnderOver()) {
+            LayoutUnit specifiedMinSupShift = 0;
+            parseMathMLLength(element()->fastGetAttribute(MathMLNames::superscriptshiftAttr), specifiedMinSupShift, &style(), false);
+            minSupScriptShift = std::max(minSupScriptShift, specifiedMinSupShift);
+        }
     }
 
     switch (m_scriptType) {
-    case Sub: {
+    case Sub:
+    case Under: {
         script->layoutIfNeeded();
         LayoutUnit subAscent = ascentForChild(*script);
         LayoutUnit subDescent = script->logicalHeight() - subAscent;
@@ -255,7 +275,8 @@
         minSubScriptShift = std::max(minSubScriptShift, subAscent - subscriptTopMax);
     }
         break;
-    case Super: {
+    case Super:
+    case Over: {
         script->layoutIfNeeded();
         LayoutUnit supAscent = ascentForChild(*script);
         LayoutUnit supDescent = script->logicalHeight() - supAscent;
@@ -264,6 +285,7 @@
     }
         break;
     case SubSup:
+    case UnderOver:
     case Multiscripts: {
         RenderBox* supScript;
         for (auto* subScript = script; subScript && !isPrescriptDelimiter(*subScript); subScript = supScript->nextSiblingBox()) {
@@ -342,7 +364,8 @@
     setLogicalHeight(ascent + descent);
 
     switch (m_scriptType) {
-    case Sub: {
+    case Sub:
+    case Under: {
         setLogicalWidth(base->logicalWidth() + std::max(LayoutUnit(0), firstPostScript->logicalWidth() - baseItalicCorrection + space));
         LayoutPoint baseLocation(mirrorIfNeeded(horizontalOffset, *base), ascent - baseAscent);
         base->setLocation(baseLocation);
@@ -352,7 +375,8 @@
         firstPostScript->setLocation(scriptLocation);
     }
         break;
-    case Super: {
+    case Super:
+    case Over: {
         setLogicalWidth(base->logicalWidth() + std::max(LayoutUnit(0), firstPostScript->logicalWidth() + space));
         LayoutPoint baseLocation(mirrorIfNeeded(horizontalOffset, *base), ascent - baseAscent);
         base->setLocation(baseLocation);
@@ -363,6 +387,7 @@
     }
         break;
     case SubSup:
+    case UnderOver:
     case Multiscripts: {
         RenderBox* supScript;
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h (202969 => 202970)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h	2016-07-08 07:15:24 UTC (rev 202970)
@@ -34,26 +34,26 @@
 
 namespace WebCore {
 // Render a base with scripts.
-class RenderMathMLScripts final : public RenderMathMLBlock {
+class RenderMathMLScripts : public RenderMathMLBlock {
 public:
     RenderMathMLScripts(Element&, RenderStyle&&);
     RenderMathMLOperator* unembellishedOperator() final;
     Optional<int> firstLineBaseline() const final;
-    void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
+    void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) override;
 
+protected:
+    bool isRenderMathMLScripts() const override { return true; }
+    const char* renderName() const override { return "RenderMathMLScripts"; }
+    void computePreferredLogicalWidths() override;
+
+    enum ScriptsType { Sub, Super, SubSup, Multiscripts, Under, Over, UnderOver };
+    ScriptsType m_scriptType;
+
 private:
-    bool isRenderMathMLScripts() const final { return true; }
-    const char* renderName() const final { return "RenderMathMLScripts"; }
-
     bool getBaseAndScripts(RenderBox*& base, RenderBox*& firstPostScript, RenderBox*& firstPreScript);
     LayoutUnit spaceAfterScript();
     LayoutUnit italicCorrection(RenderBox* base);
-    void computePreferredLogicalWidths() override;
     void getScriptMetricsAndLayoutIfNeeded(RenderBox* base, RenderBox* script, LayoutUnit& minSubScriptShift, LayoutUnit& minSupScriptShift, LayoutUnit& maxScriptDescent, LayoutUnit& maxScriptAscent);
-
-    enum ScriptsType { Sub, Super, SubSup, Multiscripts };
-
-    ScriptsType m_scriptType;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp (202969 => 202970)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp	2016-07-08 07:15:24 UTC (rev 202970)
@@ -40,36 +40,10 @@
 using namespace MathMLNames;
 
 RenderMathMLUnderOver::RenderMathMLUnderOver(Element& element, RenderStyle&& style)
-    : RenderMathMLBlock(element, WTFMove(style))
+    : RenderMathMLScripts(element, WTFMove(style))
 {
-    // Determine what kind of under/over _expression_ we have by element name
-    if (element.hasTagName(MathMLNames::munderTag))
-        m_scriptType = Under;
-    else if (element.hasTagName(MathMLNames::moverTag))
-        m_scriptType = Over;
-    else {
-        ASSERT(element.hasTagName(MathMLNames::munderoverTag));
-        m_scriptType = UnderOver;
-    }
 }
 
-RenderMathMLOperator* RenderMathMLUnderOver::unembellishedOperator()
-{
-    auto* base = firstChildBox();
-    if (!is<RenderMathMLBlock>(base))
-        return nullptr;
-    return downcast<RenderMathMLBlock>(*base).unembellishedOperator();
-}
-
-Optional<int> RenderMathMLUnderOver::firstLineBaseline() const
-{
-    auto* base = firstChildBox();
-    if (!base)
-        return Optional<int>();
-
-    return Optional<int>(static_cast<int>(lroundf(ascentForChild(*base) + base->logicalTop())));
-}
-
 void RenderMathMLUnderOver::computeOperatorsHorizontalStretch()
 {
     LayoutUnit stretchWidth = 0;
@@ -124,6 +98,13 @@
     }
 }
 
+bool RenderMathMLUnderOver::shouldMoveLimits()
+{
+    if (auto* renderOperator = unembellishedOperator())
+        return renderOperator->shouldMoveLimits();
+    return false;
+}
+
 RenderBox& RenderMathMLUnderOver::base() const
 {
     ASSERT(isValid());
@@ -156,6 +137,11 @@
         return;
     }
 
+    if (shouldMoveLimits()) {
+        RenderMathMLScripts::computePreferredLogicalWidths();
+        return;
+    }
+
     LayoutUnit preferredWidth = base().maxPreferredLogicalWidth();
 
     if (m_scriptType == Under || m_scriptType == UnderOver)
@@ -174,7 +160,7 @@
     return (logicalWidth() - child.logicalWidth()) / 2;
 }
 
-void RenderMathMLUnderOver::layoutBlock(bool relayoutChildren, LayoutUnit)
+void RenderMathMLUnderOver::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight)
 {
     ASSERT(needsLayout());
 
@@ -188,6 +174,11 @@
         return;
     }
 
+    if (shouldMoveLimits()) {
+        RenderMathMLScripts::layoutBlock(relayoutChildren, pageLogicalHeight);
+        return;
+    }
+
     recomputeLogicalWidth();
 
     computeOperatorsHorizontalStretch();

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h (202969 => 202970)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h	2016-07-08 07:05:07 UTC (rev 202969)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h	2016-07-08 07:15:24 UTC (rev 202970)
@@ -29,34 +29,28 @@
 
 #if ENABLE(MATHML)
 
-#include "RenderMathMLBlock.h"
+#include "RenderMathMLScripts.h"
 
 namespace WebCore {
 
-class RenderMathMLUnderOver final : public RenderMathMLBlock {
+class RenderMathMLUnderOver final : public RenderMathMLScripts {
 public:
     RenderMathMLUnderOver(Element&, RenderStyle&&);
-
-    RenderMathMLOperator* unembellishedOperator() override;
-
-    Optional<int> firstLineBaseline() const override;
-
     void computePreferredLogicalWidths() final;
     void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
 
 private:
+    bool isRenderMathMLScripts() const final { return false; }
     bool isRenderMathMLUnderOver() const override { return true; }
     const char* renderName() const override { return "RenderMathMLUnderOver"; }
 
     void computeOperatorsHorizontalStretch();
     bool isValid() const;
+    bool shouldMoveLimits();
     RenderBox& base() const;
     RenderBox& under() const;
     RenderBox& over() const;
     LayoutUnit horizontalOffset(const RenderBox&) const;
-
-    enum UnderOverType { Under, Over, UnderOver };
-    UnderOverType m_scriptType;
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to