[LayoutState cleanup] Remove explicit LayoutStateMaintainer::pop calls.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Nov 2017 21:36:07 +0000 (21:36 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Nov 2017 21:36:07 +0000 (21:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179380
<rdar://problem/35392161>

Reviewed by Antti Koivisto.

Besides the pagination related explicit pops (FIXME), all LayoutStateMaintainer pops are
now in LayoutStateMaintainer's d'tor.

Covered by existing tests.

* rendering/LayoutState.cpp:
(WebCore::LayoutStateMaintainer::~LayoutStateMaintainer):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::simplifiedLayout):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlock):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::layout):
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::layout):
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutBlock):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutBlock):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::layoutShadowControls):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::layout):
* rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::layout):
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::calcRowLogicalHeight):
(WebCore::RenderTableSection::layout):
(WebCore::RenderTableSection::layoutRows):
* rendering/RenderVTTCue.cpp:
(WebCore::RenderVTTCue::layout):
* rendering/RenderView.cpp:
(WebCore::RenderView::layout):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/rendering/LayoutState.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp
Source/WebCore/rendering/RenderEmbeddedObject.cpp
Source/WebCore/rendering/RenderFlexibleBox.cpp
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTableRow.cpp
Source/WebCore/rendering/RenderTableSection.cpp
Source/WebCore/rendering/RenderVTTCue.cpp
Source/WebCore/rendering/RenderView.cpp

index 97d903e..ad7f3b5 100644 (file)
@@ -1,3 +1,47 @@
+2017-11-07  Zalan Bujtas  <zalan@apple.com>
+
+        [LayoutState cleanup] Remove explicit LayoutStateMaintainer::pop calls.
+        https://bugs.webkit.org/show_bug.cgi?id=179380
+        <rdar://problem/35392161>
+
+        Reviewed by Antti Koivisto.
+
+        Besides the pagination related explicit pops (FIXME), all LayoutStateMaintainer pops are
+        now in LayoutStateMaintainer's d'tor.
+
+        Covered by existing tests.
+
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutStateMaintainer::~LayoutStateMaintainer):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::simplifiedLayout):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::layoutBlock):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::layout):
+        * rendering/RenderDeprecatedFlexibleBox.cpp:
+        (WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::layout):
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutBlock):
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::layoutBlock):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::layoutShadowControls):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::layout):
+        * rendering/RenderTableRow.cpp:
+        (WebCore::RenderTableRow::layout):
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::calcRowLogicalHeight):
+        (WebCore::RenderTableSection::layout):
+        (WebCore::RenderTableSection::layoutRows):
+        * rendering/RenderVTTCue.cpp:
+        (WebCore::RenderVTTCue::layout):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::layout):
+
 2017-11-07  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r224512 and r224521.
index ccd37bb..6f58201 100644 (file)
@@ -232,6 +232,9 @@ LayoutStateMaintainer::LayoutStateMaintainer(LayoutContext& layoutContext)
 
 LayoutStateMaintainer::~LayoutStateMaintainer()
 {
+    // FIXME: Remove conditional push/pop.
+    if (m_didCallPush && !m_didCallPop)
+        pop();
     ASSERT(!m_didCallPush || m_didCallPush == m_didCallPop);
 }
 
index 1258918..4cc47c5 100644 (file)
@@ -1321,10 +1321,8 @@ bool RenderBlock::simplifiedLayout()
         return false;
 
     LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
-    if (needsPositionedMovementLayout() && !tryLayoutDoingPositionedMovementOnly()) {
-        statePusher.pop();
+    if (needsPositionedMovementLayout() && !tryLayoutDoingPositionedMovementOnly())
         return false;
-    }
 
     // Lay out positioned descendants or objects that just need to recompute overflow.
     if (needsSimplifiedNormalFlowLayout())
@@ -1354,8 +1352,6 @@ bool RenderBlock::simplifiedLayout()
     LayoutUnit oldClientAfterEdge = hasRenderOverflow() ? m_overflow->layoutClientAfterEdge() : clientLogicalBottom();
     computeOverflow(oldClientAfterEdge, true);
 
-    statePusher.pop();
-    
     updateLayerTransform();
 
     updateScrollInfoAfterLayout();
index 67ace7f..943eee6 100644 (file)
@@ -475,88 +475,89 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalH
     bool pageLogicalHeightChanged = false;
     checkForPaginationLogicalHeightChange(relayoutChildren, pageLogicalHeight, pageLogicalHeightChanged);
 
-    const RenderStyle& styleToUse = style();
-    LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || styleToUse.isFlippedBlocksWritingMode(), pageLogicalHeight, pageLogicalHeightChanged);
-
-    preparePaginationBeforeBlockLayout(relayoutChildren);
-
-    // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track
-    // our current maximal positive and negative margins. These values are used when we
-    // are collapsed with adjacent blocks, so for example, if you have block A and B
-    // collapsing together, then you'd take the maximal positive margin from both A and B
-    // and subtract it from the maximal negative margin from both A and B to get the
-    // true collapsed margin. This algorithm is recursive, so when we finish layout()
-    // our block knows its current maximal positive/negative values.
-    //
-    // Start out by setting our margin values to our current margins. Table cells have
-    // no margins, so we don't fill in the values for table cells.
-    bool isCell = isTableCell();
-    if (!isCell) {
-        initMaxMarginValues();
-        
-        setHasMarginBeforeQuirk(styleToUse.hasMarginBeforeQuirk());
-        setHasMarginAfterQuirk(styleToUse.hasMarginAfterQuirk());
-        setPaginationStrut(0);
-    }
-
     LayoutUnit repaintLogicalTop = 0;
     LayoutUnit repaintLogicalBottom = 0;
