summaryrefslogtreecommitdiffstats
path: root/content/renderer/devtools
diff options
context:
space:
mode:
authordgozman@chromium.org <dgozman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-03 02:07:51 +0000
committerdgozman@chromium.org <dgozman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-03 02:07:51 +0000
commitb2e4c70138559bbadb9db0cb2279d7b6254dcb03 (patch)
tree7c137331605e497c352b5c86c37f5c2c76cf3cae /content/renderer/devtools
parent53d8e09c7b068dfb6a870241dc8eafdb82c5e31c (diff)
downloadchromium_src-b2e4c70138559bbadb9db0cb2279d7b6254dcb03.zip
chromium_src-b2e4c70138559bbadb9db0cb2279d7b6254dcb03.tar.gz
chromium_src-b2e4c70138559bbadb9db0cb2279d7b6254dcb03.tar.bz2
Implementation of device metrics emulation in render view.
This is used by DevTools to emulate various devices on desktop browser. Emulation includes changing view size, view/window screen positions and device scale factor. Also, the whole view is scaled down if required to fit the browser window. To achieve this, render widget creates an emulator, which handles metrics override by intercepting size/position-related messages. Scaling down is done by setting transform on the root composited layer on the blink side. This emulation is transparent to browser side. Depends on Blink-side patch: https://codereview.chromium.org/23187005/ BUG=288959 Review URL: https://codereview.chromium.org/23364004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226663 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/devtools')
-rw-r--r--content/renderer/devtools/devtools_agent.cc17
-rw-r--r--content/renderer/devtools/devtools_agent.h5
2 files changed, 22 insertions, 0 deletions
diff --git a/content/renderer/devtools/devtools_agent.cc b/content/renderer/devtools/devtools_agent.cc
index 635acc1..cb9aeba 100644
--- a/content/renderer/devtools/devtools_agent.cc
+++ b/content/renderer/devtools/devtools_agent.cc
@@ -22,6 +22,7 @@
#include "third_party/WebKit/public/web/WebConsoleMessage.h"
#include "third_party/WebKit/public/web/WebDevToolsAgent.h"
#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebSettings.h"
#include "third_party/WebKit/public/web/WebView.h"
#if defined(USE_TCMALLOC)
@@ -144,6 +145,22 @@ void DevToolsAgent::setTraceEventCallback(TraceEventCallback cb) {
}
}
+void DevToolsAgent::enableDeviceEmulation(
+ const WebKit::WebSize& device_size,
+ const WebKit::WebRect& view_rect,
+ float device_scale_factor,
+ bool fit_to_view) {
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
+ impl->webview()->settings()->setForceCompositingMode(true);
+ impl->EnableScreenMetricsEmulation(gfx::Size(device_size),
+ gfx::Rect(view_rect), device_scale_factor, fit_to_view);
+}
+
+void DevToolsAgent::disableDeviceEmulation() {
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
+ impl->DisableScreenMetricsEmulation();
+}
+
#if defined(USE_TCMALLOC) && !defined(OS_WIN)
static void AllocationVisitor(void* data, const void* ptr) {
typedef WebKit::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor;
diff --git a/content/renderer/devtools/devtools_agent.h b/content/renderer/devtools/devtools_agent.h
index 4ac22db..9860ed7 100644
--- a/content/renderer/devtools/devtools_agent.h
+++ b/content/renderer/devtools/devtools_agent.h
@@ -53,6 +53,11 @@ class DevToolsAgent : public RenderViewObserver,
virtual void clearBrowserCookies();
virtual void visitAllocatedObjects(AllocatedObjectVisitor* visitor);
virtual void setTraceEventCallback(TraceEventCallback cb);
+ virtual void enableDeviceEmulation(
+ const WebKit::WebSize& device_size,
+ const WebKit::WebRect& view_rect, float device_scale_factor,
+ bool fit_to_view);
+ virtual void disableDeviceEmulation();
void OnAttach();
void OnReattach(const std::string& agent_state);