Bug 155792 - Basic implementation of mpadded
authorfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jul 2016 06:16:32 +0000 (06:16 +0000)
committerfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jul 2016 06:16:32 +0000 (06:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155792

Patch by Frederic Wang <fwang@igalia.com> on 2016-07-07
Reviewed by Brent Fulgham.

Source/WebCore:

We implement a basic support for the mpadded element.
We support most of the attribute values except pseudo-units or negative values.

Tests: mathml/presentation/mpadded-1-2.html
       mathml/presentation/mpadded-1.html
       mathml/presentation/mpadded-2.html
       mathml/presentation/mpadded-3.html
       mathml/presentation/mpadded-unsupported-values.html
       mathml/presentation/mpadded-dynamic.html

* CMakeLists.txt: Add RenderMathMLPadded to the build system.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* mathml/MathMLInlineContainerElement.cpp:
(WebCore::MathMLInlineContainerElement::createElementRenderer): Create the renderer
for mpadded.
* mathml/mathattrs.in: Add voffset attribute.
* mathml/mathtags.in: Make mpadded use MathMLInlineContainerElement.
* rendering/RenderObject.h:
(WebCore::RenderObject::isRenderMathMLPadded): Define isRenderMathMLPadded.
* rendering/mathml/RenderMathMLPadded.cpp: Added.
We do a simple implementation by overriding the behavior of RenderMathMLRow and forcing
relayout after attribute or style change.
(WebCore::RenderMathMLPadded::RenderMathMLPadded):
(WebCore::RenderMathMLPadded::computePreferredLogicalWidths):
(WebCore::RenderMathMLPadded::layoutBlock):
(WebCore::RenderMathMLPadded::updateFromElement):
(WebCore::RenderMathMLPadded::styleDidChange):
(WebCore::RenderMathMLPadded::firstLineBaseline):
* rendering/mathml/RenderMathMLPadded.h: Added.

LayoutTests:

We import mpadded tests from Mozilla test suite.
We also add some tests for dynamic changes of mpadded attributes and to verify
that the mpadded element behaves as if it had an inferred <mrow>.
Finally, we check that fallback properly for negative and pseudo-unit values that
we do not support yet.

* mathml/presentation/inferred-mrow-baseline.html: Check baseline for mpadded.
* mathml/presentation/inferred-mrow-baseline-expected.txt: Ditto.
* mathml/presentation/inferred-mrow-stretchy.html: Check stretching of operators for mpadded.
* mathml/presentation/inferred-mrow-stretchy-expected.txt: Ditto.
* mathml/presentation/mpadded-dynamic.html: Added. Verify dynamic change of mpadded attributes.
* mathml/presentation/mpadded-dynamic-expected.html: Added. Ditto.
* mathml/presentation/mpadded-unsupported-values.html: Added. Check negative and pseudo-unit values.
* mathml/presentation/mpadded-unsupported-values-expected.html: Added.
* mathml/presentation/mpadded-1-2-expected.html: Added.
* mathml/presentation/mpadded-1-2.html: Added.
* mathml/presentation/mpadded-1-expected.html: Added.
* mathml/presentation/mpadded-1.html: Added.
* mathml/presentation/mpadded-2-expected.html: Added.
* mathml/presentation/mpadded-2.html: Added.
* mathml/presentation/mpadded-3-expected.html: Added.
* mathml/presentation/mpadded-3.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202962 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
LayoutTests/ChangeLog
LayoutTests/mathml/presentation/inferred-mrow-baseline-expected.txt
LayoutTests/mathml/presentation/inferred-mrow-baseline.html
LayoutTests/mathml/presentation/inferred-mrow-stretchy-expected.txt
LayoutTests/mathml/presentation/inferred-mrow-stretchy.html
LayoutTests/mathml/presentation/mpadded-1-2-expected.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-1-2.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-1-expected.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-1.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-2-expected.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-2.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-3-expected.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-3.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-4-expected.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-4.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-dynamic-expected.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-dynamic.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-unsupported-values-expected.html [new file with mode: 0644]
LayoutTests/mathml/presentation/mpadded-unsupported-values.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/mathml/MathMLInlineContainerElement.cpp
Source/WebCore/mathml/mathattrs.in
Source/WebCore/mathml/mathtags.in
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/mathml/RenderMathMLPadded.cpp [new file with mode: 0644]
Source/WebCore/rendering/mathml/RenderMathMLPadded.h [new file with mode: 0644]

index 4bb5234..9fcd1a9 100644 (file)
@@ -1,5 +1,35 @@
 2016-07-07  Frederic Wang  <fwang@igalia.com>
 
+        Bug 155792 - Basic implementation of mpadded
+        https://bugs.webkit.org/show_bug.cgi?id=155792
+
+        Reviewed by Brent Fulgham.
+
+        We import mpadded tests from Mozilla test suite.
+        We also add some tests for dynamic changes of mpadded attributes and to verify
+        that the mpadded element behaves as if it had an inferred <mrow>.
+        Finally, we check that fallback properly for negative and pseudo-unit values that
+        we do not support yet.
+
+        * mathml/presentation/inferred-mrow-baseline.html: Check baseline for mpadded.
+        * mathml/presentation/inferred-mrow-baseline-expected.txt: Ditto.
+        * mathml/presentation/inferred-mrow-stretchy.html: Check stretching of operators for mpadded.
+        * mathml/presentation/inferred-mrow-stretchy-expected.txt: Ditto.
+        * mathml/presentation/mpadded-dynamic.html: Added. Verify dynamic change of mpadded attributes.
+        * mathml/presentation/mpadded-dynamic-expected.html: Added. Ditto.
+        * mathml/presentation/mpadded-unsupported-values.html: Added. Check negative and pseudo-unit values.
+        * mathml/presentation/mpadded-unsupported-values-expected.html: Added.
+        * mathml/presentation/mpadded-1-2-expected.html: Added.
+        * mathml/presentation/mpadded-1-2.html: Added.
+        * mathml/presentation/mpadded-1-expected.html: Added.
+        * mathml/presentation/mpadded-1.html: Added.
+        * mathml/presentation/mpadded-2-expected.html: Added.
+        * mathml/presentation/mpadded-2.html: Added.
+        * mathml/presentation/mpadded-3-expected.html: Added.
+        * mathml/presentation/mpadded-3.html: Added.
+
+2016-07-07  Frederic Wang  <fwang@igalia.com>
+
         Implement an internal style property for displaystyle.
         https://bugs.webkit.org/show_bug.cgi?id=133845
 
index ba47867..23952c7 100644 (file)
@@ -6,6 +6,7 @@ This test passes if rectangles are correctly aligned with respect to the baselin
  
  
  
 
 
 PASS baseline alignment inside Mrow 
@@ -15,4 +16,5 @@ PASS baseline alignment inside Error
 PASS baseline alignment inside Phantom 
 PASS baseline alignment inside Math 
 PASS baseline alignment inside Menclose 
+PASS baseline alignment inside Mpadded 
 
index a32789d..e8d0674 100644 (file)
@@ -8,7 +8,7 @@
       setup({ "explicit_done": true });
       function run()
       {
-        var tags = ["Mrow", "Sqrt", "Style", "Error", "Phantom", "Math", "Menclose"];
+        var tags = ["Mrow", "Sqrt", "Style", "Error", "Phantom", "Math", "Menclose", "Mpadded"];
         for (var i in tags) {
           var tag = tags[i];
           var x = document.getElementById("above" + tag).getBoundingClientRect();
@@ -39,6 +39,8 @@
       <math><mspace id="aboveMath" width="10px" height="30px" mathbackground="red"></mspace><mspace id="belowMath" width="10px" depth="30px" mathbackground="blue"></mspace></math>
          
       <math><menclose notation="box"><mspace id="aboveMenclose" width="10px" height="30px" mathbackground="red"></mspace><mspace id="belowMenclose" width="10px" depth="30px" mathbackground="blue"></mspace></menclose></math>
+
+      <math><mpadded notation="box"><mspace id="aboveMpadded" width="10px" height="30px" mathbackground="red"></mspace><mspace id="belowMpadded" width="10px" depth="30px" mathbackground="blue"></mspace></mpadded></math>
     </p>
 
   </body>
index 695d3d3..1d901d6 100644 (file)
@@ -12,6 +12,8 @@ This test passes if all the vertical bars stretch.
 |
  
 |
+|
 
 
 PASS operator stretching inside Mrow 
@@ -21,4 +23,5 @@ PASS operator stretching inside Error
 PASS operator stretching inside Phantom 
 PASS operator stretching inside Math 
 PASS operator stretching inside Menclose 
+PASS operator stretching inside Mpadded 
 
index b429efb..ddd2156 100644 (file)
@@ -8,7 +8,7 @@
       setup({ "explicit_done": true });
       function run()
       {
-        var tags = ["Mrow", "Sqrt", "Style", "Error", "Phantom", "Math", "Menclose"];
+        var tags = ["Mrow", "Sqrt", "Style", "Error", "Phantom", "Math", "Menclose", "Mpadded"];
         for (var i in tags) {
           var tag = tags[i];
           var mo = document.getElementById("mo" + tag);
@@ -32,6 +32,7 @@
       <math><mphantom><mo style="visibilty: visible;" id="moPhantom">|</mo><mspace width="1px" height="30px" depth="30px" mathbackground="red"></mspace></mphantom></math>
       <math><mo id="moMath">|</mo><mspace width="1px" height="30px" depth="30px" mathbackground="red"></mspace></math>
       <math><menclose notation="box"><mo id="moMenclose">|</mo><mspace width="1px" height="30px" depth="30px" mathbackground="red"></mspace></menclose></math>
+      <math><mpadded notation="box"><mo id="moMpadded">|</mo><mspace width="1px" height="30px" depth="30px" mathbackground="red"></mspace></mpadded></math>
     </p>
 
   </body>
diff --git a/LayoutTests/mathml/presentation/mpadded-1-2-expected.html b/LayoutTests/mathml/presentation/mpadded-1-2-expected.html
new file mode 100644 (file)
index 0000000..7a9ff5a
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded</title>
+    <style type="text/css">
+      div#bigsquare {
+        position: absolute;
+        width: 100px;
+        height: 100px;
+        background: blue;
+      }
+
+      div#smallsquare {
+        position:absolute;
+        width: 20px;
+        height: 20px;
+        left: 20px;
+        top: 60px;
+        background: red;
+      }
+      /*left = lspace = 20px;
+        top = heightBig - voffset - heightSmall;
+            = 50 + 20 - 10
+            = 60px */
+      </style>
+  </head>
+  <body>
+    <div id="bigsquare">
+      <div id="smallsquare">
+      </div>
+    </div>
+  </body>
+<html>
diff --git a/LayoutTests/mathml/presentation/mpadded-1-2.html b/LayoutTests/mathml/presentation/mpadded-1-2.html
new file mode 100644 (file)
index 0000000..67c9fe5
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded</title>
+  </head>
+  <body>
+    <math style="padding: 0;">
+      <mpadded mathbackground="blue" width="100px" height="50px" depth="50px"
+               lspace="20px" voffset="-20px">
+        <mpadded mathbackground="red" width="20px" height="10px"
+                 depth="10px">
+        </mpadded>
+      </mpadded>
+    </math>
+  </body>
+</html>
diff --git a/LayoutTests/mathml/presentation/mpadded-1-expected.html b/LayoutTests/mathml/presentation/mpadded-1-expected.html
new file mode 100644 (file)
index 0000000..de3d44f
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded</title>
+    <style type="text/css">
+      div#bigsquare {
+        position: absolute;
+        width: 100px;
+        height: 100px;
+        background: blue;
+      }
+
+      div#smallsquare {
+        position:absolute;
+        width: 20px;
+        height: 20px;
+        left: 20px;
+        top: 10px;
+        background: red;
+      }
+      /*left = lspace = 20px;
+        top = heightBig - voffset - heightSmall;
+            = 50 - 30 - 10
+            = 10px */
+      </style>
+  </head>
+  <body>
+    <div id="bigsquare">
+      <div id="smallsquare">
+      </div>
+    </div>
+  </body>
+<html>
diff --git a/LayoutTests/mathml/presentation/mpadded-1.html b/LayoutTests/mathml/presentation/mpadded-1.html
new file mode 100644 (file)
index 0000000..6583047
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded</title>
+  </head>
+  <body>
+    <math style="padding: 0;">
+      <mpadded mathbackground="blue" width="100px" height="50px" depth="50px"
+               lspace="20px" voffset="30px">
+        <mpadded mathbackground="red" width="20px" height="10px"
+                 depth="10px">
+        </mpadded>
+      </mpadded>
+    </math>
+  </body>
+</html>
diff --git a/LayoutTests/mathml/presentation/mpadded-2-expected.html b/LayoutTests/mathml/presentation/mpadded-2-expected.html
new file mode 100644 (file)
index 0000000..5dc31d5
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded</title>
+    <style type="text/css">
+      div#square1 {
+        position: absolute;
+        width: 100px;
+        height: 100px;
+        background: blue;
+      }
+
+      div#square2 {
+        position:absolute;
+        width: 20px;
+        height: 20px;
+        left: 10px;
+        top: 55px;
+        background: red;
+      }
+      /* left = lspace = 10;
+         top = heightBig - heightSmall - voffset;
+         top = 50 - 10 + 15 = 55px */
+      </style>
+  </head>
+  <body>
+    <div id="square1">
+      <div id="square2">
+      </div>
+    </div>
+  </body>
+<html>
diff --git a/LayoutTests/mathml/presentation/mpadded-2.html b/LayoutTests/mathml/presentation/mpadded-2.html
new file mode 100644 (file)
index 0000000..636f516
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded</title>
+  </head>
+  <body>
+    <math style="padding: 0;">
+      <mpadded mathbackground="blue" width="100px" height="50px" depth="50px"
+               lspace="10px" voffset="-15px">
+        <mpadded mathbackground="red" width="20px" height="10px"
+                 depth="10px">
+        </mpadded>
+      </mpadded>
+    </math>
+  </body>
+</html>
diff --git a/LayoutTests/mathml/presentation/mpadded-3-expected.html b/LayoutTests/mathml/presentation/mpadded-3-expected.html
new file mode 100644 (file)
index 0000000..f0d3e72
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded height depth</title>
+    <style type="text/css">
+      div#bigsquare1 {
+        position: absolute;
+        width: 100px;
+        height: 50px;
+        background: blue;
+      }
+
+      div#smallsquare1 {
+        position:absolute;
+        width: 20px;
+        height: 20px;
+        left: 0px;
+        top: 30px;
+        background: red;
+      }
+      /* left = lspace = 0;
+         top = heightBig - heightSmall - voffset;
+             = 50 - 10 - 10*/
+    </style>
+  </head>
+  <body>
+    <div id="bigsquare1">
+      <div id="smallsquare1">
+      </div>
+    </div>
+
+    <div id="bigsquare2">
+      <div id="smallsquare2">
+      </div>
+    </div>
+  </body>
+<html>
diff --git a/LayoutTests/mathml/presentation/mpadded-3.html b/LayoutTests/mathml/presentation/mpadded-3.html
new file mode 100644 (file)
index 0000000..32b51cb
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded height depth</title>
+  </head>
+  <body>
+    <math style="padding: 0;">
+      <mpadded mathbackground="blue" width="100px" height="50px" depth="0px"
+               lspace="0px" voffset="10px">
+        <mpadded mathbackground="red" width="20px" height="10px"
+                 depth="10px">
+        </mpadded>
+      </mpadded>
+    </math>
+  </body>
+</html>
diff --git a/LayoutTests/mathml/presentation/mpadded-4-expected.html b/LayoutTests/mathml/presentation/mpadded-4-expected.html
new file mode 100644 (file)
index 0000000..7092903
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded</title>
+  </head>
+  <body>
+    <math style="padding: 0;">
+      <mpadded mathbackground="blue" width="100px" height="3height" depth="3depth"
+               lspace="0" voffset="10px">
+        <mpadded mathbackground="red" width="20px" height="10px"
+                 depth="10px">
+        </mpadded>
+      </mpadded>
+    </math>
+  </body>
+</html>
diff --git a/LayoutTests/mathml/presentation/mpadded-4.html b/LayoutTests/mathml/presentation/mpadded-4.html
new file mode 100644 (file)
index 0000000..2c47c27
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Test mpadded</title>
+  </head>
+  <body>
+    <math style="padding: 0;">
+      <!-- if lspace is used as a pseudounit, the lspace value is 0 -->
+      <mpadded mathbackground="blue" width="100px" height="3height" depth="3depth"
+               lspace="3lspace" voffset="10px">
+        <mpadded mathbackground="red" width="20px" height="10px"
+                 depth="10px">
+        </mpadded>
+      </mpadded>
+    </math>
+  </body>
+</html>
diff --git a/LayoutTests/mathml/presentation/mpadded-dynamic-expected.html b/LayoutTests/mathml/presentation/mpadded-dynamic-expected.html
new file mode 100644 (file)
index 0000000..77d41f2
--- /dev/null
@@ -0,0 +1,16 @@
+<!doctype html>
+<html class="reftest-wait">
+  <head>
+    <title>mpadded dynamic</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+    <math>
+      <mpadded id="mpadded" mathbackground="blue"
+               width="80px" depth="50px" height="30px"
+               lspace="60px" voffset="20px">
+        <mspace width="10px" height="5px" depth="5px" mathbackground="red"/>
+      </mpadded>
+    </math>
+  </body>
+</html>
diff --git a/LayoutTests/mathml/presentation/mpadded-dynamic.html b/LayoutTests/mathml/presentation/mpadded-dynamic.html
new file mode 100644 (file)
index 0000000..9ae327f
--- /dev/null
@@ -0,0 +1,28 @@
+<!doctype html>
+<html class="reftest-wait">
+  <head>
+    <title>mpadded dynamic</title>
+    <meta charset="utf-8"/>
+    <script type="text/javascript">
+      function doTest() {
+        var mpadded = document.getElementById("mpadded");
+        mpadded.setAttribute("width", "80px");
+        mpadded.setAttribute("height", "30px");
+        mpadded.setAttribute("depth", "50px");
+        mpadded.setAttribute("lspace", "60px");
+        mpadded.setAttribute("voffset", "20px");
+        document.documentElement.removeAttribute("class");
+      }
+      window.addEventListener("load", doTest, false);
+    </script>
+  </head>
+  <body>
+    <math>
+      <mpadded id="mpadded" mathbackground="blue"
+               width="40px" depth="30px" height="20px"
+               lspace="5px" voffset="-15px">
+        <mspace width="10px" height="5px" depth="5px" mathbackground="red"/>
+      </mpadded>
+    </math>
+  </body>
+</html>
diff --git a/LayoutTests/mathml/presentation/mpadded-unsupported-values-expected.html b/LayoutTests/mathml/presentation/mpadded-unsupported-values-expected.html
new file mode 100644 (file)
index 0000000..4f80f62
--- /dev/null
@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+  <head>
+    <title>mpadded unsupported values</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+
+    <math>
+      <mpadded mathbackground="red">
+        <mspace width="0px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded height="0px" mathbackground="green">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded depth="0px" mathbackground="blue">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded lspace="0px" mathbackground="magenta">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+    </math>
+    <hr/>
+
+    <!-- We ignore pseudo-units for now. -->
+    <math>
+      <mpadded mathbackground="red">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded mathbackground="green">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded mathbackground="blue">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+    </math>
+
+  </body>
+</html>
diff --git a/LayoutTests/mathml/presentation/mpadded-unsupported-values.html b/LayoutTests/mathml/presentation/mpadded-unsupported-values.html
new file mode 100644 (file)
index 0000000..02430af
--- /dev/null
@@ -0,0 +1,42 @@
+<!doctype html>
+<html>
+  <head>
+    <title>mpadded unsupported values</title>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+
+    <!-- This verifies that the values that we do not support do not cause any problem. -->
+
+    <!-- If width/height/depth/lspace are negative, we set them to zero. -->
+    <math>
+      <mpadded width="-20px" mathbackground="red">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded height="-20px" mathbackground="green">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded depth="-20px" mathbackground="blue">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded lspace="-20px" mathbackground="magenta">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+    </math>
+    <hr/>
+
+    <!-- We ignore pseudo-units values. -->
+    <math>
+      <mpadded width="3width" mathbackground="red">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded height="3depth" mathbackground="green">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+      <mpadded depth="3height" mathbackground="blue">
+        <mspace width="50px" height="25px" depth="25px"/>
+      </mpadded>
+    </math>
+
+  </body>
+</html>
index 6ecd091..52f918e 100644 (file)
@@ -2532,6 +2532,7 @@ set(WebCore_SOURCES
     rendering/mathml/RenderMathMLMath.cpp
     rendering/mathml/RenderMathMLMenclose.cpp
     rendering/mathml/RenderMathMLOperator.cpp
+    rendering/mathml/RenderMathMLPadded.cpp
     rendering/mathml/RenderMathMLRoot.cpp
     rendering/mathml/RenderMathMLRow.cpp
     rendering/mathml/RenderMathMLScripts.cpp
index 46bdf8e..280cfe0 100644 (file)
@@ -1,5 +1,42 @@
 2016-07-07  Frederic Wang  <fwang@igalia.com>
 
+        Bug 155792 - Basic implementation of mpadded
+        https://bugs.webkit.org/show_bug.cgi?id=155792
+
+        Reviewed by Brent Fulgham.
+
+        We implement a basic support for the mpadded element.
+        We support most of the attribute values except pseudo-units or negative values.
+
+        Tests: mathml/presentation/mpadded-1-2.html
+               mathml/presentation/mpadded-1.html
+               mathml/presentation/mpadded-2.html
+               mathml/presentation/mpadded-3.html
+               mathml/presentation/mpadded-unsupported-values.html
+               mathml/presentation/mpadded-dynamic.html
+
+        * CMakeLists.txt: Add RenderMathMLPadded to the build system.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * mathml/MathMLInlineContainerElement.cpp:
+        (WebCore::MathMLInlineContainerElement::createElementRenderer): Create the renderer
+        for mpadded.
+        * mathml/mathattrs.in: Add voffset attribute.
+        * mathml/mathtags.in: Make mpadded use MathMLInlineContainerElement.
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::isRenderMathMLPadded): Define isRenderMathMLPadded.
+        * rendering/mathml/RenderMathMLPadded.cpp: Added.
+        We do a simple implementation by overriding the behavior of RenderMathMLRow and forcing
+        relayout after attribute or style change.
+        (WebCore::RenderMathMLPadded::RenderMathMLPadded):
+        (WebCore::RenderMathMLPadded::computePreferredLogicalWidths):
+        (WebCore::RenderMathMLPadded::layoutBlock):
+        (WebCore::RenderMathMLPadded::updateFromElement):
+        (WebCore::RenderMathMLPadded::styleDidChange):
+        (WebCore::RenderMathMLPadded::firstLineBaseline):
+        * rendering/mathml/RenderMathMLPadded.h: Added.
+
+2016-07-07  Frederic Wang  <fwang@igalia.com>
+
         Move MathML-specific code into a separate accessibility class
         https://bugs.webkit.org/show_bug.cgi?id=159213
 