-    LayoutUnit maxFloatLogicalBottom = 0;
-    if (!firstChild() && !isAnonymousBlock())
-        setChildrenInline(true);
-    if (childrenInline())
-        layoutInlineChildren(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
-    else
-        layoutBlockChildren(relayoutChildren, maxFloatLogicalBottom);
+    const RenderStyle& styleToUse = style();
+    {
+        LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || styleToUse.isFlippedBlocksWritingMode(), pageLogicalHeight, pageLogicalHeightChanged);
+
+        preparePaginationBeforeBlockLayout(relayoutChildren);
+
+        // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track
+        // our current maximal positive and negative margins. These values are used when we
+        // are collapsed with adjacent blocks, so for example, if you have block A and B
+        // collapsing together, then you'd take the maximal positive margin from both A and B
+        // and subtract it from the maximal negative margin from both A and B to get the
+        // true collapsed margin. This algorithm is recursive, so when we finish layout()
+        // our block knows its current maximal positive/negative values.
+        //
+        // Start out by setting our margin values to our current margins. Table cells have
+        // no margins, so we don't fill in the values for table cells.
+        bool isCell = isTableCell();
+        if (!isCell) {
+            initMaxMarginValues();
+
+            setHasMarginBeforeQuirk(styleToUse.hasMarginBeforeQuirk());
+            setHasMarginAfterQuirk(styleToUse.hasMarginAfterQuirk());
+            setPaginationStrut(0);
+        }
 
-    // Expand our intrinsic height to encompass floats.
-    LayoutUnit toAdd = borderAndPaddingAfter() + scrollbarLogicalHeight();
-    if (lowestFloatLogicalBottom() > (logicalHeight() - toAdd) && createsNewFormattingContext())
-        setLogicalHeight(lowestFloatLogicalBottom() + toAdd);
-    
-    if (relayoutForPagination(statePusher) || relayoutToAvoidWidows(statePusher)) {
-        ASSERT(!shouldBreakAtLineToAvoidWidow());
-        return;
-    }
+        LayoutUnit maxFloatLogicalBottom = 0;
+        if (!firstChild() && !isAnonymousBlock())
+            setChildrenInline(true);
+        if (childrenInline())
+            layoutInlineChildren(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
+        else
+            layoutBlockChildren(relayoutChildren, maxFloatLogicalBottom);
 
-    // Calculate our new height.
-    LayoutUnit oldHeight = logicalHeight();
-    LayoutUnit oldClientAfterEdge = clientLogicalBottom();
+        // Expand our intrinsic height to encompass floats.
+        LayoutUnit toAdd = borderAndPaddingAfter() + scrollbarLogicalHeight();
+        if (lowestFloatLogicalBottom() > (logicalHeight() - toAdd) && createsNewFormattingContext())
+            setLogicalHeight(lowestFloatLogicalBottom() + toAdd);
 
-    // Before updating the final size of the flow thread make sure a forced break is applied after the content.
-    // This ensures the size information is correctly computed for the last auto-height fragment receiving content.
-    if (is<RenderFragmentedFlow>(*this))
-        downcast<RenderFragmentedFlow>(*this).applyBreakAfterContent(oldClientAfterEdge);
+        if (relayoutForPagination(statePusher) || relayoutToAvoidWidows(statePusher)) {
+            ASSERT(!shouldBreakAtLineToAvoidWidow());
+            return;
+        }
 
-    updateLogicalHeight();
-    LayoutUnit newHeight = logicalHeight();
-    if (oldHeight != newHeight) {
-        if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !childrenInline()) {
-            // One of our children's floats may have become an overhanging float for us. We need to look for it.
-            for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
-                if (blockFlow.isFloatingOrOutOfFlowPositioned())
-                    continue;
-                if (blockFlow.lowestFloatLogicalBottom() + blockFlow.logicalTop() > newHeight)
-                    addOverhangingFloats(blockFlow, false);
+        // Calculate our new height.
+        LayoutUnit oldHeight = logicalHeight();
+        LayoutUnit oldClientAfterEdge = clientLogicalBottom();
+
+        // Before updating the final size of the flow thread make sure a forced break is applied after the content.
+        // This ensures the size information is correctly computed for the last auto-height fragment receiving content.
+        if (is<RenderFragmentedFlow>(*this))
+            downcast<RenderFragmentedFlow>(*this).applyBreakAfterContent(oldClientAfterEdge);
+
+        updateLogicalHeight();
+        LayoutUnit newHeight = logicalHeight();
+        if (oldHeight != newHeight) {
+            if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !childrenInline()) {
+                // One of our children's floats may have become an overhanging float for us. We need to look for it.
+                for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
+                    if (blockFlow.isFloatingOrOutOfFlowPositioned())
+                        continue;
+                    if (blockFlow.lowestFloatLogicalBottom() + blockFlow.logicalTop() > newHeight)
+                        addOverhangingFloats(blockFlow, false);
+                }
             }
         }
-    }
 
-    bool heightChanged = (previousHeight != newHeight);
-    if (heightChanged)
-        relayoutChildren = true;
+        bool heightChanged = (previousHeight != newHeight);
+        if (heightChanged)
+            relayoutChildren = true;
 
-    layoutPositionedObjects(relayoutChildren || isDocumentElementRenderer());
+        layoutPositionedObjects(relayoutChildren || isDocumentElementRenderer());
 
-    // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway).
-    computeOverflow(oldClientAfterEdge);
-    
-    statePusher.pop();
+        // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway).
+        computeOverflow(oldClientAfterEdge);
 
