Title: [208648] trunk
Revision
208648
Author
[email protected]
Date
2016-11-12 06:50:50 -0800 (Sat, 12 Nov 2016)

Log Message

Ensure MathML render tree are clean by the end of FrameView::layout().
https://bugs.webkit.org/show_bug.cgi?id=162824

Patch by Frederic Wang <[email protected]> on 2016-11-12
Reviewed by Darin Adler.

Source/WebCore:

clearNeedsLayout is not called during the layout of invalid MathML markup. We introduce a new
helper function to perform proper layout of such markup and we now call it from the various
MathML layoutBlock functions. Additionally, we ensure that the preferred width is dirty after
computation in RenderMathMLScripts::computePreferredLogicalWidths.

Test: mathml/invalid-markup.html

* rendering/mathml/RenderMathMLBlock.cpp:
(WebCore::RenderMathMLBlock::layoutInvalidMarkup): Helper function to layout invalid markup.
* rendering/mathml/RenderMathMLBlock.h: Declare layoutInvalidMarkup.
* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::layoutBlock): Call layoutInvalidMarkup.
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::layoutBlock): Ditto.
* rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::computePreferredLogicalWidths): Set the preferred width dirty
after computation to avoid that it is computed again and again.
(WebCore::RenderMathMLScripts::layoutBlock): Call layoutInvalidMarkup.
* rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::layoutBlock): Ditto.

LayoutTests:

* mathml/invalid-markup-expected.txt: Added.
* mathml/invalid-markup.html: Added.
* mathml/mn-as-list-item-assert-expected.txt: Update text expectation now that invalid
subtree appears in the output.
* mathml/msubsup-fuzz-expected.txt: Ditto.
* accessibility/mac/mathml-multiscript.txt: Ditto.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208647 => 208648)


--- trunk/LayoutTests/ChangeLog	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/LayoutTests/ChangeLog	2016-11-12 14:50:50 UTC (rev 208648)
@@ -1,3 +1,17 @@
+2016-11-12  Frederic Wang  <[email protected]>
+
+        Ensure MathML render tree are clean by the end of FrameView::layout().
+        https://bugs.webkit.org/show_bug.cgi?id=162824
+
+        Reviewed by Darin Adler.
+
+        * mathml/invalid-markup-expected.txt: Added.
+        * mathml/invalid-markup.html: Added.
+        * mathml/mn-as-list-item-assert-expected.txt: Update text expectation now that invalid
+        subtree appears in the output.
+        * mathml/msubsup-fuzz-expected.txt: Ditto.
+        * accessibility/mac/mathml-multiscript.txt: Ditto.
+
 2016-11-11  Ryosuke Niwa  <[email protected]>
 
         event.composedPath() does not include window

Modified: trunk/LayoutTests/accessibility/mac/mathml-multiscript-expected.txt (208647 => 208648)


--- trunk/LayoutTests/accessibility/mac/mathml-multiscript-expected.txt	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/LayoutTests/accessibility/mac/mathml-multiscript-expected.txt	2016-11-12 14:50:50 UTC (rev 208648)
@@ -2,15 +2,35 @@
 1
 2
  
+A
+1
+2
+3
  
 A
 4
 5
  
+A
+4
+5
+6
  
+A
+1
+2
+3
+4
+5
+6
  
 A
  
+A
+1
+3
+5
+6
 This tests checks that mmultiscript tags will create the correct accessibility math hierarchy.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Added: trunk/LayoutTests/mathml/invalid-markup-expected.txt (0 => 208648)


--- trunk/LayoutTests/mathml/invalid-markup-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/mathml/invalid-markup-expected.txt	2016-11-12 14:50:50 UTC (rev 208648)
@@ -0,0 +1,65 @@
+Test passes if it does not debug assert.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Test 1: Invalid <mfrac> tag:
+
+1
+2
+3
+Test 2: Invalid <mroot> tag:
+
+1
+2
+3
+Test 3: Invalid <munder> tag:
+
+1
+2
+3
+Test 4: Invalid <mover> tag:
+
+1
+2
+3
+Test 5: Invalid <munderover> tag:
+
+1
+2
+1
+2
+3
+4
+Test 6: Invalid <msub> tag:
+
+1
+2
+3
+Test 7: Invalid <msup> tag:
+
+1
+2
+3
+Test 8: Invalid <msubsup> tag:
+
+1
+2
+1
+2
+3
+4
+Test 9: Invalid <mmultiscripts> tag:
+
+1
+2
+3
+4
+1
+2
+3
+4
+

Added: trunk/LayoutTests/mathml/invalid-markup.html (0 => 208648)


