Changeset 182809 in webkit
- Timestamp:
- Apr 14, 2015, 2:14:07 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r182808 r182809 1 2015-04-14 Simon Fraser <simon.fraser@apple.com> 2 3 [iOS] Clean up registration of layers with the ScrollingCoordinator 4 https://bugs.webkit.org/show_bug.cgi?id=143725 5 6 Reviewed by Tim Horton. 7 8 Simplify a couple of bits of code related to the registration of layers with 9 the ScrollingCoordinator in RenderLayerCompositor. 10 11 First, RenderLayerBacking was using ScrollingNodeTypes to choose which scrolling 12 roles a layer has, which let to ambiguous code where we hardcoded a ScrollingNodeType 13 with knowledge of what RenderLayerBacking did with it. Clean up by using LayerScrollCoordinationRole, 14 which is moved to RenderLayer.h so that RenderLayerCompositor.h and RenderLayerBacking.h 15 both see it. 16 17 Secondly, avoid having both detachFromScrollingCoordinator() and detachFromScrollingCoordinatorForRole() 18 by passing in the bitmask of roles. 19 20 * page/FrameView.cpp: 21 (WebCore::FrameView::scrollLayerID): 22 * rendering/RenderLayer.h: 23 * rendering/RenderLayerBacking.cpp: 24 (WebCore::RenderLayerBacking::~RenderLayerBacking): 25 (WebCore::RenderLayerBacking::detachFromScrollingCoordinator): 26 (WebCore::RenderLayerBacking::detachFromScrollingCoordinatorForRole): Deleted. 27 * rendering/RenderLayerBacking.h: 28 * rendering/RenderLayerCompositor.cpp: 29 (WebCore::RenderLayerCompositor::updateScrollCoordinatedStatus): 30 (WebCore::RenderLayerCompositor::removeFromScrollCoordinatedLayers): 31 (WebCore::scrollCoordinationRoleForNodeType): 32 (WebCore::RenderLayerCompositor::attachScrollingNode): 33 (WebCore::RenderLayerCompositor::detachScrollCoordinatedLayer): 34 (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): 35 (WebCore::RenderLayerCompositor::willRemoveScrollingLayerWithBacking): 36 (WebCore::RenderLayerCompositor::detachScrollCoordinatedLayerForRole): Deleted. 37 * rendering/RenderLayerCompositor.h: 38 1 39 2015-04-14 Benjamin Poulain <benjamin@webkit.org> 2 40 -
trunk/Source/WebCore/page/FrameView.cpp
r182807 r182809 836 836 return 0; 837 837 838 return backing->scrollingNodeIDForRole( FrameScrollingNode);838 return backing->scrollingNodeIDForRole(Scrolling); 839 839 } 840 840 -
trunk/Source/WebCore/rendering/RenderLayer.h
r182345 r182809 105 105 }; 106 106 107 enum LayerScrollCoordinationRole { 108 ViewportConstrained = 1 << 0, 109 Scrolling = 1 << 1 110 }; 111 typedef unsigned LayerScrollCoordinationRoles; 112 107 113 class RenderLayer final : public ScrollableArea { 108 114 WTF_MAKE_FAST_ALLOCATED; -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r182799 r182809 152 152 updateMaskingLayer(false, false); 153 153 updateScrollingLayers(false); 154 detachFromScrollingCoordinator( );154 detachFromScrollingCoordinator(Scrolling | ViewportConstrained); 155 155 destroyGraphicsLayers(); 156 156 } … … 1552 1552 } 1553 1553 1554 void RenderLayerBacking::detachFromScrollingCoordinator( )1554 void RenderLayerBacking::detachFromScrollingCoordinator(LayerScrollCoordinationRoles roles) 1555 1555 { 1556 1556 if (!m_scrollingNodeID && !m_viewportConstrainedNodeID) … … 1561 1561 return; 1562 1562 1563 if ( m_scrollingNodeID)1563 if ((roles & Scrolling) && m_scrollingNodeID) { 1564 1564 scrollingCoordinator->detachFromStateTree(m_scrollingNodeID); 1565 1566 if (m_viewportConstrainedNodeID) 1565 m_scrollingNodeID = 0; 1566 } 1567 1568 if ((roles & ViewportConstrained) && m_viewportConstrainedNodeID) { 1567 1569 scrollingCoordinator->detachFromStateTree(m_viewportConstrainedNodeID); 1568 1569 m_scrollingNodeID = 0; 1570 m_viewportConstrainedNodeID = 0; 1571 } 1572 1573 void RenderLayerBacking::detachFromScrollingCoordinatorForRole(ScrollingNodeType role) 1574 { 1575 ScrollingNodeID nodeID = scrollingNodeIDForRole(role); 1576 if (!nodeID) 1577 return; 1578 1579 ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer); 1580 if (!scrollingCoordinator) 1581 return; 1582 1583 scrollingCoordinator->detachFromStateTree(nodeID); 1584 setScrollingNodeIDForRole(0, role); 1570 m_viewportConstrainedNodeID = 0; 1571 } 1585 1572 } 1586 1573 -
trunk/Source/WebCore/rendering/RenderLayerBacking.h
r182799 r182809 108 108 GraphicsLayer* scrollingContentsLayer() const { return m_scrollingContentsLayer.get(); } 109 109 110 void detachFromScrollingCoordinator(); 111 void detachFromScrollingCoordinatorForRole(ScrollingNodeType); 112 113 ScrollingNodeID scrollingNodeIDForRole(ScrollingNodeType nodeType) const 110 void detachFromScrollingCoordinator(LayerScrollCoordinationRoles); 111 112 ScrollingNodeID scrollingNodeIDForRole(LayerScrollCoordinationRole role) const 114 113 { 115 switch (nodeType) { 116 case FrameScrollingNode: 117 case OverflowScrollingNode: 114 switch (role) { 115 case Scrolling: 118 116 return m_scrollingNodeID; 119 case FixedNode: 120 case StickyNode: 117 case ViewportConstrained: 121 118 return m_viewportConstrainedNodeID; 122 119 } … … 124 121 } 125 122 126 void setScrollingNodeIDForRole(ScrollingNodeID nodeID, ScrollingNodeType nodeType)123 void setScrollingNodeIDForRole(ScrollingNodeID nodeID, LayerScrollCoordinationRole role) 127 124 { 128 switch (nodeType) { 129 case FrameScrollingNode: 130 case OverflowScrollingNode: 125 switch (role) { 126 case Scrolling: 131 127 m_scrollingNodeID = nodeID; 132 128 break; 133 case FixedNode: 134 case StickyNode: 129 case ViewportConstrained: 135 130 m_viewportConstrainedNodeID = nodeID; 136 131 break; -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r182799 r182809 3644 3644 void RenderLayerCompositor::updateScrollCoordinatedStatus(RenderLayer& layer) 3645 3645 { 3646 ScrollCoordinationReasons coordinationReasons = 0;3646 LayerScrollCoordinationRoles coordinationRoles = 0; 3647 3647 if (isViewportConstrainedFixedOrStickyLayer(layer)) 3648 coordinationR easons |= FixedOrSticky;3648 coordinationRoles |= ViewportConstrained; 3649 3649 3650 3650 if (useCoordinatedScrollingForLayer(m_renderView, layer)) 3651 coordinationR easons |= Scrolling;3652 3653 if (coordinationR easons) {3651 coordinationRoles |= Scrolling; 3652 3653 if (coordinationRoles) { 3654 3654 if (m_scrollCoordinatedLayers.add(&layer).isNewEntry) 3655 3655 m_subframeScrollLayersNeedReattach = true; 3656 3656 3657 updateScrollCoordinatedLayer(layer, coordinationR easons);3657 updateScrollCoordinatedLayer(layer, coordinationRoles); 3658 3658 } else 3659 3659 removeFromScrollCoordinatedLayers(layer); … … 3670 3670 m_scrollCoordinatedLayersNeedingUpdate.remove(&layer); 3671 3671 3672 detachScrollCoordinatedLayer(layer );3672 detachScrollCoordinatedLayer(layer, Scrolling | ViewportConstrained); 3673 3673 } 3674 3674 … … 3789 3789 scrollingCoordinator->attachToStateTree(FrameScrollingNode, frameScrollingNodeID, parentNodeID); 3790 3790 } 3791 } 3792 3793 static inline LayerScrollCoordinationRole scrollCoordinationRoleForNodeType(ScrollingNodeType nodeType) 3794 { 3795 switch (nodeType) { 3796 case FrameScrollingNode: 3797 case OverflowScrollingNode: 3798 return Scrolling; 3799 case FixedNode: 3800 case StickyNode: 3801 return ViewportConstrained; 3802 } 3803 ASSERT_NOT_REACHED(); 3804 return Scrolling; 3791 3805 } 3792 3806 … … 3800 3814 return 0; 3801 3815 3802 ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(nodeType); 3816 LayerScrollCoordinationRole role = scrollCoordinationRoleForNodeType(nodeType); 3817 ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(role); 3803 3818 if (!nodeID) 3804 3819 nodeID = scrollingCoordinator->uniqueScrollLayerID(); … … 3808 3823 return 0; 3809 3824 3810 backing->setScrollingNodeIDForRole(nodeID, nodeType);3825 backing->setScrollingNodeIDForRole(nodeID, role); 3811 3826 m_scrollingNodeToLayerMap.add(nodeID, &layer); 3812 3827 … … 3814 3829 } 3815 3830 3816 void RenderLayerCompositor::detachScrollCoordinatedLayer ForRole(RenderLayer& layer, ScrollingNodeType role)3831 void RenderLayerCompositor::detachScrollCoordinatedLayer(RenderLayer& layer, LayerScrollCoordinationRoles roles) 3817 3832 { 3818 3833 RenderLayerBacking* backing = layer.backing(); … … 3820 3835 return; 3821 3836 3822 if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(role)) 3823 m_scrollingNodeToLayerMap.remove(nodeID); 3824 3825 backing->detachFromScrollingCoordinatorForRole(role); 3826 } 3827 3828 void RenderLayerCompositor::detachScrollCoordinatedLayer(RenderLayer& layer) 3829 { 3830 RenderLayerBacking* backing = layer.backing(); 3831 if (!backing) 3832 return; 3833 3834 if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(FrameScrollingNode)) 3835 m_scrollingNodeToLayerMap.remove(nodeID); 3836 3837 if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(FixedNode)) 3838 m_scrollingNodeToLayerMap.remove(nodeID); 3839 3840 backing->detachFromScrollingCoordinator(); 3837 if (roles & Scrolling) { 3838 if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(Scrolling)) 3839 m_scrollingNodeToLayerMap.remove(nodeID); 3840 } 3841 3842 if (roles & ViewportConstrained) { 3843 if (ScrollingNodeID nodeID = backing->scrollingNodeIDForRole(ViewportConstrained)) 3844 m_scrollingNodeToLayerMap.remove(nodeID); 3845 } 3846 3847 backing->detachFromScrollingCoordinator(roles); 3841 3848 } 3842 3849 … … 3850 3857 } 3851 3858 3852 void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, ScrollCoordinationReasons reasons)3859 void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, LayerScrollCoordinationRoles reasons) 3853 3860 { 3854 3861 ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator(); … … 3875 3882 3876 3883 updateScrollCoordinationForThisFrame(parentDocumentHostingNodeID); 3877 if (!(reasons & FixedOrSticky) && isRootLayer)3884 if (!(reasons & ViewportConstrained) && isRootLayer) 3878 3885 return; 3879 3886 } … … 3885 3892 // Always call this even if the backing is already attached because the parent may have changed. 3886 3893 // If a node plays both roles, fixed/sticky is always the ancestor node of scrolling. 3887 if (reasons & FixedOrSticky) {3894 if (reasons & ViewportConstrained) { 3888 3895 ScrollingNodeType nodeType = FrameScrollingNode; 3889 3896 if (layer.renderer().style().position() == FixedPosition) … … 3912 3919 parentNodeID = nodeID; 3913 3920 } else 3914 detachScrollCoordinatedLayer ForRole(layer, FixedNode);3921 detachScrollCoordinatedLayer(layer, ViewportConstrained); 3915 3922 3916 3923 if (reasons & Scrolling) { … … 3938 3945 } 3939 3946 } else 3940 detachScrollCoordinatedLayer ForRole(layer, OverflowScrollingNode);3947 detachScrollCoordinatedLayer(layer, Scrolling); 3941 3948 } 3942 3949 … … 4031 4038 { 4032 4039 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) { 4033 backing.detachFromScrollingCoordinator( );4040 backing.detachFromScrollingCoordinator(Scrolling); 4034 4041 4035 4042 // For Coordinated Graphics. -
trunk/Source/WebCore/rendering/RenderLayerCompositor.h
r182799 r182809 425 425 #endif 426 426 427 enum ScrollCoordinationReason {428 FixedOrSticky = 1 << 0,429 Scrolling = 1 << 1430 };431 typedef unsigned ScrollCoordinationReasons;432 433 427 void updateScrollCoordinationForThisFrame(ScrollingNodeID); 434 428 ScrollingNodeID attachScrollingNode(RenderLayer&, ScrollingNodeType, ScrollingNodeID parentNodeID); 435 void updateScrollCoordinatedLayer(RenderLayer&, ScrollCoordinationReasons); 436 void detachScrollCoordinatedLayer(RenderLayer&); 437 void detachScrollCoordinatedLayerForRole(RenderLayer&, ScrollingNodeType); 429 void updateScrollCoordinatedLayer(RenderLayer&, LayerScrollCoordinationRoles); 430 void detachScrollCoordinatedLayer(RenderLayer&, LayerScrollCoordinationRoles); 438 431 void reattachSubframeScrollLayers(); 439 432
Note:
See TracChangeset
for help on using the changeset viewer.