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

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

Issue 2237433004: Adds DevTools commands for forced viewport override. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove offset/scale params, rename commands, clip by backing size. Created 4 years, 4 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/InspectorEmulationAgent.cpp
diff --git a/third_party/WebKit/Source/web/InspectorEmulationAgent.cpp b/third_party/WebKit/Source/web/InspectorEmulationAgent.cpp
index 326712afcbc2f0488f9b643f30838e9d9ef96685..18f0968bfc7c2d6d62edf9a7ff85eec987f224ba 100644
--- a/third_party/WebKit/Source/web/InspectorEmulationAgent.cpp
+++ b/third_party/WebKit/Source/web/InspectorEmulationAgent.cpp
@@ -10,6 +10,7 @@
#include "core/page/Page.h"
#include "platform/geometry/DoubleRect.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebFloatPoint.h"
#include "public/platform/WebThread.h"
#include "public/platform/WebViewScheduler.h"
#include "web/DevToolsEmulator.h"
@@ -61,6 +62,29 @@ void InspectorEmulationAgent::disable(ErrorString*)
setScriptExecutionDisabled(&error, false);
setTouchEmulationEnabled(&error, false, protocol::Maybe<String>());
setEmulatedMedia(&error, String());
+ resetViewport(&error);
+}
+
+void InspectorEmulationAgent::forceViewport(ErrorString* error, double x, double y, const Maybe<double>& scale)
+{
+ if (x < 0 || y < 0) {
+ *error = "Coordinates must be non-negative";
+ return;
+ }
+
+ float appliedScale = scale.fromMaybe(1.f);
+ if (appliedScale <= 0) {
+ *error = "Scale must be positive";
+ return;
+ }
+
+ WebFloatPoint position(x, y);
+ webViewImpl()->devToolsEmulator()->forceViewport(position, appliedScale);
+}
+
+void InspectorEmulationAgent::resetViewport(ErrorString*)
+{
+ webViewImpl()->devToolsEmulator()->resetViewport();
}
void InspectorEmulationAgent::resetPageScaleFactor(ErrorString*)

Powered by Google App Engine
This is Rietveld 408576698