- Revision
- 182809
- Author
- [email protected]
- Date
- 2015-04-14 14:14:07 -0700 (Tue, 14 Apr 2015)
Log Message
[iOS] Clean up registration of layers with the ScrollingCoordinator
https://bugs.webkit.org/show_bug.cgi?id=143725
Reviewed by Tim Horton.
Simplify a couple of bits of code related to the registration of layers with
the ScrollingCoordinator in RenderLayerCompositor.
First, RenderLayerBacking was using ScrollingNodeTypes to choose which scrolling
roles a layer has, which let to ambiguous code where we hardcoded a ScrollingNodeType
with knowledge of what RenderLayerBacking did with it. Clean up by using LayerScrollCoordinationRole,
which is moved to RenderLayer.h so that RenderLayerCompositor.h and RenderLayerBacking.h
both see it.
Secondly, avoid having both detachFromScrollingCoordinator() and detachFromScrollingCoordinatorForRole()
by passing in the bitmask of roles.
* page/FrameView.cpp:
(WebCore::FrameView::scrollLayerID):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::~RenderLayerBacking):
(WebCore::RenderLayerBacking::detachFromScrollingCoordinator):
(WebCore::RenderLayerBacking::detachFromScrollingCoordinatorForRole): Deleted.
* rendering/RenderLayerBacking.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateScrollCoordinatedStatus):
(WebCore::RenderLayerCompositor::removeFromScrollCoordinatedLayers):
(WebCore::scrollCoordinationRoleForNodeType):
(WebCore::RenderLayerCompositor::attachScrollingNode):
(WebCore::RenderLayerCompositor::detachScrollCoordinatedLayer):
(WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer):
(WebCore::RenderLayerCompositor::willRemoveScrollingLayerWithBacking):
(WebCore::RenderLayerCompositor::detachScrollCoordinatedLayerForRole): Deleted.
* rendering/RenderLayerCompositor.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (182808 => 182809)
--- trunk/Source/WebCore/ChangeLog 2015-04-14 21:08:02 UTC (rev 182808)
+++ trunk/Source/WebCore/ChangeLog 2015-04-14 21:14:07 UTC (rev 182809)
@@ -1,3 +1,41 @@
+2015-04-14 Simon Fraser <[email protected]>
+
+ [iOS] Clean up registration of layers with the ScrollingCoordinator
+ https://bugs.webkit.org/show_bug.cgi?id=143725
+
+ Reviewed by Tim Horton.
+
+ Simplify a couple of bits of code related to the registration of layers with
+ the ScrollingCoordinator in RenderLayerCompositor.
+
+ First, RenderLayerBacking was using ScrollingNodeTypes to choose which scrolling
+ roles a layer has, which let to ambiguous code where we hardcoded a ScrollingNodeType
+ with knowledge of what RenderLayerBacking did with it. Clean up by using LayerScrollCoordinationRole,
+ which is moved to RenderLayer.h so that RenderLayerCompositor.h and RenderLayerBacking.h
+ both see it.
+
+ Secondly, avoid having both detachFromScrollingCoordinator() and detachFromScrollingCoordinatorForRole()
+ by passing in the bitmask of roles.
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::scrollLayerID):
+ * rendering/RenderLayer.h:
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::~RenderLayerBacking):
+ (WebCore::RenderLayerBacking::detachFromScrollingCoordinator):
+ (WebCore::RenderLayerBacking::detachFromScrollingCoordinatorForRole): Deleted.
+ * rendering/RenderLayerBacking.h:
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::updateScrollCoordinatedStatus):
+ (WebCore::RenderLayerCompositor::removeFromScrollCoordinatedLayers):
+ (WebCore::scrollCoordinationRoleForNodeType):
+ (WebCore::RenderLayerCompositor::attachScrollingNode):
+ (WebCore::RenderLayerCompositor::detachScrollCoordinatedLayer):
+ (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer):
+ (WebCore::RenderLayerCompositor::willRemoveScrollingLayerWithBacking):
+ (WebCore::RenderLayerCompositor::detachScrollCoordinatedLayerForRole): Deleted.
+ * rendering/RenderLayerCompositor.h:
+
2015-04-14 Benjamin Poulain <[email protected]>
Add a conservative DFA minimizer for the content extension matcher
Modified: trunk/Source/WebCore/page/FrameView.cpp (182808 => 182809)
--- trunk/Source/WebCore/page/FrameView.cpp 2015-04-14 21:08:02 UTC (rev 182808)
+++ trunk/Source/WebCore/page/FrameView.cpp 2015-04-14 21:14:07 UTC (rev 182809)
@@ -835,7 +835,7 @@
if (!backing)
return 0;
- return backing->scrollingNodeIDForRole(FrameScrollingNode);
+ return backing->scrollingNodeIDForRole(Scrolling);
}
ScrollableArea* FrameView::scrollableAreaForScrollLayerID(uint64_t nodeID) const
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (182808 => 182809)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2015-04-14 21:08:02 UTC (rev 182808)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2015-04-14 21:14:07 UTC (rev 182809)
@@ -104,6 +104,12 @@
IgnoreRootOffsetForFragments
};
+enum LayerScrollCoordinationRole {
+ ViewportConstrained = 1 << 0,
+ Scrolling = 1 << 1
+};
+typedef unsigned LayerScrollCoordinationRoles;
+
class RenderLayer final : public ScrollableArea {
WTF_MAKE_FAST_ALLOCATED;
public:
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (182808 => 182809)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2015-04-14 21:08:02 UTC (rev 182808)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2015-04-14 21:14:07 UTC (rev 182809)
@@ -151,7 +151,7 @@
updateBackgroundLayer(false);
updateMaskingLayer(false, false);
updateScrollingLayers(false);
- detachFromScrollingCoordinator();
+ detachFromScrollingCoordinator(Scrolling | ViewportConstrained);
destroyGraphicsLayers();
}
@@ -1551,7 +1551,7 @@
return true;
}
-void RenderLayerBacking::detachFromScrollingCoordinator()
+void RenderLayerBacking::detachFromScrollingCoordinator(LayerScrollCoordinationRoles roles)
{
if (!m_scrollingNodeID && !m_viewportConstrainedNodeID)
return;
@@ -1560,30 +1560,17 @@
if (!scrollingCoordinator)
return;
- if (m_scrollingNodeID)
+ if ((roles & Scrolling) && m_scrollingNodeID) {
scrollingCoordinator->detachFromStateTree(m_scrollingNodeID);
-
- if (m_viewportConstrainedNodeID)
+ m_scrollingNodeID = 0;
+ }
+
+ if ((roles & ViewportConstrained) && m_viewportConstrainedNodeID) {
scrollingCoordinator->detachFromStateTree(m_viewportConstrainedNodeID);
-
- m_scrollingNodeID = 0;
- m_viewportConstrainedNodeID = 0;
+ m_viewportConstrainedNodeID = 0;
+ }
}
-void RenderLayerBacking::detachFromScrollingCoordinatorForRole(ScrollingNodeType role)
-{
- ScrollingNodeID nodeID = scrollingNodeIDForRole(role);
- if (!nodeID)
- return;
-
- ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer);
- if (!scrollingCoordinator)
- return;
-
- scrollingCoordinator->detachFromStateTree(nodeID);
- setScrollingNodeIDForRole(0, role);
-}
-
GraphicsLayerPaintingPhase RenderLayerBacking::paintingPhaseForPrimaryLayer() const
{
unsigned phase = 0;
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (182808 => 182809)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.h 2015-04-14 21:08:02 UTC (rev 182808)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h 2015-04-14 21:14:07 UTC (rev 182809)
@@ -107,31 +107,26 @@
GraphicsLayer* scrollingLayer() const { return m_scrollingLayer.get(); }
GraphicsLayer* scrollingContentsLayer() const { return m_scrollingContentsLayer.get(); }
- void detachFromScrollingCoordinator();
- void detachFromScrollingCoordinatorForRole(ScrollingNodeType);
+ void detachFromScrollingCoordinator(LayerScrollCoordinationRoles);
- ScrollingNodeID scrollingNodeIDForRole(ScrollingNodeType nodeType) const
+ ScrollingNodeID scrollingNodeIDForRole(LayerScrollCoordinationRole role) const
{
- switch (nodeType) {
- case FrameScrollingNode:
- case OverflowScrollingNode:
+ switch (role) {
+ case Scrolling:
return m_scrollingNodeID;
- case FixedNode:
- case StickyNode:
+ case ViewportConstrained:
return m_viewportConstrainedNodeID;
}
return 0;
}
- void setScrollingNodeIDForRole(ScrollingNodeID nodeID, ScrollingNodeType nodeType)
+ void setScrollingNodeIDForRole(ScrollingNodeID nodeID, LayerScrollCoordinationRole role)
{
- switch (nodeType) {
- case FrameScrollingNode:
- case OverflowScrollingNode:
+ switch (role) {
+ case Scrolling:
m_scrollingNodeID = nodeID;
break;
- case FixedNode:
- case StickyNode:
+ case ViewportConstrained:
m_viewportConstrainedNodeID = nodeID;
break;
}
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (182808 => 182809)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2015-04-14 21:08:02 UTC (rev 182808)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2015-04-14 21:14:07 UTC (rev 182809)
@@ -3643,18 +3643,18 @@
void RenderLayerCompositor::updateScrollCoordinatedStatus(RenderLayer& layer)
{
- ScrollCoordinationReasons coordinationReasons = 0;
+ LayerScrollCoordinationRoles coordinationRoles = 0;
if (isViewportConstrainedFixedOrStickyLayer(layer))
- coordinationReasons |= FixedOrSticky;
+ coordinationRoles |= ViewportConstrained;
if (useCoordinatedScrollingForLayer(m_renderView, layer))
- coordinationReasons |= Scrolling;
+ coordinationRoles |= Scrolling;
- if (coordinationReasons) {
+ if (coordinationRoles) {
if (m_scrollCoordinatedLayers.add(&layer).isNewEntry)
m_subframeScrollLayersNeedReattach = true;
- updateScrollCoordinatedLayer(layer, coordinationReasons);
+ updateScrollCoordinatedLayer(layer, coordinationRoles);
} else
removeFromScrollCoordinatedLayers(layer);
}
@@ -3669,7 +3669,7 @@
m_scrollCoordinatedLayers.remove(&layer);
m_scrollCoordinatedLayersNeedingUpdate.remove(&layer);
- detachScrollCoordinatedLayer(layer);
+ detachScrollCoordinatedLayer(layer, Scrolling | ViewportConstrained);
}
FixedPositionViewportConstraints RenderLayerCompositor::computeFixedViewportConstraints(RenderLayer& layer) const
@@ -3790,6 +3790,20 @@
}
}
+static inline LayerScrollCoordinationRole scrollCoordinationRoleForNodeType(ScrollingNodeType nodeType)
+{
+ switch (nodeType) {
+ case FrameScrollingNode:
+ case OverflowScrollingNode:
+ return Scrolling;
+ case FixedNode:
+ case StickyNode:
+ return ViewportConstrained;
+ }
+ ASSERT_NOT_REACHED();
+ return Scrolling;
+}
+
ScrollingNodeID RenderLayerCompositor::attachScrollingNode(RenderLayer& layer, ScrollingNodeType nodeType, ScrollingNodeID parentNodeID)
{
ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator();
@@ -3799,7 +3813,8 @@
if (!backing)
return 0;
- ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(nodeType);
+ LayerScrollCoordinationRole role = scrollCoordinationRoleForNodeType(nodeType);
+ ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(role);
if (!nodeID)
nodeID = scrollingCoordinator->uniqueScrollLayerID();
@@ -3807,37 +3822,29 @@
if (!nodeID)
return 0;
- backing->setScrollingNodeIDForRole(nodeID, nodeType);
+ backing->setScrollingNodeIDForRole(nodeID, role);
m_scrollingNodeToLayerMap.add(nodeID, &layer);
return nodeID;
}
-void RenderLayerCompositor::detachScrollCoordinatedLayerForRole(RenderLayer& layer, ScrollingNodeType role)
+void RenderLayerCompositor::detachScrollCoordinatedLayer(RenderLayer& layer, LayerScrollCoordinationRoles roles)
{
RenderLayerBacking* backing = layer.backing();
if (!backing)
return;
- if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(role))
- m_scrollingNodeToLayerMap.remove(nodeID);
+ if (roles & Scrolling) {
+ if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(Scrolling))
+ m_scrollingNodeToLayerMap.remove(nodeID);
+ }
- backing->detachFromScrollingCoordinatorForRole(role);
-}
+ if (roles & ViewportConstrained) {
+ if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(ViewportConstrained))
+ m_scrollingNodeToLayerMap.remove(nodeID);
+ }
-void RenderLayerCompositor::detachScrollCoordinatedLayer(RenderLayer& layer)
-{
- RenderLayerBacking* backing = layer.backing();
- if (!backing)
- return;
-
- if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(FrameScrollingNode))
- m_scrollingNodeToLayerMap.remove(nodeID);
-
- if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(FixedNode))
- m_scrollingNodeToLayerMap.remove(nodeID);
-
- backing->detachFromScrollingCoordinator();
+ backing->detachFromScrollingCoordinator(roles);
}
void RenderLayerCompositor::updateScrollCoordinationForThisFrame(ScrollingNodeID parentNodeID)
@@ -3849,7 +3856,7 @@
scrollingCoordinator->updateFrameScrollingNode(nodeID, m_scrollLayer.get(), m_rootContentLayer.get(), fixedRootBackgroundLayer(), clipLayer());
}
-void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, ScrollCoordinationReasons reasons)
+void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, LayerScrollCoordinationRoles reasons)
{
ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator();
if (!scrollingCoordinator || !scrollingCoordinator->coordinatesScrollingForFrameView(m_renderView.frameView()))
@@ -3874,7 +3881,7 @@
return;
updateScrollCoordinationForThisFrame(parentDocumentHostingNodeID);
- if (!(reasons & FixedOrSticky) && isRootLayer)
+ if (!(reasons & ViewportConstrained) && isRootLayer)
return;
}
@@ -3884,7 +3891,7 @@
// Always call this even if the backing is already attached because the parent may have changed.
// If a node plays both roles, fixed/sticky is always the ancestor node of scrolling.
- if (reasons & FixedOrSticky) {
+ if (reasons & ViewportConstrained) {
ScrollingNodeType nodeType = FrameScrollingNode;
if (layer.renderer().style().position() == FixedPosition)
nodeType = FixedNode;
@@ -3911,7 +3918,7 @@
parentNodeID = nodeID;
} else
- detachScrollCoordinatedLayerForRole(layer, FixedNode);
+ detachScrollCoordinatedLayer(layer, ViewportConstrained);
if (reasons & Scrolling) {
if (isRootLayer)
@@ -3937,7 +3944,7 @@
scrollingCoordinator->updateOverflowScrollingNode(nodeID, backing->scrollingLayer(), backing->scrollingContentsLayer(), &scrollingGeometry);
}
} else
- detachScrollCoordinatedLayerForRole(layer, OverflowScrollingNode);
+ detachScrollCoordinatedLayer(layer, Scrolling);
}
ScrollableArea* RenderLayerCompositor::scrollableAreaForScrollLayerID(ScrollingNodeID nodeID) const
@@ -4030,7 +4037,7 @@
void RenderLayerCompositor::willRemoveScrollingLayerWithBacking(RenderLayer& layer, RenderLayerBacking& backing)
{
if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) {
- backing.detachFromScrollingCoordinator();
+ backing.detachFromScrollingCoordinator(Scrolling);
// For Coordinated Graphics.
scrollingCoordinator->scrollableAreaScrollLayerDidChange(layer);
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (182808 => 182809)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h 2015-04-14 21:08:02 UTC (rev 182808)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h 2015-04-14 21:14:07 UTC (rev 182809)
@@ -424,17 +424,10 @@
#endif
- enum ScrollCoordinationReason {
- FixedOrSticky = 1 << 0,
- Scrolling = 1 << 1
- };
- typedef unsigned ScrollCoordinationReasons;
-
void updateScrollCoordinationForThisFrame(ScrollingNodeID);
ScrollingNodeID attachScrollingNode(RenderLayer&, ScrollingNodeType, ScrollingNodeID parentNodeID);
- void updateScrollCoordinatedLayer(RenderLayer&, ScrollCoordinationReasons);
- void detachScrollCoordinatedLayer(RenderLayer&);
- void detachScrollCoordinatedLayerForRole(RenderLayer&, ScrollingNodeType);
+ void updateScrollCoordinatedLayer(RenderLayer&, LayerScrollCoordinationRoles);
+ void detachScrollCoordinatedLayer(RenderLayer&, LayerScrollCoordinationRoles);
void reattachSubframeScrollLayers();
FixedPositionViewportConstraints computeFixedViewportConstraints(RenderLayer&) const;