OLD | NEW |
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 if (layer()->isRootLayer()) { | 452 if (layer()->isRootLayer()) { |
453 frameView->frame().loader().saveScrollState(); | 453 frameView->frame().loader().saveScrollState(); |
454 frameView->didChangeScrollOffset(); | 454 frameView->didChangeScrollOffset(); |
455 } | 455 } |
456 | 456 |
457 // All scrolls clear the fragment anchor. | 457 // All scrolls clear the fragment anchor. |
458 frameView->clearFragmentAnchor(); | 458 frameView->clearFragmentAnchor(); |
459 | 459 |
460 // Clear the scroll anchor, unless it is the reason for this scroll. | 460 // Clear the scroll anchor, unless it is the reason for this scroll. |
461 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 461 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
462 scrollType != AnchoringScroll) | 462 scrollType != AnchoringScroll && scrollType != ClampingScroll) |
463 scrollAnchor()->clear(); | 463 scrollAnchor()->clear(); |
464 } | 464 } |
465 | 465 |
466 IntSize PaintLayerScrollableArea::scrollOffsetInt() const { | 466 IntSize PaintLayerScrollableArea::scrollOffsetInt() const { |
467 return flooredIntSize(m_scrollOffset); | 467 return flooredIntSize(m_scrollOffset); |
468 } | 468 } |
469 | 469 |
470 ScrollOffset PaintLayerScrollableArea::scrollOffset() const { | 470 ScrollOffset PaintLayerScrollableArea::scrollOffset() const { |
471 return m_scrollOffset; | 471 return m_scrollOffset; |
472 } | 472 } |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 // If a vertical scrollbar was removed, the min/max scroll offsets may have | 779 // If a vertical scrollbar was removed, the min/max scroll offsets may have |
780 // changed, so the scroll offsets needs to be clamped. If the scroll offset | 780 // changed, so the scroll offsets needs to be clamped. If the scroll offset |
781 // did not change, but the scroll origin *did* change, we still need to notify | 781 // did not change, but the scroll origin *did* change, we still need to notify |
782 // the scrollbars to update their dimensions. | 782 // the scrollbars to update their dimensions. |
783 | 783 |
784 if (DelayScrollOffsetClampScope::clampingIsDelayed()) { | 784 if (DelayScrollOffsetClampScope::clampingIsDelayed()) { |
785 DelayScrollOffsetClampScope::setNeedsClamp(this); | 785 DelayScrollOffsetClampScope::setNeedsClamp(this); |
786 return; | 786 return; |
787 } | 787 } |
788 | 788 |
789 // Restore before clamping because clamping clears the scroll anchor. | |
790 if (shouldPerformScrollAnchoring()) | |
791 m_scrollAnchor.restore(); | |
792 | |
793 if (scrollOriginChanged()) | 789 if (scrollOriginChanged()) |
794 setScrollOffsetUnconditionally(clampScrollOffset(scrollOffset())); | 790 setScrollOffsetUnconditionally(clampScrollOffset(scrollOffset())); |
795 else | 791 else |
796 ScrollableArea::setScrollOffset(scrollOffset(), ProgrammaticScroll); | 792 ScrollableArea::setScrollOffset(scrollOffset(), ClampingScroll); |
797 | 793 |
798 setNeedsScrollOffsetClamp(false); | 794 setNeedsScrollOffsetClamp(false); |
799 resetScrollOriginChanged(); | 795 resetScrollOriginChanged(); |
800 m_scrollbarManager.destroyDetachedScrollbars(); | 796 m_scrollbarManager.destroyDetachedScrollbars(); |
801 } | 797 } |
802 | 798 |
803 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { | 799 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { |
804 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 800 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
805 m_scrollAnchor.hasScroller() && | 801 m_scrollAnchor.hasScroller() && |
806 layoutBox()->style()->overflowAnchor() != AnchorNone && | 802 layoutBox()->style()->overflowAnchor() != AnchorNone && |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 | 1947 |
1952 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 1948 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
1953 clampScrollableAreas() { | 1949 clampScrollableAreas() { |
1954 for (auto& scrollableArea : *s_needsClamp) | 1950 for (auto& scrollableArea : *s_needsClamp) |
1955 scrollableArea->clampScrollOffsetsAfterLayout(); | 1951 scrollableArea->clampScrollOffsetsAfterLayout(); |
1956 delete s_needsClamp; | 1952 delete s_needsClamp; |
1957 s_needsClamp = nullptr; | 1953 s_needsClamp = nullptr; |
1958 } | 1954 } |
1959 | 1955 |
1960 } // namespace blink | 1956 } // namespace blink |
OLD | NEW |