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 22 matching lines...) Expand all Loading... | |
33 | 33 |
34 class FloatPoint; | 34 class FloatPoint; |
35 class GraphicsContext; | 35 class GraphicsContext; |
36 class GraphicsLayer; | 36 class GraphicsLayer; |
37 class PlatformGestureEvent; | 37 class PlatformGestureEvent; |
38 class PlatformWheelEvent; | 38 class PlatformWheelEvent; |
39 class ScrollAnimator; | 39 class ScrollAnimator; |
40 | 40 |
41 class ScrollableArea { | 41 class ScrollableArea { |
42 public: | 42 public: |
43 static int pixelsPerLineStep() { return 40; } | |
aelias_OOO_until_Jul13
2013/06/20 00:04:14
nit: move the implementations into ScrollableArea.
bokan
2013/06/20 19:00:16
Done.
| |
44 static float minFractionToStepWhenPaging() { return 0.875f; } | |
45 static int maxOverlapBetweenPages(); | |
46 | |
43 bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1); | 47 bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1); |
44 void scrollToOffsetWithoutAnimation(const FloatPoint&); | 48 void scrollToOffsetWithoutAnimation(const FloatPoint&); |
45 void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); | 49 void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); |
46 | 50 |
47 // Should be called when the scroll position changes externally, for example if the scroll layer position | 51 // Should be called when the scroll position changes externally, for example if the scroll layer position |
48 // is updated on the scrolling thread and we need to notify the main thread. | 52 // is updated on the scrolling thread and we need to notify the main thread. |
49 void notifyScrollPositionChanged(const IntPoint&); | 53 void notifyScrollPositionChanged(const IntPoint&); |
50 | 54 |
51 // Allows subclasses to handle scroll position updates themselves. If this m ember function | 55 // Allows subclasses to handle scroll position updates themselves. If this m ember function |
52 // returns true, the scrollable area won't actually update the scroll positi on and instead | 56 // returns true, the scrollable area won't actually update the scroll positi on and instead |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 ScrollAnimator* scrollAnimator() const; | 99 ScrollAnimator* scrollAnimator() const; |
96 | 100 |
97 // This getter will return null if the ScrollAnimator hasn't been created ye t. | 101 // This getter will return null if the ScrollAnimator hasn't been created ye t. |
98 ScrollAnimator* existingScrollAnimator() const { return m_scrollAnimator.get (); } | 102 ScrollAnimator* existingScrollAnimator() const { return m_scrollAnimator.get (); } |
99 | 103 |
100 const IntPoint& scrollOrigin() const { return m_scrollOrigin; } | 104 const IntPoint& scrollOrigin() const { return m_scrollOrigin; } |
101 bool scrollOriginChanged() const { return m_scrollOriginChanged; } | 105 bool scrollOriginChanged() const { return m_scrollOriginChanged; } |
102 | 106 |
103 virtual bool isActive() const = 0; | 107 virtual bool isActive() const = 0; |
104 virtual int scrollSize(ScrollbarOrientation) const = 0; | 108 virtual int scrollSize(ScrollbarOrientation) const = 0; |
105 virtual int scrollPosition(Scrollbar*) const = 0; | |
106 virtual void invalidateScrollbar(Scrollbar*, const IntRect&); | 109 virtual void invalidateScrollbar(Scrollbar*, const IntRect&); |
107 virtual bool isScrollCornerVisible() const = 0; | 110 virtual bool isScrollCornerVisible() const = 0; |
108 virtual IntRect scrollCornerRect() const = 0; | 111 virtual IntRect scrollCornerRect() const = 0; |
109 virtual void invalidateScrollCorner(const IntRect&); | 112 virtual void invalidateScrollCorner(const IntRect&); |
110 virtual void getTickmarks(Vector<IntRect>&) const { } | 113 virtual void getTickmarks(Vector<IntRect>&) const { } |
111 | 114 |
112 // Convert points and rects between the scrollbar and its containing view. | 115 // Convert points and rects between the scrollbar and its containing view. |
113 // The client needs to implement these in order to be aware of layout effect s | 116 // The client needs to implement these in order to be aware of layout effect s |
114 // like CSS transforms. | 117 // like CSS transforms. |
115 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar* scroll bar, const IntRect& scrollbarRect) const | 118 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar* scroll bar, const IntRect& scrollbarRect) const |
116 { | 119 { |
117 return scrollbar->Widget::convertToContainingView(scrollbarRect); | 120 return scrollbar->Widget::convertToContainingView(scrollbarRect); |
118 } | 121 } |
119 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar* scroll bar, const IntRect& parentRect) const | 122 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar* scroll bar, const IntRect& parentRect) const |
120 { | 123 { |
121 return scrollbar->Widget::convertFromContainingView(parentRect); | 124 return scrollbar->Widget::convertFromContainingView(parentRect); |
122 } | 125 } |
123 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar* scrol lbar, const IntPoint& scrollbarPoint) const | 126 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar* scrol lbar, const IntPoint& scrollbarPoint) const |
124 { | 127 { |
125 return scrollbar->Widget::convertToContainingView(scrollbarPoint); | 128 return scrollbar->Widget::convertToContainingView(scrollbarPoint); |
126 } | 129 } |
127 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar* scrol lbar, const IntPoint& parentPoint) const | 130 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar* scrol lbar, const IntPoint& parentPoint) const |
128 { | 131 { |
129 return scrollbar->Widget::convertFromContainingView(parentPoint); | 132 return scrollbar->Widget::convertFromContainingView(parentPoint); |
130 } | 133 } |
131 | 134 |
132 virtual Scrollbar* horizontalScrollbar() const { return 0; } | 135 virtual Scrollbar* horizontalScrollbar() const { return 0; } |
133 virtual Scrollbar* verticalScrollbar() const { return 0; } | 136 virtual Scrollbar* verticalScrollbar() const { return 0; } |
134 | 137 |
135 virtual IntPoint scrollPosition() const; | 138 virtual IntPoint scrollPosition() const = 0; |
136 virtual IntPoint minimumScrollPosition() const; | 139 virtual IntPoint minimumScrollPosition() const; |
137 virtual IntPoint maximumScrollPosition() const; | 140 virtual IntPoint maximumScrollPosition() const; |
138 | 141 |
139 enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScroll bars }; | 142 enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScroll bars }; |
140 virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars = Ex cludeScrollbars) const; | 143 virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars = Ex cludeScrollbars) const; |
141 virtual int visibleHeight() const = 0; | 144 virtual int visibleHeight() const = 0; |
142 virtual int visibleWidth() const = 0; | 145 virtual int visibleWidth() const = 0; |
143 virtual IntSize contentsSize() const = 0; | 146 virtual IntSize contentsSize() const = 0; |
144 virtual IntSize overhangAmount() const { return IntSize(); } | 147 virtual IntSize overhangAmount() const { return IntSize(); } |
145 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } | 148 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } |
(...skipping 22 matching lines...) Expand all Loading... | |
168 // Let subclasses provide a way of asking for and servicing scroll | 171 // Let subclasses provide a way of asking for and servicing scroll |
169 // animations. | 172 // animations. |
170 virtual bool scheduleAnimation() { return false; } | 173 virtual bool scheduleAnimation() { return false; } |
171 void serviceScrollAnimations(); | 174 void serviceScrollAnimations(); |
172 | 175 |
173 virtual bool usesCompositedScrolling() const { return false; } | 176 virtual bool usesCompositedScrolling() const { return false; } |
174 virtual void updateNeedsCompositedScrolling() { } | 177 virtual void updateNeedsCompositedScrolling() { } |
175 | 178 |
176 virtual void reportMemoryUsage(MemoryObjectInfo*) const; | 179 virtual void reportMemoryUsage(MemoryObjectInfo*) const; |
177 | 180 |
181 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; | |
182 | |
178 // Convenience functions | 183 // Convenience functions |
179 int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } | 184 int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } |
180 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio n().y(); } | 185 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio n().y(); } |
181 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio n().y(); } | 186 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio n().y(); } |
182 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi on(orientation)); } | 187 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi on(orientation)); } |
183 | 188 |
184 protected: | 189 protected: |
185 ScrollableArea(); | 190 ScrollableArea(); |
186 virtual ~ScrollableArea(); | 191 virtual ~ScrollableArea(); |
187 | 192 |
(...skipping 10 matching lines...) Expand all Loading... | |
198 virtual GraphicsLayer* layerForScrollCorner() const { return 0; } | 203 virtual GraphicsLayer* layerForScrollCorner() const { return 0; } |
199 #if ENABLE(RUBBER_BANDING) | 204 #if ENABLE(RUBBER_BANDING) |
200 virtual GraphicsLayer* layerForOverhangAreas() const { return 0; } | 205 virtual GraphicsLayer* layerForOverhangAreas() const { return 0; } |
201 #endif | 206 #endif |
202 bool hasLayerForHorizontalScrollbar() const; | 207 bool hasLayerForHorizontalScrollbar() const; |
203 bool hasLayerForVerticalScrollbar() const; | 208 bool hasLayerForVerticalScrollbar() const; |
204 bool hasLayerForScrollCorner() const; | 209 bool hasLayerForScrollCorner() const; |
205 | 210 |
206 private: | 211 private: |
207 void scrollPositionChanged(const IntPoint&); | 212 void scrollPositionChanged(const IntPoint&); |
208 | 213 |
209 // NOTE: Only called from the ScrollAnimator. | 214 // NOTE: Only called from the ScrollAnimator. |
210 friend class ScrollAnimator; | 215 friend class ScrollAnimator; |
211 void setScrollOffsetFromAnimation(const IntPoint&); | 216 void setScrollOffsetFromAnimation(const IntPoint&); |
212 | 217 |
213 // This function should be overriden by subclasses to perform the actual | 218 // This function should be overriden by subclasses to perform the actual |
214 // scroll of the content. | 219 // scroll of the content. |
215 virtual void setScrollOffset(const IntPoint&) = 0; | 220 virtual void setScrollOffset(const IntPoint&) = 0; |
216 | 221 |
222 virtual int lineStep(ScrollbarOrientation) const; | |
223 virtual int pageStep(ScrollbarOrientation) const = 0; | |
224 virtual int documentStep(ScrollbarOrientation) const; | |
225 virtual float pixelStep(ScrollbarOrientation) const; | |
226 | |
217 mutable OwnPtr<ScrollAnimator> m_scrollAnimator; | 227 mutable OwnPtr<ScrollAnimator> m_scrollAnimator; |
218 unsigned m_constrainsScrollingToContentEdge : 1; | 228 unsigned m_constrainsScrollingToContentEdge : 1; |
219 | 229 |
220 unsigned m_inLiveResize : 1; | 230 unsigned m_inLiveResize : 1; |
221 | 231 |
222 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity | 232 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity |
223 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity | 233 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity |
224 | 234 |
225 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle | 235 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle |
226 | 236 |
227 unsigned m_scrollOriginChanged : 1; | 237 unsigned m_scrollOriginChanged : 1; |
228 | 238 |
229 // There are 8 possible combinations of writing mode and direction. Scroll o rigin will be non-zero in the x or y axis | 239 // There are 8 possible combinations of writing mode and direction. Scroll o rigin will be non-zero in the x or y axis |
230 // if there is any reversed direction or writing-mode. The combinations are: | 240 // if there is any reversed direction or writing-mode. The combinations are: |
231 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set | 241 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set |
232 // horizontal-tb / ltr NO NO | 242 // horizontal-tb / ltr NO NO |
233 // horizontal-tb / rtl YES NO | 243 // horizontal-tb / rtl YES NO |
234 // horizontal-bt / ltr NO YES | 244 // horizontal-bt / ltr NO YES |
235 // horizontal-bt / rtl YES YES | 245 // horizontal-bt / rtl YES YES |
236 // vertical-lr / ltr NO NO | 246 // vertical-lr / ltr NO NO |
237 // vertical-lr / rtl NO YES | 247 // vertical-lr / rtl NO YES |
238 // vertical-rl / ltr YES NO | 248 // vertical-rl / ltr YES NO |
239 // vertical-rl / rtl YES YES | 249 // vertical-rl / rtl YES YES |
240 IntPoint m_scrollOrigin; | 250 IntPoint m_scrollOrigin; |
241 }; | 251 }; |
242 | 252 |
243 } // namespace WebCore | 253 } // namespace WebCore |
244 | 254 |
245 #endif // ScrollableArea_h | 255 #endif // ScrollableArea_h |
OLD | NEW |