OLD | NEW |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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().setCurrentPosition( |
119 FloatPoint(m_scrollOffset.width(), m_scrollOffset.height())); | 119 FloatPoint(m_scrollOffset.width(), m_scrollOffset.height())); |
120 } | |
121 element->setSavedLayerScrollOffset(IntSize()); | 120 element->setSavedLayerScrollOffset(IntSize()); |
122 } | 121 } |
123 updateResizerAreaSet(); | 122 updateResizerAreaSet(); |
124 } | 123 } |
125 | 124 |
126 PaintLayerScrollableArea::~PaintLayerScrollableArea() { | 125 PaintLayerScrollableArea::~PaintLayerScrollableArea() { |
127 ASSERT(m_hasBeenDisposed); | 126 ASSERT(m_hasBeenDisposed); |
128 } | 127 } |
129 | 128 |
130 void PaintLayerScrollableArea::dispose() { | 129 void PaintLayerScrollableArea::dispose() { |
(...skipping 11 matching lines...) Expand all Loading... |
142 | 141 |
143 if (box().frame() && box().frame()->page()) { | 142 if (box().frame() && box().frame()->page()) { |
144 if (ScrollingCoordinator* scrollingCoordinator = | 143 if (ScrollingCoordinator* scrollingCoordinator = |
145 box().frame()->page()->scrollingCoordinator()) | 144 box().frame()->page()->scrollingCoordinator()) |
146 scrollingCoordinator->willDestroyScrollableArea(this); | 145 scrollingCoordinator->willDestroyScrollableArea(this); |
147 } | 146 } |
148 | 147 |
149 if (!box().documentBeingDestroyed()) { | 148 if (!box().documentBeingDestroyed()) { |
150 Node* node = box().node(); | 149 Node* node = box().node(); |
151 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283. | 150 // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283. |
152 if (node && node->isElementNode()) { | 151 if (node && node->isElementNode()) |
153 toElement(node)->setSavedLayerScrollOffset( | 152 toElement(node)->setSavedLayerScrollOffset( |
154 flooredIntSize(m_scrollOffset)); | 153 flooredIntSize(m_scrollOffset)); |
155 } | |
156 } | 154 } |
157 | 155 |
158 if (LocalFrame* frame = box().frame()) { | 156 if (LocalFrame* frame = box().frame()) { |
159 if (FrameView* frameView = frame->view()) | 157 if (FrameView* frameView = frame->view()) |
160 frameView->removeResizerArea(box()); | 158 frameView->removeResizerArea(box()); |
161 } | 159 } |
162 | 160 |
163 if (RootScrollerController* controller = | 161 if (RootScrollerController* controller = |
164 box().document().rootScrollerController()) | 162 box().document().rootScrollerController()) |
165 controller->didDisposePaintLayerScrollableArea(*this); | 163 controller->didDisposePaintLayerScrollableArea(*this); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 verticalScrollbarWidth = | 491 verticalScrollbarWidth = |
494 (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) | 492 (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) |
495 ? verticalScrollbar()->scrollbarThickness() | 493 ? verticalScrollbar()->scrollbarThickness() |
496 : 0; | 494 : 0; |
497 horizontalScrollbarHeight = | 495 horizontalScrollbarHeight = |
498 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) | 496 (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) |
499 ? horizontalScrollbar()->scrollbarThickness() | 497 ? horizontalScrollbar()->scrollbarThickness() |
500 : 0; | 498 : 0; |
501 } | 499 } |
502 | 500 |
503 // TODO(szager): Handle fractional scroll offsets correctly. | |
504 return IntRect( | 501 return IntRect( |
505 IntPoint(flooredIntSize(adjustedScrollOffset())), | 502 IntPoint(scrollXOffset(), scrollYOffset()), |
506 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), | 503 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), |
507 max(0, layer()->size().height() - horizontalScrollbarHeight))); | 504 max(0, layer()->size().height() - horizontalScrollbarHeight))); |
508 } | 505 } |
509 | 506 |
510 int PaintLayerScrollableArea::visibleHeight() const { | 507 int PaintLayerScrollableArea::visibleHeight() const { |
511 return layer()->size().height(); | 508 return layer()->size().height(); |
512 } | 509 } |
513 | 510 |
514 int PaintLayerScrollableArea::visibleWidth() const { | 511 int PaintLayerScrollableArea::visibleWidth() const { |
515 return layer()->size().width(); | 512 return layer()->size().width(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + | 628 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + |
632 box().originAdjustmentForScrollbars()); | 629 box().originAdjustmentForScrollbars()); |
633 } | 630 } |
634 | 631 |
635 void PaintLayerScrollableArea::updateScrollDimensions() { | 632 void PaintLayerScrollableArea::updateScrollDimensions() { |
636 m_overflowRect = box().layoutOverflowRect(); | 633 m_overflowRect = box().layoutOverflowRect(); |
637 box().flipForWritingMode(m_overflowRect); | 634 box().flipForWritingMode(m_overflowRect); |
638 updateScrollOrigin(); | 635 updateScrollOrigin(); |
639 } | 636 } |
640 | 637 |
641 void PaintLayerScrollableArea::setScrollPositionUnconditionally( | 638 void PaintLayerScrollableArea::scrollToPosition( |
642 const DoublePoint& position, | 639 const DoublePoint& scrollPosition, |
| 640 ScrollOffsetClamping clamp, |
| 641 ScrollBehavior scrollBehavior, |
643 ScrollType scrollType) { | 642 ScrollType scrollType) { |
644 cancelScrollAnimation(); | 643 DoublePoint newScrollPosition = clamp == ScrollOffsetClamped |
645 scrollPositionChanged(position, scrollType); | 644 ? clampScrollPosition(scrollPosition) |
| 645 : scrollPosition; |
| 646 if (newScrollPosition != scrollPositionDouble()) |
| 647 ScrollableArea::setScrollPosition(newScrollPosition, scrollType, |
| 648 scrollBehavior); |
646 } | 649 } |
647 | 650 |
648 void PaintLayerScrollableArea::updateAfterLayout() { | 651 void PaintLayerScrollableArea::updateAfterLayout() { |
649 ASSERT(box().hasOverflowClip()); | 652 ASSERT(box().hasOverflowClip()); |
650 | 653 |
651 bool relayoutIsPrevented = PreventRelayoutScope::relayoutIsPrevented(); | 654 bool relayoutIsPrevented = PreventRelayoutScope::relayoutIsPrevented(); |
652 bool scrollbarsAreFrozen = | 655 bool scrollbarsAreFrozen = |
653 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen(); | 656 m_inOverflowRelayout || FreezeScrollbarsScope::scrollbarsAreFrozen(); |
654 | 657 |
655 if (needsScrollbarReconstruction()) { | 658 if (needsScrollbarReconstruction()) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 | 799 |
797 if (DelayScrollPositionClampScope::clampingIsDelayed()) { | 800 if (DelayScrollPositionClampScope::clampingIsDelayed()) { |
798 DelayScrollPositionClampScope::setNeedsClamp(this); | 801 DelayScrollPositionClampScope::setNeedsClamp(this); |
799 return; | 802 return; |
800 } | 803 } |
801 | 804 |
802 // Restore before clamping because clamping clears the scroll anchor. | 805 // Restore before clamping because clamping clears the scroll anchor. |
803 if (shouldPerformScrollAnchoring()) | 806 if (shouldPerformScrollAnchoring()) |
804 m_scrollAnchor.restore(); | 807 m_scrollAnchor.restore(); |
805 | 808 |
806 if (scrollOriginChanged()) { | 809 DoublePoint clamped = clampScrollPosition(scrollPositionDouble()); |
807 setScrollPositionUnconditionally( | 810 if (clamped != scrollPositionDouble() || scrollOriginChanged()) |
808 clampScrollPosition(scrollPositionDouble())); | 811 ScrollableArea::setScrollPosition(clamped, ProgrammaticScroll); |
809 } else { | |
810 ScrollableArea::setScrollPosition(scrollPositionDouble(), | |
811 ProgrammaticScroll); | |
812 } | |
813 | 812 |
814 setNeedsScrollPositionClamp(false); | 813 setNeedsScrollPositionClamp(false); |
815 resetScrollOriginChanged(); | 814 resetScrollOriginChanged(); |
816 m_scrollbarManager.destroyDetachedScrollbars(); | 815 m_scrollbarManager.destroyDetachedScrollbars(); |
817 } | 816 } |
818 | 817 |
819 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { | 818 bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { |
820 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 819 return RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
821 m_scrollAnchor.hasScroller() && | 820 m_scrollAnchor.hasScroller() && |
822 layoutBox()->style()->overflowAnchor() != AnchorNone; | 821 layoutBox()->style()->overflowAnchor() != AnchorNone; |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) | 1556 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) |
1558 .boundingBox()); | 1557 .boundingBox()); |
1559 localExposeRect.move(-box().borderLeft(), -box().borderTop()); | 1558 localExposeRect.move(-box().borderLeft(), -box().borderTop()); |
1560 LayoutRect layerBounds(LayoutPoint(), | 1559 LayoutRect layerBounds(LayoutPoint(), |
1561 LayoutSize(box().clientWidth(), box().clientHeight())); | 1560 LayoutSize(box().clientWidth(), box().clientHeight())); |
1562 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, | 1561 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, |
1563 alignX, alignY); | 1562 alignX, alignY); |
1564 | 1563 |
1565 DoublePoint clampedScrollPosition = clampScrollPosition( | 1564 DoublePoint clampedScrollPosition = clampScrollPosition( |
1566 scrollPositionDouble() + roundedIntSize(r.location())); | 1565 scrollPositionDouble() + roundedIntSize(r.location())); |
1567 if (clampedScrollPosition == scrollPositionDouble()) { | 1566 if (clampedScrollPosition == scrollPositionDouble()) |
1568 return LayoutRect( | 1567 return LayoutRect( |
1569 box() | 1568 box() |
1570 .localToAbsoluteQuad(FloatQuad(FloatRect(intersection( | 1569 .localToAbsoluteQuad(FloatQuad(FloatRect(intersection( |
1571 layerBounds, localExposeRect))), | 1570 layerBounds, localExposeRect))), |
1572 UseTransforms) | 1571 UseTransforms) |
1573 .boundingBox()); | 1572 .boundingBox()); |
1574 } | |
1575 | 1573 |
1576 DoubleSize oldScrollOffset = adjustedScrollOffset(); | 1574 DoubleSize oldScrollOffset = adjustedScrollOffset(); |
1577 setScrollPosition(clampedScrollPosition, scrollType, ScrollBehaviorInstant); | 1575 scrollToPosition(clampedScrollPosition, ScrollOffsetUnclamped, |
| 1576 ScrollBehaviorInstant, scrollType); |
1578 DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset; | 1577 DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset; |
1579 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); | 1578 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); |
1580 return LayoutRect( | 1579 return LayoutRect( |
1581 box() | 1580 box() |
1582 .localToAbsoluteQuad( | 1581 .localToAbsoluteQuad( |
1583 FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))), | 1582 FloatQuad(FloatRect(intersection(layerBounds, localExposeRect))), |
1584 UseTransforms) | 1583 UseTransforms) |
1585 .boundingBox()); | 1584 .boundingBox()); |
1586 } | 1585 } |
1587 | 1586 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 | 1952 |
1954 void PaintLayerScrollableArea::DelayScrollPositionClampScope:: | 1953 void PaintLayerScrollableArea::DelayScrollPositionClampScope:: |
1955 clampScrollableAreas() { | 1954 clampScrollableAreas() { |
1956 for (auto& scrollableArea : *s_needsClamp) | 1955 for (auto& scrollableArea : *s_needsClamp) |
1957 scrollableArea->clampScrollPositionsAfterLayout(); | 1956 scrollableArea->clampScrollPositionsAfterLayout(); |
1958 delete s_needsClamp; | 1957 delete s_needsClamp; |
1959 s_needsClamp = nullptr; | 1958 s_needsClamp = nullptr; |
1960 } | 1959 } |
1961 | 1960 |
1962 } // namespace blink | 1961 } // namespace blink |
OLD | NEW |