--- trunk/LayoutTests/mathml/invalid-markup.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/invalid-markup.html	2016-11-12 14:50:50 UTC (rev 208648)
@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <script src=""
+    <script>
+      description("Test passes if it does not debug assert.");
+    </script>
+  </head>
+  <body>
+    <div>
+      <p>Test 1: Invalid &lt;mfrac&gt; tag:</p>
+      <math>
+        <mfrac></mfrac>
+        <mfrac><mn>1</mn><mn>2</mn><mn>3</mn></mfrac>
+      </math>
+    </div>
+    <div>
+      <p>Test 2: Invalid &lt;mroot&gt; tag:</p>
+      <math>
+        <mroot></mroot>
+        <mroot><mn>1</mn><mn>2</mn><mn>3</mn></mroot>
+      </math>
+    </div>
+    <div>
+      <p>Test 3: Invalid &lt;munder&gt; tag:</p>
+      <math>
+        <munder></munder>
+        <munder><mn>1</mn><mn>2</mn><mn>3</mn></munder>
+      </math>
+    </div>
+    <div>
+      <p>Test 4: Invalid &lt;mover&gt; tag:</p>
+      <math>
+        <mover></mover>
+        <mover><mn>1</mn><mn>2</mn><mn>3</mn></mover>
+      </math>
+    </div>
+    <div>
+      <p>Test 5: Invalid &lt;munderover&gt; tag:</p>
+      <math>
+        <munderover></munderover>
+        <munderover><mn>1</mn><mn>2</mn></munderover>
+        <munderover><mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn></munderover>
+      </math>
+    </div>
+    <div>
+      <p>Test 6: Invalid &lt;msub&gt; tag:</p>
+      <math>
+        <msub></msub>
+        <msub><mn>1</mn><mn>2</mn><mn>3</mn></msub>
+      </math>
+    </div>
+    <div>
+      <p>Test 7: Invalid &lt;msup&gt; tag:</p>
+      <math>
+        <msup></msup>
+        <msup><mn>1</mn><mn>2</mn><mn>3</mn></msup>
+      </math>
+    </div>
+    <div>
+      <p>Test 8: Invalid &lt;msubsup&gt; tag:</p>
+      <math>
+        <msubsup></msubsup>
+        <msubsup><mn>1</mn><mn>2</mn></msubsup>
+        <msubsup><mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn></msubsup>
+      </math>
+    </div>
+    <div>
+      <p>Test 9: Invalid &lt;mmultiscripts&gt; tag:</p>
+      <math>
+        <mmultiscripts>
+        </mmultiscripts>
+        <mmultiscripts>
+          <mn>1</mn>
+          <mn>2</mn>
+          <mn>3</mn>
+          <mprescripts/>
+          <mn>4</mn>
+        </mmultiscripts>
+        <mmultiscripts>
+          <mn>1</mn>
+          <mn>2</mn>
+          <mprescripts/>
+          <mn>3</mn>
+          <mn>4</mn>
+        </mmultiscripts>
+      </math>
+    </div>
+  </body>
+</html>

Modified: trunk/LayoutTests/mathml/mn-as-list-item-assert-expected.txt (208647 => 208648)


--- trunk/LayoutTests/mathml/mn-as-list-item-assert-expected.txt	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/LayoutTests/mathml/mn-as-list-item-assert-expected.txt	2016-11-12 14:50:50 UTC (rev 208648)
@@ -1,3 +1,4 @@
 This test PASSES if it does not CRASH or ASSERT.
 
+mn
 

Modified: trunk/LayoutTests/mathml/msubsup-fuzz-expected.txt (208647 => 208648)


--- trunk/LayoutTests/mathml/msubsup-fuzz-expected.txt	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/LayoutTests/mathml/msubsup-fuzz-expected.txt	2016-11-12 14:50:50 UTC (rev 208648)
@@ -1,3 +1,4 @@
 This test passes if it does not crash.
 
+3
 

Modified: trunk/Source/WebCore/ChangeLog (208647 => 208648)


--- trunk/Source/WebCore/ChangeLog	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/Source/WebCore/ChangeLog	2016-11-12 14:50:50 UTC (rev 208648)
@@ -1,5 +1,33 @@
 2016-11-12  Frederic Wang  <[email protected]>
 
