Index: third_party/WebKit/Source/web/WebViewImpl.cpp |
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp |
index 7f9d5c550cfe56d0f26f919d9bc120bda193ac41..122a2f36b3ddf7b46cb3ad6e2fd35b77b0ef761c 100644 |
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp |
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp |
@@ -56,6 +56,7 @@ |
#include "core/frame/LocalFrame.h" |
#include "core/frame/PageScaleConstraintsSet.h" |
#include "core/frame/RemoteFrame.h" |
+#include "core/frame/ScrollAndScaleEmulator.h" |
#include "core/frame/Settings.h" |
#include "core/frame/SmartClip.h" |
#include "core/frame/TopControls.h" |
@@ -3207,6 +3208,57 @@ WebFloatSize WebViewImpl::visualViewportSize() const |
return page()->frameHost().visualViewport().visibleRect().size(); |
} |
+void WebViewImpl::setScrollAndScaleOverride(const WebDeviceEmulationParams& params) |
+{ |
+ if (!page()) |
+ return; |
+ |
+ if (!mainFrameImpl()) |
+ return; |
+ |
+ FrameView * view = mainFrameImpl()->frameView(); |
+ if (!view) |
+ return; |
+ |
+ if (!m_scrollAndScaleEmulator) { |
+ m_scrollAndScaleEmulator = ScrollAndScaleEmulator::create(); |
+ } |
+ |
+ bool hasChanged = m_scrollAndScaleEmulator->update( |
+ static_cast<IntPoint>(params.scrollPosition), |
+ static_cast<FloatPoint>(params.visualViewportPosition), |
+ params.visualViewportScale); |
+ if (hasChanged) { |
+ view->setScrollAndScaleEmulator(m_scrollAndScaleEmulator); |
+ page()->frameHost().visualViewport().setScrollAndScaleEmulator(m_scrollAndScaleEmulator); |
+ page()->frameHost().setUserAgentPageScaleConstraints( |
+ m_scrollAndScaleEmulator->pageScaleConstraints()); |
+ } |
bokan
2016/06/29 15:15:49
My recommendation for the mainFrameSize issue woul
|
+} |
+ |
+void WebViewImpl::clearScrollAndScaleOverride() |
+{ |
+ if (!m_scrollAndScaleEmulator) |
+ return; |
+ |
+ if (!page()) |
+ return; |
+ |
+ if (!mainFrameImpl()) |
+ return; |
+ |
+ FrameView * view = mainFrameImpl()->frameView(); |
+ if (!view) |
+ return; |
+ |
+ m_scrollAndScaleEmulator.clear(); |
+ view->setScrollAndScaleEmulator(m_scrollAndScaleEmulator); |
+ page()->frameHost().visualViewport().setScrollAndScaleEmulator(m_scrollAndScaleEmulator); |
+ page()->frameHost().setUserAgentPageScaleConstraints(PageScaleConstraints()); |
+ |
+ resetScrollAndScaleState(); |
+} |
+ |
void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, |
const IntPoint& mainFrameOrigin, |
const FloatPoint& visualViewportOrigin) |
@@ -3832,10 +3884,12 @@ void WebViewImpl::setRootLayerTransform(const WebSize& rootLayerOffset, float ro |
void WebViewImpl::enableDeviceEmulation(const WebDeviceEmulationParams& params) |
{ |
m_devToolsEmulator->enableDeviceEmulation(params); |
+ setScrollAndScaleOverride(params); |
} |
void WebViewImpl::disableDeviceEmulation() |
{ |
+ clearScrollAndScaleOverride(); |
m_devToolsEmulator->disableDeviceEmulation(); |
} |