示例#1
0
void AsyncScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView* frameView)
{
    ScrollingStateScrollingNode* node = toScrollingStateScrollingNode(m_scrollingStateTree->stateNodeForID(frameView->scrollLayerID()));
    if (!node)
        return;
    setWheelEventHandlerCountForNode(computeCurrentWheelEventHandlerCount(), node);
}
示例#2
0
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;
        }
    }
}
示例#3
0
bool RemoteScrollingCoordinatorTransaction::decode(IPC::ArgumentDecoder& decoder)
{
    int numNodes;
    if (!decoder.decode(numNodes))
        return false;

    bool hasNewRootNode;
    if (!decoder.decode(hasNewRootNode))
        return false;
    
    m_scrollingStateTree = ScrollingStateTree::create();
    
    for (int i = 0; i < numNodes; ++i) {
        ScrollingNodeType nodeType;
        if (!decoder.decodeEnum(nodeType))
            return false;

        ScrollingNodeID nodeID;
        if (!decoder.decode(nodeID))
            return false;

        ScrollingNodeID parentNodeID;
        if (!decoder.decode(parentNodeID))
            return false;

        m_scrollingStateTree->attachNode(nodeType, nodeID, parentNodeID);
        ScrollingStateNode* newNode = m_scrollingStateTree->stateNodeForID(nodeID);
        ASSERT(newNode);
        ASSERT(!parentNodeID || newNode->parent());
        
        switch (nodeType) {
        case FrameScrollingNode:
        case OverflowScrollingNode:
            if (!decoder.decode(*toScrollingStateScrollingNode(newNode)))
                return false;
            break;
        case FixedNode:
            if (!decoder.decode(*toScrollingStateFixedNode(newNode)))
                return false;
            break;
        case StickyNode:
            if (!decoder.decode(*toScrollingStateStickyNode(newNode)))
                return false;
            break;
        }
    }

    m_scrollingStateTree->setHasNewRootStateNode(hasNewRootNode);

    // Removed nodes
    Vector<ScrollingNodeID> removedNodes;
    if (!decoder.decode(removedNodes))
        return false;
    
    if (removedNodes.size())
        m_scrollingStateTree->setRemovedNodes(removedNodes);

    return true;
}
示例#4
0
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);
}
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();
}
示例#6
0
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);
}
示例#7
0
void AsyncScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
{
    ASSERT(isMainThread());
    ASSERT(m_page);

    if (!coordinatesScrollingForFrameView(frameView))
        return;

    // If the root layer does not have a ScrollingStateNode, then we should create one.
    ensureRootStateNodeForFrameView(frameView);
    ASSERT(m_scrollingStateTree->rootStateNode());

    ScrollingCoordinator::frameViewRootLayerDidChange(frameView);

    ScrollingStateScrollingNode* node = toScrollingStateScrollingNode(m_scrollingStateTree->stateNodeForID(frameView->scrollLayerID()));
    setScrollLayerForNode(scrollLayerForFrameView(frameView), node);
    setCounterScrollingLayerForNode(counterScrollingLayerForFrameView(frameView), node);
    setHeaderLayerForNode(headerLayerForFrameView(frameView), node);
    setFooterLayerForNode(footerLayerForFrameView(frameView), node);
    setScrollBehaviorForFixedElementsForNode(frameView->scrollBehaviorForFixedElements(), node);
}
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;
}
示例#9
0
static void encodeNodeAndDescendants(IPC::ArgumentEncoder& encoder, const ScrollingStateNode& stateNode)
{
    switch (stateNode.nodeType()) {
    case FrameScrollingNode:
    case OverflowScrollingNode:
        encoder << toScrollingStateScrollingNode(stateNode);
        break;
    case FixedNode:
        encoder << toScrollingStateFixedNode(stateNode);
        break;
    case StickyNode:
        encoder << toScrollingStateStickyNode(stateNode);
        break;
    }

    if (!stateNode.children())
        return;

    for (size_t i = 0; i < stateNode.children()->size(); ++i) {
        const OwnPtr<ScrollingStateNode>& child = stateNode.children()->at(i);
        encodeNodeAndDescendants(encoder, *child.get());
    }
}