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

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

Issue 1456953003: Revert of Calculate paint invalidation rect for scrollbars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 // This is used to determine whether the incoming fractional scroll offset s hould 141 // This is used to determine whether the incoming fractional scroll offset s hould
142 // be truncated to integer. Current rule is that if preferCompositingToLCDTe xtEnabled() 142 // be truncated to integer. Current rule is that if preferCompositingToLCDTe xtEnabled()
143 // is disabled (which is true on low-dpi device by default) we should do the truncation. 143 // is disabled (which is true on low-dpi device by default) we should do the truncation.
144 // The justification is that non-composited elements using fractional scroll offsets 144 // The justification is that non-composited elements using fractional scroll offsets
145 // is causing too much nasty bugs but does not add too benefit on low-dpi de vices. 145 // is causing too much nasty bugs but does not add too benefit on low-dpi de vices.
146 virtual bool shouldUseIntegerScrollOffset() const { return !RuntimeEnabledFe atures::fractionalScrollOffsetsEnabled(); } 146 virtual bool shouldUseIntegerScrollOffset() const { return !RuntimeEnabledFe atures::fractionalScrollOffsetsEnabled(); }
147 147
148 virtual bool isActive() const = 0; 148 virtual bool isActive() const = 0;
149 virtual int scrollSize(ScrollbarOrientation) const = 0; 149 virtual int scrollSize(ScrollbarOrientation) const = 0;
150 void setScrollbarNeedsPaintInvalidation(Scrollbar*); 150 virtual void invalidateScrollbar(Scrollbar*, const IntRect&);
151 virtual bool isScrollCornerVisible() const = 0; 151 virtual bool isScrollCornerVisible() const = 0;
152 virtual IntRect scrollCornerRect() const = 0; 152 virtual IntRect scrollCornerRect() const = 0;
153 void setScrollCornerNeedsPaintInvalidation(); 153 virtual void invalidateScrollCorner(const IntRect&);
154 virtual void getTickmarks(Vector<IntRect>&) const { } 154 virtual void getTickmarks(Vector<IntRect>&) const { }
155 155
156 // Convert points and rects between the scrollbar and its containing view. 156 // Convert points and rects between the scrollbar and its containing view.
157 // The client needs to implement these in order to be aware of layout effect s 157 // The client needs to implement these in order to be aware of layout effect s
158 // like CSS transforms. 158 // like CSS transforms.
159 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar* scroll bar, const IntRect& scrollbarRect) const 159 virtual IntRect convertFromScrollbarToContainingView(const Scrollbar* scroll bar, const IntRect& scrollbarRect) const
160 { 160 {
161 return scrollbar->Widget::convertToContainingView(scrollbarRect); 161 return scrollbar->Widget::convertToContainingView(scrollbarRect);
162 } 162 }
163 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar* scroll bar, const IntRect& parentRect) const 163 virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar* scroll bar, const IntRect& parentRect) const
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; 229 virtual bool userInputScrollable(ScrollbarOrientation) const = 0;
230 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0; 230 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0;
231 231
232 // Convenience functions 232 // Convenience functions
233 int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } 233 int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); }
234 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio n().y(); } 234 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio n().y(); }
235 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio n().y(); } 235 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio n().y(); }
236 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi on(orientation)); } 236 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi on(orientation)); }
237 237
238 bool hasVerticalBarDamage() const { return !m_verticalBarDamage.isEmpty(); }
239 bool hasHorizontalBarDamage() const { return !m_horizontalBarDamage.isEmpty( ); }
240 const IntRect& verticalBarDamage() const { return m_verticalBarDamage; }
241 const IntRect& horizontalBarDamage() const { return m_horizontalBarDamage; }
242
243 void addScrollbarDamage(Scrollbar* scrollbar, const IntRect& rect)
244 {
245 if (scrollbar == horizontalScrollbar())
246 m_horizontalBarDamage.unite(rect);
247 else
248 m_verticalBarDamage.unite(rect);
249 }
250
251 void resetScrollbarDamage()
252 {
253 m_verticalBarDamage = IntRect();
254 m_horizontalBarDamage = IntRect();
255 }
256
238 virtual GraphicsLayer* layerForContainer() const; 257 virtual GraphicsLayer* layerForContainer() const;
239 virtual GraphicsLayer* layerForScrolling() const { return 0; } 258 virtual GraphicsLayer* layerForScrolling() const { return 0; }
240 virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; } 259 virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; }
241 virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; } 260 virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; }
242 virtual GraphicsLayer* layerForScrollCorner() const { return 0; } 261 virtual GraphicsLayer* layerForScrollCorner() const { return 0; }
243 bool hasLayerForHorizontalScrollbar() const; 262 bool hasLayerForHorizontalScrollbar() const;
244 bool hasLayerForVerticalScrollbar() const; 263 bool hasLayerForVerticalScrollbar() const;
245 bool hasLayerForScrollCorner() const; 264 bool hasLayerForScrollCorner() const;
246 265
247 void layerForScrollingDidChange(WebCompositorAnimationTimeline*); 266 void layerForScrollingDidChange(WebCompositorAnimationTimeline*);
248 267
249 void cancelScrollAnimation(); 268 void cancelScrollAnimation();
250 void cancelProgrammaticScrollAnimation(); 269 void cancelProgrammaticScrollAnimation();
251 270
252 virtual ~ScrollableArea(); 271 virtual ~ScrollableArea();
253 272
254 // Called when any of horizontal scrollbar, vertical scrollbar and scroll co rner is setNeedsPaintInvalidation. 273 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0;
255 virtual void scrollControlWasSetNeedsPaintInvalidation() = 0; 274 virtual void invalidateScrollCornerRect(const IntRect&) = 0;
256 275
257 // Returns the default scroll style this area should scroll with when not 276 // Returns the default scroll style this area should scroll with when not
258 // explicitly specified. E.g. The scrolling behavior of an element can be 277 // explicitly specified. E.g. The scrolling behavior of an element can be
259 // specified in CSS. 278 // specified in CSS.
260 virtual ScrollBehavior scrollBehaviorStyle() const { return ScrollBehaviorIn stant; } 279 virtual ScrollBehavior scrollBehaviorStyle() const { return ScrollBehaviorIn stant; }
261 280
262 // TODO(bokan): This is only used in FrameView to check scrollability but is 281 // TODO(bokan): This is only used in FrameView to check scrollability but is
263 // needed here to allow RootFrameViewport to preserve wheelHandler 282 // needed here to allow RootFrameViewport to preserve wheelHandler
264 // semantics. Not sure why it's FrameView specific, it could probably be 283 // semantics. Not sure why it's FrameView specific, it could probably be
265 // generalized to other types of ScrollableAreas. 284 // generalized to other types of ScrollableAreas.
(...skipping 20 matching lines...) Expand all
286 void setScrollOrigin(const IntPoint&); 305 void setScrollOrigin(const IntPoint&);
287 void resetScrollOriginChanged() { m_scrollOriginChanged = false; } 306 void resetScrollOriginChanged() { m_scrollOriginChanged = false; }
288 307
289 // Needed to let the animators call scrollPositionChanged. 308 // Needed to let the animators call scrollPositionChanged.
290 friend class ScrollAnimatorBase; 309 friend class ScrollAnimatorBase;
291 friend class ProgrammaticScrollAnimator; 310 friend class ProgrammaticScrollAnimator;
292 void scrollPositionChanged(const DoublePoint&, ScrollType); 311 void scrollPositionChanged(const DoublePoint&, ScrollType);
293 312
294 void clearScrollAnimators(); 313 void clearScrollAnimators();
295 314
296 bool horizontalScrollbarNeedsPaintInvalidation() const { return m_horizontal ScrollbarNeedsPaintInvalidation; }
297 bool verticalScrollbarNeedsPaintInvalidation() const { return m_verticalScro llbarNeedsPaintInvalidation; }
298 bool scrollCornerNeedsPaintInvalidation() const { return m_scrollCornerNeeds PaintInvalidation; }
299 void clearNeedsPaintInvalidationForScrollControls()
300 {
301 m_horizontalScrollbarNeedsPaintInvalidation = false;
302 m_verticalScrollbarNeedsPaintInvalidation = false;
303 m_scrollCornerNeedsPaintInvalidation = false;
304 }
305
306 private: 315 private:
307 void programmaticScrollHelper(const DoublePoint&, ScrollBehavior); 316 void programmaticScrollHelper(const DoublePoint&, ScrollBehavior);
308 void userScrollHelper(const DoublePoint&, ScrollBehavior); 317 void userScrollHelper(const DoublePoint&, ScrollBehavior);
309 318
310 // This function should be overriden by subclasses to perform the actual 319 // This function should be overriden by subclasses to perform the actual
311 // scroll of the content. By default the DoublePoint version will just 320 // scroll of the content. By default the DoublePoint version will just
312 // call into the IntPoint version. If fractional scroll is needed, one 321 // call into the IntPoint version. If fractional scroll is needed, one
313 // can override the DoublePoint version to take advantage of the double 322 // can override the DoublePoint version to take advantage of the double
314 // precision scroll offset. 323 // precision scroll offset.
315 // FIXME: Remove the IntPoint version. And change the function to 324 // FIXME: Remove the IntPoint version. And change the function to
316 // take DoubleSize. crbug.com/414283. 325 // take DoubleSize. crbug.com/414283.
317 virtual void setScrollOffset(const IntPoint&, ScrollType) = 0; 326 virtual void setScrollOffset(const IntPoint&, ScrollType) = 0;
318 virtual void setScrollOffset(const DoublePoint& offset, ScrollType scrollTyp e) 327 virtual void setScrollOffset(const DoublePoint& offset, ScrollType scrollTyp e)
319 { 328 {
320 setScrollOffset(flooredIntPoint(offset), scrollType); 329 setScrollOffset(flooredIntPoint(offset), scrollType);
321 } 330 }
322 331
323 virtual int lineStep(ScrollbarOrientation) const; 332 virtual int lineStep(ScrollbarOrientation) const;
324 virtual int pageStep(ScrollbarOrientation) const; 333 virtual int pageStep(ScrollbarOrientation) const;
325 virtual int documentStep(ScrollbarOrientation) const; 334 virtual int documentStep(ScrollbarOrientation) const;
326 virtual float pixelStep(ScrollbarOrientation) const; 335 virtual float pixelStep(ScrollbarOrientation) const;
327 336
337 // Stores the paint invalidations for the scrollbars during layout.
338 IntRect m_horizontalBarDamage;
339 IntRect m_verticalBarDamage;
340
328 struct ScrollableAreaAnimators { 341 struct ScrollableAreaAnimators {
329 OwnPtr<ScrollAnimatorBase> scrollAnimator; 342 OwnPtr<ScrollAnimatorBase> scrollAnimator;
330 OwnPtr<ProgrammaticScrollAnimator> programmaticScrollAnimator; 343 OwnPtr<ProgrammaticScrollAnimator> programmaticScrollAnimator;
331 }; 344 };
332 345
333 mutable OwnPtr<ScrollableAreaAnimators> m_animators; 346 mutable OwnPtr<ScrollableAreaAnimators> m_animators;
334 347
335 unsigned m_inLiveResize : 1; 348 unsigned m_inLiveResize : 1;
336 349
337 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle 350 unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle
338 351
339 unsigned m_scrollOriginChanged : 1; 352 unsigned m_scrollOriginChanged : 1;
340 353
341 unsigned m_horizontalScrollbarNeedsPaintInvalidation : 1;
342 unsigned m_verticalScrollbarNeedsPaintInvalidation : 1;
343 unsigned m_scrollCornerNeedsPaintInvalidation : 1;
344
345 // There are 8 possible combinations of writing mode and direction. Scroll o rigin will be non-zero in the x or y axis 354 // There are 8 possible combinations of writing mode and direction. Scroll o rigin will be non-zero in the x or y axis
346 // if there is any reversed direction or writing-mode. The combinations are: 355 // if there is any reversed direction or writing-mode. The combinations are:
347 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set 356 // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set
348 // horizontal-tb / ltr NO NO 357 // horizontal-tb / ltr NO NO
349 // horizontal-tb / rtl YES NO 358 // horizontal-tb / rtl YES NO
350 // horizontal-bt / ltr NO YES 359 // horizontal-bt / ltr NO YES
351 // horizontal-bt / rtl YES YES 360 // horizontal-bt / rtl YES YES
352 // vertical-lr / ltr NO NO 361 // vertical-lr / ltr NO NO
353 // vertical-lr / rtl NO YES 362 // vertical-lr / rtl NO YES
354 // vertical-rl / ltr YES NO 363 // vertical-rl / ltr YES NO
355 // vertical-rl / rtl YES YES 364 // vertical-rl / rtl YES YES
356 IntPoint m_scrollOrigin; 365 IntPoint m_scrollOrigin;
357 }; 366 };
358 367
359 } // namespace blink 368 } // namespace blink
360 369
361 #endif // ScrollableArea_h 370 #endif // ScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698