9b0a4fb188d70321a2b1b930f61b7edca98d59da
[WebKit-https.git] / Source / WebCore / inspector / InspectorAgent.cpp
1 /*
2  * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3  * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include "config.h"
31 #include "InspectorAgent.h"
32
33 #if ENABLE(INSPECTOR)
34
35 #include "CachedResource.h"
36 #include "CachedResourceLoader.h"
37 #include "Chrome.h"
38 #include "Cookie.h"
39 #include "CookieJar.h"
40 #include "DOMWindow.h"
41 #include "DOMWrapperWorld.h"
42 #include "Document.h"
43 #include "DocumentLoader.h"
44 #include "Element.h"
45 #include "FloatConversion.h"
46 #include "FloatQuad.h"
47 #include "FloatRect.h"
48 #include "Frame.h"
49 #include "FrameLoadRequest.h"
50 #include "FrameLoader.h"
51 #include "FrameTree.h"
52 #include "FrameView.h"
53 #include "GraphicsContext.h"
54 #include "HTMLFrameOwnerElement.h"
55 #include "HTTPHeaderMap.h"
56 #include "HitTestResult.h"
57 #include "InjectedScript.h"
58 #include "InjectedScriptHost.h"
59 #include "InspectorBrowserDebuggerAgent.h"
60 #include "InspectorCSSAgent.h"
61 #include "InspectorClient.h"
62 #include "InspectorConsoleAgent.h"
63 #include "InspectorController.h"
64 #include "InspectorDOMAgent.h"
65 #include "InspectorDOMStorageResource.h"
66 #include "InspectorDatabaseResource.h"
67 #include "InspectorDebuggerAgent.h"
68 #include "InspectorFrontend.h"
69 #include "InspectorFrontendClient.h"
70 #include "InspectorInstrumentation.h"
71 #include "InspectorProfilerAgent.h"
72 #include "InspectorResourceAgent.h"
73 #include "InspectorRuntimeAgent.h"
74 #include "InspectorState.h"
75 #include "InspectorTimelineAgent.h"
76 #include "InspectorValues.h"
77 #include "InspectorWorkerResource.h"
78 #include "InstrumentingAgents.h"
79 #include "IntRect.h"
80 #include "Page.h"
81 #include "ProgressTracker.h"
82 #include "Range.h"
83 #include "RenderInline.h"
84 #include "ResourceRequest.h"
85 #include "ResourceResponse.h"
86 #include "ScriptArguments.h"
87 #include "ScriptCallStack.h"
88 #include "ScriptFunctionCall.h"
89 #include "ScriptObject.h"
90 #include "ScriptProfile.h"
91 #include "ScriptProfiler.h"
92 #include "ScriptSourceCode.h"
93 #include "ScriptState.h"
94 #include "SecurityOrigin.h"
95 #include "Settings.h"
96 #include "SharedBuffer.h"
97 #include "TextEncoding.h"
98 #include "TextIterator.h"
99 #include "TextRun.h"
100 #include "UserGestureIndicator.h"
101 #include "WindowFeatures.h"
102 #include <wtf/CurrentTime.h>
103 #include <wtf/ListHashSet.h>
104 #include <wtf/RefCounted.h>
105 #include <wtf/StdLibExtras.h>
106 #include <wtf/UnusedParam.h>
107 #include <wtf/text/StringConcatenate.h>
108
109 #if ENABLE(DATABASE)
110 #include "InspectorDatabaseAgent.h"
111 #endif
112
113 #if ENABLE(DOM_STORAGE)
114 #include "InspectorDOMStorageAgent.h"
115 #endif
116
117 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
118 #include "InspectorApplicationCacheAgent.h"
119 #endif
120
121 using namespace std;
122
123 namespace WebCore {
124
125 namespace InspectorAgentState {
126 static const char searchingForNode[] = "searchingForNode";
127 static const char timelineProfilerEnabled[] = "timelineProfilerEnabled";
128 static const char userInitiatedProfiling[] = "userInitiatedProfiling";
129 static const char debuggerEnabled[] = "debuggerEnabled";
130 static const char profilerEnabled[] = "profilerEnabled";
131 }
132
133 static const char scriptsPanelName[] = "scripts";
134 static const char consolePanelName[] = "console";
135 static const char profilesPanelName[] = "profiles";
136
137 InspectorAgent::InspectorAgent(Page* page, InspectorClient* client)
138     : m_inspectedPage(page)
139     , m_client(client)
140     , m_frontend(0)
141     , m_instrumentingAgents(new InstrumentingAgents())
142     , m_injectedScriptHost(InjectedScriptHost::create(this))
143     , m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), m_injectedScriptHost.get()))
144     , m_cssAgent(new InspectorCSSAgent(m_domAgent.get()))
145 #if ENABLE(DATABASE)
146     , m_databaseAgentResources(InspectorDatabaseAgent::createStorage())
147 #endif
148 #if ENABLE(DOM_STORAGE)
149     , m_domStorageAgentResources(InspectorDOMStorageAgent::createStorage())
150 #endif
151     , m_state(new InspectorState(client))
152     , m_consoleAgent(new InspectorConsoleAgent(m_instrumentingAgents.get(), this, m_state.get(), m_injectedScriptHost.get(), m_domAgent.get()))
153 #if ENABLE(JAVASCRIPT_DEBUGGER)
154     , m_profilerAgent(InspectorProfilerAgent::create(this))
155 #endif
156 {
157     ASSERT_ARG(page, page);
158     ASSERT_ARG(client, client);
159     InspectorInstrumentation::bindInspectorAgent(m_inspectedPage, this);
160 }
161
162 InspectorAgent::~InspectorAgent()
163 {
164     // These should have been cleared in inspectedPageDestroyed().
165     ASSERT(!m_client);
166     ASSERT(!m_inspectedPage);
167     ASSERT(!m_highlightedNode);
168 }
169
170 void InspectorAgent::inspectedPageDestroyed()
171 {
172     if (m_frontend)
173         m_frontend->disconnectFromBackend();
174
175     hideHighlight();
176
177 #if ENABLE(JAVASCRIPT_DEBUGGER)
178     m_debuggerAgent.clear();
179     m_browserDebuggerAgent.clear();
180 #endif
181
182     ASSERT(m_inspectedPage);
183     InspectorInstrumentation::unbindInspectorAgent(m_inspectedPage);
184     m_inspectedPage = 0;
185
186     releaseFrontendLifetimeAgents();
187     m_injectedScriptHost->disconnectController();
188
189     m_client->inspectorDestroyed();
190     m_client = 0;
191 }
192
193 bool InspectorAgent::searchingForNodeInPage() const
194 {
195     return m_state->getBoolean(InspectorAgentState::searchingForNode);
196 }
197
198 void InspectorAgent::restoreInspectorStateFromCookie(const String& inspectorStateCookie)
199 {
200     m_state = new InspectorState(m_client, inspectorStateCookie);
201
202     m_frontend->frontendReused();
203     m_frontend->inspectedURLChanged(inspectedURL().string());
204     pushDataCollectedOffline();
205
206     m_resourceAgent = InspectorResourceAgent::restore(m_inspectedPage, m_state.get(), m_frontend);
207     m_timelineAgent = InspectorTimelineAgent::restore(m_state.get(), m_frontend);
208
209 #if ENABLE(JAVASCRIPT_DEBUGGER)
210     restoreDebugger(false);
211     restoreProfiler(ProfilerRestoreResetAgent);
212     if (m_state->getBoolean(InspectorAgentState::userInitiatedProfiling))
213         startUserInitiatedProfiling();
214 #endif
215 }
216
217 void InspectorAgent::inspect(Node* node)
218 {
219     if (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE)
220         node = node->parentNode();
221     m_nodeToFocus = node;
222
223     if (!m_frontend)
224         return;
225
226     focusNode();
227 }
228
229 void InspectorAgent::focusNode()
230 {
231     if (!enabled())
232         return;
233
234     ASSERT(m_frontend);
235     ASSERT(m_nodeToFocus);
236
237     long id = m_domAgent->pushNodePathToFrontend(m_nodeToFocus.get());
238     m_frontend->updateFocusedNode(id);
239     m_nodeToFocus = 0;
240 }
241
242 void InspectorAgent::highlight(Node* node)
243 {
244     if (!enabled())
245         return;
246     ASSERT_ARG(node, node);
247     m_highlightedNode = node;
248     m_client->highlight(node);
249 }
250
251 void InspectorAgent::highlightDOMNode(long nodeId)
252 {
253     Node* node = 0;
254     if (m_domAgent && (node = m_domAgent->nodeForId(nodeId)))
255         highlight(node);
256 }
257
258 void InspectorAgent::highlightFrame(unsigned long frameId)
259 {
260     Frame* mainFrame = m_inspectedPage->mainFrame();
261     for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext(mainFrame)) {
262         if (reinterpret_cast<uintptr_t>(frame) == frameId && frame->ownerElement()) {
263             highlight(frame->ownerElement());
264             return;
265         }
266     }
267 }
268
269 void InspectorAgent::hideHighlight()
270 {
271     if (!enabled())
272         return;
273     m_highlightedNode = 0;
274     m_client->hideHighlight();
275 }
276
277 void InspectorAgent::mouseDidMoveOverElement(const HitTestResult& result, unsigned)
278 {
279     if (!enabled() || !searchingForNodeInPage())
280         return;
281
282     Node* node = result.innerNode();
283     while (node && node->nodeType() == Node::TEXT_NODE)
284         node = node->parentNode();
285     if (node)
286         highlight(node);
287 }
288
289 bool InspectorAgent::handleMousePress()
290 {
291     if (!enabled() || !searchingForNodeInPage())
292         return false;
293
294     if (m_highlightedNode) {
295         RefPtr<Node> node = m_highlightedNode;
296         setSearchingForNode(false);
297         inspect(node.get());
298     }
299     return true;
300 }
301
302 void InspectorAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world)
303 {
304     if (world != mainThreadNormalWorld())
305         return;
306
307     if (enabled()) {
308         if (m_frontend && frame == m_inspectedPage->mainFrame())
309             m_injectedScriptHost->discardInjectedScripts();
310
311         if (m_scriptsToEvaluateOnLoad.size()) {
312             ScriptState* scriptState = mainWorldScriptState(frame);
313             for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin();
314                   it != m_scriptsToEvaluateOnLoad.end(); ++it) {
315                 m_injectedScriptHost->injectScript(*it, scriptState);
316             }
317         }
318     }
319
320     if (!m_inspectorExtensionAPI.isEmpty())
321         m_injectedScriptHost->injectScript(m_inspectorExtensionAPI, mainWorldScriptState(frame));
322 }
323
324 void InspectorAgent::setSearchingForNode(bool enabled)
325 {
326     if (searchingForNodeInPage() == enabled)
327         return;
328     m_state->setBoolean(InspectorAgentState::searchingForNode, enabled);
329     if (!enabled)
330         hideHighlight();
331 }
332
333 void InspectorAgent::setSearchingForNode(bool enabled, bool* newState)
334 {
335     *newState = enabled;
336     setSearchingForNode(enabled);
337 }
338
339 void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend)
340 {
341     m_frontend = inspectorFrontend;
342     createFrontendLifetimeAgents();
343
344     m_domAgent->setFrontend(m_frontend);
345     m_consoleAgent->setFrontend(m_frontend);
346
347     // Initialize Web Inspector title.
348     m_frontend->inspectedURLChanged(inspectedURL().string());
349 }
350
351 void InspectorAgent::disconnectFrontend()
352 {
353     if (!m_frontend)
354         return;
355
356     // Destroying agents would change the state, but we don't want that.
357     // Pre-disconnect state will be used to restore inspector agents.
358     m_state->mute();
359
360     m_frontend = 0;
361
362 #if ENABLE(JAVASCRIPT_DEBUGGER)
363     // If the window is being closed with the debugger enabled,
364     // remember this state to re-enable debugger on the next window
365     // opening.
366     disableDebugger();
367 #endif
368     setSearchingForNode(false);
369
370     hideHighlight();
371
372 #if ENABLE(JAVASCRIPT_DEBUGGER)
373     m_profilerAgent->setFrontend(0);
374     m_profilerAgent->stopUserInitiatedProfiling(true);
375 #endif
376
377     m_consoleAgent->clearFrontend();
378     m_domAgent->clearFrontend();
379
380     releaseFrontendLifetimeAgents();
381     m_userAgentOverride = "";
382 }
383
384 InspectorResourceAgent* InspectorAgent::resourceAgent()
385 {
386     if (!m_resourceAgent && m_frontend)
387         m_resourceAgent = InspectorResourceAgent::create(m_inspectedPage, m_state.get(), m_frontend);
388     return m_resourceAgent.get();
389 }
390
391 void InspectorAgent::createFrontendLifetimeAgents()
392 {
393     m_runtimeAgent = InspectorRuntimeAgent::create(m_injectedScriptHost.get());
394
395 #if ENABLE(DATABASE)
396     m_databaseAgent = InspectorDatabaseAgent::create(databaseAgentResources(), m_frontend);
397 #endif
398
399 #if ENABLE(DOM_STORAGE)
400     m_domStorageAgent = InspectorDOMStorageAgent::create(domStorageAgentResources(), m_frontend);
401 #endif
402
403 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
404     m_applicationCacheAgent = new InspectorApplicationCacheAgent(m_inspectedPage->mainFrame()->loader()->documentLoader(), m_frontend);
405 #endif
406 }
407
408 void InspectorAgent::releaseFrontendLifetimeAgents()
409 {
410     m_resourceAgent.clear();
411     m_runtimeAgent.clear();
412     m_timelineAgent.clear();
413
414 #if ENABLE(DATABASE)
415     m_databaseAgent.clear();
416 #endif
417
418 #if ENABLE(DOM_STORAGE)
419     m_domStorageAgent.clear();
420 #endif
421
422 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
423     m_applicationCacheAgent.clear();
424 #endif
425 }
426
427 void InspectorAgent::populateScriptObjects()
428 {
429     ASSERT(m_frontend);
430     if (!m_frontend)
431         return;
432
433 #if ENABLE(JAVASCRIPT_DEBUGGER)
434     if (m_profilerAgent->enabled())
435         m_frontend->profilerWasEnabled();
436 #endif
437
438     pushDataCollectedOffline();
439
440     if (m_nodeToFocus)
441         focusNode();
442
443     if (!m_showPanelAfterVisible.isEmpty()) {
444         m_frontend->showPanel(m_showPanelAfterVisible);
445         m_showPanelAfterVisible = "";
446     }
447
448     restoreDebugger(true);
449     restoreProfiler(ProfilerRestoreNoAction);
450
451     // Dispatch pending frontend commands
452     for (Vector<pair<long, String> >::iterator it = m_pendingEvaluateTestCommands.begin(); it != m_pendingEvaluateTestCommands.end(); ++it)
453         m_frontend->evaluateForTestInFrontend((*it).first, (*it).second);
454     m_pendingEvaluateTestCommands.clear();
455 }
456
457 void InspectorAgent::pushDataCollectedOffline()
458 {
459     m_domAgent->setDocument(m_inspectedPage->mainFrame()->document());
460
461 #if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(WORKERS)
462     WorkersMap::iterator workersEnd = m_workers.end();
463     for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it) {
464         InspectorWorkerResource* worker = it->second.get();
465         m_frontend->didCreateWorker(worker->id(), worker->url(), worker->isSharedWorker());
466     }
467 #endif
468 }
469
470 void InspectorAgent::restoreDebugger(bool eraseStickyBreakpoints)
471 {
472     ASSERT(m_frontend);
473 #if ENABLE(JAVASCRIPT_DEBUGGER)
474     if (m_state->getBoolean(InspectorAgentState::debuggerEnabled))
475         enableDebugger(eraseStickyBreakpoints);
476 #endif
477 }
478
479 void InspectorAgent::restoreProfiler(ProfilerRestoreAction action)
480 {
481     ASSERT(m_frontend);
482 #if ENABLE(JAVASCRIPT_DEBUGGER)
483     m_profilerAgent->setFrontend(m_frontend);
484     if (m_state->getBoolean(InspectorAgentState::profilerEnabled))
485         enableProfiler();
486     if (action == ProfilerRestoreResetAgent)
487         m_profilerAgent->resetFrontendProfiles();
488 #endif
489 }
490
491 void InspectorAgent::didCommitLoad(DocumentLoader* loader)
492 {
493     if (!enabled())
494         return;
495
496     if (m_resourceAgent)
497         m_resourceAgent->didCommitLoad(loader);
498
499     ASSERT(m_inspectedPage);
500
501     if (loader->frame() == m_inspectedPage->mainFrame()) {
502         if (m_frontend)
503             m_frontend->inspectedURLChanged(loader->url().string());
504
505         m_injectedScriptHost->discardInjectedScripts();
506         m_consoleAgent->reset();
507
508         if (m_timelineAgent)
509             m_timelineAgent->didCommitLoad();
510
511 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
512         if (m_applicationCacheAgent)
513             m_applicationCacheAgent->didCommitLoad(loader);
514 #endif
515
516 #if ENABLE(JAVASCRIPT_DEBUGGER)
517         if (m_debuggerAgent) {
518             KURL url = inspectedURLWithoutFragment();
519             m_debuggerAgent->inspectedURLChanged(url);
520             if (m_browserDebuggerAgent)
521                 m_browserDebuggerAgent->inspectedURLChanged(url);
522         }
523 #endif
524
525 #if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
526         m_profilerAgent->stopUserInitiatedProfiling(true);
527         m_profilerAgent->resetState();
528 #endif
529
530         if (m_frontend) {
531             m_frontend->reset();
532             m_domAgent->reset();
533             m_cssAgent->reset();
534         }
535 #if ENABLE(WORKERS)
536         m_workers.clear();
537 #endif
538 #if ENABLE(DATABASE)
539         InspectorDatabaseAgent::clear(this);
540 #endif
541 #if ENABLE(DOM_STORAGE)
542         InspectorDOMStorageAgent::clear(this);
543 #endif
544
545         if (InspectorDOMAgent* domAgent = m_instrumentingAgents->inspectorDOMAgent())
546             domAgent->setDocument(m_inspectedPage->mainFrame()->document());
547     }
548 }
549
550 void InspectorAgent::domContentLoadedEventFired(DocumentLoader* loader, const KURL& url)
551 {
552     if (!enabled() || !isMainResourceLoader(loader, url))
553         return;
554
555     if (InspectorDOMAgent* domAgent = m_instrumentingAgents->inspectorDOMAgent())
556         domAgent->mainFrameDOMContentLoaded();
557     if (m_timelineAgent)
558         m_timelineAgent->didMarkDOMContentEvent();
559     if (m_frontend)
560         m_frontend->domContentEventFired(currentTime());
561 }
562
563 void InspectorAgent::loadEventFired(DocumentLoader* loader, const KURL& url)
564 {
565     if (!enabled())
566         return;
567
568     if (InspectorDOMAgent* domAgent = m_instrumentingAgents->inspectorDOMAgent())
569         domAgent->loadEventFired(loader->frame()->document());
570
571     if (!isMainResourceLoader(loader, url))
572         return;
573
574     if (m_timelineAgent)
575         m_timelineAgent->didMarkLoadEvent();
576     if (m_frontend)
577         m_frontend->loadEventFired(currentTime());
578 }
579
580 bool InspectorAgent::isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl)
581 {
582     return loader->frame() == m_inspectedPage->mainFrame() && requestUrl == loader->requestURL();
583 }
584
585 void InspectorAgent::setUserAgentOverride(const String& userAgent)
586 {
587     m_userAgentOverride = userAgent;
588 }
589
590 void InspectorAgent::applyUserAgentOverride(String* userAgent) const
591 {
592     if (!m_userAgentOverride.isEmpty())
593         *userAgent = m_userAgentOverride;
594 }
595
596 void InspectorAgent::startTimelineProfiler()
597 {
598     if (m_timelineAgent || !enabled() || !m_frontend)
599         return;
600
601     m_timelineAgent = InspectorTimelineAgent::create(m_state.get(), m_frontend);
602 }
603
604 void InspectorAgent::stopTimelineProfiler()
605 {
606     m_timelineAgent.clear();
607 }
608
609 #if ENABLE(WORKERS)
610 class PostWorkerNotificationToFrontendTask : public ScriptExecutionContext::Task {
611 public:
612     static PassOwnPtr<PostWorkerNotificationToFrontendTask> create(PassRefPtr<InspectorWorkerResource> worker, InspectorAgent::WorkerAction action)
613     {
614         return new PostWorkerNotificationToFrontendTask(worker, action);
615     }
616
617 private:
618     PostWorkerNotificationToFrontendTask(PassRefPtr<InspectorWorkerResource> worker, InspectorAgent::WorkerAction action)
619         : m_worker(worker)
620         , m_action(action)
621     {
622     }
623
624     virtual void performTask(ScriptExecutionContext* scriptContext)
625     {
626         if (scriptContext->isDocument()) {
627             if (InspectorAgent* inspectorAgent = static_cast<Document*>(scriptContext)->page()->inspectorController()->m_inspectorAgent.get())
628                 inspectorAgent->postWorkerNotificationToFrontend(*m_worker, m_action);
629         }
630     }
631
632 private:
633     RefPtr<InspectorWorkerResource> m_worker;
634     InspectorAgent::WorkerAction m_action;
635 };
636
637 void InspectorAgent::postWorkerNotificationToFrontend(const InspectorWorkerResource& worker, InspectorAgent::WorkerAction action)
638 {
639     if (!m_frontend)
640         return;
641 #if ENABLE(JAVASCRIPT_DEBUGGER)
642     switch (action) {
643     case InspectorAgent::WorkerCreated:
644         m_frontend->didCreateWorker(worker.id(), worker.url(), worker.isSharedWorker());
645         break;
646     case InspectorAgent::WorkerDestroyed:
647         m_frontend->didDestroyWorker(worker.id());
648         break;
649     }
650 #endif
651 }
652
653 void InspectorAgent::didCreateWorker(intptr_t id, const String& url, bool isSharedWorker)
654 {
655     if (!enabled())
656         return;
657
658     RefPtr<InspectorWorkerResource> workerResource(InspectorWorkerResource::create(id, url, isSharedWorker));
659     m_workers.set(id, workerResource);
660     if (m_inspectedPage && m_frontend)
661         m_inspectedPage->mainFrame()->document()->postTask(PostWorkerNotificationToFrontendTask::create(workerResource, InspectorAgent::WorkerCreated));
662 }
663
664 void InspectorAgent::didDestroyWorker(intptr_t id)
665 {
666     if (!enabled())
667         return;
668
669     WorkersMap::iterator workerResource = m_workers.find(id);
670     if (workerResource == m_workers.end())
671         return;
672     if (m_inspectedPage && m_frontend)
673         m_inspectedPage->mainFrame()->document()->postTask(PostWorkerNotificationToFrontendTask::create(workerResource->second, InspectorAgent::WorkerDestroyed));
674     m_workers.remove(workerResource);
675 }
676 #endif // ENABLE(WORKERS)
677
678 void InspectorAgent::getCookies(RefPtr<InspectorArray>* cookies, WTF::String* cookiesString)
679 {
680     // If we can get raw cookies.
681     ListHashSet<Cookie> rawCookiesList;
682
683     // If we can't get raw cookies - fall back to String representation
684     String stringCookiesList;
685
686     // Return value to getRawCookies should be the same for every call because
687     // the return value is platform/network backend specific, and the call will
688     // always return the same true/false value.
689     bool rawCookiesImplemented = false;
690
691     for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree()->traverseNext(m_inspectedPage->mainFrame())) {
692         Document* document = frame->document();
693         const CachedResourceLoader::DocumentResourceMap& allResources = document->cachedResourceLoader()->allCachedResources();
694         CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
695         for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
696             Vector<Cookie> docCookiesList;
697             rawCookiesImplemented = getRawCookies(document, KURL(ParsedURLString, it->second->url()), docCookiesList);
698
699             if (!rawCookiesImplemented) {
700                 // FIXME: We need duplication checking for the String representation of cookies.
701                 ExceptionCode ec = 0;
702                 stringCookiesList += document->cookie(ec);
703                 // Exceptions are thrown by cookie() in sandboxed frames. That won't happen here
704                 // because "document" is the document of the main frame of the page.
705                 ASSERT(!ec);
706             } else {
707                 int cookiesSize = docCookiesList.size();
708                 for (int i = 0; i < cookiesSize; i++) {
709                     if (!rawCookiesList.contains(docCookiesList[i]))
710                         rawCookiesList.add(docCookiesList[i]);
711                 }
712             }
713         }
714     }
715
716     if (rawCookiesImplemented)
717         *cookies = buildArrayForCookies(rawCookiesList);
718     else
719         *cookiesString = stringCookiesList;
720 }
721
722 PassRefPtr<InspectorArray> InspectorAgent::buildArrayForCookies(ListHashSet<Cookie>& cookiesList)
723 {
724     RefPtr<InspectorArray> cookies = InspectorArray::create();
725
726     ListHashSet<Cookie>::iterator end = cookiesList.end();
727     ListHashSet<Cookie>::iterator it = cookiesList.begin();
728     for (int i = 0; it != end; ++it, i++)
729         cookies->pushObject(buildObjectForCookie(*it));
730
731     return cookies;
732 }
733
734 PassRefPtr<InspectorObject> InspectorAgent::buildObjectForCookie(const Cookie& cookie)
735 {
736     RefPtr<InspectorObject> value = InspectorObject::create();
737     value->setString("name", cookie.name);
738     value->setString("value", cookie.value);
739     value->setString("domain", cookie.domain);
740     value->setString("path", cookie.path);
741     value->setNumber("expires", cookie.expires);
742     value->setNumber("size", (cookie.name.length() + cookie.value.length()));
743     value->setBoolean("httpOnly", cookie.httpOnly);
744     value->setBoolean("secure", cookie.secure);
745     value->setBoolean("session", cookie.session);
746     return value;
747 }
748
749 void InspectorAgent::deleteCookie(const String& cookieName, const String& domain)
750 {
751     for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree()->traverseNext(m_inspectedPage->mainFrame())) {
752         Document* document = frame->document();
753         if (document->url().host() != domain)
754             continue;
755         const CachedResourceLoader::DocumentResourceMap& allResources = document->cachedResourceLoader()->allCachedResources();
756         CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
757         for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it)
758             WebCore::deleteCookie(document, KURL(ParsedURLString, it->second->url()), cookieName);
759     }
760 }
761
762 #if ENABLE(WEB_SOCKETS)
763 void InspectorAgent::didCreateWebSocket(unsigned long identifier, const KURL& requestURL, const KURL& documentURL)
764 {
765     if (!enabled())
766         return;
767     ASSERT(m_inspectedPage);
768
769     if (m_resourceAgent)
770         m_resourceAgent->didCreateWebSocket(identifier, requestURL);
771     UNUSED_PARAM(documentURL);
772 }
773
774 void InspectorAgent::willSendWebSocketHandshakeRequest(unsigned long identifier, const WebSocketHandshakeRequest& request)
775 {
776     if (m_resourceAgent)
777         m_resourceAgent->willSendWebSocketHandshakeRequest(identifier, request);
778 }
779
780 void InspectorAgent::didReceiveWebSocketHandshakeResponse(unsigned long identifier, const WebSocketHandshakeResponse& response)
781 {
782     if (m_resourceAgent)
783         m_resourceAgent->didReceiveWebSocketHandshakeResponse(identifier, response);
784 }
785
786 void InspectorAgent::didCloseWebSocket(unsigned long identifier)
787 {
788     if (m_resourceAgent)
789         m_resourceAgent->didCloseWebSocket(identifier);
790 }
791 #endif // ENABLE(WEB_SOCKETS)
792
793 #if ENABLE(JAVASCRIPT_DEBUGGER)
794 bool InspectorAgent::isRecordingUserInitiatedProfile() const
795 {
796     return m_profilerAgent->isRecordingUserInitiatedProfile();
797 }
798
799 void InspectorAgent::startUserInitiatedProfiling()
800 {
801     if (!enabled())
802         return;
803     m_profilerAgent->startUserInitiatedProfiling();
804     m_state->setBoolean(InspectorAgentState::userInitiatedProfiling, true);
805 }
806
807 void InspectorAgent::stopUserInitiatedProfiling()
808 {
809     m_profilerAgent->stopUserInitiatedProfiling();
810     m_state->setBoolean(InspectorAgentState::userInitiatedProfiling, false);
811     showPanel(profilesPanelName);
812 }
813
814 bool InspectorAgent::profilerEnabled() const
815 {
816     return enabled() && m_profilerAgent->enabled();
817 }
818
819 void InspectorAgent::enableProfiler()
820 {
821     if (profilerEnabled())
822         return;
823     m_state->setBoolean(InspectorAgentState::profilerEnabled, true);
824     m_profilerAgent->enable(false);
825 }
826
827 void InspectorAgent::disableProfiler()
828 {
829     m_state->setBoolean(InspectorAgentState::profilerEnabled, false);
830     m_profilerAgent->disable();
831 }
832 #endif
833
834 #if ENABLE(JAVASCRIPT_DEBUGGER)
835 void InspectorAgent::startUserInitiatedDebugging()
836 {
837     if (debuggerEnabled())
838         return;
839
840     showPanel(scriptsPanelName);
841     if (!m_frontend) {
842         // We are called after show(), set the debuggerEnabled flag so that it was enabled
843         // upon frontend opening.
844         m_state->setBoolean(InspectorAgentState::debuggerEnabled, true);
845     } else
846         enableDebugger(true);
847 }
848
849 void InspectorAgent::enableDebugger(bool eraseStickyBreakpoints)
850 {
851     if (debuggerEnabled())
852         return;
853     m_state->setBoolean(InspectorAgentState::debuggerEnabled, true);
854     ASSERT(m_inspectedPage);
855
856     m_debuggerAgent = InspectorDebuggerAgent::create(this, m_frontend, eraseStickyBreakpoints);
857     m_browserDebuggerAgent = InspectorBrowserDebuggerAgent::create(this, eraseStickyBreakpoints);
858
859     m_frontend->debuggerWasEnabled();
860 }
861
862 void InspectorAgent::disableDebugger()
863 {
864     if (!enabled())
865         return;
866     ASSERT(m_inspectedPage);
867     m_debuggerAgent.clear();
868     m_browserDebuggerAgent.clear();
869
870     if (m_frontend) {
871         m_frontend->debuggerWasDisabled();
872         m_state->setBoolean(InspectorAgentState::debuggerEnabled, false);
873     }
874 }
875
876 void InspectorAgent::resume()
877 {
878     if (m_debuggerAgent)
879         m_debuggerAgent->resume();
880 }
881 #endif
882
883 void InspectorAgent::evaluateForTestInFrontend(long callId, const String& script)
884 {
885     if (m_frontend)
886         m_frontend->evaluateForTestInFrontend(callId, script);
887     else
888         m_pendingEvaluateTestCommands.append(pair<long, String>(callId, script));
889 }
890
891 void InspectorAgent::didEvaluateForTestInFrontend(long callId, const String& jsonResult)
892 {
893     ScriptState* scriptState = scriptStateFromPage(debuggerWorld(), m_inspectedPage);
894     ScriptObject window;
895     ScriptGlobalObject::get(scriptState, "window", window);
896     ScriptFunctionCall function(window, "didEvaluateForTestInFrontend");
897     function.appendArgument(callId);
898     function.appendArgument(jsonResult);
899     function.call();
900 }
901
902 static Path quadToPath(const FloatQuad& quad)
903 {
904     Path quadPath;
905     quadPath.moveTo(quad.p1());
906     quadPath.addLineTo(quad.p2());
907     quadPath.addLineTo(quad.p3());
908     quadPath.addLineTo(quad.p4());
909     quadPath.closeSubpath();
910     return quadPath;
911 }
912
913 static void drawOutlinedQuad(GraphicsContext& context, const FloatQuad& quad, const Color& fillColor)
914 {
915     static const int outlineThickness = 2;
916     static const Color outlineColor(62, 86, 180, 228);
917
918     Path quadPath = quadToPath(quad);
919
920     // Clip out the quad, then draw with a 2px stroke to get a pixel
921     // of outline (because inflating a quad is hard)
922     {
923         context.save();
924         context.clipOut(quadPath);
925
926         context.setStrokeThickness(outlineThickness);
927         context.setStrokeColor(outlineColor, ColorSpaceDeviceRGB);
928         context.strokePath(quadPath);
929
930         context.restore();
931     }
932
933     // Now do the fill
934     context.setFillColor(fillColor, ColorSpaceDeviceRGB);
935     context.fillPath(quadPath);
936 }
937
938 static void drawOutlinedQuadWithClip(GraphicsContext& context, const FloatQuad& quad, const FloatQuad& clipQuad, const Color& fillColor)
939 {
940     context.save();
941     Path clipQuadPath = quadToPath(clipQuad);
942     context.clipOut(clipQuadPath);
943     drawOutlinedQuad(context, quad, fillColor);
944     context.restore();
945 }
946
947 static void drawHighlightForBox(GraphicsContext& context, const FloatQuad& contentQuad, const FloatQuad& paddingQuad, const FloatQuad& borderQuad, const FloatQuad& marginQuad)
948 {
949     static const Color contentBoxColor(125, 173, 217, 128);
950     static const Color paddingBoxColor(125, 173, 217, 160);
951     static const Color borderBoxColor(125, 173, 217, 192);
952     static const Color marginBoxColor(125, 173, 217, 228);
953
954     if (marginQuad != borderQuad)
955         drawOutlinedQuadWithClip(context, marginQuad, borderQuad, marginBoxColor);
956     if (borderQuad != paddingQuad)
957         drawOutlinedQuadWithClip(context, borderQuad, paddingQuad, borderBoxColor);
958     if (paddingQuad != contentQuad)
959         drawOutlinedQuadWithClip(context, paddingQuad, contentQuad, paddingBoxColor);
960
961     drawOutlinedQuad(context, contentQuad, contentBoxColor);
962 }
963
964 static void drawHighlightForLineBoxesOrSVGRenderer(GraphicsContext& context, const Vector<FloatQuad>& lineBoxQuads)
965 {
966     static const Color lineBoxColor(125, 173, 217, 128);
967
968     for (size_t i = 0; i < lineBoxQuads.size(); ++i)
969         drawOutlinedQuad(context, lineBoxQuads[i], lineBoxColor);
970 }
971
972 static inline void convertFromFrameToMainFrame(Frame* frame, IntRect& rect)
973 {
974     rect = frame->page()->mainFrame()->view()->windowToContents(frame->view()->contentsToWindow(rect));
975 }
976
977 static inline IntSize frameToMainFrameOffset(Frame* frame)
978 {
979     IntPoint mainFramePoint = frame->page()->mainFrame()->view()->windowToContents(frame->view()->contentsToWindow(IntPoint()));
980     return mainFramePoint - IntPoint();
981 }
982
983 void InspectorAgent::drawNodeHighlight(GraphicsContext& context) const
984 {
985     if (!m_highlightedNode)
986         return;
987
988     RenderObject* renderer = m_highlightedNode->renderer();
989     Frame* containingFrame = m_highlightedNode->document()->frame();
990     if (!renderer || !containingFrame)
991         return;
992
993     IntSize mainFrameOffset = frameToMainFrameOffset(containingFrame);
994     IntRect boundingBox = renderer->absoluteBoundingBoxRect(true);
995     boundingBox.move(mainFrameOffset);
996
997     IntRect titleReferenceBox = boundingBox;
998
999     ASSERT(m_inspectedPage);
1000
1001     FrameView* view = m_inspectedPage->mainFrame()->view();
1002     FloatRect overlayRect = view->visibleContentRect();
1003     if (!overlayRect.contains(boundingBox) && !boundingBox.contains(enclosingIntRect(overlayRect)))
1004         overlayRect = view->visibleContentRect();
1005     context.translate(-overlayRect.x(), -overlayRect.y());
1006
1007     // RenderSVGRoot should be highlighted through the isBox() code path, all other SVG elements should just dump their absoluteQuads().
1008 #if ENABLE(SVG)
1009     bool isSVGRenderer = renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVGRoot();
1010 #else
1011     bool isSVGRenderer = false;
1012 #endif
1013
1014     if (renderer->isBox() && !isSVGRenderer) {
1015         RenderBox* renderBox = toRenderBox(renderer);
1016
1017         IntRect contentBox = renderBox->contentBoxRect();
1018
1019         IntRect paddingBox(contentBox.x() - renderBox->paddingLeft(), contentBox.y() - renderBox->paddingTop(),
1020                            contentBox.width() + renderBox->paddingLeft() + renderBox->paddingRight(), contentBox.height() + renderBox->paddingTop() + renderBox->paddingBottom());
1021         IntRect borderBox(paddingBox.x() - renderBox->borderLeft(), paddingBox.y() - renderBox->borderTop(),
1022                           paddingBox.width() + renderBox->borderLeft() + renderBox->borderRight(), paddingBox.height() + renderBox->borderTop() + renderBox->borderBottom());
1023         IntRect marginBox(borderBox.x() - renderBox->marginLeft(), borderBox.y() - renderBox->marginTop(),
1024                           borderBox.width() + renderBox->marginLeft() + renderBox->marginRight(), borderBox.height() + renderBox->marginTop() + renderBox->marginBottom());
1025
1026
1027         FloatQuad absContentQuad = renderBox->localToAbsoluteQuad(FloatRect(contentBox));
1028         FloatQuad absPaddingQuad = renderBox->localToAbsoluteQuad(FloatRect(paddingBox));
1029         FloatQuad absBorderQuad = renderBox->localToAbsoluteQuad(FloatRect(borderBox));
1030         FloatQuad absMarginQuad = renderBox->localToAbsoluteQuad(FloatRect(marginBox));
1031
1032         absContentQuad.move(mainFrameOffset);
1033         absPaddingQuad.move(mainFrameOffset);
1034         absBorderQuad.move(mainFrameOffset);
1035         absMarginQuad.move(mainFrameOffset);
1036
1037         titleReferenceBox = absMarginQuad.enclosingBoundingBox();
1038
1039         drawHighlightForBox(context, absContentQuad, absPaddingQuad, absBorderQuad, absMarginQuad);
1040     } else if (renderer->isRenderInline() || isSVGRenderer) {
1041         // FIXME: We should show margins/padding/border for inlines.
1042         Vector<FloatQuad> lineBoxQuads;
1043         renderer->absoluteQuads(lineBoxQuads);
1044         for (unsigned i = 0; i < lineBoxQuads.size(); ++i)
1045             lineBoxQuads[i] += mainFrameOffset;
1046
1047         drawHighlightForLineBoxesOrSVGRenderer(context, lineBoxQuads);
1048     }
1049
1050     // Draw node title if necessary.
1051
1052     if (!m_highlightedNode->isElementNode())
1053         return;
1054
1055     WebCore::Settings* settings = containingFrame->settings();
1056     drawElementTitle(context, titleReferenceBox, overlayRect, settings);
1057 }
1058
1059 void InspectorAgent::drawElementTitle(GraphicsContext& context, const IntRect& boundingBox, const FloatRect& overlayRect, WebCore::Settings* settings) const
1060 {
1061     static const int rectInflatePx = 4;
1062     static const int fontHeightPx = 12;
1063     static const int borderWidthPx = 1;
1064     static const Color tooltipBackgroundColor(255, 255, 194, 255);
1065     static const Color tooltipBorderColor(Color::black);
1066     static const Color tooltipFontColor(Color::black);
1067
1068     Element* element = static_cast<Element*>(m_highlightedNode.get());
1069     bool isXHTML = element->document()->isXHTMLDocument();
1070     String nodeTitle = isXHTML ? element->nodeName() : element->nodeName().lower();
1071     const AtomicString& idValue = element->getIdAttribute();
1072     if (!idValue.isNull() && !idValue.isEmpty()) {
1073         nodeTitle += "#";
1074         nodeTitle += idValue;
1075     }
1076     if (element->hasClass() && element->isStyledElement()) {
1077         const SpaceSplitString& classNamesString = static_cast<StyledElement*>(element)->classNames();
1078         size_t classNameCount = classNamesString.size();
1079         if (classNameCount) {
1080             HashSet<AtomicString> usedClassNames;
1081             for (size_t i = 0; i < classNameCount; ++i) {
1082                 const AtomicString& className = classNamesString[i];
1083                 if (usedClassNames.contains(className))
1084                     continue;
1085                 usedClassNames.add(className);
1086                 nodeTitle += ".";
1087                 nodeTitle += className;
1088             }
1089         }
1090     }
1091
1092     Element* highlightedElement = m_highlightedNode->isElementNode() ? static_cast<Element*>(m_highlightedNode.get()) : 0;
1093     nodeTitle += " [";
1094     nodeTitle += String::number(highlightedElement ? highlightedElement->offsetWidth() : boundingBox.width());
1095     nodeTitle.append(static_cast<UChar>(0x00D7)); // &times;
1096     nodeTitle += String::number(highlightedElement ? highlightedElement->offsetHeight() : boundingBox.height());
1097     nodeTitle += "]";
1098
1099     FontDescription desc;
1100     FontFamily family;
1101     family.setFamily(settings->fixedFontFamily());
1102     desc.setFamily(family);
1103     desc.setComputedSize(fontHeightPx);
1104     Font font = Font(desc, 0, 0);
1105     font.update(0);
1106
1107     TextRun nodeTitleRun(nodeTitle);
1108     IntPoint titleBasePoint = IntPoint(boundingBox.x(), boundingBox.maxY() - 1);
1109     titleBasePoint.move(rectInflatePx, rectInflatePx);
1110     IntRect titleRect = enclosingIntRect(font.selectionRectForText(nodeTitleRun, titleBasePoint, fontHeightPx));
1111     titleRect.inflate(rectInflatePx);
1112
1113     // The initial offsets needed to compensate for a 1px-thick border stroke (which is not a part of the rectangle).
1114     int dx = -borderWidthPx;
1115     int dy = borderWidthPx;
1116
1117     // If the tip sticks beyond the right of overlayRect, right-align the tip with the said boundary.
1118     if (titleRect.maxX() > overlayRect.maxX())
1119         dx = overlayRect.maxX() - titleRect.maxX();
1120
1121     // If the tip sticks beyond the left of overlayRect, left-align the tip with the said boundary.
1122     if (titleRect.x() + dx < overlayRect.x())
1123         dx = overlayRect.x() - titleRect.x() - borderWidthPx;
1124
1125     // If the tip sticks beyond the bottom of overlayRect, show the tip at top of bounding box.
1126     if (titleRect.maxY() > overlayRect.maxY()) {
1127         dy = boundingBox.y() - titleRect.maxY() - borderWidthPx;
1128         // If the tip still sticks beyond the bottom of overlayRect, bottom-align the tip with the said boundary.
1129         if (titleRect.maxY() + dy > overlayRect.maxY())
1130             dy = overlayRect.maxY() - titleRect.maxY();
1131     }
1132
1133     // If the tip sticks beyond the top of overlayRect, show the tip at top of overlayRect.
1134     if (titleRect.y() + dy < overlayRect.y())
1135         dy = overlayRect.y() - titleRect.y() + borderWidthPx;
1136
1137     titleRect.move(dx, dy);
1138     context.setStrokeColor(tooltipBorderColor, ColorSpaceDeviceRGB);
1139     context.setStrokeThickness(borderWidthPx);
1140     context.setFillColor(tooltipBackgroundColor, ColorSpaceDeviceRGB);
1141     context.drawRect(titleRect);
1142     context.setFillColor(tooltipFontColor, ColorSpaceDeviceRGB);
1143     context.drawText(font, nodeTitleRun, IntPoint(titleRect.x() + rectInflatePx, titleRect.y() + font.fontMetrics().height()));
1144 }
1145
1146 void InspectorAgent::openInInspectedWindow(const String& url)
1147 {
1148     Frame* mainFrame = m_inspectedPage->mainFrame();
1149
1150     FrameLoadRequest request(mainFrame->document()->securityOrigin(), ResourceRequest(), "_blank");
1151
1152     bool created;
1153     WindowFeatures windowFeatures;
1154     Frame* newFrame = WebCore::createWindow(mainFrame, mainFrame, request, windowFeatures, created);
1155     if (!newFrame)
1156         return;
1157
1158     UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
1159     newFrame->loader()->setOpener(mainFrame);
1160     newFrame->page()->setOpenedByDOM();
1161     newFrame->loader()->changeLocation(mainFrame->document()->securityOrigin(), newFrame->loader()->completeURL(url), "", false, false);
1162 }
1163
1164 void InspectorAgent::addScriptToEvaluateOnLoad(const String& source)
1165 {
1166     m_scriptsToEvaluateOnLoad.append(source);
1167 }
1168
1169 void InspectorAgent::removeAllScriptsToEvaluateOnLoad()
1170 {
1171     m_scriptsToEvaluateOnLoad.clear();
1172 }
1173
1174 void InspectorAgent::setInspectorExtensionAPI(const String& source)
1175 {
1176     m_inspectorExtensionAPI = source;
1177 }
1178
1179 KURL InspectorAgent::inspectedURL() const
1180 {
1181     return m_inspectedPage->mainFrame()->document()->url();
1182 }
1183
1184 KURL InspectorAgent::inspectedURLWithoutFragment() const
1185 {
1186     KURL url = inspectedURL();
1187     url.removeFragmentIdentifier();
1188     return url;
1189 }
1190
1191 void InspectorAgent::reloadPage(bool ignoreCache)
1192 {
1193     m_inspectedPage->mainFrame()->loader()->reload(ignoreCache);
1194 }
1195
1196 bool InspectorAgent::enabled() const
1197 {
1198     if (!m_inspectedPage)
1199         return false;
1200     return m_inspectedPage->settings()->developerExtrasEnabled();
1201 }
1202
1203 void InspectorAgent::showConsole()
1204 {
1205     showPanel(consolePanelName);
1206 }
1207
1208 void InspectorAgent::showPanel(const String& panel)
1209 {
1210     if (!m_frontend) {
1211         m_showPanelAfterVisible = panel;
1212         return;
1213     }
1214     m_frontend->showPanel(panel);
1215 }
1216
1217 } // namespace WebCore
1218
1219 #endif // ENABLE(INSPECTOR)