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@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 : m_layer(layer) | 85 : m_layer(layer) |
86 , m_inResizeMode(false) | 86 , m_inResizeMode(false) |
87 , m_scrollsOverflow(false) | 87 , m_scrollsOverflow(false) |
88 , m_inOverflowRelayout(false) | 88 , m_inOverflowRelayout(false) |
89 , m_nextTopmostScrollChild(0) | 89 , m_nextTopmostScrollChild(0) |
90 , m_topmostScrollChild(0) | 90 , m_topmostScrollChild(0) |
91 , m_needsCompositedScrolling(false) | 91 , m_needsCompositedScrolling(false) |
92 , m_scrollbarManager(*this) | 92 , m_scrollbarManager(*this) |
93 , m_scrollCorner(nullptr) | 93 , m_scrollCorner(nullptr) |
94 , m_resizer(nullptr) | 94 , m_resizer(nullptr) |
| 95 , m_scrollAnchor(this) |
95 #if ENABLE(ASSERT) | 96 #if ENABLE(ASSERT) |
96 , m_hasBeenDisposed(false) | 97 , m_hasBeenDisposed(false) |
97 #endif | 98 #endif |
98 { | 99 { |
99 Node* node = box().node(); | 100 Node* node = box().node(); |
100 if (node && node->isElementNode()) { | 101 if (node && node->isElementNode()) { |
101 // We save and restore only the scrollOffset as the other scroll values
are recalculated. | 102 // We save and restore only the scrollOffset as the other scroll values
are recalculated. |
102 Element* element = toElement(node); | 103 Element* element = toElement(node); |
103 m_scrollOffset = element->savedLayerScrollOffset(); | 104 m_scrollOffset = element->savedLayerScrollOffset(); |
104 if (!m_scrollOffset.isZero()) | 105 if (!m_scrollOffset.isZero()) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 147 |
147 m_scrollbarManager.dispose(); | 148 m_scrollbarManager.dispose(); |
148 | 149 |
149 if (m_scrollCorner) | 150 if (m_scrollCorner) |
150 m_scrollCorner->destroy(); | 151 m_scrollCorner->destroy(); |
151 if (m_resizer) | 152 if (m_resizer) |
152 m_resizer->destroy(); | 153 m_resizer->destroy(); |
153 | 154 |
154 clearScrollAnimators(); | 155 clearScrollAnimators(); |
155 | 156 |
| 157 if (RuntimeEnabledFeatures::scrollAnchoringEnabled()) |
| 158 m_scrollAnchor.clear(); |
| 159 |
156 #if ENABLE(ASSERT) | 160 #if ENABLE(ASSERT) |
157 m_hasBeenDisposed = true; | 161 m_hasBeenDisposed = true; |
158 #endif | 162 #endif |
159 } | 163 } |
160 | 164 |
161 DEFINE_TRACE(PaintLayerScrollableArea) | 165 DEFINE_TRACE(PaintLayerScrollableArea) |
162 { | 166 { |
163 visitor->trace(m_scrollbarManager); | 167 visitor->trace(m_scrollbarManager); |
| 168 visitor->trace(m_scrollAnchor); |
164 ScrollableArea::trace(visitor); | 169 ScrollableArea::trace(visitor); |
165 } | 170 } |
166 | 171 |
167 HostWindow* PaintLayerScrollableArea::hostWindow() const | 172 HostWindow* PaintLayerScrollableArea::hostWindow() const |
168 { | 173 { |
169 if (Page* page = box().frame()->page()) | 174 if (Page* page = box().frame()->page()) |
170 return &page->chromeClient(); | 175 return &page->chromeClient(); |
171 return nullptr; | 176 return nullptr; |
172 } | 177 } |
173 | 178 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 { | 325 { |
321 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; | 326 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; |
322 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); | 327 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); |
323 } | 328 } |
324 | 329 |
325 void PaintLayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset,
ScrollType scrollType) | 330 void PaintLayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset,
ScrollType scrollType) |
326 { | 331 { |
327 setScrollOffset(DoublePoint(newScrollOffset), scrollType); | 332 setScrollOffset(DoublePoint(newScrollOffset), scrollType); |
328 } | 333 } |
329 | 334 |
330 void PaintLayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffse
t, ScrollType) | 335 void PaintLayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffse
t, ScrollType scrollType) |
331 { | 336 { |
332 if (scrollOffset() == toDoubleSize(newScrollOffset)) | 337 if (scrollOffset() == toDoubleSize(newScrollOffset)) |
333 return; | 338 return; |
334 | 339 |
335 DoubleSize scrollDelta = scrollOffset() - toDoubleSize(newScrollOffset); | 340 DoubleSize scrollDelta = scrollOffset() - toDoubleSize(newScrollOffset); |
336 m_scrollOffset = toDoubleSize(newScrollOffset); | 341 m_scrollOffset = toDoubleSize(newScrollOffset); |
337 | 342 |
338 LocalFrame* frame = box().frame(); | 343 LocalFrame* frame = box().frame(); |
339 ASSERT(frame); | 344 ASSERT(frame); |
340 | 345 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 box().view()->clearHitTestCache(); | 405 box().view()->clearHitTestCache(); |
401 | 406 |
402 // Inform the FrameLoader of the new scroll position, so it can be restored
when navigating back. | 407 // Inform the FrameLoader of the new scroll position, so it can be restored
when navigating back. |
403 if (layer()->isRootLayer()) { | 408 if (layer()->isRootLayer()) { |
404 frameView->frame().loader().saveScrollState(); | 409 frameView->frame().loader().saveScrollState(); |
405 frame->loader().client()->didChangeScrollOffset(); | 410 frame->loader().client()->didChangeScrollOffset(); |
406 } | 411 } |
407 | 412 |
408 // All scrolls clear the fragment anchor. | 413 // All scrolls clear the fragment anchor. |
409 frameView->clearFragmentAnchor(); | 414 frameView->clearFragmentAnchor(); |
| 415 |
| 416 // Clear the scroll anchor, unless it is the reason for this scroll. |
| 417 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && scrollType != Anchor
ingScroll) |
| 418 scrollAnchor().clear(); |
410 } | 419 } |
411 | 420 |
412 IntPoint PaintLayerScrollableArea::scrollPosition() const | 421 IntPoint PaintLayerScrollableArea::scrollPosition() const |
413 { | 422 { |
414 return IntPoint(flooredIntSize(m_scrollOffset)); | 423 return IntPoint(flooredIntSize(m_scrollOffset)); |
415 } | 424 } |
416 | 425 |
417 DoublePoint PaintLayerScrollableArea::scrollPositionDouble() const | 426 DoublePoint PaintLayerScrollableArea::scrollPositionDouble() const |
418 { | 427 { |
419 return DoublePoint(m_scrollOffset); | 428 return DoublePoint(m_scrollOffset); |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 } | 1554 } |
1546 | 1555 |
1547 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) | 1556 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) |
1548 { | 1557 { |
1549 visitor->trace(m_scrollableArea); | 1558 visitor->trace(m_scrollableArea); |
1550 visitor->trace(m_hBar); | 1559 visitor->trace(m_hBar); |
1551 visitor->trace(m_vBar); | 1560 visitor->trace(m_vBar); |
1552 } | 1561 } |
1553 | 1562 |
1554 } // namespace blink | 1563 } // namespace blink |
OLD | NEW |