#ifndef ScrollingCoordinator_h
#define ScrollingCoordinator_h
#include "core/rendering/RenderObject.h"
#include "platform/PlatformWheelEvent.h"
#include "platform/geometry/IntRect.h"
#include "platform/scroll/ScrollTypes.h"
#include "wtf/text/WTFString.h"
namespace blink {
class WebLayer;
class WebScrollbarLayer;
}
namespace WebCore {
typedef unsigned MainThreadScrollingReasons;
class Document;
class LocalFrame;
class FrameView;
class GraphicsLayer;
class Page;
class Region;
class ScrollableArea;
class ViewportConstraints;
class ScrollingCoordinator {
public:
static PassOwnPtr<ScrollingCoordinator> create(Page*);
~ScrollingCoordinator();
void pageDestroyed();
bool coordinatesScrollingForFrameView(FrameView*) const;
void notifyLayoutUpdated();
void updateAfterCompositingChange();
bool needsToUpdateAfterCompositingChange() const { return m_scrollGestureRegionIsDirty || m_touchEventTargetRectsAreDirty || frameViewIsDirty(); }
void frameViewWheelEventHandlerCountChanged(FrameView*);
void frameViewHasSlowRepaintObjectsDidChange(FrameView*);
void frameViewFixedObjectsDidChange(FrameView*);
void frameViewRootLayerDidChange(FrameView*);
#if OS(MACOSX)
void handleWheelEventPhase(PlatformWheelEventPhase);
#endif
enum MainThreadScrollingReasonFlags {
HasSlowRepaintObjects = 1 << 0,
HasViewportConstrainedObjectsWithoutSupportingFixedLayers = 1 << 1,
HasNonLayerViewportConstrainedObjects = 1 << 2,
};
MainThreadScrollingReasons mainThreadScrollingReasons() const;
bool shouldUpdateScrollLayerPositionOnMainThread() const { return mainThreadScrollingReasons() != 0; }
PassOwnPtr<blink::WebScrollbarLayer> createSolidColorScrollbarLayer(ScrollbarOrientation, int thumbThickness, bool isLeftSideVerticalScrollbar);
void willDestroyScrollableArea(ScrollableArea*);
bool scrollableAreaScrollLayerDidChange(ScrollableArea*);
void scrollableAreaScrollbarLayerDidChange(ScrollableArea*, ScrollbarOrientation);
void setLayerIsContainerForFixedPositionLayers(GraphicsLayer*, bool);
void updateLayerPositionConstraint(RenderLayer*);
void touchEventTargetRectsDidChange();
void willDestroyRenderLayer(RenderLayer*);
void updateScrollParentForGraphicsLayer(GraphicsLayer* child, RenderLayer* parent);
void updateClipParentForGraphicsLayer(GraphicsLayer* child, RenderLayer* parent);
static String mainThreadScrollingReasonsAsText(MainThreadScrollingReasons);
String mainThreadScrollingReasonsAsText() const;
Region computeShouldHandleScrollGestureOnMainThreadRegion(const LocalFrame*, const IntPoint& frameLocation) const;
void updateTouchEventTargetRectsIfNeeded();
void reset();
protected:
explicit ScrollingCoordinator(Page*);
bool isForMainFrame(ScrollableArea*) const;
unsigned computeCurrentWheelEventHandlerCount();
GraphicsLayer* scrollLayerForFrameView(FrameView*);
GraphicsLayer* counterScrollingLayerForFrameView(FrameView*);
Page* m_page;
bool m_scrollGestureRegionIsDirty;
bool m_touchEventTargetRectsAreDirty;
bool m_shouldScrollOnMainThreadDirty;
private:
void recomputeWheelEventHandlerCountForFrameView(FrameView*);
void setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons);
bool hasVisibleSlowRepaintViewportConstrainedObjects(FrameView*) const;
bool touchHitTestingEnabled() const;
void setShouldHandleScrollGestureOnMainThreadRegion(const Region&);
void setTouchEventTargetRects(const LayerHitTestRects&);
void computeTouchEventTargetRects(LayerHitTestRects&);
void setWheelEventHandlerCount(unsigned);
blink::WebScrollbarLayer* addWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation, PassOwnPtr<blink::WebScrollbarLayer>);
blink::WebScrollbarLayer* getWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation);
void removeWebScrollbarLayer(ScrollableArea*, ScrollbarOrientation);
bool frameViewIsDirty() const;
typedef HashMap<ScrollableArea*, OwnPtr<blink::WebScrollbarLayer> > ScrollbarMap;
ScrollbarMap m_horizontalScrollbars;
ScrollbarMap m_verticalScrollbars;
HashSet<const RenderLayer*> m_layersWithTouchRects;
bool m_wasFrameScrollable;
MainThreadScrollingReasons m_lastMainThreadScrollingReasons;
};
}
#endif