#ifndef RenderLayerScrollableArea_h
#define RenderLayerScrollableArea_h
#include "platform/scroll/ScrollableArea.h"
namespace WebCore {
enum ResizerHitTestType {
ResizerForPointer,
ResizerForTouch
};
enum ForceNeedsCompositedScrollingMode {
DoNotForceCompositedScrolling = 0,
CompositedScrollingAlwaysOn = 1,
CompositedScrollingAlwaysOff = 2
};
class PlatformEvent;
class RenderBox;
class RenderLayer;
class RenderScrollbarPart;
class RenderLayerScrollableArea FINAL : public ScrollableArea {
friend class Internals;
public:
RenderLayerScrollableArea(RenderBox*);
virtual ~RenderLayerScrollableArea();
bool hasHorizontalScrollbar() const { return horizontalScrollbar(); }
bool hasVerticalScrollbar() const { return verticalScrollbar(); }
virtual Scrollbar* horizontalScrollbar() const OVERRIDE { return m_hBar.get(); }
virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_vBar.get(); }
virtual GraphicsLayer* layerForScrolling() const OVERRIDE;
virtual GraphicsLayer* layerForHorizontalScrollbar() const OVERRIDE;
virtual GraphicsLayer* layerForVerticalScrollbar() const OVERRIDE;
virtual GraphicsLayer* layerForScrollCorner() const OVERRIDE;
virtual bool usesCompositedScrolling() const OVERRIDE;
virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE;
virtual bool isActive() const OVERRIDE;
virtual bool isScrollCornerVisible() const OVERRIDE;
virtual IntRect scrollCornerRect() const OVERRIDE;
virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const OVERRIDE;
virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const OVERRIDE;
virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const OVERRIDE;
virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const OVERRIDE;
virtual int scrollSize(ScrollbarOrientation) const OVERRIDE;
virtual void setScrollOffset(const IntPoint&) OVERRIDE;
virtual IntPoint scrollPosition() const OVERRIDE;
virtual IntPoint minimumScrollPosition() const OVERRIDE;
virtual IntPoint maximumScrollPosition() const OVERRIDE;
virtual IntRect visibleContentRect(IncludeScrollbarsInRect) const OVERRIDE;
virtual int visibleHeight() const OVERRIDE;
virtual int visibleWidth() const OVERRIDE;
virtual IntSize contentsSize() const OVERRIDE;
virtual IntSize overhangAmount() const OVERRIDE;
virtual IntPoint lastKnownMousePosition() const OVERRIDE;
virtual bool shouldSuspendScrollAnimations() const OVERRIDE;
virtual bool scrollbarsCanBeActive() const OVERRIDE;
virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
virtual bool userInputScrollable(ScrollbarOrientation) const OVERRIDE;
virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE;
virtual int pageStep(ScrollbarOrientation) const OVERRIDE;
int scrollXOffset() const { return m_scrollOffset.width() + scrollOrigin().x(); }
int scrollYOffset() const { return m_scrollOffset.height() + scrollOrigin().y(); }
IntSize scrollOffset() const { return m_scrollOffset; }
LayoutRect overflowRect() const { return m_overflowRect; }
void scrollToOffset(const IntSize& scrollOffset, ScrollOffsetClamping = ScrollOffsetUnclamped);
void scrollToXOffset(int x, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(IntSize(x, scrollYOffset()), clamp); }
void scrollToYOffset(int y, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(IntSize(scrollXOffset(), y), clamp); }
void updateAfterLayout();
void updateAfterStyleChange(const RenderStyle*);
bool hasScrollbar() const { return m_hBar || m_vBar; }
bool hasScrollCorner() const { return m_scrollCorner; }
void resize(const PlatformEvent&, const LayoutSize&);
IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const;
bool inResizeMode() const { return m_inResizeMode; }
void setInResizeMode(bool inResizeMode) { m_inResizeMode = inResizeMode; }
IntRect touchResizerCornerRect(const IntRect& bounds) const
{
return resizerCornerRect(bounds, ResizerForTouch);
}
int scrollWidth() const;
int scrollHeight() const;
int verticalScrollbarWidth(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
int horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
IntSize adjustedScrollOffset() const { return IntSize(scrollXOffset(), scrollYOffset()); }
void paintResizer(GraphicsContext*, const IntPoint& paintOffset, const IntRect& damageRect);
void paintOverflowControls(GraphicsContext*, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayControls);
void paintScrollCorner(GraphicsContext*, const IntPoint&, const IntRect& damageRect);
void positionOverflowControls();
void positionOverflowControls(const IntSize& offsetFromRoot);
bool isPointInResizeControl(const IntPoint& absolutePoint, ResizerHitTestType) const;
bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
bool hitTestResizerInFragments(const LayerFragments&, const HitTestLocation&) const;
LayoutRect exposeRect(const LayoutRect&, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
bool scrollsOverflow() const;
IntRect scrollCornerAndResizerRect() const;
bool needsCompositedScrolling() const;
bool adjustForForceCompositedScrollingMode(bool) const;
private:
bool hasHorizontalOverflow() const;
bool hasVerticalOverflow() const;
bool hasScrollableHorizontalOverflow() const;
bool hasScrollableVerticalOverflow() const;
void computeScrollDimensions();
IntSize clampScrollOffset(const IntSize&) const;
void setScrollOffset(const IntSize& scrollOffset) { m_scrollOffset = scrollOffset; }
IntRect rectForHorizontalScrollbar(const IntRect& borderBoxRect) const;
IntRect rectForVerticalScrollbar(const IntRect& borderBoxRect) const;
LayoutUnit verticalScrollbarStart(int minX, int maxX) const;
LayoutUnit horizontalScrollbarStart(int minX) const;
IntSize scrollbarOffset(const Scrollbar*) const;
PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
void destroyScrollbar(ScrollbarOrientation);
void setHasHorizontalScrollbar(bool hasScrollbar);
void setHasVerticalScrollbar(bool hasScrollbar);
void updateScrollCornerStyle();
IntRect resizerCornerRect(const IntRect&, ResizerHitTestType) const;
bool overflowControlsIntersectRect(const IntRect& localRect) const;
void updateResizerAreaSet();
void updateResizerStyle();
void drawPlatformResizerImage(GraphicsContext*, IntRect resizerCornerRect);
RenderLayer* layer() const;
void updateScrollableAreaSet(bool hasOverflow);
void updateCompositingLayersAfterScroll();
virtual void updateNeedsCompositedScrolling() OVERRIDE;
bool setNeedsCompositedScrolling(bool);
virtual void updateHasVisibleNonLayerContent() OVERRIDE;
void setForceNeedsCompositedScrolling(ForceNeedsCompositedScrollingMode);
RenderBox* m_box;
unsigned m_inResizeMode : 1;
unsigned m_scrollDimensionsDirty : 1;
unsigned m_inOverflowRelayout : 1;
unsigned m_needsCompositedScrolling : 1;
unsigned m_willUseCompositedScrollingHasBeenRecorded : 1;
unsigned m_isScrollableAreaHasBeenRecorded : 1;
ForceNeedsCompositedScrollingMode m_forceNeedsCompositedScrolling;
LayoutRect m_overflowRect;
IntSize m_scrollOffset;
IntPoint m_cachedOverlayScrollbarOffset;
RefPtr<Scrollbar> m_hBar;
RefPtr<Scrollbar> m_vBar;
RenderScrollbarPart* m_scrollCorner;
RenderScrollbarPart* m_resizer;
};
}
#endif