| 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 20 matching lines...) Expand all Loading... |
| 31 #include "platform/scroll/Scrollbar.h" | 31 #include "platform/scroll/Scrollbar.h" |
| 32 #include "wtf/Noncopyable.h" | 32 #include "wtf/Noncopyable.h" |
| 33 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 class FloatPoint; | 37 class FloatPoint; |
| 38 class GraphicsLayer; | 38 class GraphicsLayer; |
| 39 class HostWindow; | 39 class HostWindow; |
| 40 class PlatformWheelEvent; | 40 class PlatformWheelEvent; |
| 41 class ProgrammaticScrollAnimator; | |
| 42 class ScrollAnimator; | 41 class ScrollAnimator; |
| 43 | 42 |
| 44 enum ScrollBehavior { | 43 enum ScrollBehavior { |
| 45 ScrollBehaviorAuto, | 44 ScrollBehaviorAuto, |
| 46 ScrollBehaviorInstant, | 45 ScrollBehaviorInstant, |
| 47 ScrollBehaviorSmooth, | 46 ScrollBehaviorSmooth, |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 enum IncludeScrollbarsInRect { | 49 enum IncludeScrollbarsInRect { |
| 51 ExcludeScrollbars, | 50 ExcludeScrollbars, |
| 52 IncludeScrollbars, | 51 IncludeScrollbars, |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 class PLATFORM_EXPORT ScrollableArea { | 54 class PLATFORM_EXPORT ScrollableArea { |
| 56 WTF_MAKE_NONCOPYABLE(ScrollableArea); | 55 WTF_MAKE_NONCOPYABLE(ScrollableArea); |
| 57 public: | 56 public: |
| 58 static int pixelsPerLineStep(); | 57 static int pixelsPerLineStep(); |
| 59 static float minFractionToStepWhenPaging(); | 58 static float minFractionToStepWhenPaging(); |
| 60 static int maxOverlapBetweenPages(); | 59 static int maxOverlapBetweenPages(); |
| 61 | 60 |
| 62 // The window that hosts the ScrollView. The ScrollView will communicate scr
olls and repaints to the | 61 // The window that hosts the ScrollView. The ScrollView will communicate scr
olls and repaints to the |
| 63 // host window in the window's coordinate space. | 62 // host window in the window's coordinate space. |
| 64 virtual HostWindow* hostWindow() const = 0; | 63 virtual HostWindow* hostWindow() const = 0; |
| 65 | 64 |
| 66 bool scroll(ScrollDirection, ScrollGranularity, float delta = 1); | 65 bool scroll(ScrollDirection, ScrollGranularity, float delta = 1); |
| 67 void scrollToOffsetWithoutAnimation(const FloatPoint&); | 66 void scrollToOffsetWithoutAnimation(const FloatPoint&); |
| 68 void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); | 67 void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); |
| 69 | 68 |
| 70 void programmaticallyScrollSmoothlyToOffset(const FloatPoint&); | |
| 71 | |
| 72 // 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 |
| 73 // 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. |
| 74 void notifyScrollPositionChanged(const IntPoint&); | 71 void notifyScrollPositionChanged(const IntPoint&); |
| 75 | 72 |
| 76 static bool scrollBehaviorFromString(const String&, ScrollBehavior&); | 73 static bool scrollBehaviorFromString(const String&, ScrollBehavior&); |
| 77 | 74 |
| 78 bool handleWheelEvent(const PlatformWheelEvent&); | 75 bool handleWheelEvent(const PlatformWheelEvent&); |
| 79 | 76 |
| 80 // 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. |
| 81 bool constrainsScrollingToContentEdge() const { return m_constrainsScrolling
ToContentEdge; } | 78 bool constrainsScrollingToContentEdge() const { return m_constrainsScrolling
ToContentEdge; } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 109 bool hasOverlayScrollbars() const; | 106 bool hasOverlayScrollbars() const; |
| 110 void setScrollbarOverlayStyle(ScrollbarOverlayStyle); | 107 void setScrollbarOverlayStyle(ScrollbarOverlayStyle); |
| 111 ScrollbarOverlayStyle scrollbarOverlayStyle() const { return static_cast<Scr
ollbarOverlayStyle>(m_scrollbarOverlayStyle); } | 108 ScrollbarOverlayStyle scrollbarOverlayStyle() const { return static_cast<Scr
ollbarOverlayStyle>(m_scrollbarOverlayStyle); } |
| 112 | 109 |
| 113 // This getter will create a ScrollAnimator if it doesn't already exist. | 110 // This getter will create a ScrollAnimator if it doesn't already exist. |
| 114 ScrollAnimator* scrollAnimator() const; | 111 ScrollAnimator* scrollAnimator() const; |
| 115 | 112 |
| 116 // This getter will return null if the ScrollAnimator hasn't been created ye
t. | 113 // This getter will return null if the ScrollAnimator hasn't been created ye
t. |
| 117 ScrollAnimator* existingScrollAnimator() const { return m_animators ? m_anim
ators->scrollAnimator.get() : 0; } | 114 ScrollAnimator* existingScrollAnimator() const { return m_animators ? m_anim
ators->scrollAnimator.get() : 0; } |
| 118 | 115 |
| 119 ProgrammaticScrollAnimator* programmaticScrollAnimator() const; | |
| 120 ProgrammaticScrollAnimator* existingProgrammaticScrollAnimator() const | |
| 121 { | |
| 122 return m_animators ? m_animators->programmaticScrollAnimator.get() : 0; | |
| 123 } | |
| 124 | |
| 125 const IntPoint& scrollOrigin() const { return m_scrollOrigin; } | 116 const IntPoint& scrollOrigin() const { return m_scrollOrigin; } |
| 126 bool scrollOriginChanged() const { return m_scrollOriginChanged; } | 117 bool scrollOriginChanged() const { return m_scrollOriginChanged; } |
| 127 | 118 |
| 128 // FIXME(bokan): Meaningless name, rename to isActiveFocus | 119 // FIXME(bokan): Meaningless name, rename to isActiveFocus |
| 129 virtual bool isActive() const = 0; | 120 virtual bool isActive() const = 0; |
| 130 virtual int scrollSize(ScrollbarOrientation) const = 0; | 121 virtual int scrollSize(ScrollbarOrientation) const = 0; |
| 131 void invalidateScrollbar(Scrollbar*, const IntRect&); | 122 void invalidateScrollbar(Scrollbar*, const IntRect&); |
| 132 | 123 |
| 133 // Convert points and rects between the scrollbar and its containing view. | 124 // Convert points and rects between the scrollbar and its containing view. |
| 134 // The client needs to implement these in order to be aware of layout effect
s | 125 // The client needs to implement these in order to be aware of layout effect
s |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 else | 175 else |
| 185 m_verticalBarDamage.unite(rect); | 176 m_verticalBarDamage.unite(rect); |
| 186 } | 177 } |
| 187 | 178 |
| 188 void resetScrollbarDamage() | 179 void resetScrollbarDamage() |
| 189 { | 180 { |
| 190 m_verticalBarDamage = IntRect(); | 181 m_verticalBarDamage = IntRect(); |
| 191 m_horizontalBarDamage = IntRect(); | 182 m_horizontalBarDamage = IntRect(); |
| 192 } | 183 } |
| 193 | 184 |
| 194 void cancelProgrammaticScrollAnimation(); | |
| 195 | |
| 196 protected: | 185 protected: |
| 197 ScrollableArea(); | 186 ScrollableArea(); |
| 198 virtual ~ScrollableArea(); | 187 virtual ~ScrollableArea(); |
| 199 | 188 |
| 200 void setScrollOrigin(const IntPoint&); | 189 void setScrollOrigin(const IntPoint&); |
| 201 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } | 190 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } |
| 202 | 191 |
| 203 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0; | 192 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0; |
| 204 | 193 |
| 205 private: | 194 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 217 int documentStep(ScrollbarOrientation) const; | 206 int documentStep(ScrollbarOrientation) const; |
| 218 virtual int pageStep(ScrollbarOrientation) const = 0; | 207 virtual int pageStep(ScrollbarOrientation) const = 0; |
| 219 float pixelStep(ScrollbarOrientation) const; | 208 float pixelStep(ScrollbarOrientation) const; |
| 220 | 209 |
| 221 // Stores the paint invalidations for the scrollbars during layout. | 210 // Stores the paint invalidations for the scrollbars during layout. |
| 222 IntRect m_horizontalBarDamage; | 211 IntRect m_horizontalBarDamage; |
| 223 IntRect m_verticalBarDamage; | 212 IntRect m_verticalBarDamage; |
| 224 | 213 |
| 225 struct ScrollableAreaAnimators { | 214 struct ScrollableAreaAnimators { |
| 226 OwnPtr<ScrollAnimator> scrollAnimator; | 215 OwnPtr<ScrollAnimator> scrollAnimator; |
| 227 OwnPtr<ProgrammaticScrollAnimator> programmaticScrollAnimator; | |
| 228 }; | 216 }; |
| 229 | 217 |
| 230 mutable OwnPtr<ScrollableAreaAnimators> m_animators; | 218 mutable OwnPtr<ScrollableAreaAnimators> m_animators; |
| 231 unsigned m_constrainsScrollingToContentEdge : 1; | 219 unsigned m_constrainsScrollingToContentEdge : 1; |
| 232 | 220 |
| 233 unsigned m_inLiveResize : 1; | 221 unsigned m_inLiveResize : 1; |
| 234 | 222 |
| 235 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity | 223 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity |
| 236 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity | 224 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity |
| 237 | 225 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 249 // vertical-lr / ltr NO NO | 237 // vertical-lr / ltr NO NO |
| 250 // vertical-lr / rtl NO YES | 238 // vertical-lr / rtl NO YES |
| 251 // vertical-rl / ltr YES NO | 239 // vertical-rl / ltr YES NO |
| 252 // vertical-rl / rtl YES YES | 240 // vertical-rl / rtl YES YES |
| 253 IntPoint m_scrollOrigin; | 241 IntPoint m_scrollOrigin; |
| 254 }; | 242 }; |
| 255 | 243 |
| 256 } // namespace blink | 244 } // namespace blink |
| 257 | 245 |
| 258 #endif // ScrollableArea_h | 246 #endif // ScrollableArea_h |
| OLD | NEW |