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

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: Add TODOs 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 void contentAreaDidShow() const; 116 void contentAreaDidShow() const;
117 void contentAreaDidHide() const; 117 void contentAreaDidHide() const;
118 118
119 void finishCurrentScrollAnimations() const; 119 void finishCurrentScrollAnimations() const;
120 120
121 virtual void didAddScrollbar(Scrollbar&, ScrollbarOrientation); 121 virtual void didAddScrollbar(Scrollbar&, ScrollbarOrientation);
122 virtual void willRemoveScrollbar(Scrollbar&, ScrollbarOrientation); 122 virtual void willRemoveScrollbar(Scrollbar&, ScrollbarOrientation);
123 123
124 virtual void contentsResized(); 124 virtual void contentsResized();
125 125
126 bool hasOverlayScrollbars() const; 126 virtual bool hasOverlayScrollbars() const;
127 void setScrollbarOverlayColorTheme(ScrollbarOverlayColorTheme); 127 void setScrollbarOverlayColorTheme(ScrollbarOverlayColorTheme);
128 void recalculateScrollbarOverlayColorTheme(Color); 128 void recalculateScrollbarOverlayColorTheme(Color);
129 ScrollbarOverlayColorTheme getScrollbarOverlayColorTheme() const { 129 virtual ScrollbarOverlayColorTheme getScrollbarOverlayColorTheme() const {
130 return static_cast<ScrollbarOverlayColorTheme>( 130 return static_cast<ScrollbarOverlayColorTheme>(
131 m_scrollbarOverlayColorTheme); 131 m_scrollbarOverlayColorTheme);
132 } 132 }
133 133
134 // 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.
135 ScrollAnimatorBase& scrollAnimator() const; 135 ScrollAnimatorBase& scrollAnimator() const;
136 136
137 // 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
138 // yet. 138 // yet.
139 ScrollAnimatorBase* existingScrollAnimator() const { 139 ScrollAnimatorBase* existingScrollAnimator() const {
(...skipping 20 matching lines...) Expand all
160 // non-composited elements using fractional scroll offsets is causing too much 160 // non-composited elements using fractional scroll offsets is causing too much
161 // 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.
162 // 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
163 // of this? 163 // of this?
164 virtual bool shouldUseIntegerScrollOffset() const { 164 virtual bool shouldUseIntegerScrollOffset() const {
165 return !RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled(); 165 return !RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled();
166 } 166 }
167 167
168 virtual bool isActive() const = 0; 168 virtual bool isActive() const = 0;
169 virtual int scrollSize(ScrollbarOrientation) const = 0; 169 virtual int scrollSize(ScrollbarOrientation) const = 0;
170 void setScrollbarNeedsPaintInvalidation(ScrollbarOrientation); 170 virtual void setScrollbarNeedsPaintInvalidation(ScrollbarOrientation);
171 virtual bool isScrollCornerVisible() const = 0; 171 virtual bool isScrollCornerVisible() const = 0;
172 virtual IntRect scrollCornerRect() const = 0; 172 virtual IntRect scrollCornerRect() const = 0;
173 void setScrollCornerNeedsPaintInvalidation(); 173 virtual void setScrollCornerNeedsPaintInvalidation();
174 virtual void getTickmarks(Vector<IntRect>&) const {} 174 virtual void getTickmarks(Vector<IntRect>&) const {}
175 175
176 // Convert points and rects between the scrollbar and its containing Widget. 176 // 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 177 // The client needs to implement these in order to be aware of layout effects
178 // like CSS transforms. 178 // like CSS transforms.
179 virtual IntRect convertFromScrollbarToContainingWidget( 179 virtual IntRect convertFromScrollbarToContainingWidget(
180 const Scrollbar& scrollbar, 180 const Scrollbar& scrollbar,
181 const IntRect& scrollbarRect) const { 181 const IntRect& scrollbarRect) const {
182 return scrollbar.Widget::convertToContainingWidget(scrollbarRect); 182 return scrollbar.Widget::convertToContainingWidget(scrollbarRect);
183 } 183 }
184 virtual IntRect convertFromContainingWidgetToScrollbar( 184 virtual IntRect convertFromContainingWidgetToScrollbar(
185 const Scrollbar& scrollbar, 185 const Scrollbar& scrollbar,
186 const IntRect& parentRect) const { 186 const IntRect& parentRect) const {
187 return scrollbar.Widget::convertFromContainingWidget(parentRect); 187 return scrollbar.Widget::convertFromContainingWidget(parentRect);
188 } 188 }
189 virtual IntPoint convertFromScrollbarToContainingWidget( 189 virtual IntPoint convertFromScrollbarToContainingWidget(
190 const Scrollbar& scrollbar, 190 const Scrollbar& scrollbar,
191 const IntPoint& scrollbarPoint) const { 191 const IntPoint& scrollbarPoint) const {
192 return scrollbar.Widget::convertToContainingWidget(scrollbarPoint); 192 return scrollbar.Widget::convertToContainingWidget(scrollbarPoint);
193 } 193 }
194 virtual IntPoint convertFromContainingWidgetToScrollbar( 194 virtual IntPoint convertFromContainingWidgetToScrollbar(
195 const Scrollbar& scrollbar, 195 const Scrollbar& scrollbar,
196 const IntPoint& parentPoint) const { 196 const IntPoint& parentPoint) const {
197 return scrollbar.Widget::convertFromContainingWidget(parentPoint); 197 return scrollbar.Widget::convertFromContainingWidget(parentPoint);
198 } 198 }
199 199
200 virtual Scrollbar* horizontalScrollbar() const { return nullptr; } 200 virtual Scrollbar* horizontalScrollbar() const { return nullptr; }
201 virtual Scrollbar* verticalScrollbar() const { return nullptr; } 201 virtual Scrollbar* verticalScrollbar() const { return nullptr; }
202 202
203 // Called to update the scrollbars to accurately reflect the state of the
204 // view.
205 virtual void updateScrollbars(){};
206
203 // scrollPosition is the location of the top/left of the scroll viewport in 207 // 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. 208 // 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 209 // 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. 210 // scrolled all the way to the beginning of its content's flow.
207 // For a more detailed explanation of scrollPosition, scrollOffset, and 211 // For a more detailed explanation of scrollPosition, scrollOffset, and
208 // scrollOrigin, see core/layout/README.md. 212 // scrollOrigin, see core/layout/README.md.
209 FloatPoint scrollPosition() const { 213 FloatPoint scrollPosition() const {
210 return FloatPoint(scrollOrigin()) + scrollOffset(); 214 return FloatPoint(scrollOrigin()) + scrollOffset();
211 } 215 }
212 virtual IntSize scrollOffsetInt() const = 0; 216 virtual IntSize scrollOffsetInt() const = 0;
213 virtual ScrollOffset scrollOffset() const { 217 virtual ScrollOffset scrollOffset() const {
214 return ScrollOffset(scrollOffsetInt()); 218 return ScrollOffset(scrollOffsetInt());
215 } 219 }
216 virtual IntSize minimumScrollOffsetInt() const = 0; 220 virtual IntSize minimumScrollOffsetInt() const = 0;
217 virtual ScrollOffset minimumScrollOffset() const { 221 virtual ScrollOffset minimumScrollOffset() const {
218 return ScrollOffset(minimumScrollOffsetInt()); 222 return ScrollOffset(minimumScrollOffsetInt());
219 } 223 }
220 virtual IntSize maximumScrollOffsetInt() const = 0; 224 virtual IntSize maximumScrollOffsetInt() const = 0;
221 virtual ScrollOffset maximumScrollOffset() const { 225 virtual ScrollOffset maximumScrollOffset() const {
222 return ScrollOffset(maximumScrollOffsetInt()); 226 return ScrollOffset(maximumScrollOffsetInt());
223 } 227 }
228 virtual ScrollOffset scrollAnimatorDesiredTargetOffset() const {
229 return scrollAnimator().desiredTargetOffset();
230 }
224 231
225 virtual IntRect visibleContentRect( 232 virtual IntRect visibleContentRect(
226 IncludeScrollbarsInRect = ExcludeScrollbars) const; 233 IncludeScrollbarsInRect = ExcludeScrollbars) const;
227 virtual int visibleHeight() const { return visibleContentRect().height(); } 234 virtual int visibleHeight() const { return visibleContentRect().height(); }
228 virtual int visibleWidth() const { return visibleContentRect().width(); } 235 virtual int visibleWidth() const { return visibleContentRect().width(); }
229 virtual IntSize contentsSize() const = 0; 236 virtual IntSize contentsSize() const = 0;
230 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); } 237 virtual IntPoint lastKnownMousePosition() const { return IntPoint(); }
231 238
232 virtual bool shouldSuspendScrollAnimations() const { return true; } 239 virtual bool shouldSuspendScrollAnimations() const { return true; }
233 virtual void scrollbarStyleChanged() {} 240 virtual void scrollbarStyleChanged() {}
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 virtual bool shouldPerformScrollAnchoring() const { return false; } 362 virtual bool shouldPerformScrollAnchoring() const { return false; }
356 363
357 // Need to promptly let go of owned animator objects. 364 // Need to promptly let go of owned animator objects.
358 EAGERLY_FINALIZE(); 365 EAGERLY_FINALIZE();
359 DECLARE_VIRTUAL_TRACE(); 366 DECLARE_VIRTUAL_TRACE();
360 367
361 virtual void clearScrollableArea(); 368 virtual void clearScrollableArea();
362 369
363 virtual ScrollAnchor* scrollAnchor() { return nullptr; } 370 virtual ScrollAnchor* scrollAnchor() { return nullptr; }
364 371
372 virtual void scrollbarVisibilityChanged() {}
373
365 protected: 374 protected:
366 ScrollableArea(); 375 ScrollableArea();
367 376
368 ScrollbarOrientation scrollbarOrientationFromDirection( 377 ScrollbarOrientation scrollbarOrientationFromDirection(
369 ScrollDirectionPhysical) const; 378 ScrollDirectionPhysical) const;
370 float scrollStep(ScrollGranularity, ScrollbarOrientation) const; 379 float scrollStep(ScrollGranularity, ScrollbarOrientation) const;
371 380
372 void setScrollOrigin(const IntPoint&); 381 void setScrollOrigin(const IntPoint&);
373 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } 382 void resetScrollOriginChanged() { m_scrollOriginChanged = false; }
374 383
375 // Needed to let the animators call scrollOffsetChanged. 384 // Needed to let the animators call scrollOffsetChanged.
376 friend class ScrollAnimatorCompositorCoordinator; 385 friend class ScrollAnimatorCompositorCoordinator;
377 void scrollOffsetChanged(const ScrollOffset&, ScrollType); 386 void scrollOffsetChanged(const ScrollOffset&, ScrollType);
378 387
379 bool horizontalScrollbarNeedsPaintInvalidation() const { 388 bool horizontalScrollbarNeedsPaintInvalidation() const {
380 return m_horizontalScrollbarNeedsPaintInvalidation; 389 return m_horizontalScrollbarNeedsPaintInvalidation;
381 } 390 }
382 bool verticalScrollbarNeedsPaintInvalidation() const { 391 bool verticalScrollbarNeedsPaintInvalidation() const {
383 return m_verticalScrollbarNeedsPaintInvalidation; 392 return m_verticalScrollbarNeedsPaintInvalidation;
384 } 393 }
385 bool scrollCornerNeedsPaintInvalidation() const { 394 bool scrollCornerNeedsPaintInvalidation() const {
386 return m_scrollCornerNeedsPaintInvalidation; 395 return m_scrollCornerNeedsPaintInvalidation;
387 } 396 }
388 void clearNeedsPaintInvalidationForScrollControls() { 397 void clearNeedsPaintInvalidationForScrollControls() {
389 m_horizontalScrollbarNeedsPaintInvalidation = false; 398 m_horizontalScrollbarNeedsPaintInvalidation = false;
390 m_verticalScrollbarNeedsPaintInvalidation = false; 399 m_verticalScrollbarNeedsPaintInvalidation = false;
391 m_scrollCornerNeedsPaintInvalidation = false; 400 m_scrollCornerNeedsPaintInvalidation = false;
392 } 401 }
393 void showOverlayScrollbars(); 402 void showOverlayScrollbars();
394 virtual void scrollbarVisibilityChanged() {}
395 403
396 private: 404 private:
397 void programmaticScrollHelper(const ScrollOffset&, ScrollBehavior); 405 void programmaticScrollHelper(const ScrollOffset&, ScrollBehavior);
398 void userScrollHelper(const ScrollOffset&, ScrollBehavior); 406 void userScrollHelper(const ScrollOffset&, ScrollBehavior);
399 407
400 void fadeOverlayScrollbarsTimerFired(TimerBase*); 408 void fadeOverlayScrollbarsTimerFired(TimerBase*);
401 409
402 // This function should be overriden by subclasses to perform the actual 410 // This function should be overriden by subclasses to perform the actual
403 // scroll of the content. 411 // scroll of the content.
404 virtual void updateScrollOffset(const ScrollOffset&, ScrollType) = 0; 412 virtual void updateScrollOffset(const ScrollOffset&, ScrollType) = 0;
(...skipping 27 matching lines...) Expand all
432 // vertical-lr / ltr NO NO 440 // vertical-lr / ltr NO NO
433 // vertical-lr / rtl NO YES 441 // vertical-lr / rtl NO YES
434 // vertical-rl / ltr YES NO 442 // vertical-rl / ltr YES NO
435 // vertical-rl / rtl YES YES 443 // vertical-rl / rtl YES YES
436 IntPoint m_scrollOrigin; 444 IntPoint m_scrollOrigin;
437 }; 445 };
438 446
439 } // namespace blink 447 } // namespace blink
440 448
441 #endif // ScrollableArea_h 449 #endif // ScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698