Title: [139802] trunk/Source/WebCore
Revision
139802
Author
simon.fra...@apple.com
Date
2013-01-15 15:46:18 -0800 (Tue, 15 Jan 2013)

Log Message

Some ScrollingCoördinator-related cleanup in RenderLayerBacking
https://bugs.webkit.org/show_bug.cgi?id=106950

Reviewed by Beth Dakin.

Wrap up code that gets the ScrollingCoordinator into a utility function.
Pull code out of updateGraphicsLayerGeometry() that registers layers with
the ScrollingCoordinator, for cleanliness.

* rendering/RenderLayerBacking.cpp:
(WebCore::scrollingCoordinatorFromLayer):
(WebCore::RenderLayerBacking::adjustTileCacheCoverage):
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
(WebCore::RenderLayerBacking::registerScrollingLayers):
(WebCore::RenderLayerBacking::attachToScrollingCoordinatorWithParent):
(WebCore::RenderLayerBacking::detachFromScrollingCoordinator):
* rendering/RenderLayerBacking.h:
(RenderLayerBacking):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (139801 => 139802)


--- trunk/Source/WebCore/ChangeLog	2013-01-15 23:45:14 UTC (rev 139801)
+++ trunk/Source/WebCore/ChangeLog	2013-01-15 23:46:18 UTC (rev 139802)
@@ -1,3 +1,24 @@
+2013-01-15  Simon Fraser  <simon.fra...@apple.com>
+
+        Some ScrollingCoördinator-related cleanup in RenderLayerBacking
+        https://bugs.webkit.org/show_bug.cgi?id=106950
+
+        Reviewed by Beth Dakin.
+        
+        Wrap up code that gets the ScrollingCoordinator into a utility function.
+        Pull code out of updateGraphicsLayerGeometry() that registers layers with
+        the ScrollingCoordinator, for cleanliness.
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::scrollingCoordinatorFromLayer):
+        (WebCore::RenderLayerBacking::adjustTileCacheCoverage):
+        (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
+        (WebCore::RenderLayerBacking::registerScrollingLayers):
+        (WebCore::RenderLayerBacking::attachToScrollingCoordinatorWithParent):
+        (WebCore::RenderLayerBacking::detachFromScrollingCoordinator):
+        * rendering/RenderLayerBacking.h:
+        (RenderLayerBacking):
+
 2013-01-15  Beth Dakin  <bda...@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=106940

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (139801 => 139802)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2013-01-15 23:45:14 UTC (rev 139801)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2013-01-15 23:46:18 UTC (rev 139802)
@@ -95,6 +95,16 @@
     return false;
 }
 
+// Get the scrolling coordinator in a way that works inside RenderLayerBacking's destructor.
+static ScrollingCoordinator* scrollingCoordinatorFromLayer(RenderLayer* layer)
+{
+    Page* page = layer->renderer()->frame()->page();
+    if (!page)
+        return 0;
+
+    return page->scrollingCoordinator();
+}
+
 bool RenderLayerBacking::m_creatingPrimaryGraphicsLayer = false;
 
 RenderLayerBacking::RenderLayerBacking(RenderLayer* layer)
@@ -200,7 +210,7 @@
         if (frameView->verticalScrollbarMode() != ScrollbarAlwaysOff)
             tileCoverage |= TiledBacking::CoverageForVerticalScrolling;
 
-        if (ScrollingCoordinator* scrollingCoordinator = frame->page()->scrollingCoordinator()) {
+        if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer)) {
             // Ask our TiledBacking for large tiles unless the only reason we're main-thread-scrolling
             // is a page overlay (find-in-page, the Web Inspector highlight mechanism, etc.).
             if (scrollingCoordinator->mainThreadScrollingReasons() & ~ScrollingCoordinator::ForcedOnMainThread)
@@ -569,23 +579,6 @@
     m_graphicsLayer->setPreserves3D(style->transformStyle3D() == TransformStyle3DPreserve3D && !renderer()->hasReflection());
     m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == BackfaceVisibilityVisible);
 
