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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // Returns a rect, in the space of the area's backing graphics layer, that | 102 // Returns a rect, in the space of the area's backing graphics layer, that |
103 // contains the visual region of all scrollbar parts. | 103 // contains the visual region of all scrollbar parts. |
104 virtual LayoutRect visualRectForScrollbarParts() const = 0; | 104 virtual LayoutRect visualRectForScrollbarParts() const = 0; |
105 | 105 |
106 static bool scrollBehaviorFromString(const String&, ScrollBehavior&); | 106 static bool scrollBehaviorFromString(const String&, ScrollBehavior&); |
107 | 107 |
108 void contentAreaWillPaint() const; | 108 void contentAreaWillPaint() const; |
109 void mouseEnteredContentArea() const; | 109 void mouseEnteredContentArea() const; |
110 void mouseExitedContentArea() const; | 110 void mouseExitedContentArea() const; |
111 void mouseMovedInContentArea() const; | 111 void mouseMovedInContentArea() const; |
112 void mouseEnteredScrollbar(Scrollbar&); | 112 void mouseEnteredScrollbar(Scrollbar&) const; |
113 void mouseExitedScrollbar(Scrollbar&); | 113 void mouseExitedScrollbar(Scrollbar&) const; |
114 void mouseCapturedScrollbar(); | |
115 void mouseReleasedScrollbar(); | |
116 void contentAreaDidShow() const; | 114 void contentAreaDidShow() const; |
117 void contentAreaDidHide() const; | 115 void contentAreaDidHide() const; |
118 | 116 |
119 void finishCurrentScrollAnimations() const; | 117 void finishCurrentScrollAnimations() const; |
120 | 118 |
121 virtual void didAddScrollbar(Scrollbar&, ScrollbarOrientation); | 119 virtual void didAddScrollbar(Scrollbar&, ScrollbarOrientation); |
122 virtual void willRemoveScrollbar(Scrollbar&, ScrollbarOrientation); | 120 virtual void willRemoveScrollbar(Scrollbar&, ScrollbarOrientation); |
123 | 121 |
124 virtual void contentsResized(); | 122 virtual void contentsResized(); |
125 | 123 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 222 |
225 virtual IntRect visibleContentRect( | 223 virtual IntRect visibleContentRect( |
226 IncludeScrollbarsInRect = ExcludeScrollbars) const; | 224 IncludeScrollbarsInRect = ExcludeScrollbars) const; |
227 virtual int visibleHeight() const { return visibleContentRect().height(); } | 225 virtual int visibleHeight() const { return visibleContentRect().height(); } |
228 virtual int visibleWidth() const { return visibleContentRect().width(); } | 226 virtual int visibleWidth() const { return visibleContentRect().width(); } |
229 virtual IntSize contentsSize() const = 0; | 227 virtual IntSize contentsSize() const = 0; |
230 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } | 228 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } |
231 | 229 |
232 virtual bool shouldSuspendScrollAnimations() const { return true; } | 230 virtual bool shouldSuspendScrollAnimations() const { return true; } |
233 virtual void scrollbarStyleChanged() {} | 231 virtual void scrollbarStyleChanged() {} |
| 232 virtual void scrollbarVisibilityChanged() {} |
234 virtual bool scrollbarsCanBeActive() const = 0; | 233 virtual bool scrollbarsCanBeActive() const = 0; |
235 | 234 |
236 // Returns the bounding box of this scrollable area, in the coordinate system | 235 // Returns the bounding box of this scrollable area, in the coordinate system |
237 // of the enclosing scroll view. | 236 // of the enclosing scroll view. |
238 virtual IntRect scrollableAreaBoundingBox() const = 0; | 237 virtual IntRect scrollableAreaBoundingBox() const = 0; |
239 | 238 |
240 virtual bool scrollAnimatorEnabled() const { return false; } | 239 virtual bool scrollAnimatorEnabled() const { return false; } |
241 | 240 |
242 // NOTE: Only called from Internals for testing. | 241 // NOTE: Only called from Internals for testing. |
243 void updateScrollOffsetFromInternals(const IntSize&); | 242 void updateScrollOffsetFromInternals(const IntSize&); |
244 | 243 |
245 IntSize clampScrollOffset(const IntSize&) const; | 244 IntSize clampScrollOffset(const IntSize&) const; |
246 ScrollOffset clampScrollOffset(const ScrollOffset&) const; | 245 ScrollOffset clampScrollOffset(const ScrollOffset&) const; |
247 | 246 |
248 // Let subclasses provide a way of asking for and servicing scroll | 247 // Let subclasses provide a way of asking for and servicing scroll |
249 // animations. | 248 // animations. |
250 virtual bool scheduleAnimation(); | 249 virtual bool scheduleAnimation(); |
251 virtual void serviceScrollAnimations(double monotonicTime); | 250 virtual void serviceScrollAnimations(double monotonicTime); |
252 virtual void updateCompositorScrollAnimations(); | 251 virtual void updateCompositorScrollAnimations(); |
253 virtual void registerForAnimation() {} | 252 virtual void registerForAnimation() {} |
254 virtual void deregisterForAnimation() {} | 253 virtual void deregisterForAnimation() {} |
255 | 254 |
256 virtual bool usesCompositedScrolling() const { return false; } | 255 virtual bool usesCompositedScrolling() const { return false; } |
257 virtual bool shouldScrollOnMainThread() const; | 256 virtual bool shouldScrollOnMainThread() const; |
258 | 257 |
259 // Overlay scrollbars can "fade-out" when inactive. | 258 // Overlay scrollbars can "fade-out" when inactive. |
260 virtual bool scrollbarsHidden() const; | 259 virtual bool scrollbarsHidden() const; |
261 virtual void setScrollbarsHidden(bool); | 260 virtual void setScrollbarsHidden(bool); |
| 261 virtual void didChangeScrollbarsHidden(){}; |
262 | 262 |
263 // Returns true if the GraphicsLayer tree needs to be rebuilt. | 263 // Returns true if the GraphicsLayer tree needs to be rebuilt. |
264 virtual bool updateAfterCompositingChange() { return false; } | 264 virtual bool updateAfterCompositingChange() { return false; } |
265 | 265 |
266 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; | 266 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; |
267 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0; | 267 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0; |
268 | 268 |
269 // Convenience functions | 269 // Convenience functions |
270 float scrollOffset(ScrollbarOrientation orientation) { | 270 float scrollOffset(ScrollbarOrientation orientation) { |
271 return orientation == HorizontalScrollbar ? scrollOffsetInt().width() | 271 return orientation == HorizontalScrollbar ? scrollOffsetInt().width() |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 virtual bool isRootFrameViewport() const { return false; } | 351 virtual bool isRootFrameViewport() const { return false; } |
352 | 352 |
353 // Returns true if the scroller adjusts the scroll offset to compensate | 353 // Returns true if the scroller adjusts the scroll offset to compensate |
354 // for layout movements (bit.ly/scroll-anchoring). | 354 // for layout movements (bit.ly/scroll-anchoring). |
355 virtual bool shouldPerformScrollAnchoring() const { return false; } | 355 virtual bool shouldPerformScrollAnchoring() const { return false; } |
356 | 356 |
357 // Need to promptly let go of owned animator objects. | 357 // Need to promptly let go of owned animator objects. |
358 EAGERLY_FINALIZE(); | 358 EAGERLY_FINALIZE(); |
359 DECLARE_VIRTUAL_TRACE(); | 359 DECLARE_VIRTUAL_TRACE(); |
360 | 360 |
361 virtual void clearScrollableArea(); | 361 virtual void clearScrollAnimators(); |
362 | 362 |
363 virtual ScrollAnchor* scrollAnchor() { return nullptr; } | 363 virtual ScrollAnchor* scrollAnchor() { return nullptr; } |
364 | 364 |
365 protected: | 365 protected: |
366 ScrollableArea(); | 366 ScrollableArea(); |
367 | 367 |
368 ScrollbarOrientation scrollbarOrientationFromDirection( | 368 ScrollbarOrientation scrollbarOrientationFromDirection( |
369 ScrollDirectionPhysical) const; | 369 ScrollDirectionPhysical) const; |
370 float scrollStep(ScrollGranularity, ScrollbarOrientation) const; | 370 float scrollStep(ScrollGranularity, ScrollbarOrientation) const; |
371 | 371 |
(...skipping 11 matching lines...) Expand all Loading... |
383 return m_verticalScrollbarNeedsPaintInvalidation; | 383 return m_verticalScrollbarNeedsPaintInvalidation; |
384 } | 384 } |
385 bool scrollCornerNeedsPaintInvalidation() const { | 385 bool scrollCornerNeedsPaintInvalidation() const { |
386 return m_scrollCornerNeedsPaintInvalidation; | 386 return m_scrollCornerNeedsPaintInvalidation; |
387 } | 387 } |
388 void clearNeedsPaintInvalidationForScrollControls() { | 388 void clearNeedsPaintInvalidationForScrollControls() { |
389 m_horizontalScrollbarNeedsPaintInvalidation = false; | 389 m_horizontalScrollbarNeedsPaintInvalidation = false; |
390 m_verticalScrollbarNeedsPaintInvalidation = false; | 390 m_verticalScrollbarNeedsPaintInvalidation = false; |
391 m_scrollCornerNeedsPaintInvalidation = false; | 391 m_scrollCornerNeedsPaintInvalidation = false; |
392 } | 392 } |
393 void showOverlayScrollbars(); | |
394 virtual void scrollbarVisibilityChanged() {} | |
395 | 393 |
396 private: | 394 private: |
397 void programmaticScrollHelper(const ScrollOffset&, ScrollBehavior); | 395 void programmaticScrollHelper(const ScrollOffset&, ScrollBehavior); |
398 void userScrollHelper(const ScrollOffset&, ScrollBehavior); | 396 void userScrollHelper(const ScrollOffset&, ScrollBehavior); |
399 | 397 |
400 void fadeOverlayScrollbarsTimerFired(TimerBase*); | |
401 | |
402 // This function should be overriden by subclasses to perform the actual | 398 // This function should be overriden by subclasses to perform the actual |
403 // scroll of the content. | 399 // scroll of the content. |
404 virtual void updateScrollOffset(const ScrollOffset&, ScrollType) = 0; | 400 virtual void updateScrollOffset(const ScrollOffset&, ScrollType) = 0; |
405 | 401 |
406 virtual int lineStep(ScrollbarOrientation) const; | 402 virtual int lineStep(ScrollbarOrientation) const; |
407 virtual int pageStep(ScrollbarOrientation) const; | 403 virtual int pageStep(ScrollbarOrientation) const; |
408 virtual int documentStep(ScrollbarOrientation) const; | 404 virtual int documentStep(ScrollbarOrientation) const; |
409 virtual float pixelStep(ScrollbarOrientation) const; | 405 virtual float pixelStep(ScrollbarOrientation) const; |
410 | 406 |
411 mutable Member<ScrollAnimatorBase> m_scrollAnimator; | 407 mutable Member<ScrollAnimatorBase> m_scrollAnimator; |
412 mutable Member<ProgrammaticScrollAnimator> m_programmaticScrollAnimator; | 408 mutable Member<ProgrammaticScrollAnimator> m_programmaticScrollAnimator; |
413 | 409 |
414 std::unique_ptr<Timer<ScrollableArea>> m_fadeOverlayScrollbarsTimer; | |
415 | |
416 unsigned m_scrollbarOverlayColorTheme : 2; | 410 unsigned m_scrollbarOverlayColorTheme : 2; |
417 | 411 |
418 unsigned m_scrollOriginChanged : 1; | 412 unsigned m_scrollOriginChanged : 1; |
419 | 413 |
420 unsigned m_horizontalScrollbarNeedsPaintInvalidation : 1; | 414 unsigned m_horizontalScrollbarNeedsPaintInvalidation : 1; |
421 unsigned m_verticalScrollbarNeedsPaintInvalidation : 1; | 415 unsigned m_verticalScrollbarNeedsPaintInvalidation : 1; |
422 unsigned m_scrollCornerNeedsPaintInvalidation : 1; | 416 unsigned m_scrollCornerNeedsPaintInvalidation : 1; |
423 unsigned m_scrollbarsHidden : 1; | 417 unsigned m_scrollbarsHidden : 1; |
424 unsigned m_scrollbarCaptured : 1; | |
425 | 418 |
426 // There are 6 possible combinations of writing mode and direction. Scroll | 419 // There are 6 possible combinations of writing mode and direction. Scroll |
427 // origin will be non-zero in the x or y axis if there is any reversed | 420 // origin will be non-zero in the x or y axis if there is any reversed |
428 // direction or writing-mode. The combinations are: | 421 // direction or writing-mode. The combinations are: |
429 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set | 422 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set |
430 // horizontal-tb / ltr NO NO | 423 // horizontal-tb / ltr NO NO |
431 // horizontal-tb / rtl YES NO | 424 // horizontal-tb / rtl YES NO |
432 // vertical-lr / ltr NO NO | 425 // vertical-lr / ltr NO NO |
433 // vertical-lr / rtl NO YES | 426 // vertical-lr / rtl NO YES |
434 // vertical-rl / ltr YES NO | 427 // vertical-rl / ltr YES NO |
435 // vertical-rl / rtl YES YES | 428 // vertical-rl / rtl YES YES |
436 IntPoint m_scrollOrigin; | 429 IntPoint m_scrollOrigin; |
437 }; | 430 }; |
438 | 431 |
439 } // namespace blink | 432 } // namespace blink |
440 | 433 |
441 #endif // ScrollableArea_h | 434 #endif // ScrollableArea_h |
OLD | NEW |