void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree& stateTree, const RemoteLayerTreeHost& layerTreeHost) { for (auto it : stateTree.nodeMap()) { ScrollingStateNode* currNode = it.value; switch (currNode->nodeType()) { case ScrollingNode: { ScrollingStateScrollingNode* scrollingStateNode = toScrollingStateScrollingNode(currNode); if (scrollingStateNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) scrollingStateNode->setLayer(layerTreeHost.getLayer(scrollingStateNode->layer())); if (scrollingStateNode->hasChangedProperty(ScrollingStateScrollingNode::CounterScrollingLayer)) scrollingStateNode->setCounterScrollingLayer(layerTreeHost.getLayer(scrollingStateNode->counterScrollingLayer())); // FIXME: we should never have header and footer layers coming from the WebProcess. if (scrollingStateNode->hasChangedProperty(ScrollingStateScrollingNode::HeaderLayer)) scrollingStateNode->setHeaderLayer(layerTreeHost.getLayer(scrollingStateNode->headerLayer())); if (scrollingStateNode->hasChangedProperty(ScrollingStateScrollingNode::FooterLayer)) scrollingStateNode->setFooterLayer(layerTreeHost.getLayer(scrollingStateNode->footerLayer())); break; } case FixedNode: if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) currNode->setLayer(layerTreeHost.getLayer(currNode->layer())); break; case StickyNode: if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) currNode->setLayer(layerTreeHost.getLayer(currNode->layer())); break; } } }
void ArgumentCoder<ScrollingStateScrollingNode>::encode(ArgumentEncoder& encoder, const ScrollingStateScrollingNode& node) { encoder << static_cast<const ScrollingStateNode&>(node); SCROLLING_NODE_ENCODE(ViewportSize, viewportSize) SCROLLING_NODE_ENCODE(TotalContentsSize, totalContentsSize) SCROLLING_NODE_ENCODE(ScrollPosition, scrollPosition) SCROLLING_NODE_ENCODE(ScrollOrigin, scrollOrigin) SCROLLING_NODE_ENCODE(FrameScaleFactor, frameScaleFactor) SCROLLING_NODE_ENCODE(NonFastScrollableRegion, nonFastScrollableRegion) SCROLLING_NODE_ENCODE(WheelEventHandlerCount, wheelEventHandlerCount) SCROLLING_NODE_ENCODE(ReasonsForSynchronousScrolling, synchronousScrollingReasons) SCROLLING_NODE_ENCODE(ScrollableAreaParams, scrollableAreaParameters) SCROLLING_NODE_ENCODE_ENUM(BehaviorForFixedElements, scrollBehaviorForFixedElements) SCROLLING_NODE_ENCODE(RequestedScrollPosition, requestedScrollPosition) SCROLLING_NODE_ENCODE(RequestedScrollPosition, requestedScrollPositionRepresentsProgrammaticScroll) SCROLLING_NODE_ENCODE(HeaderHeight, headerHeight) SCROLLING_NODE_ENCODE(FooterHeight, footerHeight) SCROLLING_NODE_ENCODE(TopContentInset, topContentInset) if (node.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer)) encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.scrolledContentsLayer()); if (node.hasChangedProperty(ScrollingStateScrollingNode::CounterScrollingLayer)) encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.counterScrollingLayer()); }
void ScrollingTree::commitNewTreeState(std::unique_ptr<ScrollingStateTree> scrollingStateTree) { bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode(); ScrollingStateScrollingNode* rootNode = scrollingStateTree->rootStateNode(); if (rootNode && (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateFrameScrollingNode::NonFastScrollableRegion) || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))) { MutexLocker lock(m_mutex); if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) m_mainFrameScrollPosition = FloatPoint(); if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateFrameScrollingNode::NonFastScrollableRegion)) m_nonFastScrollableRegion = scrollingStateTree->rootStateNode()->nonFastScrollableRegion(); } bool scrollRequestIsProgammatic = rootNode ? rootNode->requestedScrollPositionRepresentsProgrammaticScroll() : false; TemporaryChange<bool> changeHandlingProgrammaticScroll(m_isHandlingProgrammaticScroll, scrollRequestIsProgammatic); removeDestroyedNodes(*scrollingStateTree); OrphanScrollingNodeMap orphanNodes; updateTreeFromStateNode(rootNode, orphanNodes); }
bool ArgumentCoder<ScrollingStateScrollingNode>::decode(ArgumentDecoder& decoder, ScrollingStateScrollingNode& node) { if (!decoder.decode(static_cast<ScrollingStateNode&>(node))) return false; SCROLLING_NODE_DECODE(ViewportSize, FloatSize, setViewportSize); SCROLLING_NODE_DECODE(TotalContentsSize, IntSize, setTotalContentsSize); SCROLLING_NODE_DECODE(ScrollPosition, FloatPoint, setScrollPosition); SCROLLING_NODE_DECODE(ScrollOrigin, IntPoint, setScrollOrigin); SCROLLING_NODE_DECODE(FrameScaleFactor, float, setFrameScaleFactor); SCROLLING_NODE_DECODE(NonFastScrollableRegion, Region, setNonFastScrollableRegion); SCROLLING_NODE_DECODE(WheelEventHandlerCount, int, setWheelEventHandlerCount); SCROLLING_NODE_DECODE(ReasonsForSynchronousScrolling, SynchronousScrollingReasons, setSynchronousScrollingReasons); SCROLLING_NODE_DECODE(ScrollableAreaParams, ScrollableAreaParameters, setScrollableAreaParameters); SCROLLING_NODE_DECODE_ENUM(BehaviorForFixedElements, ScrollBehaviorForFixedElements, setScrollBehaviorForFixedElements); if (node.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { FloatPoint scrollPosition; if (!decoder.decode(scrollPosition)) return false; bool representsProgrammaticScroll; if (!decoder.decode(representsProgrammaticScroll)) return false; node.setRequestedScrollPosition(scrollPosition, representsProgrammaticScroll); } SCROLLING_NODE_DECODE(HeaderHeight, int, setHeaderHeight); SCROLLING_NODE_DECODE(FooterHeight, int, setFooterHeight); SCROLLING_NODE_DECODE(TopContentInset, float, setTopContentInset); if (node.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer)) { GraphicsLayer::PlatformLayerID layerID; if (!decoder.decode(layerID)) return false; node.setScrolledContentsLayer(layerID); } if (node.hasChangedProperty(ScrollingStateScrollingNode::CounterScrollingLayer)) { GraphicsLayer::PlatformLayerID layerID; if (!decoder.decode(layerID)) return false; node.setCounterScrollingLayer(layerID); } return true; }
void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree) { ASSERT(ScrollingThread::isCurrentThread()); ScrollingStateScrollingNode* rootNode = scrollingStateTree->rootStateNode(); if (rootNode->hasChangedProperty(ScrollingStateScrollingNode::WheelEventHandlerCount) || rootNode->hasChangedProperty(ScrollingStateScrollingNode::NonFastScrollableRegion) || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) { MutexLocker lock(m_mutex); if (rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) m_mainFrameScrollPosition = IntPoint(); if (rootNode->hasChangedProperty(ScrollingStateScrollingNode::WheelEventHandlerCount)) m_hasWheelEventHandlers = scrollingStateTree->rootStateNode()->wheelEventHandlerCount(); if (rootNode->hasChangedProperty(ScrollingStateScrollingNode::NonFastScrollableRegion)) m_nonFastScrollableRegion = scrollingStateTree->rootStateNode()->nonFastScrollableRegion(); } TemporaryChange<bool> changeHandlingProgrammaticScroll(m_isHandlingProgrammaticScroll, rootNode->requestedScrollPositionRepresentsProgrammaticScroll()); removeDestroyedNodes(scrollingStateTree.get()); updateTreeFromStateNode(rootNode); }
void ScrollingTreeScrollingNode::updateBeforeChildren(ScrollingStateNode* stateNode) { ScrollingStateScrollingNode* state = toScrollingStateScrollingNode(stateNode); if (state->hasChangedProperty(ScrollingStateScrollingNode::ViewportRect)) m_viewportRect = state->viewportRect(); if (state->hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) { if (scrollingTree().isRubberBandInProgress()) m_totalContentsSizeForRubberBand = m_totalContentsSize; else m_totalContentsSizeForRubberBand = state->totalContentsSize(); m_totalContentsSize = state->totalContentsSize(); } if (state->hasChangedProperty(ScrollingStateScrollingNode::FrameScaleFactor)) m_frameScaleFactor = state->frameScaleFactor(); if (state->hasChangedProperty(ScrollingStateScrollingNode::ShouldUpdateScrollLayerPositionOnMainThread)) m_shouldUpdateScrollLayerPositionOnMainThread = state->shouldUpdateScrollLayerPositionOnMainThread(); if (state->hasChangedProperty(ScrollingStateScrollingNode::HorizontalScrollElasticity)) m_horizontalScrollElasticity = state->horizontalScrollElasticity(); if (state->hasChangedProperty(ScrollingStateScrollingNode::VerticalScrollElasticity)) m_verticalScrollElasticity = state->verticalScrollElasticity(); if (state->hasChangedProperty(ScrollingStateScrollingNode::HasEnabledHorizontalScrollbar)) m_hasEnabledHorizontalScrollbar = state->hasEnabledHorizontalScrollbar(); if (state->hasChangedProperty(ScrollingStateScrollingNode::HasEnabledVerticalScrollbar)) m_hasEnabledVerticalScrollbar = state->hasEnabledVerticalScrollbar(); if (state->hasChangedProperty(ScrollingStateScrollingNode::HorizontalScrollbarMode)) m_horizontalScrollbarMode = state->horizontalScrollbarMode(); if (state->hasChangedProperty(ScrollingStateScrollingNode::VerticalScrollbarMode)) m_verticalScrollbarMode = state->verticalScrollbarMode(); if (state->hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin)) m_scrollOrigin = state->scrollOrigin(); if (state->hasChangedProperty(ScrollingStateScrollingNode::HeaderHeight)) m_headerHeight = state->headerHeight(); if (state->hasChangedProperty(ScrollingStateScrollingNode::FooterHeight)) m_footerHeight = state->footerHeight(); if (state->hasChangedProperty(ScrollingStateScrollingNode::BehaviorForFixedElements)) m_behaviorForFixed = state->scrollBehaviorForFixedElements(); }
void RemoteScrollingTreeTextStream::dump(const ScrollingStateScrollingNode& node, bool changedPropertiesOnly) { RemoteScrollingTreeTextStream& ts = *this; if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ViewportSize)) dumpProperty(ts, "viewport-size", node.viewportSize()); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) dumpProperty(ts, "total-contents-size", node.totalContentsSize()); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition)) dumpProperty(ts, "scroll-position", node.scrollPosition()); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin)) dumpProperty(ts, "scroll-origin", node.scrollOrigin()); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::FrameScaleFactor)) dumpProperty(ts, "frame-scale-factor", node.frameScaleFactor()); // FIXME: dump nonFastScrollableRegion // FIXME: dump wheelEventHandlerCount // FIXME: dump synchronousScrollingReasons // FIXME: dump scrollableAreaParameters // FIXME: dump scrollBehaviorForFixedElements if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { dumpProperty(ts, "requested-scroll-position", node.requestedScrollPosition()); dumpProperty(ts, "requested-scroll-position-is-programatic", node.requestedScrollPositionRepresentsProgrammaticScroll()); } if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::HeaderHeight)) dumpProperty(ts, "header-height", node.headerHeight()); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::FooterHeight)) dumpProperty(ts, "footer-height", node.footerHeight()); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::TopContentInset)) dumpProperty(ts, "top-content-inset", node.topContentInset()); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer)) dumpProperty(ts, "scrolled-contents-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.scrolledContentsLayer())); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::CounterScrollingLayer)) dumpProperty(ts, "counter-scrolling-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.counterScrollingLayer())); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::InsetClipLayer)) dumpProperty(ts, "clip-inset-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.insetClipLayer())); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::HeaderLayer)) dumpProperty(ts, "header-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.headerLayer())); if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::FooterLayer)) dumpProperty(ts, "footer-layer", static_cast<GraphicsLayer::PlatformLayerID>(node.footerLayer())); }