-    // Register fixed position layers and their containers with the scrolling coordinator.
-    if (Page* page = renderer()->frame()->page()) {
-        if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator()) {
-            if (style->position() == FixedPosition || compositor()->fixedPositionedByAncestor(m_owningLayer))
-                scrollingCoordinator->setLayerIsFixedToContainerLayer(childForSuperlayers(), true);
-            else {
-                if (m_ancestorClippingLayer)
-                    scrollingCoordinator->setLayerIsFixedToContainerLayer(m_ancestorClippingLayer.get(), false);
-                scrollingCoordinator->setLayerIsFixedToContainerLayer(m_graphicsLayer.get(), false);
-            }
-            // Page scale is applied as a transform on the root render view layer. Because the scroll
-            // layer is further up in the hierarchy, we need to avoid marking the root render view
-            // layer as a container.
-            bool isContainer = m_owningLayer->hasTransform() && !m_owningLayer->isRootLayer();
-            scrollingCoordinator->setLayerIsContainerForFixedPositionLayers(childForSuperlayers(), isContainer);
-        }
-    }
     RenderLayer* compAncestor = m_owningLayer->ancestorCompositingLayer();
     
     // We compute everything relative to the enclosing compositing layer.
@@ -770,8 +763,31 @@
     updateBackgroundColor(isSimpleContainer);
     updateDrawsContent(isSimpleContainer);
     updateAfterWidgetResize();
+    registerScrollingLayers();
 }
 
+void RenderLayerBacking::registerScrollingLayers()
+{
+    // Register fixed position layers and their containers with the scrolling coordinator.
+    ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer);
+    if (!scrollingCoordinator)
+        return;
+
+    // FIXME: it would be nice to avoid all this work if the platform doesn't implement setLayerIsFixedToContainerLayer().
+    if (renderer()->style()->position() == FixedPosition || compositor()->fixedPositionedByAncestor(m_owningLayer))
+        scrollingCoordinator->setLayerIsFixedToContainerLayer(childForSuperlayers(), true);
+    else {
+        if (m_ancestorClippingLayer)
+            scrollingCoordinator->setLayerIsFixedToContainerLayer(m_ancestorClippingLayer.get(), false);
+        scrollingCoordinator->setLayerIsFixedToContainerLayer(m_graphicsLayer.get(), false);
+    }
+    // Page scale is applied as a transform on the root render view layer. Because the scroll
+    // layer is further up in the hierarchy, we need to avoid marking the root render view
+    // layer as a container.
+    bool isContainer = m_owningLayer->hasTransform() && !m_owningLayer->isRootLayer();
+    scrollingCoordinator->setLayerIsContainerForFixedPositionLayers(childForSuperlayers(), isContainer);
+}
+
 void RenderLayerBacking::updateInternalHierarchy()
 {
     // m_foregroundLayer has to be inserted in the correct order with child layers,
@@ -1074,11 +1090,7 @@
 
 void RenderLayerBacking::attachToScrollingCoordinatorWithParent(RenderLayerBacking* parent)
 {
-    Page* page = renderer()->frame()->page();
-    if (!page)
-        return;
-
-    ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator();
+    ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer);
     if (!scrollingCoordinator)
         return;
 
@@ -1102,11 +1114,7 @@
     if (!m_scrollLayerID)
         return;
 
-    Page* page = renderer()->frame()->page();
-    if (!page)
-        return;
-
-    ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator();
+    ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer);
     if (!scrollingCoordinator)
         return;
 

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (139801 => 139802)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2013-01-15 23:45:14 UTC (rev 139801)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2013-01-15 23:46:18 UTC (rev 139802)
@@ -210,7 +210,8 @@
     bool requiresScrollCornerLayer() const;
     bool updateScrollingLayers(bool scrollingLayers);
     void updateDrawsContent(bool isSimpleContainer);
-
+    void registerScrollingLayers();
+    
     GraphicsLayerPaintingPhase paintingPhaseForPrimaryLayer() const;
     
     IntSize contentOffsetInCompostingLayer() const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to