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

Unified Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2096633002: Adds scroll position/scale emulation to DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing file, fix forbidden include. Created 4 years, 6 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/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();
}
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebDeviceEmulationParams.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698