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

Side by Side 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: sync. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "web/InspectorEmulationAgent.h" 5 #include "web/InspectorEmulationAgent.h"
6 6
7 #include "core/frame/FrameHost.h" 7 #include "core/frame/FrameHost.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/page/Page.h" 10 #include "core/page/Page.h"
11 #include "platform/geometry/DoubleRect.h" 11 #include "platform/geometry/DoubleRect.h"
12 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
13 #include "public/platform/WebFloatPoint.h"
13 #include "public/platform/WebThread.h" 14 #include "public/platform/WebThread.h"
14 #include "public/platform/WebViewScheduler.h" 15 #include "public/platform/WebViewScheduler.h"
15 #include "web/DevToolsEmulator.h" 16 #include "web/DevToolsEmulator.h"
16 #include "web/WebLocalFrameImpl.h" 17 #include "web/WebLocalFrameImpl.h"
17 #include "web/WebViewImpl.h" 18 #include "web/WebViewImpl.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 namespace EmulationAgentState { 22 namespace EmulationAgentState {
22 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled"; 23 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled";
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 m_state->getString(EmulationAgentState::emulatedMedia, &emulatedMedia); 55 m_state->getString(EmulationAgentState::emulatedMedia, &emulatedMedia);
55 setEmulatedMedia(&error, emulatedMedia); 56 setEmulatedMedia(&error, emulatedMedia);
56 } 57 }
57 58
58 void InspectorEmulationAgent::disable(ErrorString*) 59 void InspectorEmulationAgent::disable(ErrorString*)
59 { 60 {
60 ErrorString error; 61 ErrorString error;
61 setScriptExecutionDisabled(&error, false); 62 setScriptExecutionDisabled(&error, false);
62 setTouchEmulationEnabled(&error, false, protocol::Maybe<String>()); 63 setTouchEmulationEnabled(&error, false, protocol::Maybe<String>());
63 setEmulatedMedia(&error, String()); 64 setEmulatedMedia(&error, String());
65 resetViewport(&error);
66 }
67
68 void InspectorEmulationAgent::forceViewport(ErrorString* error, double x, double y, const Maybe<double>& scale)
69 {
70 if (x < 0 || y < 0) {
71 *error = "Coordinates must be non-negative";
72 return;
73 }
74
75 float appliedScale = scale.fromMaybe(1.f);
76 if (appliedScale <= 0) {
77 *error = "Scale must be positive";
78 return;
79 }
80
81 WebFloatPoint position(x, y);
82 webViewImpl()->devToolsEmulator()->forceViewport(position, appliedScale);
dgozman 2016/08/29 20:45:36 We should store the values in |m_state| and restor
Eric Seckler 2016/09/12 13:58:00 Done.
83 }
84
85 void InspectorEmulationAgent::resetViewport(ErrorString*)
86 {
87 webViewImpl()->devToolsEmulator()->resetViewport();
64 } 88 }
65 89
66 void InspectorEmulationAgent::resetPageScaleFactor(ErrorString*) 90 void InspectorEmulationAgent::resetPageScaleFactor(ErrorString*)
67 { 91 {
68 webViewImpl()->resetScaleStateImmediately(); 92 webViewImpl()->resetScaleStateImmediately();
69 } 93 }
70 94
71 void InspectorEmulationAgent::setPageScaleFactor(ErrorString*, double pageScaleF actor) 95 void InspectorEmulationAgent::setPageScaleFactor(ErrorString*, double pageScaleF actor)
72 { 96 {
73 webViewImpl()->setPageScaleFactor(static_cast<float>(pageScaleFactor)); 97 webViewImpl()->setPageScaleFactor(static_cast<float>(pageScaleFactor));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 frontend()->virtualTimeBudgetExpired(); 144 frontend()->virtualTimeBudgetExpired();
121 } 145 }
122 146
123 DEFINE_TRACE(InspectorEmulationAgent) 147 DEFINE_TRACE(InspectorEmulationAgent)
124 { 148 {
125 visitor->trace(m_webLocalFrameImpl); 149 visitor->trace(m_webLocalFrameImpl);
126 InspectorBaseAgent::trace(visitor); 150 InspectorBaseAgent::trace(visitor);
127 } 151 }
128 152
129 } // namespace blink 153 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698