ScrollingCoordinator.h [plain text]
#ifndef ScrollingCoordinator_h
#define ScrollingCoordinator_h
#include "GraphicsLayer.h"
#include "IntRect.h"
#include "PlatformWheelEvent.h"
#include "ScrollTypes.h"
#include "Timer.h"
#include <wtf/Forward.h>
#if ENABLE(THREADED_SCROLLING)
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/Threading.h>
#endif
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#endif
namespace WebCore {
class FrameView;
class GraphicsLayer;
class Page;
class Region;
class ScrollingCoordinatorPrivate;
class ScrollingTreeState;
#if ENABLE(THREADED_SCROLLING)
class ScrollingTree;
#endif
class ScrollingCoordinator : public ThreadSafeRefCounted<ScrollingCoordinator> {
public:
static PassRefPtr<ScrollingCoordinator> create(Page*);
~ScrollingCoordinator();
void pageDestroyed();
#if ENABLE(THREADED_SCROLLING)
ScrollingTree* scrollingTree() const;
void commitTreeStateIfNeeded();
#endif
bool coordinatesScrollingForFrameView(FrameView*) const;
void frameViewLayoutUpdated(FrameView*);
void frameViewWheelEventHandlerCountChanged(FrameView*);
void frameViewHasSlowRepaintObjectsDidChange(FrameView*);
void frameViewHasFixedObjectsDidChange(FrameView*);
void frameViewRootLayerDidChange(FrameView*);
void frameViewHorizontalScrollbarLayerDidChange(FrameView*, GraphicsLayer* horizontalScrollbarLayer);
void frameViewVerticalScrollbarLayerDidChange(FrameView*, GraphicsLayer* verticalScrollbarLayer);
bool requestScrollPositionUpdate(FrameView*, const IntPoint&);
bool handleWheelEvent(FrameView*, const PlatformWheelEvent&);
void updateMainFrameScrollPosition(const IntPoint&, bool programmaticScroll);
void updateMainFrameScrollPositionAndScrollLayerPosition();
#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
void handleWheelEventPhase(PlatformWheelEventPhase);
#endif
void setForceMainThreadScrollLayerPositionUpdates(bool);
bool shouldUpdateScrollLayerPositionOnMainThread() const;
private:
explicit ScrollingCoordinator(Page*);
void recomputeWheelEventHandlerCount();
void updateShouldUpdateScrollLayerPositionOnMainThread();
void setScrollLayer(GraphicsLayer*);
void setNonFastScrollableRegion(const Region&);
struct ScrollParameters {
ScrollElasticity horizontalScrollElasticity;
ScrollElasticity verticalScrollElasticity;
bool hasEnabledHorizontalScrollbar;
bool hasEnabledVerticalScrollbar;
ScrollbarMode horizontalScrollbarMode;
ScrollbarMode verticalScrollbarMode;
IntPoint scrollOrigin;
IntRect viewportRect;
IntSize contentsSize;
};
void setScrollParameters(const ScrollParameters&);
void setWheelEventHandlerCount(unsigned);
void setShouldUpdateScrollLayerPositionOnMainThread(bool);
void updateMainFrameScrollLayerPosition();
Page* m_page;
bool m_forceMainThreadScrollLayerPositionUpdates;
#if ENABLE(THREADED_SCROLLING)
void scheduleTreeStateCommit();
void scrollingTreeStateCommitterTimerFired(Timer<ScrollingCoordinator>*);
void commitTreeState();
OwnPtr<ScrollingTreeState> m_scrollingTreeState;
RefPtr<ScrollingTree> m_scrollingTree;
Timer<ScrollingCoordinator> m_scrollingTreeStateCommitterTimer;
#endif
ScrollingCoordinatorPrivate* m_private;
};
}
#endif // ScrollingCoordinator_h