LayoutState and subtree layout code should use RenderElement.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 00:39:36 +0000 (00:39 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 00:39:36 +0000 (00:39 +0000)
<https://webkit.org/b/126878>

Subtree layout will never begin at a RenderText, so tighten up
the code to operate on RenderElements instead of RenderObjects.

Reviewed by Antti Koivisto.

* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::willLayout):
* page/FrameView.cpp:
(WebCore::FrameView::layoutRoot):
(WebCore::FrameView::layout):
* page/FrameView.h:

    Make FrameView::layoutRoot() return RenderElement*.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::willBeDestroyed):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::willBeDestroyed):
* rendering/RenderObject.h:

    Move subtree layout root clearing logic in willBeDestroyed()
    from RenderObject to RenderElement.

* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
* rendering/LayoutState.h:
* rendering/RenderView.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::pushLayoutState):
(WebCore::RenderView::pushLayoutStateForCurrentFlowThread):

    Make all of these functions take RenderElement instead of
    RenderObject since layout never starts from a RenderText.

(WebCore::RenderView::shouldDisableLayoutStateForSubtree):

    Tweak loop since it's never null on first iteration.

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/rendering/LayoutState.cpp
Source/WebCore/rendering/LayoutState.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/RenderView.h

index e8a4442..aaafbbb 100644 (file)
@@ -1,3 +1,46 @@
+2015-01-19  Andreas Kling  <akling@apple.com>
+
+        LayoutState and subtree layout code should use RenderElement.
+        <https://webkit.org/b/126878>
+
+        Subtree layout will never begin at a RenderText, so tighten up
+        the code to operate on RenderElements instead of RenderObjects.
+
+        Reviewed by Antti Koivisto.
+
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::willLayout):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layoutRoot):
+        (WebCore::FrameView::layout):
+        * page/FrameView.h:
+
+            Make FrameView::layoutRoot() return RenderElement*.
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::willBeDestroyed):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::willBeDestroyed):
+        * rendering/RenderObject.h:
+
+            Move subtree layout root clearing logic in willBeDestroyed()
+            from RenderObject to RenderElement.
+
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutState::LayoutState):
+        * rendering/LayoutState.h:
+        * rendering/RenderView.h:
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::pushLayoutState):
+        (WebCore::RenderView::pushLayoutStateForCurrentFlowThread):
+
+            Make all of these functions take RenderElement instead of
+            RenderObject since layout never starts from a RenderText.
+
+        (WebCore::RenderView::shouldDisableLayoutStateForSubtree):
+
+            Tweak loop since it's never null on first iteration.
+
 2015-01-19  Beth Dakin  <bdakin@apple.com>
 
         Speculative build fix.
index a27a946..74938d7 100644 (file)
@@ -282,7 +282,7 @@ void InspectorTimelineAgent::didInvalidateLayout(Frame& frame)
 
 void InspectorTimelineAgent::willLayout(Frame& frame)
 {
-    RenderObject* root = frame.view()->layoutRoot();
+    RenderElement* root = frame.view()->layoutRoot();
     bool partialLayout = !!root;
 
     if (!partialLayout)
index 2d98262..bb4a098 100644 (file)
@@ -1083,9 +1083,9 @@ void FrameView::setIsInWindow(bool isInWindow)
         renderView->setIsInWindow(isInWindow);
 }
 
-RenderObject* FrameView::layoutRoot(bool onlyDuringLayout) const
+RenderElement* FrameView::layoutRoot(bool onlyDuringLayout) const
 {
-    return onlyDuringLayout && layoutPending() ? 0 : m_layoutRoot;
+    return onlyDuringLayout && layoutPending() ? nullptr : m_layoutRoot;
 }
 
 inline void FrameView::forceLayoutParentViewIfNeeded()
@@ -1301,7 +1301,7 @@ void FrameView::layout(bool allowSubtree)
 
         bool disableLayoutState = false;
         if (subtree) {
-            disableLayoutState = root->view().shouldDisableLayoutStateForSubtree(root);
+            disableLayoutState = root->view().shouldDisableLayoutStateForSubtree(*root);
             root->view().pushLayoutState(*root);
         }
         LayoutStateDisabler layoutStateDisabler(disableLayoutState ? &root->view() : 0);
index f8f0ef1..04f6c9a 100644 (file)
@@ -114,7 +114,7 @@ public:
     bool layoutPending() const;
     bool isInLayout() const { return m_layoutPhase == InLayout; }
 
-    RenderObject* layoutRoot(bool onlyDuringLayout = false) const;
+    RenderElement* layoutRoot(bool onlyDuringLayout = false) const;
     void clearLayoutRoot() { m_layoutRoot = nullptr; }
     int layoutCount() const { return m_layoutCount; }
 
index 17d0601..e534320 100644 (file)
@@ -122,7 +122,7 @@ LayoutState::LayoutState(std::unique_ptr<LayoutState> next, RenderBox* renderer,
     // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
 }
 
-LayoutState::LayoutState(RenderObject& root)
+LayoutState::LayoutState(RenderElement& root)
     : m_clipped(false)
     , m_isPaginated(false)
     , m_pageLogicalHeightChanged(false)
index d0e7a9e..8f8f9e2 100644 (file)
@@ -37,7 +37,6 @@ class RenderBlockFlow;
 class RenderBox;
 class RenderElement;
 class RenderFlowThread;
-class RenderObject;
 class ShapeInsideInfo;
 
 class LayoutState {
@@ -61,7 +60,7 @@ public:
     }
 
     LayoutState(std::unique_ptr<LayoutState>, RenderBox*, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged);
