[LayoutState cleanup] Rename enable/disableLayoutState
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2017 00:29:33 +0000 (00:29 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2017 00:29:33 +0000 (00:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179399
<rdar://problem/35400245>

Reviewed by Antti Koivisto.

It only enables/disables paint offset caching.

No change in functionality.

* page/LayoutContext.cpp:
(WebCore::LayoutContext::pushLayoutState):
(WebCore::LayoutContext::checkLayoutState):
* page/LayoutContext.h:
(WebCore::LayoutContext::isPaintOffsetCacheEnabled const):
(WebCore::LayoutContext::disablePaintOffsetCache):
(WebCore::LayoutContext::enablePaintOffsetCache):
(WebCore::LayoutContext::layoutStateEnabled const): Deleted.
(WebCore::LayoutContext::disableLayoutState): Deleted.
(WebCore::LayoutContext::enableLayoutState): Deleted.
* rendering/LayoutState.cpp:
(WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
(WebCore::LayoutStateMaintainer::push):
(WebCore::LayoutStateMaintainer::pop):
(WebCore::LayoutStateDisabler::LayoutStateDisabler):
(WebCore::LayoutStateDisabler::~LayoutStateDisabler):
(WebCore::shouldDisablePaintOffsetCacheForSubtree):
(WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
(WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
(WebCore::shouldDisableLayoutStateForSubtree): Deleted.
* rendering/LayoutState.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::mapLocalToContainer const):
(WebCore::RenderBox::computeRectForRepaint const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::clippedOverflowRectForRepaint const):
(WebCore::RenderInline::computeRectForRepaint const):
(WebCore::RenderInline::mapLocalToContainer const):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPositions):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::computeRectForRepaint const):
* rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::layout):
* rendering/svg/RenderSVGForeignObject.cpp:
(WebCore::RenderSVGForeignObject::layout):

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

Source/WebCore/ChangeLog
Source/WebCore/page/LayoutContext.cpp
Source/WebCore/page/LayoutContext.h
Source/WebCore/rendering/LayoutState.cpp
Source/WebCore/rendering/LayoutState.h
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderTableCell.cpp
Source/WebCore/rendering/svg/RenderSVGContainer.cpp
Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp

index 477901e..d00f569 100644 (file)
@@ -1,3 +1,52 @@
+2017-11-07  Zalan Bujtas  <zalan@apple.com>
+
+        [LayoutState cleanup] Rename enable/disableLayoutState
+        https://bugs.webkit.org/show_bug.cgi?id=179399
+        <rdar://problem/35400245>
+
+        Reviewed by Antti Koivisto.
+
+        It only enables/disables paint offset caching.
+
+        No change in functionality.
+
+        * page/LayoutContext.cpp:
+        (WebCore::LayoutContext::pushLayoutState):
+        (WebCore::LayoutContext::checkLayoutState):
+        * page/LayoutContext.h:
+        (WebCore::LayoutContext::isPaintOffsetCacheEnabled const):
+        (WebCore::LayoutContext::disablePaintOffsetCache):
+        (WebCore::LayoutContext::enablePaintOffsetCache):
+        (WebCore::LayoutContext::layoutStateEnabled const): Deleted.
+        (WebCore::LayoutContext::disableLayoutState): Deleted.
+        (WebCore::LayoutContext::enableLayoutState): Deleted.
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
+        (WebCore::LayoutStateMaintainer::push):
+        (WebCore::LayoutStateMaintainer::pop):
+        (WebCore::LayoutStateDisabler::LayoutStateDisabler):
+        (WebCore::LayoutStateDisabler::~LayoutStateDisabler):
+        (WebCore::shouldDisablePaintOffsetCacheForSubtree):
+        (WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
+        (WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
+        (WebCore::shouldDisableLayoutStateForSubtree): Deleted.
+        * rendering/LayoutState.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::mapLocalToContainer const):
+        (WebCore::RenderBox::computeRectForRepaint const):
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::clippedOverflowRectForRepaint const):
+        (WebCore::RenderInline::computeRectForRepaint const):
+        (WebCore::RenderInline::mapLocalToContainer const):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateLayerPositions):
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::computeRectForRepaint const):
+        * rendering/svg/RenderSVGContainer.cpp:
+        (WebCore::RenderSVGContainer::layout):
+        * rendering/svg/RenderSVGForeignObject.cpp:
+        (WebCore::RenderSVGForeignObject::layout):
+
 2017-11-07  Brady Eidson  <beidson@apple.com>
 
         Implement "UpdateWorkerState" and use it