-    fitBorderToLinesIfNeeded();
+        fitBorderToLinesIfNeeded();
+    }
 
-    if (view().frameView().layoutContext().layoutState()->m_pageLogicalHeight)
-        setPageLogicalOffset(view().frameView().layoutContext().layoutState()->pageLogicalOffset(this, logicalTop()));
+    auto* state = view().frameView().layoutContext().layoutState();
+    if (state && state->m_pageLogicalHeight)
+        setPageLogicalOffset(state->pageLogicalOffset(this, logicalTop()));
 
     updateLayerTransform();
 
index 6a90d1f..1fa66d0 100644 (file)
@@ -518,7 +518,6 @@ void RenderBox::layout()
         ASSERT(!child->needsLayout());
         child = child->nextSibling();
     }
-    statePusher.pop();
     invalidateBackgroundObscurationStatus();
     clearNeedsLayout();
 }
index e664608..4f3d6ac 100644 (file)
@@ -281,60 +281,61 @@ void RenderDeprecatedFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit)
         return;
 
     LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
-    LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
+    {
+        LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
 
-    preparePaginationBeforeBlockLayout(relayoutChildren);
+        preparePaginationBeforeBlockLayout(relayoutChildren);
 
-    LayoutSize previousSize = size();
+        LayoutSize previousSize = size();
 
-    updateLogicalWidth();
-    updateLogicalHeight();
+        updateLogicalWidth();
+        updateLogicalHeight();
 
-    if (previousSize != size()
-        || (parent()->isDeprecatedFlexibleBox() && parent()->style().boxOrient() == HORIZONTAL
-        && parent()->style().boxAlign() == BSTRETCH))
-        relayoutChildren = true;
+        if (previousSize != size()
+            || (parent()->isDeprecatedFlexibleBox() && parent()->style().boxOrient() == HORIZONTAL
+                && parent()->style().boxAlign() == BSTRETCH))
+            relayoutChildren = true;
 
-    setHeight(0);
+        setHeight(0);
 
-    m_stretchingChildren = false;
+        m_stretchingChildren = false;
 
 #if !ASSERT_DISABLED
-    LayoutSize oldLayoutDelta = view().frameView().layoutContext().layoutDelta();
+        LayoutSize oldLayoutDelta = view().frameView().layoutContext().layoutDelta();
 #endif
 
-    // Fieldsets need to find their legend and position it inside the border of the object.
-    // The legend then gets skipped during normal layout. The same is true for ruby text.
-    // It doesn't get included in the normal layout process but is instead skipped.
-    layoutExcludedChildren(relayoutChildren);
+        // Fieldsets need to find their legend and position it inside the border of the object.
+        // The legend then gets skipped during normal layout. The same is true for ruby text.
+        // It doesn't get included in the normal layout process but is instead skipped.
+        layoutExcludedChildren(relayoutChildren);
 
-    ChildFrameRects oldChildRects;
-    appendChildFrameRects(this, oldChildRects);
+        ChildFrameRects oldChildRects;
+        appendChildFrameRects(this, oldChildRects);
 
-    if (isHorizontal())
-        layoutHorizontalBox(relayoutChildren);
-    else
-        layoutVerticalBox(relayoutChildren);
-
-    repaintChildrenDuringLayoutIfMoved(this, oldChildRects);
-    ASSERT(view().frameView().layoutContext().layoutDeltaMatches(oldLayoutDelta));
+        if (isHorizontal())
+            layoutHorizontalBox(relayoutChildren);
+        else
+            layoutVerticalBox(relayoutChildren);
 
-    LayoutUnit oldClientAfterEdge = clientLogicalBottom();
-    updateLogicalHeight();
+        repaintChildrenDuringLayoutIfMoved(this, oldChildRects);
+        ASSERT(view().frameView().layoutContext().layoutDeltaMatches(oldLayoutDelta));
 
-    if (previousSize.height() != height())
-        relayoutChildren = true;
+        LayoutUnit oldClientAfterEdge = clientLogicalBottom();
+        updateLogicalHeight();
 
-    layoutPositionedObjects(relayoutChildren || isDocumentElementRenderer());
+        if (previousSize.height() != height())
+            relayoutChildren = true;
 
-    computeOverflow(oldClientAfterEdge);
+        layoutPositionedObjects(relayoutChildren || isDocumentElementRenderer());
 
-    statePusher.pop();
+        computeOverflow(oldClientAfterEdge);
+    }
 
     updateLayerTransform();
 
-    if (view().frameView().layoutContext().layoutState()->pageLogicalHeight())
-        setPageLogicalOffset(view().frameView().layoutContext().layoutState()->pageLogicalOffset(this, logicalTop()));
+    auto* layoutState = view().frameView().layoutContext().layoutState();
+    if (layoutState && layoutState->pageLogicalHeight())
+        setPageLogicalOffset(layoutState->pageLogicalOffset(this, logicalTop()));
 
     // Update our scrollbars if we're overflow:auto/scroll/hidden now that we know if
     // we overflow or not.
index ad05445..000a089 100644 (file)
@@ -464,8 +464,6 @@ void RenderEmbeddedObject::layout()
     childBox.setNeedsLayout(MarkOnlyThis);
     childBox.layout();
     clearChildNeedsLayout();
-    
-    statePusher.pop();
 }
 
 bool RenderEmbeddedObject::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
index 73fccf1..4d6ad75 100644 (file)
@@ -275,48 +275,46 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit)
 
     LayoutUnit previousHeight = logicalHeight();
     setLogicalHeight(borderAndPaddingLogicalHeight() + scrollbarLogicalHeight());