index 0343085..80174b1 100644 (file)
                5B30695D18B3D3450099D5E8 /* WebGLDrawBuffers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5B30695A18B3D3450099D5E8 /* WebGLDrawBuffers.cpp */; };
                5B30695E18B3D3450099D5E8 /* WebGLDrawBuffers.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B30695B18B3D3450099D5E8 /* WebGLDrawBuffers.h */; };
                5B7A208D2E12979B4AE19DE6 /* RenderMathMLSpace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DBFCB0EBFF5CD77EBEB35395 /* RenderMathMLSpace.cpp */; };
+               5B7A208D2E12979B4AE19E6F /* RenderMathMLPadded.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DBFCB0EBFF5CD77EBEB3595F /* RenderMathMLPadded.cpp */; };
                5C4304B0191AC908000E2BC0 /* EXTShaderTextureLOD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C4304AD191AC908000E2BC0 /* EXTShaderTextureLOD.cpp */; };
                5C4304B1191AC908000E2BC0 /* EXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */; };
                5C4304B5191AEF46000E2BC0 /* JSEXTShaderTextureLOD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C4304B3191AEF46000E2BC0 /* JSEXTShaderTextureLOD.cpp */; };
                3314ACE910892086000F0E56 /* JSExceptionBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSExceptionBase.cpp; sourceTree = "<group>"; };
                3314ACEA10892086000F0E56 /* JSExceptionBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSExceptionBase.h; sourceTree = "<group>"; };
                331FF67DE197B57393C46AA7 /* RenderMathMLSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLSpace.h; sourceTree = "<group>"; };
+               331FF67DE197B57393C46A7F /* RenderMathMLPadded.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLPadded.h; sourceTree = "<group>"; };
                333F704E0FB49CA2008E12A6 /* Notification.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Notification.idl; sourceTree = "<group>"; };
                333F704F0FB49CA2008E12A6 /* Notification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Notification.h; sourceTree = "<group>"; };
                33503C9910179A74003B47E1 /* NotificationClient.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = NotificationClient.h; sourceTree = "<group>"; };
                DB23C2C90A508D29002489EB /* IndentOutdentCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IndentOutdentCommand.cpp; sourceTree = "<group>"; };
                DB23C2CA0A508D29002489EB /* IndentOutdentCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IndentOutdentCommand.h; sourceTree = "<group>"; };
                DBFCB0EBFF5CD77EBEB35395 /* RenderMathMLSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLSpace.cpp; sourceTree = "<group>"; };
+               DBFCB0EBFF5CD77EBEB3595F /* RenderMathMLPadded.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLPadded.cpp; sourceTree = "<group>"; };
                DD05FE0B0B8BA3C6009ACDFE /* WebCoreObjCExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreObjCExtras.h; sourceTree = "<group>"; };
                DD763BB10992C2C900740B8E /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = /usr/lib/libxml2.dylib; sourceTree = "<absolute>"; };
                DE49B2FF165F2FC60010338D /* MediaControlElementTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControlElementTypes.cpp; sourceTree = "<group>"; };
                                439046D412DA25E800AF80A2 /* RenderMathMLScripts.h */,
                                DBFCB0EBFF5CD77EBEB35395 /* RenderMathMLSpace.cpp */,
                                331FF67DE197B57393C46AA7 /* RenderMathMLSpace.h */,
