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