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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: tweaks and docs Created 4 years, 2 months 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) 2003, 2009, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 public: 207 public:
208 FreezeScrollbarsScope() { s_count++; } 208 FreezeScrollbarsScope() { s_count++; }
209 ~FreezeScrollbarsScope() { s_count--; } 209 ~FreezeScrollbarsScope() { s_count--; }
210 210
211 static bool scrollbarsAreFrozen() { return s_count; } 211 static bool scrollbarsAreFrozen() { return s_count; }
212 212
213 private: 213 private:
214 static int s_count; 214 static int s_count;
215 }; 215 };
216 216
217 // If a DelayScrollPositionClampScope object is alive, updateAfterLayout() wil l not 217 // If a DelayScrollOffsetClampScope object is alive, updateAfterLayout() will not
218 // clamp scroll positions to ensure they are in the valid range. When 218 // clamp scroll offsets to ensure they are in the valid range. When
219 // the last DelayScrollPositionClampScope object is destructed, all PaintLayer ScrollableArea's 219 // the last DelayScrollOffsetClampScope object is destructed, all PaintLayerSc rollableArea's
220 // that delayed clamping their positions will immediately clamp them. 220 // that delayed clamping their offsets will immediately clamp them.
221 class DelayScrollPositionClampScope { 221 class DelayScrollOffsetClampScope {
222 STACK_ALLOCATED(); 222 STACK_ALLOCATED();
223 223
224 public: 224 public:
225 DelayScrollPositionClampScope(); 225 DelayScrollOffsetClampScope();
226 ~DelayScrollPositionClampScope(); 226 ~DelayScrollOffsetClampScope();
227 227
228 static bool clampingIsDelayed() { return s_count; } 228 static bool clampingIsDelayed() { return s_count; }
229 static void setNeedsClamp(PaintLayerScrollableArea*); 229 static void setNeedsClamp(PaintLayerScrollableArea*);
230 230
231 private: 231 private:
232 static void clampScrollableAreas(); 232 static void clampScrollableAreas();
233 233
234 static int s_count; 234 static int s_count;
235 static PersistentHeapVector<Member<PaintLayerScrollableArea>>* s_needsClamp; 235 static PersistentHeapVector<Member<PaintLayerScrollableArea>>* s_needsClamp;
236 }; 236 };
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 const IntRect&) const override; 280 const IntRect&) const override;
281 IntRect convertFromContainingWidgetToScrollbar(const Scrollbar&, 281 IntRect convertFromContainingWidgetToScrollbar(const Scrollbar&,
282 const IntRect&) const override; 282 const IntRect&) const override;
283 IntPoint convertFromScrollbarToContainingWidget( 283 IntPoint convertFromScrollbarToContainingWidget(
284 const Scrollbar&, 284 const Scrollbar&,
285 const IntPoint&) const override; 285 const IntPoint&) const override;
286 IntPoint convertFromContainingWidgetToScrollbar( 286 IntPoint convertFromContainingWidgetToScrollbar(
287 const Scrollbar&, 287 const Scrollbar&,
288 const IntPoint&) const override; 288 const IntPoint&) const override;
289 int scrollSize(ScrollbarOrientation) const override; 289 int scrollSize(ScrollbarOrientation) const override;
290 IntPoint scrollPosition() const override; 290 IntSize scrollOffsetInt() const override;
291 DoublePoint scrollPositionDouble() const override; 291 ScrollOffset scrollOffset() const override;
292 IntPoint minimumScrollPosition() const override; 292 IntSize minimumScrollOffsetInt() const override;
293 IntPoint maximumScrollPosition() const override; 293 IntSize maximumScrollOffsetInt() const override;
294 IntRect visibleContentRect( 294 IntRect visibleContentRect(
295 IncludeScrollbarsInRect = ExcludeScrollbars) const override; 295 IncludeScrollbarsInRect = ExcludeScrollbars) const override;
296 int visibleHeight() const override; 296 int visibleHeight() const override;
297 int visibleWidth() const override; 297 int visibleWidth() const override;
298 IntSize contentsSize() const override; 298 IntSize contentsSize() const override;
299 IntPoint lastKnownMousePosition() const override; 299 IntPoint lastKnownMousePosition() const override;
300 bool scrollAnimatorEnabled() const override; 300 bool scrollAnimatorEnabled() const override;
301 bool shouldSuspendScrollAnimations() const override; 301 bool shouldSuspendScrollAnimations() const override;
302 bool scrollbarsCanBeActive() const override; 302 bool scrollbarsCanBeActive() const override;
303 void scrollbarVisibilityChanged() override; 303 void scrollbarVisibilityChanged() override;
304 IntRect scrollableAreaBoundingBox() const override; 304 IntRect scrollableAreaBoundingBox() const override;
305 void registerForAnimation() override; 305 void registerForAnimation() override;
306 void deregisterForAnimation() override; 306 void deregisterForAnimation() override;
307 bool userInputScrollable(ScrollbarOrientation) const override; 307 bool userInputScrollable(ScrollbarOrientation) const override;
308 bool shouldPlaceVerticalScrollbarOnLeft() const override; 308 bool shouldPlaceVerticalScrollbarOnLeft() const override;
309 int pageStep(ScrollbarOrientation) const override; 309 int pageStep(ScrollbarOrientation) const override;
310 ScrollBehavior scrollBehaviorStyle() const override; 310 ScrollBehavior scrollBehaviorStyle() const override;
311 CompositorAnimationTimeline* compositorAnimationTimeline() const override; 311 CompositorAnimationTimeline* compositorAnimationTimeline() const override;
312 312
313 DoubleSize scrollOffset() const { return m_scrollOffset; }
314
315 // FIXME: We shouldn't allow access to m_overflowRect outside this class. 313 // FIXME: We shouldn't allow access to m_overflowRect outside this class.
316 LayoutRect overflowRect() const { return m_overflowRect; } 314 LayoutRect overflowRect() const { return m_overflowRect; }
317 315
318 void scrollToOffset(const DoubleSize& scrollOffset, 316 void scrollToAbsolutePosition(
319 ScrollBehavior scrollBehavior = ScrollBehaviorInstant, 317 const FloatPoint& position,
320 ScrollType scrollType = ProgrammaticScroll) { 318 ScrollBehavior scrollBehavior = ScrollBehaviorInstant,
321 ScrollableArea::setScrollPosition(-scrollOrigin() + scrollOffset, 319 ScrollType scrollType = ProgrammaticScroll) {
322 scrollType, scrollBehavior); 320 setScrollOffset(position - scrollOrigin(), scrollType, scrollBehavior);
323 }
324
325 void setScrollPosition(
326 const DoublePoint& position,
327 ScrollType scrollType,
328 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) override {
329 scrollToOffset(toDoubleSize(position), scrollBehavior, scrollType);
330 } 321 }
331 322
332 // This will set the scroll position without clamping, and it will do all 323 // This will set the scroll position without clamping, and it will do all
333 // post-update work even if the scroll position didn't change. 324 // post-update work even if the scroll position didn't change.
325 void setScrollOffsetUnconditionally(const ScrollOffset&,
326 ScrollType = ProgrammaticScroll);
327
328 // This will set the scroll position without clamping, and it will do all
329 // post-update work even if the scroll position didn't change.
334 void setScrollPositionUnconditionally(const DoublePoint&, 330 void setScrollPositionUnconditionally(const DoublePoint&,
335 ScrollType = ProgrammaticScroll); 331 ScrollType = ProgrammaticScroll);
336 332
337 // TODO(szager): Actually run these after all of layout is finished. Currentl y, they 333 // TODO(szager): Actually run these after all of layout is finished. Currentl y, they
338 // run at the end of box()'es layout (or after all flexbox layout has finished ) but while 334 // run at the end of box()'es layout (or after all flexbox layout has finished ) but while
339 // document layout is still happening. 335 // document layout is still happening.
340 void updateAfterLayout(); 336 void updateAfterLayout();
341 void clampScrollPositionsAfterLayout(); 337 void clampScrollOffsetsAfterLayout();
342 338
343 void updateAfterStyleChange(const ComputedStyle*); 339 void updateAfterStyleChange(const ComputedStyle*);
344 void updateAfterOverflowRecalc(); 340 void updateAfterOverflowRecalc();
345 341
346 bool updateAfterCompositingChange() override; 342 bool updateAfterCompositingChange() override;
347 343
348 bool hasScrollbar() const { 344 bool hasScrollbar() const {
349 return hasHorizontalScrollbar() || hasVerticalScrollbar(); 345 return hasHorizontalScrollbar() || hasVerticalScrollbar();
350 } 346 }
351 bool hasOverflowControls() const { 347 bool hasOverflowControls() const {
(...skipping 30 matching lines...) Expand all
382 378
383 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control 379 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control
384 // area. 380 // area.
385 bool isPointInResizeControl(const IntPoint& absolutePoint, 381 bool isPointInResizeControl(const IntPoint& absolutePoint,
386 ResizerHitTestType) const; 382 ResizerHitTestType) const;
387 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint); 383 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
388 384
389 bool hitTestResizerInFragments(const PaintLayerFragments&, 385 bool hitTestResizerInFragments(const PaintLayerFragments&,
390 const HitTestLocation&) const; 386 const HitTestLocation&) const;
391 387
392 // Returns the new position, after scrolling, of the given rect in absolute 388 // Returns the new offset, after scrolling, of the given rect in absolute
393 // coordinates, clipped by the parent's client rect. 389 // coordinates, clipped by the parent's client rect.
394 LayoutRect scrollIntoView(const LayoutRect&, 390 LayoutRect scrollIntoView(const LayoutRect&,
395 const ScrollAlignment& alignX, 391 const ScrollAlignment& alignX,
396 const ScrollAlignment& alignY, 392 const ScrollAlignment& alignY,
397 ScrollType = ProgrammaticScroll) override; 393 ScrollType = ProgrammaticScroll) override;
398 394
399 // Returns true if scrollable area is in the FrameView's collection of scrolla ble areas. This can 395 // Returns true if scrollable area is in the FrameView's collection of scrolla ble areas. This can
400 // only happen if we're scrollable, visible to hit test, and do in fact overfl ow. This means that 396 // only happen if we're scrollable, visible to hit test, and do in fact overfl ow. This means that
401 // 'overflow: hidden' or 'pointer-events: none' layers never get added to the FrameView's collection. 397 // 'overflow: hidden' or 'pointer-events: none' layers never get added to the FrameView's collection.
402 bool scrollsOverflow() const { return m_scrollsOverflow; } 398 bool scrollsOverflow() const { return m_scrollsOverflow; }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 LayoutBox* layoutBox() const override { return &box(); } 439 LayoutBox* layoutBox() const override { return &box(); }
444 440
445 bool shouldRebuildHorizontalScrollbarLayer() const { 441 bool shouldRebuildHorizontalScrollbarLayer() const {
446 return m_rebuildHorizontalScrollbarLayer; 442 return m_rebuildHorizontalScrollbarLayer;
447 } 443 }
448 bool shouldRebuildVerticalScrollbarLayer() const { 444 bool shouldRebuildVerticalScrollbarLayer() const {
449 return m_rebuildVerticalScrollbarLayer; 445 return m_rebuildVerticalScrollbarLayer;
450 } 446 }
451 void resetRebuildScrollbarLayerFlags(); 447 void resetRebuildScrollbarLayerFlags();
452 448
453 // Did DelayScrollPositionClampScope prevent us from running clampScrollPositi onsAfterLayout() 449 // Did DelayScrollOffsetClampScope prevent us from running clampScrollOffsetsA fterLayout()
454 // in updateAfterLayout()? 450 // in updateAfterLayout()?
455 bool needsScrollPositionClamp() const { return m_needsScrollPositionClamp; } 451 bool needsScrollOffsetClamp() const { return m_needsScrollOffsetClamp; }
456 void setNeedsScrollPositionClamp(bool val) { 452 void setNeedsScrollOffsetClamp(bool val) { m_needsScrollOffsetClamp = val; }
457 m_needsScrollPositionClamp = val;
458 }
459 453
460 // Did PreventRelayoutScope prevent us from running re-layout due to adding/su btracting 454 // Did PreventRelayoutScope prevent us from running re-layout due to adding/su btracting
461 // scrollbars in updateAfterLayout()? 455 // scrollbars in updateAfterLayout()?
462 bool needsRelayout() const { return m_needsRelayout; } 456 bool needsRelayout() const { return m_needsRelayout; }
463 void setNeedsRelayout(bool val) { m_needsRelayout = val; } 457 void setNeedsRelayout(bool val) { m_needsRelayout = val; }
464 458
465 // Were we laid out with a horizontal scrollbar at the time we were marked as 459 // Were we laid out with a horizontal scrollbar at the time we were marked as
466 // needing relayout by PreventRelayoutScope? 460 // needing relayout by PreventRelayoutScope?
467 bool hadHorizontalScrollbarBeforeRelayout() const { 461 bool hadHorizontalScrollbarBeforeRelayout() const {
468 return m_hadHorizontalScrollbarBeforeRelayout; 462 return m_hadHorizontalScrollbarBeforeRelayout;
(...skipping 29 matching lines...) Expand all
498 bool hasVerticalOverflow() const; 492 bool hasVerticalOverflow() const;
499 bool hasScrollableHorizontalOverflow() const; 493 bool hasScrollableHorizontalOverflow() const;
500 bool hasScrollableVerticalOverflow() const; 494 bool hasScrollableVerticalOverflow() const;
501 bool visualViewportSuppliesScrollbars() const; 495 bool visualViewportSuppliesScrollbars() const;
502 496
503 bool needsScrollbarReconstruction() const; 497 bool needsScrollbarReconstruction() const;
504 498
505 void updateScrollOrigin(); 499 void updateScrollOrigin();
506 void updateScrollDimensions(); 500 void updateScrollDimensions();
507 501
508 void setScrollOffset(const DoublePoint&, ScrollType) override; 502 void updateScrollOffset(const ScrollOffset&, ScrollType) override;
509 503
510 int verticalScrollbarStart(int minX, int maxX) const; 504 int verticalScrollbarStart(int minX, int maxX) const;
511 int horizontalScrollbarStart(int minX) const; 505 int horizontalScrollbarStart(int minX) const;
512 IntSize scrollbarOffset(const Scrollbar&) const; 506 IntSize scrollbarOffset(const Scrollbar&) const;
513 507
514 void setHasHorizontalScrollbar(bool hasScrollbar); 508 void setHasHorizontalScrollbar(bool hasScrollbar);
515 void setHasVerticalScrollbar(bool hasScrollbar); 509 void setHasVerticalScrollbar(bool hasScrollbar);
516 510
517 void updateScrollCornerStyle(); 511 void updateScrollCornerStyle();
518 512
(...skipping 27 matching lines...) Expand all
546 // FIXME: once cc can handle composited scrolling with clip paths, we will 540 // FIXME: once cc can handle composited scrolling with clip paths, we will
547 // no longer need this bit. 541 // no longer need this bit.
548 unsigned m_needsCompositedScrolling : 1; 542 unsigned m_needsCompositedScrolling : 1;
549 543
550 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt 544 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt
551 // in the next compositing update because the underlying blink::Scrollbar 545 // in the next compositing update because the underlying blink::Scrollbar
552 // instance has been reconstructed. 546 // instance has been reconstructed.
553 unsigned m_rebuildHorizontalScrollbarLayer : 1; 547 unsigned m_rebuildHorizontalScrollbarLayer : 1;
554 unsigned m_rebuildVerticalScrollbarLayer : 1; 548 unsigned m_rebuildVerticalScrollbarLayer : 1;
555 549
556 unsigned m_needsScrollPositionClamp : 1; 550 unsigned m_needsScrollOffsetClamp : 1;
557 unsigned m_needsRelayout : 1; 551 unsigned m_needsRelayout : 1;
558 unsigned m_hadHorizontalScrollbarBeforeRelayout : 1; 552 unsigned m_hadHorizontalScrollbarBeforeRelayout : 1;
559 unsigned m_hadVerticalScrollbarBeforeRelayout : 1; 553 unsigned m_hadVerticalScrollbarBeforeRelayout : 1;
560 554
561 // The width/height of our scrolled area. 555 // The width/height of our scrolled area.
562 // This is OverflowModel's layout overflow translated to physical 556 // This is OverflowModel's layout overflow translated to physical
563 // coordinates. See OverflowModel for the different overflow and 557 // coordinates. See OverflowModel for the different overflow and
564 // LayoutBoxModelObject for the coordinate systems. 558 // LayoutBoxModelObject for the coordinate systems.
565 LayoutRect m_overflowRect; 559 LayoutRect m_overflowRect;
566 560
567 // ScrollbarManager holds the Scrollbar instances. 561 // ScrollbarManager holds the Scrollbar instances.
568 ScrollbarManager m_scrollbarManager; 562 ScrollbarManager m_scrollbarManager;
569 563
570 // This is the (scroll) offset from scrollOrigin(). 564 // This is the offset from the beginning of content flow.
571 DoubleSize m_scrollOffset; 565 ScrollOffset m_scrollOffset;
572 566
573 IntPoint m_cachedOverlayScrollbarOffset; 567 IntPoint m_cachedOverlayScrollbarOffset;
574 568
575 // LayoutObject to hold our custom scroll corner. 569 // LayoutObject to hold our custom scroll corner.
576 LayoutScrollbarPart* m_scrollCorner; 570 LayoutScrollbarPart* m_scrollCorner;
577 571
578 // LayoutObject to hold our custom resizer. 572 // LayoutObject to hold our custom resizer.
579 LayoutScrollbarPart* m_resizer; 573 LayoutScrollbarPart* m_resizer;
580 574
581 ScrollAnchor m_scrollAnchor; 575 ScrollAnchor m_scrollAnchor;
582 576
583 std::unique_ptr<PaintLayerScrollableAreaRareData> m_rareData; 577 std::unique_ptr<PaintLayerScrollableAreaRareData> m_rareData;
584 578
585 #if ENABLE(ASSERT) 579 #if ENABLE(ASSERT)
586 bool m_hasBeenDisposed; 580 bool m_hasBeenDisposed;
587 #endif 581 #endif
588 }; 582 };
589 583
590 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, 584 DEFINE_TYPE_CASTS(PaintLayerScrollableArea,
591 ScrollableArea, 585 ScrollableArea,
592 scrollableArea, 586 scrollableArea,
593 scrollableArea->isPaintLayerScrollableArea(), 587 scrollableArea->isPaintLayerScrollableArea(),
594 scrollableArea.isPaintLayerScrollableArea()); 588 scrollableArea.isPaintLayerScrollableArea());
595 589
596 } // namespace blink 590 } // namespace blink
597 591
598 #endif // LayerScrollableArea_h 592 #endif // LayerScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698