+                               DBFCB0EBFF5CD77EBEB3595F /* RenderMathMLPadded.cpp */,
+                               331FF67DE197B57393C46A7F /* RenderMathMLPadded.h */,
                                439046D712DA25E800AF80A9 /* RenderMathMLToken.cpp */,
                                439046D812DA25E800AF80A9 /* RenderMathMLToken.h */,
                                439046D512DA25E800AF80A2 /* RenderMathMLUnderOver.cpp */,
                                439046E312DA25E800AF80A2 /* RenderMathMLRow.cpp in Sources */,
                                439046E712DA25E800AF80A2 /* RenderMathMLScripts.cpp in Sources */,
                                5B7A208D2E12979B4AE19DE6 /* RenderMathMLSpace.cpp in Sources */,
+                               5B7A208D2E12979B4AE19E6F /* RenderMathMLPadded.cpp in Sources */,
                                439046EB12DA25E800AF80A9 /* RenderMathMLToken.cpp in Sources */,
                                439046E912DA25E800AF80A2 /* RenderMathMLUnderOver.cpp in Sources */,
                                E4C279580CF9741900E97B98 /* RenderMedia.cpp in Sources */,
index 3577128..09c58b5 100644 (file)
@@ -35,6 +35,7 @@
 #include "RenderMathMLFenced.h"
 #include "RenderMathMLFraction.h"
 #include "RenderMathMLMenclose.h"