index 7e8a1c4..df1185c 100644 (file)
@@ -558,7 +558,7 @@ bool LayoutContext::layoutDeltaMatches(const LayoutSize& delta)
     
 void LayoutContext::pushLayoutState(RenderElement& root)
 {
-    ASSERT(!m_layoutStateDisableCount);
+    ASSERT(!m_paintOffsetCacheDisableCount);
     ASSERT(!m_layoutState);
 
     m_layoutState = std::make_unique<LayoutState>(root);
@@ -600,7 +600,7 @@ void LayoutContext::popLayoutState()
 void LayoutContext::checkLayoutState()
 {
     ASSERT(layoutDeltaMatches(LayoutSize()));
-    ASSERT(!m_layoutStateDisableCount);
+    ASSERT(!m_paintOffsetCacheDisableCount);
 }
 #endif
 
index 27f444d..61a36e3 100644 (file)
@@ -94,7 +94,7 @@ public:
     void popLayoutState(RenderObject&);
     LayoutState* layoutState() const { return m_layoutState.get(); }
     // Returns true if layoutState should be used for its cached offset and clip.
-    bool layoutStateEnabled() const { return !m_layoutStateDisableCount && m_layoutState; }
+    bool isPaintOffsetCacheEnabled() const { return !m_paintOffsetCacheDisableCount && m_layoutState; }
 #ifndef NDEBUG
     void checkLayoutState();
 #endif
@@ -141,8 +141,8 @@ private:
     // that can trigger repaint of a non-child (e.g. when a list item moves its list marker around).
     // Note that even when disabled, LayoutState is still used to store layoutDelta.
     // These functions may only be accessed by LayoutStateMaintainer or LayoutStateDisabler.
-    void disableLayoutState() { m_layoutStateDisableCount++; }
-    void enableLayoutState() { ASSERT(m_layoutStateDisableCount > 0); m_layoutStateDisableCount--; }
+    void disablePaintOffsetCache() { m_paintOffsetCacheDisableCount++; }
+    void enablePaintOffsetCache() { ASSERT(m_paintOffsetCacheDisableCount > 0); m_paintOffsetCacheDisableCount--; }
 
     Frame& frame() const;
     FrameView& view() const;
@@ -167,7 +167,7 @@ private:
     int m_layoutDisallowedCount { 0 };
     WeakPtr<RenderElement> m_subtreeLayoutRoot;
     std::unique_ptr<LayoutState> m_layoutState;
-    unsigned m_layoutStateDisableCount { 0 };
+    unsigned m_paintOffsetCacheDisableCount { 0 };
 };
 
 } // namespace WebCore
index 6f58201..dd0e13d 100644 (file)
@@ -218,9 +218,9 @@ void LayoutState::establishLineGrid(RenderBlockFlow& renderer)
     m_lineGridOffset = m_layoutOffset;
 }
 
-LayoutStateMaintainer::LayoutStateMaintainer(RenderBox& root, LayoutSize offset, bool disableState, LayoutUnit pageHeight, bool pageHeightChanged)
+LayoutStateMaintainer::LayoutStateMaintainer(RenderBox& root, LayoutSize offset, bool disablePaintOffsetCache, LayoutUnit pageHeight, bool pageHeightChanged)
     : m_layoutContext(root.view().frameView().layoutContext())
-    , m_disabled(disableState)
+    , m_paintOffsetCacheIsDisabled(disablePaintOffsetCache)
 {
     push(root, offset, pageHeight, pageHeightChanged);
 }
@@ -246,8 +246,8 @@ void LayoutStateMaintainer::push(RenderBox& root, LayoutSize offset, LayoutUnit
     m_didPushLayoutState = m_layoutContext.pushLayoutState(root, offset, pageHeight, pageHeightChanged);
     if (!m_didPushLayoutState)
         return;
-    if (m_disabled)
-        m_layoutContext.disableLayoutState();
+    if (m_paintOffsetCacheIsDisabled)
+        m_layoutContext.disablePaintOffsetCache();
 }
 
 void LayoutStateMaintainer::pop()
@@ -259,22 +259,22 @@ void LayoutStateMaintainer::pop()
     if (!m_didPushLayoutState)
         return;
     m_layoutContext.popLayoutState();
-    if (m_disabled)
-        m_layoutContext.enableLayoutState();
+    if (m_paintOffsetCacheIsDisabled)
+        m_layoutContext.enablePaintOffsetCache();
 }
 
 LayoutStateDisabler::LayoutStateDisabler(LayoutContext& layoutContext)
     : m_layoutContext(layoutContext)
 {
-    m_layoutContext.disableLayoutState();
+    m_layoutContext.disablePaintOffsetCache();
 }
 
 LayoutStateDisabler::~LayoutStateDisabler()
 {
-    m_layoutContext.enableLayoutState();
+    m_layoutContext.enablePaintOffsetCache();
 }
 
