Changeset 164759 in webkit
- Timestamp:
- Feb 26, 2014, 5:04:23 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r164757 r164759 1 2014-02-26 Simon Fraser <simon.fraser@apple.com> 2 3 Prepare for overflow scrolling nodes in the scrolling tree 4 https://bugs.webkit.org/show_bug.cgi?id=129398 5 6 Reviewed by Tim Horton. 7 8 Lay some groundwork for overflow:scrolling nodes in the scrolling tree. 9 Change terminology to refer to "scroll-coordinatored" layers now, not just viewport-constrained 10 layers. 11 12 A given layer can be both viewport-constrained and overflow-scrolling (e.g. position:fixed, 13 overflow:scroll), so handle that in RenderLayerBacking, and use some "reason" flags 14 in RenderLayerCompositor. 15 16 * page/FrameView.cpp: 17 (WebCore::FrameView::scrollLayerID): Rename 18 * page/scrolling/ScrollingStateTree.cpp: 19 (WebCore::ScrollingStateTree::attachNode): Remove invalid assertion. 20 * rendering/RenderLayerBacking.cpp: 21 (WebCore::RenderLayerBacking::RenderLayerBacking): 22 (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry): 23 (WebCore::RenderLayerBacking::updateScrollingLayers): Simplify the logic with 24 an early return. 25 (WebCore::RenderLayerBacking::detachFromScrollingCoordinator): 26 Allow a layer to play both viewport-constrained and scrolling roles 27 in the scrolling tree. 28 * rendering/RenderLayerBacking.h: 29 (WebCore::RenderLayerBacking::viewportConstrainedNodeID): 30 (WebCore::RenderLayerBacking::setViewportConstrainedNodeID): 31 (WebCore::RenderLayerBacking::scrollingNodeID): 32 (WebCore::RenderLayerBacking::setScrollingNodeID): 33 (WebCore::RenderLayerBacking::scrollingNodeIDForChildren): 34 * rendering/RenderLayerCompositor.cpp: 35 (WebCore::RenderLayerCompositor::flushPendingLayerChanges): 36 (WebCore::RenderLayerCompositor::didFlushChangesForLayer): 37 (WebCore::RenderLayerCompositor::updateBacking): 38 (WebCore::RenderLayerCompositor::layerWillBeRemoved): 39 (WebCore::RenderLayerCompositor::fixedRootBackgroundLayerChanged): 40 (WebCore::RenderLayerCompositor::clearBackingForLayerIncludingDescendants): 41 (WebCore::RenderLayerCompositor::requiresCompositingLayer): 42 (WebCore::RenderLayerCompositor::requiresOwnBackingStore): 43 (WebCore::RenderLayerCompositor::reasonsForCompositing): 44 (WebCore::RenderLayerCompositor::requiresCompositingForScrolling): 45 (WebCore::isViewportConstrainedFixedOrStickyLayer): 46 (WebCore::isMainFrameScrollingOrOverflowScrolling): 47 (WebCore::RenderLayerCompositor::rootLayerAttachmentChanged): 48 (WebCore::RenderLayerCompositor::updateScrollCoordinatedStatus): 49 (WebCore::RenderLayerCompositor::removeFromScrollCoordinatedLayers): 50 (WebCore::nearestScrollCoordinatedAncestor): 51 (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): 52 (WebCore::RenderLayerCompositor::detachScrollCoordinatedLayer): 53 (WebCore::RenderLayerCompositor::registerAllViewportConstrainedLayers): 54 (WebCore::RenderLayerCompositor::willRemoveScrollingLayer): 55 (WebCore::RenderLayerCompositor::didAddScrollingLayer): 56 * rendering/RenderLayerCompositor.h: 57 1 58 2014-02-26 Andy Estes <aestes@apple.com> 2 59 -
trunk/Source/WebCore/page/FrameView.cpp
r164697 r164759 815 815 return 0; 816 816 817 return backing->scroll LayerID();817 return backing->scrollingNodeID(); 818 818 } 819 819 -
trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp
r161315 r164759 109 109 } 110 110 case ScrollingNode: { 111 // FIXME: We currently only support child nodes that are fixed.112 ASSERT_NOT_REACHED();113 111 OwnPtr<ScrollingStateScrollingNode> scrollingNode = ScrollingStateScrollingNode::create(*this, newNodeID); 114 112 newNode = scrollingNode.get(); -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r164532 r164759 110 110 RenderLayerBacking::RenderLayerBacking(RenderLayer& layer) 111 111 : m_owningLayer(layer) 112 , m_scrollLayerID(0) 112 , m_viewportConstrainedNodeID(0) 113 , m_scrollingNodeID(0) 113 114 , m_artificiallyInflatedBounds(false) 114 115 , m_isMainFrameRenderViewLayer(false) … … 952 953 // Scrolling the content layer does not need to trigger a repaint. The offset will be compensated away during painting. 953 954 // FIXME: The paint offset and the scroll offset should really be separate concepts. 954 m_scrollingContentsLayer->setOffsetFromRenderer(paddingBox.location() - FloatPoint() - scrollOffset, GraphicsLayer::DontSetNeedsDisplay); 955 956 compositor().scrollingLayerAddedOrUpdated(&m_owningLayer); 955 m_scrollingContentsLayer->setOffsetFromRenderer(paddingBox.location() - IntPoint() - scrollOffset, GraphicsLayer::DontSetNeedsDisplay); 957 956 #else 958 957 m_scrollingContentsLayer->setPosition(FloatPoint(-scrollOffset.width(), -scrollOffset.height())); … … 993 992 updateAfterWidgetResize(); 994 993 995 compositor().update ViewportConstraintStatus(m_owningLayer);994 compositor().updateScrollCoordinatedStatus(m_owningLayer); 996 995 } 997 996 … … 1424 1423 bool RenderLayerBacking::updateScrollingLayers(bool needsScrollingLayers) 1425 1424 { 1426 ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer); 1427 1428 bool layerChanged = false; 1429 if (needsScrollingLayers) { 1430 if (!m_scrollingLayer) { 1431 // Outer layer which corresponds with the scroll view. 1432 m_scrollingLayer = createGraphicsLayer("Scrolling container"); 1433 m_scrollingLayer->setDrawsContent(false); 1434 m_scrollingLayer->setMasksToBounds(true); 1435 1436 // Inner layer which renders the content that scrolls. 1437 m_scrollingContentsLayer = createGraphicsLayer("Scrolled Contents"); 1438 m_scrollingContentsLayer->setDrawsContent(true); 1439 GraphicsLayerPaintingPhase paintPhase = GraphicsLayerPaintOverflowContents | GraphicsLayerPaintCompositedScroll; 1440 if (!m_foregroundLayer) 1441 paintPhase |= GraphicsLayerPaintForeground; 1442 m_scrollingContentsLayer->setPaintingPhase(paintPhase); 1443 m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); 1444 1445 layerChanged = true; 1446 if (scrollingCoordinator) 1447 scrollingCoordinator->scrollableAreaScrollLayerDidChange(&m_owningLayer); 1448 #if PLATFORM(IOS) 1449 if (m_owningLayer.parent()) 1450 compositor().scrollingLayerAddedOrUpdated(&m_owningLayer); 1451 #endif 1452 } 1453 } else if (m_scrollingLayer) { 1454 #if PLATFORM(IOS) 1455 if (!renderer().documentBeingDestroyed()) 1456 compositor().scrollingLayerRemoved(&m_owningLayer, m_scrollingLayer->platformLayer(), m_scrollingContentsLayer->platformLayer()); 1457 #endif 1425 if (needsScrollingLayers == !!m_scrollingLayer) 1426 return false; 1427 1428 if (!m_scrollingLayer) { 1429 // Outer layer which corresponds with the scroll view. 1430 m_scrollingLayer = createGraphicsLayer("Scrolling container"); 1431 m_scrollingLayer->setDrawsContent(false); 1432 m_scrollingLayer->setMasksToBounds(true); 1433 1434 // Inner layer which renders the content that scrolls. 1435 m_scrollingContentsLayer = createGraphicsLayer("Scrolled Contents"); 1436 m_scrollingContentsLayer->setDrawsContent(true); 1437 GraphicsLayerPaintingPhase paintPhase = GraphicsLayerPaintOverflowContents | GraphicsLayerPaintCompositedScroll; 1438 if (!m_foregroundLayer) 1439 paintPhase |= GraphicsLayerPaintForeground; 1440 m_scrollingContentsLayer->setPaintingPhase(paintPhase); 1441 m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); 1442 } else { 1443 compositor().willRemoveScrollingLayer(m_owningLayer); 1444 1458 1445 willDestroyLayer(m_scrollingLayer.get()); 1459 1446 willDestroyLayer(m_scrollingContentsLayer.get()); 1460 1447 m_scrollingLayer = nullptr; 1461 1448 m_scrollingContentsLayer = nullptr; 1462 layerChanged = true; 1463 if (scrollingCoordinator) 1464 scrollingCoordinator->scrollableAreaScrollLayerDidChange(&m_owningLayer); 1465 } 1466 1467 if (layerChanged) { 1468 updateInternalHierarchy(); 1469 m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer()); 1470 #if !PLATFORM(IOS) 1471 m_graphicsLayer->setNeedsDisplay(); 1472 compositor().scrollingLayerDidChange(m_owningLayer); 1473 #endif 1474 } 1475 1476 return layerChanged; 1477 } 1478 1479 void RenderLayerBacking::attachToScrollingCoordinatorWithParent(RenderLayerBacking* parent) 1480 { 1449 } 1450 1451 updateInternalHierarchy(); 1452 m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer()); 1453 m_graphicsLayer->setNeedsDisplay(); // Because painting phases changed. 1454 1455 if (m_scrollingLayer) 1456 compositor().didAddScrollingLayer(m_owningLayer); 1457 1458 return true; 1459 } 1460 1461 void RenderLayerBacking::detachFromScrollingCoordinator() 1462 { 1463 if (!m_scrollingNodeID && !m_viewportConstrainedNodeID) 1464 return; 1465 1481 1466 ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer); 1482 1467 if (!scrollingCoordinator) 1483 1468 return; 1484 1469 1485 // FIXME: When we support overflow areas, we will have to refine this for overflow areas that are also 1486 // positon:fixed. 1487 ScrollingNodeType nodeType; 1488 if (renderer().style().position() == FixedPosition) 1489 nodeType = FixedNode; 1490 else if (renderer().style().position() == StickyPosition) 1491 nodeType = StickyNode; 1492 else 1493 nodeType = ScrollingNode; 1494 1495 ScrollingNodeID parentID = parent ? parent->scrollLayerID() : 0; 1496 m_scrollLayerID = scrollingCoordinator->attachToStateTree(nodeType, m_scrollLayerID ? m_scrollLayerID : scrollingCoordinator->uniqueScrollLayerID(), parentID); 1497 } 1498 1499 void RenderLayerBacking::detachFromScrollingCoordinator() 1500 { 1501 // If m_scrollLayerID is 0, then this backing is not attached to the ScrollingCoordinator. 1502 if (!m_scrollLayerID) 1503 return; 1504 1505 ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer); 1506 if (!scrollingCoordinator) 1507 return; 1508 1509 scrollingCoordinator->detachFromStateTree(m_scrollLayerID); 1510 m_scrollLayerID = 0; 1470 if (m_scrollingNodeID) 1471 scrollingCoordinator->detachFromStateTree(m_scrollingNodeID); 1472 1473 if (m_viewportConstrainedNodeID) 1474 scrollingCoordinator->detachFromStateTree(m_viewportConstrainedNodeID); 1475 1476 m_scrollingNodeID = 0; 1477 m_viewportConstrainedNodeID = 0; 1511 1478 } 1512 1479 -
trunk/Source/WebCore/rendering/RenderLayerBacking.h
r164532 r164759 32 32 #include "GraphicsLayerClient.h" 33 33 #include "RenderLayer.h" 34 #include "ScrollingCoordinator.h" 34 35 35 36 namespace WebCore { … … 102 103 GraphicsLayer* scrollingContentsLayer() const { return m_scrollingContentsLayer.get(); } 103 104 104 void attachToScrollingCoordinatorWithParent(RenderLayerBacking* parent);105 105 void detachFromScrollingCoordinator(); 106 uint64_t scrollLayerID() const { return m_scrollLayerID; } 107 106 107 ScrollingNodeID viewportConstrainedNodeID() const { return m_viewportConstrainedNodeID; } 108 void setViewportConstrainedNodeID(ScrollingNodeID nodeID) { m_viewportConstrainedNodeID = nodeID; } 109 110 ScrollingNodeID scrollingNodeID() const { return m_scrollingNodeID; } 111 void setScrollingNodeID(ScrollingNodeID nodeID) { m_scrollingNodeID = nodeID; } 112 113 ScrollingNodeID scrollingNodeIDForChildren() const { return m_scrollingNodeID ? m_scrollingNodeID : m_viewportConstrainedNodeID; } 114 108 115 bool hasMaskLayer() const { return m_maskLayer != 0; } 109 116 … … 309 316 std::unique_ptr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is using composited scrolling. 310 317 311 uint64_t m_scrollLayerID; 318 ScrollingNodeID m_viewportConstrainedNodeID; 319 ScrollingNodeID m_scrollingNodeID; 312 320 313 321 LayoutRect m_compositedBounds; -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r164699 r164759 440 440 #endif 441 441 442 for (auto it = m_ viewportConstrainedLayersNeedingUpdate.begin(), end = m_viewportConstrainedLayersNeedingUpdate.end(); it != end; ++it)443 registerOrUpdateViewportConstrainedLayer(**it);444 445 m_ viewportConstrainedLayersNeedingUpdate.clear();442 for (auto it = m_scrollCoordinatedLayersNeedingUpdate.begin(), end = m_scrollCoordinatedLayersNeedingUpdate.end(); it != end; ++it) 443 updateScrollCoordinatedStatus(**it); 444 445 m_scrollCoordinatedLayersNeedingUpdate.clear(); 446 446 startLayerFlushTimerIfNeeded(); 447 447 } … … 489 489 void RenderLayerCompositor::didFlushChangesForLayer(RenderLayer& layer, const GraphicsLayer* graphicsLayer) 490 490 { 491 if (m_ viewportConstrainedLayers.contains(&layer))492 m_ viewportConstrainedLayersNeedingUpdate.add(&layer);491 if (m_scrollCoordinatedLayers.contains(&layer)) 492 m_scrollCoordinatedLayersNeedingUpdate.add(&layer); 493 493 494 494 #if PLATFORM(IOS) … … 775 775 // At this time, the ScrollingCoordinator only supports the top-level frame. 776 776 if (layer.isRootLayer() && !m_renderView.document().ownerElement()) { 777 layer.backing()->attachToScrollingCoordinatorWithParent(0);777 updateScrollCoordinatedStatus(layer); 778 778 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) 779 779 scrollingCoordinator->frameViewRootLayerDidChange(&m_renderView.frameView()); … … 808 808 } 809 809 810 removeViewportConstrainedLayer(layer);810 detachScrollCoordinatedLayer(layer); 811 811 812 812 layer.clearBacking(); … … 931 931 return; 932 932 933 remove ViewportConstrainedLayer(child);933 removeFromScrollCoordinatedLayers(child); 934 934 repaintInCompositedAncestor(child, child.backing()->compositedBounds()); 935 935 … … 1560 1560 return; 1561 1561 1562 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) { 1563 RenderLayerBacking* renderViewBacking = m_renderView.layer()->backing(); 1564 if (!renderViewBacking) 1565 return; 1566 1567 scrollingCoordinator->updateScrollingNode(renderViewBacking->scrollLayerID(), scrollLayer(), nullptr, fixedRootBackgroundLayer()); 1568 } 1562 if (m_renderView.layer()->isComposited()) 1563 updateScrollCoordinatedStatus(*m_renderView.layer()); 1569 1564 } 1570 1565 … … 1868 1863 { 1869 1864 if (layer.isComposited()) { 1870 remove ViewportConstrainedLayer(layer);1865 removeFromScrollCoordinatedLayers(layer); 1871 1866 layer.clearBacking(); 1872 1867 } … … 1986 1981 || requiresCompositingForPosition(*renderer, *renderer->layer(), viewportConstrainedNotCompositedReason) 1987 1982 #if PLATFORM(IOS) 1988 || requiresCompositingForScrolling(*renderer )1983 || requiresCompositingForScrolling(*renderer->layer()) 1989 1984 #endif 1990 1985 || requiresCompositingForOverflowScrolling(*renderer->layer()); … … 2034 2029 || renderer.hasFilter() 2035 2030 #if PLATFORM(IOS) 2036 || requiresCompositingForScrolling( renderer)2031 || requiresCompositingForScrolling(layer) 2037 2032 #endif 2038 2033 ) … … 2094 2089 2095 2090 #if PLATFORM(IOS) 2096 if (requiresCompositingForScrolling(*renderer ))2091 if (requiresCompositingForScrolling(*renderer->layer())) 2097 2092 reasons |= CompositingReasonOverflowScrollingTouch; 2098 2093 #endif … … 2417 2412 2418 2413 #if PLATFORM(IOS) 2419 bool RenderLayerCompositor::requiresCompositingForScrolling( RenderLayerModelObject& renderer) const2420 { 2421 return renderer.hasLayer() && toRenderBoxModelObject(renderer).layer()->hasAcceleratedTouchScrolling();2414 bool RenderLayerCompositor::requiresCompositingForScrolling(const RenderLayer& layer) const 2415 { 2416 return layer.hasAcceleratedTouchScrolling(); 2422 2417 } 2423 2418 #endif … … 2465 2460 return false; 2466 2461 2462 // FIXME: Handle fixed inside of a transform, which should not behave as fixed. 2467 2463 for (RenderLayer* stackingContainer = layer.stackingContainer(); stackingContainer; stackingContainer = stackingContainer->stackingContainer()) { 2468 2464 if (stackingContainer->isComposited() && stackingContainer->renderer().style().position() == FixedPosition) … … 2471 2467 2472 2468 return true; 2469 } 2470 2471 static bool isMainFrameScrollingOrOverflowScrolling(RenderView& view, const RenderLayer& layer) 2472 { 2473 if (layer.isRootLayer() && !view.document().ownerElement()) 2474 return true; 2475 2476 #if PLATFORM(IOS) 2477 return layer.hasAcceleratedTouchScrolling(); 2478 #else 2479 return layer.needsCompositedScrolling(); 2480 #endif 2473 2481 } 2474 2482 … … 3269 3277 { 3270 3278 // The attachment can affect whether the RenderView layer's paintsIntoWindow() behavior, 3271 // so call update GraphicsLayerGeometry() to udpate that.3279 // so call updateDrawsContent() to update that. 3272 3280 RenderLayer* layer = m_renderView.layer(); 3273 3281 if (RenderLayerBacking* backing = layer ? layer->backing() : 0) … … 3343 3351 } 3344 3352 3345 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer& layer) 3346 { 3353 void RenderLayerCompositor::updateScrollCoordinatedStatus(RenderLayer& layer) 3354 { 3355 ScrollCoordinationReasons coordinationReasons = 0; 3347 3356 if (isViewportConstrainedFixedOrStickyLayer(layer)) 3348 addViewportConstrainedLayer(layer); 3349 else 3350 removeViewportConstrainedLayer(layer); 3351 } 3352 3353 void RenderLayerCompositor::addViewportConstrainedLayer(RenderLayer& layer) 3354 { 3355 m_viewportConstrainedLayers.add(&layer); 3356 registerOrUpdateViewportConstrainedLayer(layer); 3357 } 3358 3359 void RenderLayerCompositor::removeViewportConstrainedLayer(RenderLayer& layer) 3360 { 3361 if (!m_viewportConstrainedLayers.contains(&layer)) 3362 return; 3363 3364 unregisterViewportConstrainedLayer(layer); 3365 m_viewportConstrainedLayers.remove(&layer); 3366 m_viewportConstrainedLayersNeedingUpdate.remove(&layer); 3357 coordinationReasons |= FixedOrSticky; 3358 3359 if (isMainFrameScrollingOrOverflowScrolling(m_renderView, layer)) 3360 coordinationReasons |= Scrolling; 3361 3362 if (coordinationReasons) { 3363 m_scrollCoordinatedLayers.add(&layer); 3364 updateScrollCoordinatedLayer(layer, coordinationReasons); 3365 } else 3366 removeFromScrollCoordinatedLayers(layer); 3367 } 3368 3369 void RenderLayerCompositor::removeFromScrollCoordinatedLayers(RenderLayer& layer) 3370 { 3371 if (!m_scrollCoordinatedLayers.contains(&layer)) 3372 return; 3373 3374 removeFromScrollCoordinatedLayers(layer); 3375 m_scrollCoordinatedLayers.remove(&layer); 3376 m_scrollCoordinatedLayersNeedingUpdate.remove(&layer); 3367 3377 } 3368 3378 … … 3425 3435 } 3426 3436 3427 static RenderLayerBacking* nearestScroll ingCoordinatorAncestor(RenderLayer& layer)3437 static RenderLayerBacking* nearestScrollCoordinatedAncestor(RenderLayer& layer) 3428 3438 { 3429 3439 RenderLayer* ancestor = layer.parent(); 3430 3440 while (ancestor) { 3431 3441 if (RenderLayerBacking* backing = ancestor->backing()) { 3432 if (backing->scroll LayerID() && !ancestor->scrollsOverflow())3442 if (backing->scrollingNodeIDForChildren()) 3433 3443 return backing; 3434 3444 } … … 3439 3449 } 3440 3450 3441 void RenderLayerCompositor::registerOrUpdateViewportConstrainedLayer(RenderLayer& layer) 3442 { 3443 // FIXME: We should support sticky position here! And we should eventuall support fixed/sticky elements 3444 // that are inside non-main frames once we get non-main frames scrolling with the ScrollingCoordinator. 3451 void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, ScrollCoordinationReasons reasons) 3452 { 3453 // FIXME: support scrolling layers in iframes. 3445 3454 if (m_renderView.document().ownerElement()) 3446 3455 return; … … 3449 3458 if (!scrollingCoordinator) 3450 3459 return; 3451 3452 // FIXME: rename to supportsViewportConstrainedPositionLayers()? 3453 if (!scrollingCoordinator->supportsFixedPositionLayers() || !layer.parent()) 3454 return; 3455 3456 ASSERT(m_viewportConstrainedLayers.contains(&layer)); 3460 3461 bool isRootLayer = &layer == m_renderView.layer(); 3462 3463 // FIXME: Remove supportsFixedPositionLayers() since all platforms support them now. 3464 if (!scrollingCoordinator->supportsFixedPositionLayers() || (!layer.parent() && !isRootLayer)) 3465 return; 3466 3467 ASSERT(m_scrollCoordinatedLayers.contains(&layer)); 3457 3468 ASSERT(layer.isComposited()); 3458 3469 … … 3461 3472 return; 3462 3473 3463 ScrollingNodeID nodeID = backing->scrollLayerID(); 3464 RenderLayerBacking* parent = nearestScrollingCoordinatorAncestor(layer); 3465 if (!parent) 3466 return; 3467 3474 RenderLayerBacking* parent = nearestScrollCoordinatedAncestor(layer); 3475 if (!parent && !isRootLayer) 3476 return; 3477 3478 ScrollingNodeID parentNodeID = parent ? parent->scrollingNodeIDForChildren() : 0; 3479 3468 3480 // Always call this even if the backing is already attached because the parent may have changed. 3469 backing->attachToScrollingCoordinatorWithParent(parent); 3470 nodeID = backing->scrollLayerID(); 3471 3472 if (layer.renderer().isStickyPositioned()) 3473 scrollingCoordinator->updateViewportConstrainedNode(nodeID, computeStickyViewportConstraints(layer), backing->graphicsLayer()); 3474 else 3475 scrollingCoordinator->updateViewportConstrainedNode(nodeID, computeFixedViewportConstraints(layer), backing->graphicsLayer()); 3476 } 3477 3478 void RenderLayerCompositor::unregisterViewportConstrainedLayer(RenderLayer& layer) 3479 { 3480 ASSERT(m_viewportConstrainedLayers.contains(&layer)); 3481 // If a node plays both roles, fixed/sticky is always the ancestor node of scrolling. 3482 if (reasons & FixedOrSticky) { 3483 ScrollingNodeID nodeID = backing->viewportConstrainedNodeID(); 3484 if (!nodeID) 3485 nodeID = scrollingCoordinator->uniqueScrollLayerID(); 3486 3487 ScrollingNodeType nodeType = ScrollingNode; 3488 if (layer.renderer().style().position() == FixedPosition) 3489 nodeType = FixedNode; 3490 else if (layer.renderer().style().position() == StickyPosition) 3491 nodeType = StickyNode; 3492 else 3493 ASSERT_NOT_REACHED(); 3494 3495 nodeID = scrollingCoordinator->attachToStateTree(nodeType, nodeID, parentNodeID); 3496 backing->setViewportConstrainedNodeID(nodeID); 3497 3498 switch (nodeType) { 3499 case FixedNode: 3500 scrollingCoordinator->updateViewportConstrainedNode(nodeID, computeFixedViewportConstraints(layer), backing->graphicsLayer()); 3501 break; 3502 case StickyNode: 3503 scrollingCoordinator->updateViewportConstrainedNode(nodeID, computeStickyViewportConstraints(layer), backing->graphicsLayer()); 3504 break; 3505 case ScrollingNode: 3506 break; 3507 } 3508 3509 parentNodeID = nodeID; 3510 } 3511 3512 if (reasons & Scrolling) { 3513 ScrollingNodeID nodeID = backing->scrollingNodeID(); 3514 if (!nodeID) 3515 nodeID = scrollingCoordinator->uniqueScrollLayerID(); 3516 3517 nodeID = scrollingCoordinator->attachToStateTree(ScrollingNode, nodeID, parentNodeID); 3518 backing->setScrollingNodeID(nodeID); 3519 3520 GraphicsLayer* scrollingLayer = backing->scrollingLayer(); 3521 GraphicsLayer* scrolledContentsLayer = backing->scrollingContentsLayer(); 3522 GraphicsLayer* counterScrollingLayer = nullptr; 3523 3524 if (&layer == m_renderView.layer()) { 3525 scrollingLayer = m_scrollLayer.get(); 3526 scrolledContentsLayer = nullptr; 3527 counterScrollingLayer = fixedRootBackgroundLayer(); 3528 } 3529 3530 scrollingCoordinator->updateScrollingNode(nodeID, scrollingLayer, scrolledContentsLayer, counterScrollingLayer); 3531 } 3532 } 3533 3534 void RenderLayerCompositor::detachScrollCoordinatedLayer(RenderLayer& layer) 3535 { 3536 ASSERT(m_scrollCoordinatedLayers.contains(&layer)); 3481 3537 3482 3538 if (RenderLayerBacking* backing = layer.backing()) … … 3500 3556 StickyContainerMap stickyContainerMap; 3501 3557 3502 for (auto it = m_ viewportConstrainedLayers.begin(), end = m_viewportConstrainedLayers.end(); it != end; ++it) {3558 for (auto it = m_scrollCoordinatedLayers.begin(), end = m_scrollCoordinatedLayers.end(); it != end; ++it) { 3503 3559 RenderLayer& layer = **it; 3504 3560 ASSERT(layer.isComposited()); … … 3512 3568 stickyContainerMap.add(layer.backing()->graphicsLayer()->platformLayer(), enclosingTouchScrollableLayer->backing()->scrollingLayer()->platformLayer()); 3513 3569 } 3514 } else 3570 } else if (layer.renderer().style().position() == FixedPosition) 3515 3571 constraints = std::make_unique<FixedPositionViewportConstraints>(computeFixedViewportConstraints(layer)); 3572 else 3573 continue; 3516 3574 3517 3575 layerMap.add(layer.backing()->graphicsLayer()->platformLayer(), adoptPtr(constraints.release())); … … 3561 3619 } 3562 3620 } 3563 3564 // Called when the size of the contentsLayer changes, and when the contentsLayer is replaced by another layer. 3565 void RenderLayerCompositor::scrollingLayerAddedOrUpdated(RenderLayer* layer) 3566 { 3621 #endif 3622 3623 void RenderLayerCompositor::willRemoveScrollingLayer(RenderLayer& layer) 3624 { 3625 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) { 3626 RenderLayerBacking* backing = layer.backing(); 3627 3628 if (backing) 3629 scrollingCoordinator->detachFromStateTree(backing->scrollingNodeID()); 3630 3631 // For Coordinated Graphics. 3632 scrollingCoordinator->scrollableAreaScrollLayerDidChange(&layer); 3633 return; 3634 } 3635 3636 #if PLATFORM(IOS) 3637 m_scrollingLayersNeedingUpdate.remove(&layer); 3638 m_scrollingLayers.remove(&layer); 3639 3640 if (m_renderView.document().inPageCache() || !layer.backing()) 3641 return; 3642 3643 if (ChromeClient* client = this->chromeClient()) { 3644 PlatformLayer* scrollingLayer = layer.backing()->scrollingLayer()->platformLayer(); 3645 PlatformLayer* contentsLayer = layer.backing()->scrollingContentsLayer()->platformLayer(); 3646 client->removeScrollingLayer(layer.renderer().element(), scrollingLayer, contentsLayer); 3647 } 3648 #endif 3649 } 3650 3651 void RenderLayerCompositor::didAddScrollingLayer(RenderLayer& layer) 3652 { 3653 updateScrollCoordinatedStatus(layer); 3654 3655 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) { 3656 // For Coordinated Graphics. 3657 scrollingCoordinator->scrollableAreaScrollLayerDidChange(&layer); 3658 return; 3659 } 3660 3661 #if PLATFORM(IOS) 3567 3662 ASSERT(!m_renderView.document().inPageCache()); 3568 m_scrollingLayers.add(layer); 3569 } 3570 3571 void RenderLayerCompositor::scrollingLayerRemoved(RenderLayer* layer, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer) 3572 { 3573 m_scrollingLayersNeedingUpdate.remove(layer); 3574 m_scrollingLayers.remove(layer); 3575 3576 if (m_renderView.document().inPageCache()) 3577 return; 3578 3579 if (ChromeClient* client = this->chromeClient()) 3580 client->removeScrollingLayer(layer->renderer().element(), scrollingLayer, contentsLayer); 3581 } 3582 #endif 3663 m_scrollingLayers.add(&layer); 3664 #endif 3665 } 3583 3666 3584 3667 void RenderLayerCompositor::windowScreenDidChange(PlatformDisplayID displayID) -
trunk/Source/WebCore/rendering/RenderLayerCompositor.h
r164699 r164759 267 267 #endif 268 268 269 void updateViewportConstraintStatus(RenderLayer&); 270 void removeViewportConstrainedLayer(RenderLayer&); 269 void updateScrollCoordinatedStatus(RenderLayer&); 270 void removeFromScrollCoordinatedLayers(RenderLayer&); 271 272 void willRemoveScrollingLayer(RenderLayer&); 273 void didAddScrollingLayer(RenderLayer&); 271 274 272 275 #if PLATFORM(IOS) … … 274 277 void unregisterAllViewportConstrainedLayers(); 275 278 276 void scrollingLayerAddedOrUpdated(RenderLayer*);277 void scrollingLayerRemoved(RenderLayer*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer);278 279 279 void registerAllScrollingLayers(); 280 280 void unregisterAllScrollingLayers(); 281 281 #endif 282 282 283 void resetTrackedRepaintRects(); 283 284 void setTracksRepaints(bool); … … 396 397 397 398 #if PLATFORM(IOS) 398 bool requiresCompositingForScrolling( RenderLayerModelObject&) const;399 bool requiresCompositingForScrolling(const RenderLayer&) const; 399 400 400 401 void updateCustomLayersAfterFlush(); … … 404 405 #endif 405 406 406 void addViewportConstrainedLayer(RenderLayer&); 407 void registerOrUpdateViewportConstrainedLayer(RenderLayer&); 408 void unregisterViewportConstrainedLayer(RenderLayer&); 407 enum ScrollCoordinationReason { 408 FixedOrSticky = 1 << 0, 409 Scrolling = 1 << 1 410 }; 411 typedef unsigned ScrollCoordinationReasons; 412 413 void updateScrollCoordinatedLayer(RenderLayer&, ScrollCoordinationReasons); 414 void detachScrollCoordinatedLayer(RenderLayer&); 409 415 410 416 FixedPositionViewportConstraints computeFixedViewportConstraints(RenderLayer&) const; … … 476 482 HashSet<RenderLayer*> m_scrollingLayersNeedingUpdate; 477 483 #endif 478 HashSet<RenderLayer*> m_ viewportConstrainedLayers;479 HashSet<RenderLayer*> m_ viewportConstrainedLayersNeedingUpdate;484 HashSet<RenderLayer*> m_scrollCoordinatedLayers; 485 HashSet<RenderLayer*> m_scrollCoordinatedLayersNeedingUpdate; 480 486 481 487 // Enclosing layer for overflow controls and the clipping layer
Note:
See TracChangeset
for help on using the changeset viewer.