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; } | |
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; | 109 virtual int scrollPosition(Scrollbar*) const = 0; |
aelias_OOO_until_Jul13
2013/06/19 22:25:12
It's no longer appropriate for this call to take a
bokan
2013/06/19 23:50:58
Done (there's an existing currentPos() accessor fo
aelias_OOO_until_Jul13
2013/06/20 00:04:14
Not quite; it means maximumScrollPosition.x() == v
aelias_OOO_until_Jul13
2013/06/20 00:09:40
Err, actually what you said was correct, since we
| |
106 virtual void invalidateScrollbar(Scrollbar*, const IntRect&); | 110 virtual void invalidateScrollbar(Scrollbar*, const IntRect&); |
107 virtual bool isScrollCornerVisible() const = 0; | 111 virtual bool isScrollCornerVisible() const = 0; |
108 virtual IntRect scrollCornerRect() const = 0; | 112 virtual IntRect scrollCornerRect() const = 0; |
109 virtual void invalidateScrollCorner(const IntRect&); | 113 virtual void invalidateScrollCorner(const IntRect&); |
110 virtual void getTickmarks(Vector<IntRect>&) const { } | 114 virtual void getTickmarks(Vector<IntRect>&) const { } |
111 | 115 |
112 // Convert points and rects between the scrollbar and its containing view. | 116 // 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 | 117 // The client needs to implement these in order to be aware of layout effect s |
114 // like CSS transforms. | 118 // like CSS transforms. |
115 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar* scroll bar, const IntRect& scrollbarRect) const | 119 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar* scroll bar, const IntRect& scrollbarRect) const |
116 { | 120 { |
117 return scrollbar->Widget::convertToContainingView(scrollbarRect); | 121 return scrollbar->Widget::convertToContainingView(scrollbarRect); |
118 } | 122 } |
119 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar* scroll bar, const IntRect& parentRect) const | 123 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar* scroll bar, const IntRect& parentRect) const |
120 { | 124 { |
121 return scrollbar->Widget::convertFromContainingView(parentRect); | 125 return scrollbar->Widget::convertFromContainingView(parentRect); |
122 } | 126 } |
123 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar* scrol lbar, const IntPoint& scrollbarPoint) const | 127 virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar* scrol lbar, const IntPoint& scrollbarPoint) const |
124 { | 128 { |
125 return scrollbar->Widget::convertToContainingView(scrollbarPoint); | 129 return scrollbar->Widget::convertToContainingView(scrollbarPoint); |
126 } | 130 } |
127 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar* scrol lbar, const IntPoint& parentPoint) const | 131 virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar* scrol lbar, const IntPoint& parentPoint) const |
128 { | 132 { |
129 return scrollbar->Widget::convertFromContainingView(parentPoint); | 133 return scrollbar->Widget::convertFromContainingView(parentPoint); |
130 } | 134 } |
131 | 135 |
132 virtual Scrollbar* horizontalScrollbar() const { return 0; } | 136 virtual Scrollbar* horizontalScrollbar() const { return 0; } |
133 virtual Scrollbar* verticalScrollbar() const { return 0; } | 137 virtual Scrollbar* verticalScrollbar() const { return 0; } |
134 | 138 |
135 virtual IntPoint scrollPosition() const; | 139 virtual IntPoint scrollPosition() const = 0; |
136 virtual IntPoint minimumScrollPosition() const; | 140 virtual IntPoint minimumScrollPosition() const; |
137 virtual IntPoint maximumScrollPosition() const; | 141 virtual IntPoint maximumScrollPosition() const; |
138 | 142 |
139 enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScroll bars }; | 143 enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScroll bars }; |
140 virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars = Ex cludeScrollbars) const; | 144 virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars = Ex cludeScrollbars) const; |
141 virtual int visibleHeight() const = 0; | 145 virtual int visibleHeight() const = 0; |
142 virtual int visibleWidth() const = 0; | 146 virtual int visibleWidth() const = 0; |
143 virtual IntSize contentsSize() const = 0; | 147 virtual IntSize contentsSize() const = 0; |
144 virtual IntSize overhangAmount() const { return IntSize(); } | 148 virtual IntSize overhangAmount() const { return IntSize(); } |
145 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } | 149 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 | 172 // Let subclasses provide a way of asking for and servicing scroll |
169 // animations. | 173 // animations. |
170 virtual bool scheduleAnimation() { return false; } | 174 virtual bool scheduleAnimation() { return false; } |
171 void serviceScrollAnimations(); | 175 void serviceScrollAnimations(); |
172 | 176 |
173 virtual bool usesCompositedScrolling() const { return false; } | 177 virtual bool usesCompositedScrolling() const { return false; } |
174 virtual void updateNeedsCompositedScrolling() { } | 178 virtual void updateNeedsCompositedScrolling() { } |
175 | 179 |
176 virtual void reportMemoryUsage(MemoryObjectInfo*) const; | 180 virtual void reportMemoryUsage(MemoryObjectInfo*) const; |
177 | 181 |
182 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; | |
183 | |
178 // Convenience functions | 184 // Convenience functions |
179 int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } | 185 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(); } | 186 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(); } | 187 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)); } | 188 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi on(orientation)); } |
183 | 189 |
184 protected: | 190 protected: |
191 | |
aelias_OOO_until_Jul13
2013/06/19 22:25:12
nit: accidental newline
bokan
2013/06/19 23:50:58
Done.
| |
185 ScrollableArea(); | 192 ScrollableArea(); |
186 virtual ~ScrollableArea(); | 193 virtual ~ScrollableArea(); |
187 | 194 |
188 void setScrollOrigin(const IntPoint&); | 195 void setScrollOrigin(const IntPoint&); |
189 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } | 196 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } |
190 | 197 |
191 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0; | 198 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0; |
192 virtual void invalidateScrollCornerRect(const IntRect&) = 0; | 199 virtual void invalidateScrollCornerRect(const IntRect&) = 0; |
193 | 200 |
194 friend class ScrollingCoordinator; | 201 friend class ScrollingCoordinator; |
195 virtual GraphicsLayer* layerForScrolling() const { return 0; } | 202 virtual GraphicsLayer* layerForScrolling() const { return 0; } |
196 virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; } | 203 virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; } |
197 virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; } | 204 virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; } |
198 virtual GraphicsLayer* layerForScrollCorner() const { return 0; } | 205 virtual GraphicsLayer* layerForScrollCorner() const { return 0; } |
199 #if ENABLE(RUBBER_BANDING) | 206 #if ENABLE(RUBBER_BANDING) |
200 virtual GraphicsLayer* layerForOverhangAreas() const { return 0; } | 207 virtual GraphicsLayer* layerForOverhangAreas() const { return 0; } |
201 #endif | 208 #endif |
202 bool hasLayerForHorizontalScrollbar() const; | 209 bool hasLayerForHorizontalScrollbar() const; |
203 bool hasLayerForVerticalScrollbar() const; | 210 bool hasLayerForVerticalScrollbar() const; |
204 bool hasLayerForScrollCorner() const; | 211 bool hasLayerForScrollCorner() const; |
205 | 212 |
206 private: | 213 private: |
207 void scrollPositionChanged(const IntPoint&); | 214 void scrollPositionChanged(const IntPoint&); |
208 | 215 |
209 // NOTE: Only called from the ScrollAnimator. | 216 // NOTE: Only called from the ScrollAnimator. |
210 friend class ScrollAnimator; | 217 friend class ScrollAnimator; |
211 void setScrollOffsetFromAnimation(const IntPoint&); | 218 void setScrollOffsetFromAnimation(const IntPoint&); |
212 | 219 |
213 // This function should be overriden by subclasses to perform the actual | 220 // This function should be overriden by subclasses to perform the actual |
214 // scroll of the content. | 221 // scroll of the content. |
215 virtual void setScrollOffset(const IntPoint&) = 0; | 222 virtual void setScrollOffset(const IntPoint&) = 0; |
216 | 223 |
224 virtual int lineStep(ScrollbarOrientation) const; | |
225 virtual int pageStep(ScrollbarOrientation) const; | |
226 virtual int documentStep(ScrollbarOrientation) const; | |
227 virtual float pixelStep(ScrollbarOrientation) const; | |
228 | |
217 mutable OwnPtr<ScrollAnimator> m_scrollAnimator; | 229 mutable OwnPtr<ScrollAnimator> m_scrollAnimator; |
218 unsigned m_constrainsScrollingToContentEdge : 1; | 230 unsigned m_constrainsScrollingToContentEdge : 1; |
219 | 231 |
220 unsigned m_inLiveResize : 1; | 232 unsigned m_inLiveResize : 1; |
221 | 233 |
222 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity | 234 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity |
223 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity | 235 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity |
224 | 236 |
225 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle | 237 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle |
226 | 238 |
227 unsigned m_scrollOriginChanged : 1; | 239 unsigned m_scrollOriginChanged : 1; |
228 | 240 |
229 // There are 8 possible combinations of writing mode and direction. Scroll o rigin will be non-zero in the x or y axis | 241 // 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: | 242 // if there is any reversed direction or writing-mode. The combinations are: |
231 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set | 243 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set |
232 // horizontal-tb / ltr NO NO | 244 // horizontal-tb / ltr NO NO |
233 // horizontal-tb / rtl YES NO | 245 // horizontal-tb / rtl YES NO |
234 // horizontal-bt / ltr NO YES | 246 // horizontal-bt / ltr NO YES |
235 // horizontal-bt / rtl YES YES | 247 // horizontal-bt / rtl YES YES |
236 // vertical-lr / ltr NO NO | 248 // vertical-lr / ltr NO NO |
237 // vertical-lr / rtl NO YES | 249 // vertical-lr / rtl NO YES |
238 // vertical-rl / ltr YES NO | 250 // vertical-rl / ltr YES NO |
239 // vertical-rl / rtl YES YES | 251 // vertical-rl / rtl YES YES |
240 IntPoint m_scrollOrigin; | 252 IntPoint m_scrollOrigin; |
241 }; | 253 }; |
242 | 254 |
243 } // namespace WebCore | 255 } // namespace WebCore |
244 | 256 |
245 #endif // ScrollableArea_h | 257 #endif // ScrollableArea_h |
OLD | NEW |