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&) const; | 112 void mouseEnteredScrollbar(Scrollbar&); |
113 void mouseExitedScrollbar(Scrollbar&) const; | 113 void mouseExitedScrollbar(Scrollbar&); |
| 114 void mouseCapturedScrollbar(); |
| 115 void mouseReleasedScrollbar(); |
114 void contentAreaDidShow() const; | 116 void contentAreaDidShow() const; |
115 void contentAreaDidHide() const; | 117 void contentAreaDidHide() const; |
116 | 118 |
117 void finishCurrentScrollAnimations() const; | 119 void finishCurrentScrollAnimations() const; |
118 | 120 |
119 virtual void didAddScrollbar(Scrollbar&, ScrollbarOrientation); | 121 virtual void didAddScrollbar(Scrollbar&, ScrollbarOrientation); |
120 virtual void willRemoveScrollbar(Scrollbar&, ScrollbarOrientation); | 122 virtual void willRemoveScrollbar(Scrollbar&, ScrollbarOrientation); |
121 | 123 |
122 virtual void contentsResized(); | 124 virtual void contentsResized(); |
123 | 125 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 224 |
223 virtual IntRect visibleContentRect( | 225 virtual IntRect visibleContentRect( |
224 IncludeScrollbarsInRect = ExcludeScrollbars) const; | 226 IncludeScrollbarsInRect = ExcludeScrollbars) const; |
225 virtual int visibleHeight() const { return visibleContentRect().height(); } | 227 virtual int visibleHeight() const { return visibleContentRect().height(); } |
226 virtual int visibleWidth() const { return visibleContentRect().width(); } | 228 virtual int visibleWidth() const { return visibleContentRect().width(); } |
227 virtual IntSize contentsSize() const = 0; | 229 virtual IntSize contentsSize() const = 0; |
228 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } | 230 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } |
229 | 231 |
230 virtual bool shouldSuspendScrollAnimations() const { return true; } | 232 virtual bool shouldSuspendScrollAnimations() const { return true; } |
231 virtual void scrollbarStyleChanged() {} | 233 virtual void scrollbarStyleChanged() {} |
232 virtual void scrollbarVisibilityChanged() {} | |
233 virtual bool scrollbarsCanBeActive() const = 0; | 234 virtual bool scrollbarsCanBeActive() const = 0; |
234 | 235 |
235 // Returns the bounding box of this scrollable area, in the coordinate system | 236 // Returns the bounding box of this scrollable area, in the coordinate system |
236 // of the enclosing scroll view. | 237 // of the enclosing scroll view. |
237 virtual IntRect scrollableAreaBoundingBox() const = 0; | 238 virtual IntRect scrollableAreaBoundingBox() const = 0; |
238 | 239 |
239 virtual bool scrollAnimatorEnabled() const { return false; } | 240 virtual bool scrollAnimatorEnabled() const { return false; } |
240 | 241 |
241 // NOTE: Only called from Internals for testing. | 242 // NOTE: Only called from Internals for testing. |
242 void updateScrollOffsetFromInternals(const IntSize&); | 243 void updateScrollOffsetFromInternals(const IntSize&); |
243 | 244 |
244 IntSize clampScrollOffset(const IntSize&) const; | 245 IntSize clampScrollOffset(const IntSize&) const; |
245 ScrollOffset clampScrollOffset(const ScrollOffset&) const; | 246 ScrollOffset clampScrollOffset(const ScrollOffset&) const; |
246 | 247 |
247 // Let subclasses provide a way of asking for and servicing scroll | 248 // Let subclasses provide a way of asking for and servicing scroll |
248 // animations. | 249 // animations. |
249 virtual bool scheduleAnimation(); | 250 virtual bool scheduleAnimation(); |
250 virtual void serviceScrollAnimations(double monotonicTime); | 251 virtual void serviceScrollAnimations(double monotonicTime); |
251 virtual void updateCompositorScrollAnimations(); | 252 virtual void updateCompositorScrollAnimations(); |
252 virtual void registerForAnimation() {} | 253 virtual void registerForAnimation() {} |
253 virtual void deregisterForAnimation() {} | 254 virtual void deregisterForAnimation() {} |
254 | 255 |
255 virtual bool usesCompositedScrolling() const { return false; } | 256 virtual bool usesCompositedScrolling() const { return false; } |
256 virtual bool shouldScrollOnMainThread() const; | 257 virtual bool shouldScrollOnMainThread() const; |
257 | 258 |
258 // Overlay scrollbars can "fade-out" when inactive. | 259 // Overlay scrollbars can "fade-out" when inactive. |
259 virtual bool scrollbarsHidden() const; | 260 virtual bool scrollbarsHidden() const; |
260 virtual void setScrollbarsHidden(bool); | 261 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 clearScrollAnimators(); | 361 virtual void clearScrollableArea(); |
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 |
| 395 // Called when scrollbar hides/shows for overlay scrollbars. This callback |
| 396 // shouldn't do any significant work as it can be called unexpectadly often |
| 397 // on Mac. This happens because painting code has to set alpha to 1, paint, |
| 398 // then reset to alpha, causing spurrious "visibilityChanged" calls. |
| 399 virtual void scrollbarVisibilityChanged() {} |
393 | 400 |
394 private: | 401 private: |
395 void programmaticScrollHelper(const ScrollOffset&, ScrollBehavior); | 402 void programmaticScrollHelper(const ScrollOffset&, ScrollBehavior); |
396 void userScrollHelper(const ScrollOffset&, ScrollBehavior); | 403 void userScrollHelper(const ScrollOffset&, ScrollBehavior); |
397 | 404 |
| 405 void fadeOverlayScrollbarsTimerFired(TimerBase*); |
| 406 |
398 // This function should be overriden by subclasses to perform the actual | 407 // This function should be overriden by subclasses to perform the actual |
399 // scroll of the content. | 408 // scroll of the content. |
400 virtual void updateScrollOffset(const ScrollOffset&, ScrollType) = 0; | 409 virtual void updateScrollOffset(const ScrollOffset&, ScrollType) = 0; |
401 | 410 |
402 virtual int lineStep(ScrollbarOrientation) const; | 411 virtual int lineStep(ScrollbarOrientation) const; |
403 virtual int pageStep(ScrollbarOrientation) const; | 412 virtual int pageStep(ScrollbarOrientation) const; |
404 virtual int documentStep(ScrollbarOrientation) const; | 413 virtual int documentStep(ScrollbarOrientation) const; |
405 virtual float pixelStep(ScrollbarOrientation) const; | 414 virtual float pixelStep(ScrollbarOrientation) const; |
406 | 415 |
407 mutable Member<ScrollAnimatorBase> m_scrollAnimator; | 416 mutable Member<ScrollAnimatorBase> m_scrollAnimator; |
408 mutable Member<ProgrammaticScrollAnimator> m_programmaticScrollAnimator; | 417 mutable Member<ProgrammaticScrollAnimator> m_programmaticScrollAnimator; |
409 | 418 |
| 419 std::unique_ptr<Timer<ScrollableArea>> m_fadeOverlayScrollbarsTimer; |
| 420 |
410 unsigned m_scrollbarOverlayColorTheme : 2; | 421 unsigned m_scrollbarOverlayColorTheme : 2; |
411 | 422 |
412 unsigned m_scrollOriginChanged : 1; | 423 unsigned m_scrollOriginChanged : 1; |
413 | 424 |
414 unsigned m_horizontalScrollbarNeedsPaintInvalidation : 1; | 425 unsigned m_horizontalScrollbarNeedsPaintInvalidation : 1; |
415 unsigned m_verticalScrollbarNeedsPaintInvalidation : 1; | 426 unsigned m_verticalScrollbarNeedsPaintInvalidation : 1; |
416 unsigned m_scrollCornerNeedsPaintInvalidation : 1; | 427 unsigned m_scrollCornerNeedsPaintInvalidation : 1; |
417 unsigned m_scrollbarsHidden : 1; | 428 unsigned m_scrollbarsHidden : 1; |
| 429 unsigned m_scrollbarCaptured : 1; |
418 | 430 |
419 // There are 6 possible combinations of writing mode and direction. Scroll | 431 // There are 6 possible combinations of writing mode and direction. Scroll |
420 // origin will be non-zero in the x or y axis if there is any reversed | 432 // origin will be non-zero in the x or y axis if there is any reversed |
421 // direction or writing-mode. The combinations are: | 433 // direction or writing-mode. The combinations are: |
422 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set | 434 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set |
423 // horizontal-tb / ltr NO NO | 435 // horizontal-tb / ltr NO NO |
424 // horizontal-tb / rtl YES NO | 436 // horizontal-tb / rtl YES NO |
425 // vertical-lr / ltr NO NO | 437 // vertical-lr / ltr NO NO |
426 // vertical-lr / rtl NO YES | 438 // vertical-lr / rtl NO YES |
427 // vertical-rl / ltr YES NO | 439 // vertical-rl / ltr YES NO |
428 // vertical-rl / rtl YES YES | 440 // vertical-rl / rtl YES YES |
429 IntPoint m_scrollOrigin; | 441 IntPoint m_scrollOrigin; |
430 }; | 442 }; |
431 | 443 |
432 } // namespace blink | 444 } // namespace blink |
433 | 445 |
434 #endif // ScrollableArea_h | 446 #endif // ScrollableArea_h |
OLD | NEW |