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

Unified Diff: Source/core/frame/PinchViewport.cpp

Issue 584833003: Made double-tap zoom work in pinch virtual viewport mode. (Blink-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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: Source/core/frame/PinchViewport.cpp
diff --git a/Source/core/frame/PinchViewport.cpp b/Source/core/frame/PinchViewport.cpp
index 8cb90bdf3d23ebd7d6c687171dd226e4d2e48d8c..d8bea70e8458612fe2e1ad344e6de7978970eca0 100644
--- a/Source/core/frame/PinchViewport.cpp
+++ b/Source/core/frame/PinchViewport.cpp
@@ -170,7 +170,7 @@ void PinchViewport::move(const FloatPoint& delta)
setLocation(m_offset + delta);
}
-void PinchViewport::setScale(float scale)
+void PinchViewport::setScaleWithoutClampingViewportOffset(float scale)
{
if (scale == m_scale)
return;
@@ -185,13 +185,18 @@ void PinchViewport::setScale(float scale)
if (!m_innerViewportScrollLayer)
return;
- // Ensure we clamp so we remain within the bounds.
- setLocation(visibleRect().location());
-
// TODO: We should probably be calling scaleDidChange type functions here.
// see Page::setPageScaleFactor.
}
+void PinchViewport::setScale(float scale)
+{
+ setScaleWithoutClampingViewportOffset(scale);
+
+ // Ensure we clamp so we remain within the bounds.
+ setLocation(visibleRect().location());
+}
+
// Modifies the top of the graphics layer tree to add layers needed to support
// the inner/outer viewport fixed-position model for pinch zoom. When finished,
// the tree will look like this (with * denoting added layers):
@@ -351,6 +356,26 @@ IntPoint PinchViewport::maximumScrollPosition() const
return flooredIntPoint(FloatSize(contentsSize()) - visibleRect().size());
}
+IntPoint PinchViewport::clampDocumentOffsetAtScale(const IntPoint& offset, float scale)
+{
+ if (!mainFrame() || !mainFrame()->view())
+ return IntPoint();
+
+ FrameView* view = mainFrame()->view();
+
+ FloatSize scaledSize(m_size);
+ scaledSize.scale(1 / scale);
+
+ IntPoint pinchViewportMax = flooredIntPoint(FloatSize(contentsSize()) - scaledSize);
+ IntPoint max = view->maximumScrollPosition() + pinchViewportMax;
+ IntPoint min = view->minimumScrollPosition(); // PinchViewportMin should be (0, 0)
+
+ IntPoint clamped = offset;
+ clamped = clamped.shrunkTo(max);
+ clamped = clamped.expandedTo(min);
+ return clamped;
+}
+
IntRect PinchViewport::scrollableAreaBoundingBox() const
{
// This method should return the bounding box in the parent view's coordinate

Powered by Google App Engine
This is Rietveld 408576698