#ifndef ScrollingTree_h
#define ScrollingTree_h
#if ENABLE(THREADED_SCROLLING)
#include "PlatformWheelEvent.h"
#include "Region.h"
#include "ScrollingCoordinator.h"
#include <wtf/Functional.h>
#include <wtf/HashMap.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/ThreadSafeRefCounted.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
OBJC_CLASS CALayer;
#endif
namespace WebCore {
class IntPoint;
class ScrollingStateNode;
class ScrollingStateTree;
class ScrollingTreeNode;
class ScrollingTreeScrollingNode;
class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
public:
static PassRefPtr<ScrollingTree> create(ScrollingCoordinator*);
~ScrollingTree();
enum EventResult {
DidNotHandleEvent,
DidHandleEvent,
SendToMainThread
};
EventResult tryToHandleWheelEvent(const PlatformWheelEvent&);
bool hasWheelEventHandlers() const { return m_hasWheelEventHandlers; }
void updateBackForwardState(bool canGoBack, bool canGoForward);
void handleWheelEvent(const PlatformWheelEvent&);
void setMainFrameIsRubberBanding(bool);
bool isRubberBandInProgress();
void invalidate();
void commitNewTreeState(PassOwnPtr<ScrollingStateTree>);
void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom);
void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition);
IntPoint mainFrameScrollPosition();
#if PLATFORM(MAC)
void handleWheelEventPhase(PlatformWheelEventPhase);
#endif
bool canGoBack();
bool canGoForward();
bool rubberBandsAtBottom();
void setRubberBandsAtBottom(bool);
bool rubberBandsAtTop();
void setRubberBandsAtTop(bool);
void setScrollPinningBehavior(ScrollPinningBehavior);
ScrollPinningBehavior scrollPinningBehavior();
bool willWheelEventStartSwipeGesture(const PlatformWheelEvent&);
void setScrollingPerformanceLoggingEnabled(bool flag);
bool scrollingPerformanceLoggingEnabled();
ScrollingTreeScrollingNode* rootNode() const { return m_rootNode.get(); }
private:
explicit ScrollingTree(ScrollingCoordinator*);
void removeDestroyedNodes(ScrollingStateTree*);
void updateTreeFromStateNode(ScrollingStateNode*);
RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
OwnPtr<ScrollingTreeScrollingNode> m_rootNode;
typedef HashMap<ScrollingNodeID, ScrollingTreeNode*> ScrollingTreeNodeMap;
ScrollingTreeNodeMap m_nodeMap;
Mutex m_mutex;
Region m_nonFastScrollableRegion;
IntPoint m_mainFrameScrollPosition;
bool m_hasWheelEventHandlers;
Mutex m_swipeStateMutex;
bool m_canGoBack;
bool m_canGoForward;
bool m_mainFramePinnedToTheLeft;
bool m_mainFramePinnedToTheRight;
bool m_rubberBandsAtBottom;
bool m_rubberBandsAtTop;
bool m_mainFramePinnedToTheTop;
bool m_mainFramePinnedToTheBottom;
bool m_mainFrameIsRubberBanding;
ScrollPinningBehavior m_scrollPinningBehavior;
bool m_scrollingPerformanceLoggingEnabled;
bool m_isHandlingProgrammaticScroll;
};
}
#endif // ENABLE(THREADED_SCROLLING)
#endif // ScrollingTree_h