Assert that computePreferredLogicalWidths never calls setNeedsLayout
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 18:54:56 +0000 (18:54 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 18:54:56 +0000 (18:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107613

Reviewed by Eric Seidel.

computePreferredLogicalWidths should only set m_minPreferredLogicalWidth
and m_maxPreferredLogicalWidth. It shouldn't have other side-effects.
The mathml bits can be removed once https://bugs.webkit.org/show_bug.cgi?id=107353
is resolved.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::minPreferredLogicalWidth):
* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::computePreferredLogicalWidths):
* rendering/mathml/RenderMathMLRow.cpp:
(WebCore::RenderMathMLRow::computePreferredLogicalWidths):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp
Source/WebCore/rendering/mathml/RenderMathMLRow.cpp

index 452a235..e4ee6f5 100644 (file)
@@ -1,3 +1,24 @@
+2013-01-23  Ojan Vafai  <ojan@chromium.org>
+
+        Assert that computePreferredLogicalWidths never calls setNeedsLayout
+        https://bugs.webkit.org/show_bug.cgi?id=107613
+
+        Reviewed by Eric Seidel.
+
+        computePreferredLogicalWidths should only set m_minPreferredLogicalWidth
+        and m_maxPreferredLogicalWidth. It shouldn't have other side-effects.
+        The mathml bits can be removed once https://bugs.webkit.org/show_bug.cgi?id=107353
+        is resolved.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::minPreferredLogicalWidth):
+        * rendering/mathml/RenderMathMLOperator.cpp:
+        (WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
+        * rendering/mathml/RenderMathMLRoot.cpp:
+        (WebCore::RenderMathMLRoot::computePreferredLogicalWidths):
+        * rendering/mathml/RenderMathMLRow.cpp:
+        (WebCore::RenderMathMLRow::computePreferredLogicalWidths):
+
 2013-01-23  Noam Rosenthal  <noam@webkit.org>
 
         REGRESSION(r140518): Broke Chromium Win build (gyp file not updated) (Requested by arv on #webkit).
index c4a9ce4..443d224 100644 (file)
@@ -849,16 +849,24 @@ void RenderBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou
 
 LayoutUnit RenderBox::minPreferredLogicalWidth() const
 {
-    if (preferredLogicalWidthsDirty())
+    if (preferredLogicalWidthsDirty()) {
+#ifndef NDEBUG
+        SetLayoutNeededForbiddenScope layoutForbiddenScope(const_cast<RenderBox*>(this));
+#endif
         const_cast<RenderBox*>(this)->computePreferredLogicalWidths();
+    }
         
     return m_minPreferredLogicalWidth;
 }
 
 LayoutUnit RenderBox::maxPreferredLogicalWidth() const
 {
-    if (preferredLogicalWidthsDirty())
+    if (preferredLogicalWidthsDirty()) {
+#ifndef NDEBUG
+        SetLayoutNeededForbiddenScope layoutForbiddenScope(const_cast<RenderBox*>(this));
+#endif
         const_cast<RenderBox*>(this)->computePreferredLogicalWidths();
+    }
         
     return m_maxPreferredLogicalWidth;
 }
index bab3a48..c5e6e36 100644 (file)
@@ -83,11 +83,21 @@ void RenderMathMLOperator::styleDidChange(StyleDifference diff, const RenderStyl
 void RenderMathMLOperator::computePreferredLogicalWidths() 
 {
     ASSERT(preferredLogicalWidthsDirty());
+
+#ifndef NDEBUG
+    // FIXME: Remove the setNeedsLayoutIsForbidden calls once mathml stops modifying the render tree here.
+    bool oldSetNeedsLayoutIsForbidden = isSetNeedsLayoutForbidden();
+    setNeedsLayoutIsForbidden(false);
+#endif
     
     // Check for an uninitialized operator.
     if (!firstChild())
         updateFromElement();
-    
+
+#ifndef NDEBUG
+    setNeedsLayoutIsForbidden(oldSetNeedsLayoutIsForbidden);
+#endif
+
     RenderMathMLBlock::computePreferredLogicalWidths();
 }
 
index 3fc1723..17fa23e 100644 (file)
@@ -187,6 +187,12 @@ void RenderMathMLRoot::computePreferredLogicalWidths()
 {
     ASSERT(preferredLogicalWidthsDirty() && needsLayout());
     
+#ifndef NDEBUG
+    // FIXME: Remove the setNeedsLayoutIsForbidden calls once mathml stops modifying the render tree here.
+    bool oldSetNeedsLayoutIsForbidden = isSetNeedsLayoutForbidden();
+    setNeedsLayoutIsForbidden(false);
+#endif
+    
     computeChildrenPreferredLogicalHeights();
     
     int baseHeight = firstChild() ? roundToInt(preferredLogicalHeightAfterSizing(firstChild())) : style()->fontSize();
@@ -219,7 +225,11 @@ void RenderMathMLRoot::computePreferredLogicalWidths()
             m_indexTop = - rootExtraTop;
     } else
         m_intrinsicPaddingStart = frontWidth;
-    
+
+#ifndef NDEBUG
+    setNeedsLayoutIsForbidden(oldSetNeedsLayoutIsForbidden);
+#endif
+
     RenderMathMLBlock::computePreferredLogicalWidths();
     
     // Shrink our logical width to its probable value now without triggering unnecessary relayout of our children.
index a1438a4..d747359 100644 (file)
@@ -54,7 +54,13 @@ RenderMathMLRow* RenderMathMLRow::createAnonymousWithParentRenderer(const Render
 void RenderMathMLRow::computePreferredLogicalWidths()
 {
     ASSERT(preferredLogicalWidthsDirty() && needsLayout());
-    
+
+#ifndef NDEBUG
+    // FIXME: Remove the setNeedsLayoutIsForbidden calls once mathml stops modifying the render tree here.
+    bool oldSetNeedsLayoutIsForbidden = isSetNeedsLayoutForbidden();
+    setNeedsLayoutIsForbidden(false);
+#endif
+
     computeChildrenPreferredLogicalHeights();
     int stretchLogicalHeight = 0;
     for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
@@ -77,7 +83,11 @@ void RenderMathMLRow::computePreferredLogicalWidths()
                 renderMo->stretchToHeight(stretchLogicalHeight);
         }
     }
-    
+
+#ifndef NDEBUG
+    setNeedsLayoutIsForbidden(oldSetNeedsLayoutIsForbidden);
+#endif
+
     RenderMathMLBlock::computePreferredLogicalWidths();
     
     // Shrink our logical width to its probable value now without triggering unnecessary relayout of our children.