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

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

Issue 678153003: Use layout units in PinchViewport::scrollIntoView. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/web/tests/PinchViewportTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/PinchViewport.cpp
diff --git a/Source/core/frame/PinchViewport.cpp b/Source/core/frame/PinchViewport.cpp
index 8102f25eb384fc8b0b14e989d6dc0778ff4385b3..30d86e8871a7e4a60513600ee62c95ac916ea54d 100644
--- a/Source/core/frame/PinchViewport.cpp
+++ b/Source/core/frame/PinchViewport.cpp
@@ -133,19 +133,22 @@ FloatRect PinchViewport::visibleRectInDocument() const
return pinchRect;
}
-void PinchViewport::scrollIntoView(const FloatRect& rect)
+void PinchViewport::scrollIntoView(const LayoutRect& rect)
{
if (!mainFrame() || !mainFrame()->view())
return;
FrameView* view = mainFrame()->view();
- float centeringOffsetX = (visibleRect().width() - rect.width()) / 2;
- float centeringOffsetY = (visibleRect().height() - rect.height()) / 2;
+ // Snap the visible rect to layout units to match the input rect.
+ FloatRect visible = LayoutRect(visibleRect());
+
+ float centeringOffsetX = (visible.width() - rect.width()) / 2;
+ float centeringOffsetY = (visible.height() - rect.height()) / 2;
DoublePoint targetOffset(
- rect.x() - centeringOffsetX - visibleRect().x(),
- rect.y() - centeringOffsetY - visibleRect().y());
+ rect.x() - centeringOffsetX - visible.x(),
+ rect.y() - centeringOffsetY - visible.y());
view->setScrollPosition(targetOffset);
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/web/tests/PinchViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698