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

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

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: rebase 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_scrollOffset = element->savedLayerScrollOffset(); 116 m_scrollOffset = element->savedLayerScrollOffset();
117 if (!m_scrollOffset.isZero()) { 117 if (!m_scrollOffset.isZero())
118 scrollAnimator().setCurrentPosition( 118 scrollAnimator().setCurrentOffset(m_scrollOffset);
119 FloatPoint(m_scrollOffset.width(), m_scrollOffset.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_scrollOffset));
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::setScrollOffset( 356 void PaintLayerScrollableArea::updateScrollOffset(const ScrollOffset& newOffset,
360 const DoublePoint& newScrollOffset, 357 ScrollType scrollType) {
361 ScrollType scrollType) { 358 if (scrollOffset() == newOffset)
362 if (scrollOffset() == toDoubleSize(newScrollOffset))
363 return; 359 return;
364 360
365 DoubleSize scrollDelta = scrollOffset() - toDoubleSize(newScrollOffset); 361 ScrollOffset scrollDelta = scrollOffset() - newOffset;
366 m_scrollOffset = toDoubleSize(newScrollOffset); 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_scrollOffset)); 456 return flooredIntSize(m_scrollOffset);
461 } 457 }
462 458
463 DoublePoint PaintLayerScrollableArea::scrollPositionDouble() const { 459 ScrollOffset PaintLayerScrollableArea::scrollOffset() const {
464 return DoublePoint(m_scrollOffset); 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()->scrollbarThickness() 491 ? verticalScrollbar()->scrollbarThickness()
496 : 0; 492 : 0;
497 horizontalScrollbarHeight = 493 horizontalScrollbarHeight =
498 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) 494 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar())
499 ? horizontalScrollbar()->scrollbarThickness() 495 ? horizontalScrollbar()->scrollbarThickness()
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(adjustedScrollOffset())), 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 if (scrollOriginChanged()) { 802 if (scrollOriginChanged())
807 setScrollPositionUnconditionally( 803 setScrollOffsetUnconditionally(clampScrollOffset(scrollOffset()));
808 clampScrollPosition(scrollPositionDouble())); 804 else
809 } else { 805 ScrollableArea::setScrollOffset(scrollOffset(), ProgrammaticScroll);
810 ScrollableArea::setScrollPosition(scrollPositionDouble(),
811 ProgrammaticScroll);
812 }
813 806
814 setNeedsScrollPositionClamp(false); 807 setNeedsScrollOffsetClamp(false);
815 resetScrollOriginChanged(); 808 resetScrollOriginChanged();
816 m_scrollbarManager.destroyDetachedScrollbars(); 809 m_scrollbarManager.destroyDetachedScrollbars();
817 } 810 }
818 811
819 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { 812 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const {
820 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && 813 return RuntimeEnabledFeatures::scrollAnchoringEnabled() &&
821 m_scrollAnchor.hasScroller() && 814 m_scrollAnchor.hasScroller() &&
822 layoutBox()->style()->overflowAnchor() != AnchorNone; 815 layoutBox()->style()->overflowAnchor() != AnchorNone;
823 } 816 }
824 817
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 LayoutRect localExposeRect( 1548 LayoutRect localExposeRect(
1556 box() 1549 box()
1557 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) 1550 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms)
1558 .boundingBox()); 1551 .boundingBox());
1559 localExposeRect.move(-box().borderLeft(), -box().borderTop()); 1552 localExposeRect.move(-box().borderLeft(), -box().borderTop());
1560 LayoutRect layerBounds(LayoutPoint(), 1553 LayoutRect layerBounds(LayoutPoint(),
1561 LayoutSize(box().clientWidth(), box().clientHeight())); 1554 LayoutSize(box().clientWidth(), box().clientHeight()));
1562 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, 1555 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect,
1563 alignX, alignY); 1556 alignX, alignY);
1564 1557
1565 DoublePoint clampedScrollPosition = clampScrollPosition( 1558 ScrollOffset oldScrollOffset = scrollOffset();
1566 scrollPositionDouble() + roundedIntSize(r.location())); 1559 ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize(
1567 if (clampedScrollPosition == scrollPositionDouble()) { 1560 toScrollOffset(FloatPoint(r.location()) + oldScrollOffset))));
1561
1562 if (newScrollOffset == oldScrollOffset) {
1568 return LayoutRect( 1563 return LayoutRect(
1569 box() 1564 box()
1570 .localToAbsoluteQuad(FloatQuad(FloatRect(intersection( 1565 .localToAbsoluteQuad(FloatQuad(FloatRect(intersection(
1571 layerBounds, localExposeRect))), 1566 layerBounds, localExposeRect))),
1572 UseTransforms) 1567 UseTransforms)
1573 .boundingBox()); 1568 .boundingBox());
1574 } 1569 }
1575 1570
1576 DoubleSize oldScrollOffset = adjustedScrollOffset(); 1571 setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
1577 setScrollPosition(clampedScrollPosition, scrollType, ScrollBehaviorInstant); 1572 ScrollOffset scrollOffsetDifference = scrollOffset() - oldScrollOffset;
1578 DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset;
1579 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); 1573 localExposeRect.move(-LayoutSize(scrollOffsetDifference));
1580 return LayoutRect( 1574 return LayoutRect(
1581 box() 1575 box()
1582 .localToAbsoluteQuad( 1576 .localToAbsoluteQuad(
1583 FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))), 1577 FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))),
1584 UseTransforms) 1578 UseTransforms)
1585 .boundingBox()); 1579 .boundingBox());
1586 } 1580 }
1587 1581
1588 void PaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) { 1582 void PaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 if (!m_hBar) { 1755 if (!m_hBar) {
1762 m_hBar = createScrollbar(HorizontalScrollbar); 1756 m_hBar = createScrollbar(HorizontalScrollbar);
1763 m_hBarIsAttached = 1; 1757 m_hBarIsAttached = 1;
1764 if (!m_hBar->isCustomScrollbar()) 1758 if (!m_hBar->isCustomScrollbar())
1765 m_scrollableArea->didAddScrollbar(*m_hBar, HorizontalScrollbar); 1759 m_scrollableArea->didAddScrollbar(*m_hBar, HorizontalScrollbar);
1766 } else { 1760 } else {
1767 m_hBarIsAttached = 1; 1761 m_hBarIsAttached = 1;
1768 } 1762 }
1769 } else { 1763 } else {
1770 m_hBarIsAttached = 0; 1764 m_hBarIsAttached = 0;
1771 if (!DelayScrollPositionClampScope::clampingIsDelayed()) 1765 if (!DelayScrollOffsetClampScope::clampingIsDelayed())
1772 destroyScrollbar(HorizontalScrollbar); 1766 destroyScrollbar(HorizontalScrollbar);
1773 } 1767 }
1774 } 1768 }
1775 1769
1776 void PaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar( 1770 void PaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar(
1777 bool hasScrollbar) { 1771 bool hasScrollbar) {
1778 if (hasScrollbar) { 1772 if (hasScrollbar) {
1779 DisableCompositingQueryAsserts disabler; 1773 DisableCompositingQueryAsserts disabler;
1780 if (!m_vBar) { 1774 if (!m_vBar) {
1781 m_vBar = createScrollbar(VerticalScrollbar); 1775 m_vBar = createScrollbar(VerticalScrollbar);
1782 m_vBarIsAttached = 1; 1776 m_vBarIsAttached = 1;
1783 if (!m_vBar->isCustomScrollbar()) 1777 if (!m_vBar->isCustomScrollbar())
1784 m_scrollableArea->didAddScrollbar(*m_vBar, VerticalScrollbar); 1778 m_scrollableArea->didAddScrollbar(*m_vBar, VerticalScrollbar);
1785 } else { 1779 } else {
1786 m_vBarIsAttached = 1; 1780 m_vBarIsAttached = 1;
1787 } 1781 }
1788 } else { 1782 } else {
1789 m_vBarIsAttached = 0; 1783 m_vBarIsAttached = 0;
1790 if (!DelayScrollPositionClampScope::clampingIsDelayed()) 1784 if (!DelayScrollOffsetClampScope::clampingIsDelayed())
1791 destroyScrollbar(VerticalScrollbar); 1785 destroyScrollbar(VerticalScrollbar);
1792 } 1786 }
1793 } 1787 }
1794 1788
1795 Scrollbar* PaintLayerScrollableArea::ScrollbarManager::createScrollbar( 1789 Scrollbar* PaintLayerScrollableArea::ScrollbarManager::createScrollbar(
1796 ScrollbarOrientation orientation) { 1790 ScrollbarOrientation orientation) {
1797 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached 1791 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached
1798 : !m_vBarIsAttached); 1792 : !m_vBarIsAttached);
1799 Scrollbar* scrollbar = nullptr; 1793 Scrollbar* scrollbar = nullptr;
1800 const LayoutObject& actualLayoutObject = 1794 const LayoutObject& actualLayoutObject =
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 } 1911 }
1918 1912
1919 void PaintLayerScrollableArea::PreventRelayoutScope::resetRelayoutNeeded() { 1913 void PaintLayerScrollableArea::PreventRelayoutScope::resetRelayoutNeeded() {
1920 DCHECK_EQ(s_count, 0); 1914 DCHECK_EQ(s_count, 0);
1921 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty()); 1915 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty());
1922 s_relayoutNeeded = false; 1916 s_relayoutNeeded = false;
1923 } 1917 }
1924 1918
1925 int PaintLayerScrollableArea::FreezeScrollbarsScope::s_count = 0; 1919 int PaintLayerScrollableArea::FreezeScrollbarsScope::s_count = 0;
1926 1920
1927 int PaintLayerScrollableArea::DelayScrollPositionClampScope::s_count = 0; 1921 int PaintLayerScrollableArea::DelayScrollOffsetClampScope::s_count = 0;
1928 PersistentHeapVector<Member<PaintLayerScrollableArea>>* 1922 PersistentHeapVector<Member<PaintLayerScrollableArea>>*
1929 PaintLayerScrollableArea::DelayScrollPositionClampScope::s_needsClamp = 1923 PaintLayerScrollableArea::DelayScrollOffsetClampScope::s_needsClamp =
1930 nullptr; 1924 nullptr;
1931 1925
1932 PaintLayerScrollableArea::DelayScrollPositionClampScope:: 1926 PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1933 DelayScrollPositionClampScope() { 1927 DelayScrollOffsetClampScope() {
1934 if (!s_needsClamp) 1928 if (!s_needsClamp)
1935 s_needsClamp = new PersistentHeapVector<Member<PaintLayerScrollableArea>>(); 1929 s_needsClamp = new PersistentHeapVector<Member<PaintLayerScrollableArea>>();
1936 DCHECK(s_count > 0 || s_needsClamp->isEmpty()); 1930 DCHECK(s_count > 0 || s_needsClamp->isEmpty());
1937 s_count++; 1931 s_count++;
1938 } 1932 }
1939 1933
1940 PaintLayerScrollableArea::DelayScrollPositionClampScope:: 1934 PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1941 ~DelayScrollPositionClampScope() { 1935 ~DelayScrollOffsetClampScope() {
1942 if (--s_count == 0) 1936 if (--s_count == 0)
1943 DelayScrollPositionClampScope::clampScrollableAreas(); 1937 DelayScrollOffsetClampScope::clampScrollableAreas();
1944 } 1938 }
1945 1939
1946 void PaintLayerScrollableArea::DelayScrollPositionClampScope::setNeedsClamp( 1940 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::setNeedsClamp(
1947 PaintLayerScrollableArea* scrollableArea) { 1941 PaintLayerScrollableArea* scrollableArea) {
1948 if (!scrollableArea->needsScrollPositionClamp()) { 1942 if (!scrollableArea->needsScrollOffsetClamp()) {
1949 scrollableArea->setNeedsScrollPositionClamp(true); 1943 scrollableArea->setNeedsScrollOffsetClamp(true);
1950 s_needsClamp->append(scrollableArea); 1944 s_needsClamp->append(scrollableArea);
1951 } 1945 }
1952 } 1946 }
1953 1947
1954 void PaintLayerScrollableArea::DelayScrollPositionClampScope:: 1948 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1955 clampScrollableAreas() { 1949 clampScrollableAreas() {
1956 for (auto& scrollableArea : *s_needsClamp) 1950 for (auto& scrollableArea : *s_needsClamp)
1957 scrollableArea->clampScrollPositionsAfterLayout(); 1951 scrollableArea->clampScrollOffsetsAfterLayout();
1958 delete s_needsClamp; 1952 delete s_needsClamp;
1959 s_needsClamp = nullptr; 1953 s_needsClamp = nullptr;
1960 } 1954 }
1961 1955
1962 } // namespace blink 1956 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698