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(); |
| 44 static float minFractionToStepWhenPaging(); |
| 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 // scrollPosition is relative to the scrollOrigin. i.e. If the page is RTL |
136 virtual IntPoint minimumScrollPosition() const; | 139 // then scrollPosition will be negative. |
137 virtual IntPoint maximumScrollPosition() const; | 140 virtual IntPoint scrollPosition() const = 0; |
| 141 virtual IntPoint minimumScrollPosition() const = 0; |
| 142 virtual IntPoint maximumScrollPosition() const = 0; |
138 | 143 |
139 enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScroll
bars }; | 144 enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScroll
bars }; |
140 virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars = Ex
cludeScrollbars) const; | 145 virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars = Ex
cludeScrollbars) const; |
141 virtual int visibleHeight() const = 0; | 146 virtual int visibleHeight() const = 0; |
142 virtual int visibleWidth() const = 0; | 147 virtual int visibleWidth() const = 0; |
143 virtual IntSize contentsSize() const = 0; | 148 virtual IntSize contentsSize() const = 0; |
144 virtual IntSize overhangAmount() const { return IntSize(); } | 149 virtual IntSize overhangAmount() const { return IntSize(); } |
145 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } | 150 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } |
146 | 151 |
147 virtual bool shouldSuspendScrollAnimations() const { return true; } | 152 virtual bool shouldSuspendScrollAnimations() const { return true; } |
(...skipping 18 matching lines...) Expand all Loading... |
166 IntPoint clampScrollPosition(const IntPoint&) const; | 171 IntPoint clampScrollPosition(const IntPoint&) const; |
167 | 172 |
168 // Let subclasses provide a way of asking for and servicing scroll | 173 // Let subclasses provide a way of asking for and servicing scroll |
169 // animations. | 174 // animations. |
170 virtual bool scheduleAnimation() { return false; } | 175 virtual bool scheduleAnimation() { return false; } |
171 void serviceScrollAnimations(); | 176 void serviceScrollAnimations(); |
172 | 177 |
173 virtual bool usesCompositedScrolling() const { return false; } | 178 virtual bool usesCompositedScrolling() const { return false; } |
174 virtual void updateNeedsCompositedScrolling() { } | 179 virtual void updateNeedsCompositedScrolling() { } |
175 | 180 |
| 181 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; |
| 182 |
176 // Convenience functions | 183 // Convenience functions |
177 int scrollPosition(ScrollbarOrientation orientation) { return orientation ==
HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } | 184 int scrollPosition(ScrollbarOrientation orientation) { return orientation ==
HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } |
178 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(); } |
179 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(); } |
180 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)); } |
181 | 188 |
182 protected: | 189 protected: |
183 ScrollableArea(); | 190 ScrollableArea(); |
184 virtual ~ScrollableArea(); | 191 virtual ~ScrollableArea(); |
185 | 192 |
(...skipping 19 matching lines...) Expand all Loading... |
205 void scrollPositionChanged(const IntPoint&); | 212 void scrollPositionChanged(const IntPoint&); |
206 | 213 |
207 // NOTE: Only called from the ScrollAnimator. | 214 // NOTE: Only called from the ScrollAnimator. |
208 friend class ScrollAnimator; | 215 friend class ScrollAnimator; |
209 void setScrollOffsetFromAnimation(const IntPoint&); | 216 void setScrollOffsetFromAnimation(const IntPoint&); |
210 | 217 |
211 // This function should be overriden by subclasses to perform the actual | 218 // This function should be overriden by subclasses to perform the actual |
212 // scroll of the content. | 219 // scroll of the content. |
213 virtual void setScrollOffset(const IntPoint&) = 0; | 220 virtual void setScrollOffset(const IntPoint&) = 0; |
214 | 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 |
215 mutable OwnPtr<ScrollAnimator> m_scrollAnimator; | 227 mutable OwnPtr<ScrollAnimator> m_scrollAnimator; |
216 unsigned m_constrainsScrollingToContentEdge : 1; | 228 unsigned m_constrainsScrollingToContentEdge : 1; |
217 | 229 |
218 unsigned m_inLiveResize : 1; | 230 unsigned m_inLiveResize : 1; |
219 | 231 |
220 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity | 232 unsigned m_verticalScrollElasticity : 2; // ScrollElasticity |
221 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity | 233 unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity |
222 | 234 |
223 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle | 235 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle |
224 | 236 |
225 unsigned m_scrollOriginChanged : 1; | 237 unsigned m_scrollOriginChanged : 1; |
226 | 238 |
227 // 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 |
228 // 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: |
229 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set | 241 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set |
230 // horizontal-tb / ltr NO NO | 242 // horizontal-tb / ltr NO NO |
231 // horizontal-tb / rtl YES NO | 243 // horizontal-tb / rtl YES NO |
232 // horizontal-bt / ltr NO YES | 244 // horizontal-bt / ltr NO YES |
233 // horizontal-bt / rtl YES YES | 245 // horizontal-bt / rtl YES YES |
234 // vertical-lr / ltr NO NO | 246 // vertical-lr / ltr NO NO |
235 // vertical-lr / rtl NO YES | 247 // vertical-lr / rtl NO YES |
236 // vertical-rl / ltr YES NO | 248 // vertical-rl / ltr YES NO |
237 // vertical-rl / rtl YES YES | 249 // vertical-rl / rtl YES YES |
238 IntPoint m_scrollOrigin; | 250 IntPoint m_scrollOrigin; |
239 }; | 251 }; |
240 | 252 |
241 } // namespace WebCore | 253 } // namespace WebCore |
242 | 254 |
243 #endif // ScrollableArea_h | 255 #endif // ScrollableArea_h |
OLD | NEW |