Title: [156036] trunk
Revision
156036
Author
commit-qu...@webkit.org
Date
2013-09-18 05:39:23 -0700 (Wed, 18 Sep 2013)

Log Message

[MathML] Implement the subscriptshift and superscriptshift attributes
https://bugs.webkit.org/show_bug.cgi?id=120069

Patch by Gurpreet Kaur <k.gurpr...@samsung.com> on 2013-09-18
Reviewed by Darin Adler.

Source/WebCore:

Added support for subscriptshift and superscriptshift attributes. The
subscriptshift attribute is for msup element and superscriptshift for
msup. msubsup can have both subscriptshift and superscriptshift. The
subscriptshift attribute specifies the minimum amount to shift the
baseline of subscript down. The superscriptshift attribute specifies
the minimum amount to shift the baseline of superscript up.

Tests: mathml/presentation/msub-subscriptshift.html
       mathml/presentation/msubsup-subscriptshift.html
       mathml/presentation/msubsup-superscriptshift.html
       mathml/presentation/msup-superscriptshift.html
       mathml/presentation/multiscript-subscriptshift.html
       mathml/presentation/multiscript-superscriptshift.html

* mathml/mathattrs.in:
* rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::layout):
For aligning the subscript and superscript padding is added to the base.
So subscriptshift and superscriptshift attributes is set as padding bottom
and padding top of base respectively.

LayoutTests:

* mathml/presentation/msub-subscriptshift-expected.txt: Added.
* mathml/presentation/msub-subscriptshift.html: Added.
* mathml/presentation/msubsup-subscriptshift-expected.txt: Added.
* mathml/presentation/msubsup-subscriptshift.html: Added.
* mathml/presentation/msubsup-superscriptshift-expected.txt: Added.
* mathml/presentation/msubsup-superscriptshift.html: Added.
* mathml/presentation/msup-superscriptshift-expected.txt: Added.
* mathml/presentation/msup-superscriptshift.html: Added.
* mathml/presentation/multiscript-subscriptshift-expected.txt: Added.
* mathml/presentation/multiscript-subscriptshift.html: Added.
* mathml/presentation/multiscript-superscriptshift-expected.txt: Added.
* mathml/presentation/multiscript-superscriptshift.html: Added.
Added new tests for verifying that subscriptshift and superscriptshift are
being applied properly to the script base.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (156035 => 156036)


--- trunk/LayoutTests/ChangeLog	2013-09-18 10:12:09 UTC (rev 156035)
+++ trunk/LayoutTests/ChangeLog	2013-09-18 12:39:23 UTC (rev 156036)
@@ -1,3 +1,25 @@
+2013-09-18  Gurpreet Kaur  <k.gurpr...@samsung.com>
+
+        [MathML] Implement the subscriptshift and superscriptshift attributes
+        https://bugs.webkit.org/show_bug.cgi?id=120069
+
+        Reviewed by Darin Adler.
+
+        * mathml/presentation/msub-subscriptshift-expected.txt: Added.
+        * mathml/presentation/msub-subscriptshift.html: Added.
+        * mathml/presentation/msubsup-subscriptshift-expected.txt: Added.
+        * mathml/presentation/msubsup-subscriptshift.html: Added.
+        * mathml/presentation/msubsup-superscriptshift-expected.txt: Added.
+        * mathml/presentation/msubsup-superscriptshift.html: Added.
+        * mathml/presentation/msup-superscriptshift-expected.txt: Added.
+        * mathml/presentation/msup-superscriptshift.html: Added.
+        * mathml/presentation/multiscript-subscriptshift-expected.txt: Added.
+        * mathml/presentation/multiscript-subscriptshift.html: Added.
+        * mathml/presentation/multiscript-superscriptshift-expected.txt: Added.
+        * mathml/presentation/multiscript-superscriptshift.html: Added.
+        Added new tests for verifying that subscriptshift and superscriptshift are
+        being applied properly to the script base.
+
 2013-09-18  Mario Sanchez Prada  <mario.pr...@samsung.com>
 
         [ATK] Expose aria-haspopup and aria-sort without the 'aria-' prefix