+    {
+        LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
 
-    LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
-
-    preparePaginationBeforeBlockLayout(relayoutChildren);
-
-    m_numberOfInFlowChildrenOnFirstLine = -1;
+        preparePaginationBeforeBlockLayout(relayoutChildren);
 
-    beginUpdateScrollInfoAfterLayoutTransaction();
+        m_numberOfInFlowChildrenOnFirstLine = -1;
 
-    prepareOrderIteratorAndMargins();
+        beginUpdateScrollInfoAfterLayoutTransaction();
 
-    // Fieldsets need to find their legend and position it inside the border of the object.
-    // The legend then gets skipped during normal layout. The same is true for ruby text.
-    // It doesn't get included in the normal layout process but is instead skipped.
-    layoutExcludedChildren(relayoutChildren);
+        prepareOrderIteratorAndMargins();
 
-    ChildFrameRects oldChildRects;
-    appendChildFrameRects(oldChildRects);
+        // Fieldsets need to find their legend and position it inside the border of the object.
+        // The legend then gets skipped during normal layout. The same is true for ruby text.
+        // It doesn't get included in the normal layout process but is instead skipped.
+        layoutExcludedChildren(relayoutChildren);
 
-    layoutFlexItems(relayoutChildren);
+        ChildFrameRects oldChildRects;
+        appendChildFrameRects(oldChildRects);
 
-    endAndCommitUpdateScrollInfoAfterLayoutTransaction();
+        layoutFlexItems(relayoutChildren);
 
-    if (logicalHeight() != previousHeight)
-        relayoutChildren = true;
+        endAndCommitUpdateScrollInfoAfterLayoutTransaction();
 
-    layoutPositionedObjects(relayoutChildren || isDocumentElementRenderer());
+        if (logicalHeight() != previousHeight)
+            relayoutChildren = true;
 
-    repaintChildrenDuringLayoutIfMoved(oldChildRects);
-    // FIXME: css3/flexbox/repaint-rtl-column.html seems to repaint more overflow than it needs to.
-    computeOverflow(clientLogicalBottomAfterRepositioning());
-    statePusher.pop();
+        layoutPositionedObjects(relayoutChildren || isDocumentElementRenderer());
 
+        repaintChildrenDuringLayoutIfMoved(oldChildRects);
+        // FIXME: css3/flexbox/repaint-rtl-column.html seems to repaint more overflow than it needs to.
+        computeOverflow(clientLogicalBottomAfterRepositioning());
+    }
     updateLayerTransform();
-    
+
     // We have to reset this, because changes to our ancestors' style can affect
     // this value. Also, this needs to be before we call updateAfterLayout, as
     // that function may re-enter this one.
     m_hasDefiniteHeight = SizeDefiniteness::Unknown;
 
-    // Update our scroll information if we're overflow:auto/scroll/hidden now that we know if
-    // we overflow or not.
+    // Update our scroll information if we're overflow:auto/scroll/hidden now that we know if we overflow or not.
     updateScrollInfoAfterLayout();
 
     repainter.repaintAfterLayout();
index a4cf76d..9a681fb 100644 (file)
@@ -233,92 +233,93 @@ void RenderGrid::layoutBlock(bool relayoutChildren, LayoutUnit)
         return;
 
     LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
-    LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
+    {
+        LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
+
+        preparePaginationBeforeBlockLayout(relayoutChildren);
+
+        LayoutSize previousSize = size();
+        // FIXME: We should use RenderBlock::hasDefiniteLogicalHeight() but it does not work for positioned stuff.
+        // FIXME: Consider caching the hasDefiniteLogicalHeight value throughout the layout.
+        bool hasDefiniteLogicalHeight = hasOverrideLogicalContentHeight() || computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), std::nullopt);
+
+        // We need to clear both own and containingBlock override sizes of orthogonal items to ensure we get the
+        // same result when grid's intrinsic size is computed again in the updateLogicalWidth call bellow.
+        if (sizesLogicalWidthToFitContent(MaxSize) || style().logicalWidth().isIntrinsicOrAuto()) {
+            for (auto* child = firstChildBox(); child; child = child->nextSiblingBox()) {
+                if (child->isOutOfFlowPositioned() || !isOrthogonalChild(*child))
+                    continue;
+                child->clearOverrideSize();
+                child->clearContainingBlockOverrideSize();
+                child->setNeedsLayout();
+                child->layoutIfNeeded();
+            }
+        }
 
-    preparePaginationBeforeBlockLayout(relayoutChildren);
+        setLogicalHeight(0);
+        updateLogicalWidth();
 
-    LayoutSize previousSize = size();
-    // FIXME: We should use RenderBlock::hasDefiniteLogicalHeight() but it does not work for positioned stuff.
-    // FIXME: Consider caching the hasDefiniteLogicalHeight value throughout the layout.
-    bool hasDefiniteLogicalHeight = hasOverrideLogicalContentHeight() || computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), std::nullopt);
+        // Fieldsets need to find their legend and position it inside the border of the object.
+        // The legend then gets skipped during normal layout. The same is true for ruby text.
+        // It doesn't get included in the normal layout process but is instead skipped.
+        layoutExcludedChildren(relayoutChildren);
 
