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

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

Issue 2383113003: Refactor ScrollableArea::setScrollPosition. (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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 double scrollXOffset() const {
314 return m_scrollOffset.width() + scrollOrigin().x();
315 }
316 double scrollYOffset() const {
317 return m_scrollOffset.height() + scrollOrigin().y();
318 }
319
320 DoubleSize scrollOffset() const { return m_scrollOffset; }
321
322 // 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.
323 LayoutRect overflowRect() const { return m_overflowRect; } 314 LayoutRect overflowRect() const { return m_overflowRect; }
324 315
325 void scrollToPosition(const DoublePoint& scrollPosition, 316 DoubleSize offsetFromOrigin() const {
bokan 2016/10/01 20:32:47 I find this naming to be confusing, I think what t
szager1 2016/10/02 19:35:28 In discussion with skobes, we had different ideas
326 ScrollOffsetClamping = ScrollOffsetUnclamped, 317 return toDoubleSize(DoublePoint(scrollOrigin())) + m_scrollPosition;
327 ScrollBehavior = ScrollBehaviorInstant, 318 }
328 ScrollType = ProgrammaticScroll); 319 void scrollToOffsetFromOrigin(
329 320 const DoubleSize& scrollOffset,
330 void scrollToOffset(const DoubleSize& scrollOffset, 321 ScrollBehavior scrollBehavior = ScrollBehaviorInstant,
331 ScrollOffsetClamping clamp = ScrollOffsetUnclamped, 322 ScrollType scrollType = ProgrammaticScroll) {
332 ScrollBehavior scrollBehavior = ScrollBehaviorInstant, 323 setScrollPosition(-scrollOrigin() + scrollOffset, scrollType,
333 ScrollType scrollType = ProgrammaticScroll) { 324 scrollBehavior);
334 scrollToPosition(-scrollOrigin() + scrollOffset, clamp, scrollBehavior,
335 scrollType);
336 } 325 }
337 326
338 void scrollToXOffset(double x, 327 // This will set the scroll position without clamping, and it will do all post -update
339 ScrollOffsetClamping clamp = ScrollOffsetUnclamped, 328 // work even if the scroll position didn't change.
340 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) { 329 void setScrollPositionUnconditionally(const DoublePoint&,
341 scrollToOffset(DoubleSize(x, scrollYOffset()), clamp, scrollBehavior); 330 ScrollType = ProgrammaticScroll);
342 }
343
344 void scrollToYOffset(double y,
345 ScrollOffsetClamping clamp = ScrollOffsetUnclamped,
346 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) {
347 scrollToOffset(DoubleSize(scrollXOffset(), y), clamp, scrollBehavior);
348 }
349
350 void setScrollPosition(
351 const DoublePoint& position,
352 ScrollType scrollType,
353 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) override {
354 scrollToOffset(toDoubleSize(position), ScrollOffsetClamped, scrollBehavior,
355 scrollType);
356 }
357 331
358 // TODO(szager): Actually run these after all of layout is finished. Currentl y, they 332 // TODO(szager): Actually run these after all of layout is finished. Currentl y, they
359 // run at the end of box()'es layout (or after all flexbox layout has finished ) but while 333 // run at the end of box()'es layout (or after all flexbox layout has finished ) but while
360 // document layout is still happening. 334 // document layout is still happening.
361 void updateAfterLayout(); 335 void updateAfterLayout();
362 void clampScrollPositionsAfterLayout(); 336 void clampScrollPositionsAfterLayout();
363 337
364 void updateAfterStyleChange(const ComputedStyle*); 338 void updateAfterStyleChange(const ComputedStyle*);
365 void updateAfterOverflowRecalc(); 339 void updateAfterOverflowRecalc();
366 340
(...skipping 21 matching lines...) Expand all
388 LayoutUnit scrollWidth() const; 362 LayoutUnit scrollWidth() const;
389 LayoutUnit scrollHeight() const; 363 LayoutUnit scrollHeight() const;
390 int pixelSnappedScrollWidth() const; 364 int pixelSnappedScrollWidth() const;
391 int pixelSnappedScrollHeight() const; 365 int pixelSnappedScrollHeight() const;
392 366
393 int verticalScrollbarWidth( 367 int verticalScrollbarWidth(
394 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const; 368 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const;
395 int horizontalScrollbarHeight( 369 int horizontalScrollbarHeight(
396 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const; 370 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const;
397 371
398 DoubleSize adjustedScrollOffset() const {
399 return DoubleSize(scrollXOffset(), scrollYOffset());
400 }
401
402 void positionOverflowControls(); 372 void positionOverflowControls();
403 373
404 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control 374 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control
405 // area. 375 // area.
406 bool isPointInResizeControl(const IntPoint& absolutePoint, 376 bool isPointInResizeControl(const IntPoint& absolutePoint,
407 ResizerHitTestType) const; 377 ResizerHitTestType) const;
408 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint); 378 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
409 379
410 bool hitTestResizerInFragments(const PaintLayerFragments&, 380 bool hitTestResizerInFragments(const PaintLayerFragments&,
411 const HitTestLocation&) const; 381 const HitTestLocation&) const;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 bool hasVerticalOverflow() const; 489 bool hasVerticalOverflow() const;
520 bool hasScrollableHorizontalOverflow() const; 490 bool hasScrollableHorizontalOverflow() const;
521 bool hasScrollableVerticalOverflow() const; 491 bool hasScrollableVerticalOverflow() const;
522 bool visualViewportSuppliesScrollbars() const; 492 bool visualViewportSuppliesScrollbars() const;
523 493
524 bool needsScrollbarReconstruction() const; 494 bool needsScrollbarReconstruction() const;
525 495
526 void updateScrollOrigin(); 496 void updateScrollOrigin();
527 void updateScrollDimensions(); 497 void updateScrollDimensions();
528 498
529 void setScrollOffset(const DoublePoint&, ScrollType) override; 499 void updateScrollPosition(const DoublePoint&, ScrollType) override;
530 500
531 int verticalScrollbarStart(int minX, int maxX) const; 501 int verticalScrollbarStart(int minX, int maxX) const;
532 int horizontalScrollbarStart(int minX) const; 502 int horizontalScrollbarStart(int minX) const;
533 IntSize scrollbarOffset(const Scrollbar&) const; 503 IntSize scrollbarOffset(const Scrollbar&) const;
534 504
535 void setHasHorizontalScrollbar(bool hasScrollbar); 505 void setHasHorizontalScrollbar(bool hasScrollbar);
536 void setHasVerticalScrollbar(bool hasScrollbar); 506 void setHasVerticalScrollbar(bool hasScrollbar);
537 507
538 void updateScrollCornerStyle(); 508 void updateScrollCornerStyle();
539 509
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 551
582 // The width/height of our scrolled area. 552 // The width/height of our scrolled area.
583 // This is OverflowModel's layout overflow translated to physical 553 // This is OverflowModel's layout overflow translated to physical
584 // coordinates. See OverflowModel for the different overflow and 554 // coordinates. See OverflowModel for the different overflow and
585 // LayoutBoxModelObject for the coordinate systems. 555 // LayoutBoxModelObject for the coordinate systems.
586 LayoutRect m_overflowRect; 556 LayoutRect m_overflowRect;
587 557
588 // ScrollbarManager holds the Scrollbar instances. 558 // ScrollbarManager holds the Scrollbar instances.
589 ScrollbarManager m_scrollbarManager; 559 ScrollbarManager m_scrollbarManager;
590 560
591 // This is the (scroll) offset from scrollOrigin(). 561 // This is the absolute scroll position, *not* relative to m_scrollOrigin.
bokan 2016/10/01 20:32:47 Ok, I think I'm missing something. Absolute would
szager1 2016/10/02 19:35:28 Yeah, this is a bad comment; I changed it.
592 DoubleSize m_scrollOffset; 562 DoubleSize m_scrollPosition;
593 563
594 IntPoint m_cachedOverlayScrollbarOffset; 564 IntPoint m_cachedOverlayScrollbarOffset;
595 565
596 // LayoutObject to hold our custom scroll corner. 566 // LayoutObject to hold our custom scroll corner.
597 LayoutScrollbarPart* m_scrollCorner; 567 LayoutScrollbarPart* m_scrollCorner;
598 568
599 // LayoutObject to hold our custom resizer. 569 // LayoutObject to hold our custom resizer.
600 LayoutScrollbarPart* m_resizer; 570 LayoutScrollbarPart* m_resizer;
601 571
602 ScrollAnchor m_scrollAnchor; 572 ScrollAnchor m_scrollAnchor;
603 573
604 std::unique_ptr<PaintLayerScrollableAreaRareData> m_rareData; 574 std::unique_ptr<PaintLayerScrollableAreaRareData> m_rareData;
605 575
606 #if ENABLE(ASSERT) 576 #if ENABLE(ASSERT)
607 bool m_hasBeenDisposed; 577 bool m_hasBeenDisposed;
608 #endif 578 #endif
609 }; 579 };
610 580
611 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, 581 DEFINE_TYPE_CASTS(PaintLayerScrollableArea,
612 ScrollableArea, 582 ScrollableArea,
613 scrollableArea, 583 scrollableArea,
614 scrollableArea->isPaintLayerScrollableArea(), 584 scrollableArea->isPaintLayerScrollableArea(),
615 scrollableArea.isPaintLayerScrollableArea()); 585 scrollableArea.isPaintLayerScrollableArea());
616 586
617 } // namespace blink 587 } // namespace blink
618 588
619 #endif // LayerScrollableArea_h 589 #endif // LayerScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698