Replace RenderObject::isRooted() logic with isDescendantOf().
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Aug 2015 21:30:35 +0000 (21:30 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Aug 2015 21:30:35 +0000 (21:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147788

Reviewed by Simon Fraser.

And some related cleanups.

No change in functionality.

* page/FrameView.cpp:
(WebCore::FrameView::scheduleRelayoutOfSubtree):
(WebCore::FrameView::extendedBackgroundRectForPainting):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintRootBoxFillLayers):
* rendering/RenderElement.cpp:
(WebCore::shouldRepaintForImageAnimation):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::isDescendantOf):
(WebCore::scheduleRelayoutForSubtree):
(WebCore::RenderObject::repaint):
(WebCore::RenderObject::repaintRectangle):
(WebCore::RenderObject::repaintSlowRepaintObject):
(WebCore::RenderObject::isRooted):
* rendering/RenderObject.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::unextendedBackgroundRect):
(WebCore::RenderView::backgroundRect):
* rendering/RenderView.h:

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

Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/rendering/RenderBox.cpp
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 b47bd4f..3c98f67 100644 (file)
@@ -1,5 +1,36 @@
 2015-08-07  Zalan Bujtas  <zalan@apple.com>
 
+        Replace RenderObject::isRooted() logic with isDescendantOf().
+        https://bugs.webkit.org/show_bug.cgi?id=147788
+
+        Reviewed by Simon Fraser.
+
+        And some related cleanups.
+
+        No change in functionality.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scheduleRelayoutOfSubtree):
+        (WebCore::FrameView::extendedBackgroundRectForPainting):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintRootBoxFillLayers):
+        * rendering/RenderElement.cpp:
+        (WebCore::shouldRepaintForImageAnimation):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::isDescendantOf):
+        (WebCore::scheduleRelayoutForSubtree):
+        (WebCore::RenderObject::repaint):
+        (WebCore::RenderObject::repaintRectangle):
+        (WebCore::RenderObject::repaintSlowRepaintObject):
+        (WebCore::RenderObject::isRooted):
+        * rendering/RenderObject.h:
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::unextendedBackgroundRect):
+        (WebCore::RenderView::backgroundRect):
+        * rendering/RenderView.h:
+
+2015-08-07  Zalan Bujtas  <zalan@apple.com>
+
         Subtree layout code should use RenderElement.
         https://bugs.webkit.org/show_bug.cgi?id=147694
 
index bf2e6c7..acf1380 100644 (file)
@@ -2581,7 +2581,7 @@ static bool isObjectAncestorContainerOf(RenderObject* ancestor, RenderObject* de
 void FrameView::scheduleRelayoutOfSubtree(RenderElement& newRelayoutRoot)
 {
     ASSERT(renderView());
-    RenderView& renderView = *this->renderView();
+    const RenderView& renderView = *this->renderView();
 
     // Try to catch unnecessary work during render tree teardown.
     ASSERT(!renderView.documentBeingDestroyed());
@@ -2879,7 +2879,7 @@ IntRect FrameView::extendedBackgroundRectForPainting() const
     if (!renderView)
         return IntRect();
     
-    LayoutRect extendedRect = renderView->unextendedBackgroundRect(renderView);
+    LayoutRect extendedRect = renderView->unextendedBackgroundRect();
     if (!tiledBacking->hasMargins())
         return snappedIntRect(extendedRect);
     
index aa97daf..e47ffea 100644 (file)
@@ -1249,7 +1249,7 @@ void RenderBox::paintRootBoxFillLayers(const PaintInfo& paintInfo)
     const FillLayer* bgLayer = rootBackgroundRenderer.style().backgroundLayers();
     Color bgColor = rootBackgroundRenderer.style().visitedDependentColor(CSSPropertyBackgroundColor);
 
-    paintFillLayers(paintInfo, bgColor, bgLayer, view().backgroundRect(this), BackgroundBleedNone, CompositeSourceOver, &rootBackgroundRenderer);
+    paintFillLayers(paintInfo, bgColor, bgLayer, view().backgroundRect(), BackgroundBleedNone, CompositeSourceOver, &rootBackgroundRenderer);
 }
 
 BackgroundBleedAvoidance RenderBox::determineBackgroundBleedAvoidance(GraphicsContext* context) const
index b309f77..7e26535 100644 (file)
@@ -1446,7 +1446,7 @@ static bool shouldRepaintForImageAnimation(const RenderElement& renderer, const
         backgroundIsPaintedByRoot = !rootRenderer.hasBackground();
 
     }
-    LayoutRect backgroundPaintingRect = backgroundIsPaintedByRoot ? renderer.view().backgroundRect(&renderer.view()) : renderer.absoluteClippedOverflowRect();
+    LayoutRect backgroundPaintingRect = backgroundIsPaintedByRoot ? renderer.view().backgroundRect() : renderer.absoluteClippedOverflowRect();
     if (!visibleRect.intersects(enclosingIntRect(backgroundPaintingRect)))
         return false;
 
index 00c2fb4..1a6fde7 100644 (file)
@@ -141,10 +141,10 @@ RenderTheme& RenderObject::theme() const
     return document().page()->theme();
 }
 
