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

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: 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..e093273f0e2df60fae0955b76907522927353892 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/WebFloatRect.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());
+ clearCompositedAreaOverride(&error);
+}
+
+void InspectorEmulationAgent::setCompositedAreaOverride(ErrorString* error, double x, double y, double width, double height, const Maybe<double>& scale)
+{
+ if (x < 0 || y < 0 || width < 0 || height < 0) {
+ *error = "Coordinates must be non-negative";
+ return;
+ }
+
+ float appliedScale = scale.fromMaybe(1.f);
+ if (appliedScale <= 0) {
+ *error = "Scale must be positive";
+ return;
+ }
+
+ WebFloatRect area(x, y, width, height);
+ webViewImpl()->devToolsEmulator()->setCompositedAreaOverride(area, appliedScale);
+}
+
+void InspectorEmulationAgent::clearCompositedAreaOverride(ErrorString*)
+{
+ webViewImpl()->devToolsEmulator()->clearCompositedAreaOverride();
}
void InspectorEmulationAgent::resetPageScaleFactor(ErrorString*)

Powered by Google App Engine
This is Rietveld 408576698