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

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

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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 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@gmail.com> 9 * Christian Biesinger <cbiesinger@gmail.com>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer) 89 PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer)
90 : m_layer(layer), 90 : m_layer(layer),
91 m_nextTopmostScrollChild(0), 91 m_nextTopmostScrollChild(0),
92 m_topmostScrollChild(0), 92 m_topmostScrollChild(0),
93 m_inResizeMode(false), 93 m_inResizeMode(false),
94 m_scrollsOverflow(false), 94 m_scrollsOverflow(false),
95 m_inOverflowRelayout(false), 95 m_inOverflowRelayout(false),
96 m_needsCompositedScrolling(false), 96 m_needsCompositedScrolling(false),
97 m_rebuildHorizontalScrollbarLayer(false), 97 m_rebuildHorizontalScrollbarLayer(false),
98 m_rebuildVerticalScrollbarLayer(false), 98 m_rebuildVerticalScrollbarLayer(false),
99 m_needsScrollPositionClamp(false), 99 m_needsScrollOffsetClamp(false),
100 m_needsRelayout(false), 100 m_needsRelayout(false),
101 m_hadHorizontalScrollbarBeforeRelayout(false), 101 m_hadHorizontalScrollbarBeforeRelayout(false),
102 m_hadVerticalScrollbarBeforeRelayout(false), 102 m_hadVerticalScrollbarBeforeRelayout(false),
103 m_scrollbarManager(*this), 103 m_scrollbarManager(*this),
104 m_scrollCorner(nullptr), 104 m_scrollCorner(nullptr),
105 m_resizer(nullptr), 105 m_resizer(nullptr),
106 m_scrollAnchor(this) 106 m_scrollAnchor(this)
107 #if ENABLE(ASSERT) 107 #if ENABLE(ASSERT)
108 , 108 ,
109 m_hasBeenDisposed(false) 109 m_hasBeenDisposed(false)
110 #endif 110 #endif
111 { 111 {
112 Node* node = box().node(); 112 Node* node = box().node();
113 if (node && node->isElementNode()) { 113 if (node && node->isElementNode()) {
114 // We save and restore only the scrollOffset as the other scroll values are recalculated. 114 // We save and restore only the scrollOffset as the other scroll values are recalculated.
115 Element* element = toElement(node); 115 Element* element = toElement(node);
116 m_scrollPosition = element->savedLayerScrollOffset(); 116 m_scrollOffset = element->savedLayerScrollOffset();
117 if (!m_scrollPosition.isZero()) { 117 if (!m_scrollOffset.isZero())
118 scrollAnimator().setCurrentPosition( 118 scrollAnimator().setCurrentOffset(m_scrollOffset);
119 FloatPoint(m_scrollPosition.width(), m_scrollPosition.height())); 119 element->setSavedLayerScrollOffset(ScrollOffset());
120 }
121 element->setSavedLayerScrollOffset(IntSize());
122 } 120 }
123 updateResizerAreaSet(); 121 updateResizerAreaSet();
124 } 122 }
125 123
126 PaintLayerScrollableArea::~PaintLayerScrollableArea() { 124 PaintLayerScrollableArea::~PaintLayerScrollableArea() {
127 ASSERT(m_hasBeenDisposed); 125 ASSERT(m_hasBeenDisposed);
128 } 126 }
129 127
130 void PaintLayerScrollableArea::dispose() { 128 void PaintLayerScrollableArea::dispose() {
131 if (inResizeMode() && !box().documentBeingDestroyed()) { 129 if (inResizeMode() && !box().documentBeingDestroyed()) {
(...skipping 10 matching lines...) Expand all
142 140
143 if (box().frame() && box().frame()->page()) { 141 if (box().frame() && box().frame()->page()) {
144 if (ScrollingCoordinator* scrollingCoordinator = 142 if (ScrollingCoordinator* scrollingCoordinator =
145 box().frame()->page()->scrollingCoordinator()) 143 box().frame()->page()->scrollingCoordinator())
146 scrollingCoordinator->willDestroyScrollableArea(this); 144 scrollingCoordinator->willDestroyScrollableArea(this);
147 } 145 }
148 146
149 if (!box().documentBeingDestroyed()) { 147 if (!box().documentBeingDestroyed()) {
150 Node* node = box().node(); 148 Node* node = box().node();
151 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283. 149 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283.
152 if (node && node->isElementNode()) { 150 if (node && node->isElementNode())
153 toElement(node)->setSavedLayerScrollOffset( 151 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset);
154 flooredIntSize(m_scrollPosition));
155 }
156 } 152 }
157 153
158 if (LocalFrame* frame = box().frame()) { 154 if (LocalFrame* frame = box().frame()) {
159 if (FrameView* frameView = frame->view()) 155 if (FrameView* frameView = frame->view())
160 frameView->removeResizerArea(box()); 156 frameView->removeResizerArea(box());
161 } 157 }
162 158
163 if (RootScrollerController* controller = 159 if (RootScrollerController* controller =
164 box().document().rootScrollerController()) 160 box().document().rootScrollerController())
165 controller->didDisposePaintLayerScrollableArea(*this); 161 controller->didDisposePaintLayerScrollableArea(*this);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return parentPoint; 340 return parentPoint;
345 341
346 IntPoint point = view->frameView()->convertToLayoutObject(box(), parentPoint); 342 IntPoint point = view->frameView()->convertToLayoutObject(box(), parentPoint);
347 343
348 point.move(-scrollbarOffset(scrollbar)); 344 point.move(-scrollbarOffset(scrollbar));
349 return point; 345 return point;
350 } 346 }
351 347
352 int PaintLayerScrollableArea::scrollSize( 348 int PaintLayerScrollableArea::scrollSize(
353 ScrollbarOrientation orientation) const { 349 ScrollbarOrientation orientation) const {
354 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition(); 350 IntSize scrollDimensions =
351 maximumScrollOffsetInt() - minimumScrollOffsetInt();
355 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() 352 return (orientation == HorizontalScrollbar) ? scrollDimensions.width()
356 : scrollDimensions.height(); 353 : scrollDimensions.height();
357 } 354 }
358 355
359 void PaintLayerScrollableArea::updateScrollPosition( 356 void PaintLayerScrollableArea::updateScrollOffset(const ScrollOffset& newOffset,
360 const DoublePoint& newPosition, 357 ScrollType scrollType) {
361 ScrollType scrollType) { 358 if (scrollOffset() == newOffset)
362 if (scrollPositionDouble() == newPosition)
363 return; 359 return;
364 360
365 DoubleSize scrollDelta = scrollPositionDouble() - newPosition; 361 ScrollOffset scrollDelta = scrollOffset() - newOffset;
366 m_scrollPosition = toDoubleSize(newPosition); 362 m_scrollOffset = newOffset;
367 363
368 LocalFrame* frame = box().frame(); 364 LocalFrame* frame = box().frame();
369 ASSERT(frame); 365 ASSERT(frame);
370 366
371 FrameView* frameView = box().frameView(); 367 FrameView* frameView = box().frameView();
372 368
373 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", 369 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data",
374 InspectorScrollLayerEvent::data(&box())); 370 InspectorScrollLayerEvent::data(&box()));
375 371
376 // FIXME(420741): Resolve circular dependency between scroll offset and 372 // FIXME(420741): Resolve circular dependency between scroll offset and
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 430 }
435 431
436 // Schedule the scroll DOM event. 432 // Schedule the scroll DOM event.
437 if (box().node()) 433 if (box().node())
438 box().node()->document().enqueueScrollEventForNode(box().node()); 434 box().node()->document().enqueueScrollEventForNode(box().node());
439 435
440 if (AXObjectCache* cache = box().document().existingAXObjectCache()) 436 if (AXObjectCache* cache = box().document().existingAXObjectCache())
441 cache->handleScrollPositionChanged(&box()); 437 cache->handleScrollPositionChanged(&box());
442 box().view()->clearHitTestCache(); 438 box().view()->clearHitTestCache();
443 439
444 // Inform the FrameLoader of the new scroll position, so it can be restored wh en navigating back. 440 // Inform the FrameLoader of the new scroll offset, so it can be restored when navigating back.
445 if (layer()->isRootLayer()) { 441 if (layer()->isRootLayer()) {
446 frameView->frame().loader().saveScrollState(); 442 frameView->frame().loader().saveScrollState();
447 frameView->didChangeScrollOffset(); 443 frameView->didChangeScrollOffset();
448 } 444 }
449 445
450 // All scrolls clear the fragment anchor. 446 // All scrolls clear the fragment anchor.
451 frameView->clearFragmentAnchor(); 447 frameView->clearFragmentAnchor();
452 448
453 // Clear the scroll anchor, unless it is the reason for this scroll. 449 // Clear the scroll anchor, unless it is the reason for this scroll.
454 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && 450 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() &&
455 scrollType != AnchoringScroll) 451 scrollType != AnchoringScroll)
456 scrollAnchor()->clear(); 452 scrollAnchor()->clear();
457 } 453 }
458 454
459 IntPoint PaintLayerScrollableArea::scrollPosition() const { 455 IntSize PaintLayerScrollableArea::scrollOffsetInt() const {
460 return IntPoint(flooredIntSize(m_scrollPosition)); 456 return flooredIntSize(m_scrollOffset);
461 } 457 }
462 458
463 DoublePoint PaintLayerScrollableArea::scrollPositionDouble() const { 459 ScrollOffset PaintLayerScrollableArea::scrollOffset() const {
464 return DoublePoint(m_scrollPosition); 460 return m_scrollOffset;
465 } 461 }
466 462
467 IntPoint PaintLayerScrollableArea::minimumScrollPosition() const { 463 IntSize PaintLayerScrollableArea::minimumScrollOffsetInt() const {
468 return -scrollOrigin(); 464 return toIntSize(-scrollOrigin());
469 } 465 }
470 466
471 IntPoint PaintLayerScrollableArea::maximumScrollPosition() const { 467 IntSize PaintLayerScrollableArea::maximumScrollOffsetInt() const {
472 IntSize contentSize; 468 IntSize contentSize;
473 IntSize visibleSize; 469 IntSize visibleSize;
474 if (box().hasOverflowClip()) { 470 if (box().hasOverflowClip()) {
475 contentSize = 471 contentSize =
476 IntSize(pixelSnappedScrollWidth(), pixelSnappedScrollHeight()); 472 IntSize(pixelSnappedScrollWidth(), pixelSnappedScrollHeight());
477 visibleSize = 473 visibleSize =
478 pixelSnappedIntRect(box().overflowClipRect(box().location())).size(); 474 pixelSnappedIntRect(box().overflowClipRect(box().location())).size();
479 475
480 // TODO(skobes): We should really ASSERT that contentSize >= visibleSize 476 // TODO(skobes): We should really ASSERT that contentSize >= visibleSize
481 // when we are not the root layer, but we can't because contentSize is 477 // when we are not the root layer, but we can't because contentSize is
482 // based on stale layout overflow data (http://crbug.com/576933). 478 // based on stale layout overflow data (http://crbug.com/576933).
483 contentSize = contentSize.expandedTo(visibleSize); 479 contentSize = contentSize.expandedTo(visibleSize);
484 } 480 }
485 return -scrollOrigin() + (contentSize - visibleSize); 481 return toIntSize(-scrollOrigin() + (contentSize - visibleSize));
486 } 482 }
487 483
488 IntRect PaintLayerScrollableArea::visibleContentRect( 484 IntRect PaintLayerScrollableArea::visibleContentRect(
489 IncludeScrollbarsInRect scrollbarInclusion) const { 485 IncludeScrollbarsInRect scrollbarInclusion) const {
490 int verticalScrollbarWidth = 0; 486 int verticalScrollbarWidth = 0;
491 int horizontalScrollbarHeight = 0; 487 int horizontalScrollbarHeight = 0;
492 if (scrollbarInclusion == IncludeScrollbars) { 488 if (scrollbarInclusion == IncludeScrollbars) {
493 verticalScrollbarWidth = 489 verticalScrollbarWidth =
494 (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) 490 (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar())
495 ? verticalScrollbar()->width() 491 ? verticalScrollbar()->width()
496 : 0; 492 : 0;
497 horizontalScrollbarHeight = 493 horizontalScrollbarHeight =
498 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) 494 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar())
499 ? horizontalScrollbar()->height() 495 ? horizontalScrollbar()->height()
500 : 0; 496 : 0;
501 } 497 }
502 498
503 // TODO(szager): Handle fractional scroll offsets correctly. 499 // TODO(szager): Handle fractional scroll offsets correctly.
504 return IntRect( 500 return IntRect(
505 IntPoint(flooredIntSize(offsetFromOrigin())), 501 flooredIntPoint(absolutePosition()),
506 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), 502 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth),
507 max(0, layer()->size().height() - horizontalScrollbarHeight))); 503 max(0, layer()->size().height() - horizontalScrollbarHeight)));
508 } 504 }
509 505
510 int PaintLayerScrollableArea::visibleHeight() const { 506 int PaintLayerScrollableArea::visibleHeight() const {
511 return layer()->size().height(); 507 return layer()->size().height();
512 } 508 }
513 509
514 int PaintLayerScrollableArea::visibleWidth() const { 510 int PaintLayerScrollableArea::visibleWidth() const {
515 return layer()->size().width(); 511 return layer()->size().width();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + 627 setScrollOrigin(flooredIntPoint(-scrollableOverflow) +
632 box().originAdjustmentForScrollbars()); 628 box().originAdjustmentForScrollbars());
633 } 629 }
634 630
635 void PaintLayerScrollableArea::updateScrollDimensions() { 631 void PaintLayerScrollableArea::updateScrollDimensions() {
636 m_overflowRect = box().layoutOverflowRect(); 632 m_overflowRect = box().layoutOverflowRect();
637 box().flipForWritingMode(m_overflowRect); 633 box().flipForWritingMode(m_overflowRect);
638 updateScrollOrigin(); 634 updateScrollOrigin();
639 } 635 }
640 636
641 void PaintLayerScrollableArea::setScrollPositionUnconditionally( 637 void PaintLayerScrollableArea::setScrollOffsetUnconditionally(
642 const DoublePoint& position, 638 const ScrollOffset& offset,
643 ScrollType scrollType) { 639 ScrollType scrollType) {
644 cancelScrollAnimation(); 640 cancelScrollAnimation();
645 scrollPositionChanged(position, scrollType); 641 scrollOffsetChanged(offset, scrollType);
646 } 642 }
647 643
648 void PaintLayerScrollableArea::updateAfterLayout() { 644 void PaintLayerScrollableArea::updateAfterLayout() {
649 ASSERT(box().hasOverflowClip()); 645 ASSERT(box().hasOverflowClip());
650 646
651 bool relayoutIsPrevented = PreventRelayoutScope::relayoutIsPrevented(); 647 bool relayoutIsPrevented = PreventRelayoutScope::relayoutIsPrevented();
652 bool scrollbarsAreFrozen = 648 bool scrollbarsAreFrozen =
653 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen(); 649 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen();
654 650
655 if (needsScrollbarReconstruction()) { 651 if (needsScrollbarReconstruction()) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 } 765 }
770 } 766 }
771 767
772 if (!scrollbarsAreFrozen && hasOverlayScrollbars()) { 768 if (!scrollbarsAreFrozen && hasOverlayScrollbars()) {
773 if (!scrollSize(HorizontalScrollbar)) 769 if (!scrollSize(HorizontalScrollbar))
774 setHasHorizontalScrollbar(false); 770 setHasHorizontalScrollbar(false);
775 if (!scrollSize(VerticalScrollbar)) 771 if (!scrollSize(VerticalScrollbar))
776 setHasVerticalScrollbar(false); 772 setHasVerticalScrollbar(false);
777 } 773 }
778 774
779 clampScrollPositionsAfterLayout(); 775 clampScrollOffsetsAfterLayout();
780 776
781 if (!scrollbarsAreFrozen) { 777 if (!scrollbarsAreFrozen) {
782 bool hasOverflow = 778 bool hasOverflow =
783 hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow(); 779 hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow();
784 updateScrollableAreaSet(hasOverflow); 780 updateScrollableAreaSet(hasOverflow);
785 } 781 }
786 782
787 DisableCompositingQueryAsserts disabler; 783 DisableCompositingQueryAsserts disabler;
788 positionOverflowControls(); 784 positionOverflowControls();
789 } 785 }
790 786
791 void PaintLayerScrollableArea::clampScrollPositionsAfterLayout() { 787 void PaintLayerScrollableArea::clampScrollOffsetsAfterLayout() {
792 // If a vertical scrollbar was removed, the min/max scroll positions may have changed, 788 // If a vertical scrollbar was removed, the min/max scroll offsets may have ch anged,
793 // so the scroll positions needs to be clamped. If the scroll position did no t change, 789 // so the scroll offsets needs to be clamped. If the scroll offset did not ch ange,
794 // but the scroll origin *did* change, we still need to notify the scrollbars to 790 // but the scroll origin *did* change, we still need to notify the scrollbars to
795 // update their dimensions. 791 // update their dimensions.
796 792
797 if (DelayScrollPositionClampScope::clampingIsDelayed()) { 793 if (DelayScrollOffsetClampScope::clampingIsDelayed()) {
798 DelayScrollPositionClampScope::setNeedsClamp(this); 794 DelayScrollOffsetClampScope::setNeedsClamp(this);
799 return; 795 return;
800 } 796 }
801 797
802 // Restore before clamping because clamping clears the scroll anchor. 798 // Restore before clamping because clamping clears the scroll anchor.
803 if (shouldPerformScrollAnchoring()) 799 if (shouldPerformScrollAnchoring())
804 m_scrollAnchor.restore(); 800 m_scrollAnchor.restore();
805 801
806 DoublePoint clamped = clampScrollPosition(scrollPositionDouble()); 802 ScrollOffset clamped = clampScrollOffset(scrollOffset());
807 if (scrollOriginChanged()) 803 if (scrollOriginChanged())
808 setScrollPositionUnconditionally(clamped); 804 setScrollOffsetUnconditionally(clamped);
809 else if (clamped != scrollPositionDouble()) 805 else if (clamped != scrollOffset())
810 ScrollableArea::setScrollPosition(clamped, ProgrammaticScroll); 806 ScrollableArea::setScrollOffset(clamped, ProgrammaticScroll);
811 807
812 setNeedsScrollPositionClamp(false); 808 setNeedsScrollOffsetClamp(false);
813 resetScrollOriginChanged(); 809 resetScrollOriginChanged();
814 m_scrollbarManager.destroyDetachedScrollbars(); 810 m_scrollbarManager.destroyDetachedScrollbars();
815 } 811 }
816 812
817 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { 813 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const {
818 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && 814 return RuntimeEnabledFeatures::scrollAnchoringEnabled() &&
819 m_scrollAnchor.hasScroller() && 815 m_scrollAnchor.hasScroller() &&
820 layoutBox()->style()->overflowAnchor() != AnchorNone; 816 layoutBox()->style()->overflowAnchor() != AnchorNone;
821 } 817 }
822 818
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 LayoutRect localExposeRect( 1548 LayoutRect localExposeRect(
1553 box() 1549 box()
1554 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) 1550 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms)
1555 .boundingBox()); 1551 .boundingBox());
1556 localExposeRect.move(-box().borderLeft(), -box().borderTop()); 1552 localExposeRect.move(-box().borderLeft(), -box().borderTop());
1557 LayoutRect layerBounds(LayoutPoint(), 1553 LayoutRect layerBounds(LayoutPoint(),
1558 LayoutSize(box().clientWidth(), box().clientHeight())); 1554 LayoutSize(box().clientWidth(), box().clientHeight()));
1559 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, 1555 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect,
1560 alignX, alignY); 1556 alignX, alignY);
1561 1557
1562 DoublePoint oldScrollPosition = scrollPositionDouble(); 1558 ScrollOffset oldScrollOffset = scrollOffset();
1563 DoublePoint newScrollPosition = 1559 ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize(
1564 clampScrollPosition(oldScrollPosition + roundedIntSize(r.location())); 1560 toScrollOffset(FloatPoint(r.location()) + oldScrollOffset))));
1565 if (newScrollPosition == oldScrollPosition) 1561
1562 if (newScrollOffset == oldScrollOffset)
1566 return LayoutRect( 1563 return LayoutRect(
1567 box() 1564 box()
1568 .localToAbsoluteQuad(FloatQuad(FloatRect(intersection( 1565 .localToAbsoluteQuad(FloatQuad(FloatRect(intersection(
1569 layerBounds, localExposeRect))), 1566 layerBounds, localExposeRect))),
1570 UseTransforms) 1567 UseTransforms)
1571 .boundingBox()); 1568 .boundingBox());
1572 1569
1573 setScrollPosition(newScrollPosition, scrollType, ScrollBehaviorInstant); 1570 setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
1574 DoubleSize scrollOffsetDifference = 1571 ScrollOffset scrollOffsetDifference = scrollOffset() - oldScrollOffset;
1575 scrollPositionDouble() - oldScrollPosition;
1576 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); 1572 localExposeRect.move(-LayoutSize(scrollOffsetDifference));
1577 return LayoutRect( 1573 return LayoutRect(
1578 box() 1574 box()
1579 .localToAbsoluteQuad( 1575 .localToAbsoluteQuad(
1580 FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))), 1576 FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))),
1581 UseTransforms) 1577 UseTransforms)
1582 .boundingBox()); 1578 .boundingBox());
1583 } 1579 }
1584 1580
1585 void PaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) { 1581 void PaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 if (!m_hBar) { 1754 if (!m_hBar) {
1759 m_hBar = createScrollbar(HorizontalScrollbar); 1755 m_hBar = createScrollbar(HorizontalScrollbar);
1760 m_hBarIsAttached = 1; 1756 m_hBarIsAttached = 1;
1761 if (!m_hBar->isCustomScrollbar()) 1757 if (!m_hBar->isCustomScrollbar())
1762 m_scrollableArea->didAddScrollbar(*m_hBar, HorizontalScrollbar); 1758 m_scrollableArea->didAddScrollbar(*m_hBar, HorizontalScrollbar);
1763 } else { 1759 } else {
1764 m_hBarIsAttached = 1; 1760 m_hBarIsAttached = 1;
1765 } 1761 }
1766 } else { 1762 } else {
1767 m_hBarIsAttached = 0; 1763 m_hBarIsAttached = 0;
1768 if (!DelayScrollPositionClampScope::clampingIsDelayed()) 1764 if (!DelayScrollOffsetClampScope::clampingIsDelayed())
1769 destroyScrollbar(HorizontalScrollbar); 1765 destroyScrollbar(HorizontalScrollbar);
1770 } 1766 }
1771 } 1767 }
1772 1768
1773 void PaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar( 1769 void PaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar(
1774 bool hasScrollbar) { 1770 bool hasScrollbar) {
1775 if (hasScrollbar) { 1771 if (hasScrollbar) {
1776 DisableCompositingQueryAsserts disabler; 1772 DisableCompositingQueryAsserts disabler;
1777 if (!m_vBar) { 1773 if (!m_vBar) {
1778 m_vBar = createScrollbar(VerticalScrollbar); 1774 m_vBar = createScrollbar(VerticalScrollbar);
1779 m_vBarIsAttached = 1; 1775 m_vBarIsAttached = 1;
1780 if (!m_vBar->isCustomScrollbar()) 1776 if (!m_vBar->isCustomScrollbar())
1781 m_scrollableArea->didAddScrollbar(*m_vBar, VerticalScrollbar); 1777 m_scrollableArea->didAddScrollbar(*m_vBar, VerticalScrollbar);
1782 } else { 1778 } else {
1783 m_vBarIsAttached = 1; 1779 m_vBarIsAttached = 1;
1784 } 1780 }
1785 } else { 1781 } else {
1786 m_vBarIsAttached = 0; 1782 m_vBarIsAttached = 0;
1787 if (!DelayScrollPositionClampScope::clampingIsDelayed()) 1783 if (!DelayScrollOffsetClampScope::clampingIsDelayed())
1788 destroyScrollbar(VerticalScrollbar); 1784 destroyScrollbar(VerticalScrollbar);
1789 } 1785 }
1790 } 1786 }
1791 1787
1792 Scrollbar* PaintLayerScrollableArea::ScrollbarManager::createScrollbar( 1788 Scrollbar* PaintLayerScrollableArea::ScrollbarManager::createScrollbar(
1793 ScrollbarOrientation orientation) { 1789 ScrollbarOrientation orientation) {
1794 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached 1790 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached
1795 : !m_vBarIsAttached); 1791 : !m_vBarIsAttached);
1796 Scrollbar* scrollbar = nullptr; 1792 Scrollbar* scrollbar = nullptr;
1797 const LayoutObject& actualLayoutObject = 1793 const LayoutObject& actualLayoutObject =
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 } 1910 }
1915 1911
1916 void PaintLayerScrollableArea::PreventRelayoutScope::resetRelayoutNeeded() { 1912 void PaintLayerScrollableArea::PreventRelayoutScope::resetRelayoutNeeded() {
1917 DCHECK_EQ(s_count, 0); 1913 DCHECK_EQ(s_count, 0);
1918 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty()); 1914 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty());
1919 s_relayoutNeeded = false; 1915 s_relayoutNeeded = false;
1920 } 1916 }
1921 1917
1922 int PaintLayerScrollableArea::FreezeScrollbarsScope::s_count = 0; 1918 int PaintLayerScrollableArea::FreezeScrollbarsScope::s_count = 0;
1923 1919
1924 int PaintLayerScrollableArea::DelayScrollPositionClampScope::s_count = 0; 1920 int PaintLayerScrollableArea::DelayScrollOffsetClampScope::s_count = 0;
1925 PersistentHeapVector<Member<PaintLayerScrollableArea>>* 1921 PersistentHeapVector<Member<PaintLayerScrollableArea>>*
1926 PaintLayerScrollableArea::DelayScrollPositionClampScope::s_needsClamp = 1922 PaintLayerScrollableArea::DelayScrollOffsetClampScope::s_needsClamp =
1927 nullptr; 1923 nullptr;
1928 1924
1929 PaintLayerScrollableArea::DelayScrollPositionClampScope:: 1925 PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1930 DelayScrollPositionClampScope() { 1926 DelayScrollOffsetClampScope() {
1931 if (!s_needsClamp) 1927 if (!s_needsClamp)
1932 s_needsClamp = new PersistentHeapVector<Member<PaintLayerScrollableArea>>(); 1928 s_needsClamp = new PersistentHeapVector<Member<PaintLayerScrollableArea>>();
1933 DCHECK(s_count > 0 || s_needsClamp->isEmpty()); 1929 DCHECK(s_count > 0 || s_needsClamp->isEmpty());
1934 s_count++; 1930 s_count++;
1935 } 1931 }
1936 1932
1937 PaintLayerScrollableArea::DelayScrollPositionClampScope:: 1933 PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1938 ~DelayScrollPositionClampScope() { 1934 ~DelayScrollOffsetClampScope() {
1939 if (--s_count == 0) 1935 if (--s_count == 0)
1940 DelayScrollPositionClampScope::clampScrollableAreas(); 1936 DelayScrollOffsetClampScope::clampScrollableAreas();
1941 } 1937 }
1942 1938
1943 void PaintLayerScrollableArea::DelayScrollPositionClampScope::setNeedsClamp( 1939 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::setNeedsClamp(
1944 PaintLayerScrollableArea* scrollableArea) { 1940 PaintLayerScrollableArea* scrollableArea) {
1945 if (!scrollableArea->needsScrollPositionClamp()) { 1941 if (!scrollableArea->needsScrollOffsetClamp()) {
1946 scrollableArea->setNeedsScrollPositionClamp(true); 1942 scrollableArea->setNeedsScrollOffsetClamp(true);
1947 s_needsClamp->append(scrollableArea); 1943 s_needsClamp->append(scrollableArea);
1948 } 1944 }
1949 } 1945 }
1950 1946
1951 void PaintLayerScrollableArea::DelayScrollPositionClampScope:: 1947 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1952 clampScrollableAreas() { 1948 clampScrollableAreas() {
1953 for (auto& scrollableArea : *s_needsClamp) 1949 for (auto& scrollableArea : *s_needsClamp)
1954 scrollableArea->clampScrollPositionsAfterLayout(); 1950 scrollableArea->clampScrollOffsetsAfterLayout();
1955 delete s_needsClamp; 1951 delete s_needsClamp;
1956 s_needsClamp = nullptr; 1952 s_needsClamp = nullptr;
1957 } 1953 }
1958 1954
1959 } // namespace blink 1955 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698