OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2010-2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 static void ensureMainThreadDebuggerCreated(WebDevToolsAgentClient* client) { | 110 static void ensureMainThreadDebuggerCreated(WebDevToolsAgentClient* client) { |
111 if (s_instance) | 111 if (s_instance) |
112 return; | 112 return; |
113 std::unique_ptr<ClientMessageLoopAdapter> instance = | 113 std::unique_ptr<ClientMessageLoopAdapter> instance = |
114 WTF::wrapUnique(new ClientMessageLoopAdapter( | 114 WTF::wrapUnique(new ClientMessageLoopAdapter( |
115 WTF::wrapUnique(client->createClientMessageLoop()))); | 115 WTF::wrapUnique(client->createClientMessageLoop()))); |
116 s_instance = instance.get(); | 116 s_instance = instance.get(); |
117 MainThreadDebugger::instance()->setClientMessageLoop(std::move(instance)); | 117 MainThreadDebugger::instance()->setClientMessageLoop(std::move(instance)); |
118 } | 118 } |
119 | 119 |
120 static void webViewImplClosed(WebViewImpl* view) { | |
121 if (s_instance) | |
122 s_instance->m_frozenViews.remove(view); | |
123 } | |
124 | |
125 static void webFrameWidgetImplClosed(WebFrameWidgetImpl* widget) { | |
126 if (s_instance) | |
127 s_instance->m_frozenWidgets.remove(widget); | |
128 } | |
129 | |
130 static void continueProgram() { | 120 static void continueProgram() { |
131 // Release render thread if necessary. | 121 // Release render thread if necessary. |
132 if (s_instance) | 122 if (s_instance) |
133 s_instance->quitNow(); | 123 s_instance->quitNow(); |
134 } | 124 } |
135 | 125 |
136 static void pauseForCreateWindow(WebLocalFrameImpl* frame) { | 126 static void pauseForCreateWindow(WebLocalFrameImpl* frame) { |
137 if (s_instance) | 127 if (s_instance) |
138 s_instance->runForCreateWindow(frame); | 128 s_instance->runForCreateWindow(frame); |
139 } | 129 } |
(...skipping 28 matching lines...) Expand all Loading... |
168 m_runningForCreateWindow = true; | 158 m_runningForCreateWindow = true; |
169 if (!m_runningForDebugBreak) | 159 if (!m_runningForDebugBreak) |
170 runLoop(frame); | 160 runLoop(frame); |
171 } | 161 } |
172 | 162 |
173 void runLoop(WebLocalFrameImpl* frame) { | 163 void runLoop(WebLocalFrameImpl* frame) { |
174 // 0. Flush pending frontend messages. | 164 // 0. Flush pending frontend messages. |
175 WebDevToolsAgentImpl* agent = frame->devToolsAgentImpl(); | 165 WebDevToolsAgentImpl* agent = frame->devToolsAgentImpl(); |
176 agent->flushProtocolNotifications(); | 166 agent->flushProtocolNotifications(); |
177 | 167 |
178 Vector<WebViewImpl*> views; | |
179 HeapVector<Member<WebFrameWidgetImpl>> widgets; | |
180 | |
181 // 1. Disable input events. | 168 // 1. Disable input events. |
182 const HashSet<WebViewImpl*>& viewImpls = WebViewImpl::allInstances(); | 169 WebFrameWidgetBase::setIgnoreInputEvents(true); |
183 HashSet<WebViewImpl*>::const_iterator viewImplsEnd = viewImpls.end(); | 170 for (const auto view : WebViewImpl::allInstances()) |
184 for (HashSet<WebViewImpl*>::const_iterator it = viewImpls.begin(); | |
185 it != viewImplsEnd; ++it) { | |
186 WebViewImpl* view = *it; | |
187 m_frozenViews.add(view); | |
188 views.append(view); | |
189 view->setIgnoreInputEvents(true); | |
190 view->chromeClient().notifyPopupOpeningObservers(); | 171 view->chromeClient().notifyPopupOpeningObservers(); |
191 } | |
192 | |
193 const WebFrameWidgetsSet& widgetImpls = WebFrameWidgetImpl::allInstances(); | |
194 WebFrameWidgetsSet::const_iterator widgetImplsEnd = widgetImpls.end(); | |
195 for (WebFrameWidgetsSet::const_iterator it = widgetImpls.begin(); | |
196 it != widgetImplsEnd; ++it) { | |
197 WebFrameWidgetImpl* widget = *it; | |
198 m_frozenWidgets.add(widget); | |
199 widgets.append(widget); | |
200 widget->setIgnoreInputEvents(true); | |
201 } | |
202 | 172 |
203 // 2. Notify embedder about pausing. | 173 // 2. Notify embedder about pausing. |
204 if (agent->client()) | 174 if (agent->client()) |
205 agent->client()->willEnterDebugLoop(); | 175 agent->client()->willEnterDebugLoop(); |
206 | 176 |
207 // 3. Disable active objects | 177 // 3. Disable active objects |
208 WebView::willEnterModalLoop(); | 178 WebView::willEnterModalLoop(); |
209 | 179 |
210 // 4. Process messages until quitNow is called. | 180 // 4. Process messages until quitNow is called. |
211 m_messageLoop->run(); | 181 m_messageLoop->run(); |
212 | 182 |
213 // 5. Resume active objects | 183 // 5. Resume active objects |
214 WebView::didExitModalLoop(); | 184 WebView::didExitModalLoop(); |
215 | 185 |
216 // 6. Resume input events. | 186 WebFrameWidgetBase::setIgnoreInputEvents(false); |
217 for (Vector<WebViewImpl*>::iterator it = views.begin(); it != views.end(); | |
218 ++it) { | |
219 if (m_frozenViews.contains(*it)) { | |
220 // The view was not closed during the dispatch. | |
221 (*it)->setIgnoreInputEvents(false); | |
222 } | |
223 } | |
224 for (HeapVector<Member<WebFrameWidgetImpl>>::iterator it = widgets.begin(); | |
225 it != widgets.end(); ++it) { | |
226 if (m_frozenWidgets.contains(*it)) { | |
227 // The widget was not closed during the dispatch. | |
228 (*it)->setIgnoreInputEvents(false); | |
229 } | |
230 } | |
231 | 187 |
232 // 7. Notify embedder about resuming. | 188 // 7. Notify embedder about resuming. |
233 if (agent->client()) | 189 if (agent->client()) |
234 agent->client()->didExitDebugLoop(); | 190 agent->client()->didExitDebugLoop(); |
235 | |
236 // 8. All views have been resumed, clear the set. | |
237 m_frozenViews.clear(); | |
238 m_frozenWidgets.clear(); | |
239 } | 191 } |
240 | 192 |
241 void quitNow() override { | 193 void quitNow() override { |
242 if (m_runningForDebugBreak) { | 194 if (m_runningForDebugBreak) { |
243 m_runningForDebugBreak = false; | 195 m_runningForDebugBreak = false; |
244 if (!m_runningForCreateWindow) | 196 if (!m_runningForCreateWindow) |
245 m_messageLoop->quitNow(); | 197 m_messageLoop->quitNow(); |
246 } | 198 } |
247 } | 199 } |
248 | 200 |
(...skipping 15 matching lines...) Expand all Loading... |
264 WebDevToolsAgentImpl* agent = | 216 WebDevToolsAgentImpl* agent = |
265 WebLocalFrameImpl::fromFrame(frame)->devToolsAgentImpl(); | 217 WebLocalFrameImpl::fromFrame(frame)->devToolsAgentImpl(); |
266 if (agent && agent->client()) | 218 if (agent && agent->client()) |
267 agent->client()->resumeStartup(); | 219 agent->client()->resumeStartup(); |
268 } | 220 } |
269 | 221 |
270 bool m_runningForDebugBreak; | 222 bool m_runningForDebugBreak; |
271 bool m_runningForCreateWindow; | 223 bool m_runningForCreateWindow; |
272 std::unique_ptr<WebDevToolsAgentClient::WebKitClientMessageLoop> | 224 std::unique_ptr<WebDevToolsAgentClient::WebKitClientMessageLoop> |
273 m_messageLoop; | 225 m_messageLoop; |
274 typedef HashSet<WebViewImpl*> FrozenViewsSet; | 226 |
275 FrozenViewsSet m_frozenViews; | |
276 WebFrameWidgetsSet m_frozenWidgets; | |
277 static ClientMessageLoopAdapter* s_instance; | 227 static ClientMessageLoopAdapter* s_instance; |
278 }; | 228 }; |
279 | 229 |
280 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = nullptr; | 230 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = nullptr; |
281 | 231 |
282 // static | 232 // static |
283 WebDevToolsAgentImpl* WebDevToolsAgentImpl::create( | 233 WebDevToolsAgentImpl* WebDevToolsAgentImpl::create( |
284 WebLocalFrameImpl* frame, | 234 WebLocalFrameImpl* frame, |
285 WebDevToolsAgentClient* client) { | 235 WebDevToolsAgentClient* client) { |
286 InspectorOverlay* overlay = new InspectorOverlay(frame); | 236 InspectorOverlay* overlay = new InspectorOverlay(frame); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 m_includeViewAgents(includeViewAgents), | 272 m_includeViewAgents(includeViewAgents), |
323 m_layerTreeId(0) { | 273 m_layerTreeId(0) { |
324 DCHECK(isMainThread()); | 274 DCHECK(isMainThread()); |
325 DCHECK(m_webLocalFrameImpl->frame()); | 275 DCHECK(m_webLocalFrameImpl->frame()); |
326 } | 276 } |
327 | 277 |
328 WebDevToolsAgentImpl::~WebDevToolsAgentImpl() { | 278 WebDevToolsAgentImpl::~WebDevToolsAgentImpl() { |
329 DCHECK(!m_client); | 279 DCHECK(!m_client); |
330 } | 280 } |
331 | 281 |
332 // static | |
333 void WebDevToolsAgentImpl::webViewImplClosed(WebViewImpl* webViewImpl) { | |
334 ClientMessageLoopAdapter::webViewImplClosed(webViewImpl); | |
335 } | |
336 | |
337 // static | |
338 void WebDevToolsAgentImpl::webFrameWidgetImplClosed( | |
339 WebFrameWidgetImpl* webFrameWidgetImpl) { | |
340 ClientMessageLoopAdapter::webFrameWidgetImplClosed(webFrameWidgetImpl); | |
341 } | |
342 | |
343 DEFINE_TRACE(WebDevToolsAgentImpl) { | 282 DEFINE_TRACE(WebDevToolsAgentImpl) { |
344 visitor->trace(m_webLocalFrameImpl); | 283 visitor->trace(m_webLocalFrameImpl); |
345 visitor->trace(m_instrumentingAgents); | 284 visitor->trace(m_instrumentingAgents); |
346 visitor->trace(m_resourceContentLoader); | 285 visitor->trace(m_resourceContentLoader); |
347 visitor->trace(m_overlay); | 286 visitor->trace(m_overlay); |
348 visitor->trace(m_inspectedFrames); | 287 visitor->trace(m_inspectedFrames); |
349 visitor->trace(m_resourceContainer); | 288 visitor->trace(m_resourceContainer); |
350 visitor->trace(m_domAgent); | 289 visitor->trace(m_domAgent); |
351 visitor->trace(m_pageAgent); | 290 visitor->trace(m_pageAgent); |
352 visitor->trace(m_networkAgent); | 291 visitor->trace(m_networkAgent); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 } | 638 } |
700 | 639 |
701 bool WebDevToolsAgent::shouldInterruptForMethod(const WebString& method) { | 640 bool WebDevToolsAgent::shouldInterruptForMethod(const WebString& method) { |
702 return method == "Debugger.pause" || method == "Debugger.setBreakpoint" || | 641 return method == "Debugger.pause" || method == "Debugger.setBreakpoint" || |
703 method == "Debugger.setBreakpointByUrl" || | 642 method == "Debugger.setBreakpointByUrl" || |
704 method == "Debugger.removeBreakpoint" || | 643 method == "Debugger.removeBreakpoint" || |
705 method == "Debugger.setBreakpointsActive"; | 644 method == "Debugger.setBreakpointsActive"; |
706 } | 645 } |
707 | 646 |
708 } // namespace blink | 647 } // namespace blink |
OLD | NEW |