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

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

Issue 1647793002: Use ScrollAnchor in FrameView and PaintLayerScrollableArea. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@anchor-skeleton
Patch Set: Created 4 years, 10 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 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
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 clearScrollAnimators(); 155 clearScrollAnimators();
155 156
156 #if ENABLE(ASSERT) 157 #if ENABLE(ASSERT)
157 m_hasBeenDisposed = true; 158 m_hasBeenDisposed = true;
158 #endif 159 #endif
159 } 160 }
160 161
161 DEFINE_TRACE(PaintLayerScrollableArea) 162 DEFINE_TRACE(PaintLayerScrollableArea)
162 { 163 {
163 visitor->trace(m_scrollbarManager); 164 visitor->trace(m_scrollbarManager);
165 visitor->trace(m_scrollAnchor);
164 ScrollableArea::trace(visitor); 166 ScrollableArea::trace(visitor);
165 } 167 }
166 168
167 HostWindow* PaintLayerScrollableArea::hostWindow() const 169 HostWindow* PaintLayerScrollableArea::hostWindow() const
168 { 170 {
169 if (Page* page = box().frame()->page()) 171 if (Page* page = box().frame()->page())
170 return &page->chromeClient(); 172 return &page->chromeClient();
171 return nullptr; 173 return nullptr;
172 } 174 }
173 175
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 { 323 {
322 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition() ; 324 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition() ;
323 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height(); 325 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height();
324 } 326 }
325 327
326 void PaintLayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset, ScrollType scrollType) 328 void PaintLayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset, ScrollType scrollType)
327 { 329 {
328 setScrollOffset(DoublePoint(newScrollOffset), scrollType); 330 setScrollOffset(DoublePoint(newScrollOffset), scrollType);
329 } 331 }
330 332
331 void PaintLayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffse t, ScrollType) 333 void PaintLayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffse t, ScrollType scrollType)
332 { 334 {
333 if (scrollOffset() == toDoubleSize(newScrollOffset)) 335 if (scrollOffset() == toDoubleSize(newScrollOffset))
334 return; 336 return;
335 337
336 DoubleSize scrollDelta = scrollOffset() - toDoubleSize(newScrollOffset); 338 DoubleSize scrollDelta = scrollOffset() - toDoubleSize(newScrollOffset);
337 m_scrollOffset = toDoubleSize(newScrollOffset); 339 m_scrollOffset = toDoubleSize(newScrollOffset);
338 340
339 LocalFrame* frame = box().frame(); 341 LocalFrame* frame = box().frame();
340 ASSERT(frame); 342 ASSERT(frame);
341 343
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 box().view()->clearHitTestCache(); 404 box().view()->clearHitTestCache();
403 405
404 // Inform the FrameLoader of the new scroll position, so it can be restored when navigating back. 406 // Inform the FrameLoader of the new scroll position, so it can be restored when navigating back.
405 if (layer()->isRootLayer()) { 407 if (layer()->isRootLayer()) {
406 frameView->frame().loader().saveScrollState(); 408 frameView->frame().loader().saveScrollState();
407 frame->loader().client()->didChangeScrollOffset(); 409 frame->loader().client()->didChangeScrollOffset();
408 } 410 }
409 411
410 // All scrolls clear the fragment anchor. 412 // All scrolls clear the fragment anchor.
411 frameView->clearFragmentAnchor(); 413 frameView->clearFragmentAnchor();
414
415 // Clear the scroll anchor, unless it is the reason for this scroll.
416 if (scrollAnchoringEnabled() && scrollType != AnchoringScroll)
ojan 2016/02/02 06:51:01 It's a bummer we need to copy-paste this. Maybe pu
skobes 2016/02/02 22:39:11 Yes, this is why we want root layer scrolling. :)
417 scrollAnchor().clear();
412 } 418 }
413 419
414 IntPoint PaintLayerScrollableArea::scrollPosition() const 420 IntPoint PaintLayerScrollableArea::scrollPosition() const
415 { 421 {
416 return IntPoint(flooredIntSize(m_scrollOffset)); 422 return IntPoint(flooredIntSize(m_scrollOffset));
417 } 423 }
418 424
419 DoublePoint PaintLayerScrollableArea::scrollPositionDouble() const 425 DoublePoint PaintLayerScrollableArea::scrollPositionDouble() const
420 { 426 {
421 return DoublePoint(m_scrollOffset); 427 return DoublePoint(m_scrollOffset);
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 return false; 1448 return false;
1443 1449
1444 return frame->settings()->viewportMetaEnabled(); 1450 return frame->settings()->viewportMetaEnabled();
1445 } 1451 }
1446 1452
1447 Widget* PaintLayerScrollableArea::widget() 1453 Widget* PaintLayerScrollableArea::widget()
1448 { 1454 {
1449 return box().frame()->view(); 1455 return box().frame()->view();
1450 } 1456 }
1451 1457
1458 bool PaintLayerScrollableArea::scrollAnchoringEnabled() const
1459 {
1460 if (Frame* frame = box().frame()) {
ojan 2016/02/02 06:51:01 Nit: If you add a scrollAnchoringEnabled method to
skobes 2016/02/02 22:39:11 Hmm, this doesn't save us very much, and it increa
1461 if (Settings* settings = frame->settings())
1462 return settings->scrollAnchoringEnabled();
1463 }
1464 return false;
1465 }
1466
1452 PaintLayerScrollableArea::ScrollbarManager::ScrollbarManager(PaintLayerScrollabl eArea& scrollableArea) 1467 PaintLayerScrollableArea::ScrollbarManager::ScrollbarManager(PaintLayerScrollabl eArea& scrollableArea)
1453 : m_scrollableArea(&scrollableArea) 1468 : m_scrollableArea(&scrollableArea)
1454 , m_canDetachScrollbars(0) 1469 , m_canDetachScrollbars(0)
1455 , m_hBarIsAttached(0) 1470 , m_hBarIsAttached(0)
1456 , m_vBarIsAttached(0) 1471 , m_vBarIsAttached(0)
1457 { 1472 {
1458 } 1473 }
1459 1474
1460 void PaintLayerScrollableArea::ScrollbarManager::dispose() 1475 void PaintLayerScrollableArea::ScrollbarManager::dispose()
1461 { 1476 {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 } 1562 }
1548 1563
1549 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) 1564 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager)
1550 { 1565 {
1551 visitor->trace(m_scrollableArea); 1566 visitor->trace(m_scrollableArea);
1552 visitor->trace(m_hBar); 1567 visitor->trace(m_hBar);
1553 visitor->trace(m_vBar); 1568 visitor->trace(m_vBar);
1554 } 1569 }
1555 1570
1556 } // namespace blink 1571 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698