-    // We need to clear both own and containingBlock override sizes of orthogonal items to ensure we get the
-    // same result when grid's intrinsic size is computed again in the updateLogicalWidth call bellow.
-    if (sizesLogicalWidthToFitContent(MaxSize) || style().logicalWidth().isIntrinsicOrAuto()) {
-        for (auto* child = firstChildBox(); child; child = child->nextSiblingBox()) {
-            if (child->isOutOfFlowPositioned() || !isOrthogonalChild(*child))
-                continue;
-            child->clearOverrideSize();
-            child->clearContainingBlockOverrideSize();
-            child->setNeedsLayout();
-            child->layoutIfNeeded();
-        }
-    }
+        LayoutUnit availableSpaceForColumns = availableLogicalWidth();
+        placeItemsOnGrid(m_grid, availableSpaceForColumns);
 
-    setLogicalHeight(0);
-    updateLogicalWidth();
-
-    // Fieldsets need to find their legend and position it inside the border of the object.
-    // The legend then gets skipped during normal layout. The same is true for ruby text.
-    // It doesn't get included in the normal layout process but is instead skipped.
-    layoutExcludedChildren(relayoutChildren);
-
-    LayoutUnit availableSpaceForColumns = availableLogicalWidth();
-    placeItemsOnGrid(m_grid, availableSpaceForColumns);
-
-    // At this point the logical width is always definite as the above call to updateLogicalWidth()
-    // properly resolves intrinsic sizes. We cannot do the same for heights though because many code
-    // paths inside updateLogicalHeight() require a previous call to setLogicalHeight() to resolve
-    // heights properly (like for positioned items for example).
-    computeTrackSizesForDefiniteSize(ForColumns, availableSpaceForColumns);
-
-    if (!hasDefiniteLogicalHeight) {
-        m_minContentHeight = LayoutUnit();
-        m_maxContentHeight = LayoutUnit();
-        computeTrackSizesForIndefiniteSize(m_trackSizingAlgorithm, ForRows, m_grid, *m_minContentHeight, *m_maxContentHeight);
-        // FIXME: This should be really added to the intrinsic height in RenderBox::computeContentAndScrollbarLogicalHeightUsing().
-        // Remove this when that is fixed.
-        ASSERT(m_minContentHeight);
-        ASSERT(m_maxContentHeight);
-        LayoutUnit scrollbarHeight = scrollbarLogicalHeight();
-        *m_minContentHeight += scrollbarHeight;
-        *m_maxContentHeight += scrollbarHeight;
-    } else
-        computeTrackSizesForDefiniteSize(ForRows, availableLogicalHeight(ExcludeMarginBorderPadding));
-    LayoutUnit trackBasedLogicalHeight = computeTrackBasedLogicalHeight() + borderAndPaddingLogicalHeight() + scrollbarLogicalHeight();
-    setLogicalHeight(trackBasedLogicalHeight);
-
-    LayoutUnit oldClientAfterEdge = clientLogicalBottom();
-    updateLogicalHeight();
-
-    // Once grid's indefinite height is resolved, we can compute the
-    // available free space for Content Alignment.
-    if (!hasDefiniteLogicalHeight)
-        m_trackSizingAlgorithm.setFreeSpace(ForRows, logicalHeight() - trackBasedLogicalHeight);
-
-    // 3- If the min-content contribution of any grid items have changed based on the row
-    // sizes calculated in step 2, steps 1 and 2 are repeated with the new min-content
-    // contribution (once only).
-    repeatTracksSizingIfNeeded(availableSpaceForColumns, contentLogicalHeight());
-
-    // Grid container should have the minimum height of a line if it's editable. That does not affect track sizing though.
-    if (hasLineIfEmpty()) {
-        LayoutUnit minHeightForEmptyLine = borderAndPaddingLogicalHeight()
-            + lineHeight(true, isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes)
-            + scrollbarLogicalHeight();
-        setLogicalHeight(std::max(logicalHeight(), minHeightForEmptyLine));
-    }
+        // At this point the logical width is always definite as the above call to updateLogicalWidth()
+        // properly resolves intrinsic sizes. We cannot do the same for heights though because many code
+        // paths inside updateLogicalHeight() require a previous call to setLogicalHeight() to resolve
+        // heights properly (like for positioned items for example).
+        computeTrackSizesForDefiniteSize(ForColumns, availableSpaceForColumns);
 
-    layoutGridItems();
-    m_trackSizingAlgorithm.reset();
+        if (!hasDefiniteLogicalHeight) {
+            m_minContentHeight = LayoutUnit();
+            m_maxContentHeight = LayoutUnit();
+            computeTrackSizesForIndefiniteSize(m_trackSizingAlgorithm, ForRows, m_grid, *m_minContentHeight, *m_maxContentHeight);
+            // FIXME: This should be really added to the intrinsic height in RenderBox::computeContentAndScrollbarLogicalHeightUsing().
+            // Remove this when that is fixed.
+            ASSERT(m_minContentHeight);
+            ASSERT(m_maxContentHeight);
+            LayoutUnit scrollbarHeight = scrollbarLogicalHeight();
+            *m_minContentHeight += scrollbarHeight;
+            *m_maxContentHeight += scrollbarHeight;
+        } else
+            computeTrackSizesForDefiniteSize(ForRows, availableLogicalHeight(ExcludeMarginBorderPadding));
+        LayoutUnit trackBasedLogicalHeight = computeTrackBasedLogicalHeight() + borderAndPaddingLogicalHeight() + scrollbarLogicalHeight();
+        setLogicalHeight(trackBasedLogicalHeight);
+
+        LayoutUnit oldClientAfterEdge = clientLogicalBottom();
+        updateLogicalHeight();
+
+        // Once grid's indefinite height is resolved, we can compute the
+        // available free space for Content Alignment.
+        if (!hasDefiniteLogicalHeight)
+            m_trackSizingAlgorithm.setFreeSpace(ForRows, logicalHeight() - trackBasedLogicalHeight);
+
+        // 3- If the min-content contribution of any grid items have changed based on the row
+        // sizes calculated in step 2, steps 1 and 2 are repeated with the new min-content
+        // contribution (once only).
+        repeatTracksSizingIfNeeded(availableSpaceForColumns, contentLogicalHeight());
+
+        // Grid container should have the minimum height of a line if it's editable. That does not affect track sizing though.
+        if (hasLineIfEmpty()) {
+            LayoutUnit minHeightForEmptyLine = borderAndPaddingLogicalHeight()
+                + lineHeight(true, isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes)
+                + scrollbarLogicalHeight();
+            setLogicalHeight(std::max(logicalHeight(), minHeightForEmptyLine));
+        }
 