+        Ensure MathML render tree are clean by the end of FrameView::layout().
+        https://bugs.webkit.org/show_bug.cgi?id=162824
+
+        Reviewed by Darin Adler.
+
+        clearNeedsLayout is not called during the layout of invalid MathML markup. We introduce a new
+        helper function to perform proper layout of such markup and we now call it from the various
+        MathML layoutBlock functions. Additionally, we ensure that the preferred width is dirty after
+        computation in RenderMathMLScripts::computePreferredLogicalWidths.
+
+        Test: mathml/invalid-markup.html
+
+        * rendering/mathml/RenderMathMLBlock.cpp:
+        (WebCore::RenderMathMLBlock::layoutInvalidMarkup): Helper function to layout invalid markup.
+        * rendering/mathml/RenderMathMLBlock.h: Declare layoutInvalidMarkup.
+        * rendering/mathml/RenderMathMLFraction.cpp:
+        (WebCore::RenderMathMLFraction::layoutBlock): Call layoutInvalidMarkup.
+        * rendering/mathml/RenderMathMLRoot.cpp:
+        (WebCore::RenderMathMLRoot::layoutBlock): Ditto.
+        * rendering/mathml/RenderMathMLScripts.cpp:
+        (WebCore::RenderMathMLScripts::computePreferredLogicalWidths): Set the preferred width dirty
+        after computation to avoid that it is computed again and again.
+        (WebCore::RenderMathMLScripts::layoutBlock): Call layoutInvalidMarkup.
+        * rendering/mathml/RenderMathMLUnderOver.cpp:
+        (WebCore::RenderMathMLUnderOver::layoutBlock): Ditto.
+
+2016-11-12  Frederic Wang  <[email protected]>
+
         Remove RenderMathMLOperator::shouldAllowStretching
         https://bugs.webkit.org/show_bug.cgi?id=164313
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp (208647 => 208648)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2016-11-12 14:50:50 UTC (rev 208648)
@@ -248,6 +248,18 @@
     clearNeedsLayout();
 }
 
+void RenderMathMLBlock::layoutInvalidMarkup()
+{
+    // Invalid MathML subtrees are just renderered as empty boxes.
+    // FIXME: https://webkit.org/b/135460 - Should we display some "invalid" markup message instead?
+    ASSERT(needsLayout());
+    for (auto child = firstChildBox(); child; child = child->nextSiblingBox())
+        child->layoutIfNeeded();
+    setLogicalWidth(0);
+    setLogicalHeight(0);
+    clearNeedsLayout();
 }
 
+}
+
 #endif

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h (208647 => 208648)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h	2016-11-12 14:50:50 UTC (rev 208648)
@@ -83,6 +83,7 @@
     }
 
     void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) override;
+    void layoutInvalidMarkup();
 
 private:
     bool isRenderMathMLBlock() const final { return true; }

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp (208647 => 208648)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp	2016-11-12 14:50:50 UTC (rev 208648)
@@ -180,9 +180,7 @@
         return;
 
     if (!isValid()) {
-        setLogicalWidth(0);
-        setLogicalHeight(0);
-        clearNeedsLayout();
+        layoutInvalidMarkup();
         return;
     }
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp (208647 => 208648)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp	2016-11-12 14:50:50 UTC (rev 208648)
@@ -185,9 +185,7 @@
     m_baseWidth = 0;
 
     if (!isValid()) {
-        setLogicalWidth(0);
-        setLogicalHeight(0);
-        clearNeedsLayout();
+        layoutInvalidMarkup();
         return;
     }
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp (208647 => 208648)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2016-11-12 14:50:50 UTC (rev 208648)
@@ -182,12 +182,16 @@
 
 void RenderMathMLScripts::computePreferredLogicalWidths()
 {
+    ASSERT(preferredLogicalWidthsDirty());
+
     m_minPreferredLogicalWidth = 0;
     m_maxPreferredLogicalWidth = 0;
 
     auto possibleReference = validateAndGetReferenceChildren();
-    if (!possibleReference)
+    if (!possibleReference) {
+        setPreferredLogicalWidthsDirty(false);
         return;
+    }
     auto& reference = possibleReference.value();
 
     LayoutUnit baseItalicCorrection = std::min(reference.base->maxPreferredLogicalWidth(), italicCorrection(reference));
@@ -228,6 +232,8 @@
     }
 
     m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
+
+    setPreferredLogicalWidthsDirty(false);
 }
 
 auto RenderMathMLScripts::verticalParameters() const -> VerticalParameters
@@ -357,9 +363,7 @@
 
     auto possibleReference = validateAndGetReferenceChildren();
     if (!possibleReference) {
-        setLogicalWidth(0);
-        setLogicalHeight(0);
-        clearNeedsLayout();
+        layoutInvalidMarkup();
         return;
     }
     auto& reference = possibleReference.value();

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp (208647 => 208648)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp	2016-11-12 12:41:35 UTC (rev 208647)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp	2016-11-12 14:50:50 UTC (rev 208648)
@@ -247,9 +247,7 @@
         return;
 
     if (!isValid()) {
-        setLogicalWidth(0);
-        setLogicalHeight(0);
-        clearNeedsLayout();
+        layoutInvalidMarkup();
         return;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to