-static bool shouldDisableLayoutStateForSubtree(RenderElement& subtreeLayoutRoot)
+static bool shouldDisablePaintOffsetCacheForSubtree(RenderElement& subtreeLayoutRoot)
 {
     for (auto* renderer = &subtreeLayoutRoot; renderer; renderer = renderer->container()) {
         if (renderer->hasTransform() || renderer->hasReflection())
@@ -289,9 +289,9 @@ SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer(RenderElement* subtre
     if (m_subtreeLayoutRoot) {
         auto& layoutContext = m_subtreeLayoutRoot->view().frameView().layoutContext();
         layoutContext.pushLayoutState(*m_subtreeLayoutRoot);
-        if (shouldDisableLayoutStateForSubtree(*m_subtreeLayoutRoot)) {
-            layoutContext.disableLayoutState();
-            m_didDisableLayoutState = true;
+        if (shouldDisablePaintOffsetCacheForSubtree(*m_subtreeLayoutRoot)) {
+            layoutContext.disablePaintOffsetCache();
+            m_didDisablePaintOffsetCache = true;
         }
     }
 }
@@ -301,8 +301,8 @@ SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer()
     if (m_subtreeLayoutRoot) {
         auto& layoutContext = m_subtreeLayoutRoot->view().frameView().layoutContext();
         layoutContext.popLayoutState(*m_subtreeLayoutRoot);
-        if (m_didDisableLayoutState)
-            layoutContext.enableLayoutState();
+        if (m_didDisablePaintOffsetCache)
+            layoutContext.enablePaintOffsetCache();
     }
 }
 
index b4549e5..1dbb15b 100644 (file)
@@ -143,7 +143,7 @@ public:
 
 private:
     LayoutContext& m_layoutContext;
-    bool m_disabled { false };
+    bool m_paintOffsetCacheIsDisabled { false };
     bool m_didCallPush { false };
     bool m_didCallPop { false };
     bool m_didPushLayoutState { false };
@@ -156,7 +156,7 @@ public:
 
 private:
     RenderElement* m_subtreeLayoutRoot { nullptr };
-    bool m_didDisableLayoutState { false };
+    bool m_didDisablePaintOffsetCache { false };
 };
 
 class LayoutStateDisabler {
index 1fa66d0..23cff72 100644 (file)
@@ -1924,7 +1924,7 @@ void RenderBox::mapLocalToContainer(const RenderLayerModelObject* repaintContain
     if (repaintContainer == this)
         return;
 
-    if (view().frameView().layoutContext().layoutStateEnabled() && !repaintContainer) {
+    if (view().frameView().layoutContext().isPaintOffsetCacheEnabled() && !repaintContainer) {
         auto* layoutState = view().frameView().layoutContext().layoutState();
         LayoutSize offset = layoutState->m_paintOffset + locationOffset();
         if (style().hasInFlowPosition() && layer())
@@ -2139,8 +2139,8 @@ LayoutRect RenderBox::computeRectForRepaint(const LayoutRect& rect, const Render
     // physical coordinate space of the repaintContainer.
     LayoutRect adjustedRect = rect;
     const RenderStyle& styleToUse = style();
-    // LayoutState is only valid for root-relative, non-fixed position repainting
-    if (view().frameView().layoutContext().layoutStateEnabled() && !repaintContainer && styleToUse.position() != FixedPosition) {
+    // Paint offset cache is only valid for root-relative, non-fixed position repainting
+    if (view().frameView().layoutContext().isPaintOffsetCacheEnabled() && !repaintContainer && styleToUse.position() != FixedPosition) {
         auto* layoutState = view().frameView().layoutContext().layoutState();
 
         if (layer() && layer()->transform())
index 1e48971..ace2605 100644 (file)
@@ -1165,7 +1165,7 @@ LayoutRect RenderInline::linesVisualOverflowBoundingBoxInFragment(const RenderFr
 LayoutRect RenderInline::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
 {
     // Only first-letter renderers are allowed in here during layout. They mutate the tree triggering repaints.
-    ASSERT(!view().frameView().layoutContext().layoutStateEnabled() || style().styleType() == FIRST_LETTER || hasSelfPaintingLayer());
+    ASSERT(!view().frameView().layoutContext().isPaintOffsetCacheEnabled() || style().styleType() == FIRST_LETTER || hasSelfPaintingLayer());
 
     if (!firstLineBoxIncludingCulling() && !continuation())
         return LayoutRect();
@@ -1220,9 +1220,9 @@ LayoutRect RenderInline::rectWithOutlineForRepaint(const RenderLayerModelObject*
 
 LayoutRect RenderInline::computeRectForRepaint(const LayoutRect& rect, const RenderLayerModelObject* repaintContainer, RepaintContext context) const
 {
-    // LayoutState is only valid for root-relative repainting
+    // Repaint offset cache is only valid for root-relative repainting
     LayoutRect adjustedRect = rect;
-    if (view().frameView().layoutContext().layoutStateEnabled() && !repaintContainer) {
+    if (view().frameView().layoutContext().isPaintOffsetCacheEnabled() && !repaintContainer) {
         auto* layoutState = view().frameView().layoutContext().layoutState();
         if (style().hasInFlowPosition() && layer())
             adjustedRect.move(layer()->offsetForInFlowPosition());
@@ -1290,7 +1290,7 @@ void RenderInline::mapLocalToContainer(const RenderLayerModelObject* repaintCont
     if (repaintContainer == this)
         return;
 
-    if (view().frameView().layoutContext().layoutStateEnabled() && !repaintContainer) {
+    if (view().frameView().layoutContext().isPaintOffsetCacheEnabled() && !repaintContainer) {
         auto* layoutState = view().frameView().layoutContext().layoutState();
         LayoutSize offset = layoutState->m_paintOffset;
         if (style().hasInFlowPosition() && layer())
index 501fca8..697cf05 100644 (file)
@@ -514,10 +514,10 @@ void RenderLayer::updateLayerPositions(RenderGeometryMap* geometryMap, UpdateLay
         m_enclosingPaginationLayer = nullptr;
     
     if (m_hasVisibleContent) {
-        // FIXME: LayoutState does not work with RenderLayers as there is not a 1-to-1
+        // FIXME: Paint offset cache does not work with RenderLayers as there is not a 1-to-1
         // mapping between them and the RenderObjects. It would be neat to enable
         // LayoutState outside the layout() phase and use it here.
-        ASSERT(!renderer().view().frameView().layoutContext().layoutStateEnabled());
+        ASSERT(!renderer().view().frameView().layoutContext().isPaintOffsetCacheEnabled());
 
         RenderLayerModelObject* repaintContainer = renderer().containerForRepaint();
         
index 28e7639..243ae60 100644 (file)
@@ -398,7 +398,7 @@ LayoutRect RenderTableCell::computeRectForRepaint(const LayoutRect& rect, const
     if (repaintContainer == this)
         return rect;
     LayoutRect adjustedRect = rect;
-    if ((!view().frameView().layoutContext().layoutStateEnabled() || repaintContainer) && parent())
+    if ((!view().frameView().layoutContext().isPaintOffsetCacheEnabled() || repaintContainer) && parent())
         adjustedRect.moveBy(-parentBox()->location()); // Rows are in the same coordinate space, so don't add their offset in.
     return RenderBlockFlow::computeRectForRepaint(adjustedRect, repaintContainer, context);
 }
index 9b1dffd..814361f 100644 (file)
@@ -55,8 +55,8 @@ void RenderSVGContainer::layout()
     StackStats::LayoutCheckPoint layoutCheckPoint;
     ASSERT(needsLayout());
 
-    // RenderSVGRoot disables layoutState for the SVG rendering tree.
-    ASSERT(!view().frameView().layoutContext().layoutStateEnabled());
+    // RenderSVGRoot disables paint offset cache for the SVG rendering tree.
+    ASSERT(!view().frameView().layoutContext().isPaintOffsetCacheEnabled());
 
     LayoutRepainter repainter(*this, SVGRenderSupport::checkForSVGRepaintDuringLayout(*this) || selfWillPaint());
 
index f0724a9..b997bb9 100644 (file)
@@ -134,7 +134,7 @@ void RenderSVGForeignObject::layout()
 {
     StackStats::LayoutCheckPoint layoutCheckPoint;
     ASSERT(needsLayout());
-    ASSERT(!view().frameView().layoutContext().layoutStateEnabled()); // RenderSVGRoot disables layoutState for the SVG rendering tree.
+    ASSERT(!view().frameView().layoutContext().isPaintOffsetCacheEnabled()); // RenderSVGRoot disables paint offset cache for the SVG rendering tree.
 
     LayoutRepainter repainter(*this, SVGRenderSupport::checkForSVGRepaintDuringLayout(*this));