Bad position of large operators inside an munderover element
authorfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Dec 2015 14:46:11 +0000 (14:46 +0000)
committerfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Dec 2015 14:46:11 +0000 (14:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151916

Reviewed by Alejandro G. Castro.

Source/WebCore:

Test: mathml/opentype/large-operators-munderover.html

* rendering/mathml/RenderMathMLOperator.h:
(WebCore::RenderMathMLOperator::isVertical): Expose the direction of the operator.
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::layout): Remove call to horizontal stretching for vertical operators.

LayoutTests:

* mathml/opentype/large-operators-munderover-expected.txt: Added.
* mathml/opentype/large-operators-munderover.html: Added.

Add a test to verify the position and size of a large operator used as an munderover base.

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

LayoutTests/ChangeLog
LayoutTests/mathml/opentype/large-operators-munderover-expected.txt [new file with mode: 0644]
LayoutTests/mathml/opentype/large-operators-munderover.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/mathml/RenderMathMLOperator.h
Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp

index 32e1217..4af7983 100644 (file)
@@ -1,3 +1,15 @@
+2015-12-09  Frederic Wang  <fred.wang@free.fr>
+
+        Bad position of large operators inside an munderover element
+        https://bugs.webkit.org/show_bug.cgi?id=151916
+
+        Reviewed by Alejandro G. Castro.
+
+        * mathml/opentype/large-operators-munderover-expected.txt: Added.
+        * mathml/opentype/large-operators-munderover.html: Added.
+
+        Add a test to verify the position and size of a large operator used as an munderover base.
+
 2015-12-09  Joanmarie Diggs  <jdiggs@igalia.com>
 
         [AX][GTK] Accessibility gardening
diff --git a/LayoutTests/mathml/opentype/large-operators-munderover-expected.txt b/LayoutTests/mathml/opentype/large-operators-munderover-expected.txt
new file mode 100644 (file)
index 0000000..a3544b8
--- /dev/null
@@ -0,0 +1,7 @@
+This test passes if you see a large black square with a green bar overscript and a red bar underscript.
+
+largeop width: PASS
+largeop height: PASS
+green bar is above: PASS
+red bar is below: PASS
+
diff --git a/LayoutTests/mathml/opentype/large-operators-munderover.html b/LayoutTests/mathml/opentype/large-operators-munderover.html
new file mode 100644 (file)
index 0000000..0344268
--- /dev/null
@@ -0,0 +1,54 @@
+<!doctype html>
+<html>
+  <head>
+    <title>Large Operator Munderover</title>
+    <meta charset="utf-8"/>
+    <style type="text/css">
+      /* This font is taken from Mozilla's test suite. */
+      @font-face {
+      font-family: stretchy;
+        src: url("stretchy.woff");
+      }
+      math {
+        font-family: stretchy;
+      }
+    </style>
+    <script>
+      var result;
+      var epsilon = 1;
+      function almostEqual(x, y) {
+        return Math.abs(x - y) < epsilon;
+      }
+      function assert(text, condition) {
+        result += text + ": " + (condition ? "PASS" : "FAIL") + "\n";
+      }
+      function test() {
+        result = "";
+        // font em is 1024, size of glyph L8 is 8389 and font-size is 16px
+        var largeop = document.getElementById("largeop").getBoundingClientRect();
+        var green = document.getElementById("green").getBoundingClientRect();
+        var red = document.getElementById("red").getBoundingClientRect();
+        var size = (8389/1024)*16;
+
+        assert("largeop width", almostEqual(largeop.width, size));
+        assert("largeop height", almostEqual(largeop.height, size));
+        assert("green bar is above", green.bottom <= largeop.top);
+        assert("red bar is below", red.top >= largeop.bottom);
+        document.getElementById("result").innerText = result;
+        if (window.testRunner)
+          testRunner.dumpAsText();
+      }
+    </script>
+  </head>
+  <body onload="test()">
+    <p>This test passes if you see a large black square with a green bar overscript and a red bar underscript.</p>
+    <math display="block">
+      <munderover>
+        <mo id="largeop" lspace="0px" rspace="0px" style="font-size: 16px;" >&#x2A1C;</mo>
+        <mspace id="red" width="200px" height="10px" depth="10px" mathbackground="red"/>
+        <mspace id="green" width="250px" height="10px" depth="10px" mathbackground="green"/>
+      </munderover>
+    </math>
+    <div id="result"></div>
+  </body>
+</html>
index 247f28e..8e27314 100644 (file)
@@ -1,3 +1,17 @@
+2015-12-09  Frederic Wang  <fred.wang@free.fr>
+
+        Bad position of large operators inside an munderover element
+        https://bugs.webkit.org/show_bug.cgi?id=151916
+
+        Reviewed by Alejandro G. Castro.
+
+        Test: mathml/opentype/large-operators-munderover.html
+
+        * rendering/mathml/RenderMathMLOperator.h:
+        (WebCore::RenderMathMLOperator::isVertical): Expose the direction of the operator.
+        * rendering/mathml/RenderMathMLUnderOver.cpp:
+        (WebCore::RenderMathMLUnderOver::layout): Remove call to horizontal stretching for vertical operators.
+
 2015-12-09  Zan Dobersek  <zdobersek@igalia.com>
 
         [TexMap] TextureMapperTiledBackingStore should notify the ImageObserver of the data access
index 859be4f..858092d 100644 (file)
@@ -71,6 +71,7 @@ public:
     bool hasOperatorFlag(MathMLOperatorDictionary::Flag flag) const { return m_operatorFlags & flag; }
     // FIXME: The displaystyle property is not implemented (https://bugs.webkit.org/show_bug.cgi?id=118737).
     bool isLargeOperatorInDisplayStyle() const { return !hasOperatorFlag(MathMLOperatorDictionary::Stretchy) && hasOperatorFlag(MathMLOperatorDictionary::LargeOp); }
+    bool isVertical() const { return m_isVertical; }
 
     virtual void updateStyle() override final;
 
index d2f005b..e368881 100644 (file)
@@ -80,8 +80,10 @@ void RenderMathMLUnderOver::layout()
         if (child->needsLayout()) {
             if (is<RenderMathMLBlock>(child)) {
                 if (auto renderOperator = downcast<RenderMathMLBlock>(*child).unembellishedOperator()) {
-                    renderOperator->resetStretchSize();
-                    renderOperators.append(renderOperator);
+                    if (!renderOperator->isVertical()) {
+                        renderOperator->resetStretchSize();
+                        renderOperators.append(renderOperator);
+                    }
                 }
             }