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

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

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: 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 // 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.
314 LayoutRect overflowRect() const { return m_overflowRect; } 314 LayoutRect overflowRect() const { return m_overflowRect; }
315 315
316 DoubleSize offsetFromOrigin() const { 316 FloatPoint absolutePosition() const {
bokan 2016/10/02 19:47:51 Since scrollOrigin is a ScrollableArea concept, I
szager1 2016/10/05 07:43:36 Done.
317 return toDoubleSize(DoublePoint(scrollOrigin())) + m_scrollPosition; 317 return FloatPoint(scrollOrigin()) + m_scrollOffset;
318 } 318 }
319 void scrollToOffsetFromOrigin( 319 void scrollToAbsolutePosition(
320 const DoubleSize& scrollOffset, 320 const FloatPoint& position,
321 ScrollBehavior scrollBehavior = ScrollBehaviorInstant, 321 ScrollBehavior scrollBehavior = ScrollBehaviorInstant,
322 ScrollType scrollType = ProgrammaticScroll) { 322 ScrollType scrollType = ProgrammaticScroll) {
323 setScrollPosition(-scrollOrigin() + scrollOffset, scrollType, 323 setScrollOffset(position - scrollOrigin(), scrollType, scrollBehavior);
324 scrollBehavior);
325 } 324 }
326 325
327 // This will set the scroll position without clamping, and it will do all post -update 326 // This will set the scroll offset without clamping, and it will do all post-u pdate
328 // work even if the scroll position didn't change. 327 // work even if the scroll offset didn't change.
329 void setScrollPositionUnconditionally(const DoublePoint&, 328 void setScrollOffsetUnconditionally(const ScrollOffset&,
330 ScrollType = ProgrammaticScroll); 329 ScrollType = ProgrammaticScroll);
331 330
332 // TODO(szager): Actually run these after all of layout is finished. Currentl y, they 331 // TODO(szager): Actually run these after all of layout is finished. Currentl y, they
333 // run at the end of box()'es layout (or after all flexbox layout has finished ) but while 332 // run at the end of box()'es layout (or after all flexbox layout has finished ) but while
334 // document layout is still happening. 333 // document layout is still happening.
335 void updateAfterLayout(); 334 void updateAfterLayout();
336 void clampScrollPositionsAfterLayout(); 335 void clampScrollOffsetsAfterLayout();
337 336
338 void updateAfterStyleChange(const ComputedStyle*); 337 void updateAfterStyleChange(const ComputedStyle*);
339 void updateAfterOverflowRecalc(); 338 void updateAfterOverflowRecalc();
340 339
341 bool updateAfterCompositingChange() override; 340 bool updateAfterCompositingChange() override;
342 341
343 bool hasScrollbar() const { 342 bool hasScrollbar() const {
344 return hasHorizontalScrollbar() || hasVerticalScrollbar(); 343 return hasHorizontalScrollbar() || hasVerticalScrollbar();
345 } 344 }
346 bool hasOverflowControls() const { 345 bool hasOverflowControls() const {
(...skipping 26 matching lines...) Expand all
373 372
374 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control 373 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control
375 // area. 374 // area.
376 bool isPointInResizeControl(const IntPoint& absolutePoint, 375 bool isPointInResizeControl(const IntPoint& absolutePoint,
377 ResizerHitTestType) const; 376 ResizerHitTestType) const;
378 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint); 377 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
379 378
380 bool hitTestResizerInFragments(const PaintLayerFragments&, 379 bool hitTestResizerInFragments(const PaintLayerFragments&,
381 const HitTestLocation&) const; 380 const HitTestLocation&) const;
382 381
383 // Returns the new position, after scrolling, of the given rect in absolute 382 // Returns the new offset, after scrolling, of the given rect in absolute
384 // coordinates, clipped by the parent's client rect. 383 // coordinates, clipped by the parent's client rect.
385 LayoutRect scrollIntoView(const LayoutRect&, 384 LayoutRect scrollIntoView(const LayoutRect&,
386 const ScrollAlignment& alignX, 385 const ScrollAlignment& alignX,
387 const ScrollAlignment& alignY, 386 const ScrollAlignment& alignY,
388 ScrollType = ProgrammaticScroll) override; 387 ScrollType = ProgrammaticScroll) override;
389 388
390 // Returns true if scrollable area is in the FrameView's collection of scrolla ble areas. This can 389 // Returns true if scrollable area is in the FrameView's collection of scrolla ble areas. This can
391 // only happen if we're scrollable, visible to hit test, and do in fact overfl ow. This means that 390 // only happen if we're scrollable, visible to hit test, and do in fact overfl ow. This means that
392 // 'overflow: hidden' or 'pointer-events: none' layers never get added to the FrameView's collection. 391 // 'overflow: hidden' or 'pointer-events: none' layers never get added to the FrameView's collection.
393 bool scrollsOverflow() const { return m_scrollsOverflow; } 392 bool scrollsOverflow() const { return m_scrollsOverflow; }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 LayoutBox* layoutBox() const override { return &box(); } 433 LayoutBox* layoutBox() const override { return &box(); }
435 434
436 bool shouldRebuildHorizontalScrollbarLayer() const { 435 bool shouldRebuildHorizontalScrollbarLayer() const {
437 return m_rebuildHorizontalScrollbarLayer; 436 return m_rebuildHorizontalScrollbarLayer;
438 } 437 }
439 bool shouldRebuildVerticalScrollbarLayer() const { 438 bool shouldRebuildVerticalScrollbarLayer() const {
440 return m_rebuildVerticalScrollbarLayer; 439 return m_rebuildVerticalScrollbarLayer;
441 } 440 }
442 void resetRebuildScrollbarLayerFlags(); 441 void resetRebuildScrollbarLayerFlags();
443 442
444 // Did DelayScrollPositionClampScope prevent us from running clampScrollPositi onsAfterLayout() 443 // Did DelayScrollOffsetClampScope prevent us from running clampScrollOffsetsA fterLayout()
445 // in updateAfterLayout()? 444 // in updateAfterLayout()?
446 bool needsScrollPositionClamp() const { return m_needsScrollPositionClamp; } 445 bool needsScrollOffsetClamp() const { return m_needsScrollOffsetClamp; }
447 void setNeedsScrollPositionClamp(bool val) { 446 void setNeedsScrollOffsetClamp(bool val) { m_needsScrollOffsetClamp = val; }
448 m_needsScrollPositionClamp = val;
449 }
450 447
451 // Did PreventRelayoutScope prevent us from running re-layout due to adding/su btracting 448 // Did PreventRelayoutScope prevent us from running re-layout due to adding/su btracting
452 // scrollbars in updateAfterLayout()? 449 // scrollbars in updateAfterLayout()?
453 bool needsRelayout() const { return m_needsRelayout; } 450 bool needsRelayout() const { return m_needsRelayout; }
454 void setNeedsRelayout(bool val) { m_needsRelayout = val; } 451 void setNeedsRelayout(bool val) { m_needsRelayout = val; }
455 452
456 // Were we laid out with a horizontal scrollbar at the time we were marked as 453 // Were we laid out with a horizontal scrollbar at the time we were marked as
457 // needing relayout by PreventRelayoutScope? 454 // needing relayout by PreventRelayoutScope?
458 bool hadHorizontalScrollbarBeforeRelayout() const { 455 bool hadHorizontalScrollbarBeforeRelayout() const {
459 return m_hadHorizontalScrollbarBeforeRelayout; 456 return m_hadHorizontalScrollbarBeforeRelayout;
(...skipping 29 matching lines...) Expand all
489 bool hasVerticalOverflow() const; 486 bool hasVerticalOverflow() const;
490 bool hasScrollableHorizontalOverflow() const; 487 bool hasScrollableHorizontalOverflow() const;
491 bool hasScrollableVerticalOverflow() const; 488 bool hasScrollableVerticalOverflow() const;
492 bool visualViewportSuppliesScrollbars() const; 489 bool visualViewportSuppliesScrollbars() const;
493 490
494 bool needsScrollbarReconstruction() const; 491 bool needsScrollbarReconstruction() const;
495 492
496 void updateScrollOrigin(); 493 void updateScrollOrigin();
497 void updateScrollDimensions(); 494 void updateScrollDimensions();
498 495
499 void updateScrollPosition(const DoublePoint&, ScrollType) override; 496 void updateScrollOffset(const ScrollOffset&, ScrollType) override;
500 497
501 int verticalScrollbarStart(int minX, int maxX) const; 498 int verticalScrollbarStart(int minX, int maxX) const;
502 int horizontalScrollbarStart(int minX) const; 499 int horizontalScrollbarStart(int minX) const;
503 IntSize scrollbarOffset(const Scrollbar&) const; 500 IntSize scrollbarOffset(const Scrollbar&) const;
504 501
505 void setHasHorizontalScrollbar(bool hasScrollbar); 502 void setHasHorizontalScrollbar(bool hasScrollbar);
506 void setHasVerticalScrollbar(bool hasScrollbar); 503 void setHasVerticalScrollbar(bool hasScrollbar);
507 504
508 void updateScrollCornerStyle(); 505 void updateScrollCornerStyle();
509 506
(...skipping 27 matching lines...) Expand all
537 // FIXME: once cc can handle composited scrolling with clip paths, we will 534 // FIXME: once cc can handle composited scrolling with clip paths, we will
538 // no longer need this bit. 535 // no longer need this bit.
539 unsigned m_needsCompositedScrolling : 1; 536 unsigned m_needsCompositedScrolling : 1;
540 537
541 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt 538 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt
542 // in the next compositing update because the underlying blink::Scrollbar 539 // in the next compositing update because the underlying blink::Scrollbar
543 // instance has been reconstructed. 540 // instance has been reconstructed.
544 unsigned m_rebuildHorizontalScrollbarLayer : 1; 541 unsigned m_rebuildHorizontalScrollbarLayer : 1;
545 unsigned m_rebuildVerticalScrollbarLayer : 1; 542 unsigned m_rebuildVerticalScrollbarLayer : 1;
546 543
547 unsigned m_needsScrollPositionClamp : 1; 544 unsigned m_needsScrollOffsetClamp : 1;
548 unsigned m_needsRelayout : 1; 545 unsigned m_needsRelayout : 1;
549 unsigned m_hadHorizontalScrollbarBeforeRelayout : 1; 546 unsigned m_hadHorizontalScrollbarBeforeRelayout : 1;
550 unsigned m_hadVerticalScrollbarBeforeRelayout : 1; 547 unsigned m_hadVerticalScrollbarBeforeRelayout : 1;
551 548
552 // The width/height of our scrolled area. 549 // The width/height of our scrolled area.
553 // This is OverflowModel's layout overflow translated to physical 550 // This is OverflowModel's layout overflow translated to physical
554 // coordinates. See OverflowModel for the different overflow and 551 // coordinates. See OverflowModel for the different overflow and
555 // LayoutBoxModelObject for the coordinate systems. 552 // LayoutBoxModelObject for the coordinate systems.
556 LayoutRect m_overflowRect; 553 LayoutRect m_overflowRect;
557 554
558 // ScrollbarManager holds the Scrollbar instances. 555 // ScrollbarManager holds the Scrollbar instances.
559 ScrollbarManager m_scrollbarManager; 556 ScrollbarManager m_scrollbarManager;
560 557
561 // This is the absolute scroll position, *not* relative to m_scrollOrigin. 558 // This is the offset from the beginning of content flow.
562 DoubleSize m_scrollPosition; 559 ScrollOffset m_scrollOffset;
563 560
564 IntPoint m_cachedOverlayScrollbarOffset; 561 IntPoint m_cachedOverlayScrollbarOffset;
565 562
566 // LayoutObject to hold our custom scroll corner. 563 // LayoutObject to hold our custom scroll corner.
567 LayoutScrollbarPart* m_scrollCorner; 564 LayoutScrollbarPart* m_scrollCorner;
568 565
569 // LayoutObject to hold our custom resizer. 566 // LayoutObject to hold our custom resizer.
570 LayoutScrollbarPart* m_resizer; 567 LayoutScrollbarPart* m_resizer;
571 568
572 ScrollAnchor m_scrollAnchor; 569 ScrollAnchor m_scrollAnchor;
573 570
574 std::unique_ptr<PaintLayerScrollableAreaRareData> m_rareData; 571 std::unique_ptr<PaintLayerScrollableAreaRareData> m_rareData;
575 572
576 #if ENABLE(ASSERT) 573 #if ENABLE(ASSERT)
577 bool m_hasBeenDisposed; 574 bool m_hasBeenDisposed;
578 #endif 575 #endif
579 }; 576 };
580 577
581 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, 578 DEFINE_TYPE_CASTS(PaintLayerScrollableArea,
582 ScrollableArea, 579 ScrollableArea,
583 scrollableArea, 580 scrollableArea,
584 scrollableArea->isPaintLayerScrollableArea(), 581 scrollableArea->isPaintLayerScrollableArea(),
585 scrollableArea.isPaintLayerScrollableArea()); 582 scrollableArea.isPaintLayerScrollableArea());
586 583
587 } // namespace blink 584 } // namespace blink
588 585
589 #endif // LayerScrollableArea_h 586 #endif // LayerScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698