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

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

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Fix README.md 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 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@gmail.com> 10 * Christian Biesinger <cbiesinger@gmail.com>
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer) 90 PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer)
91 : m_layer(layer), 91 : m_layer(layer),
92 m_nextTopmostScrollChild(0), 92 m_nextTopmostScrollChild(0),
93 m_topmostScrollChild(0), 93 m_topmostScrollChild(0),
94 m_inResizeMode(false), 94 m_inResizeMode(false),
95 m_scrollsOverflow(false), 95 m_scrollsOverflow(false),
96 m_inOverflowRelayout(false), 96 m_inOverflowRelayout(false),
97 m_needsCompositedScrolling(false), 97 m_needsCompositedScrolling(false),
98 m_rebuildHorizontalScrollbarLayer(false), 98 m_rebuildHorizontalScrollbarLayer(false),
99 m_rebuildVerticalScrollbarLayer(false), 99 m_rebuildVerticalScrollbarLayer(false),
100 m_needsScrollPositionClamp(false), 100 m_needsScrollOffsetClamp(false),
101 m_needsRelayout(false), 101 m_needsRelayout(false),
102 m_hadHorizontalScrollbarBeforeRelayout(false), 102 m_hadHorizontalScrollbarBeforeRelayout(false),
103 m_hadVerticalScrollbarBeforeRelayout(false), 103 m_hadVerticalScrollbarBeforeRelayout(false),
104 m_scrollbarManager(*this), 104 m_scrollbarManager(*this),
105 m_scrollCorner(nullptr), 105 m_scrollCorner(nullptr),
106 m_resizer(nullptr), 106 m_resizer(nullptr),
107 m_scrollAnchor(this) 107 m_scrollAnchor(this)
108 #if ENABLE(ASSERT) 108 #if ENABLE(ASSERT)
109 , 109 ,
110 m_hasBeenDisposed(false) 110 m_hasBeenDisposed(false)
111 #endif 111 #endif
112 { 112 {
113 Node* node = box().node(); 113 Node* node = box().node();
114 if (node && node->isElementNode()) { 114 if (node && node->isElementNode()) {
115 // We save and restore only the scrollOffset as the other scroll values are 115 // We save and restore only the scrollOffset as the other scroll values are
116 // recalculated. 116 // recalculated.
117 Element* element = toElement(node); 117 Element* element = toElement(node);
118 m_scrollOffset = element->savedLayerScrollOffset(); 118 m_scrollOffset = element->savedLayerScrollOffset();
119 if (!m_scrollOffset.isZero()) { 119 if (!m_scrollOffset.isZero())
120 scrollAnimator().setCurrentPosition( 120 scrollAnimator().setCurrentOffset(m_scrollOffset);
121 FloatPoint(m_scrollOffset.width(), m_scrollOffset.height())); 121 element->setSavedLayerScrollOffset(ScrollOffset());
122 }
123 element->setSavedLayerScrollOffset(IntSize());
124 } 122 }
125 updateResizerAreaSet(); 123 updateResizerAreaSet();
126 } 124 }
127 125
128 PaintLayerScrollableArea::~PaintLayerScrollableArea() { 126 PaintLayerScrollableArea::~PaintLayerScrollableArea() {
129 ASSERT(m_hasBeenDisposed); 127 ASSERT(m_hasBeenDisposed);
130 } 128 }
131 129
132 void PaintLayerScrollableArea::dispose() { 130 void PaintLayerScrollableArea::dispose() {
133 if (inResizeMode() && !box().documentBeingDestroyed()) { 131 if (inResizeMode() && !box().documentBeingDestroyed()) {
(...skipping 10 matching lines...) Expand all
144 142
145 if (box().frame() && box().frame()->page()) { 143 if (box().frame() && box().frame()->page()) {
146 if (ScrollingCoordinator* scrollingCoordinator = 144 if (ScrollingCoordinator* scrollingCoordinator =
147 box().frame()->page()->scrollingCoordinator()) 145 box().frame()->page()->scrollingCoordinator())
148 scrollingCoordinator->willDestroyScrollableArea(this); 146 scrollingCoordinator->willDestroyScrollableArea(this);
149 } 147 }
150 148
151 if (!box().documentBeingDestroyed()) { 149 if (!box().documentBeingDestroyed()) {
152 Node* node = box().node(); 150 Node* node = box().node();
153 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283. 151 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283.
154 if (node && node->isElementNode()) { 152 if (node && node->isElementNode())
155 toElement(node)->setSavedLayerScrollOffset( 153 toElement(node)->setSavedLayerScrollOffset(m_scrollOffset);
156 flooredIntSize(m_scrollOffset));
157 }
158 } 154 }
159 155
160 if (LocalFrame* frame = box().frame()) { 156 if (LocalFrame* frame = box().frame()) {
161 if (FrameView* frameView = frame->view()) 157 if (FrameView* frameView = frame->view())
162 frameView->removeResizerArea(box()); 158 frameView->removeResizerArea(box());
163 } 159 }
164 160
165 if (RootScrollerController* controller = 161 if (RootScrollerController* controller =
166 box().document().rootScrollerController()) 162 box().document().rootScrollerController())
167 controller->didDisposePaintLayerScrollableArea(*this); 163 controller->didDisposePaintLayerScrollableArea(*this);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 return parentPoint; 345 return parentPoint;
350 346
351 IntPoint point = view->frameView()->convertToLayoutObject(box(), parentPoint); 347 IntPoint point = view->frameView()->convertToLayoutObject(box(), parentPoint);
352 348
353 point.move(-scrollbarOffset(scrollbar)); 349 point.move(-scrollbarOffset(scrollbar));
354 return point; 350 return point;
355 } 351 }
356 352
357 int PaintLayerScrollableArea::scrollSize( 353 int PaintLayerScrollableArea::scrollSize(
358 ScrollbarOrientation orientation) const { 354 ScrollbarOrientation orientation) const {
359 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition(); 355 IntSize scrollDimensions =
356 maximumScrollOffsetInt() - minimumScrollOffsetInt();
360 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() 357 return (orientation == HorizontalScrollbar) ? scrollDimensions.width()
361 : scrollDimensions.height(); 358 : scrollDimensions.height();
362 } 359 }
363 360
364 void PaintLayerScrollableArea::setScrollOffset( 361 void PaintLayerScrollableArea::updateScrollOffset(const ScrollOffset& newOffset,
365 const DoublePoint& newScrollOffset, 362 ScrollType scrollType) {
366 ScrollType scrollType) { 363 if (scrollOffset() == newOffset)
367 if (scrollOffset() == toDoubleSize(newScrollOffset))
368 return; 364 return;
369 365
370 DoubleSize scrollDelta = scrollOffset() - toDoubleSize(newScrollOffset); 366 ScrollOffset scrollDelta = scrollOffset() - newOffset;
371 m_scrollOffset = toDoubleSize(newScrollOffset); 367 m_scrollOffset = newOffset;
372 368
373 LocalFrame* frame = box().frame(); 369 LocalFrame* frame = box().frame();
374 ASSERT(frame); 370 ASSERT(frame);
375 371
376 FrameView* frameView = box().frameView(); 372 FrameView* frameView = box().frameView();
377 373
378 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", 374 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data",
379 InspectorScrollLayerEvent::data(&box())); 375 InspectorScrollLayerEvent::data(&box()));
380 376
381 // FIXME(420741): Resolve circular dependency between scroll offset and 377 // FIXME(420741): Resolve circular dependency between scroll offset and
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 453
458 // All scrolls clear the fragment anchor. 454 // All scrolls clear the fragment anchor.
459 frameView->clearFragmentAnchor(); 455 frameView->clearFragmentAnchor();
460 456
461 // Clear the scroll anchor, unless it is the reason for this scroll. 457 // Clear the scroll anchor, unless it is the reason for this scroll.
462 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && 458 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() &&
463 scrollType != AnchoringScroll) 459 scrollType != AnchoringScroll)
464 scrollAnchor()->clear(); 460 scrollAnchor()->clear();
465 } 461 }
466 462
467 IntPoint PaintLayerScrollableArea::scrollPosition() const { 463 IntSize PaintLayerScrollableArea::scrollOffsetInt() const {
468 return IntPoint(flooredIntSize(m_scrollOffset)); 464 return flooredIntSize(m_scrollOffset);
469 } 465 }
470 466
471 DoublePoint PaintLayerScrollableArea::scrollPositionDouble() const { 467 ScrollOffset PaintLayerScrollableArea::scrollOffset() const {
472 return DoublePoint(m_scrollOffset); 468 return m_scrollOffset;
473 } 469 }
474 470
475 IntPoint PaintLayerScrollableArea::minimumScrollPosition() const { 471 IntSize PaintLayerScrollableArea::minimumScrollOffsetInt() const {
476 return -scrollOrigin(); 472 return toIntSize(-scrollOrigin());
477 } 473 }
478 474
479 IntPoint PaintLayerScrollableArea::maximumScrollPosition() const { 475 IntSize PaintLayerScrollableArea::maximumScrollOffsetInt() const {
480 IntSize contentSize; 476 IntSize contentSize;
481 IntSize visibleSize; 477 IntSize visibleSize;
482 if (box().hasOverflowClip()) { 478 if (box().hasOverflowClip()) {
483 contentSize = 479 contentSize =
484 IntSize(pixelSnappedScrollWidth(), pixelSnappedScrollHeight()); 480 IntSize(pixelSnappedScrollWidth(), pixelSnappedScrollHeight());
485 visibleSize = 481 visibleSize =
486 pixelSnappedIntRect(box().overflowClipRect(box().location())).size(); 482 pixelSnappedIntRect(box().overflowClipRect(box().location())).size();
487 483
488 // TODO(skobes): We should really ASSERT that contentSize >= visibleSize 484 // TODO(skobes): We should really ASSERT that contentSize >= visibleSize
489 // when we are not the root layer, but we can't because contentSize is 485 // when we are not the root layer, but we can't because contentSize is
490 // based on stale layout overflow data (http://crbug.com/576933). 486 // based on stale layout overflow data (http://crbug.com/576933).
491 contentSize = contentSize.expandedTo(visibleSize); 487 contentSize = contentSize.expandedTo(visibleSize);
492 } 488 }
493 return -scrollOrigin() + (contentSize - visibleSize); 489 return toIntSize(-scrollOrigin() + (contentSize - visibleSize));
494 } 490 }
495 491
496 IntRect PaintLayerScrollableArea::visibleContentRect( 492 IntRect PaintLayerScrollableArea::visibleContentRect(
497 IncludeScrollbarsInRect scrollbarInclusion) const { 493 IncludeScrollbarsInRect scrollbarInclusion) const {
498 int verticalScrollbarWidth = 0; 494 int verticalScrollbarWidth = 0;
499 int horizontalScrollbarHeight = 0; 495 int horizontalScrollbarHeight = 0;
500 if (scrollbarInclusion == IncludeScrollbars) { 496 if (scrollbarInclusion == IncludeScrollbars) {
501 verticalScrollbarWidth = 497 verticalScrollbarWidth =
502 (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) 498 (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar())
503 ? verticalScrollbar()->scrollbarThickness() 499 ? verticalScrollbar()->scrollbarThickness()
504 : 0; 500 : 0;
505 horizontalScrollbarHeight = 501 horizontalScrollbarHeight =
506 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) 502 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar())
507 ? horizontalScrollbar()->scrollbarThickness() 503 ? horizontalScrollbar()->scrollbarThickness()
508 : 0; 504 : 0;
509 } 505 }
510 506
511 // TODO(szager): Handle fractional scroll offsets correctly. 507 // TODO(szager): Handle fractional scroll offsets correctly.
512 return IntRect( 508 return IntRect(
513 IntPoint(flooredIntSize(adjustedScrollOffset())), 509 flooredIntPoint(scrollPosition()),
514 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), 510 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth),
515 max(0, layer()->size().height() - horizontalScrollbarHeight))); 511 max(0, layer()->size().height() - horizontalScrollbarHeight)));
516 } 512 }
517 513
518 int PaintLayerScrollableArea::visibleHeight() const { 514 int PaintLayerScrollableArea::visibleHeight() const {
519 return layer()->size().height(); 515 return layer()->size().height();
520 } 516 }
521 517
522 int PaintLayerScrollableArea::visibleWidth() const { 518 int PaintLayerScrollableArea::visibleWidth() const {
523 return layer()->size().width(); 519 return layer()->size().width();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + 636 setScrollOrigin(flooredIntPoint(-scrollableOverflow) +
641 box().originAdjustmentForScrollbars()); 637 box().originAdjustmentForScrollbars());
642 } 638 }
643 639
644 void PaintLayerScrollableArea::updateScrollDimensions() { 640 void PaintLayerScrollableArea::updateScrollDimensions() {
645 m_overflowRect = box().layoutOverflowRect(); 641 m_overflowRect = box().layoutOverflowRect();
646 box().flipForWritingMode(m_overflowRect); 642 box().flipForWritingMode(m_overflowRect);
647 updateScrollOrigin(); 643 updateScrollOrigin();
648 } 644 }
649 645
650 void PaintLayerScrollableArea::setScrollPositionUnconditionally( 646 void PaintLayerScrollableArea::setScrollOffsetUnconditionally(
651 const DoublePoint& position, 647 const ScrollOffset& offset,
652 ScrollType scrollType) { 648 ScrollType scrollType) {
653 cancelScrollAnimation(); 649 cancelScrollAnimation();
654 scrollPositionChanged(position, scrollType); 650 scrollOffsetChanged(offset, scrollType);
655 } 651 }
656 652
657 void PaintLayerScrollableArea::updateAfterLayout() { 653 void PaintLayerScrollableArea::updateAfterLayout() {
658 ASSERT(box().hasOverflowClip()); 654 ASSERT(box().hasOverflowClip());
659 655
660 bool relayoutIsPrevented = PreventRelayoutScope::relayoutIsPrevented(); 656 bool relayoutIsPrevented = PreventRelayoutScope::relayoutIsPrevented();
661 bool scrollbarsAreFrozen = 657 bool scrollbarsAreFrozen =
662 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen(); 658 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen();
663 659
664 if (needsScrollbarReconstruction()) { 660 if (needsScrollbarReconstruction()) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } 783 }
788 } 784 }
789 785
790 if (!scrollbarsAreFrozen && hasOverlayScrollbars()) { 786 if (!scrollbarsAreFrozen && hasOverlayScrollbars()) {
791 if (!scrollSize(HorizontalScrollbar)) 787 if (!scrollSize(HorizontalScrollbar))
792 setHasHorizontalScrollbar(false); 788 setHasHorizontalScrollbar(false);
793 if (!scrollSize(VerticalScrollbar)) 789 if (!scrollSize(VerticalScrollbar))
794 setHasVerticalScrollbar(false); 790 setHasVerticalScrollbar(false);
795 } 791 }
796 792
797 clampScrollPositionsAfterLayout(); 793 clampScrollOffsetsAfterLayout();
798 794
799 if (!scrollbarsAreFrozen) { 795 if (!scrollbarsAreFrozen) {
800 bool hasOverflow = 796 bool hasOverflow =
801 hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow(); 797 hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow();
802 updateScrollableAreaSet(hasOverflow); 798 updateScrollableAreaSet(hasOverflow);
803 } 799 }
804 800
805 DisableCompositingQueryAsserts disabler; 801 DisableCompositingQueryAsserts disabler;
806 positionOverflowControls(); 802 positionOverflowControls();
807 } 803 }
808 804
809 void PaintLayerScrollableArea::clampScrollPositionsAfterLayout() { 805 void PaintLayerScrollableArea::clampScrollOffsetsAfterLayout() {
810 // If a vertical scrollbar was removed, the min/max scroll positions may have 806 // If a vertical scrollbar was removed, the min/max scroll offsets may have
811 // changed, so the scroll positions needs to be clamped. If the scroll 807 // changed, so the scroll offsets needs to be clamped. If the scroll offset
812 // position did not change, but the scroll origin *did* change, we still need 808 // did not change, but the scroll origin *did* change, we still need to notify
813 // to notify the scrollbars to update their dimensions. 809 // the scrollbars to update their dimensions.
814 810
815 if (DelayScrollPositionClampScope::clampingIsDelayed()) { 811 if (DelayScrollOffsetClampScope::clampingIsDelayed()) {
816 DelayScrollPositionClampScope::setNeedsClamp(this); 812 DelayScrollOffsetClampScope::setNeedsClamp(this);
817 return; 813 return;
818 } 814 }
819 815
820 // Restore before clamping because clamping clears the scroll anchor. 816 // Restore before clamping because clamping clears the scroll anchor.
821 if (shouldPerformScrollAnchoring()) 817 if (shouldPerformScrollAnchoring())
822 m_scrollAnchor.restore(); 818 m_scrollAnchor.restore();
823 819
824 if (scrollOriginChanged()) { 820 if (scrollOriginChanged())
825 setScrollPositionUnconditionally( 821 setScrollOffsetUnconditionally(clampScrollOffset(scrollOffset()));
826 clampScrollPosition(scrollPositionDouble())); 822 else
827 } else { 823 ScrollableArea::setScrollOffset(scrollOffset(), ProgrammaticScroll);
828 ScrollableArea::setScrollPosition(scrollPositionDouble(),
829 ProgrammaticScroll);
830 }
831 824
832 setNeedsScrollPositionClamp(false); 825 setNeedsScrollOffsetClamp(false);
833 resetScrollOriginChanged(); 826 resetScrollOriginChanged();
834 m_scrollbarManager.destroyDetachedScrollbars(); 827 m_scrollbarManager.destroyDetachedScrollbars();
835 } 828 }
836 829
837 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { 830 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const {
838 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && 831 return RuntimeEnabledFeatures::scrollAnchoringEnabled() &&
839 m_scrollAnchor.hasScroller() && 832 m_scrollAnchor.hasScroller() &&
840 layoutBox()->style()->overflowAnchor() != AnchorNone; 833 layoutBox()->style()->overflowAnchor() != AnchorNone;
841 } 834 }
842 835
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 LayoutRect localExposeRect( 1576 LayoutRect localExposeRect(
1584 box() 1577 box()
1585 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) 1578 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms)
1586 .boundingBox()); 1579 .boundingBox());
1587 localExposeRect.move(-box().borderLeft(), -box().borderTop()); 1580 localExposeRect.move(-box().borderLeft(), -box().borderTop());
1588 LayoutRect layerBounds(LayoutPoint(), 1581 LayoutRect layerBounds(LayoutPoint(),
1589 LayoutSize(box().clientWidth(), box().clientHeight())); 1582 LayoutSize(box().clientWidth(), box().clientHeight()));
1590 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, 1583 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect,
1591 alignX, alignY); 1584 alignX, alignY);
1592 1585
1593 DoublePoint clampedScrollPosition = clampScrollPosition( 1586 ScrollOffset oldScrollOffset = scrollOffset();
1594 scrollPositionDouble() + roundedIntSize(r.location())); 1587 ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize(
1595 if (clampedScrollPosition == scrollPositionDouble()) { 1588 toScrollOffset(FloatPoint(r.location()) + oldScrollOffset))));
1589
1590 if (newScrollOffset == oldScrollOffset) {
1596 return LayoutRect( 1591 return LayoutRect(
1597 box() 1592 box()
1598 .localToAbsoluteQuad(FloatQuad(FloatRect(intersection( 1593 .localToAbsoluteQuad(FloatQuad(FloatRect(intersection(
1599 layerBounds, localExposeRect))), 1594 layerBounds, localExposeRect))),
1600 UseTransforms) 1595 UseTransforms)
1601 .boundingBox()); 1596 .boundingBox());
1602 } 1597 }
1603 1598
1604 DoubleSize oldScrollOffset = adjustedScrollOffset(); 1599 setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
1605 setScrollPosition(clampedScrollPosition, scrollType, ScrollBehaviorInstant); 1600 ScrollOffset scrollOffsetDifference = scrollOffset() - oldScrollOffset;
1606 DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset;
1607 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); 1601 localExposeRect.move(-LayoutSize(scrollOffsetDifference));
1608 return LayoutRect( 1602 return LayoutRect(
1609 box() 1603 box()
1610 .localToAbsoluteQuad( 1604 .localToAbsoluteQuad(
1611 FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))), 1605 FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))),
1612 UseTransforms) 1606 UseTransforms)
1613 .boundingBox()); 1607 .boundingBox());
1614 } 1608 }
1615 1609
1616 void PaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) { 1610 void PaintLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 if (!m_hBar) { 1786 if (!m_hBar) {
1793 m_hBar = createScrollbar(HorizontalScrollbar); 1787 m_hBar = createScrollbar(HorizontalScrollbar);
1794 m_hBarIsAttached = 1; 1788 m_hBarIsAttached = 1;
1795 if (!m_hBar->isCustomScrollbar()) 1789 if (!m_hBar->isCustomScrollbar())
1796 m_scrollableArea->didAddScrollbar(*m_hBar, HorizontalScrollbar); 1790 m_scrollableArea->didAddScrollbar(*m_hBar, HorizontalScrollbar);
1797 } else { 1791 } else {
1798 m_hBarIsAttached = 1; 1792 m_hBarIsAttached = 1;
1799 } 1793 }
1800 } else { 1794 } else {
1801 m_hBarIsAttached = 0; 1795 m_hBarIsAttached = 0;
1802 if (!DelayScrollPositionClampScope::clampingIsDelayed()) 1796 if (!DelayScrollOffsetClampScope::clampingIsDelayed())
1803 destroyScrollbar(HorizontalScrollbar); 1797 destroyScrollbar(HorizontalScrollbar);
1804 } 1798 }
1805 } 1799 }
1806 1800
1807 void PaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar( 1801 void PaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar(
1808 bool hasScrollbar) { 1802 bool hasScrollbar) {
1809 if (hasScrollbar) { 1803 if (hasScrollbar) {
1810 DisableCompositingQueryAsserts disabler; 1804 DisableCompositingQueryAsserts disabler;
1811 if (!m_vBar) { 1805 if (!m_vBar) {
1812 m_vBar = createScrollbar(VerticalScrollbar); 1806 m_vBar = createScrollbar(VerticalScrollbar);
1813 m_vBarIsAttached = 1; 1807 m_vBarIsAttached = 1;
1814 if (!m_vBar->isCustomScrollbar()) 1808 if (!m_vBar->isCustomScrollbar())
1815 m_scrollableArea->didAddScrollbar(*m_vBar, VerticalScrollbar); 1809 m_scrollableArea->didAddScrollbar(*m_vBar, VerticalScrollbar);
1816 } else { 1810 } else {
1817 m_vBarIsAttached = 1; 1811 m_vBarIsAttached = 1;
1818 } 1812 }
1819 } else { 1813 } else {
1820 m_vBarIsAttached = 0; 1814 m_vBarIsAttached = 0;
1821 if (!DelayScrollPositionClampScope::clampingIsDelayed()) 1815 if (!DelayScrollOffsetClampScope::clampingIsDelayed())
1822 destroyScrollbar(VerticalScrollbar); 1816 destroyScrollbar(VerticalScrollbar);
1823 } 1817 }
1824 } 1818 }
1825 1819
1826 Scrollbar* PaintLayerScrollableArea::ScrollbarManager::createScrollbar( 1820 Scrollbar* PaintLayerScrollableArea::ScrollbarManager::createScrollbar(
1827 ScrollbarOrientation orientation) { 1821 ScrollbarOrientation orientation) {
1828 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached 1822 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached
1829 : !m_vBarIsAttached); 1823 : !m_vBarIsAttached);
1830 Scrollbar* scrollbar = nullptr; 1824 Scrollbar* scrollbar = nullptr;
1831 const LayoutObject& actualLayoutObject = 1825 const LayoutObject& actualLayoutObject =
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 } 1942 }
1949 1943
1950 void PaintLayerScrollableArea::PreventRelayoutScope::resetRelayoutNeeded() { 1944 void PaintLayerScrollableArea::PreventRelayoutScope::resetRelayoutNeeded() {
1951 DCHECK_EQ(s_count, 0); 1945 DCHECK_EQ(s_count, 0);
1952 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty()); 1946 DCHECK(!s_needsRelayout || s_needsRelayout->isEmpty());
1953 s_relayoutNeeded = false; 1947 s_relayoutNeeded = false;
1954 } 1948 }
1955 1949
1956 int PaintLayerScrollableArea::FreezeScrollbarsScope::s_count = 0; 1950 int PaintLayerScrollableArea::FreezeScrollbarsScope::s_count = 0;
1957 1951
1958 int PaintLayerScrollableArea::DelayScrollPositionClampScope::s_count = 0; 1952 int PaintLayerScrollableArea::DelayScrollOffsetClampScope::s_count = 0;
1959 PersistentHeapVector<Member<PaintLayerScrollableArea>>* 1953 PersistentHeapVector<Member<PaintLayerScrollableArea>>*
1960 PaintLayerScrollableArea::DelayScrollPositionClampScope::s_needsClamp = 1954 PaintLayerScrollableArea::DelayScrollOffsetClampScope::s_needsClamp =
1961 nullptr; 1955 nullptr;
1962 1956
1963 PaintLayerScrollableArea::DelayScrollPositionClampScope:: 1957 PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1964 DelayScrollPositionClampScope() { 1958 DelayScrollOffsetClampScope() {
1965 if (!s_needsClamp) 1959 if (!s_needsClamp)
1966 s_needsClamp = new PersistentHeapVector<Member<PaintLayerScrollableArea>>(); 1960 s_needsClamp = new PersistentHeapVector<Member<PaintLayerScrollableArea>>();
1967 DCHECK(s_count > 0 || s_needsClamp->isEmpty()); 1961 DCHECK(s_count > 0 || s_needsClamp->isEmpty());
1968 s_count++; 1962 s_count++;
1969 } 1963 }
1970 1964
1971 PaintLayerScrollableArea::DelayScrollPositionClampScope:: 1965 PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1972 ~DelayScrollPositionClampScope() { 1966 ~DelayScrollOffsetClampScope() {
1973 if (--s_count == 0) 1967 if (--s_count == 0)
1974 DelayScrollPositionClampScope::clampScrollableAreas(); 1968 DelayScrollOffsetClampScope::clampScrollableAreas();
1975 } 1969 }
1976 1970
1977 void PaintLayerScrollableArea::DelayScrollPositionClampScope::setNeedsClamp( 1971 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::setNeedsClamp(
1978 PaintLayerScrollableArea* scrollableArea) { 1972 PaintLayerScrollableArea* scrollableArea) {
1979 if (!scrollableArea->needsScrollPositionClamp()) { 1973 if (!scrollableArea->needsScrollOffsetClamp()) {
1980 scrollableArea->setNeedsScrollPositionClamp(true); 1974 scrollableArea->setNeedsScrollOffsetClamp(true);
1981 s_needsClamp->append(scrollableArea); 1975 s_needsClamp->append(scrollableArea);
1982 } 1976 }
1983 } 1977 }
1984 1978
1985 void PaintLayerScrollableArea::DelayScrollPositionClampScope:: 1979 void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
1986 clampScrollableAreas() { 1980 clampScrollableAreas() {
1987 for (auto& scrollableArea : *s_needsClamp) 1981 for (auto& scrollableArea : *s_needsClamp)
1988 scrollableArea->clampScrollPositionsAfterLayout(); 1982 scrollableArea->clampScrollOffsetsAfterLayout();
1989 delete s_needsClamp; 1983 delete s_needsClamp;
1990 s_needsClamp = nullptr; 1984 s_needsClamp = nullptr;
1991 } 1985 }
1992 1986
1993 } // namespace blink 1987 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698