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

Side by Side Diff: third_party/WebKit/Source/web/InspectorEmulationAgent.cpp

Issue 2877363002: Move more classes over to use WebLocalFrameBase instead of WebLocalFrameImpl. (Closed)
Patch Set: Created 3 years, 7 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/exported/WebViewBase.h" 7 #include "core/exported/WebViewBase.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/frame/WebLocalFrameBase.h"
10 #include "core/inspector/protocol/DOM.h" 11 #include "core/inspector/protocol/DOM.h"
11 #include "core/page/Page.h" 12 #include "core/page/Page.h"
12 #include "platform/geometry/DoubleRect.h" 13 #include "platform/geometry/DoubleRect.h"
13 #include "platform/graphics/Color.h" 14 #include "platform/graphics/Color.h"
14 #include "platform/scheduler/renderer/web_view_scheduler.h" 15 #include "platform/scheduler/renderer/web_view_scheduler.h"
15 #include "public/platform/Platform.h" 16 #include "public/platform/Platform.h"
16 #include "public/platform/WebFloatPoint.h" 17 #include "public/platform/WebFloatPoint.h"
17 #include "public/platform/WebThread.h" 18 #include "public/platform/WebThread.h"
18 #include "web/DevToolsEmulator.h" 19 #include "web/DevToolsEmulator.h"
19 #include "web/WebLocalFrameImpl.h"
20 20
21 namespace blink { 21 namespace blink {
22 22
23 using protocol::Maybe; 23 using protocol::Maybe;
24 using protocol::Response; 24 using protocol::Response;
25 25
26 namespace EmulationAgentState { 26 namespace EmulationAgentState {
27 static const char kScriptExecutionDisabled[] = "scriptExecutionDisabled"; 27 static const char kScriptExecutionDisabled[] = "scriptExecutionDisabled";
28 static const char kTouchEventEmulationEnabled[] = "touchEventEmulationEnabled"; 28 static const char kTouchEventEmulationEnabled[] = "touchEventEmulationEnabled";
29 static const char kEmulatedMedia[] = "emulatedMedia"; 29 static const char kEmulatedMedia[] = "emulatedMedia";
30 static const char kForcedViewportEnabled[] = "forcedViewportEnabled"; 30 static const char kForcedViewportEnabled[] = "forcedViewportEnabled";
31 static const char kForcedViewportX[] = "forcedViewportX"; 31 static const char kForcedViewportX[] = "forcedViewportX";
32 static const char kForcedViewportY[] = "forcedViewportY"; 32 static const char kForcedViewportY[] = "forcedViewportY";
33 static const char kForcedViewportScale[] = "forcedViewportScale"; 33 static const char kForcedViewportScale[] = "forcedViewportScale";
34 static const char kDefaultBackgroundColorOverrideRGBA[] = 34 static const char kDefaultBackgroundColorOverrideRGBA[] =
35 "defaultBackgroundColorOverrideRGBA"; 35 "defaultBackgroundColorOverrideRGBA";
36 } 36 }
37 37
38 InspectorEmulationAgent* InspectorEmulationAgent::Create( 38 InspectorEmulationAgent* InspectorEmulationAgent::Create(
39 WebLocalFrameImpl* web_local_frame_impl, 39 WebLocalFrameBase* web_local_frame_impl,
40 Client* client) { 40 Client* client) {
41 return new InspectorEmulationAgent(web_local_frame_impl, client); 41 return new InspectorEmulationAgent(web_local_frame_impl, client);
42 } 42 }
43 43
44 InspectorEmulationAgent::InspectorEmulationAgent( 44 InspectorEmulationAgent::InspectorEmulationAgent(
45 WebLocalFrameImpl* web_local_frame_impl, 45 WebLocalFrameBase* web_local_frame_impl,
46 Client* client) 46 Client* client)
47 : web_local_frame_impl_(web_local_frame_impl), client_(client) {} 47 : web_local_frame_(web_local_frame_impl), client_(client) {}
48 48
49 InspectorEmulationAgent::~InspectorEmulationAgent() {} 49 InspectorEmulationAgent::~InspectorEmulationAgent() {}
50 50
51 WebViewBase* InspectorEmulationAgent::GetWebViewBase() { 51 WebViewBase* InspectorEmulationAgent::GetWebViewBase() {
52 return web_local_frame_impl_->ViewImpl(); 52 return web_local_frame_->ViewImpl();
53 } 53 }
54 54
55 void InspectorEmulationAgent::Restore() { 55 void InspectorEmulationAgent::Restore() {
56 setScriptExecutionDisabled(state_->booleanProperty( 56 setScriptExecutionDisabled(state_->booleanProperty(
57 EmulationAgentState::kScriptExecutionDisabled, false)); 57 EmulationAgentState::kScriptExecutionDisabled, false));
58 setTouchEmulationEnabled( 58 setTouchEmulationEnabled(
59 state_->booleanProperty(EmulationAgentState::kTouchEventEmulationEnabled, 59 state_->booleanProperty(EmulationAgentState::kTouchEventEmulationEnabled,
60 false), 60 false),
61 protocol::Maybe<String>()); 61 protocol::Maybe<String>());
62 String emulated_media; 62 String emulated_media;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 Response InspectorEmulationAgent::setCPUThrottlingRate(double throttling_rate) { 151 Response InspectorEmulationAgent::setCPUThrottlingRate(double throttling_rate) {
152 client_->SetCPUThrottlingRate(throttling_rate); 152 client_->SetCPUThrottlingRate(throttling_rate);
153 return Response::OK(); 153 return Response::OK();
154 } 154 }
155 155
156 Response InspectorEmulationAgent::setVirtualTimePolicy(const String& policy, 156 Response InspectorEmulationAgent::setVirtualTimePolicy(const String& policy,
157 Maybe<int> budget) { 157 Maybe<int> budget) {
158 if (protocol::Emulation::VirtualTimePolicyEnum::Advance == policy) { 158 if (protocol::Emulation::VirtualTimePolicyEnum::Advance == policy) {
159 web_local_frame_impl_->View()->Scheduler()->SetVirtualTimePolicy( 159 web_local_frame_->View()->Scheduler()->SetVirtualTimePolicy(
160 WebViewScheduler::VirtualTimePolicy::ADVANCE); 160 WebViewScheduler::VirtualTimePolicy::ADVANCE);
161 } else if (protocol::Emulation::VirtualTimePolicyEnum::Pause == policy) { 161 } else if (protocol::Emulation::VirtualTimePolicyEnum::Pause == policy) {
162 web_local_frame_impl_->View()->Scheduler()->SetVirtualTimePolicy( 162 web_local_frame_->View()->Scheduler()->SetVirtualTimePolicy(
163 WebViewScheduler::VirtualTimePolicy::PAUSE); 163 WebViewScheduler::VirtualTimePolicy::PAUSE);
164 } else if (protocol::Emulation::VirtualTimePolicyEnum:: 164 } else if (protocol::Emulation::VirtualTimePolicyEnum::
165 PauseIfNetworkFetchesPending == policy) { 165 PauseIfNetworkFetchesPending == policy) {
166 web_local_frame_impl_->View()->Scheduler()->SetVirtualTimePolicy( 166 web_local_frame_->View()->Scheduler()->SetVirtualTimePolicy(
167 WebViewScheduler::VirtualTimePolicy::DETERMINISTIC_LOADING); 167 WebViewScheduler::VirtualTimePolicy::DETERMINISTIC_LOADING);
168 } 168 }
169 web_local_frame_impl_->View()->Scheduler()->EnableVirtualTime(); 169 web_local_frame_->View()->Scheduler()->EnableVirtualTime();
170 170
171 if (budget.isJust()) { 171 if (budget.isJust()) {
172 base::TimeDelta budget_amount = 172 base::TimeDelta budget_amount =
173 base::TimeDelta::FromMilliseconds(budget.fromJust()); 173 base::TimeDelta::FromMilliseconds(budget.fromJust());
174 web_local_frame_impl_->View()->Scheduler()->GrantVirtualTimeBudget( 174 web_local_frame_->View()->Scheduler()->GrantVirtualTimeBudget(
175 budget_amount, 175 budget_amount,
176 WTF::Bind(&InspectorEmulationAgent::VirtualTimeBudgetExpired, 176 WTF::Bind(&InspectorEmulationAgent::VirtualTimeBudgetExpired,
177 WrapWeakPersistent(this))); 177 WrapWeakPersistent(this)));
178 } 178 }
179 return Response::OK(); 179 return Response::OK();
180 } 180 }
181 181
182 void InspectorEmulationAgent::VirtualTimeBudgetExpired() { 182 void InspectorEmulationAgent::VirtualTimeBudgetExpired() {
183 web_local_frame_impl_->View()->Scheduler()->SetVirtualTimePolicy( 183 web_local_frame_->View()->Scheduler()->SetVirtualTimePolicy(
184 WebViewScheduler::VirtualTimePolicy::PAUSE); 184 WebViewScheduler::VirtualTimePolicy::PAUSE);
185 GetFrontend()->virtualTimeBudgetExpired(); 185 GetFrontend()->virtualTimeBudgetExpired();
186 } 186 }
187 187
188 Response InspectorEmulationAgent::setDefaultBackgroundColorOverride( 188 Response InspectorEmulationAgent::setDefaultBackgroundColorOverride(
189 Maybe<protocol::DOM::RGBA> color) { 189 Maybe<protocol::DOM::RGBA> color) {
190 if (!color.isJust()) { 190 if (!color.isJust()) {
191 // Clear the override and state. 191 // Clear the override and state.
192 GetWebViewBase()->ClearBaseBackgroundColorOverride(); 192 GetWebViewBase()->ClearBaseBackgroundColorOverride();
193 state_->remove(EmulationAgentState::kDefaultBackgroundColorOverrideRGBA); 193 state_->remove(EmulationAgentState::kDefaultBackgroundColorOverrideRGBA);
194 return Response::OK(); 194 return Response::OK();
195 } 195 }
196 196
197 blink::protocol::DOM::RGBA* rgba = color.fromJust(); 197 blink::protocol::DOM::RGBA* rgba = color.fromJust();
198 state_->setValue(EmulationAgentState::kDefaultBackgroundColorOverrideRGBA, 198 state_->setValue(EmulationAgentState::kDefaultBackgroundColorOverrideRGBA,
199 rgba->toValue()); 199 rgba->toValue());
200 // Clamping of values is done by Color() constructor. 200 // Clamping of values is done by Color() constructor.
201 int alpha = lroundf(255.0f * rgba->getA(1.0f)); 201 int alpha = lroundf(255.0f * rgba->getA(1.0f));
202 GetWebViewBase()->SetBaseBackgroundColorOverride( 202 GetWebViewBase()->SetBaseBackgroundColorOverride(
203 Color(rgba->getR(), rgba->getG(), rgba->getB(), alpha).Rgb()); 203 Color(rgba->getR(), rgba->getG(), rgba->getB(), alpha).Rgb());
204 return Response::OK(); 204 return Response::OK();
205 } 205 }
206 206
207 DEFINE_TRACE(InspectorEmulationAgent) { 207 DEFINE_TRACE(InspectorEmulationAgent) {
208 visitor->Trace(web_local_frame_impl_); 208 visitor->Trace(web_local_frame_);
209 InspectorBaseAgent::Trace(visitor); 209 InspectorBaseAgent::Trace(visitor);
210 } 210 }
211 211
212 } // namespace blink 212 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/InspectorEmulationAgent.h ('k') | third_party/WebKit/Source/web/LocalFileSystemClient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698