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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
index 90ff56744e3faba95093776f53ca75b508b374dd..c4e56b7a84a669d3acd960c73d366fc562bb390e 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -92,6 +92,7 @@ PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer)
, m_scrollbarManager(*this)
, m_scrollCorner(nullptr)
, m_resizer(nullptr)
+ , m_scrollAnchor(this)
#if ENABLE(ASSERT)
, m_hasBeenDisposed(false)
#endif
@@ -161,6 +162,7 @@ void PaintLayerScrollableArea::dispose()
DEFINE_TRACE(PaintLayerScrollableArea)
{
visitor->trace(m_scrollbarManager);
+ visitor->trace(m_scrollAnchor);
ScrollableArea::trace(visitor);
}
@@ -328,7 +330,7 @@ void PaintLayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset,
setScrollOffset(DoublePoint(newScrollOffset), scrollType);
}
-void PaintLayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffset, ScrollType)
+void PaintLayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffset, ScrollType scrollType)
{
if (scrollOffset() == toDoubleSize(newScrollOffset))
return;
@@ -409,6 +411,10 @@ void PaintLayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffse
// All scrolls clear the fragment anchor.
frameView->clearFragmentAnchor();
+
+ // Clear the scroll anchor, unless it is the reason for this scroll.
+ 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. :)
+ scrollAnchor().clear();
}
IntPoint PaintLayerScrollableArea::scrollPosition() const
@@ -1449,6 +1455,15 @@ Widget* PaintLayerScrollableArea::widget()
return box().frame()->view();
}
+bool PaintLayerScrollableArea::scrollAnchoringEnabled() const
+{
+ 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
+ if (Settings* settings = frame->settings())
+ return settings->scrollAnchoringEnabled();
+ }
+ return false;
+}
+
PaintLayerScrollableArea::ScrollbarManager::ScrollbarManager(PaintLayerScrollableArea& scrollableArea)
: m_scrollableArea(&scrollableArea)
, m_canDetachScrollbars(0)

Powered by Google App Engine
This is Rietveld 408576698