OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "bindings/core/v8/ScriptFunctionCall.h" | 33 #include "bindings/core/v8/ScriptFunctionCall.h" |
34 #include "bindings/core/v8/ScriptState.h" | 34 #include "bindings/core/v8/ScriptState.h" |
35 #include "core/clipboard/Pasteboard.h" | 35 #include "core/clipboard/Pasteboard.h" |
36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
38 #include "core/events/EventTarget.h" | 38 #include "core/events/EventTarget.h" |
39 #include "core/fetch/ResourceFetcher.h" | 39 #include "core/fetch/ResourceFetcher.h" |
40 #include "core/frame/LocalDOMWindow.h" | 40 #include "core/frame/LocalDOMWindow.h" |
41 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
42 #include "core/html/parser/TextResourceDecoder.h" | 42 #include "core/html/parser/TextResourceDecoder.h" |
43 #include "core/inspector/InspectorController.h" | |
44 #include "core/inspector/InspectorFrontendClient.h" | 43 #include "core/inspector/InspectorFrontendClient.h" |
45 #include "core/layout/LayoutTheme.h" | 44 #include "core/layout/LayoutTheme.h" |
46 #include "core/loader/FrameLoader.h" | 45 #include "core/loader/FrameLoader.h" |
47 #include "core/page/ContextMenuController.h" | 46 #include "core/page/ContextMenuController.h" |
48 #include "core/page/ContextMenuProvider.h" | 47 #include "core/page/ContextMenuProvider.h" |
49 #include "core/page/Page.h" | 48 #include "core/page/Page.h" |
50 #include "platform/ContextMenu.h" | 49 #include "platform/ContextMenu.h" |
51 #include "platform/ContextMenuItem.h" | 50 #include "platform/ContextMenuItem.h" |
52 #include "platform/SharedBuffer.h" | 51 #include "platform/SharedBuffer.h" |
53 #include "platform/UserGestureIndicator.h" | 52 #include "platform/UserGestureIndicator.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 , m_items(items) | 119 , m_items(items) |
121 { | 120 { |
122 } | 121 } |
123 | 122 |
124 RawPtrWillBeMember<DevToolsHost> m_devtoolsHost; | 123 RawPtrWillBeMember<DevToolsHost> m_devtoolsHost; |
125 ScriptValue m_devtoolsApiObject; | 124 ScriptValue m_devtoolsApiObject; |
126 | 125 |
127 Vector<ContextMenuItem> m_items; | 126 Vector<ContextMenuItem> m_items; |
128 }; | 127 }; |
129 | 128 |
130 DevToolsHost::DevToolsHost(InspectorFrontendClient* client, Page* frontendPage) | 129 DevToolsHost::DevToolsHost(InspectorFrontendClient* client, LocalFrame* frontend
Frame) |
131 : m_client(client) | 130 : m_client(client) |
132 , m_frontendPage(frontendPage) | 131 , m_frontendFrame(frontendFrame) |
133 , m_menuProvider(nullptr) | 132 , m_menuProvider(nullptr) |
134 { | 133 { |
135 } | 134 } |
136 | 135 |
137 DevToolsHost::~DevToolsHost() | 136 DevToolsHost::~DevToolsHost() |
138 { | 137 { |
139 ASSERT(!m_client); | 138 ASSERT(!m_client); |
140 } | 139 } |
141 | 140 |
142 void DevToolsHost::trace(Visitor* visitor) | 141 void DevToolsHost::trace(Visitor* visitor) |
143 { | 142 { |
144 visitor->trace(m_frontendPage); | 143 visitor->trace(m_frontendFrame); |
145 visitor->trace(m_menuProvider); | 144 visitor->trace(m_menuProvider); |
146 } | 145 } |
147 | 146 |
148 void DevToolsHost::disconnectClient() | 147 void DevToolsHost::disconnectClient() |
149 { | 148 { |
150 m_client = 0; | 149 m_client = 0; |
151 if (m_menuProvider) { | 150 if (m_menuProvider) { |
152 m_menuProvider->disconnect(); | 151 m_menuProvider->disconnect(); |
153 m_menuProvider = nullptr; | 152 m_menuProvider = nullptr; |
154 } | 153 } |
155 m_frontendPage = nullptr; | 154 m_frontendFrame = nullptr; |
156 } | 155 } |
157 | 156 |
158 float DevToolsHost::zoomFactor() | 157 float DevToolsHost::zoomFactor() |
159 { | 158 { |
160 if (!m_frontendPage) | 159 return m_frontendFrame ? m_frontendFrame->pageZoomFactor() : 1; |
161 return 1; | |
162 if (LocalFrame* frame = m_frontendPage->deprecatedLocalMainFrame()) | |
163 return frame->pageZoomFactor(); | |
164 return 1; | |
165 } | 160 } |
166 | 161 |
167 void DevToolsHost::setInjectedScriptForOrigin(const String& origin, const String
& script) | 162 void DevToolsHost::setInjectedScriptForOrigin(const String& origin, const String
& script) |
168 { | 163 { |
169 if (!m_frontendPage) | 164 if (m_client) |
170 return; | 165 m_client->setInjectedScriptForOrigin(origin, script); |
171 m_frontendPage->inspectorController().setInjectedScriptForOrigin(origin, scr
ipt); | |
172 } | 166 } |
173 | 167 |
174 void DevToolsHost::copyText(const String& text) | 168 void DevToolsHost::copyText(const String& text) |
175 { | 169 { |
176 Pasteboard::generalPasteboard()->writePlainText(text, Pasteboard::CannotSmar
tReplace); | 170 Pasteboard::generalPasteboard()->writePlainText(text, Pasteboard::CannotSmar
tReplace); |
177 } | 171 } |
178 | 172 |
179 static String escapeUnicodeNonCharacters(const String& str) | 173 static String escapeUnicodeNonCharacters(const String& str) |
180 { | 174 { |
181 const UChar nonChar = 0xD800; | 175 const UChar nonChar = 0xD800; |
(...skipping 24 matching lines...) Expand all Loading... |
206 if (m_client) | 200 if (m_client) |
207 m_client->sendMessageToBackend(escapeUnicodeNonCharacters(message)); | 201 m_client->sendMessageToBackend(escapeUnicodeNonCharacters(message)); |
208 } | 202 } |
209 | 203 |
210 void DevToolsHost::sendMessageToEmbedder(const String& message) | 204 void DevToolsHost::sendMessageToEmbedder(const String& message) |
211 { | 205 { |
212 if (m_client) | 206 if (m_client) |
213 m_client->sendMessageToEmbedder(escapeUnicodeNonCharacters(message)); | 207 m_client->sendMessageToEmbedder(escapeUnicodeNonCharacters(message)); |
214 } | 208 } |
215 | 209 |
216 void DevToolsHost::showContextMenu(Page* page, float x, float y, const Vector<Co
ntextMenuItem>& items) | 210 void DevToolsHost::showContextMenu(LocalFrame* targetFrame, float x, float y, co
nst Vector<ContextMenuItem>& items) |
217 { | 211 { |
218 ASSERT(m_frontendPage); | 212 ASSERT(m_frontendFrame); |
219 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendPage-
>deprecatedLocalMainFrame()); | 213 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendFrame
); |
220 ScriptValue devtoolsApiObject = frontendScriptState->getFromGlobalObject("De
vToolsAPI"); | 214 ScriptValue devtoolsApiObject = frontendScriptState->getFromGlobalObject("De
vToolsAPI"); |
221 ASSERT(devtoolsApiObject.isObject()); | 215 ASSERT(devtoolsApiObject.isObject()); |
222 | 216 |
223 RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider
::create(this, devtoolsApiObject, items); | 217 RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider
::create(this, devtoolsApiObject, items); |
224 m_menuProvider = menuProvider.get(); | 218 m_menuProvider = menuProvider.get(); |
225 float zoom = page->deprecatedLocalMainFrame()->pageZoomFactor(); | 219 float zoom = targetFrame->pageZoomFactor(); |
226 page->inspectorController().showContextMenu(x * zoom, y * zoom, menuProvider
); | 220 if (m_client) |
| 221 m_client->showContextMenu(targetFrame, x * zoom, y * zoom, menuProvider)
; |
227 } | 222 } |
228 | 223 |
229 void DevToolsHost::showContextMenu(Event* event, const Vector<ContextMenuItem>&
items) | 224 void DevToolsHost::showContextMenu(Event* event, const Vector<ContextMenuItem>&
items) |
230 { | 225 { |
231 if (!event) | 226 if (!event) |
232 return; | 227 return; |
233 | 228 |
234 ASSERT(m_frontendPage); | 229 ASSERT(m_frontendFrame); |
235 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendPage-
>deprecatedLocalMainFrame()); | 230 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendFrame
); |
236 ScriptValue devtoolsApiObject = frontendScriptState->getFromGlobalObject("De
vToolsAPI"); | 231 ScriptValue devtoolsApiObject = frontendScriptState->getFromGlobalObject("De
vToolsAPI"); |
237 ASSERT(devtoolsApiObject.isObject()); | 232 ASSERT(devtoolsApiObject.isObject()); |
238 | 233 |
239 Page* targetPage = m_frontendPage; | 234 Page* targetPage = m_frontendFrame->page(); |
240 if (event->target() && event->target()->executionContext() && event->target(
)->executionContext()->executingWindow()) { | 235 if (event->target() && event->target()->executionContext() && event->target(
)->executionContext()->executingWindow()) { |
241 LocalDOMWindow* window = event->target()->executionContext()->executingW
indow(); | 236 LocalDOMWindow* window = event->target()->executionContext()->executingW
indow(); |
242 if (window->document() && window->document()->page()) | 237 if (window->document() && window->document()->page()) |
243 targetPage = window->document()->page(); | 238 targetPage = window->document()->page(); |
244 } | 239 } |
245 | 240 |
246 RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider
::create(this, devtoolsApiObject, items); | 241 RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider
::create(this, devtoolsApiObject, items); |
247 targetPage->contextMenuController().showContextMenu(event, menuProvider); | 242 targetPage->contextMenuController().showContextMenu(event, menuProvider); |
248 m_menuProvider = menuProvider.get(); | 243 m_menuProvider = menuProvider.get(); |
249 } | 244 } |
(...skipping 12 matching lines...) Expand all Loading... |
262 { | 257 { |
263 return m_client && m_client->isUnderTest(); | 258 return m_client && m_client->isUnderTest(); |
264 } | 259 } |
265 | 260 |
266 bool DevToolsHost::isHostedMode() | 261 bool DevToolsHost::isHostedMode() |
267 { | 262 { |
268 return false; | 263 return false; |
269 } | 264 } |
270 | 265 |
271 } // namespace blink | 266 } // namespace blink |
OLD | NEW |