-bool RenderObject::isDescendantOf(const RenderObject* obj) const
+bool RenderObject::isDescendantOf(const RenderObject* ancestor) const
 {
-    for (const RenderObject* r = this; r; r = r->m_parent) {
-        if (r == obj)
+    for (const RenderObject* renderer = this; renderer; renderer = renderer->m_parent) {
+        if (renderer == ancestor)
             return true;
     }
     return false;
@@ -571,13 +571,13 @@ void RenderObject::clearNeedsLayout()
 
 static void scheduleRelayoutForSubtree(RenderElement& renderer)
 {
-    if (!is<RenderView>(renderer)) {
-        if (!renderer.isRooted())
-            return;
-        renderer.view().frameView().scheduleRelayoutOfSubtree(renderer);
+    if (is<RenderView>(renderer)) {
+        downcast<RenderView>(renderer).frameView().scheduleRelayout();
         return;
     }
-    downcast<RenderView>(renderer).frameView().scheduleRelayout();
+
+    if (renderer.isRooted())
+        renderer.view().frameView().scheduleRelayoutOfSubtree(renderer);
 }
 
 void RenderObject::markContainingBlocksForLayout(ScheduleRelayout scheduleRelayout, RenderElement* newRoot)
@@ -1249,61 +1249,58 @@ void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintCo
 void RenderObject::repaint() const
 {
     // Don't repaint if we're unrooted (note that view() still returns the view when unrooted)
-    RenderView* view;
-    if (!isRooted(&view))
+    if (!isRooted())
         return;
 
-    if (view->printing())
-        return; // Don't repaint if we're printing.
+    const RenderView& view = this->view();
+    if (view.printing())
+        return;
 
     RenderLayerModelObject* repaintContainer = containerForRepaint();
-    repaintUsingContainer(repaintContainer ? repaintContainer : view, clippedOverflowRectForRepaint(repaintContainer));
+    repaintUsingContainer(repaintContainer ? repaintContainer : &view, clippedOverflowRectForRepaint(repaintContainer));
 }
 
 void RenderObject::repaintRectangle(const LayoutRect& r, bool shouldClipToLayer) const
 {
     // Don't repaint if we're unrooted (note that view() still returns the view when unrooted)
-    RenderView* view;
-    if (!isRooted(&view))
+    if (!isRooted())
         return;
 
-    if (view->printing())
-        return; // Don't repaint if we're printing.
+    const RenderView& view = this->view();
+    if (view.printing())
+        return;
 
     LayoutRect dirtyRect(r);
-
     // FIXME: layoutDelta needs to be applied in parts before/after transforms and
     // repaint containers. https://bugs.webkit.org/show_bug.cgi?id=23308
-    dirtyRect.move(view->layoutDelta());
+    dirtyRect.move(view.layoutDelta());
 
     RenderLayerModelObject* repaintContainer = containerForRepaint();
     computeRectForRepaint(repaintContainer, dirtyRect);
-    repaintUsingContainer(repaintContainer ? repaintContainer : view, dirtyRect, shouldClipToLayer);
+    repaintUsingContainer(repaintContainer ? repaintContainer : &view, dirtyRect, shouldClipToLayer);
 }
 
 void RenderObject::repaintSlowRepaintObject() const
 {
     // Don't repaint if we're unrooted (note that view() still returns the view when unrooted)
-    RenderView* view;
-    if (!isRooted(&view))
+    if (!isRooted())
         return;
 
-    // Don't repaint if we're printing.
-    if (view->printing())
+    const RenderView& view = this->view();
+    if (view.printing())
         return;
 
-    RenderLayerModelObject* repaintContainer = containerForRepaint();
+    const RenderLayerModelObject* repaintContainer = containerForRepaint();
     if (!repaintContainer)
-        repaintContainer = view;
+        repaintContainer = &view;
 
     bool shouldClipToLayer = true;
     IntRect repaintRect;
-
     // If this is the root background, we need to check if there is an extended background rect. If
     // there is, then we should not allow painting to clip to the layer size.
     if (isRoot() || isBody()) {
-        shouldClipToLayer = !view->frameView().hasExtendedBackgroundRectForPainting();
-        repaintRect = snappedIntRect(view->backgroundRect(view));
+        shouldClipToLayer = !view.frameView().hasExtendedBackgroundRectForPainting();
+        repaintRect = snappedIntRect(view.backgroundRect());
     } else
         repaintRect = snappedIntRect(clippedOverflowRectForRepaint(repaintContainer));
 
@@ -1764,19 +1761,9 @@ LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
     return LayoutRect();
 }
 
-bool RenderObject::isRooted(RenderView** view) const
+bool RenderObject::isRooted() const
 {
-    const RenderObject* renderer = this;
-    while (renderer->parent())
-        renderer = renderer->parent();
-
-    if (!is<RenderView>(*renderer))
-        return false;
-
-    if (view)
-        *view = const_cast<RenderView*>(downcast<RenderView>(renderer));
-
-    return true;
+    return isDescendantOf(&view());
 }
 
 RespectImageOrientationEnum RenderObject::shouldRespectImageOrientation() const
index 9b0e0ff..e2d3520 100644 (file)
@@ -568,8 +568,8 @@ public:
 
     RenderView& view() const { return *document().renderView(); };
 
-    // Returns true if this renderer is rooted, and optionally returns the hosting view (the root of the hierarchy).
-    bool isRooted(RenderView** = nullptr) const;
+    // Returns true if this renderer is rooted.
+    bool isRooted() const;
 
     Node* node() const { return isAnonymous() ? nullptr : &m_node; }
     Node* nonPseudoNode() const { return isPseudoElement() ? nullptr : node(); }
index 62abfe0..428c160 100644 (file)
@@ -1162,19 +1162,19 @@ bool RenderView::rootBackgroundIsEntirelyFixed() const
     return rootObject->rendererForRootBackground().hasEntirelyFixedBackground();
 }
     
-LayoutRect RenderView::unextendedBackgroundRect(RenderBox*) const
+LayoutRect RenderView::unextendedBackgroundRect() const
 {
     // FIXME: What is this? Need to patch for new columns?
     return unscaledDocumentRect();
 }
     
-LayoutRect RenderView::backgroundRect(RenderBox* backgroundRenderer) const
+LayoutRect RenderView::backgroundRect() const
 {
     // FIXME: New columns care about this?
     if (frameView().hasExtendedBackgroundRectForPainting())
         return frameView().extendedBackgroundRectForPainting();
 
-    return unextendedBackgroundRect(backgroundRenderer);
+    return unextendedBackgroundRect();
 }
 
 IntRect RenderView::documentRect() const
index 7160c9d..c800efb 100644 (file)
@@ -188,8 +188,8 @@ public:
     WEBCORE_EXPORT bool usesCompositing() const;
 
     WEBCORE_EXPORT IntRect unscaledDocumentRect() const;
-    LayoutRect unextendedBackgroundRect(RenderBox* backgroundRenderer) const;
-    LayoutRect backgroundRect(RenderBox* backgroundRenderer) const;
+    LayoutRect unextendedBackgroundRect() const;
+    LayoutRect backgroundRect() const;
 
     WEBCORE_EXPORT IntRect documentRect() const;