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 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef ScrollableArea_h | 26 #ifndef ScrollableArea_h |
27 #define ScrollableArea_h | 27 #define ScrollableArea_h |
28 | 28 |
29 #include "platform/PlatformExport.h" | 29 #include "platform/PlatformExport.h" |
30 #include "platform/RuntimeEnabledFeatures.h" | 30 #include "platform/RuntimeEnabledFeatures.h" |
31 #include "platform/geometry/DoublePoint.h" | 31 #include "platform/geometry/DoublePoint.h" |
| 32 #include "platform/heap/Handle.h" |
32 #include "platform/scroll/ScrollAnimator.h" | 33 #include "platform/scroll/ScrollAnimator.h" |
33 #include "platform/scroll/ScrollTypes.h" | 34 #include "platform/scroll/ScrollTypes.h" |
34 #include "platform/scroll/Scrollbar.h" | 35 #include "platform/scroll/Scrollbar.h" |
35 #include "wtf/Noncopyable.h" | 36 #include "wtf/Noncopyable.h" |
36 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 class DoubleRect; | 41 class DoubleRect; |
41 class FloatPoint; | 42 class FloatPoint; |
42 class GraphicsLayer; | 43 class GraphicsLayer; |
43 class HostWindow; | 44 class HostWindow; |
44 class PlatformWheelEvent; | 45 class PlatformWheelEvent; |
45 class ProgrammaticScrollAnimator; | 46 class ProgrammaticScrollAnimator; |
46 struct ScrollAlignment; | 47 struct ScrollAlignment; |
47 class ScrollAnimator; | 48 class ScrollAnimator; |
48 | 49 |
49 enum ScrollBehavior { | 50 enum ScrollBehavior { |
50 ScrollBehaviorAuto, | 51 ScrollBehaviorAuto, |
51 ScrollBehaviorInstant, | 52 ScrollBehaviorInstant, |
52 ScrollBehaviorSmooth, | 53 ScrollBehaviorSmooth, |
53 }; | 54 }; |
54 | 55 |
55 enum IncludeScrollbarsInRect { | 56 enum IncludeScrollbarsInRect { |
56 ExcludeScrollbars, | 57 ExcludeScrollbars, |
57 IncludeScrollbars, | 58 IncludeScrollbars, |
58 }; | 59 }; |
59 | 60 |
| 61 #if ENABLE(OILPAN) |
| 62 // Oilpan: Using the transition type WillBeGarbageCollectedMixin is |
| 63 // problematic non-Oilpan as the type expands to DummyBase, exporting it |
| 64 // also from 'platform' as a result. Bringing about duplicate DummyBases |
| 65 // as core also exports same; with component build linking fails as a |
| 66 // result. Hence the workaround of not using a transition type. |
| 67 class PLATFORM_EXPORT ScrollableArea : public GarbageCollectedMixin { |
| 68 #else |
60 class PLATFORM_EXPORT ScrollableArea { | 69 class PLATFORM_EXPORT ScrollableArea { |
| 70 #endif |
61 WTF_MAKE_NONCOPYABLE(ScrollableArea); | 71 WTF_MAKE_NONCOPYABLE(ScrollableArea); |
62 public: | 72 public: |
63 static int pixelsPerLineStep(); | 73 static int pixelsPerLineStep(); |
64 static float minFractionToStepWhenPaging(); | 74 static float minFractionToStepWhenPaging(); |
65 static int maxOverlapBetweenPages(); | 75 static int maxOverlapBetweenPages(); |
66 | 76 |
67 // Convert a non-finite scroll value (Infinity, -Infinity, NaN) to 0 as | 77 // Convert a non-finite scroll value (Infinity, -Infinity, NaN) to 0 as |
68 // per http://dev.w3.org/csswg/cssom-view/#normalize-non_finite-values. | 78 // per http://dev.w3.org/csswg/cssom-view/#normalize-non_finite-values. |
69 static double normalizeNonFiniteScroll(double value) { return std::isfinite(
value) ? value : 0.0; } | 79 static double normalizeNonFiniteScroll(double value) { return std::isfinite(
value) ? value : 0.0; } |
70 | 80 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // TODO(bokan): FrameView::setScrollPosition uses updateScrollbars to scroll | 292 // TODO(bokan): FrameView::setScrollPosition uses updateScrollbars to scroll |
283 // which bails out early if its already in updateScrollbars, the effect bein
g | 293 // which bails out early if its already in updateScrollbars, the effect bein
g |
284 // that programmatic scrolls (i.e. setScrollPosition) are disabled when in | 294 // that programmatic scrolls (i.e. setScrollPosition) are disabled when in |
285 // updateScrollbars. Expose this here to allow RootFrameViewport to match th
e | 295 // updateScrollbars. Expose this here to allow RootFrameViewport to match th
e |
286 // semantics for now but it should be cleaned up at the source. | 296 // semantics for now but it should be cleaned up at the source. |
287 virtual bool isProgrammaticallyScrollable() { return true; } | 297 virtual bool isProgrammaticallyScrollable() { return true; } |
288 | 298 |
289 // Subtracts space occupied by this ScrollableArea's scrollbars. | 299 // Subtracts space occupied by this ScrollableArea's scrollbars. |
290 // Does nothing if overlay scrollbars are enabled. | 300 // Does nothing if overlay scrollbars are enabled. |
291 IntSize excludeScrollbars(const IntSize&) const; | 301 IntSize excludeScrollbars(const IntSize&) const; |
| 302 |
| 303 // Need to promptly let go of owned animator objects. |
| 304 EAGERLY_FINALIZE(); |
| 305 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 306 |
292 protected: | 307 protected: |
293 ScrollableArea(); | 308 ScrollableArea(); |
294 | 309 |
295 void setScrollOrigin(const IntPoint&); | 310 void setScrollOrigin(const IntPoint&); |
296 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } | 311 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } |
297 | 312 |
298 // Needed to let the animators call scrollPositionChanged. | 313 // Needed to let the animators call scrollPositionChanged. |
299 friend class ScrollAnimator; | 314 friend class ScrollAnimator; |
300 friend class ProgrammaticScrollAnimator; | 315 friend class ProgrammaticScrollAnimator; |
301 void scrollPositionChanged(const DoublePoint&, ScrollType); | 316 void scrollPositionChanged(const DoublePoint&, ScrollType); |
302 | 317 |
| 318 void clearScrollAnimators(); |
| 319 |
303 private: | 320 private: |
304 void programmaticScrollHelper(const DoublePoint&, ScrollBehavior); | 321 void programmaticScrollHelper(const DoublePoint&, ScrollBehavior); |
305 void userScrollHelper(const DoublePoint&, ScrollBehavior); | 322 void userScrollHelper(const DoublePoint&, ScrollBehavior); |
306 | 323 |
307 // This function should be overriden by subclasses to perform the actual | 324 // This function should be overriden by subclasses to perform the actual |
308 // scroll of the content. By default the DoublePoint version will just | 325 // scroll of the content. By default the DoublePoint version will just |
309 // call into the IntPoint version. If fractional scroll is needed, one | 326 // call into the IntPoint version. If fractional scroll is needed, one |
310 // can override the DoublePoint version to take advantage of the double | 327 // can override the DoublePoint version to take advantage of the double |
311 // precision scroll offset. | 328 // precision scroll offset. |
312 // FIXME: Remove the IntPoint version. And change the function to | 329 // FIXME: Remove the IntPoint version. And change the function to |
313 // take DoubleSize. crbug.com/414283. | 330 // take DoubleSize. crbug.com/414283. |
314 virtual void setScrollOffset(const IntPoint&, ScrollType) = 0; | 331 virtual void setScrollOffset(const IntPoint&, ScrollType) = 0; |
315 virtual void setScrollOffset(const DoublePoint& offset, ScrollType scrollTyp
e) | 332 virtual void setScrollOffset(const DoublePoint& offset, ScrollType scrollTyp
e) |
316 { | 333 { |
317 setScrollOffset(flooredIntPoint(offset), scrollType); | 334 setScrollOffset(flooredIntPoint(offset), scrollType); |
318 } | 335 } |
319 | 336 |
320 virtual int lineStep(ScrollbarOrientation) const; | 337 virtual int lineStep(ScrollbarOrientation) const; |
321 virtual int pageStep(ScrollbarOrientation) const; | 338 virtual int pageStep(ScrollbarOrientation) const; |
322 virtual int documentStep(ScrollbarOrientation) const; | 339 virtual int documentStep(ScrollbarOrientation) const; |
323 virtual float pixelStep(ScrollbarOrientation) const; | 340 virtual float pixelStep(ScrollbarOrientation) const; |
324 | 341 |
325 // Stores the paint invalidations for the scrollbars during layout. | 342 // Stores the paint invalidations for the scrollbars during layout. |
326 IntRect m_horizontalBarDamage; | 343 IntRect m_horizontalBarDamage; |
327 IntRect m_verticalBarDamage; | 344 IntRect m_verticalBarDamage; |
328 | 345 |
329 struct ScrollableAreaAnimators { | 346 struct ScrollableAreaAnimators { |
330 RefPtr<ScrollAnimator> scrollAnimator; | 347 OwnPtr<ScrollAnimator> scrollAnimator; |
331 OwnPtr<ProgrammaticScrollAnimator> programmaticScrollAnimator; | 348 OwnPtr<ProgrammaticScrollAnimator> programmaticScrollAnimator; |
332 }; | 349 }; |
333 | 350 |
334 mutable OwnPtr<ScrollableAreaAnimators> m_animators; | 351 mutable OwnPtr<ScrollableAreaAnimators> m_animators; |
335 | 352 |
336 unsigned m_inLiveResize : 1; | 353 unsigned m_inLiveResize : 1; |
337 | 354 |
338 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle | 355 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle |
339 | 356 |
340 unsigned m_scrollOriginChanged : 1; | 357 unsigned m_scrollOriginChanged : 1; |
341 | 358 |
342 // There are 8 possible combinations of writing mode and direction. Scroll o
rigin will be non-zero in the x or y axis | 359 // There are 8 possible combinations of writing mode and direction. Scroll o
rigin will be non-zero in the x or y axis |
343 // if there is any reversed direction or writing-mode. The combinations are: | 360 // if there is any reversed direction or writing-mode. The combinations are: |
344 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set | 361 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set |
345 // horizontal-tb / ltr NO NO | 362 // horizontal-tb / ltr NO NO |
346 // horizontal-tb / rtl YES NO | 363 // horizontal-tb / rtl YES NO |
347 // horizontal-bt / ltr NO YES | 364 // horizontal-bt / ltr NO YES |
348 // horizontal-bt / rtl YES YES | 365 // horizontal-bt / rtl YES YES |
349 // vertical-lr / ltr NO NO | 366 // vertical-lr / ltr NO NO |
350 // vertical-lr / rtl NO YES | 367 // vertical-lr / rtl NO YES |
351 // vertical-rl / ltr YES NO | 368 // vertical-rl / ltr YES NO |
352 // vertical-rl / rtl YES YES | 369 // vertical-rl / rtl YES YES |
353 IntPoint m_scrollOrigin; | 370 IntPoint m_scrollOrigin; |
354 }; | 371 }; |
355 | 372 |
356 } // namespace blink | 373 } // namespace blink |
357 | 374 |
358 #endif // ScrollableArea_h | 375 #endif // ScrollableArea_h |
OLD | NEW |