+#include "RenderMathMLPadded.h"
 #include "RenderMathMLRoot.h"
 #include "RenderMathMLRow.h"
 #include "RenderMathMLScripts.h"
@@ -79,6 +80,8 @@ RenderPtr<RenderElement> MathMLInlineContainerElement::createElementRenderer(Ren
         return createRenderer<RenderMathMLFenced>(*this, WTFMove(style));
     if (hasTagName(mtableTag))
         return createRenderer<RenderMathMLTable>(*this, WTFMove(style));
+    if (hasTagName(mpaddedTag))
+        return createRenderer<RenderMathMLPadded>(*this, WTFMove(style));
 
     return createRenderer<RenderMathMLBlock>(*this, WTFMove(style));
 }
index 0d31d49..d7c04a8 100644 (file)
@@ -47,4 +47,5 @@ stretchy
 symmetric
 subscriptshift
 superscriptshift
+voffset
 width
index 5d081d1..3e53056 100644 (file)
@@ -11,6 +11,7 @@ mfrac interfaceName=MathMLInlineContainerElement
 mfenced interfaceName=MathMLInlineContainerElement
 msubsup interfaceName=MathMLInlineContainerElement
 merror interfaceName=MathMLInlineContainerElement
+mpadded interfaceName=MathMLInlineContainerElement
 mphantom interfaceName=MathMLInlineContainerElement
 mrow interfaceName=MathMLInlineContainerElement
 mstyle interfaceName=MathMLInlineContainerElement
