| 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 virtual void mouseEnteredScrollbar(Scrollbar&); | 112 void mouseEnteredScrollbar(Scrollbar&); |
| 113 virtual void mouseExitedScrollbar(Scrollbar&); | 113 void mouseExitedScrollbar(Scrollbar&); |
| 114 void mouseCapturedScrollbar(); | 114 void mouseCapturedScrollbar(); |
| 115 void mouseReleasedScrollbar(); | 115 void mouseReleasedScrollbar(); |
| 116 | |
| 117 void contentAreaDidShow() const; | 116 void contentAreaDidShow() const; |
| 118 void contentAreaDidHide() const; | 117 void contentAreaDidHide() const; |
| 119 | 118 |
| 120 void finishCurrentScrollAnimations() const; | 119 void finishCurrentScrollAnimations() const; |
| 121 | 120 |
| 122 virtual void didAddScrollbar(Scrollbar&, ScrollbarOrientation); | 121 virtual void didAddScrollbar(Scrollbar&, ScrollbarOrientation); |
| 123 virtual void willRemoveScrollbar(Scrollbar&, ScrollbarOrientation); | 122 virtual void willRemoveScrollbar(Scrollbar&, ScrollbarOrientation); |
| 124 | 123 |
| 125 virtual void contentsResized(); | 124 virtual void contentsResized(); |
| 126 | 125 |
| 127 virtual bool hasOverlayScrollbars() const; | 126 bool hasOverlayScrollbars() const; |
| 128 void setScrollbarOverlayColorTheme(ScrollbarOverlayColorTheme); | 127 void setScrollbarOverlayColorTheme(ScrollbarOverlayColorTheme); |
| 129 void recalculateScrollbarOverlayColorTheme(Color); | 128 void recalculateScrollbarOverlayColorTheme(Color); |
| 130 virtual ScrollbarOverlayColorTheme getScrollbarOverlayColorTheme() const { | 129 ScrollbarOverlayColorTheme getScrollbarOverlayColorTheme() const { |
| 131 return static_cast<ScrollbarOverlayColorTheme>( | 130 return static_cast<ScrollbarOverlayColorTheme>( |
| 132 m_scrollbarOverlayColorTheme); | 131 m_scrollbarOverlayColorTheme); |
| 133 } | 132 } |
| 134 | 133 |
| 135 // This getter will create a ScrollAnimatorBase if it doesn't already exist. | 134 // This getter will create a ScrollAnimatorBase if it doesn't already exist. |
| 136 ScrollAnimatorBase& scrollAnimator() const; | 135 ScrollAnimatorBase& scrollAnimator() const; |
| 137 | 136 |
| 138 // This getter will return null if the ScrollAnimatorBase hasn't been created | 137 // This getter will return null if the ScrollAnimatorBase hasn't been created |
| 139 // yet. | 138 // yet. |
| 140 ScrollAnimatorBase* existingScrollAnimator() const { | 139 ScrollAnimatorBase* existingScrollAnimator() const { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 161 // non-composited elements using fractional scroll offsets is causing too much | 160 // non-composited elements using fractional scroll offsets is causing too much |
| 162 // nasty bugs but does not add too benefit on low-dpi devices. | 161 // nasty bugs but does not add too benefit on low-dpi devices. |
| 163 // TODO(szager): Now that scroll offsets are floats everywhere, can we get rid | 162 // TODO(szager): Now that scroll offsets are floats everywhere, can we get rid |
| 164 // of this? | 163 // of this? |
| 165 virtual bool shouldUseIntegerScrollOffset() const { | 164 virtual bool shouldUseIntegerScrollOffset() const { |
| 166 return !RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled(); | 165 return !RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled(); |
| 167 } | 166 } |
| 168 | 167 |
| 169 virtual bool isActive() const = 0; | 168 virtual bool isActive() const = 0; |
| 170 virtual int scrollSize(ScrollbarOrientation) const = 0; | 169 virtual int scrollSize(ScrollbarOrientation) const = 0; |
| 171 virtual void setScrollbarNeedsPaintInvalidation(ScrollbarOrientation); | 170 void setScrollbarNeedsPaintInvalidation(ScrollbarOrientation); |
| 172 virtual bool isScrollCornerVisible() const = 0; | 171 virtual bool isScrollCornerVisible() const = 0; |
| 173 virtual IntRect scrollCornerRect() const = 0; | 172 virtual IntRect scrollCornerRect() const = 0; |
| 174 virtual void setScrollCornerNeedsPaintInvalidation(); | 173 void setScrollCornerNeedsPaintInvalidation(); |
| 175 virtual void getTickmarks(Vector<IntRect>&) const {} | 174 virtual void getTickmarks(Vector<IntRect>&) const {} |
| 176 | 175 |
| 177 // Convert points and rects between the scrollbar and its containing Widget. | 176 // Convert points and rects between the scrollbar and its containing Widget. |
| 178 // The client needs to implement these in order to be aware of layout effects | 177 // The client needs to implement these in order to be aware of layout effects |
| 179 // like CSS transforms. | 178 // like CSS transforms. |
| 180 virtual IntRect convertFromScrollbarToContainingWidget( | 179 virtual IntRect convertFromScrollbarToContainingWidget( |
| 181 const Scrollbar& scrollbar, | 180 const Scrollbar& scrollbar, |
| 182 const IntRect& scrollbarRect) const { | 181 const IntRect& scrollbarRect) const { |
| 183 return scrollbar.Widget::convertToContainingWidget(scrollbarRect); | 182 return scrollbar.Widget::convertToContainingWidget(scrollbarRect); |
| 184 } | 183 } |
| 185 virtual IntRect convertFromContainingWidgetToScrollbar( | 184 virtual IntRect convertFromContainingWidgetToScrollbar( |
| 186 const Scrollbar& scrollbar, | 185 const Scrollbar& scrollbar, |
| 187 const IntRect& parentRect) const { | 186 const IntRect& parentRect) const { |
| 188 return scrollbar.Widget::convertFromContainingWidget(parentRect); | 187 return scrollbar.Widget::convertFromContainingWidget(parentRect); |
| 189 } | 188 } |
| 190 virtual IntPoint convertFromScrollbarToContainingWidget( | 189 virtual IntPoint convertFromScrollbarToContainingWidget( |
| 191 const Scrollbar& scrollbar, | 190 const Scrollbar& scrollbar, |
| 192 const IntPoint& scrollbarPoint) const { | 191 const IntPoint& scrollbarPoint) const { |
| 193 return scrollbar.Widget::convertToContainingWidget(scrollbarPoint); | 192 return scrollbar.Widget::convertToContainingWidget(scrollbarPoint); |
| 194 } | 193 } |
| 195 virtual IntPoint convertFromContainingWidgetToScrollbar( | 194 virtual IntPoint convertFromContainingWidgetToScrollbar( |
| 196 const Scrollbar& scrollbar, | 195 const Scrollbar& scrollbar, |
| 197 const IntPoint& parentPoint) const { | 196 const IntPoint& parentPoint) const { |
| 198 return scrollbar.Widget::convertFromContainingWidget(parentPoint); | 197 return scrollbar.Widget::convertFromContainingWidget(parentPoint); |
| 199 } | 198 } |
| 200 | 199 |
| 201 virtual Scrollbar* horizontalScrollbar() const { return nullptr; } | 200 virtual Scrollbar* horizontalScrollbar() const { return nullptr; } |
| 202 virtual Scrollbar* verticalScrollbar() const { return nullptr; } | 201 virtual Scrollbar* verticalScrollbar() const { return nullptr; } |
| 203 | 202 |
| 204 // TODO(crbug.com/661236): This method should be moved to ScrollbarManager | |
| 205 // which will update the scrollbars directly for all subclasses. | |
| 206 // Called to update the scrollbars to accurately reflect the state of the | |
| 207 // view. | |
| 208 virtual void updateScrollbars(){}; | |
| 209 | |
| 210 // scrollPosition is the location of the top/left of the scroll viewport in | 203 // scrollPosition is the location of the top/left of the scroll viewport in |
| 211 // the coordinate system defined by the top/left of the overflow rect. | 204 // the coordinate system defined by the top/left of the overflow rect. |
| 212 // scrollOffset is the offset of the scroll viewport from its position when | 205 // scrollOffset is the offset of the scroll viewport from its position when |
| 213 // scrolled all the way to the beginning of its content's flow. | 206 // scrolled all the way to the beginning of its content's flow. |
| 214 // For a more detailed explanation of scrollPosition, scrollOffset, and | 207 // For a more detailed explanation of scrollPosition, scrollOffset, and |
| 215 // scrollOrigin, see core/layout/README.md. | 208 // scrollOrigin, see core/layout/README.md. |
| 216 FloatPoint scrollPosition() const { | 209 FloatPoint scrollPosition() const { |
| 217 return FloatPoint(scrollOrigin()) + scrollOffset(); | 210 return FloatPoint(scrollOrigin()) + scrollOffset(); |
| 218 } | 211 } |
| 219 virtual IntSize scrollOffsetInt() const = 0; | 212 virtual IntSize scrollOffsetInt() const = 0; |
| 220 virtual ScrollOffset scrollOffset() const { | 213 virtual ScrollOffset scrollOffset() const { |
| 221 return ScrollOffset(scrollOffsetInt()); | 214 return ScrollOffset(scrollOffsetInt()); |
| 222 } | 215 } |
| 223 virtual IntSize minimumScrollOffsetInt() const = 0; | 216 virtual IntSize minimumScrollOffsetInt() const = 0; |
| 224 virtual ScrollOffset minimumScrollOffset() const { | 217 virtual ScrollOffset minimumScrollOffset() const { |
| 225 return ScrollOffset(minimumScrollOffsetInt()); | 218 return ScrollOffset(minimumScrollOffsetInt()); |
| 226 } | 219 } |
| 227 virtual IntSize maximumScrollOffsetInt() const = 0; | 220 virtual IntSize maximumScrollOffsetInt() const = 0; |
| 228 virtual ScrollOffset maximumScrollOffset() const { | 221 virtual ScrollOffset maximumScrollOffset() const { |
| 229 return ScrollOffset(maximumScrollOffsetInt()); | 222 return ScrollOffset(maximumScrollOffsetInt()); |
| 230 } | 223 } |
| 231 virtual ScrollOffset scrollAnimatorDesiredTargetOffset() const { | |
| 232 return scrollAnimator().desiredTargetOffset(); | |
| 233 } | |
| 234 | 224 |
| 235 virtual IntRect visibleContentRect( | 225 virtual IntRect visibleContentRect( |
| 236 IncludeScrollbarsInRect = ExcludeScrollbars) const; | 226 IncludeScrollbarsInRect = ExcludeScrollbars) const; |
| 237 virtual int visibleHeight() const { return visibleContentRect().height(); } | 227 virtual int visibleHeight() const { return visibleContentRect().height(); } |
| 238 virtual int visibleWidth() const { return visibleContentRect().width(); } | 228 virtual int visibleWidth() const { return visibleContentRect().width(); } |
| 239 virtual IntSize contentsSize() const = 0; | 229 virtual IntSize contentsSize() const = 0; |
| 240 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } | 230 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } |
| 241 | 231 |
| 242 virtual bool shouldSuspendScrollAnimations() const { return true; } | 232 virtual bool shouldSuspendScrollAnimations() const { return true; } |
| 243 virtual void scrollbarStyleChanged() {} | 233 virtual void scrollbarStyleChanged() {} |
| 244 // Called when scrollbar hides/shows for overlay scrollbars. This callback | |
| 245 // shouldn't do any significant work as it can be called unexpectadly often | |
| 246 // on Mac. This happens because painting code has to set alpha to 1, paint, | |
| 247 // then reset to alpha, causing spurrious "visibilityChanged" calls. | |
| 248 virtual void scrollbarVisibilityChanged() {} | |
| 249 virtual bool scrollbarsCanBeActive() const = 0; | 234 virtual bool scrollbarsCanBeActive() const = 0; |
| 250 | 235 |
| 251 // 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 |
| 252 // of the enclosing scroll view. | 237 // of the enclosing scroll view. |
| 253 virtual IntRect scrollableAreaBoundingBox() const = 0; | 238 virtual IntRect scrollableAreaBoundingBox() const = 0; |
| 254 | 239 |
| 255 virtual bool scrollAnimatorEnabled() const { return false; } | 240 virtual bool scrollAnimatorEnabled() const { return false; } |
| 256 | 241 |
| 257 // NOTE: Only called from Internals for testing. | 242 // NOTE: Only called from Internals for testing. |
| 258 void updateScrollOffsetFromInternals(const IntSize&); | 243 void updateScrollOffsetFromInternals(const IntSize&); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 bool scrollCornerNeedsPaintInvalidation() const { | 385 bool scrollCornerNeedsPaintInvalidation() const { |
| 401 return m_scrollCornerNeedsPaintInvalidation; | 386 return m_scrollCornerNeedsPaintInvalidation; |
| 402 } | 387 } |
| 403 void clearNeedsPaintInvalidationForScrollControls() { | 388 void clearNeedsPaintInvalidationForScrollControls() { |
| 404 m_horizontalScrollbarNeedsPaintInvalidation = false; | 389 m_horizontalScrollbarNeedsPaintInvalidation = false; |
| 405 m_verticalScrollbarNeedsPaintInvalidation = false; | 390 m_verticalScrollbarNeedsPaintInvalidation = false; |
| 406 m_scrollCornerNeedsPaintInvalidation = false; | 391 m_scrollCornerNeedsPaintInvalidation = false; |
| 407 } | 392 } |
| 408 void showOverlayScrollbars(); | 393 void showOverlayScrollbars(); |
| 409 | 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() {} |
| 400 |
| 410 private: | 401 private: |
| 411 void programmaticScrollHelper(const ScrollOffset&, ScrollBehavior); | 402 void programmaticScrollHelper(const ScrollOffset&, ScrollBehavior); |
| 412 void userScrollHelper(const ScrollOffset&, ScrollBehavior); | 403 void userScrollHelper(const ScrollOffset&, ScrollBehavior); |
| 413 | 404 |
| 414 void fadeOverlayScrollbarsTimerFired(TimerBase*); | 405 void fadeOverlayScrollbarsTimerFired(TimerBase*); |
| 415 | 406 |
| 416 // This function should be overriden by subclasses to perform the actual | 407 // This function should be overriden by subclasses to perform the actual |
| 417 // scroll of the content. | 408 // scroll of the content. |
| 418 virtual void updateScrollOffset(const ScrollOffset&, ScrollType) = 0; | 409 virtual void updateScrollOffset(const ScrollOffset&, ScrollType) = 0; |
| 419 | 410 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 446 // vertical-lr / ltr NO NO | 437 // vertical-lr / ltr NO NO |
| 447 // vertical-lr / rtl NO YES | 438 // vertical-lr / rtl NO YES |
| 448 // vertical-rl / ltr YES NO | 439 // vertical-rl / ltr YES NO |
| 449 // vertical-rl / rtl YES YES | 440 // vertical-rl / rtl YES YES |
| 450 IntPoint m_scrollOrigin; | 441 IntPoint m_scrollOrigin; |
| 451 }; | 442 }; |
| 452 | 443 |
| 453 } // namespace blink | 444 } // namespace blink |
| 454 | 445 |
| 455 #endif // ScrollableArea_h | 446 #endif // ScrollableArea_h |
| OLD | NEW |