Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(764)

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollableArea.h

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

Powered by Google App Engine
This is Rietveld 408576698