@@ -41,7 +42,6 @@ malignmark interfaceName=MathMLElement
 mglyph interfaceName=MathMLElement
 mlabeledtr interfaceName=MathMLElement
 mlongdiv interfaceName=MathMLElement
-mpadded interfaceName=MathMLElement
 mscarries interfaceName=MathMLElement
 mscarry interfaceName=MathMLElement
 msgroup interfaceName=MathMLElement
index 2baf11e..47892f9 100644 (file)
@@ -342,6 +342,7 @@ public:
     virtual bool isRenderMathMLMenclose() const { return false; }
     virtual bool isRenderMathMLFenced() const { return false; }
     virtual bool isRenderMathMLFraction() const { return false; }
+    virtual bool isRenderMathMLPadded() const { return false; }
     virtual bool isRenderMathMLRoot() const { return false; }
     virtual bool isRenderMathMLSpace() const { return false; }
     virtual bool isRenderMathMLSquareRoot() const { return false; }
diff --git a/Source/WebCore/rendering/mathml/RenderMathMLPadded.cpp b/Source/WebCore/rendering/mathml/RenderMathMLPadded.cpp
new file mode 100644 (file)
index 0000000..21a555d
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * 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"
+#include "RenderMathMLPadded.h"
+
+#if ENABLE(MATHML)
+
+#include "MathMLNames.h"
+#include <cmath>
+
+namespace WebCore {
+
+using namespace MathMLNames;
+
+RenderMathMLPadded::RenderMathMLPadded(Element& element, RenderStyle&& style)
+    : RenderMathMLRow(element, WTFMove(style))
+{
+}
+
+void RenderMathMLPadded::computePreferredLogicalWidths()
+{
+    ASSERT(preferredLogicalWidthsDirty());
+
+    // Determine the intrinsic width of the content.
+    RenderMathMLRow::computePreferredLogicalWidths();
+
+    // Only the width attribute should modify the width.
+    // We parse it using the preferred width of the content as its default value.
+    LayoutUnit width = m_maxPreferredLogicalWidth;
+    parseMathMLLength(element()->fastGetAttribute(MathMLNames::widthAttr), width, &style(), false);
+
+    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = width;
+
+    setPreferredLogicalWidthsDirty(false);
+}
+
+void RenderMathMLPadded::layoutBlock(bool relayoutChildren, LayoutUnit)
+{
+    ASSERT(needsLayout());
+
+    if (!relayoutChildren && simplifiedLayout())
+        return;
+
+    // We first layout our children as a normal <mrow> element.
+    LayoutUnit contentAscent, contentDescent, contentWidth;
+    contentAscent = contentDescent = 0;
+    RenderMathMLRow::computeLineVerticalStretch(contentAscent, contentDescent);
+    RenderMathMLRow::layoutRowItems(contentAscent, contentDescent);
+    contentWidth = logicalWidth();
+
+    // We parse the mpadded attributes using the content metrics as the default value.
+    // FIXME: We should also accept pseudo-units and (some) negative values.
+    // See https://bugs.webkit.org/show_bug.cgi?id=85730
+    LayoutUnit width = contentWidth;
+    LayoutUnit ascent = contentAscent;
+    LayoutUnit descent = contentDescent;
+    LayoutUnit lspace = 0;
+    LayoutUnit voffset = 0;
+    parseMathMLLength(element()->fastGetAttribute(MathMLNames::widthAttr), width, &style());
+    parseMathMLLength(element()->fastGetAttribute(MathMLNames::heightAttr), ascent, &style());
+    parseMathMLLength(element()->fastGetAttribute(MathMLNames::depthAttr), descent, &style());
+    parseMathMLLength(element()->fastGetAttribute(MathMLNames::lspaceAttr), lspace, &style());
+    parseMathMLLength(element()->fastGetAttribute(MathMLNames::voffsetAttr), voffset, &style());
+    if (width < 0)
+        width = 0;
+    if (ascent < 0)
+        ascent = 0;
+    if (descent < 0)
+        descent = 0;
+    if (lspace < 0)
+        lspace = 0;
+
+    // Align children on the new baseline and shift them by (lspace, -voffset)
+    LayoutPoint contentLocation(lspace, ascent - contentAscent - voffset);
+    for (auto* child = firstChildBox(); child; child = child->nextSiblingBox())
+        child->setLocation(child->location() + contentLocation);
+
+    // Set the final metrics.
+    setLogicalWidth(width);
+    m_ascent = ascent;
+    setLogicalHeight(ascent + descent);
+
+    clearNeedsLayout();
+}
+
+void RenderMathMLPadded::updateFromElement()
+{
+    RenderMathMLRow::updateFromElement();
+    setNeedsLayoutAndPrefWidthsRecalc();
+}
+
+void RenderMathMLPadded::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
+{
+    RenderMathMLRow::styleDidChange(diff, oldStyle);
+    setNeedsLayoutAndPrefWidthsRecalc();
+}
+
+Optional<int> RenderMathMLPadded::firstLineBaseline() const
+{
+    return Optional<int>(std::lround(static_cast<float>(m_ascent)));
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/rendering/mathml/RenderMathMLPadded.h b/Source/WebCore/rendering/mathml/RenderMathMLPadded.h
new file mode 100644 (file)
index 0000000..67747f2
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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 RenderMathMLPadded_h
+#define RenderMathMLPadded_h
+#pragma once
+
+#if ENABLE(MATHML)
+
+#include "RenderMathMLRow.h"
+
+namespace WebCore {
+
+class RenderMathMLPadded final : public RenderMathMLRow {
+public:
+    RenderMathMLPadded(Element&, RenderStyle&&);
+
+private:
+    const char* renderName() const final { return "RenderMathMLPadded"; }
+    bool isRenderMathMLPadded() const final { return true; }
+
+    void computePreferredLogicalWidths() final;
+    void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
+    Optional<int> firstLineBaseline() const final;
+
+    void updateFromElement() final;
+    void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
+
+    LayoutUnit m_ascent;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLPadded, isRenderMathMLPadded())
+
+#endif // ENABLE(MATHML)
+#endif // RenderMathMLPadded_h