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

Unified Diff: third_party/WebKit/Source/core/frame/VisualViewport.cpp

Issue 2123053002: Improve scroll anchoring's interactions with the visual viewport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix broken tests Created 4 years, 5 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/frame/VisualViewport.cpp
diff --git a/third_party/WebKit/Source/core/frame/VisualViewport.cpp b/third_party/WebKit/Source/core/frame/VisualViewport.cpp
index fe5ac4494ee2ecb6dc58e36d675b0f7f4d2dad20..da1e5a8e5a4ca0824f43d43df1ca8a8ab127f02f 100644
--- a/third_party/WebKit/Source/core/frame/VisualViewport.cpp
+++ b/third_party/WebKit/Source/core/frame/VisualViewport.cpp
@@ -273,8 +273,14 @@ double VisualViewport::pageScale()
void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location)
{
+ if (didSetScaleOrLocation(scale, location))
+ clearScrollAnchor();
+}
+
+bool VisualViewport::didSetScaleOrLocation(float scale, const FloatPoint& location)
+{
if (!mainFrame())
- return;
+ return false;
bool valuesChanged = false;
@@ -307,12 +313,23 @@ void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location
}
if (!valuesChanged)
- return;
+ return false;
InspectorInstrumentation::didUpdateLayout(mainFrame());
mainFrame()->loader().saveScrollState();
clampToBoundaries();
+
+ return true;
+}
+
+void VisualViewport::clearScrollAnchor()
+{
+ if (RuntimeEnabledFeatures::scrollAnchoringEnabled()) {
+ LocalFrame* frame = mainFrame();
+ if (frame && frame->view())
+ frame->view()->clearScrollAnchor();
+ }
}
bool VisualViewport::magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoint& anchor)
@@ -631,9 +648,10 @@ IntSize VisualViewport::contentsSize() const
return frame->view()->visibleContentRect(IncludeScrollbars).size();
}
-void VisualViewport::setScrollOffset(const DoublePoint& offset, ScrollType)
+void VisualViewport::setScrollOffset(const DoublePoint& offset, ScrollType scrollType)
{
- setLocation(toFloatPoint(offset));
+ if (didSetScaleOrLocation(m_scale, toFloatPoint(offset)) && scrollType != AnchoringScroll)
+ clearScrollAnchor();
}
GraphicsLayer* VisualViewport::layerForContainer() const
« no previous file with comments | « third_party/WebKit/Source/core/frame/VisualViewport.h ('k') | third_party/WebKit/Source/core/layout/ScrollAnchor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698