Index: third_party/WebKit/Source/core/frame/FrameView.cpp |
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp |
index 98fbad2cfa1d92d0135b8f87a218ea762d250839..be15e2992e63bdd3eafcd0a687096da44f4a096a 100644 |
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp |
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp |
@@ -153,6 +153,7 @@ FrameView::FrameView(LocalFrame* frame) |
, m_hiddenForThrottling(false) |
, m_crossOriginForThrottling(false) |
, m_isUpdatingAllLifecyclePhases(false) |
+ , m_scrollAnchor(this) |
{ |
ASSERT(m_frame); |
init(); |
@@ -197,6 +198,7 @@ DEFINE_TRACE(FrameView) |
visitor->trace(m_verticalScrollbar); |
visitor->trace(m_children); |
visitor->trace(m_viewportScrollableArea); |
+ visitor->trace(m_scrollAnchor); |
#endif |
Widget::trace(visitor); |
ScrollableArea::trace(visitor); |
@@ -270,6 +272,9 @@ void FrameView::dispose() |
scrollAnimator->cancelAnimation(); |
cancelProgrammaticScrollAnimation(); |
+ if (RuntimeEnabledFeatures::scrollAnchoringEnabled()) |
+ m_scrollAnchor.clear(); |
+ |
detachScrollbars(); |
// When the view is no longer associated with a frame, it needs to be removed from the ax object cache |
@@ -795,6 +800,9 @@ void FrameView::performPreLayoutTasks() |
ASSERT(layoutViewport); |
m_viewportScrollableArea = RootFrameViewport::create(visualViewport, *layoutViewport); |
} |
+ |
+ if (RuntimeEnabledFeatures::scrollAnchoringEnabled()) |
+ m_scrollAnchor.save(); |
} |
static inline void layoutFromRootObject(LayoutObject& root) |
@@ -1534,6 +1542,9 @@ void FrameView::setScrollPosition(const DoublePoint& scrollPoint, ScrollType scr |
scrollBehavior = scrollBehaviorStyle(); |
ScrollableArea::setScrollPosition(newScrollPosition, scrollType, scrollBehavior); |
+ |
+ if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && scrollType != AnchoringScroll) |
+ m_scrollAnchor.clear(); |
} |
void FrameView::didUpdateElasticOverscroll() |
@@ -2045,6 +2056,9 @@ void FrameView::performPostLayoutTasks() |
scrollingCoordinator->notifyGeometryChanged(); |
scrollToFragmentAnchor(); |
+ // TODO(skobes): Figure out interactions between scroll anchor, fragment anchor, and history restoration. |
+ if (RuntimeEnabledFeatures::scrollAnchoringEnabled()) |
+ m_scrollAnchor.restore(); |
sendResizeEventIfNeeded(); |
} |