-    if (size() != previousSize)
-        relayoutChildren = true;
+        layoutGridItems();
+        m_trackSizingAlgorithm.reset();
 
-    layoutPositionedObjects(relayoutChildren || isDocumentElementRenderer());
+        if (size() != previousSize)
+            relayoutChildren = true;
 
-    computeOverflow(oldClientAfterEdge);
-    statePusher.pop();
+        layoutPositionedObjects(relayoutChildren || isDocumentElementRenderer());
+
+        computeOverflow(oldClientAfterEdge);
+    }
 
     updateLayerTransform();
 
index 2ae3ce2..f34ed10 100644 (file)
@@ -746,8 +746,6 @@ void RenderImage::layoutShadowControls(const LayoutSize& oldSize)
     controlsRenderer->setNeedsLayout(MarkOnlyThis);
     controlsRenderer->layout();
     clearChildNeedsLayout();
-
-    statePusher.pop();
 }
 
 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const
index ae1f161..b23e162 100644 (file)
@@ -449,140 +449,139 @@ void RenderTable::layout()
     // FIXME: We should do this recalc lazily in borderStart/borderEnd so that we don't have to make sure
     // to call this before we call borderStart/borderEnd to avoid getting a stale value.
     recalcBordersInRowDirection();
+    bool sectionMoved = false;
+    LayoutUnit movedSectionLogicalTop = 0;
 
     LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