-    explicit LayoutState(RenderObject&);
+    explicit LayoutState(RenderElement&);
 
     void clearPaginationInformation();
     bool isPaginated() const { return m_isPaginated; }
@@ -129,7 +128,7 @@ public:
     RenderFlowThread* m_currentRenderFlowThread { nullptr };
 
 #ifndef NDEBUG
-    RenderObject* m_renderer;
+    RenderElement* m_renderer;
 #endif
 };
 
index 9d7169d..01a26bc 100644 (file)
@@ -1064,6 +1064,14 @@ void RenderElement::willBeDestroyed()
     if (hasCounterNodeMap())
         RenderCounter::destroyCounterNodes(*this);
 
+    if (!documentBeingDestroyed() && view().frameView().layoutRoot() == this) {
+        ASSERT_NOT_REACHED();
+        // This indicates a failure to layout the child, which is why
+        // the layout root is still set to |this|. Make sure to clear it
+        // since we are getting destroyed.
+        view().frameView().clearLayoutRoot();
+    }
+
     RenderObject::willBeDestroyed();
 
 #if !ASSERT_DISABLED
index 32f969a..8b8b189 100644 (file)
@@ -1865,20 +1865,6 @@ bool RenderObject::isSelectionBorder() const
         || view().selectionUnsplitEnd() == this;
 }
 
-inline void RenderObject::clearLayoutRootIfNeeded() const
-{
-    if (documentBeingDestroyed())
-        return;
-
-    if (view().frameView().layoutRoot() == this) {
-        ASSERT_NOT_REACHED();
-        // This indicates a failure to layout the child, which is why
-        // the layout root is still set to |this|. Make sure to clear it
-        // since we are getting destroyed.
-        view().frameView().clearLayoutRoot();
-    }
-}
-
 void RenderObject::willBeDestroyed()
 {
     // For accessibility management, notify the parent of the imminent change to its child set.
@@ -1901,8 +1887,6 @@ void RenderObject::willBeDestroyed()
         setHasLayer(false);
         downcast<RenderLayerModelObject>(*this).destroyLayer();
     }
-
-    clearLayoutRootIfNeeded();
 }
 
 void RenderObject::insertedIntoTree()
index 1a27ca7..626a258 100644 (file)
@@ -856,7 +856,6 @@ protected:
 
     void adjustRectForOutlineAndShadow(LayoutRect&) const;
 
-    void clearLayoutRootIfNeeded() const;
     virtual void willBeDestroyed();
 
     virtual void insertedIntoTree();
index 3212db2..79d66fa 100644 (file)
@@ -1186,7 +1186,7 @@ float RenderView::zoomFactor() const
     return frameView().frame().pageZoomFactor();
 }
 
-void RenderView::pushLayoutState(RenderObject& root)
+void RenderView::pushLayoutState(RenderElement& root)
 {
     ASSERT(m_layoutStateDisableCount == 0);
     ASSERT(m_layoutState == 0);
@@ -1195,9 +1195,9 @@ void RenderView::pushLayoutState(RenderObject& root)
     pushLayoutStateForCurrentFlowThread(root);
 }
 
-bool RenderView::shouldDisableLayoutStateForSubtree(RenderObject* renderer) const
+bool RenderView::shouldDisableLayoutStateForSubtree(const RenderElement& renderer) const
 {
-    RenderObject* o = renderer;
+    const RenderElement* o = &renderer;
     while (o) {
         if (o->hasTransform() || o->hasReflection())
             return true;
@@ -1300,18 +1300,18 @@ FlowThreadController& RenderView::flowThreadController()
     return *m_flowThreadController;
 }
 
-void RenderView::pushLayoutStateForCurrentFlowThread(const RenderObject& object)
+void RenderView::pushLayoutStateForCurrentFlowThread(const RenderElement& renderer)
 {
     if (!m_flowThreadController)
         return;
 
-    RenderFlowThread* currentFlowThread = object.flowThreadContainingBlock();
+    RenderFlowThread* currentFlowThread = renderer.flowThreadContainingBlock();
     if (!currentFlowThread)
         return;
 
     m_layoutState->setCurrentRenderFlowThread(currentFlowThread);
 
-    currentFlowThread->pushFlowThreadLayoutState(object);
+    currentFlowThread->pushFlowThreadLayoutState(renderer);
 }
 
 void RenderView::popLayoutStateForCurrentFlowThread()
index d4c3690..2534b89 100644 (file)
@@ -137,10 +137,10 @@ public:
     bool doingFullRepaint() const { return frameView().needsFullRepaint(); }
 
     // Subtree push/pop
-    void pushLayoutState(RenderObject&);
-    void popLayoutState(RenderObject&) { return popLayoutState(); } // Just doing this to keep popLayoutState() private and to make the subtree calls symmetrical.
+    void pushLayoutState(RenderElement&);
+    void popLayoutState(RenderElement&) { return popLayoutState(); } // Just doing this to keep popLayoutState() private and to make the subtree calls symmetrical.
 
-    bool shouldDisableLayoutStateForSubtree(RenderObject*) const;
+    bool shouldDisableLayoutStateForSubtree(const RenderElement&) const;
 
     // Returns true if layoutState should be used for its cached offset and clip.
     bool layoutStateEnabled() const { return m_layoutStateDisableCount == 0 && m_layoutState; }
@@ -290,7 +290,7 @@ private:
     void checkLayoutState(const LayoutState&);
 #endif
 
-    void pushLayoutStateForCurrentFlowThread(const RenderObject&);
+    void pushLayoutStateForCurrentFlowThread(const RenderElement&);
     void popLayoutStateForCurrentFlowThread();
 
     friend class LayoutStateMaintainer;