| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "wtf/Noncopyable.h" | 32 #include "wtf/Noncopyable.h" |
| 33 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
| 34 | 34 |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 class FloatPoint; | 37 class FloatPoint; |
| 38 class GraphicsContext; | 38 class GraphicsContext; |
| 39 class GraphicsLayer; | 39 class GraphicsLayer; |
| 40 class PlatformGestureEvent; | 40 class PlatformGestureEvent; |
| 41 class PlatformWheelEvent; | 41 class PlatformWheelEvent; |
| 42 class ProgrammaticScrollAnimator; |
| 42 class ScrollAnimator; | 43 class ScrollAnimator; |
| 43 | 44 |
| 44 enum ScrollBehavior { | 45 enum ScrollBehavior { |
| 45 ScrollBehaviorAuto, | 46 ScrollBehaviorAuto, |
| 46 ScrollBehaviorInstant, | 47 ScrollBehaviorInstant, |
| 47 ScrollBehaviorSmooth, | 48 ScrollBehaviorSmooth, |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 enum IncludeScrollbarsInRect { | 51 enum IncludeScrollbarsInRect { |
| 51 ExcludeScrollbars, | 52 ExcludeScrollbars, |
| 52 IncludeScrollbars, | 53 IncludeScrollbars, |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 class PLATFORM_EXPORT ScrollableArea { | 56 class PLATFORM_EXPORT ScrollableArea { |
| 56 WTF_MAKE_NONCOPYABLE(ScrollableArea); | 57 WTF_MAKE_NONCOPYABLE(ScrollableArea); |
| 57 public: | 58 public: |
| 58 static int pixelsPerLineStep(); | 59 static int pixelsPerLineStep(); |
| 59 static float minFractionToStepWhenPaging(); | 60 static float minFractionToStepWhenPaging(); |
| 60 static int maxOverlapBetweenPages(); | 61 static int maxOverlapBetweenPages(); |
| 61 | 62 |
| 62 bool scroll(ScrollDirection, ScrollGranularity, float delta = 1); | 63 bool scroll(ScrollDirection, ScrollGranularity, float delta = 1); |
| 63 void scrollToOffsetWithoutAnimation(const FloatPoint&); | 64 void scrollToOffsetWithoutAnimation(const FloatPoint&); |
| 64 void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); | 65 void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); |
| 65 | 66 |
| 67 void programmaticallyScrollSmoothlyToOffset(const FloatPoint&); |
| 68 |
| 66 // Should be called when the scroll position changes externally, for example
if the scroll layer position | 69 // Should be called when the scroll position changes externally, for example
if the scroll layer position |
| 67 // is updated on the scrolling thread and we need to notify the main thread. | 70 // is updated on the scrolling thread and we need to notify the main thread. |
| 68 void notifyScrollPositionChanged(const IntPoint&); | 71 void notifyScrollPositionChanged(const IntPoint&); |
| 69 | 72 |
| 70 static bool scrollBehaviorFromString(const String&, ScrollBehavior&); | 73 static bool scrollBehaviorFromString(const String&, ScrollBehavior&); |
| 71 | 74 |
| 72 bool handleWheelEvent(const PlatformWheelEvent&); | 75 bool handleWheelEvent(const PlatformWheelEvent&); |
| 73 | 76 |
| 74 // Functions for controlling if you can scroll past the end of the document. | 77 // Functions for controlling if you can scroll past the end of the document. |
| 75 bool constrainsScrollingToContentEdge() const { return m_constrainsScrolling
ToContentEdge; } | 78 bool constrainsScrollingToContentEdge() const { return m_constrainsScrolling
ToContentEdge; } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 104 bool hasOverlayScrollbars() const; | 107 bool hasOverlayScrollbars() const; |
| 105 void setScrollbarOverlayStyle(ScrollbarOverlayStyle); | 108 void setScrollbarOverlayStyle(ScrollbarOverlayStyle); |
| 106 ScrollbarOverlayStyle scrollbarOverlayStyle() const { return static_cast<Scr
ollbarOverlayStyle>(m_scrollbarOverlayStyle); } | 109 ScrollbarOverlayStyle scrollbarOverlayStyle() const { return static_cast<Scr
ollbarOverlayStyle>(m_scrollbarOverlayStyle); } |
| 107 | 110 |
| 108 // This getter will create a ScrollAnimator if it doesn't already exist. | 111 // This getter will create a ScrollAnimator if it doesn't already exist. |
| 109 ScrollAnimator* scrollAnimator() const; | 112 ScrollAnimator* scrollAnimator() const; |
| 110 | 113 |
| 111 // This getter will return null if the ScrollAnimator hasn't been created ye
t. | 114 // This getter will return null if the ScrollAnimator hasn't been created ye
t. |
| 112 ScrollAnimator* existingScrollAnimator() const { return m_scrollAnimator.get
(); } | 115 ScrollAnimator* existingScrollAnimator() const { return m_scrollAnimator.get
(); } |
| 113 | 116 |
| 117 ProgrammaticScrollAnimator* programmaticScrollAnimator() const; |
| 118 ProgrammaticScrollAnimator* existingProgrammaticScrollAnimator() const |
| 119 { |
| 120 return m_programmaticScrollAnimator.get(); |
| 121 } |
| 122 |
| 114 const IntPoint& scrollOrigin() const { return m_scrollOrigin; } | 123 const IntPoint& scrollOrigin() const { return m_scrollOrigin; } |
| 115 bool scrollOriginChanged() const { return m_scrollOriginChanged; } | 124 bool scrollOriginChanged() const { return m_scrollOriginChanged; } |
| 116 | 125 |
| 117 // FIXME(bokan): Meaningless name, rename to isActiveFocus | 126 // FIXME(bokan): Meaningless name, rename to isActiveFocus |
| 118 virtual bool isActive() const = 0; | 127 virtual bool isActive() const = 0; |
| 119 virtual int scrollSize(ScrollbarOrientation) const = 0; | 128 virtual int scrollSize(ScrollbarOrientation) const = 0; |
| 120 virtual void invalidateScrollbar(Scrollbar*, const IntRect&); | 129 virtual void invalidateScrollbar(Scrollbar*, const IntRect&); |
| 121 virtual bool isScrollCornerVisible() const = 0; | 130 virtual bool isScrollCornerVisible() const = 0; |
| 122 virtual IntRect scrollCornerRect() const = 0; | 131 virtual IntRect scrollCornerRect() const = 0; |
| 123 virtual void invalidateScrollCorner(const IntRect&); | 132 virtual void invalidateScrollCorner(const IntRect&); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 180 |
| 172 virtual bool scrollAnimatorEnabled() const { return false; } | 181 virtual bool scrollAnimatorEnabled() const { return false; } |
| 173 | 182 |
| 174 // NOTE: Only called from Internals for testing. | 183 // NOTE: Only called from Internals for testing. |
| 175 void setScrollOffsetFromInternals(const IntPoint&); | 184 void setScrollOffsetFromInternals(const IntPoint&); |
| 176 | 185 |
| 177 IntPoint clampScrollPosition(const IntPoint&) const; | 186 IntPoint clampScrollPosition(const IntPoint&) const; |
| 178 | 187 |
| 179 // Let subclasses provide a way of asking for and servicing scroll | 188 // Let subclasses provide a way of asking for and servicing scroll |
| 180 // animations. | 189 // animations. |
| 190 virtual void registerForAnimation() { } |
| 191 virtual void deregisterForAnimation() { } |
| 181 virtual bool scheduleAnimation() { return false; } | 192 virtual bool scheduleAnimation() { return false; } |
| 182 void serviceScrollAnimations(); | 193 virtual void serviceScrollAnimations(double monotonicTime); |
| 183 | 194 |
| 184 virtual bool usesCompositedScrolling() const { return false; } | 195 virtual bool usesCompositedScrolling() const { return false; } |
| 185 | 196 |
| 186 // Returns true if the GraphicsLayer tree needs to be rebuilt. | 197 // Returns true if the GraphicsLayer tree needs to be rebuilt. |
| 187 virtual bool updateAfterCompositingChange() { return false; } | 198 virtual bool updateAfterCompositingChange() { return false; } |
| 188 | 199 |
| 189 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; | 200 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; |
| 190 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0; | 201 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0; |
| 191 | 202 |
| 203 // Notifications for compositor-driven animations. |
| 204 void notifyAnimationStarted(double monotonicTime); |
| 205 void notifyAnimationFinished(double monotonicTime); |
| 206 |
| 207 void layerForScrollingDidChange(); |
| 208 void requiresMainThreadScrollingDidChange(); |
| 209 bool canUseCompositedScrollAnimations() const; |
| 210 |
| 192 // Convenience functions | 211 // Convenience functions |
| 193 int scrollPosition(ScrollbarOrientation orientation) { return orientation ==
HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } | 212 int scrollPosition(ScrollbarOrientation orientation) { return orientation ==
HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } |
| 194 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta
tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio
n().y(); } | 213 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta
tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio
n().y(); } |
| 195 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta
tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio
n().y(); } | 214 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta
tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio
n().y(); } |
| 196 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return
std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi
on(orientation)); } | 215 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return
std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi
on(orientation)); } |
| 197 | 216 |
| 198 bool hasVerticalBarDamage() const { return m_hasVerticalBarDamage; } | 217 bool hasVerticalBarDamage() const { return m_hasVerticalBarDamage; } |
| 199 bool hasHorizontalBarDamage() const { return m_hasHorizontalBarDamage; } | 218 bool hasHorizontalBarDamage() const { return m_hasHorizontalBarDamage; } |
| 200 | 219 |
| 201 const IntRect& verticalBarDamage() const | 220 const IntRect& verticalBarDamage() const |
| (...skipping 15 matching lines...) Expand all Loading... |
| 217 } | 236 } |
| 218 virtual GraphicsLayer* layerForContainer() const; | 237 virtual GraphicsLayer* layerForContainer() const; |
| 219 virtual GraphicsLayer* layerForScrolling() const { return 0; } | 238 virtual GraphicsLayer* layerForScrolling() const { return 0; } |
| 220 virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; } | 239 virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; } |
| 221 virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; } | 240 virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; } |
| 222 virtual GraphicsLayer* layerForScrollCorner() const { return 0; } | 241 virtual GraphicsLayer* layerForScrollCorner() const { return 0; } |
| 223 bool hasLayerForHorizontalScrollbar() const; | 242 bool hasLayerForHorizontalScrollbar() const; |
| 224 bool hasLayerForVerticalScrollbar() const; | 243 bool hasLayerForVerticalScrollbar() const; |
| 225 bool hasLayerForScrollCorner() const; | 244 bool hasLayerForScrollCorner() const; |
| 226 | 245 |
| 246 void cancelProgrammaticScrollAnimation(); |
| 247 |
| 227 protected: | 248 protected: |
| 228 ScrollableArea(); | 249 ScrollableArea(); |
| 229 virtual ~ScrollableArea(); | 250 virtual ~ScrollableArea(); |
| 230 | 251 |
| 231 void setScrollOrigin(const IntPoint&); | 252 void setScrollOrigin(const IntPoint&); |
| 232 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } | 253 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } |
| 233 | 254 |
| 234 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0; | 255 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0; |
| 235 virtual void invalidateScrollCornerRect(const IntRect&) = 0; | 256 virtual void invalidateScrollCornerRect(const IntRect&) = 0; |
| 236 | 257 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 251 // This function should be overriden by subclasses to perform the actual | 272 // This function should be overriden by subclasses to perform the actual |
| 252 // scroll of the content. | 273 // scroll of the content. |
| 253 virtual void setScrollOffset(const IntPoint&) = 0; | 274 virtual void setScrollOffset(const IntPoint&) = 0; |
| 254 | 275 |
| 255 virtual int lineStep(ScrollbarOrientation) const; | 276 virtual int lineStep(ScrollbarOrientation) const; |
| 256 virtual int pageStep(ScrollbarOrientation) const; | 277 virtual int pageStep(ScrollbarOrientation) const; |
| 257 virtual int documentStep(ScrollbarOrientation) const; | 278 virtual int documentStep(ScrollbarOrientation) const; |
| 258 virtual float pixelStep(ScrollbarOrientation) const; | 279 virtual float pixelStep(ScrollbarOrientation) const; |
| 259 | 280 |
| 260 mutable OwnPtr<ScrollAnimator> m_scrollAnimator; | 281 mutable OwnPtr<ScrollAnimator> m_scrollAnimator; |
| 282 mutable OwnPtr<ProgrammaticScrollAnimator> m_programmaticScrollAnimator; |
| 261 unsigned m_constrainsScrollingToContentEdge : 1; | 283 unsigned m_constrainsScrollingToContentEdge : 1; |
| 262 | 284 |
| 263 unsigned m_inLiveResize : 1; | 285 unsigned m_inLiveResize : 1; |
| 264 | 286 |
| 265 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity | 287 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity |
| 266 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity | 288 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity |
| 267 | 289 |
| 268 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle | 290 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle |
| 269 | 291 |
| 270 unsigned m_scrollOriginChanged : 1; | 292 unsigned m_scrollOriginChanged : 1; |
| 271 | 293 |
| 272 // There are 8 possible combinations of writing mode and direction. Scroll o
rigin will be non-zero in the x or y axis | 294 // There are 8 possible combinations of writing mode and direction. Scroll o
rigin will be non-zero in the x or y axis |
| 273 // if there is any reversed direction or writing-mode. The combinations are: | 295 // if there is any reversed direction or writing-mode. The combinations are: |
| 274 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set | 296 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set |
| 275 // horizontal-tb / ltr NO NO | 297 // horizontal-tb / ltr NO NO |
| 276 // horizontal-tb / rtl YES NO | 298 // horizontal-tb / rtl YES NO |
| 277 // horizontal-bt / ltr NO YES | 299 // horizontal-bt / ltr NO YES |
| 278 // horizontal-bt / rtl YES YES | 300 // horizontal-bt / rtl YES YES |
| 279 // vertical-lr / ltr NO NO | 301 // vertical-lr / ltr NO NO |
| 280 // vertical-lr / rtl NO YES | 302 // vertical-lr / rtl NO YES |
| 281 // vertical-rl / ltr YES NO | 303 // vertical-rl / ltr YES NO |
| 282 // vertical-rl / rtl YES YES | 304 // vertical-rl / rtl YES YES |
| 283 IntPoint m_scrollOrigin; | 305 IntPoint m_scrollOrigin; |
| 284 }; | 306 }; |
| 285 | 307 |
| 286 } // namespace WebCore | 308 } // namespace WebCore |
| 287 | 309 |
| 288 #endif // ScrollableArea_h | 310 #endif // ScrollableArea_h |
| OLD | NEW |