-    LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
+    {
+        LayoutStateMaintainer statePusher(*this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
 
-    LayoutUnit oldLogicalWidth = logicalWidth();
-    LayoutUnit oldLogicalHeight = logicalHeight();
-    setLogicalHeight(0);
-    updateLogicalWidth();
+        LayoutUnit oldLogicalWidth = logicalWidth();
+        LayoutUnit oldLogicalHeight = logicalHeight();
+        setLogicalHeight(0);
+        updateLogicalWidth();
 
-    if (logicalWidth() != oldLogicalWidth) {
-        for (unsigned i = 0; i < m_captions.size(); i++)
-            m_captions[i]->setNeedsLayout(MarkOnlyThis);
-    }
-    // FIXME: The optimisation below doesn't work since the internal table
-    // layout could have changed.  we need to add a flag to the table
-    // layout that tells us if something has changed in the min max
-    // calculations to do it correctly.
-//     if ( oldWidth != width() || columns.size() + 1 != columnPos.size() )
-    m_tableLayout->layout();
-
-    LayoutUnit totalSectionLogicalHeight = 0;
-    LayoutUnit oldTableLogicalTop = 0;
-    for (unsigned i = 0; i < m_captions.size(); i++) {
-        if (m_captions[i]->style().captionSide() == CAPBOTTOM)
-            continue;
-        oldTableLogicalTop += m_captions[i]->logicalHeight() + m_captions[i]->marginBefore() + m_captions[i]->marginAfter();
-    }
-
-    bool collapsing = collapseBorders();
-
-    for (auto& child : childrenOfType<RenderElement>(*this)) {
-        if (is<RenderTableSection>(child)) {
-            RenderTableSection& section = downcast<RenderTableSection>(child);
-            if (m_columnLogicalWidthChanged)
-                section.setChildNeedsLayout(MarkOnlyThis);
-            section.layoutIfNeeded();
-            totalSectionLogicalHeight += section.calcRowLogicalHeight();
-            if (collapsing)
-                section.recalcOuterBorder();
-            ASSERT(!section.needsLayout());
-        } else if (is<RenderTableCol>(child)) {
-            downcast<RenderTableCol>(child).layoutIfNeeded();
-            ASSERT(!child.needsLayout());
+        if (logicalWidth() != oldLogicalWidth) {
+            for (unsigned i = 0; i < m_captions.size(); i++)
+                m_captions[i]->setNeedsLayout(MarkOnlyThis);
+        }
+        // FIXME: The optimisation below doesn't work since the internal table
+        // layout could have changed. We need to add a flag to the table
+        // layout that tells us if something has changed in the min max
+        // calculations to do it correctly.
+        //     if ( oldWidth != width() || columns.size() + 1 != columnPos.size() )
+        m_tableLayout->layout();
+
+        LayoutUnit totalSectionLogicalHeight = 0;
+        LayoutUnit oldTableLogicalTop = 0;
+        for (unsigned i = 0; i < m_captions.size(); i++) {
+            if (m_captions[i]->style().captionSide() == CAPBOTTOM)
+                continue;
+            oldTableLogicalTop += m_captions[i]->logicalHeight() + m_captions[i]->marginBefore() + m_captions[i]->marginAfter();
         }
-    }
 
-    // If any table section moved vertically, we will just repaint everything from that
-    // section down (it is quite unlikely that any of the following sections
-    // did not shift).
-    bool sectionMoved = false;
-    LayoutUnit movedSectionLogicalTop = 0;
+        bool collapsing = collapseBorders();
+
+        for (auto& child : childrenOfType<RenderElement>(*this)) {
+            if (is<RenderTableSection>(child)) {
+                RenderTableSection& section = downcast<RenderTableSection>(child);
+                if (m_columnLogicalWidthChanged)
+                    section.setChildNeedsLayout(MarkOnlyThis);
+                section.layoutIfNeeded();
+                totalSectionLogicalHeight += section.calcRowLogicalHeight();
+                if (collapsing)
+                    section.recalcOuterBorder();
+                ASSERT(!section.needsLayout());
+            } else if (is<RenderTableCol>(child)) {
+                downcast<RenderTableCol>(child).layoutIfNeeded();
+                ASSERT(!child.needsLayout());
+            }
+        }
 
-    layoutCaptions();
-    if (!m_captions.isEmpty() && logicalHeight() != oldTableLogicalTop) {
-        sectionMoved = true;
-        movedSectionLogicalTop = std::min(logicalHeight(), oldTableLogicalTop);
-    }
+        // If any table section moved vertically, we will just repaint everything from that
+        // section down (it is quite unlikely that any of the following sections
+        // did not shift).
+        layoutCaptions();
+        if (!m_captions.isEmpty() && logicalHeight() != oldTableLogicalTop) {
+            sectionMoved = true;
+            movedSectionLogicalTop = std::min(logicalHeight(), oldTableLogicalTop);
+        }
 
-    LayoutUnit borderAndPaddingBefore = borderBefore() + (collapsing ? LayoutUnit() : paddingBefore());
-    LayoutUnit borderAndPaddingAfter = borderAfter() + (collapsing ? LayoutUnit() : paddingAfter());
+        LayoutUnit borderAndPaddingBefore = borderBefore() + (collapsing ? LayoutUnit() : paddingBefore());
+        LayoutUnit borderAndPaddingAfter = borderAfter() + (collapsing ? LayoutUnit() : paddingAfter());
 
-    setLogicalHeight(logicalHeight() + borderAndPaddingBefore);
+        setLogicalHeight(logicalHeight() + borderAndPaddingBefore);
 
-    if (!isOutOfFlowPositioned())
-        updateLogicalHeight();
+        if (!isOutOfFlowPositioned())
+            updateLogicalHeight();
 
-    LayoutUnit computedLogicalHeight = 0;
-    
-    Length logicalHeightLength = style().logicalHeight();
-    if (logicalHeightLength.isIntrinsic() || (logicalHeightLength.isSpecified() && logicalHeightLength.isPositive()))
-        computedLogicalHeight = convertStyleLogicalHeightToComputedHeight(logicalHeightLength);
+        LayoutUnit computedLogicalHeight = 0;
     
-    Length logicalMaxHeightLength = style().logicalMaxHeight();
-    if (logicalMaxHeightLength.isIntrinsic() || (logicalMaxHeightLength.isSpecified() && !logicalMaxHeightLength.isNegative())) {
-        LayoutUnit computedMaxLogicalHeight = convertStyleLogicalHeightToComputedHeight(logicalMaxHeightLength);
-        computedLogicalHeight = std::min(computedLogicalHeight, computedMaxLogicalHeight);
-    }
-
-    Length logicalMinHeightLength = style().logicalMinHeight();
-    if (logicalMinHeightLength.isIntrinsic() || (logicalMinHeightLength.isSpecified() && !logicalMinHeightLength.isNegative())) {
-        LayoutUnit computedMinLogicalHeight = convertStyleLogicalHeightToComputedHeight(logicalMinHeightLength);
-        computedLogicalHeight = std::max(computedLogicalHeight, computedMinLogicalHeight);
-    }
-
-    distributeExtraLogicalHeight(computedLogicalHeight - totalSectionLogicalHeight);
+        Length logicalHeightLength = style().logicalHeight();
+        if (logicalHeightLength.isIntrinsic() || (logicalHeightLength.isSpecified() && logicalHeightLength.isPositive()))
+            computedLogicalHeight = convertStyleLogicalHeightToComputedHeight(logicalHeightLength);
+
+        Length logicalMaxHeightLength = style().logicalMaxHeight();
+        if (logicalMaxHeightLength.isIntrinsic() || (logicalMaxHeightLength.isSpecified() && !logicalMaxHeightLength.isNegative())) {
+            LayoutUnit computedMaxLogicalHeight = convertStyleLogicalHeightToComputedHeight(logicalMaxHeightLength);
+            computedLogicalHeight = std::min(computedLogicalHeight, computedMaxLogicalHeight);
+        }
 
-    for (RenderTableSection* section = topSection(); section; section = sectionBelow(section))
-        section->layoutRows();
+        Length logicalMinHeightLength = style().logicalMinHeight();
+        if (logicalMinHeightLength.isIntrinsic() || (logicalMinHeightLength.isSpecified() && !logicalMinHeightLength.isNegative())) {
+            LayoutUnit computedMinLogicalHeight = convertStyleLogicalHeightToComputedHeight(logicalMinHeightLength);
+            computedLogicalHeight = std::max(computedLogicalHeight, computedMinLogicalHeight);
+        }
 
-    if (!topSection() && computedLogicalHeight > totalSectionLogicalHeight && !document().inQuirksMode()) {
-        // Completely empty tables (with no sections or anything) should at least honor specified height
-        // in strict mode.
-        setLogicalHeight(logicalHeight() + computedLogicalHeight);
-    }
+        distributeExtraLogicalHeight(computedLogicalHeight - totalSectionLogicalHeight);
 
-    LayoutUnit sectionLogicalLeft = style().isLeftToRightDirection() ? borderStart() : borderEnd();
-    if (!collapsing)
-        sectionLogicalLeft += style().isLeftToRightDirection() ? paddingStart() : paddingEnd();
+        for (RenderTableSection* section = topSection(); section; section = sectionBelow(section))
+            section->layoutRows();
 
-    // position the table sections
-    RenderTableSection* section = topSection();
-    while (section) {
-        if (!sectionMoved && section->logicalTop() != logicalHeight()) {
-            sectionMoved = true;
-            movedSectionLogicalTop = std::min(logicalHeight(), section->logicalTop()) + (style().isHorizontalWritingMode() ? section->visualOverflowRect().y() : section->visualOverflowRect().x());
+        if (!topSection() && computedLogicalHeight > totalSectionLogicalHeight && !document().inQuirksMode()) {
+            // Completely empty tables (with no sections or anything) should at least honor specified height
+            // in strict mode.
+            setLogicalHeight(logicalHeight() + computedLogicalHeight);
         }
-        section->setLogicalLocation(LayoutPoint(sectionLogicalLeft, logicalHeight()));
 
-        setLogicalHeight(logicalHeight() + section->logicalHeight());
-        section = sectionBelow(section);
-    }
+        LayoutUnit sectionLogicalLeft = style().isLeftToRightDirection() ? borderStart() : borderEnd();
+        if (!collapsing)
+            sectionLogicalLeft += style().isLeftToRightDirection() ? paddingStart() : paddingEnd();
 
-    setLogicalHeight(logicalHeight() + borderAndPaddingAfter);
+        // position the table sections
+        RenderTableSection* section = topSection();
+        while (section) {
+            if (!sectionMoved && section->logicalTop() != logicalHeight()) {
+                sectionMoved = true;
+                movedSectionLogicalTop = std::min(logicalHeight(), section->logicalTop()) + (style().isHorizontalWritingMode() ? section->visualOverflowRect().y() : section->visualOverflowRect().x());
+            }
+            section->setLogicalLocation(LayoutPoint(sectionLogicalLeft, logicalHeight()));
 
-    layoutCaptions(BottomCaptionLayoutPhase::Yes);
+            setLogicalHeight(logicalHeight() + section->logicalHeight());
+            section = sectionBelow(section);
+        }
+
+        setLogicalHeight(logicalHeight() + borderAndPaddingAfter);
 
-    if (isOutOfFlowPositioned())
-        updateLogicalHeight();
+        layoutCaptions(BottomCaptionLayoutPhase::Yes);
 
-    // table can be containing block of positioned elements.
-    bool dimensionChanged = oldLogicalWidth != logicalWidth() || oldLogicalHeight != logicalHeight();
-    layoutPositionedObjects(dimensionChanged);
+        if (isOutOfFlowPositioned())
+            updateLogicalHeight();
 
-    updateLayerTransform();
+        // table can be containing block of positioned elements.
+        bool dimensionChanged = oldLogicalWidth != logicalWidth() || oldLogicalHeight != logicalHeight();
+        layoutPositionedObjects(dimensionChanged);
 
-    // Layout was changed, so probably borders too.
-    invalidateCollapsedBorders();
+        updateLayerTransform();
 
-    // The location or height of one or more sections may have changed.
-    invalidateCachedColumnOffsets();
+        // Layout was changed, so probably borders too.
+        invalidateCollapsedBorders();
 
-    computeOverflow(clientLogicalBottom());
+        // The location or height of one or more sections may have changed.
+        invalidateCachedColumnOffsets();
 
-    statePusher.pop();
+        computeOverflow(clientLogicalBottom());
+    }
 
     auto* layoutState = view().frameView().layoutContext().layoutState();
     if (layoutState->pageLogicalHeight())
index 4d49b9f..2a74f68 100644 (file)
@@ -207,7 +207,6 @@ void RenderTableRow::layout()
             cell->repaint();
     }
 
-    statePusher.pop();
     // RenderTableSection::layoutRows will set our logical height and width later, so it calls updateLayerTransform().
     clearNeedsLayout();
 }
index faac5b5..c4ca554 100644 (file)
@@ -372,8 +372,6 @@ LayoutUnit RenderTableSection::calcRowLogicalHeight()
 
     ASSERT(!needsLayout());
 
-    statePusher.pop();
-
     return m_rowPos[m_grid.size()];
 }
 
@@ -423,8 +421,6 @@ void RenderTableSection::layout()
             rowRenderer->layoutIfNeeded();
         }
     }
-
-    statePusher.pop();
     clearNeedsLayout();
 }
 
@@ -683,8 +679,6 @@ void RenderTableSection::layoutRows()
     setLogicalHeight(m_rowPos[totalRows]);
 
     computeOverflowFromCells(totalRows, nEffCols);
-
-    statePusher.pop();
 }
 
 void RenderTableSection::computeOverflowFromCells()
index 55c9811..cc056c9 100644 (file)
@@ -68,8 +68,6 @@ void RenderVTTCue::layout()
             repositionCueSnapToLinesNotSet();
     } else
         repositionGenericCue();
-
-    statePusher.pop();
 }
 
 bool RenderVTTCue::initializeLayoutParameters(InlineFlowBox*& firstLineBox, LayoutUnit& step, LayoutUnit& position)
index 6a822ca..67959ae 100644 (file)
@@ -239,7 +239,6 @@ void RenderView::layout()
 #ifndef NDEBUG
     frameView().layoutContext().checkLayoutState();
 #endif
-    statePusher.pop();
     clearNeedsLayout();
 }