2
* Copyright (C) 2012 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
13
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
* THE POSSIBILITY OF SUCH DAMAGE.
26
#ifndef ScrollingStateTree_h
27
#define ScrollingStateTree_h
29
#if ENABLE(THREADED_SCROLLING)
31
#include "ScrollingStateScrollingNode.h"
32
#include <wtf/OwnPtr.h>
33
#include <wtf/PassOwnPtr.h>
34
#include <wtf/RefPtr.h>
38
// The ScrollingStateTree is a tree that managed ScrollingStateNodes. The nodes keep track of the current
39
// state of scrolling related properties. Whenever any properties change, the scrolling coordinator
40
// will be informed and will schedule a timer that will clone the new state tree and send it over to
41
// the scrolling thread, avoiding locking.
43
// FIXME: Right now the scrolling thread only ever looks at the root node. In the future, it should
44
// look at the whole tree and build a ScrollingTree that mimics the ScrollingStateTree.
46
// FIXME: Right now there is only one type of ScrollingStateNode, which is the ScrollingStateScrollingNode.
47
// It is currently used for the main frame, but in the future it should be able to be used for subframes
48
// and overflow areas. In the future, more classes will inherit from ScrollingStateNode, such as
49
// ScrollingStateFixedNode and ScrollingStateStickyNode for fixed position objects and sticky positoned
50
// objects, respectively.
52
class ScrollingStateTree {
54
static PassOwnPtr<ScrollingStateTree> create();
55
~ScrollingStateTree();
57
ScrollingStateScrollingNode* rootStateNode() const { return m_rootStateNode.get(); }
59
// Copies the current tree state and clears the changed properties mask in the original.
60
PassOwnPtr<ScrollingStateTree> commit();
62
void removeNode(ScrollingStateNode*);
63
void didRemoveNode(ScrollingNodeID);
64
const Vector<ScrollingNodeID>& removedNodes() const { return m_nodesRemovedSinceLastCommit; }
66
void setHasChangedProperties(bool changedProperties) { m_hasChangedProperties = changedProperties; }
67
bool hasChangedProperties() const { return m_hasChangedProperties; }
72
void setRootStateNode(PassOwnPtr<ScrollingStateScrollingNode> rootStateNode) { m_rootStateNode = rootStateNode; }
74
PassOwnPtr<ScrollingStateTree> clone();
76
OwnPtr<ScrollingStateScrollingNode> m_rootStateNode;
77
Vector<ScrollingNodeID> m_nodesRemovedSinceLastCommit;
78
bool m_hasChangedProperties;
81
} // namespace WebCore
83
#endif // ENABLE(THREADED_SCROLLING)
85
#endif // ScrollingStateTree_h