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 AsyncScrollingCoordinator::updateScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* scrollLayer, GraphicsLayer* counterScrollingLayer) { ScrollingStateScrollingNode* node = toScrollingStateScrollingNode(m_scrollingStateTree->stateNodeForID(nodeID)); ASSERT(node); if (!node) return; node->setLayer(scrollLayer); node->setCounterScrollingLayer(counterScrollingLayer); }
static inline void setStateScrollingNodeSnapOffsetsAsFloat(ScrollingStateScrollingNode& node, ScrollEventAxis axis, const Vector<LayoutUnit>& snapOffsets, float deviceScaleFactor) { // FIXME: Incorporate current page scale factor in snapping to device pixel. Perhaps we should just convert to float here and let UI process do the pixel snapping? Vector<float> snapOffsetsAsFloat; snapOffsetsAsFloat.reserveInitialCapacity(snapOffsets.size()); for (size_t i = 0; i < snapOffsets.size(); ++i) snapOffsetsAsFloat.append(roundToDevicePixel(snapOffsets[i], deviceScaleFactor, false)); if (axis == ScrollEventAxis::Horizontal) node.setHorizontalSnapOffsets(snapOffsetsAsFloat); else node.setVerticalSnapOffsets(snapOffsetsAsFloat); }
void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree) { bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode(); ScrollingStateScrollingNode* rootNode = scrollingStateTree->rootStateNode(); if (rootNode && (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateScrollingNode::WheelEventHandlerCount) || rootNode->hasChangedProperty(ScrollingStateScrollingNode::NonFastScrollableRegion) || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))) { MutexLocker lock(m_mutex); if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) m_mainFrameScrollPosition = FloatPoint(); if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateScrollingNode::WheelEventHandlerCount)) m_hasWheelEventHandlers = scrollingStateTree->rootStateNode()->wheelEventHandlerCount(); if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateScrollingNode::NonFastScrollableRegion)) m_nonFastScrollableRegion = scrollingStateTree->rootStateNode()->nonFastScrollableRegion(); } bool scrollRequestIsProgammatic = rootNode ? rootNode->requestedScrollPositionRepresentsProgrammaticScroll() : false; TemporaryChange<bool> changeHandlingProgrammaticScroll(m_isHandlingProgrammaticScroll, scrollRequestIsProgammatic); removeDestroyedNodes(*scrollingStateTree); updateTreeFromStateNode(rootNode); }
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); }
ScrollingStateScrollingNode::ScrollingStateScrollingNode(const ScrollingStateScrollingNode& stateNode, ScrollingStateTree& adoptiveTree) : ScrollingStateNode(stateNode, adoptiveTree) , m_scrollableAreaSize(stateNode.scrollableAreaSize()) , m_totalContentsSize(stateNode.totalContentsSize()) , m_scrollPosition(stateNode.scrollPosition()) , m_requestedScrollPosition(stateNode.requestedScrollPosition()) , m_scrollOrigin(stateNode.scrollOrigin()) , m_scrollableAreaParameters(stateNode.scrollableAreaParameters()) , m_requestedScrollPositionRepresentsProgrammaticScroll(stateNode.requestedScrollPositionRepresentsProgrammaticScroll()) { }
bool AsyncScrollingCoordinator::requestScrollPositionUpdate(FrameView* frameView, const IntPoint& scrollPosition) { ASSERT(isMainThread()); ASSERT(m_page); if (!coordinatesScrollingForFrameView(frameView)) return false; if (frameView->inProgrammaticScroll() || frameView->frame().document()->inPageCache()) updateScrollPositionAfterAsyncScroll(frameView->scrollLayerID(), scrollPosition, frameView->inProgrammaticScroll(), SetScrollingLayerPosition); // If this frame view's document is being put into the page cache, we don't want to update our // main frame scroll position. Just let the FrameView think that we did. if (frameView->frame().document()->inPageCache()) return true; ScrollingStateScrollingNode* stateNode = toScrollingStateScrollingNode(m_scrollingStateTree->stateNodeForID(frameView->scrollLayerID())); if (!stateNode) return false; stateNode->setRequestedScrollPosition(scrollPosition, frameView->inProgrammaticScroll()); return true; }
void AsyncScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView) { ASSERT(isMainThread()); ASSERT(m_page); // If there isn't a root node yet, don't do anything. We'll be called again after creating one. if (!m_scrollingStateTree->rootStateNode()) return; // Compute the region of the page that we can't do fast scrolling for. This currently includes // all scrollable areas, such as subframes, overflow divs and list boxes. We need to do this even if the // frame view whose layout was updated is not the main frame. Region nonFastScrollableRegion = computeNonFastScrollableRegion(&m_page->mainFrame(), IntPoint()); // In the future, we may want to have the ability to set non-fast scrolling regions for more than // just the root node. But right now, this concept only applies to the root. setNonFastScrollableRegionForNode(nonFastScrollableRegion, m_scrollingStateTree->rootStateNode()); if (!coordinatesScrollingForFrameView(frameView)) return; ScrollingStateScrollingNode* node = toScrollingStateScrollingNode(m_scrollingStateTree->stateNodeForID(frameView->scrollLayerID())); if (!node) return; Scrollbar* verticalScrollbar = frameView->verticalScrollbar(); Scrollbar* horizontalScrollbar = frameView->horizontalScrollbar(); setScrollbarPaintersFromScrollbarsForNode(verticalScrollbar, horizontalScrollbar, node); node->setFrameScaleFactor(frameView->frame().frameScaleFactor()); node->setHeaderHeight(frameView->headerHeight()); node->setFooterHeight(frameView->footerHeight()); node->setScrollOrigin(frameView->scrollOrigin()); node->setViewportConstrainedObjectRect(FloatRect(FloatPoint(), frameView->visibleContentRect().size())); node->setTotalContentsSize(frameView->totalContentsSize()); ScrollableAreaParameters scrollParameters; scrollParameters.horizontalScrollElasticity = frameView->horizontalScrollElasticity(); scrollParameters.verticalScrollElasticity = frameView->verticalScrollElasticity(); scrollParameters.hasEnabledHorizontalScrollbar = horizontalScrollbar && horizontalScrollbar->enabled(); scrollParameters.hasEnabledVerticalScrollbar = verticalScrollbar && verticalScrollbar->enabled(); scrollParameters.horizontalScrollbarMode = frameView->horizontalScrollbarMode(); scrollParameters.verticalScrollbarMode = frameView->verticalScrollbarMode(); node->setScrollableAreaParameters(scrollParameters); }
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; }
ScrollingStateScrollingNode::ScrollingStateScrollingNode(const ScrollingStateScrollingNode& stateNode, ScrollingStateTree& adoptiveTree) : ScrollingStateNode(stateNode, adoptiveTree) #if PLATFORM(MAC) , m_verticalScrollbarPainter(stateNode.verticalScrollbarPainter()) , m_horizontalScrollbarPainter(stateNode.horizontalScrollbarPainter()) #endif , m_viewportSize(stateNode.viewportSize()) , m_totalContentsSize(stateNode.totalContentsSize()) , m_scrollPosition(stateNode.scrollPosition()) , m_scrollOrigin(stateNode.scrollOrigin()) , m_scrollableAreaParameters(stateNode.scrollableAreaParameters()) , m_nonFastScrollableRegion(stateNode.nonFastScrollableRegion()) , m_frameScaleFactor(stateNode.frameScaleFactor()) , m_wheelEventHandlerCount(stateNode.wheelEventHandlerCount()) , m_synchronousScrollingReasons(stateNode.synchronousScrollingReasons()) , m_behaviorForFixed(stateNode.scrollBehaviorForFixedElements()) , m_headerHeight(stateNode.headerHeight()) , m_footerHeight(stateNode.footerHeight()) , m_requestedScrollPosition(stateNode.requestedScrollPosition()) , m_requestedScrollPositionRepresentsProgrammaticScroll(stateNode.requestedScrollPositionRepresentsProgrammaticScroll()) , m_topContentInset(stateNode.topContentInset()) { if (hasChangedProperty(ScrolledContentsLayer)) setScrolledContentsLayer(stateNode.scrolledContentsLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation())); if (hasChangedProperty(CounterScrollingLayer)) setCounterScrollingLayer(stateNode.counterScrollingLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation())); if (hasChangedProperty(InsetClipLayer)) setInsetClipLayer(stateNode.insetClipLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation())); if (hasChangedProperty(ContentShadowLayer)) setContentShadowLayer(stateNode.contentShadowLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation())); if (hasChangedProperty(HeaderLayer)) setHeaderLayer(stateNode.headerLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation())); if (hasChangedProperty(FooterLayer)) setFooterLayer(stateNode.footerLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation())); }
ScrollingStateScrollingNode::ScrollingStateScrollingNode(const ScrollingStateScrollingNode& stateNode) : ScrollingStateNode(stateNode) , m_changedProperties(stateNode.changedProperties()) , m_viewportRect(stateNode.viewportRect()) , m_contentsSize(stateNode.contentsSize()) , m_nonFastScrollableRegion(stateNode.nonFastScrollableRegion()) , m_wheelEventHandlerCount(stateNode.wheelEventHandlerCount()) , m_shouldUpdateScrollLayerPositionOnMainThread(stateNode.shouldUpdateScrollLayerPositionOnMainThread()) , m_horizontalScrollElasticity(stateNode.horizontalScrollElasticity()) , m_verticalScrollElasticity(stateNode.verticalScrollElasticity()) , m_hasEnabledHorizontalScrollbar(stateNode.hasEnabledHorizontalScrollbar()) , m_hasEnabledVerticalScrollbar(stateNode.hasEnabledVerticalScrollbar()) , m_requestedScrollPositionRepresentsProgrammaticScroll(stateNode.requestedScrollPositionRepresentsProgrammaticScroll()) , m_horizontalScrollbarMode(stateNode.horizontalScrollbarMode()) , m_verticalScrollbarMode(stateNode.verticalScrollbarMode()) , m_requestedScrollPosition(stateNode.requestedScrollPosition()) , m_scrollOrigin(stateNode.scrollOrigin()) { }
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 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 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())); }