Added: trunk/LayoutTests/mathml/presentation/msub-subscriptshift-expected.txt (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/msub-subscriptshift-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/msub-subscriptshift-expected.txt	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,10 @@
+Tests that subscriptshift works on msub. After adding subscriptshift the height of msub element should increase
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS height > 100 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/mathml/presentation/msub-subscriptshift-expected.txt
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/msub-subscriptshift.html (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/msub-subscriptshift.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/msub-subscriptshift.html	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script>
+            function runTest() {
+                description('Tests that subscriptshift works on msub. After adding subscriptshift the height of msub element should increase');
+
+                var rect = document.getElementById("msubEle").getBoundingClientRect();
+                height = rect.bottom - rect.top;
+
+                shouldBeTrue("height > 100");
+                isSuccessfullyParsed();
+            }
+        </script>
+    </head>
+    <body _onload_="runTest()">        
+        <math>
+            <msub subscriptshift="60px" id="msubEle">
+                <mspace width="50px" height="50px" mathbackground="green"/>
+                <mspace width="50px" height="50px" mathbackground="blue"/>
+            </msub>
+        </math>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/mathml/presentation/msub-subscriptshift.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/msubsup-subscriptshift-expected.txt (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/msubsup-subscriptshift-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/msubsup-subscriptshift-expected.txt	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,10 @@
+Tests that subscriptshift works on msubsup. After adding subscriptshift the height of msubsup element should increase
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS height > 150 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/mathml/presentation/msubsup-subscriptshift-expected.txt
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/msubsup-subscriptshift.html (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/msubsup-subscriptshift.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/msubsup-subscriptshift.html	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script>
+            function runTest() {
+                description('Tests that subscriptshift works on msubsup. After adding subscriptshift the height of msubsup element should increase');
+
+                var rect = document.getElementById("msubsupEle").getBoundingClientRect();
+                height = rect.bottom - rect.top;
+
+                shouldBeTrue("height > 150");
+                isSuccessfullyParsed();
+            }
+        </script>
+    </head>
+    <body _onload_="runTest()">
+        <math>
+		    <msubsup subscriptshift="60px" id="msubsupEle">
+                <mspace width="50px" height="50px" mathbackground="green"/>
+                <mspace width="50px" height="50px" mathbackground="blue"/>
+                <mspace width="50px" height="50px" mathbackground="red"/>
+            </msubsup>
+        </math>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/mathml/presentation/msubsup-subscriptshift.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/msubsup-superscriptshift-expected.txt (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/msubsup-superscriptshift-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/msubsup-superscriptshift-expected.txt	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,10 @@
+Tests that superscriptshift works on msubsup. After adding superscriptshift the height of msubsup element should increase
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS height > 150 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/mathml/presentation/msubsup-superscriptshift-expected.txt
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/msubsup-superscriptshift.html (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/msubsup-superscriptshift.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/msubsup-superscriptshift.html	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script>
+            function runTest() {
+                description('Tests that superscriptshift works on msubsup. After adding superscriptshift the height of msubsup element should increase');
+
+                var rect = document.getElementById("msubsupEle").getBoundingClientRect();
+                height = rect.bottom - rect.top;
+
+                shouldBeTrue("height > 150");
+                isSuccessfullyParsed();
+            }
+        </script>
+    </head>
+    <body _onload_="runTest()">
+        <math>
+		    <msubsup superscriptshift="60px" id="msubsupEle">
+                <mspace width="50px" height="50px" mathbackground="green"/>
+                <mspace width="50px" height="50px" mathbackground="blue"/>
+                <mspace width="50px" height="50px" mathbackground="red"/>
+            </msubsup>
+        </math>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/mathml/presentation/msubsup-superscriptshift.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/msup-superscriptshift-expected.txt (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/msup-superscriptshift-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/msup-superscriptshift-expected.txt	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,10 @@
+Tests that superscriptshift works on msup. After adding superscriptshift the height of msup element should increase
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS height > 100 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/mathml/presentation/msup-superscriptshift-expected.txt
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/msup-superscriptshift.html (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/msup-superscriptshift.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/msup-superscriptshift.html	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script>
+            function runTest() {
+                description('Tests that superscriptshift works on msup. After adding superscriptshift the height of msup element should increase');
+
+                var rect = document.getElementById("msupEle").getBoundingClientRect();
+                height = rect.bottom - rect.top;
+
+                shouldBeTrue("height > 100");
+                isSuccessfullyParsed();
+            }
+        </script>
+    </head>
+    <body _onload_="runTest()">
+        <math>
+		    <msup superscriptshift="60px" id="msupEle">
+                <mspace width="50px" height="50px" mathbackground="green"/>
+                <mspace width="50px" height="50px" mathbackground="red"/>
+            </msup>
+        </math>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/mathml/presentation/msup-superscriptshift.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/multiscript-subscriptshift-expected.txt (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/multiscript-subscriptshift-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/multiscript-subscriptshift-expected.txt	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,10 @@
+Tests that subscriptshift works on mmultiscripts. After adding subscriptshift the height of mmultiscripts element should increase
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS height > 150 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/mathml/presentation/multiscript-subscriptshift-expected.txt
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/multiscript-subscriptshift.html (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/multiscript-subscriptshift.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/multiscript-subscriptshift.html	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script>
+            function runTest() {
+                description('Tests that subscriptshift works on mmultiscripts. After adding subscriptshift the height of mmultiscripts element should increase');
+
+                var rect = document.getElementById("multiscriptEle").getBoundingClientRect();
+                height = rect.bottom - rect.top;
+
+                shouldBeTrue("height > 150");
+                isSuccessfullyParsed();
+            }
+        </script>
+    </head>
+    <body _onload_="runTest()">
+        <math>
+            <mmultiscripts subscriptshift="60px" id="multiscriptEle">
+                <mspace width="50px" height="50px" mathbackground="green"/>
+                <mspace width="50px" height="50px" mathbackground="blue"/>
+                <mspace width="50px" height="50px" mathbackground="red"/>
+				<mprescripts />
+				<mspace width="50px" height="50px" mathbackground="yellow"/>
+                <mspace width="50px" height="50px" mathbackground="black"/>
+            </mmultiscripts>
+      </math>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/mathml/presentation/multiscript-subscriptshift.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/multiscript-superscriptshift-expected.txt (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/multiscript-superscriptshift-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/multiscript-superscriptshift-expected.txt	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,10 @@
+Tests that superscriptshift works on mmultiscripts. After adding superscriptshift the height of mmultiscripts element should increase
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS height > 150 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/mathml/presentation/multiscript-superscriptshift-expected.txt
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/mathml/presentation/multiscript-superscriptshift.html (0 => 156036)


--- trunk/LayoutTests/mathml/presentation/multiscript-superscriptshift.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/multiscript-superscriptshift.html	2013-09-18 12:39:23 UTC (rev 156036)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script>
+            function runTest() {
+                description('Tests that superscriptshift works on mmultiscripts. After adding superscriptshift the height of mmultiscripts element should increase');
+
+                var rect = document.getElementById("multiscriptEle").getBoundingClientRect();
+                height = rect.bottom - rect.top;
+
+                shouldBeTrue("height > 150");
+                isSuccessfullyParsed();
+            }
+        </script>
+    </head>
+    <body _onload_="runTest()">
+        <math>
+            <mmultiscripts superscriptshift="60px" id="multiscriptEle">
+                <mspace width="50px" height="50px" mathbackground="green"/>
+                <mspace width="50px" height="50px" mathbackground="blue"/>
+                <mspace width="50px" height="50px" mathbackground="red"/>
+				<mprescripts />
+				<mspace width="50px" height="50px" mathbackground="yellow"/>
+                <mspace width="50px" height="50px" mathbackground="black"/>
+            </mmultiscripts>
+      </math>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/mathml/presentation/multiscript-superscriptshift.html
___________________________________________________________________

Added: svn:executable

Modified: trunk/Source/WebCore/ChangeLog (156035 => 156036)


--- trunk/Source/WebCore/ChangeLog	2013-09-18 10:12:09 UTC (rev 156035)
+++ trunk/Source/WebCore/ChangeLog	2013-09-18 12:39:23 UTC (rev 156036)
@@ -1,3 +1,31 @@
+2013-09-18  Gurpreet Kaur  <k.gurpr...@samsung.com>
+
+        [MathML] Implement the subscriptshift and superscriptshift attributes
+        https://bugs.webkit.org/show_bug.cgi?id=120069
+
+        Reviewed by Darin Adler.
+
+        Added support for subscriptshift and superscriptshift attributes. The
+        subscriptshift attribute is for msup element and superscriptshift for
+        msup. msubsup can have both subscriptshift and superscriptshift. The
+        subscriptshift attribute specifies the minimum amount to shift the
+        baseline of subscript down. The superscriptshift attribute specifies
+        the minimum amount to shift the baseline of superscript up.
+
+        Tests: mathml/presentation/msub-subscriptshift.html
+               mathml/presentation/msubsup-subscriptshift.html
+               mathml/presentation/msubsup-superscriptshift.html
+               mathml/presentation/msup-superscriptshift.html
+               mathml/presentation/multiscript-subscriptshift.html
+               mathml/presentation/multiscript-superscriptshift.html
+
+        * mathml/mathattrs.in:
+        * rendering/mathml/RenderMathMLScripts.cpp:
+        (WebCore::RenderMathMLScripts::layout):
+        For aligning the subscript and superscript padding is added to the base.
+        So subscriptshift and superscriptshift attributes is set as padding bottom
+        and padding top of base respectively.
+
 2013-09-18  Mario Sanchez Prada  <mario.pr...@samsung.com>
 
         [ATK] Expose aria-haspopup and aria-sort without the 'aria-' prefix

Modified: trunk/Source/WebCore/mathml/mathattrs.in (156035 => 156036)


--- trunk/Source/WebCore/mathml/mathattrs.in	2013-09-18 10:12:09 UTC (rev 156035)
+++ trunk/Source/WebCore/mathml/mathattrs.in	2013-09-18 12:39:23 UTC (rev 156036)
@@ -27,4 +27,6 @@
 rowspan
 separators
 stretchy
+subscriptshift
+superscriptshift
 width

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp (156035 => 156036)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2013-09-18 10:12:09 UTC (rev 156035)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2013-09-18 12:39:23 UTC (rev 156036)
@@ -277,9 +277,6 @@
     // Our layout rules include: Don't let the superscript go below the "axis" (half x-height above the
     // baseline), or the subscript above the axis. Also, don't let the superscript's top edge be
     // below the base's top edge, or the subscript's bottom edge above the base's bottom edge.
-    //
-    // FIXME: Check any subscriptshift or superscriptshift attributes, and maybe use more sophisticated
-    // heuristics from TeX or elsewhere. See https://bugs.webkit.org/show_bug.cgi?id=79274#c5.
 
     LayoutUnit baseHeight = base->logicalHeight();
     LayoutUnit baseBaseline = base->firstLineBoxBaseline();
@@ -294,6 +291,14 @@
     LayoutUnit topPadding = 0;
     LayoutUnit bottomPadding = 0;
 
+    Element* scriptElement = element();
+    LayoutUnit superscriptShiftValue = 0;
+    LayoutUnit subscriptShiftValue = 0;
+    if (m_kind == Sub || m_kind == SubSup || m_kind == Multiscripts)
+        parseMathMLLength(scriptElement->fastGetAttribute(MathMLNames::subscriptshiftAttr), subscriptShiftValue, style(), false);
+    if (m_kind == Super || m_kind == SubSup || m_kind == Multiscripts)
+        parseMathMLLength(scriptElement->fastGetAttribute(MathMLNames::superscriptshiftAttr), superscriptShiftValue, style(), false);
+
     bool isPostScript = true;
     RenderMathMLBlock* subSupPair = toRenderMathMLBlock(m_baseWrapper->nextSibling());
     for (; subSupPair; subSupPair = toRenderMathMLBlock(subSupPair->nextSibling())) {
@@ -311,7 +316,7 @@
             LayoutUnit superscriptBaseline = superscript->firstLineBoxBaseline();
             if (superscriptBaseline == -1)
                 superscriptBaseline = superscriptHeight;
-            LayoutUnit minBaseline = max<LayoutUnit>(fontSize / 3 + 1 + superscriptBaseline, superscriptHeight + axis);
+            LayoutUnit minBaseline = max<LayoutUnit>(fontSize / 3 + 1 + superscriptBaseline, superscriptHeight + axis + superscriptShiftValue);
 
             topPadding = max<LayoutUnit>(topPadding, minBaseline - baseBaseline);
         }
@@ -323,7 +328,7 @@
                 subscriptBaseline = subscriptHeight;
             LayoutUnit baseExtendUnderBaseline = baseHeight - baseBaseline;
             LayoutUnit subscriptUnderItsBaseline = subscriptHeight - subscriptBaseline;
-            LayoutUnit minExtendUnderBaseline = max<LayoutUnit>(fontSize / 5 + 1 + subscriptUnderItsBaseline, subscriptHeight - axis);
+            LayoutUnit minExtendUnderBaseline = max<LayoutUnit>(fontSize / 5 + 1 + subscriptUnderItsBaseline, subscriptHeight + subscriptShiftValue - axis);
 
             bottomPadding = max<LayoutUnit>(bottomPadding, minExtendUnderBaseline - baseExtendUnderBaseline);
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to