Esempio n. 1
0
void ScrollingTree::updateTreeFromStateNode(ScrollingStateNode* stateNode)
{
    // This fuction recurses through the ScrollingStateTree and updates the corresponding ScrollingTreeNodes.
    // Find the ScrollingTreeNode associated with the current stateNode using the shared ID and our HashMap.
    ScrollingTreeNodeMap::const_iterator it = m_nodeMap.find(stateNode->scrollingNodeID());

    if (it != m_nodeMap.end()) {
        ScrollingTreeNode* node = it->value;
        node->update(stateNode);
    } else {
        // If the node isn't found, it's either new and needs to be added to the tree, or there is a new ID for our
        // root node.
        if (!stateNode->parent()) {
            // This is the root node.
            m_rootNode->setScrollingNodeID(stateNode->scrollingNodeID());
            m_nodeMap.set(stateNode->scrollingNodeID(), m_rootNode.get());
            m_rootNode->update(stateNode);
        } else {
            // FIXME: In the future, we will have more than just ScrollingTreeScrollingNode, so we'll have to
            // figure out which type of node to create.
            OwnPtr<ScrollingTreeNode> newNode = ScrollingTreeScrollingNode::create(this);
            ScrollingTreeNode* newNodeRawPtr = newNode.get();
            m_nodeMap.set(stateNode->scrollingNodeID(), newNodeRawPtr);
            ScrollingTreeNodeMap::const_iterator it = m_nodeMap.find(stateNode->parent()->scrollingNodeID());
            ASSERT(it != m_nodeMap.end());
            if (it != m_nodeMap.end()) {
                ScrollingTreeNode* parent = it->value;
                newNode->setParent(parent);
                parent->appendChild(newNode.release());
            }
            newNodeRawPtr->update(stateNode);
        }
    }

    // Now update the children if we have any.
    Vector<OwnPtr<ScrollingStateNode> >* stateNodeChildren = stateNode->children();
    if (!stateNodeChildren)
        return;

    size_t size = stateNodeChildren->size();
    for (size_t i = 0; i < size; ++i)
        updateTreeFromStateNode(stateNodeChildren->at(i).get());
}
Esempio n. 2
0
void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree)
{
    ASSERT(ScrollingThread::isCurrentThread());

    if (scrollingStateTree->rootStateNode()->changedProperties() & (ScrollingStateScrollingNode::WheelEventHandlerCount | ScrollingStateScrollingNode::NonFastScrollableRegion) || scrollingStateTree->rootStateNode()->scrollLayerDidChange()) {
        MutexLocker lock(m_mutex);

        if (scrollingStateTree->rootStateNode()->scrollLayerDidChange())
            m_mainFrameScrollPosition = IntPoint();
        if (scrollingStateTree->rootStateNode()->changedProperties() & ScrollingStateScrollingNode::WheelEventHandlerCount)
            m_hasWheelEventHandlers = scrollingStateTree->rootStateNode()->wheelEventHandlerCount();
        if (scrollingStateTree->rootStateNode()->changedProperties() & ScrollingStateScrollingNode::NonFastScrollableRegion)
            m_nonFastScrollableRegion = scrollingStateTree->rootStateNode()->nonFastScrollableRegion();
    }
    
    TemporaryChange<bool> changeHandlingProgrammaticScroll(m_isHandlingProgrammaticScroll, scrollingStateTree->rootStateNode()->requestedScrollPositionRepresentsProgrammaticScroll());

    removeDestroyedNodes(scrollingStateTree.get());
    updateTreeFromStateNode(scrollingStateTree->rootStateNode());
}
Esempio n. 3
0
void ScrollingTree::updateTreeFromStateNode(ScrollingStateNode* stateNode)
{
    if (!stateNode) {
        m_nodeMap.clear();
        m_rootNode = nullptr;
        return;
    }
    
    // This fuction recurses through the ScrollingStateTree and updates the corresponding ScrollingTreeNodes.
    // Find the ScrollingTreeNode associated with the current stateNode using the shared ID and our HashMap.
    ScrollingTreeNodeMap::const_iterator it = m_nodeMap.find(stateNode->scrollingNodeID());

    ScrollingTreeNode* node;
    if (it != m_nodeMap.end()) {
        node = it->value;
        node->updateBeforeChildren(stateNode);
    } else {
        // If the node isn't found, it's either new and needs to be added to the tree, or there is a new ID for our
        // root node.
        ScrollingNodeID nodeID = stateNode->scrollingNodeID();
        if (!stateNode->parent()) {
            // This is the root node. Nuke the node map.
            m_nodeMap.clear();

            m_rootNode = ScrollingTreeScrollingNode::create(*this, nodeID);
            m_nodeMap.set(nodeID, m_rootNode.get());
            m_rootNode->updateBeforeChildren(stateNode);
            node = m_rootNode.get();
        } else {
            OwnPtr<ScrollingTreeNode> newNode;
            if (stateNode->isScrollingNode())
                newNode = ScrollingTreeScrollingNode::create(*this, nodeID);
            else if (stateNode->isFixedNode())
                newNode = ScrollingTreeFixedNode::create(*this, nodeID);
            else if (stateNode->isStickyNode())
                newNode = ScrollingTreeStickyNode::create(*this, nodeID);
            else
                ASSERT_NOT_REACHED();

            node = newNode.get();
            m_nodeMap.set(nodeID, node);
            ScrollingTreeNodeMap::const_iterator it = m_nodeMap.find(stateNode->parent()->scrollingNodeID());
            ASSERT(it != m_nodeMap.end());
            if (it != m_nodeMap.end()) {
                ScrollingTreeNode* parent = it->value;
                newNode->setParent(parent);
                parent->appendChild(newNode.release());
            }
            node->updateBeforeChildren(stateNode);
        }
    }

    // Now update the children if we have any.
    Vector<OwnPtr<ScrollingStateNode>>* stateNodeChildren = stateNode->children();
    if (stateNodeChildren) {
        size_t size = stateNodeChildren->size();
        for (size_t i = 0; i < size; ++i)
            updateTreeFromStateNode(stateNodeChildren->at(i).get());
    }
    node->updateAfterChildren(stateNode);
}