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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if (layer()->isRootLayer()) { | 449 if (layer()->isRootLayer()) { |
450 frameView->frame().loader().saveScrollState(); | 450 frameView->frame().loader().saveScrollState(); |
451 frameView->didChangeScrollOffset(); | 451 frameView->didChangeScrollOffset(); |
452 } | 452 } |
453 | 453 |
454 // All scrolls clear the fragment anchor. | 454 // All scrolls clear the fragment anchor. |
455 frameView->clearFragmentAnchor(); | 455 frameView->clearFragmentAnchor(); |
456 | 456 |
457 // 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. |
458 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 458 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
459 scrollType != AnchoringScroll) | 459 scrollType != AnchoringScroll && scrollType != ClampingScroll) |
460 scrollAnchor()->clear(); | 460 scrollAnchor()->clear(); |
461 } | 461 } |
462 | 462 |
463 IntSize PaintLayerScrollableArea::scrollOffsetInt() const { | 463 IntSize PaintLayerScrollableArea::scrollOffsetInt() const { |
464 return flooredIntSize(m_scrollOffset); | 464 return flooredIntSize(m_scrollOffset); |
465 } | 465 } |
466 | 466 |
467 ScrollOffset PaintLayerScrollableArea::scrollOffset() const { | 467 ScrollOffset PaintLayerScrollableArea::scrollOffset() const { |
468 return m_scrollOffset; | 468 return m_scrollOffset; |
469 } | 469 } |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 // If a vertical scrollbar was removed, the min/max scroll offsets may have | 806 // If a vertical scrollbar was removed, the min/max scroll offsets may have |
807 // changed, so the scroll offsets needs to be clamped. If the scroll offset | 807 // changed, so the scroll offsets needs to be clamped. If the scroll offset |
808 // did not change, but the scroll origin *did* change, we still need to notify | 808 // did not change, but the scroll origin *did* change, we still need to notify |
809 // the scrollbars to update their dimensions. | 809 // the scrollbars to update their dimensions. |
810 | 810 |
811 if (DelayScrollOffsetClampScope::clampingIsDelayed()) { | 811 if (DelayScrollOffsetClampScope::clampingIsDelayed()) { |
812 DelayScrollOffsetClampScope::setNeedsClamp(this); | 812 DelayScrollOffsetClampScope::setNeedsClamp(this); |
813 return; | 813 return; |
814 } | 814 } |
815 | 815 |
816 // Restore before clamping because clamping clears the scroll anchor. | |
817 if (shouldPerformScrollAnchoring()) | |
818 m_scrollAnchor.restore(); | |
819 | |
820 if (scrollOriginChanged()) | 816 if (scrollOriginChanged()) |
821 setScrollOffsetUnconditionally(clampScrollOffset(scrollOffset())); | 817 setScrollOffsetUnconditionally(clampScrollOffset(scrollOffset())); |
822 else | 818 else |
823 ScrollableArea::setScrollOffset(scrollOffset(), ProgrammaticScroll); | 819 ScrollableArea::setScrollOffset(scrollOffset(), ClampingScroll); |
824 | 820 |
825 setNeedsScrollOffsetClamp(false); | 821 setNeedsScrollOffsetClamp(false); |
826 resetScrollOriginChanged(); | 822 resetScrollOriginChanged(); |
827 m_scrollbarManager.destroyDetachedScrollbars(); | 823 m_scrollbarManager.destroyDetachedScrollbars(); |
828 } | 824 } |
829 | 825 |
830 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { | 826 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { |
831 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 827 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
832 m_scrollAnchor.hasScroller() && | 828 m_scrollAnchor.hasScroller() && |
833 layoutBox()->style()->overflowAnchor() != AnchorNone; | 829 layoutBox()->style()->overflowAnchor() != AnchorNone; |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1978 | 1974 |
1979 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: | 1975 void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: |
1980 clampScrollableAreas() { | 1976 clampScrollableAreas() { |
1981 for (auto& scrollableArea : *s_needsClamp) | 1977 for (auto& scrollableArea : *s_needsClamp) |
1982 scrollableArea->clampScrollOffsetsAfterLayout(); | 1978 scrollableArea->clampScrollOffsetsAfterLayout(); |
1983 delete s_needsClamp; | 1979 delete s_needsClamp; |
1984 s_needsClamp = nullptr; | 1980 s_needsClamp = nullptr; |
1985 } | 1981 } |
1986 | 1982 |
1987 } // namespace blink | 1983 } // namespace blink |
OLD | NEW |