| OLD | NEW |
| 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/WebFloatRect.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 Loading... |
| 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 clearCompositedAreaOverride(&error); |
| 66 } |
| 67 |
| 68 void InspectorEmulationAgent::setCompositedAreaOverride(ErrorString* error, doub
le x, double y, double width, double height, const Maybe<double>& scale) |
| 69 { |
| 70 if (x < 0 || y < 0 || width < 0 || height < 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 WebFloatRect area(x, y, width, height); |
| 82 webViewImpl()->devToolsEmulator()->setCompositedAreaOverride(area, appliedSc
ale); |
| 83 } |
| 84 |
| 85 void InspectorEmulationAgent::clearCompositedAreaOverride(ErrorString*) |
| 86 { |
| 87 webViewImpl()->devToolsEmulator()->clearCompositedAreaOverride(); |
| 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 Loading... |
| 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 |
| OLD | NEW |