diff options
author | Ben Murdoch <benm@google.com> | 2011-05-13 16:23:25 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-16 11:35:02 +0100 |
commit | 65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch) | |
tree | f478babb801e720de7bfaee23443ffe029f58731 /Source/WebCore/inspector | |
parent | 47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff) | |
download | external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2 |
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebCore/inspector')
74 files changed, 2768 insertions, 1620 deletions
diff --git a/Source/WebCore/inspector/CodeGeneratorInspector.pm b/Source/WebCore/inspector/CodeGeneratorInspector.pm index b8aea0e..b7be15e 100644 --- a/Source/WebCore/inspector/CodeGeneratorInspector.pm +++ b/Source/WebCore/inspector/CodeGeneratorInspector.pm @@ -20,11 +20,21 @@ $typeTransform{"CSS"} = { "header" => "InspectorCSSAgent.h", "domainAccessor" => "m_inspectorController->m_cssAgent", }; +$typeTransform{"Console"} = { + "forward" => "InspectorConsoleAgent", + "header" => "InspectorConsoleAgent.h", + "domainAccessor" => "m_inspectorController->m_consoleAgent", +}; $typeTransform{"Debugger"} = { "forward" => "InspectorDebuggerAgent", "header" => "InspectorDebuggerAgent.h", "domainAccessor" => "m_inspectorController->m_debuggerAgent", }; +$typeTransform{"BrowserDebugger"} = { + "forward" => "InspectorBrowserDebuggerAgent", + "header" => "InspectorBrowserDebuggerAgent.h", + "domainAccessor" => "m_inspectorController->m_browserDebuggerAgent", +}; $typeTransform{"Database"} = { "forward" => "InspectorDatabaseAgent", "header" => "InspectorDatabaseAgent.h", diff --git a/Source/WebCore/inspector/ConsoleMessage.cpp b/Source/WebCore/inspector/ConsoleMessage.cpp index b22a6ef..8d56a5a 100644 --- a/Source/WebCore/inspector/ConsoleMessage.cpp +++ b/Source/WebCore/inspector/ConsoleMessage.cpp @@ -82,6 +82,10 @@ ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, c { } +ConsoleMessage::~ConsoleMessage() +{ +} + void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost) { RefPtr<InspectorObject> jsonObj = InspectorObject::create(); diff --git a/Source/WebCore/inspector/ConsoleMessage.h b/Source/WebCore/inspector/ConsoleMessage.h index 06a17d4..310aa8e 100644 --- a/Source/WebCore/inspector/ConsoleMessage.h +++ b/Source/WebCore/inspector/ConsoleMessage.h @@ -51,6 +51,7 @@ public: ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u); ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>); ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, const String& responseUrl, unsigned long identifier); + ~ConsoleMessage(); void addToFrontend(InspectorFrontend*, InjectedScriptHost*); void updateRepeatCountInConsole(InspectorFrontend* frontend); diff --git a/Source/WebCore/inspector/InjectedScriptHost.cpp b/Source/WebCore/inspector/InjectedScriptHost.cpp index a4a0c6f..3fd70e4 100644 --- a/Source/WebCore/inspector/InjectedScriptHost.cpp +++ b/Source/WebCore/inspector/InjectedScriptHost.cpp @@ -30,6 +30,7 @@ #include "config.h" #include "InjectedScriptHost.h" +#include "InjectedScriptSource.h" #include "InspectorDatabaseAgent.h" #include "InspectorDOMStorageAgent.h" @@ -42,6 +43,7 @@ #include "HTMLFrameOwnerElement.h" #include "InjectedScript.h" #include "InspectorClient.h" +#include "InspectorConsoleAgent.h" #include "InspectorController.h" #include "InspectorDOMAgent.h" #include "InspectorFrontend.h" @@ -82,7 +84,7 @@ InjectedScriptHost::~InjectedScriptHost() void InjectedScriptHost::clearConsoleMessages() { if (m_inspectorController) - m_inspectorController->clearConsoleMessages(); + m_inspectorController->consoleAgent()->clearConsoleMessages(); } void InjectedScriptHost::copyText(const String& text) @@ -182,6 +184,11 @@ InspectorFrontend* InjectedScriptHost::frontend() return m_inspectorController->m_frontend.get(); } +String InjectedScriptHost::injectedScriptSource() +{ + return String(reinterpret_cast<char*>(InjectedScriptSource_js), sizeof(InjectedScriptSource_js)); +} + pair<long, ScriptObject> InjectedScriptHost::injectScript(const String& source, ScriptState* scriptState) { long id = m_nextInjectedScriptId++; diff --git a/Source/WebCore/inspector/InjectedScriptHost.h b/Source/WebCore/inspector/InjectedScriptHost.h index 6b70f62..e9c09aa 100644 --- a/Source/WebCore/inspector/InjectedScriptHost.h +++ b/Source/WebCore/inspector/InjectedScriptHost.h @@ -58,9 +58,6 @@ public: ~InjectedScriptHost(); - String injectedScriptSource() { return m_injectedScriptSource; } - void setInjectedScriptSource(const String& source) { m_injectedScriptSource = source; } - InspectorController* inspectorController() { return m_inspectorController; } void disconnectController() { m_inspectorController = 0; } @@ -96,11 +93,11 @@ private: InjectedScriptHost(InspectorController* inspectorController); InspectorDOMAgent* inspectorDOMAgent(); InspectorFrontend* frontend(); + String injectedScriptSource(); ScriptObject createInjectedScript(const String& source, ScriptState* scriptState, long id); void discardInjectedScript(ScriptState*); InspectorController* m_inspectorController; - String m_injectedScriptSource; long m_nextInjectedScriptId; long m_lastWorkerId; typedef HashMap<long, InjectedScript> IdToInjectedScriptMap; diff --git a/Source/WebCore/inspector/front-end/InjectedScript.js b/Source/WebCore/inspector/InjectedScriptSource.js index fb6b796..90797fb 100644 --- a/Source/WebCore/inspector/front-end/InjectedScript.js +++ b/Source/WebCore/inspector/InjectedScriptSource.js @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var injectedScriptConstructor = (function (InjectedScriptHost, inspectedWindow, injectedScriptId) { +(function (InjectedScriptHost, inspectedWindow, injectedScriptId) { var InjectedScript = function() { @@ -713,4 +713,5 @@ CommandLineAPI.prototype = { injectedScript._commandLineAPI = new CommandLineAPI(); return injectedScript; -}); +}) + diff --git a/Source/WebCore/inspector/Inspector.idl b/Source/WebCore/inspector/Inspector.idl index 7b2d7e2..6c2cc2e 100644 --- a/Source/WebCore/inspector/Inspector.idl +++ b/Source/WebCore/inspector/Inspector.idl @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Apple Inc. All rights reserved. - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -37,7 +37,6 @@ module core { /////////////////////////////////////////////////////////////////////// // HUGE FIXME: we need to expose InjectedScript methods here. Or document InjectedScript capabilities. - [domain=Inspector] void setInjectedScriptSource(in String scriptSource); [domain=Inspector] void dispatchOnInjectedScript(in long injectedScriptId, in String methodName, in String arguments, out Value result, out boolean isException); [domain=Inspector] void addScriptToEvaluateOnLoad(in String scriptSource); [domain=Inspector] void removeAllScriptsToEvaluateOnLoad(); @@ -49,6 +48,7 @@ module core { [domain=Inspector] void openInInspectedWindow(in String url); [domain=Inspector] void setSearchingForNode(in boolean enabled, out boolean newState); + [notify, domain=Inspector] void frontendReused(); [notify, domain=Inspector] void addNodesToSearchResult(out Array nodeIds); [notify, domain=Inspector] void bringToFront(); [notify, domain=Inspector] void disconnectFromBackend(); @@ -76,12 +76,12 @@ module core { // Console API /////////////////////////////////////////////////////////////////////// - [domain=Inspector] void setConsoleMessagesEnabled(in boolean enabled, out boolean newState); - [notify, domain=Inspector] void addConsoleMessage(out Object messageObj); - [notify, domain=Inspector] void updateConsoleMessageExpiredCount(out unsigned long count); - [notify, domain=Inspector] void updateConsoleMessageRepeatCount(out unsigned long count); - [domain=Inspector] void clearConsoleMessages(); - [notify, domain=Inspector] void consoleMessagesCleared(); + [domain=Console] void setConsoleMessagesEnabled(in boolean enabled, out boolean newState); + [notify, domain=Console] void addConsoleMessage(out Object messageObj); + [notify, domain=Console] void updateConsoleMessageExpiredCount(out unsigned long count); + [notify, domain=Console] void updateConsoleMessageRepeatCount(out unsigned long count); + [domain=Console] void clearConsoleMessages(); + [notify, domain=Console] void consoleMessagesCleared(); /////////////////////////////////////////////////////////////////////// // Network API @@ -186,7 +186,6 @@ module core { [notify, domain=DOM] void childNodeCountUpdated(out long id, out int newValue); [notify, domain=DOM] void childNodeInserted(out long parentId, out long prevId, out Object node); [notify, domain=DOM] void childNodeRemoved(out long parentId, out long id); - [notify, domain=DOM] void didCommitLoad(); /////////////////////////////////////////////////////////////////////// // CSS API @@ -222,14 +221,15 @@ module core { // Debugger API /////////////////////////////////////////////////////////////////////// - [domain=Inspector] void enableDebuggerFromFrontend(in boolean always); + [domain=Inspector] void enableDebugger(in boolean always); [domain=Inspector] void disableDebugger(in boolean always); + + [domain=Inspector] void setStickyBreakpoints(in Object breakpoints); + [notify, domain=Debugger] void debuggerWasEnabled(); [notify, domain=Debugger] void debuggerWasDisabled(); - [notify, domain=Debugger] void attachDebuggerWhenShown(); // FIXME: do something with this eventually. - - [notify, domain=Debugger] void parsedScriptSource(out String sourceID, out String url, out String data, out int firstLine, out int scriptWorldType); + [notify, domain=Debugger] void parsedScriptSource(out String sourceID, out String url, out int lineOffset, out int columnOffset, out int scriptWorldType); [notify, domain=Debugger] void failedToParseScriptSource(out String url, out String data, out int firstLine, out int errorLine, out String errorMessage); [domain=Debugger] void activateBreakpoints(); @@ -238,20 +238,16 @@ module core { [domain=Debugger] void setBreakpoint(in String sourceID, in unsigned int lineNumber, in String condition, in boolean enabled, out String breakpointId, out unsigned int actualLineNumber); [domain=Debugger] void removeBreakpoint(in String breakpointId); - [domain=Inspector] void setStickyBreakpoints(in Object breakpoints); // FIXME: Move to newly introduced BrowserDebugger. - - [domain=DOM] void setDOMBreakpoint(in long nodeId, in long type); // FIXME: Move to newly introduced BrowserDebugger. - [domain=DOM] void removeDOMBreakpoint(in long nodeId, in long type); // FIXME: Move to newly introduced BrowserDebugger. - - [domain=Inspector] void setEventListenerBreakpoint(in String eventName); // FIXME: Move to newly introduced BrowserDebugger. - [domain=Inspector] void removeEventListenerBreakpoint(in String eventName); // FIXME: Move to newly introduced BrowserDebugger. - - [domain=Inspector] void setXHRBreakpoint(in String url); // FIXME: Move to newly introduced BrowserDebugger. - [domain=Inspector] void removeXHRBreakpoint(in String url); // FIXME: Move to newly introduced BrowserDebugger. + [domain=BrowserDebugger] void setDOMBreakpoint(in long nodeId, in long type); + [domain=BrowserDebugger] void removeDOMBreakpoint(in long nodeId, in long type); + [domain=BrowserDebugger] void setEventListenerBreakpoint(in String eventName); + [domain=BrowserDebugger] void removeEventListenerBreakpoint(in String eventName); + [domain=BrowserDebugger] void setXHRBreakpoint(in String url); + [domain=BrowserDebugger] void removeXHRBreakpoint(in String url); - [domain=Debugger] void stepOverStatement(); // FIXME: rename to stepOver - [domain=Debugger] void stepIntoStatement(); // FIXME: rename to stepInto - [domain=Debugger] void stepOutOfFunction(); // FIXME: rename to stepOut + [domain=Debugger] void stepOver(); + [domain=Debugger] void stepInto(); + [domain=Debugger] void stepOut(); [domain=Debugger] void pause(); [notify, domain=Debugger] void pausedScript(out Object details); [domain=Debugger] void resume(); diff --git a/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp b/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp index ced61c5..1cca6fe 100644 --- a/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp +++ b/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp @@ -35,6 +35,7 @@ #include "InspectorController.h" #include "InspectorFrontend.h" #include "InspectorValues.h" +#include "NetworkStateNotifier.h" #include "Page.h" #include "ResourceResponse.h" @@ -46,18 +47,15 @@ InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InspectorControll { } -void InspectorApplicationCacheAgent::didReceiveManifestResponse(unsigned long identifier, const ResourceResponse& response) -{ - m_inspectorController->didReceiveResponse(identifier, 0, response); -} - -void InspectorApplicationCacheAgent::updateApplicationCacheStatus(ApplicationCacheHost::Status status) +void InspectorApplicationCacheAgent::updateApplicationCacheStatus(Frame* frame) { + ApplicationCacheHost::Status status = frame->loader()->documentLoader()->applicationCacheHost()->status(); m_frontend->updateApplicationCacheStatus(status); } -void InspectorApplicationCacheAgent::updateNetworkState(bool isNowOnline) +void InspectorApplicationCacheAgent::networkStateChanged() { + bool isNowOnline = networkStateNotifier().onLine(); m_frontend->updateNetworkState(isNowOnline); } diff --git a/Source/WebCore/inspector/InspectorApplicationCacheAgent.h b/Source/WebCore/inspector/InspectorApplicationCacheAgent.h index 11f10ce..3d9e494 100644 --- a/Source/WebCore/inspector/InspectorApplicationCacheAgent.h +++ b/Source/WebCore/inspector/InspectorApplicationCacheAgent.h @@ -33,6 +33,7 @@ namespace WebCore { +class Frame; class InspectorArray; class InspectorController; class InspectorFrontend; @@ -46,9 +47,8 @@ public: ~InspectorApplicationCacheAgent() { } // Backend to Frontend - void didReceiveManifestResponse(unsigned long identifier, const ResourceResponse&); - void updateApplicationCacheStatus(ApplicationCacheHost::Status); - void updateNetworkState(bool isNowOnline); + void updateApplicationCacheStatus(Frame*); + void networkStateChanged(); // From Frontend void getApplicationCaches(RefPtr<InspectorValue>* applicationCaches); diff --git a/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp new file mode 100644 index 0000000..a33bacc --- /dev/null +++ b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp @@ -0,0 +1,325 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "InspectorBrowserDebuggerAgent.h" + +#if ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER) + +#include "HTMLElement.h" +#include "InspectorController.h" +#include "InspectorDOMAgent.h" +#include "InspectorDebuggerAgent.h" +#include "InspectorState.h" +#include <wtf/text/CString.h> + +namespace { + +enum DOMBreakpointType { + SubtreeModified = 0, + AttributeModified, + NodeRemoved, + DOMBreakpointTypesCount +}; + +static const char* const domNativeBreakpointType = "DOM"; +static const char* const eventListenerNativeBreakpointType = "EventListener"; +static const char* const xhrNativeBreakpointType = "XHR"; + +const uint32_t inheritableDOMBreakpointTypesMask = (1 << SubtreeModified); +const int domBreakpointDerivedTypeShift = 16; + +} + +namespace WebCore { + +InspectorBrowserDebuggerAgent::InspectorBrowserDebuggerAgent(InspectorController* inspectorController) + : m_inspectorController(inspectorController) + , m_hasXHRBreakpointWithEmptyURL(false) +{ +} + +InspectorBrowserDebuggerAgent::~InspectorBrowserDebuggerAgent() +{ +} + +void InspectorBrowserDebuggerAgent::discardBindings() +{ + m_breakpoints.clear(); +} + +void InspectorBrowserDebuggerAgent::setEventListenerBreakpoint(const String& eventName) +{ + m_eventListenerBreakpoints.add(eventName); +} + +void InspectorBrowserDebuggerAgent::removeEventListenerBreakpoint(const String& eventName) +{ + m_eventListenerBreakpoints.remove(eventName); +} + +void InspectorBrowserDebuggerAgent::didInsertDOMNode(Node* node) +{ + if (m_breakpoints.size()) { + uint32_t mask = m_breakpoints.get(InspectorDOMAgent::innerParentNode(node)); + uint32_t inheritableTypesMask = (mask | (mask >> domBreakpointDerivedTypeShift)) & inheritableDOMBreakpointTypesMask; + if (inheritableTypesMask) + updateSubtreeBreakpoints(node, inheritableTypesMask, true); + } +} + +void InspectorBrowserDebuggerAgent::didRemoveDOMNode(Node* node) +{ + if (m_breakpoints.size()) { + // Remove subtree breakpoints. + m_breakpoints.remove(node); + Vector<Node*> stack(1, InspectorDOMAgent::innerFirstChild(node)); + do { + Node* node = stack.last(); + stack.removeLast(); + if (!node) + continue; + m_breakpoints.remove(node); + stack.append(InspectorDOMAgent::innerFirstChild(node)); + stack.append(InspectorDOMAgent::innerNextSibling(node)); + } while (!stack.isEmpty()); + } +} + +void InspectorBrowserDebuggerAgent::setDOMBreakpoint(long nodeId, long type) +{ + Node* node = m_inspectorController->m_domAgent->nodeForId(nodeId); + if (!node) + return; + + uint32_t rootBit = 1 << type; + m_breakpoints.set(node, m_breakpoints.get(node) | rootBit); + if (rootBit & inheritableDOMBreakpointTypesMask) { + for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child)) + updateSubtreeBreakpoints(child, rootBit, true); + } +} + +void InspectorBrowserDebuggerAgent::removeDOMBreakpoint(long nodeId, long type) +{ + Node* node = m_inspectorController->m_domAgent->nodeForId(nodeId); + if (!node) + return; + + uint32_t rootBit = 1 << type; + uint32_t mask = m_breakpoints.get(node) & ~rootBit; + if (mask) + m_breakpoints.set(node, mask); + else + m_breakpoints.remove(node); + + if ((rootBit & inheritableDOMBreakpointTypesMask) && !(mask & (rootBit << domBreakpointDerivedTypeShift))) { + for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child)) + updateSubtreeBreakpoints(child, rootBit, false); + } +} + +void InspectorBrowserDebuggerAgent::willInsertDOMNode(Node*, Node* parent) +{ + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + if (!debuggerAgent) + return; + + if (hasBreakpoint(parent, SubtreeModified)) { + RefPtr<InspectorObject> eventData = InspectorObject::create(); + descriptionForDOMEvent(parent, SubtreeModified, true, eventData.get()); + eventData->setString("breakpointType", domNativeBreakpointType); + debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release()); + } +} + +void InspectorBrowserDebuggerAgent::willRemoveDOMNode(Node* node) +{ + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + if (!debuggerAgent) + return; + + if (hasBreakpoint(node, NodeRemoved)) { + RefPtr<InspectorObject> eventData = InspectorObject::create(); + descriptionForDOMEvent(node, NodeRemoved, false, eventData.get()); + eventData->setString("breakpointType", domNativeBreakpointType); + debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release()); + } else if (hasBreakpoint(InspectorDOMAgent::innerParentNode(node), SubtreeModified)) { + RefPtr<InspectorObject> eventData = InspectorObject::create(); + descriptionForDOMEvent(node, SubtreeModified, false, eventData.get()); + eventData->setString("breakpointType", domNativeBreakpointType); + debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release()); + } +} + +void InspectorBrowserDebuggerAgent::willModifyDOMAttr(Element* element) +{ + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + if (!debuggerAgent) + return; + + if (hasBreakpoint(element, AttributeModified)) { + RefPtr<InspectorObject> eventData = InspectorObject::create(); + descriptionForDOMEvent(element, AttributeModified, false, eventData.get()); + eventData->setString("breakpointType", domNativeBreakpointType); + debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release()); + } +} + +void InspectorBrowserDebuggerAgent::descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, InspectorObject* description) +{ + ASSERT(hasBreakpoint(target, breakpointType)); + + Node* breakpointOwner = target; + if ((1 << breakpointType) & inheritableDOMBreakpointTypesMask) { + // For inheritable breakpoint types, target node isn't always the same as the node that owns a breakpoint. + // Target node may be unknown to frontend, so we need to push it first. + long targetNodeId = m_inspectorController->m_domAgent->pushNodePathToFrontend(target); + ASSERT(targetNodeId); + description->setNumber("targetNodeId", targetNodeId); + + // Find breakpoint owner node. + if (!insertion) + breakpointOwner = InspectorDOMAgent::innerParentNode(target); + ASSERT(breakpointOwner); + while (!(m_breakpoints.get(breakpointOwner) & (1 << breakpointType))) { + breakpointOwner = InspectorDOMAgent::innerParentNode(breakpointOwner); + ASSERT(breakpointOwner); + } + + if (breakpointType == SubtreeModified) + description->setBoolean("insertion", insertion); + } + + long breakpointOwnerNodeId = m_inspectorController->m_domAgent->pushNodePathToFrontend(breakpointOwner); + ASSERT(breakpointOwnerNodeId); + description->setNumber("nodeId", breakpointOwnerNodeId); + description->setNumber("type", breakpointType); +} + +bool InspectorBrowserDebuggerAgent::hasBreakpoint(Node* node, long type) +{ + uint32_t rootBit = 1 << type; + uint32_t derivedBit = rootBit << domBreakpointDerivedTypeShift; + return m_breakpoints.get(node) & (rootBit | derivedBit); +} + +void InspectorBrowserDebuggerAgent::updateSubtreeBreakpoints(Node* node, uint32_t rootMask, bool set) +{ + uint32_t oldMask = m_breakpoints.get(node); + uint32_t derivedMask = rootMask << domBreakpointDerivedTypeShift; + uint32_t newMask = set ? oldMask | derivedMask : oldMask & ~derivedMask; + if (newMask) + m_breakpoints.set(node, newMask); + else + m_breakpoints.remove(node); + + uint32_t newRootMask = rootMask & ~newMask; + if (!newRootMask) + return; + + for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child)) + updateSubtreeBreakpoints(child, newRootMask, set); +} + +void InspectorBrowserDebuggerAgent::pauseOnNativeEventIfNeeded(const String& categoryType, const String& eventName, bool synchronous) +{ + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + if (!debuggerAgent) + return; + + String fullEventName = String::format("%s:%s", categoryType.utf8().data(), eventName.utf8().data()); + if (!m_eventListenerBreakpoints.contains(fullEventName)) + return; + + RefPtr<InspectorObject> eventData = InspectorObject::create(); + eventData->setString("breakpointType", eventListenerNativeBreakpointType); + eventData->setString("eventName", fullEventName); + if (synchronous) + debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release()); + else + debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData.release()); +} + +void InspectorBrowserDebuggerAgent::setXHRBreakpoint(const String& url) +{ + if (url.isEmpty()) + m_hasXHRBreakpointWithEmptyURL = true; + else + m_XHRBreakpoints.add(url); +} + +void InspectorBrowserDebuggerAgent::removeXHRBreakpoint(const String& url) +{ + if (url.isEmpty()) + m_hasXHRBreakpointWithEmptyURL = false; + else + m_XHRBreakpoints.remove(url); +} + +void InspectorBrowserDebuggerAgent::willSendXMLHttpRequest(const String& url) +{ + InspectorDebuggerAgent* debuggerAgent = m_inspectorController->m_debuggerAgent.get(); + if (!debuggerAgent) + return; + + String breakpointURL; + if (m_hasXHRBreakpointWithEmptyURL) + breakpointURL = ""; + else { + for (HashSet<String>::iterator it = m_XHRBreakpoints.begin(); it != m_XHRBreakpoints.end(); ++it) { + if (url.contains(*it)) { + breakpointURL = *it; + break; + } + } + } + + if (breakpointURL.isNull()) + return; + + RefPtr<InspectorObject> eventData = InspectorObject::create(); + eventData->setString("breakpointType", xhrNativeBreakpointType); + eventData->setString("breakpointURL", breakpointURL); + eventData->setString("url", url); + debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release()); +} + +void InspectorBrowserDebuggerAgent::clearForPageNavigation() +{ + m_eventListenerBreakpoints.clear(); + m_XHRBreakpoints.clear(); + m_hasXHRBreakpointWithEmptyURL = false; +} + +} // namespace WebCore + +#endif // ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER) diff --git a/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h new file mode 100644 index 0000000..537bda1 --- /dev/null +++ b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InspectorBrowserDebuggerAgent_h +#define InspectorBrowserDebuggerAgent_h + +#if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) + +#include "PlatformString.h" + +#include <wtf/HashMap.h> +#include <wtf/HashSet.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/text/StringHash.h> + +namespace WebCore { + +class Element; +class InspectorController; +class InspectorObject; +class Node; + +class InspectorBrowserDebuggerAgent : public Noncopyable { +public: + static PassOwnPtr<InspectorBrowserDebuggerAgent> create(InspectorController* inspectorController) + { + return adoptPtr(new InspectorBrowserDebuggerAgent(inspectorController)); + } + + virtual ~InspectorBrowserDebuggerAgent(); + + // BrowserDebugger API for InspectorFrontend + void setXHRBreakpoint(const String& url); + void removeXHRBreakpoint(const String& url); + void setEventListenerBreakpoint(const String& eventName); + void removeEventListenerBreakpoint(const String& eventName); + void setDOMBreakpoint(long nodeId, long type); + void removeDOMBreakpoint(long nodeId, long type); + + // InspectorInstrumentation API + void willInsertDOMNode(Node*, Node* parent); + void didInsertDOMNode(Node*); + void willRemoveDOMNode(Node*); + void didRemoveDOMNode(Node*); + void willModifyDOMAttr(Element*); + void willSendXMLHttpRequest(const String& url); + void pauseOnNativeEventIfNeeded(const String& categoryType, const String& eventName, bool synchronous); + + void clearForPageNavigation(); +private: + InspectorBrowserDebuggerAgent(InspectorController*); + + void descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, InspectorObject* description); + void updateSubtreeBreakpoints(Node*, uint32_t rootMask, bool set); + bool hasBreakpoint(Node*, long type); + void discardBindings(); + + InspectorController* m_inspectorController; + HashMap<Node*, uint32_t> m_breakpoints; + HashSet<String> m_eventListenerBreakpoints; + HashSet<String> m_XHRBreakpoints; + bool m_hasXHRBreakpointWithEmptyURL; +}; + +} // namespace WebCore + +#endif // ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) + +#endif // !defined(InspectorBrowserDebuggerAgent_h) diff --git a/Source/WebCore/inspector/InspectorClient.h b/Source/WebCore/inspector/InspectorClient.h index 0c78246..3b8007e 100644 --- a/Source/WebCore/inspector/InspectorClient.h +++ b/Source/WebCore/inspector/InspectorClient.h @@ -26,7 +26,6 @@ #ifndef InspectorClient_h #define InspectorClient_h -#include "InspectorController.h" #include <wtf/Forward.h> namespace WebCore { diff --git a/Source/WebCore/inspector/InspectorConsoleAgent.cpp b/Source/WebCore/inspector/InspectorConsoleAgent.cpp new file mode 100644 index 0000000..a543cb2 --- /dev/null +++ b/Source/WebCore/inspector/InspectorConsoleAgent.cpp @@ -0,0 +1,230 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "config.h" +#include "InspectorConsoleAgent.h" + +#if ENABLE(INSPECTOR) +#include "Console.h" +#include "ConsoleMessage.h" +#include "InjectedScriptHost.h" +#include "InspectorController.h" +#include "InspectorDOMAgent.h" +#include "InspectorFrontend.h" +#include "InspectorState.h" +#include "ResourceError.h" +#include "ResourceResponse.h" +#include "ScriptArguments.h" +#include "ScriptCallFrame.h" +#include "ScriptCallStack.h" +#include <wtf/CurrentTime.h> +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/text/StringConcatenate.h> + +namespace WebCore { + +static const unsigned maximumConsoleMessages = 1000; +static const unsigned expireConsoleMessagesStep = 100; + +InspectorConsoleAgent::InspectorConsoleAgent(InspectorController* inspectorController, InspectorState* state) + : m_inspectorController(inspectorController) + , m_state(state) + , m_frontend(0) + , m_previousMessage(0) + , m_expiredConsoleMessageCount(0) +{ +} + +InspectorConsoleAgent::~InspectorConsoleAgent() +{ + m_inspectorController = 0; +} + +void InspectorConsoleAgent::setConsoleMessagesEnabled(bool enabled, bool* newState) +{ + *newState = enabled; + setConsoleMessagesEnabled(enabled); +} + +void InspectorConsoleAgent::clearConsoleMessages() +{ + m_consoleMessages.clear(); + m_expiredConsoleMessageCount = 0; + m_previousMessage = 0; + m_inspectorController->injectedScriptHost()->releaseWrapperObjectGroup(0 /* release the group in all scripts */, "console"); + if (InspectorDOMAgent* domAgent = m_inspectorController->domAgent()) + domAgent->releaseDanglingNodes(); + if (m_frontend) + m_frontend->consoleMessagesCleared(); +} + +void InspectorConsoleAgent::reset() +{ + clearConsoleMessages(); + m_times.clear(); + m_counts.clear(); +} + +void InspectorConsoleAgent::setFrontend(InspectorFrontend* frontend) +{ + m_frontend = frontend; +} + +void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack) +{ + if (!m_inspectorController->enabled()) + return; + addConsoleMessage(new ConsoleMessage(source, type, level, message, arguments, callStack)); +} + +void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) +{ + if (!m_inspectorController->enabled()) + return; + addConsoleMessage(new ConsoleMessage(source, type, level, message, lineNumber, sourceID)); +} + +void InspectorConsoleAgent::startTiming(const String& title) +{ + // Follow Firebug's behavior of requiring a title that is not null or + // undefined for timing functions + if (title.isNull()) + return; + + m_times.add(title, currentTime() * 1000); +} + +void InspectorConsoleAgent::stopTiming(const String& title, PassRefPtr<ScriptCallStack> callStack) +{ + // Follow Firebug's behavior of requiring a title that is not null or + // undefined for timing functions + if (title.isNull()) + return; + + HashMap<String, double>::iterator it = m_times.find(title); + if (it == m_times.end()) + return; + + double startTime = it->second; + m_times.remove(it); + + double elapsed = currentTime() * 1000 - startTime; + String message = title + String::format(": %.0fms", elapsed); + const ScriptCallFrame& lastCaller = callStack->at(0); + addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lastCaller.lineNumber(), lastCaller.sourceURL()); +} + +void InspectorConsoleAgent::count(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack) +{ + const ScriptCallFrame& lastCaller = callStack->at(0); + // Follow Firebug's behavior of counting with null and undefined title in + // the same bucket as no argument + String title; + arguments->getFirstArgumentAsString(title); + String identifier = makeString(title, '@', lastCaller.sourceURL(), ':', String::number(lastCaller.lineNumber())); + + HashMap<String, unsigned>::iterator it = m_counts.find(identifier); + int count; + if (it == m_counts.end()) + count = 1; + else { + count = it->second + 1; + m_counts.remove(it); + } + + m_counts.add(identifier, count); + + String message = makeString(title, ": ", String::number(count)); + addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lastCaller.lineNumber(), lastCaller.sourceURL()); +} + +void InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest(const String& url, const String& sendURL, unsigned sendLineNumber) +{ + if (!m_inspectorController->enabled()) + return; + if (m_state->getBoolean(InspectorState::monitoringXHR)) + addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, "XHR finished loading: \"" + url + "\".", sendLineNumber, sendURL); +} + +void InspectorConsoleAgent::didReceiveResponse(unsigned long identifier, const ResourceResponse& response) +{ + if (!m_inspectorController->enabled()) + return; + + if (response.httpStatusCode() >= 400) { + String message = makeString("Failed to load resource: the server responded with a status of ", String::number(response.httpStatusCode()), " (", response.httpStatusText(), ')'); + addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, response.url().string(), identifier)); + } +} + +void InspectorConsoleAgent::didFailLoading(unsigned long identifier, const ResourceError& error) +{ + if (!m_inspectorController->enabled()) + return; + + String message = "Failed to load resource"; + if (!error.localizedDescription().isEmpty()) + message += ": " + error.localizedDescription(); + addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, error.failingURL(), identifier)); +} + +void InspectorConsoleAgent::setConsoleMessagesEnabled(bool enabled) +{ + m_state->setBoolean(InspectorState::consoleMessagesEnabled, enabled); + if (!m_inspectorController->enabled()) + return; + if (m_expiredConsoleMessageCount) + m_frontend->updateConsoleMessageExpiredCount(m_expiredConsoleMessageCount); + unsigned messageCount = m_consoleMessages.size(); + for (unsigned i = 0; i < messageCount; ++i) + m_consoleMessages[i]->addToFrontend(m_frontend, m_inspectorController->injectedScriptHost()); +} + +void InspectorConsoleAgent::addConsoleMessage(PassOwnPtr<ConsoleMessage> consoleMessage) +{ + ASSERT(m_inspectorController->enabled()); + ASSERT_ARG(consoleMessage, consoleMessage); + + if (m_previousMessage && m_previousMessage->isEqual(consoleMessage.get())) { + m_previousMessage->incrementCount(); + if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend) + m_previousMessage->updateRepeatCountInConsole(m_frontend); + } else { + m_previousMessage = consoleMessage.get(); + m_consoleMessages.append(consoleMessage); + if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend) + m_previousMessage->addToFrontend(m_frontend, m_inspectorController->injectedScriptHost()); + } + + if (!m_frontend && m_consoleMessages.size() >= maximumConsoleMessages) { + m_expiredConsoleMessageCount += expireConsoleMessagesStep; + m_consoleMessages.remove(0, expireConsoleMessagesStep); + } +} + +} // namespace WebCore + +#endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorConsoleAgent.h b/Source/WebCore/inspector/InspectorConsoleAgent.h new file mode 100644 index 0000000..97fcb3f --- /dev/null +++ b/Source/WebCore/inspector/InspectorConsoleAgent.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InspectorConsoleAgent_h +#define InspectorConsoleAgent_h + +#include "Console.h" +#include <wtf/Forward.h> +#include <wtf/HashMap.h> +#include <wtf/Noncopyable.h> +#include <wtf/text/StringHash.h> +#include <wtf/Vector.h> + +namespace WebCore { + +#if ENABLE(INSPECTOR) + +class ConsoleMessage; +class InspectorController; +class InspectorFrontend; +class InspectorState; +class ResourceError; +class ResourceResponse; +class ScriptArguments; +class ScriptCallStack; +class ScriptProfile; + +class InspectorConsoleAgent : public Noncopyable { +public: + InspectorConsoleAgent(InspectorController*, InspectorState*); + ~InspectorConsoleAgent(); + + void setConsoleMessagesEnabled(bool enabled, bool* newState); + void clearConsoleMessages(); + void reset(); + void setFrontend(InspectorFrontend*); + + void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>); + void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID); + + void startTiming(const String& title); + void stopTiming(const String& title, PassRefPtr<ScriptCallStack>); + void count(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>); + + void resourceRetrievedByXMLHttpRequest(const String& url, const String& sendURL, unsigned sendLineNumber); + void didReceiveResponse(unsigned long identifier, const ResourceResponse&); + void didFailLoading(unsigned long identifier, const ResourceError&); +#if ENABLE(JAVASCRIPT_DEBUGGER) + void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL); + void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL); +#endif + +private: + void setConsoleMessagesEnabled(bool); + void addConsoleMessage(PassOwnPtr<ConsoleMessage>); + + InspectorController* m_inspectorController; + InspectorState* m_state; + InspectorFrontend* m_frontend; + ConsoleMessage* m_previousMessage; + Vector<OwnPtr<ConsoleMessage> > m_consoleMessages; + unsigned m_expiredConsoleMessageCount; + HashMap<String, unsigned> m_counts; + HashMap<String, double> m_times; +}; + +#endif + +} // namespace WebCore + +#endif // !defined(InspectorConsoleAgent_h) diff --git a/Source/WebCore/inspector/InspectorController.cpp b/Source/WebCore/inspector/InspectorController.cpp index 7248dc9..5a139b6 100644 --- a/Source/WebCore/inspector/InspectorController.cpp +++ b/Source/WebCore/inspector/InspectorController.cpp @@ -35,11 +35,10 @@ #include "CachedResource.h" #include "CachedResourceLoader.h" #include "Chrome.h" -#include "Console.h" -#include "ConsoleMessage.h" #include "Cookie.h" #include "CookieJar.h" #include "DOMWindow.h" +#include "DOMWrapperWorld.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -58,8 +57,10 @@ #include "InjectedScript.h" #include "InjectedScriptHost.h" #include "InspectorBackendDispatcher.h" +#include "InspectorBrowserDebuggerAgent.h" #include "InspectorCSSAgent.h" #include "InspectorClient.h" +#include "InspectorConsoleAgent.h" #include "InspectorDOMAgent.h" #include "InspectorDOMStorageResource.h" #include "InspectorDatabaseResource.h" @@ -69,6 +70,7 @@ #include "InspectorInstrumentation.h" #include "InspectorProfilerAgent.h" #include "InspectorResourceAgent.h" +#include "InspectorSettings.h" #include "InspectorState.h" #include "InspectorTimelineAgent.h" #include "InspectorValues.h" @@ -130,29 +132,20 @@ const char* const InspectorController::ConsolePanel = "console"; const char* const InspectorController::ScriptsPanel = "scripts"; const char* const InspectorController::ProfilesPanel = "profiles"; -const unsigned InspectorController::defaultAttachedHeight = 300; - -static const unsigned maximumConsoleMessages = 1000; -static const unsigned expireConsoleMessagesStep = 100; - InspectorController::InspectorController(Page* page, InspectorClient* client) : m_inspectedPage(page) , m_client(client) , m_openingFrontend(false) , m_cssAgent(new InspectorCSSAgent()) - , m_mainResourceIdentifier(0) - , m_expiredConsoleMessageCount(0) - , m_previousMessage(0) - , m_settingsLoaded(false) + , m_state(new InspectorState(client)) , m_inspectorBackendDispatcher(new InspectorBackendDispatcher(this)) , m_injectedScriptHost(InjectedScriptHost::create(this)) + , m_consoleAgent(new InspectorConsoleAgent(this, m_state.get())) #if ENABLE(JAVASCRIPT_DEBUGGER) , m_attachDebuggerWhenShown(false) - , m_hasXHRBreakpointWithEmptyURL(false) , m_profilerAgent(InspectorProfilerAgent::create(this)) #endif { - m_state = new InspectorState(client); ASSERT_ARG(page, page); ASSERT_ARG(client, client); } @@ -178,7 +171,9 @@ void InspectorController::inspectedPageDestroyed() #if ENABLE(JAVASCRIPT_DEBUGGER) m_debuggerAgent.clear(); + m_browserDebuggerAgent.clear(); #endif + ASSERT(m_inspectedPage); m_inspectedPage = 0; @@ -195,22 +190,22 @@ bool InspectorController::enabled() const bool InspectorController::inspectorStartsAttached() { - return m_state->getBoolean(InspectorState::inspectorStartsAttached); + return m_settings->getBoolean(InspectorSettings::InspectorStartsAttached); } void InspectorController::setInspectorStartsAttached(bool attached) { - m_state->setBoolean(InspectorState::inspectorStartsAttached, attached); + m_settings->setBoolean(InspectorSettings::InspectorStartsAttached, attached); } void InspectorController::setInspectorAttachedHeight(long height) { - m_state->setLong(InspectorState::inspectorAttachedHeight, height); + m_settings->setLong(InspectorSettings::InspectorAttachedHeight, height); } -int InspectorController::inspectorAttachedHeight() const +long InspectorController::inspectorAttachedHeight() const { - return m_state->getBoolean(InspectorState::inspectorAttachedHeight); + return m_settings->getLong(InspectorSettings::InspectorAttachedHeight); } bool InspectorController::searchingForNodeInPage() const @@ -230,12 +225,24 @@ void InspectorController::getInspectorState(RefPtr<InspectorObject>* state) void InspectorController::restoreInspectorStateFromCookie(const String& inspectorStateCookie) { m_state->restoreFromInspectorCookie(inspectorStateCookie); + + if (!m_frontend) { + connectFrontend(); + m_frontend->frontendReused(); + m_frontend->inspectedURLChanged(m_inspectedPage->mainFrame()->loader()->url().string()); + m_domAgent->setDocument(m_inspectedPage->mainFrame()->document()); + pushDataCollectedOffline(); + } + if (m_state->getBoolean(InspectorState::timelineProfilerEnabled)) startTimelineProfiler(); + #if ENABLE(JAVASCRIPT_DEBUGGER) + restoreDebugger(); + restoreProfiler(ProfilerRestoreResetAgent); if (m_state->getBoolean(InspectorState::userInitiatedProfiling)) startUserInitiatedProfiling(); -#endif +#endif } void InspectorController::inspect(Node* node) @@ -303,91 +310,6 @@ void InspectorController::hideHighlight() m_client->hideHighlight(); } -void InspectorController::setConsoleMessagesEnabled(bool enabled, bool* newState) -{ - *newState = enabled; - setConsoleMessagesEnabled(enabled); -} - -void InspectorController::setConsoleMessagesEnabled(bool enabled) -{ - m_state->setBoolean(InspectorState::consoleMessagesEnabled, enabled); - if (!enabled) - return; - - if (m_expiredConsoleMessageCount) - m_frontend->updateConsoleMessageExpiredCount(m_expiredConsoleMessageCount); - unsigned messageCount = m_consoleMessages.size(); - for (unsigned i = 0; i < messageCount; ++i) - m_consoleMessages[i]->addToFrontend(m_frontend.get(), m_injectedScriptHost.get()); -} - -void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack) -{ - if (!enabled()) - return; - - addConsoleMessage(new ConsoleMessage(source, type, level, message, arguments, callStack)); -} - -void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) -{ - if (!enabled()) - return; - - addConsoleMessage(new ConsoleMessage(source, type, level, message, lineNumber, sourceID)); -} - -void InspectorController::addConsoleMessage(PassOwnPtr<ConsoleMessage> consoleMessage) -{ - ASSERT(enabled()); - ASSERT_ARG(consoleMessage, consoleMessage); - - if (m_previousMessage && m_previousMessage->isEqual(consoleMessage.get())) { - m_previousMessage->incrementCount(); - if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend) - m_previousMessage->updateRepeatCountInConsole(m_frontend.get()); - } else { - m_previousMessage = consoleMessage.get(); - m_consoleMessages.append(consoleMessage); - if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend) - m_previousMessage->addToFrontend(m_frontend.get(), m_injectedScriptHost.get()); - } - - if (!m_frontend && m_consoleMessages.size() >= maximumConsoleMessages) { - m_expiredConsoleMessageCount += expireConsoleMessagesStep; - m_consoleMessages.remove(0, expireConsoleMessagesStep); - } -} - -void InspectorController::clearConsoleMessages() -{ - m_consoleMessages.clear(); - m_expiredConsoleMessageCount = 0; - m_previousMessage = 0; - m_injectedScriptHost->releaseWrapperObjectGroup(0 /* release the group in all scripts */, "console"); - if (m_domAgent) - m_domAgent->releaseDanglingNodes(); - if (m_frontend) - m_frontend->consoleMessagesCleared(); -} - -void InspectorController::startGroup(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack, bool collapsed) -{ - addConsoleMessage(new ConsoleMessage(JSMessageSource, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, "", arguments, callStack)); -} - -void InspectorController::endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL) -{ - addConsoleMessage(new ConsoleMessage(source, EndGroupMessageType, LogMessageLevel, String(), lineNumber, sourceURL)); -} - -void InspectorController::markTimeline(const String& message) -{ - if (timelineAgent()) - timelineAgent()->didMarkTimeline(message); -} - void InspectorController::mouseDidMoveOverElement(const HitTestResult& result, unsigned) { if (!enabled() || !searchingForNodeInPage()) @@ -400,18 +322,17 @@ void InspectorController::mouseDidMoveOverElement(const HitTestResult& result, u highlight(node); } -void InspectorController::handleMousePress() +bool InspectorController::handleMousePress() { - if (!enabled()) - return; - - ASSERT(searchingForNodeInPage()); - if (!m_highlightedNode) - return; + if (!enabled() || !searchingForNodeInPage()) + return false; - RefPtr<Node> node = m_highlightedNode; - setSearchingForNode(false); - inspect(node.get()); + if (m_highlightedNode) { + RefPtr<Node> node = m_highlightedNode; + setSearchingForNode(false); + inspect(node.get()); + } + return true; } void InspectorController::setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient> client) @@ -420,8 +341,11 @@ void InspectorController::setInspectorFrontendClient(PassOwnPtr<InspectorFronten m_inspectorFrontendClient = client; } -void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame) +void InspectorController::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world) { + if (world != mainThreadNormalWorld()) + return; + // If the page is supposed to serve as InspectorFrontend notify inspetor frontend // client that it's cleared so that the client can expose inspector bindings. if (m_inspectorFrontendClient && frame == m_inspectedPage->mainFrame()) @@ -461,6 +385,7 @@ void InspectorController::setMonitoringXHREnabled(bool enabled, bool* newState) { *newState = enabled; m_state->setBoolean(InspectorState::monitoringXHR, enabled); + m_settings->setBoolean(InspectorSettings::MonitoringXHREnabled, enabled); } void InspectorController::connectFrontend() @@ -484,6 +409,8 @@ void InspectorController::connectFrontend() if (m_timelineAgent) m_timelineAgent->resetFrontendProxyObject(m_frontend.get()); + m_consoleAgent->setFrontend(m_frontend.get()); + // Initialize Web Inspector title. m_frontend->inspectedURLChanged(m_inspectedPage->mainFrame()->loader()->url().string()); @@ -500,13 +427,6 @@ void InspectorController::connectFrontend() InspectorInstrumentation::frontendCreated(); } -void InspectorController::reuseFrontend() -{ - connectFrontend(); - restoreDebugger(); - restoreProfiler(ProfilerRestoreResetAgent); -} - void InspectorController::show() { if (!enabled()) @@ -574,6 +494,7 @@ void InspectorController::disconnectFrontend() m_profilerAgent->setFrontend(0); m_profilerAgent->stopUserInitiatedProfiling(true); #endif + m_consoleAgent->setFrontend(0); releaseFrontendLifetimeAgents(); m_timelineAgent.clear(); @@ -630,11 +551,24 @@ void InspectorController::populateScriptObjects() m_frontend->profilerWasEnabled(); #endif - m_domAgent->setDocument(m_inspectedPage->mainFrame()->document()); + pushDataCollectedOffline(); if (m_nodeToFocus) focusNode(); + // Dispatch pending frontend commands + for (Vector<pair<long, String> >::iterator it = m_pendingEvaluateTestCommands.begin(); it != m_pendingEvaluateTestCommands.end(); ++it) + m_frontend->evaluateForTestInFrontend((*it).first, (*it).second); + m_pendingEvaluateTestCommands.clear(); + + restoreDebugger(); + restoreProfiler(ProfilerRestoreNoAction); +} + +void InspectorController::pushDataCollectedOffline() +{ + m_domAgent->setDocument(m_inspectedPage->mainFrame()->document()); + #if ENABLE(DATABASE) DatabaseResourcesMap::iterator databasesEnd = m_databaseResources.end(); for (DatabaseResourcesMap::iterator it = m_databaseResources.begin(); it != databasesEnd; ++it) @@ -652,25 +586,15 @@ void InspectorController::populateScriptObjects() m_frontend->didCreateWorker(worker->id(), worker->url(), worker->isSharedWorker()); } #endif - - // Dispatch pending frontend commands - for (Vector<pair<long, String> >::iterator it = m_pendingEvaluateTestCommands.begin(); it != m_pendingEvaluateTestCommands.end(); ++it) - m_frontend->evaluateForTestInFrontend((*it).first, (*it).second); - m_pendingEvaluateTestCommands.clear(); - - restoreDebugger(); - restoreProfiler(ProfilerRestoreNoAction); } void InspectorController::restoreDebugger() { ASSERT(m_frontend); #if ENABLE(JAVASCRIPT_DEBUGGER) - if (InspectorDebuggerAgent::isDebuggerAlwaysEnabled()) - enableDebuggerFromFrontend(false); - else { - if (m_state->getBoolean(InspectorState::debuggerAlwaysEnabled) || m_attachDebuggerWhenShown) - enableDebugger(); + if (InspectorDebuggerAgent::isDebuggerAlwaysEnabled() || m_attachDebuggerWhenShown || m_settings->getBoolean(InspectorSettings::DebuggerAlwaysEnabled)) { + enableDebugger(false); + m_attachDebuggerWhenShown = false; } #endif } @@ -680,7 +604,7 @@ void InspectorController::restoreProfiler(ProfilerRestoreAction action) ASSERT(m_frontend); #if ENABLE(JAVASCRIPT_DEBUGGER) m_profilerAgent->setFrontend(m_frontend.get()); - if (!ScriptProfiler::isProfilerAlwaysEnabled() && m_state->getBoolean(InspectorState::profilerAlwaysEnabled)) + if (!ScriptProfiler::isProfilerAlwaysEnabled() && m_settings->getBoolean(InspectorSettings::ProfilerAlwaysEnabled)) enableProfiler(); if (action == ProfilerRestoreResetAgent) m_profilerAgent->resetState(); @@ -718,14 +642,13 @@ void InspectorController::didCommitLoad(DocumentLoader* loader) m_frontend->inspectedURLChanged(loader->url().string()); m_injectedScriptHost->discardInjectedScripts(); - clearConsoleMessages(); - - m_times.clear(); - m_counts.clear(); + m_consoleAgent->reset(); #if ENABLE(JAVASCRIPT_DEBUGGER) if (m_debuggerAgent) { m_debuggerAgent->clearForPageNavigation(); + if (m_browserDebuggerAgent) + m_browserDebuggerAgent->clearForPageNavigation(); restoreStickyBreakpoints(); } #endif @@ -754,50 +677,11 @@ void InspectorController::didCommitLoad(DocumentLoader* loader) m_domStorageResources.clear(); #endif - if (m_frontend) { - m_mainResourceIdentifier = 0; - m_frontend->didCommitLoad(); + if (m_frontend) m_domAgent->setDocument(m_inspectedPage->mainFrame()->document()); - } } } -void InspectorController::frameDetachedFromParent(Frame* rootFrame) -{ - if (!enabled()) - return; - - if (m_resourceAgent) - m_resourceAgent->frameDetachedFromParent(rootFrame); -} - -void InspectorController::didLoadResourceFromMemoryCache(DocumentLoader* loader, const CachedResource* cachedResource) -{ - if (!enabled()) - return; - - ensureSettingsLoaded(); - - if (m_resourceAgent) - m_resourceAgent->didLoadResourceFromMemoryCache(loader, cachedResource); -} - -void InspectorController::identifierForInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request) -{ - if (!enabled()) - return; - ASSERT(m_inspectedPage); - - bool isMainResource = isMainResourceLoader(loader, request.url()); - if (isMainResource) - m_mainResourceIdentifier = identifier; - - ensureSettingsLoaded(); - - if (m_resourceAgent) - m_resourceAgent->identifierForInitialRequest(identifier, request.url(), loader); -} - void InspectorController::mainResourceFiredDOMContentEvent(DocumentLoader* loader, const KURL& url) { if (!enabled() || !isMainResourceLoader(loader, url)) @@ -825,16 +709,14 @@ bool InspectorController::isMainResourceLoader(DocumentLoader* loader, const KUR return loader->frame() == m_inspectedPage->mainFrame() && requestUrl == loader->requestURL(); } -void InspectorController::willSendRequest(unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse) +void InspectorController::willSendRequest(ResourceRequest& request) { if (!enabled()) return; - request.setReportLoadTiming(true); - if (m_frontend) { - // Only enable raw headers if front-end is attached, as otherwise we may lack - // permissions to fetch the headers. + // Only enable load timing and raw headers if front-end is attached, as otherwise we may produce overhead. + request.setReportLoadTiming(true); request.setReportRawHeaders(true); if (m_extraHeaders) { @@ -843,104 +725,14 @@ void InspectorController::willSendRequest(unsigned long identifier, ResourceRequ request.setHTTPHeaderField(it->first, it->second); } } - - bool isMainResource = m_mainResourceIdentifier == identifier; - if (m_timelineAgent) - m_timelineAgent->willSendResourceRequest(identifier, isMainResource, request); - - if (m_resourceAgent) - m_resourceAgent->willSendRequest(identifier, request, redirectResponse); -} - -void InspectorController::markResourceAsCached(unsigned long identifier) -{ - if (!enabled()) - return; - - if (m_resourceAgent) - m_resourceAgent->markResourceAsCached(identifier); -} - -void InspectorController::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response) -{ - if (!enabled()) - return; - - if (m_resourceAgent) - m_resourceAgent->didReceiveResponse(identifier, loader, response); - - if (response.httpStatusCode() >= 400) { - String message = makeString("Failed to load resource: the server responded with a status of ", String::number(response.httpStatusCode()), " (", response.httpStatusText(), ')'); - addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, response.url().string(), identifier)); - } -} - -void InspectorController::didReceiveContentLength(unsigned long identifier, int lengthReceived) -{ - if (!enabled()) - return; - - if (m_resourceAgent) - m_resourceAgent->didReceiveContentLength(identifier, lengthReceived); -} - -void InspectorController::didFinishLoading(unsigned long identifier, double finishTime) -{ - if (!enabled()) - return; - - if (m_timelineAgent) - m_timelineAgent->didFinishLoadingResource(identifier, false, finishTime); - - if (m_resourceAgent) - m_resourceAgent->didFinishLoading(identifier, finishTime); -} - -void InspectorController::didFailLoading(unsigned long identifier, const ResourceError& error) -{ - if (!enabled()) - return; - - if (m_timelineAgent) - m_timelineAgent->didFinishLoadingResource(identifier, true, 0); - - String message = "Failed to load resource"; - if (!error.localizedDescription().isEmpty()) - message += ": " + error.localizedDescription(); - addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, error.failingURL(), identifier)); - - if (m_resourceAgent) - m_resourceAgent->didFailLoading(identifier, error); -} - -void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber) -{ - if (!enabled()) - return; - - if (m_state->getBoolean(InspectorState::monitoringXHR)) - addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, "XHR finished loading: \"" + url + "\".", sendLineNumber, sendURL); - - if (m_resourceAgent) - m_resourceAgent->setInitialContent(identifier, sourceString, "XHR"); -} - -void InspectorController::scriptImported(unsigned long identifier, const String& sourceString) -{ - if (!enabled()) - return; - - if (m_resourceAgent) - m_resourceAgent->setInitialContent(identifier, sourceString, "Script"); } void InspectorController::ensureSettingsLoaded() { - if (m_settingsLoaded) + if (m_settings) return; - m_settingsLoaded = true; - - m_state->loadFromSettings(); + m_settings = new InspectorSettings(m_client); + m_state->setBoolean(InspectorState::monitoringXHR, m_settings->getBoolean(InspectorSettings::MonitoringXHREnabled)); } void InspectorController::startTimelineProfiler() @@ -990,8 +782,10 @@ private: virtual void performTask(ScriptExecutionContext* scriptContext) { - if (InspectorController* inspector = scriptContext->inspectorController()) - inspector->postWorkerNotificationToFrontend(*m_worker, m_action); + if (scriptContext->isDocument()) { + if (InspectorController* inspector = static_cast<Document*>(scriptContext)->page()->inspectorController()) + inspector->postWorkerNotificationToFrontend(*m_worker, m_action); + } } private: @@ -1201,17 +995,6 @@ void InspectorController::addProfile(PassRefPtr<ScriptProfile> prpProfile, unsig m_profilerAgent->addProfile(prpProfile, lineNumber, sourceURL); } -void InspectorController::addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, const String& sourceURL) -{ - m_profilerAgent->addProfileFinishedMessageToConsole(prpProfile, lineNumber, sourceURL); -} - -void InspectorController::addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL) -{ - m_profilerAgent->addStartProfilingMessageToConsole(title, lineNumber, sourceURL); -} - - bool InspectorController::isRecordingUserInitiatedProfile() const { return m_profilerAgent->isRecordingUserInitiatedProfile(); @@ -1246,60 +1029,61 @@ bool InspectorController::profilerEnabled() const void InspectorController::enableProfiler(bool always, bool skipRecompile) { if (always) - m_state->setBoolean(InspectorState::profilerAlwaysEnabled, true); + m_settings->setBoolean(InspectorSettings::ProfilerAlwaysEnabled, true); m_profilerAgent->enable(skipRecompile); } void InspectorController::disableProfiler(bool always) { if (always) - m_state->setBoolean(InspectorState::profilerAlwaysEnabled, false); + m_settings->setBoolean(InspectorSettings::ProfilerAlwaysEnabled, false); m_profilerAgent->disable(); } #endif #if ENABLE(JAVASCRIPT_DEBUGGER) -void InspectorController::enableDebuggerFromFrontend(bool always) +void InspectorController::showAndEnableDebugger() +{ + if (!enabled()) + return; + + if (debuggerEnabled()) + return; + + if (!m_frontend) { + m_attachDebuggerWhenShown = true; + showPanel(ScriptsPanel); + } else + enableDebugger(false); +} + +void InspectorController::enableDebugger(bool always) { ASSERT(!debuggerEnabled()); if (always) - m_state->setBoolean(InspectorState::debuggerAlwaysEnabled, true); + m_settings->setBoolean(InspectorSettings::DebuggerAlwaysEnabled, true); ASSERT(m_inspectedPage); m_debuggerAgent = InspectorDebuggerAgent::create(this, m_frontend.get()); + m_browserDebuggerAgent = InspectorBrowserDebuggerAgent::create(this); restoreStickyBreakpoints(); m_frontend->debuggerWasEnabled(); } -void InspectorController::enableDebugger() -{ - if (!enabled()) - return; - - if (debuggerEnabled()) - return; - - if (!m_frontend) - m_attachDebuggerWhenShown = true; - else { - m_frontend->attachDebuggerWhenShown(); - m_attachDebuggerWhenShown = false; - } -} - void InspectorController::disableDebugger(bool always) { if (!enabled()) return; if (always) - m_state->setBoolean(InspectorState::debuggerAlwaysEnabled, false); + m_settings->setBoolean(InspectorSettings::DebuggerAlwaysEnabled, false); ASSERT(m_inspectedPage); m_debuggerAgent.clear(); + m_browserDebuggerAgent.clear(); m_attachDebuggerWhenShown = false; @@ -1320,10 +1104,6 @@ void InspectorController::setStickyBreakpoints(PassRefPtr<InspectorObject> break void InspectorController::restoreStickyBreakpoints() { - m_eventListenerBreakpoints.clear(); - m_XHRBreakpoints.clear(); - m_hasXHRBreakpointWithEmptyURL = false; - RefPtr<InspectorObject> allBreakpoints = m_state->getObject(InspectorState::stickyBreakpoints); KURL url = m_inspectedPage->mainFrame()->loader()->url(); url.removeFragmentIdentifier(); @@ -1352,13 +1132,14 @@ void InspectorController::restoreStickyBreakpoint(PassRefPtr<InspectorObject> br if (!condition) return; - if (type == eventListenerBreakpointType) { + if (type == eventListenerBreakpointType && m_browserDebuggerAgent) { if (!enabled) return; String eventName; - if (condition->getString("eventName", &eventName)) - setEventListenerBreakpoint(eventName); - } else if (type == javaScriptBreakpointType) { + if (!condition->getString("eventName", &eventName)) + return; + m_browserDebuggerAgent->setEventListenerBreakpoint(eventName); + } else if (type == javaScriptBreakpointType && m_debuggerAgent) { String url; if (!condition->getString("url", &url)) return; @@ -1368,70 +1149,18 @@ void InspectorController::restoreStickyBreakpoint(PassRefPtr<InspectorObject> br String javaScriptCondition; if (!condition->getString("condition", &javaScriptCondition)) return; - if (m_debuggerAgent) - m_debuggerAgent->setStickyBreakpoint(url, static_cast<unsigned>(lineNumber), javaScriptCondition, enabled); - } else if (type == xhrBreakpointType) { + m_debuggerAgent->setStickyBreakpoint(url, static_cast<unsigned>(lineNumber), javaScriptCondition, enabled); + } else if (type == xhrBreakpointType && m_browserDebuggerAgent) { if (!enabled) return; String url; - if (condition->getString("url", &url)) - setXHRBreakpoint(url); - } -} - -void InspectorController::setEventListenerBreakpoint(const String& eventName) -{ - m_eventListenerBreakpoints.add(eventName); -} - -void InspectorController::removeEventListenerBreakpoint(const String& eventName) -{ - m_eventListenerBreakpoints.remove(eventName); -} - -bool InspectorController::hasEventListenerBreakpoint(const String& eventName) -{ - return m_eventListenerBreakpoints.contains(eventName); -} - -void InspectorController::setXHRBreakpoint(const String& url) -{ - if (url.isEmpty()) - m_hasXHRBreakpointWithEmptyURL = true; - else - m_XHRBreakpoints.add(url); -} - -void InspectorController::removeXHRBreakpoint(const String& url) -{ - if (url.isEmpty()) - m_hasXHRBreakpointWithEmptyURL = false; - else - m_XHRBreakpoints.remove(url); -} - -bool InspectorController::hasXHRBreakpoint(const String& url, String* breakpointURL) -{ - if (m_hasXHRBreakpointWithEmptyURL) { - *breakpointURL = ""; - return true; - } - for (HashSet<String>::iterator it = m_XHRBreakpoints.begin(); it != m_XHRBreakpoints.end(); ++it) { - if (url.contains(*it)) { - *breakpointURL = *it; - return true; - } + if (!condition->getString("url", &url)) + return; + m_browserDebuggerAgent->setXHRBreakpoint(url); } - return false; } - #endif -void InspectorController::setInjectedScriptSource(const String& source) -{ - injectedScriptHost()->setInjectedScriptSource(source); -} - void InspectorController::dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException) { if (!m_frontend) @@ -1739,42 +1468,6 @@ void InspectorController::openInInspectedWindow(const String& url) newFrame->loader()->changeLocation(mainFrame->document()->securityOrigin(), newFrame->loader()->completeURL(url), "", false, false); } -void InspectorController::count(const String& title, unsigned lineNumber, const String& sourceID) -{ - String identifier = makeString(title, '@', sourceID, ':', String::number(lineNumber)); - HashMap<String, unsigned>::iterator it = m_counts.find(identifier); - int count; - if (it == m_counts.end()) - count = 1; - else { - count = it->second + 1; - m_counts.remove(it); - } - - m_counts.add(identifier, count); - - String message = makeString(title, ": ", String::number(count)); - addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceID); -} - -void InspectorController::startTiming(const String& title) -{ - m_times.add(title, currentTime() * 1000); -} - -bool InspectorController::stopTiming(const String& title, double& elapsed) -{ - HashMap<String, double>::iterator it = m_times.find(title); - if (it == m_times.end()) - return false; - - double startTime = it->second; - m_times.remove(it); - - elapsed = currentTime() * 1000 - startTime; - return true; -} - InjectedScript InspectorController::injectedScriptForNodeId(long id) { diff --git a/Source/WebCore/inspector/InspectorController.h b/Source/WebCore/inspector/InspectorController.h index 481344d..9cddc56 100644 --- a/Source/WebCore/inspector/InspectorController.h +++ b/Source/WebCore/inspector/InspectorController.h @@ -45,8 +45,8 @@ namespace WebCore { class CachedResource; class CharacterData; -class ConsoleMessage; class Database; +class DOMWrapperWorld; class Document; class DocumentLoader; class FloatRect; @@ -57,7 +57,9 @@ class InjectedScript; class InjectedScriptHost; class InspectorArray; class InspectorBackendDispatcher; +class InspectorBrowserDebuggerAgent; class InspectorClient; +class InspectorConsoleAgent; class InspectorCSSAgent; class InspectorDOMAgent; class InspectorDOMStorageAgent; @@ -70,6 +72,7 @@ class InspectorFrontendClient; class InspectorObject; class InspectorProfilerAgent; class InspectorResourceAgent; +class InspectorSettings; class InspectorState; class InspectorStorageAgent; class InspectorTimelineAgent; @@ -141,39 +144,22 @@ public: void reuseFrontend(); void disconnectFrontend(); - void setConsoleMessagesEnabled(bool enabled, bool* newState); - void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack>); - void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String&); - void clearConsoleMessages(); - const Vector<OwnPtr<ConsoleMessage> >& consoleMessages() const { return m_consoleMessages; } + InspectorConsoleAgent* consoleAgent() const { return m_consoleAgent.get(); } + InspectorDOMAgent* domAgent() const { return m_domAgent.get(); } bool searchingForNodeInPage() const; void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); - void handleMousePress(); + bool handleMousePress(); void setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient> client); bool hasInspectorFrontendClient() const { return m_inspectorFrontendClient; } - void inspectedWindowScriptObjectCleared(Frame*); + void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*); void didCommitLoad(DocumentLoader*); - void frameDetachedFromParent(Frame*); - void didLoadResourceFromMemoryCache(DocumentLoader*, const CachedResource*); - - void identifierForInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&); - void willSendRequest(unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse); - void markResourceAsCached(unsigned long identifier); - void didReceiveResponse(unsigned long identifier, DocumentLoader*, const ResourceResponse&); - void didReceiveContentLength(unsigned long identifier, int lengthReceived); - void didFinishLoading(unsigned long identifier, double finishTime); - void didFailLoading(unsigned long identifier, const ResourceError&); - void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber); - void scriptImported(unsigned long identifier, const String& sourceString); void setExtraHeaders(PassRefPtr<InspectorObject>); - void ensureSettingsLoaded(); - void startTimelineProfiler(); void stopTimelineProfiler(); InspectorTimelineAgent* timelineAgent() { return m_timelineAgent.get(); } @@ -217,20 +203,8 @@ public: void openInInspectedWindow(const String& url); void drawElementTitle(GraphicsContext&, const IntRect& boundingBox, const FloatRect& overlayRect, WebCore::Settings*) const; - void count(const String& title, unsigned lineNumber, const String& sourceID); - - void startTiming(const String& title); - bool stopTiming(const String& title, double& elapsed); - - void startGroup(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack> callFrame, bool collapsed = false); - void endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL); - - void markTimeline(const String& message); - #if ENABLE(JAVASCRIPT_DEBUGGER) void addProfile(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL); - void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL); - void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL); bool isRecordingUserInitiatedProfile() const; String getCurrentUserInitiatedProfileName(bool incrementProfileNumber = false); void startProfiling() { startUserInitiatedProfiling(); } @@ -241,18 +215,13 @@ public: void disableProfiler(bool always = false); bool profilerEnabled() const; - void enableDebugger(); + void showAndEnableDebugger(); + void enableDebugger(bool always); void disableDebugger(bool always = false); bool debuggerEnabled() const { return m_debuggerAgent; } void resume(); void setStickyBreakpoints(PassRefPtr<InspectorObject> breakpoints); - void setEventListenerBreakpoint(const String& eventName); - void removeEventListenerBreakpoint(const String& eventName); - bool hasEventListenerBreakpoint(const String& eventName); - void setXHRBreakpoint(const String& url); - void removeXHRBreakpoint(const String& url); - bool hasXHRBreakpoint(const String& url, String* breakpointURL); #endif void setInjectedScriptSource(const String& source); @@ -272,26 +241,28 @@ public: bool inspectorStartsAttached(); void setInspectorStartsAttached(bool); void setInspectorAttachedHeight(long height); - int inspectorAttachedHeight() const; - - static const unsigned defaultAttachedHeight; + long inspectorAttachedHeight() const; private: - void getInspectorState(RefPtr<InspectorObject>* state); - void setConsoleMessagesEnabled(bool enabled); - friend class InspectorBackend; friend class InspectorBackendDispatcher; + friend class InspectorBrowserDebuggerAgent; friend class InspectorInstrumentation; friend class InjectedScriptHost; + void willSendRequest(ResourceRequest&); + + void ensureSettingsLoaded(); + + void getInspectorState(RefPtr<InspectorObject>* state); + + void populateScriptObjects(); + void pushDataCollectedOffline(); + void restoreDebugger(); enum ProfilerRestoreAction { ProfilerRestoreNoAction = 0, ProfilerRestoreResetAgent = 1 }; - - void populateScriptObjects(); - void restoreDebugger(); void restoreProfiler(ProfilerRestoreAction action); void unbindAllResources(); void setSearchingForNode(bool enabled); @@ -304,7 +275,6 @@ private: #if ENABLE(JAVASCRIPT_DEBUGGER) void toggleRecordButton(bool); - void enableDebuggerFromFrontend(bool always); void restoreStickyBreakpoints(); void restoreStickyBreakpoint(PassRefPtr<InspectorObject> breakpoint); #endif @@ -314,8 +284,6 @@ private: void focusNode(); - void addConsoleMessage(PassOwnPtr<ConsoleMessage>); - bool isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl); void didEvaluateForTestInFrontend(long callId, const String& jsonResult); @@ -338,6 +306,7 @@ private: OwnPtr<InspectorTimelineAgent> m_timelineAgent; OwnPtr<InspectorState> m_state; + OwnPtr<InspectorSettings> m_settings; #if ENABLE(OFFLINE_WEB_APPLICATIONS) OwnPtr<InspectorApplicationCacheAgent> m_applicationCacheAgent; @@ -349,11 +318,6 @@ private: RefPtr<Node> m_nodeToFocus; RefPtr<InspectorResourceAgent> m_resourceAgent; - unsigned long m_mainResourceIdentifier; - Vector<OwnPtr<ConsoleMessage> > m_consoleMessages; - unsigned m_expiredConsoleMessageCount; - HashMap<String, double> m_times; - HashMap<String, unsigned> m_counts; #if ENABLE(DATABASE) typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap; @@ -366,13 +330,9 @@ private: String m_showAfterVisible; RefPtr<Node> m_highlightedNode; - ConsoleMessage* m_previousMessage; - bool m_settingsLoaded; OwnPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher; RefPtr<InjectedScriptHost> m_injectedScriptHost; - - typedef HashMap<String, String> Settings; - mutable Settings m_settings; + OwnPtr<InspectorConsoleAgent> m_consoleAgent; Vector<pair<long, String> > m_pendingEvaluateTestCommands; Vector<String> m_scriptsToEvaluateOnLoad; @@ -380,10 +340,7 @@ private: #if ENABLE(JAVASCRIPT_DEBUGGER) bool m_attachDebuggerWhenShown; OwnPtr<InspectorDebuggerAgent> m_debuggerAgent; - - HashSet<String> m_eventListenerBreakpoints; - HashSet<String> m_XHRBreakpoints; - bool m_hasXHRBreakpointWithEmptyURL; + OwnPtr<InspectorBrowserDebuggerAgent> m_browserDebuggerAgent; OwnPtr<InspectorProfilerAgent> m_profilerAgent; #endif diff --git a/Source/WebCore/inspector/InspectorDOMAgent.cpp b/Source/WebCore/inspector/InspectorDOMAgent.cpp index e42bf2a..19ae30d 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMAgent.cpp @@ -204,16 +204,6 @@ public: virtual ~MatchPlainTextJob() { } }; -enum DOMBreakpointType { - SubtreeModified = 0, - AttributeModified, - NodeRemoved, - DOMBreakpointTypesCount -}; - -const uint32_t inheritableDOMBreakpointTypesMask = (1 << SubtreeModified); -const int domBreakpointDerivedTypeShift = 16; - } InspectorDOMAgent::InspectorDOMAgent(InspectorFrontend* frontend) @@ -268,6 +258,15 @@ void InspectorDOMAgent::releaseDanglingNodes() m_danglingNodeToIdMaps.clear(); } +void InspectorDOMAgent::startListeningFrameDocument(Node* frameOwnerNode) +{ + ASSERT(frameOwnerNode->isFrameOwnerElement()); + HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(frameOwnerNode); + Document* doc = frameOwner->contentDocument(); + if (doc) + startListening(doc); +} + void InspectorDOMAgent::startListening(Document* doc) { if (m_documents.contains(doc)) @@ -395,7 +394,6 @@ void InspectorDOMAgent::discardBindings() releaseDanglingNodes(); m_childrenRequested.clear(); m_inspectedNodes.clear(); - m_breakpoints.clear(); } Node* InspectorDOMAgent::nodeForId(long id) @@ -760,101 +758,6 @@ void InspectorDOMAgent::searchCanceled() m_searchResults.clear(); } -void InspectorDOMAgent::setDOMBreakpoint(long nodeId, long type) -{ - Node* node = nodeForId(nodeId); - if (!node) - return; - - uint32_t rootBit = 1 << type; - m_breakpoints.set(node, m_breakpoints.get(node) | rootBit); - if (rootBit & inheritableDOMBreakpointTypesMask) { - for (Node* child = innerFirstChild(node); child; child = innerNextSibling(child)) - updateSubtreeBreakpoints(child, rootBit, true); - } -} - -void InspectorDOMAgent::removeDOMBreakpoint(long nodeId, long type) -{ - Node* node = nodeForId(nodeId); - if (!node) - return; - - uint32_t rootBit = 1 << type; - uint32_t mask = m_breakpoints.get(node) & ~rootBit; - if (mask) - m_breakpoints.set(node, mask); - else - m_breakpoints.remove(node); - - if ((rootBit & inheritableDOMBreakpointTypesMask) && !(mask & (rootBit << domBreakpointDerivedTypeShift))) { - for (Node* child = innerFirstChild(node); child; child = innerNextSibling(child)) - updateSubtreeBreakpoints(child, rootBit, false); - } -} - -bool InspectorDOMAgent::shouldBreakOnNodeInsertion(Node*, Node* parent, PassRefPtr<InspectorObject> details) -{ - if (hasBreakpoint(parent, SubtreeModified)) { - descriptionForDOMEvent(parent, SubtreeModified, true, details); - return true; - } - return false; -} - -bool InspectorDOMAgent::shouldBreakOnNodeRemoval(Node* node, PassRefPtr<InspectorObject> details) -{ - if (hasBreakpoint(node, NodeRemoved)) { - descriptionForDOMEvent(node, NodeRemoved, false, details); - return true; - } - if (hasBreakpoint(innerParentNode(node), SubtreeModified)) { - descriptionForDOMEvent(node, SubtreeModified, false, details); - return true; - } - return false; -} - -bool InspectorDOMAgent::shouldBreakOnAttributeModification(Element* element, PassRefPtr<InspectorObject> details) -{ - if (hasBreakpoint(element, AttributeModified)) { - descriptionForDOMEvent(element, AttributeModified, false, details); - return true; - } - return false; -} - -void InspectorDOMAgent::descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, PassRefPtr<InspectorObject> description) -{ - ASSERT(hasBreakpoint(target, breakpointType)); - - Node* breakpointOwner = target; - if ((1 << breakpointType) & inheritableDOMBreakpointTypesMask) { - // For inheritable breakpoint types, target node isn't always the same as the node that owns a breakpoint. - // Target node may be unknown to frontend, so we need to push it first. - long targetNodeId = pushNodePathToFrontend(target); - ASSERT(targetNodeId); - description->setNumber("targetNodeId", targetNodeId); - - // Find breakpoint owner node. - if (!insertion) - breakpointOwner = innerParentNode(target); - ASSERT(breakpointOwner); - while (!(m_breakpoints.get(breakpointOwner) & (1 << breakpointType))) { - breakpointOwner = innerParentNode(breakpointOwner); - ASSERT(breakpointOwner); - } - - if (breakpointType == SubtreeModified) - description->setBoolean("insertion", insertion); - } - - long breakpointOwnerNodeId = m_documentNodeToIdMap.get(breakpointOwner); - ASSERT(breakpointOwnerNodeId); - description->setNumber("nodeId", breakpointOwnerNodeId); - description->setNumber("type", breakpointType); -} - String InspectorDOMAgent::documentURLString(Document* document) const { if (!document || document->url().isNull()) @@ -947,20 +850,24 @@ PassRefPtr<InspectorArray> InspectorDOMAgent::buildArrayForElementAttributes(Ele PassRefPtr<InspectorArray> InspectorDOMAgent::buildArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap) { RefPtr<InspectorArray> children = InspectorArray::create(); + Node* child = innerFirstChild(container); + if (depth == 0) { // Special case the_only text child. - if (innerChildNodeCount(container) == 1) { - Node *child = innerFirstChild(container); - if (child->nodeType() == Node::TEXT_NODE) - children->pushObject(buildObjectForNode(child, 0, nodesMap)); - } + if (child && child->nodeType() == Node::TEXT_NODE && !innerNextSibling(child)) + children->pushObject(buildObjectForNode(child, 0, nodesMap)); return children.release(); } else if (depth > 0) { depth--; } - for (Node *child = innerFirstChild(container); child; child = innerNextSibling(child)) + if (container->isFrameOwnerElement()) + startListeningFrameDocument(container); + + while (child) { children->pushObject(buildObjectForNode(child, depth, nodesMap)); + child = innerNextSibling(child); + } return children.release(); } @@ -987,10 +894,8 @@ Node* InspectorDOMAgent::innerFirstChild(Node* node) if (node->isFrameOwnerElement()) { HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(node); Document* doc = frameOwner->contentDocument(); - if (doc) { - startListening(doc); + if (doc) return doc->firstChild(); - } } node = node->firstChild(); while (isWhitespace(node)) @@ -1059,13 +964,6 @@ void InspectorDOMAgent::didInsertDOMNode(Node* node) if (isWhitespace(node)) return; - if (m_breakpoints.size()) { - uint32_t mask = m_breakpoints.get(innerParentNode(node)); - uint32_t inheritableTypesMask = (mask | (mask >> domBreakpointDerivedTypeShift)) & inheritableDOMBreakpointTypesMask; - if (inheritableTypesMask) - updateSubtreeBreakpoints(node, inheritableTypesMask, true); - } - // We could be attaching existing subtree. Forget the bindings. unbind(node, &m_documentNodeToIdMap); @@ -1092,21 +990,6 @@ void InspectorDOMAgent::didRemoveDOMNode(Node* node) if (isWhitespace(node)) return; - if (m_breakpoints.size()) { - // Remove subtree breakpoints. - m_breakpoints.remove(node); - Vector<Node*> stack(1, innerFirstChild(node)); - do { - Node* node = stack.last(); - stack.removeLast(); - if (!node) - continue; - m_breakpoints.remove(node); - stack.append(innerFirstChild(node)); - stack.append(innerNextSibling(node)); - } while (!stack.isEmpty()); - } - ContainerNode* parent = node->parentNode(); long parentId = m_documentNodeToIdMap.get(parent); // If parent is not mapped yet -> ignore the event. @@ -1146,31 +1029,6 @@ void InspectorDOMAgent::characterDataModified(CharacterData* characterData) m_frontend->characterDataModified(id, characterData->data()); } -bool InspectorDOMAgent::hasBreakpoint(Node* node, long type) -{ - uint32_t rootBit = 1 << type; - uint32_t derivedBit = rootBit << domBreakpointDerivedTypeShift; - return m_breakpoints.get(node) & (rootBit | derivedBit); -} - -void InspectorDOMAgent::updateSubtreeBreakpoints(Node* node, uint32_t rootMask, bool set) -{ - uint32_t oldMask = m_breakpoints.get(node); - uint32_t derivedMask = rootMask << domBreakpointDerivedTypeShift; - uint32_t newMask = set ? oldMask | derivedMask : oldMask & ~derivedMask; - if (newMask) - m_breakpoints.set(node, newMask); - else - m_breakpoints.remove(node); - - uint32_t newRootMask = rootMask & ~newMask; - if (!newRootMask) - return; - - for (Node* child = innerFirstChild(node); child; child = innerNextSibling(child)) - updateSubtreeBreakpoints(child, newRootMask, set); -} - Node* InspectorDOMAgent::nodeForPath(const String& path) { // The path is of form "1,HTML,2,BODY,1,DIV" diff --git a/Source/WebCore/inspector/InspectorDOMAgent.h b/Source/WebCore/inspector/InspectorDOMAgent.h index 1611baa..97175fe 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.h +++ b/Source/WebCore/inspector/InspectorDOMAgent.h @@ -124,7 +124,7 @@ namespace WebCore { bool shouldBreakOnNodeRemoval(Node* node, PassRefPtr<InspectorObject> details); bool shouldBreakOnAttributeModification(Element* element, PassRefPtr<InspectorObject> details); - // Methods called from the InspectorController. + // Methods called from the InspectorInstrumentation. void setDocument(Document* document); void releaseDanglingNodes(); @@ -144,10 +144,17 @@ namespace WebCore { String documentURLString(Document* document) const; - void setDOMBreakpoint(long nodeId, long type); - void removeDOMBreakpoint(long nodeId, long type); + // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently. + // We also skip whitespace text nodes conditionally. Following methods encapsulate these specifics. + static Node* innerFirstChild(Node*); + static Node* innerNextSibling(Node*); + static Node* innerPreviousSibling(Node*); + static unsigned innerChildNodeCount(Node*); + static Node* innerParentNode(Node*); + static bool isWhitespace(Node*); private: + void startListeningFrameDocument(Node* frameOwnerNode); void startListening(Document* document); void stopListening(Document* document); @@ -169,15 +176,6 @@ namespace WebCore { PassRefPtr<InspectorArray> buildArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap); PassRefPtr<InspectorObject> buildObjectForEventListener(const RegisteredEventListener& registeredEventListener, const AtomicString& eventType, Node* node); - // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently. - // We also skip whitespace text nodes conditionally. Following methods encapsulate these specifics. - Node* innerFirstChild(Node* node); - Node* innerNextSibling(Node* node); - Node* innerPreviousSibling(Node* node); - unsigned innerChildNodeCount(Node* node); - Node* innerParentNode(Node* node); - bool isWhitespace(Node* node); - Document* mainFrameDocument() const; void onMatchJobsTimer(Timer<InspectorDOMAgent>*); @@ -202,7 +200,6 @@ namespace WebCore { Timer<InspectorDOMAgent> m_matchJobsTimer; HashSet<RefPtr<Node> > m_searchResults; Vector<long> m_inspectedNodes; - HashMap<Node*, uint32_t> m_breakpoints; }; #endif diff --git a/Source/WebCore/inspector/InspectorDOMStorageAgent.h b/Source/WebCore/inspector/InspectorDOMStorageAgent.h index bdfd7cb..f1d4d5c 100644 --- a/Source/WebCore/inspector/InspectorDOMStorageAgent.h +++ b/Source/WebCore/inspector/InspectorDOMStorageAgent.h @@ -36,7 +36,6 @@ namespace WebCore { class InspectorArray; -class InspectorController; class InspectorDOMStorageResource; class InspectorFrontend; class Storage; diff --git a/Source/WebCore/inspector/InspectorDatabaseAgent.cpp b/Source/WebCore/inspector/InspectorDatabaseAgent.cpp index 88db3ae..36bcab8 100644 --- a/Source/WebCore/inspector/InspectorDatabaseAgent.cpp +++ b/Source/WebCore/inspector/InspectorDatabaseAgent.cpp @@ -34,9 +34,9 @@ #include "Database.h" #include "ExceptionCode.h" -#include "InspectorFrontend.h" #include "InspectorController.h" #include "InspectorDatabaseResource.h" +#include "InspectorFrontend.h" #include "InspectorValues.h" #include "SQLError.h" #include "SQLStatementCallback.h" diff --git a/Source/WebCore/inspector/InspectorDatabaseAgent.h b/Source/WebCore/inspector/InspectorDatabaseAgent.h index c73d3c8..a9e9a5d 100644 --- a/Source/WebCore/inspector/InspectorDatabaseAgent.h +++ b/Source/WebCore/inspector/InspectorDatabaseAgent.h @@ -37,7 +37,6 @@ namespace WebCore { class Database; class InspectorArray; -class InspectorController; class InspectorDatabaseResource; class InspectorFrontend; diff --git a/Source/WebCore/inspector/InspectorDebuggerAgent.cpp b/Source/WebCore/inspector/InspectorDebuggerAgent.cpp index 0046989..82c250a 100644 --- a/Source/WebCore/inspector/InspectorDebuggerAgent.cpp +++ b/Source/WebCore/inspector/InspectorDebuggerAgent.cpp @@ -152,17 +152,17 @@ void InspectorDebuggerAgent::resume() ScriptDebugServer::shared().continueProgram(); } -void InspectorDebuggerAgent::stepOverStatement() +void InspectorDebuggerAgent::stepOver() { ScriptDebugServer::shared().stepOverStatement(); } -void InspectorDebuggerAgent::stepIntoStatement() +void InspectorDebuggerAgent::stepInto() { ScriptDebugServer::shared().stepIntoStatement(); } -void InspectorDebuggerAgent::stepOutOfFunction() +void InspectorDebuggerAgent::stepOut() { ScriptDebugServer::shared().stepOutOfFunction(); } @@ -199,10 +199,10 @@ PassRefPtr<InspectorValue> InspectorDebuggerAgent::currentCallFrames() // JavaScriptDebugListener functions -void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType worldType) +void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String& url, const String& data, int lineOffset, int columnOffset, ScriptWorldType worldType) { // Don't send script content to the front end until it's really needed. - m_frontend->parsedScriptSource(sourceID, url, "", firstLine, worldType); + m_frontend->parsedScriptSource(sourceID, url, lineOffset, columnOffset, worldType); m_scriptIDToContent.set(sourceID, data); diff --git a/Source/WebCore/inspector/InspectorDebuggerAgent.h b/Source/WebCore/inspector/InspectorDebuggerAgent.h index 6e45e59..07d2ab9 100644 --- a/Source/WebCore/inspector/InspectorDebuggerAgent.h +++ b/Source/WebCore/inspector/InspectorDebuggerAgent.h @@ -73,9 +73,9 @@ public: void breakProgram(DebuggerEventType type, PassRefPtr<InspectorValue> data); void pause(); void resume(); - void stepOverStatement(); - void stepIntoStatement(); - void stepOutOfFunction(); + void stepOver(); + void stepInto(); + void stepOut(); void setPauseOnExceptionsState(long pauseState, long* newState); long pauseOnExceptionsState(); @@ -87,7 +87,7 @@ private: PassRefPtr<InspectorValue> currentCallFrames(); - virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType); + virtual void didParseSource(const String& sourceID, const String& url, const String& data, int lineOffset, int columnOffset, ScriptWorldType); virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage); virtual void didPause(ScriptState*); virtual void didContinue(); diff --git a/Source/WebCore/inspector/InspectorFrontendHost.cpp b/Source/WebCore/inspector/InspectorFrontendHost.cpp index 4b7e13f..342af0f 100644 --- a/Source/WebCore/inspector/InspectorFrontendHost.cpp +++ b/Source/WebCore/inspector/InspectorFrontendHost.cpp @@ -41,6 +41,7 @@ #include "FrameLoader.h" #include "HitTestResult.h" #include "HTMLFrameOwnerElement.h" +#include "InspectorController.h" #include "InspectorFrontendClient.h" #include "Page.h" #include "Pasteboard.h" diff --git a/Source/WebCore/inspector/InspectorFrontendHost.h b/Source/WebCore/inspector/InspectorFrontendHost.h index d333893..03c55a9 100644 --- a/Source/WebCore/inspector/InspectorFrontendHost.h +++ b/Source/WebCore/inspector/InspectorFrontendHost.h @@ -32,7 +32,6 @@ #include "Console.h" #include "ContextMenu.h" #include "ContextMenuProvider.h" -#include "InspectorController.h" #include "PlatformString.h" #include <wtf/RefCounted.h> @@ -46,6 +45,7 @@ class FrontendMenuProvider; class InspectorClient; class InspectorFrontendClient; class Node; +class Page; class InspectorFrontendHost : public RefCounted<InspectorFrontendHost> { diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp index f3a73ba..aa941df 100644 --- a/Source/WebCore/inspector/InspectorInstrumentation.cpp +++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp @@ -1,5 +1,5 @@ /* -* Copyright (C) 2010 Google Inc. All rights reserved. +* Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -34,21 +34,26 @@ #if ENABLE(INSPECTOR) #include "DOMWindow.h" +#include "Database.h" +#include "DocumentLoader.h" #include "Event.h" #include "EventContext.h" +#include "InspectorApplicationCacheAgent.h" +#include "InspectorBrowserDebuggerAgent.h" +#include "InspectorConsoleAgent.h" #include "InspectorController.h" #include "InspectorDOMAgent.h" #include "InspectorDebuggerAgent.h" +#include "InspectorProfilerAgent.h" +#include "InspectorResourceAgent.h" #include "InspectorTimelineAgent.h" +#include "ScriptArguments.h" +#include "ScriptCallStack.h" #include "XMLHttpRequest.h" #include <wtf/text/CString.h> namespace WebCore { -static const char* const domNativeBreakpointType = "DOM"; -static const char* const eventListenerNativeBreakpointType = "EventListener"; -static const char* const xhrNativeBreakpointType = "XHR"; - static const char* const listenerEventCategoryType = "listener"; static const char* const instrumentationEventCategoryType = "instrumentation"; @@ -75,20 +80,21 @@ static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window, return false; } +void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InspectorController* inspectorController, Frame* frame, DOMWrapperWorld* world) +{ + inspectorController->didClearWindowObjectInWorld(frame, world); +} + +void InspectorInstrumentation::inspectedPageDestroyedImpl(InspectorController* inspectorController) +{ + inspectorController->inspectedPageDestroyed(); +} + void InspectorInstrumentation::willInsertDOMNodeImpl(InspectorController* inspectorController, Node* node, Node* parent) { #if ENABLE(JAVASCRIPT_DEBUGGER) - InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get(); - if (!debuggerAgent) - return; - InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get(); - if (!domAgent) - return; - RefPtr<InspectorObject> eventData = InspectorObject::create(); - if (domAgent->shouldBreakOnNodeInsertion(node, parent, eventData)) { - eventData->setString("breakpointType", domNativeBreakpointType); - debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); - } + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + browserDebuggerAgent->willInsertDOMNode(node, parent); #endif } @@ -96,27 +102,26 @@ void InspectorInstrumentation::didInsertDOMNodeImpl(InspectorController* inspect { if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get()) domAgent->didInsertDOMNode(node); +#if ENABLE(JAVASCRIPT_DEBUGGER) + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + browserDebuggerAgent->didInsertDOMNode(node); +#endif } void InspectorInstrumentation::willRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node) { #if ENABLE(JAVASCRIPT_DEBUGGER) - InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get(); - if (!debuggerAgent) - return; - InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get(); - if (!domAgent) - return; - RefPtr<InspectorObject> eventData = InspectorObject::create(); - if (domAgent->shouldBreakOnNodeRemoval(node, eventData)) { - eventData->setString("breakpointType", domNativeBreakpointType); - debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); - } + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + browserDebuggerAgent->willRemoveDOMNode(node); #endif } void InspectorInstrumentation::didRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node) { +#if ENABLE(JAVASCRIPT_DEBUGGER) + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + browserDebuggerAgent->didRemoveDOMNode(node); +#endif if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get()) domAgent->didRemoveDOMNode(node); } @@ -124,17 +129,8 @@ void InspectorInstrumentation::didRemoveDOMNodeImpl(InspectorController* inspect void InspectorInstrumentation::willModifyDOMAttrImpl(InspectorController* inspectorController, Element* element) { #if ENABLE(JAVASCRIPT_DEBUGGER) - InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get(); - if (!debuggerAgent) - return; - InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get(); - if (!domAgent) - return; - RefPtr<InspectorObject> eventData = InspectorObject::create(); - if (domAgent->shouldBreakOnAttributeModification(element, eventData)) { - eventData->setString("breakpointType", domNativeBreakpointType); - debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); - } + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + browserDebuggerAgent->willModifyDOMAttr(element); #endif } @@ -144,6 +140,16 @@ void InspectorInstrumentation::didModifyDOMAttrImpl(InspectorController* inspect domAgent->didModifyDOMAttr(element); } +void InspectorInstrumentation::mouseDidMoveOverElementImpl(InspectorController* inspectorController, const HitTestResult& result, unsigned modifierFlags) +{ + inspectorController->mouseDidMoveOverElement(result, modifierFlags); +} + +bool InspectorInstrumentation::handleMousePressImpl(InspectorController* inspectorController) +{ + return inspectorController->handleMousePress(); +} + void InspectorInstrumentation::characterDataModifiedImpl(InspectorController* inspectorController, CharacterData* characterData) { if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get()) @@ -153,19 +159,8 @@ void InspectorInstrumentation::characterDataModifiedImpl(InspectorController* in void InspectorInstrumentation::willSendXMLHttpRequestImpl(InspectorController* inspectorController, const String& url) { #if ENABLE(JAVASCRIPT_DEBUGGER) - InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get(); - if (!debuggerAgent) - return; - - String breakpointURL; - if (!inspectorController->hasXHRBreakpoint(url, &breakpointURL)) - return; - - RefPtr<InspectorObject> eventData = InspectorObject::create(); - eventData->setString("breakpointType", xhrNativeBreakpointType); - eventData->setString("breakpointURL", breakpointURL); - eventData->setString("url", url); - debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + browserDebuggerAgent->willSendXMLHttpRequest(url); #endif } @@ -189,7 +184,6 @@ void InspectorInstrumentation::didRemoveTimerImpl(InspectorController* inspector timelineAgent->didRemoveTimer(timerId); } - InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(InspectorController* inspectorController, const String& scriptName, int scriptLine) { int timelineAgentId = 0; @@ -372,6 +366,40 @@ void InspectorInstrumentation::didRecalculateStyleImpl(const InspectorInstrument timelineAgent->didRecalculateStyle(); } +void InspectorInstrumentation::identifierForInitialRequestImpl(InspectorController* ic, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request) +{ + if (!ic->enabled()) + return; + ic->ensureSettingsLoaded(); + + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->identifierForInitialRequest(identifier, request.url(), loader); +} + +void InspectorInstrumentation::willSendRequestImpl(InspectorController* ic, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse) +{ + ic->willSendRequest(request); + if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(ic)) + timelineAgent->willSendResourceRequest(identifier, request); + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->willSendRequest(identifier, request, redirectResponse); +} + +void InspectorInstrumentation::markResourceAsCachedImpl(InspectorController* ic, unsigned long identifier) +{ + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->markResourceAsCached(identifier); +} + +void InspectorInstrumentation::didLoadResourceFromMemoryCacheImpl(InspectorController* ic, DocumentLoader* loader, const CachedResource* cachedResource) +{ + if (!ic->enabled()) + return; + ic->ensureSettingsLoaded(); + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->didLoadResourceFromMemoryCache(loader, cachedResource); +} + InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceDataImpl(InspectorController* inspectorController, unsigned long identifier) { int timelineAgentId = 0; @@ -400,12 +428,73 @@ InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResp return InspectorInstrumentationCookie(inspectorController, timelineAgentId); } -void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie) +void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response) { + InspectorController* ic = cookie.first; + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->didReceiveResponse(identifier, loader, response); + ic->m_consoleAgent->didReceiveResponse(identifier, response); if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie)) timelineAgent->didReceiveResourceResponse(); } +void InspectorInstrumentation::didReceiveContentLengthImpl(InspectorController* ic, unsigned long identifier, int lengthReceived) +{ + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->didReceiveContentLength(identifier, lengthReceived); +} + +void InspectorInstrumentation::didFinishLoadingImpl(InspectorController* ic, unsigned long identifier, double finishTime) +{ + if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(ic)) + timelineAgent->didFinishLoadingResource(identifier, false, finishTime); + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->didFinishLoading(identifier, finishTime); +} + +void InspectorInstrumentation::didFailLoadingImpl(InspectorController* ic, unsigned long identifier, const ResourceError& error) +{ + ic->m_consoleAgent->didFailLoading(identifier, error); + if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(ic)) + timelineAgent->didFinishLoadingResource(identifier, true, 0); + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->didFailLoading(identifier, error); +} + +void InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl(InspectorController* ic, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber) +{ + ic->m_consoleAgent->resourceRetrievedByXMLHttpRequest(url, sendURL, sendLineNumber); + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->setInitialContent(identifier, sourceString, "XHR"); +} + +void InspectorInstrumentation::scriptImportedImpl(InspectorController* ic, unsigned long identifier, const String& sourceString) +{ + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic)) + resourceAgent->setInitialContent(identifier, sourceString, "Script"); +} + +void InspectorInstrumentation::mainResourceFiredLoadEventImpl(InspectorController* inspectorController, Frame* frame, const KURL& url) +{ + inspectorController->mainResourceFiredLoadEvent(frame->loader()->documentLoader(), url); +} + +void InspectorInstrumentation::mainResourceFiredDOMContentEventImpl(InspectorController* inspectorController, Frame* frame, const KURL& url) +{ + inspectorController->mainResourceFiredDOMContentEvent(frame->loader()->documentLoader(), url); +} + +void InspectorInstrumentation::frameDetachedFromParentImpl(InspectorController* inspectorController, Frame* frame) +{ + if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(inspectorController)) + resourceAgent->frameDetachedFromParent(frame); +} + +void InspectorInstrumentation::didCommitLoadImpl(InspectorController* inspectorController, DocumentLoader* loader) +{ + inspectorController->didCommitLoad(loader); +} + InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTMLImpl(InspectorController* inspectorController, unsigned int length, unsigned int startLine) { int timelineAgentId = 0; @@ -423,6 +512,74 @@ void InspectorInstrumentation::didWriteHTMLImpl(const InspectorInstrumentationCo timelineAgent->didWriteHTML(endLine); } +void InspectorInstrumentation::addMessageToConsoleImpl(InspectorController* inspectorController, MessageSource source, MessageType type, MessageLevel level, const String& message, ScriptArguments* arguments, ScriptCallStack* callStack) +{ + inspectorController->consoleAgent()->addMessageToConsole(source, type, level, message, arguments, callStack); +} + +void InspectorInstrumentation::addMessageToConsoleImpl(InspectorController* inspectorController, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) +{ + inspectorController->consoleAgent()->addMessageToConsole(source, type, level, message, lineNumber, sourceID); +} + +void InspectorInstrumentation::consoleCountImpl(InspectorController* inspectorController, ScriptArguments* arguments, ScriptCallStack* stack) +{ + inspectorController->consoleAgent()->count(arguments, stack); +} + +void InspectorInstrumentation::startConsoleTimingImpl(InspectorController* inspectorController, const String& title) +{ + inspectorController->consoleAgent()->startTiming(title); +} + +void InspectorInstrumentation::stopConsoleTimingImpl(InspectorController* inspectorController, const String& title, ScriptCallStack* stack) +{ + inspectorController->consoleAgent()->stopTiming(title, stack); +} + +void InspectorInstrumentation::consoleMarkTimelineImpl(InspectorController* inspectorController, ScriptArguments* arguments) +{ + if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) { + String message; + arguments->getFirstArgumentAsString(message); + timelineAgent->didMarkTimeline(message); + } +} + +#if ENABLE(JAVASCRIPT_DEBUGGER) +void InspectorInstrumentation::addStartProfilingMessageToConsoleImpl(InspectorController* inspectorController, const String& title, unsigned lineNumber, const String& sourceURL) +{ + if (InspectorProfilerAgent* profilerAgent = inspectorController->m_profilerAgent.get()) + profilerAgent->addStartProfilingMessageToConsole(title, lineNumber, sourceURL); +} +#endif + +#if ENABLE(DATABASE) +void InspectorInstrumentation::didOpenDatabaseImpl(InspectorController* inspectorController, Database* database, const String& domain, const String& name, const String& version) +{ + inspectorController->didOpenDatabase(database, domain, name, version); +} +#endif + +#if ENABLE(DOM_STORAGE) +void InspectorInstrumentation::didUseDOMStorageImpl(InspectorController* inspectorController, StorageArea* storageArea, bool isLocalStorage, Frame* frame) +{ + inspectorController->didUseDOMStorage(storageArea, isLocalStorage, frame); +} +#endif + +#if ENABLE(WORKERS) +void InspectorInstrumentation::didCreateWorkerImpl(InspectorController* inspectorController, intptr_t id, const String& url, bool isSharedWorker) +{ + inspectorController->didCreateWorker(id, url, isSharedWorker); +} + +void InspectorInstrumentation::didDestroyWorkerImpl(InspectorController* inspectorController, intptr_t id) +{ + inspectorController->didDestroyWorker(id); +} +#endif + #if ENABLE(WEB_SOCKETS) void InspectorInstrumentation::didCreateWebSocketImpl(InspectorController* inspectorController, unsigned long identifier, const KURL& requestURL, const KURL& documentURL) { @@ -445,6 +602,20 @@ void InspectorInstrumentation::didCloseWebSocketImpl(InspectorController* inspec } #endif +#if ENABLE(OFFLINE_WEB_APPLICATIONS) +void InspectorInstrumentation::networkStateChangedImpl(InspectorController* ic) +{ + if (InspectorApplicationCacheAgent* applicationCacheAgent = ic->applicationCacheAgent()) + applicationCacheAgent->networkStateChanged(); +} + +void InspectorInstrumentation::updateApplicationCacheStatusImpl(InspectorController* ic, Frame* frame) +{ + if (InspectorApplicationCacheAgent* applicationCacheAgent = ic->applicationCacheAgent()) + applicationCacheAgent->updateApplicationCacheStatus(frame); +} +#endif + bool InspectorInstrumentation::hasFrontend(InspectorController* inspectorController) { return inspectorController->hasFrontend(); @@ -453,19 +624,8 @@ bool InspectorInstrumentation::hasFrontend(InspectorController* inspectorControl void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InspectorController* inspectorController, const String& categoryType, const String& eventName, bool synchronous) { #if ENABLE(JAVASCRIPT_DEBUGGER) - InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get(); - if (!debuggerAgent) - return; - String fullEventName = String::format("%s:%s", categoryType.utf8().data(), eventName.utf8().data()); - if (!inspectorController->hasEventListenerBreakpoint(fullEventName)) - return; - RefPtr<InspectorObject> eventData = InspectorObject::create(); - eventData->setString("breakpointType", eventListenerNativeBreakpointType); - eventData->setString("eventName", fullEventName); - if (synchronous) - debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); - else - debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData); + if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get()) + browserDebuggerAgent->pauseOnNativeEventIfNeeded(categoryType, eventName, synchronous); #endif } @@ -490,6 +650,11 @@ InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(const In return 0; } +InspectorResourceAgent* InspectorInstrumentation::retrieveResourceAgent(InspectorController* ic) +{ + return ic->m_resourceAgent.get(); +} + } // namespace WebCore #endif // !ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h index 9c69055..28867cb 100644 --- a/Source/WebCore/inspector/InspectorInstrumentation.h +++ b/Source/WebCore/inspector/InspectorInstrumentation.h @@ -31,22 +31,34 @@ #ifndef InspectorInstrumentation_h #define InspectorInstrumentation_h +#include "Console.h" #include "Frame.h" #include "Page.h" #include "ScriptExecutionContext.h" +#include <wtf/PassRefPtr.h> + namespace WebCore { class CharacterData; +class DOMWrapperWorld; +class Database; class Document; class Element; class EventContext; +class DocumentLoader; +class HitTestResult; class InspectorController; +class InspectorResourceAgent; class InspectorTimelineAgent; class KURL; class Node; class ResourceRequest; class ResourceResponse; +class ScriptArguments; +class ScriptCallStack; +class ScriptExecutionContext; +class StorageArea; class XMLHttpRequest; #if ENABLE(WEB_SOCKETS) @@ -58,6 +70,9 @@ typedef pair<InspectorController*, int> InspectorInstrumentationCookie; class InspectorInstrumentation { public: + static void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*); + static void inspectedPageDestroyed(Page*); + static void willInsertDOMNode(Document*, Node*, Node* parent); static void didInsertDOMNode(Document*, Node*); static void willRemoveDOMNode(Document*, Node*); @@ -65,6 +80,9 @@ public: static void didModifyDOMAttr(Document*, Element*); static void characterDataModified(Document*, CharacterData*); + static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags); + static bool handleMousePress(Page*); + static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url); static void didScheduleResourceRequest(Document*, const String& url); static void didInstallTimer(ScriptExecutionContext*, int timerId, int timeout, bool singleShot); @@ -90,13 +108,52 @@ public: static void didPaint(const InspectorInstrumentationCookie&); static InspectorInstrumentationCookie willRecalculateStyle(Document*); static void didRecalculateStyle(const InspectorInstrumentationCookie&); + + static void identifierForInitialRequest(Frame*, unsigned long identifier, DocumentLoader*, const ResourceRequest&); + static void willSendRequest(Frame*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse); + static void markResourceAsCached(Page*, unsigned long identifier); + static void didLoadResourceFromMemoryCache(Page*, DocumentLoader*, const CachedResource*); static InspectorInstrumentationCookie willReceiveResourceData(Frame*, unsigned long identifier); static void didReceiveResourceData(const InspectorInstrumentationCookie&); - static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*, unsigned long identifier, const ResourceResponse& response); - static void didReceiveResourceResponse(const InspectorInstrumentationCookie&); + static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*, unsigned long identifier, const ResourceResponse&); + static void didReceiveResourceResponse(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&); + static void didReceiveContentLength(Frame*, unsigned long identifier, int lengthReceived); + static void didFinishLoading(Frame*, unsigned long identifier, double finishTime); + static void didFailLoading(Frame*, unsigned long identifier, const ResourceError&); + static void resourceRetrievedByXMLHttpRequest(ScriptExecutionContext*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber); + static void scriptImported(ScriptExecutionContext*, unsigned long identifier, const String& sourceString); + static void mainResourceFiredLoadEvent(Frame*, const KURL&); + static void mainResourceFiredDOMContentEvent(Frame*, const KURL&); + static void frameDetachedFromParent(Frame*); + static void didCommitLoad(Frame*, DocumentLoader*); + static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine); static void didWriteHTML(const InspectorInstrumentationCookie&, unsigned int endLine); + static void addMessageToConsole(Page*, MessageSource, MessageType, MessageLevel, const String& message, ScriptArguments*, ScriptCallStack*); + static void addMessageToConsole(Page*, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String&); + static void consoleCount(Page*, ScriptArguments*, ScriptCallStack*); + static void startConsoleTiming(Page*, const String& title); + static void stopConsoleTiming(Page*, const String& title, ScriptCallStack*); + static void consoleMarkTimeline(Page*, ScriptArguments*); + +#if ENABLE(JAVASCRIPT_DEBUGGER) + static void addStartProfilingMessageToConsole(Page*, const String& title, unsigned lineNumber, const String& sourceURL); +#endif + +#if ENABLE(DATABASE) + static void didOpenDatabase(ScriptExecutionContext*, Database*, const String& domain, const String& name, const String& version); +#endif + +#if ENABLE(DOM_STORAGE) + static void didUseDOMStorage(Page*, StorageArea*, bool isLocalStorage, Frame*); +#endif + +#if ENABLE(WORKERS) + static void didCreateWorker(ScriptExecutionContext*, intptr_t id, const String& url, bool isSharedWorker); + static void didDestroyWorker(ScriptExecutionContext*, intptr_t id); +#endif + #if ENABLE(WEB_SOCKETS) static void didCreateWebSocket(ScriptExecutionContext*, unsigned long identifier, const KURL& requestURL, const KURL& documentURL); static void willSendWebSocketHandshakeRequest(ScriptExecutionContext*, unsigned long identifier, const WebSocketHandshakeRequest&); @@ -104,6 +161,12 @@ public: static void didCloseWebSocket(ScriptExecutionContext*, unsigned long identifier); #endif + static void networkStateChanged(Page*); + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + static void updateApplicationCacheStatus(Frame*); +#endif + #if ENABLE(INSPECTOR) static void frontendCreated() { s_frontendCounter += 1; } static void frontendDeleted() { s_frontendCounter -= 1; } @@ -114,6 +177,9 @@ public: private: #if ENABLE(INSPECTOR) + static void didClearWindowObjectInWorldImpl(InspectorController*, Frame*, DOMWrapperWorld*); + static void inspectedPageDestroyedImpl(InspectorController*); + static void willInsertDOMNodeImpl(InspectorController*, Node* node, Node* parent); static void didInsertDOMNodeImpl(InspectorController*, Node*); static void willRemoveDOMNodeImpl(InspectorController*, Node*); @@ -122,6 +188,9 @@ private: static void didModifyDOMAttrImpl(InspectorController*, Element*); static void characterDataModifiedImpl(InspectorController*, CharacterData*); + static void mouseDidMoveOverElementImpl(InspectorController*, const HitTestResult&, unsigned modifierFlags); + static bool handleMousePressImpl(InspectorController*); + static void willSendXMLHttpRequestImpl(InspectorController*, const String& url); static void didScheduleResourceRequestImpl(InspectorController*, const String& url); static void didInstallTimerImpl(InspectorController*, int timerId, int timeout, bool singleShot); @@ -147,13 +216,51 @@ private: static void didPaintImpl(const InspectorInstrumentationCookie&); static InspectorInstrumentationCookie willRecalculateStyleImpl(InspectorController*); static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&); + static void identifierForInitialRequestImpl(InspectorController*, unsigned long identifier, DocumentLoader*, const ResourceRequest&); + static void willSendRequestImpl(InspectorController*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse); + static void markResourceAsCachedImpl(InspectorController*, unsigned long identifier); + static void didLoadResourceFromMemoryCacheImpl(InspectorController*, DocumentLoader*, const CachedResource*); static InspectorInstrumentationCookie willReceiveResourceDataImpl(InspectorController*, unsigned long identifier); static void didReceiveResourceDataImpl(const InspectorInstrumentationCookie&); - static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InspectorController*, unsigned long identifier, const ResourceResponse& response); - static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&); + static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InspectorController*, unsigned long identifier, const ResourceResponse&); + static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&); + static void didReceiveContentLengthImpl(InspectorController*, unsigned long identifier, int lengthReceived); + static void didFinishLoadingImpl(InspectorController*, unsigned long identifier, double finishTime); + static void didFailLoadingImpl(InspectorController*, unsigned long identifier, const ResourceError&); + static void resourceRetrievedByXMLHttpRequestImpl(InspectorController*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber); + static void scriptImportedImpl(InspectorController*, unsigned long identifier, const String& sourceString); + static void mainResourceFiredLoadEventImpl(InspectorController*, Frame*, const KURL&); + static void mainResourceFiredDOMContentEventImpl(InspectorController*, Frame*, const KURL&); + static void frameDetachedFromParentImpl(InspectorController*, Frame*); + static void didCommitLoadImpl(InspectorController*, DocumentLoader*); + static InspectorInstrumentationCookie willWriteHTMLImpl(InspectorController*, unsigned int length, unsigned int startLine); static void didWriteHTMLImpl(const InspectorInstrumentationCookie&, unsigned int endLine); + static void addMessageToConsoleImpl(InspectorController*, MessageSource, MessageType, MessageLevel, const String& message, ScriptArguments*, ScriptCallStack*); + static void addMessageToConsoleImpl(InspectorController*, MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID); + static void consoleCountImpl(InspectorController*, ScriptArguments*, ScriptCallStack*); + static void startConsoleTimingImpl(InspectorController*, const String& title); + static void stopConsoleTimingImpl(InspectorController*, const String& title, ScriptCallStack*); + static void consoleMarkTimelineImpl(InspectorController*, ScriptArguments*); + +#if ENABLE(JAVASCRIPT_DEBUGGER) + static void addStartProfilingMessageToConsoleImpl(InspectorController*, const String& title, unsigned lineNumber, const String& sourceURL); +#endif + +#if ENABLE(DATABASE) + static void didOpenDatabaseImpl(InspectorController*, Database*, const String& domain, const String& name, const String& version); +#endif + +#if ENABLE(DOM_STORAGE) + static void didUseDOMStorageImpl(InspectorController*, StorageArea*, bool isLocalStorage, Frame*); +#endif + +#if ENABLE(WORKERS) + static void didCreateWorkerImpl(InspectorController*, intptr_t id, const String& url, bool isSharedWorker); + static void didDestroyWorkerImpl(InspectorController*, intptr_t id); +#endif + #if ENABLE(WEB_SOCKETS) static void didCreateWebSocketImpl(InspectorController*, unsigned long identifier, const KURL& requestURL, const KURL& documentURL); static void willSendWebSocketHandshakeRequestImpl(InspectorController*, unsigned long identifier, const WebSocketHandshakeRequest&); @@ -161,25 +268,50 @@ private: static void didCloseWebSocketImpl(InspectorController*, unsigned long identifier); #endif - static InspectorController* inspectorControllerForContext(ScriptExecutionContext*); - static InspectorController* inspectorControllerForDocument(Document*); +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + static void networkStateChangedImpl(InspectorController*); + static void updateApplicationCacheStatusImpl(InspectorController*, Frame*); +#endif + static InspectorController* inspectorControllerForFrame(Frame*); + static InspectorController* inspectorControllerForContext(ScriptExecutionContext*); static InspectorController* inspectorControllerForPage(Page*); + static InspectorController* inspectorControllerWithFrontendForContext(ScriptExecutionContext*); + static InspectorController* inspectorControllerWithFrontendForDocument(Document*); + static InspectorController* inspectorControllerWithFrontendForFrame(Frame*); + static InspectorController* inspectorControllerWithFrontendForPage(Page*); static bool hasFrontend(InspectorController*); static void pauseOnNativeEventIfNeeded(InspectorController*, const String& categoryType, const String& eventName, bool synchronous); static void cancelPauseOnNativeEvent(InspectorController*); static InspectorTimelineAgent* retrieveTimelineAgent(InspectorController*); static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&); + static InspectorResourceAgent* retrieveResourceAgent(InspectorController*); static int s_frontendCounter; #endif }; +inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForFrame(frame)) + didClearWindowObjectInWorldImpl(inspectorController, frame, world); +#endif +} + +inline void InspectorInstrumentation::inspectedPageDestroyed(Page* page) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + inspectedPageDestroyedImpl(inspectorController); +#endif +} + inline void InspectorInstrumentation::willInsertDOMNode(Document* document, Node* node, Node* parent) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) willInsertDOMNodeImpl(inspectorController, node, parent); #endif } @@ -187,7 +319,7 @@ inline void InspectorInstrumentation::willInsertDOMNode(Document* document, Node inline void InspectorInstrumentation::didInsertDOMNode(Document* document, Node* node) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) didInsertDOMNodeImpl(inspectorController, node); #endif } @@ -195,7 +327,7 @@ inline void InspectorInstrumentation::didInsertDOMNode(Document* document, Node* inline void InspectorInstrumentation::willRemoveDOMNode(Document* document, Node* node) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) { + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) { willRemoveDOMNodeImpl(inspectorController, node); didRemoveDOMNodeImpl(inspectorController, node); } @@ -205,7 +337,7 @@ inline void InspectorInstrumentation::willRemoveDOMNode(Document* document, Node inline void InspectorInstrumentation::willModifyDOMAttr(Document* document, Element* element) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) willModifyDOMAttrImpl(inspectorController, element); #endif } @@ -213,15 +345,32 @@ inline void InspectorInstrumentation::willModifyDOMAttr(Document* document, Elem inline void InspectorInstrumentation::didModifyDOMAttr(Document* document, Element* element) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) didModifyDOMAttrImpl(inspectorController, element); #endif } +inline void InspectorInstrumentation::mouseDidMoveOverElement(Page* page, const HitTestResult& result, unsigned modifierFlags) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForPage(page)) + mouseDidMoveOverElementImpl(inspectorController, result, modifierFlags); +#endif +} + +inline bool InspectorInstrumentation::handleMousePress(Page* page) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForPage(page)) + return handleMousePressImpl(inspectorController); +#endif + return false; +} + inline void InspectorInstrumentation::characterDataModified(Document* document, CharacterData* characterData) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) characterDataModifiedImpl(inspectorController, characterData); #endif } @@ -229,7 +378,7 @@ inline void InspectorInstrumentation::characterDataModified(Document* document, inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) willSendXMLHttpRequestImpl(inspectorController, url); #endif } @@ -237,7 +386,7 @@ inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionCont inline void InspectorInstrumentation::didScheduleResourceRequest(Document* document, const String& url) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) didScheduleResourceRequestImpl(inspectorController, url); #endif } @@ -245,7 +394,7 @@ inline void InspectorInstrumentation::didScheduleResourceRequest(Document* docum inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, int timeout, bool singleShot) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) didInstallTimerImpl(inspectorController, timerId, timeout, singleShot); #endif } @@ -253,7 +402,7 @@ inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* co inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext* context, int timerId) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) didRemoveTimerImpl(inspectorController, timerId); #endif } @@ -262,7 +411,7 @@ inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext* con inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(Frame* frame, const String& scriptName, int scriptLine) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForFrame(frame)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) return willCallFunctionImpl(inspectorController, scriptName, scriptLine); #endif return InspectorInstrumentationCookie(); @@ -279,7 +428,7 @@ inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumenta inline InspectorInstrumentationCookie InspectorInstrumentation::willChangeXHRReadyState(ScriptExecutionContext* context, XMLHttpRequest* request) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) return willChangeXHRReadyStateImpl(inspectorController, request); #endif return InspectorInstrumentationCookie(); @@ -296,7 +445,7 @@ inline void InspectorInstrumentation::didChangeXHRReadyState(const InspectorInst inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document* document, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) return willDispatchEventImpl(inspectorController, event, window, node, ancestors); #endif return InspectorInstrumentationCookie(); @@ -313,7 +462,7 @@ inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrument inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindow(Frame* frame, const Event& event, DOMWindow* window) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForFrame(frame)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) return willDispatchEventOnWindowImpl(inspectorController, event, window); #endif return InspectorInstrumentationCookie(); @@ -330,7 +479,7 @@ inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorIn inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame* frame, const String& url, int lineNumber) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForFrame(frame)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) return willEvaluateScriptImpl(inspectorController, url, lineNumber); #endif return InspectorInstrumentationCookie(); @@ -347,7 +496,7 @@ inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumen inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext* context, int timerId) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) return willFireTimerImpl(inspectorController, timerId); #endif return InspectorInstrumentationCookie(); @@ -364,7 +513,7 @@ inline void InspectorInstrumentation::didFireTimer(const InspectorInstrumentatio inline InspectorInstrumentationCookie InspectorInstrumentation::willLayout(Frame* frame) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForFrame(frame)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) return willLayoutImpl(inspectorController); #endif return InspectorInstrumentationCookie(); @@ -381,7 +530,7 @@ inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCo inline InspectorInstrumentationCookie InspectorInstrumentation::willLoadXHR(ScriptExecutionContext* context, XMLHttpRequest* request) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) return willLoadXHRImpl(inspectorController, request); #endif return InspectorInstrumentationCookie(); @@ -398,7 +547,7 @@ inline void InspectorInstrumentation::didLoadXHR(const InspectorInstrumentationC inline InspectorInstrumentationCookie InspectorInstrumentation::willPaint(Frame* frame, const IntRect& rect) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForFrame(frame)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) return willPaintImpl(inspectorController, rect); #endif return InspectorInstrumentationCookie(); @@ -415,7 +564,7 @@ inline void InspectorInstrumentation::didPaint(const InspectorInstrumentationCoo inline InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyle(Document* document) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) return willRecalculateStyleImpl(inspectorController); #endif return InspectorInstrumentationCookie(); @@ -429,10 +578,43 @@ inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrum #endif } +inline void InspectorInstrumentation::identifierForInitialRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request) +{ +#if ENABLE(INSPECTOR) + // This notification should be procecessed even in cases there is no frontend. + if (!frame) + return; + if (InspectorController* ic = inspectorControllerForPage(frame->page())) + identifierForInitialRequestImpl(ic, identifier, loader, request); +#endif +} + +inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* ic = inspectorControllerWithFrontendForFrame(frame)) + willSendRequestImpl(ic, identifier, request, redirectResponse); +#endif +} + +inline void InspectorInstrumentation::markResourceAsCached(Page* page, unsigned long identifier) +{ +#if ENABLE(INSPECTOR) + markResourceAsCachedImpl(inspectorControllerForPage(page), identifier); +#endif +} + +inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page* page, DocumentLoader* loader, const CachedResource* resource) +{ +#if ENABLE(INSPECTOR) + didLoadResourceFromMemoryCacheImpl(inspectorControllerForPage(page), loader, resource); +#endif +} + inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceData(Frame* frame, unsigned long identifier) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForFrame(frame)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) return willReceiveResourceDataImpl(inspectorController, identifier); #endif return InspectorInstrumentationCookie(); @@ -449,24 +631,96 @@ inline void InspectorInstrumentation::didReceiveResourceData(const InspectorInst inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponse(Frame* frame, unsigned long identifier, const ResourceResponse& response) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForFrame(frame)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) return willReceiveResourceResponseImpl(inspectorController, identifier, response); #endif return InspectorInstrumentationCookie(); } -inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie) +inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response) { #if ENABLE(INSPECTOR) if (hasFrontends() && cookie.first) - didReceiveResourceResponseImpl(cookie); + didReceiveResourceResponseImpl(cookie, identifier, loader, response); +#endif +} + +inline void InspectorInstrumentation::didReceiveContentLength(Frame* frame, unsigned long identifier, int lengthReceived) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) + didReceiveContentLengthImpl(inspectorController, identifier, lengthReceived); +#endif +} + +inline void InspectorInstrumentation::didFinishLoading(Frame* frame, unsigned long identifier, double finishTime) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) + didFinishLoadingImpl(inspectorController, identifier, finishTime); +#endif +} + +inline void InspectorInstrumentation::didFailLoading(Frame* frame, unsigned long identifier, const ResourceError& error) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) + didFailLoadingImpl(inspectorController, identifier, error); +#endif +} + +inline void InspectorInstrumentation::resourceRetrievedByXMLHttpRequest(ScriptExecutionContext* context, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForContext(context)) + resourceRetrievedByXMLHttpRequestImpl(inspectorController, identifier, sourceString, url, sendURL, sendLineNumber); +#endif +} + +inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext* context, unsigned long identifier, const String& sourceString) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForContext(context)) + scriptImportedImpl(inspectorController, identifier, sourceString); +#endif +} + +inline void InspectorInstrumentation::mainResourceFiredLoadEvent(Frame* frame, const KURL& url) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) + mainResourceFiredLoadEventImpl(inspectorController, frame, url); +#endif +} + +inline void InspectorInstrumentation::mainResourceFiredDOMContentEvent(Frame* frame, const KURL& url) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) + mainResourceFiredDOMContentEventImpl(inspectorController, frame, url); +#endif +} + +inline void InspectorInstrumentation::frameDetachedFromParent(Frame* frame) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) + frameDetachedFromParentImpl(inspectorController, frame); +#endif +} + +inline void InspectorInstrumentation::didCommitLoad(Frame* frame, DocumentLoader* loader) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForFrame(frame)) + didCommitLoadImpl(inspectorController, loader); #endif } inline InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTML(Document* document, unsigned int length, unsigned int startLine) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForDocument(document)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForDocument(document)) return willWriteHTMLImpl(inspectorController, length, startLine); #endif return InspectorInstrumentationCookie(); @@ -480,11 +734,50 @@ inline void InspectorInstrumentation::didWriteHTML(const InspectorInstrumentatio #endif } +#if ENABLE(DATABASE) +inline void InspectorInstrumentation::didOpenDatabase(ScriptExecutionContext* context, Database* database, const String& domain, const String& name, const String& version) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForContext(context)) + didOpenDatabaseImpl(inspectorController, database, domain, name, version); +#endif +} +#endif + +#if ENABLE(DOM_STORAGE) +inline void InspectorInstrumentation::didUseDOMStorage(Page* page, StorageArea* storageArea, bool isLocalStorage, Frame* frame) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + didUseDOMStorageImpl(inspectorController, storageArea, isLocalStorage, frame); +#endif +} +#endif + +#if ENABLE(WORKERS) +inline void InspectorInstrumentation::didCreateWorker(ScriptExecutionContext* context, intptr_t id, const String& url, bool isSharedWorker) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) + didCreateWorkerImpl(inspectorController, id, url, isSharedWorker); +#endif +} + +inline void InspectorInstrumentation::didDestroyWorker(ScriptExecutionContext* context, intptr_t id) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) + didDestroyWorkerImpl(inspectorController, id); +#endif +} +#endif + + #if ENABLE(WEB_SOCKETS) inline void InspectorInstrumentation::didCreateWebSocket(ScriptExecutionContext* context, unsigned long identifier, const KURL& requestURL, const KURL& documentURL) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) didCreateWebSocketImpl(inspectorController, identifier, requestURL, documentURL); #endif } @@ -492,7 +785,7 @@ inline void InspectorInstrumentation::didCreateWebSocket(ScriptExecutionContext* inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(ScriptExecutionContext* context, unsigned long identifier, const WebSocketHandshakeRequest& request) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) willSendWebSocketHandshakeRequestImpl(inspectorController, identifier, request); #endif } @@ -500,7 +793,7 @@ inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(ScriptEx inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(ScriptExecutionContext* context, unsigned long identifier, const WebSocketHandshakeResponse& response) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) didReceiveWebSocketHandshakeResponseImpl(inspectorController, identifier, response); #endif } @@ -508,38 +801,135 @@ inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(Scrip inline void InspectorInstrumentation::didCloseWebSocket(ScriptExecutionContext* context, unsigned long identifier) { #if ENABLE(INSPECTOR) - if (InspectorController* inspectorController = inspectorControllerForContext(context)) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForContext(context)) didCloseWebSocketImpl(inspectorController, identifier); #endif } #endif +inline void InspectorInstrumentation::networkStateChanged(Page* page) +{ +#if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForPage(page)) + networkStateChangedImpl(inspectorController); +#endif +} + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) +inline void InspectorInstrumentation::updateApplicationCacheStatus(Frame* frame) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForFrame(frame)) + updateApplicationCacheStatusImpl(inspectorController, frame); +#endif +} +#endif + +inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, ScriptArguments* arguments, ScriptCallStack* callStack) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + addMessageToConsoleImpl(inspectorController, source, type, level, message, arguments, callStack); +#endif +} + +inline void InspectorInstrumentation::addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + addMessageToConsoleImpl(inspectorController, source, type, level, message, lineNumber, sourceID); +#endif +} + +inline void InspectorInstrumentation::consoleCount(Page* page, ScriptArguments* arguments, ScriptCallStack* stack) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + consoleCountImpl(inspectorController, arguments, stack); +#endif +} + +inline void InspectorInstrumentation::startConsoleTiming(Page* page, const String& title) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + startConsoleTimingImpl(inspectorController, title); +#endif +} + +inline void InspectorInstrumentation::stopConsoleTiming(Page* page, const String& title, ScriptCallStack* stack) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + stopConsoleTimingImpl(inspectorController, title, stack); +#endif +} + +inline void InspectorInstrumentation::consoleMarkTimeline(Page* page, ScriptArguments* arguments) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerWithFrontendForPage(page)) + consoleMarkTimelineImpl(inspectorController, arguments); +#endif +} + +#if ENABLE(JAVASCRIPT_DEBUGGER) +inline void InspectorInstrumentation::addStartProfilingMessageToConsole(Page* page, const String& title, unsigned lineNumber, const String& sourceURL) +{ +#if ENABLE(INSPECTOR) + if (InspectorController* inspectorController = inspectorControllerForPage(page)) + addStartProfilingMessageToConsoleImpl(inspectorController, title, lineNumber, sourceURL); +#endif +} +#endif + #if ENABLE(INSPECTOR) inline InspectorController* InspectorInstrumentation::inspectorControllerForContext(ScriptExecutionContext* context) { - if (hasFrontends() && context && context->isDocument()) + if (context && context->isDocument()) return inspectorControllerForPage(static_cast<Document*>(context)->page()); return 0; } -inline InspectorController* InspectorInstrumentation::inspectorControllerForDocument(Document* document) +inline InspectorController* InspectorInstrumentation::inspectorControllerForFrame(Frame* frame) +{ + if (frame) + return inspectorControllerForPage(frame->page()); + return 0; +} + +inline InspectorController* InspectorInstrumentation::inspectorControllerForPage(Page* page) +{ + if (!page) + return 0; + return page->inspectorController(); +} + +inline InspectorController* InspectorInstrumentation::inspectorControllerWithFrontendForContext(ScriptExecutionContext* context) +{ + if (hasFrontends() && context && context->isDocument()) + return inspectorControllerWithFrontendForPage(static_cast<Document*>(context)->page()); + return 0; +} + +inline InspectorController* InspectorInstrumentation::inspectorControllerWithFrontendForDocument(Document* document) { if (hasFrontends() && document) - return inspectorControllerForPage(document->page()); + return inspectorControllerWithFrontendForPage(document->page()); return 0; } -inline InspectorController* InspectorInstrumentation::inspectorControllerForFrame(Frame* frame) +inline InspectorController* InspectorInstrumentation::inspectorControllerWithFrontendForFrame(Frame* frame) { if (hasFrontends() && frame) - return inspectorControllerForPage(frame->page()); + return inspectorControllerWithFrontendForPage(frame->page()); return 0; } -inline InspectorController* InspectorInstrumentation::inspectorControllerForPage(Page* page) +inline InspectorController* InspectorInstrumentation::inspectorControllerWithFrontendForPage(Page* page) { if (page) { - if (InspectorController* inspectorController = page->inspectorController()) { + if (InspectorController* inspectorController = inspectorControllerForPage(page)) { if (hasFrontend(inspectorController)) return inspectorController; } diff --git a/Source/WebCore/inspector/InspectorProfilerAgent.cpp b/Source/WebCore/inspector/InspectorProfilerAgent.cpp index ac67a1a..da9b67d 100644 --- a/Source/WebCore/inspector/InspectorProfilerAgent.cpp +++ b/Source/WebCore/inspector/InspectorProfilerAgent.cpp @@ -33,6 +33,7 @@ #if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) #include "Console.h" +#include "InspectorConsoleAgent.h" #include "InspectorController.h" #include "InspectorFrontend.h" #include "InspectorValues.h" @@ -90,13 +91,13 @@ void InspectorProfilerAgent::addProfileFinishedMessageToConsole(PassRefPtr<Scrip RefPtr<ScriptProfile> profile = prpProfile; String title = profile->title(); String message = makeString("Profile \"webkit-profile://", CPUProfileType, '/', encodeWithURLEscapeSequences(title), '#', String::number(profile->uid()), "\" finished."); - m_inspectorController->addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL); + m_inspectorController->consoleAgent()->addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL); } void InspectorProfilerAgent::addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL) { String message = makeString("Profile \"webkit-profile://", CPUProfileType, '/', encodeWithURLEscapeSequences(title), "#0\" started."); - m_inspectorController->addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL); + m_inspectorController->consoleAgent()->addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL); } PassRefPtr<InspectorObject> InspectorProfilerAgent::createProfileHeader(const ScriptProfile& profile) diff --git a/Source/WebCore/inspector/InspectorResourceAgent.cpp b/Source/WebCore/inspector/InspectorResourceAgent.cpp index 9fc562c..6779790 100644 --- a/Source/WebCore/inspector/InspectorResourceAgent.cpp +++ b/Source/WebCore/inspector/InspectorResourceAgent.cpp @@ -132,7 +132,7 @@ CachedResource* InspectorResourceAgent::cachedResource(Frame* frame, const KURL& { CachedResource* cachedResource = frame->document()->cachedResourceLoader()->cachedResource(url); if (!cachedResource) - cachedResource = cache()->resourceForURL(url); + cachedResource = memoryCache()->resourceForURL(url); return cachedResource; } diff --git a/Source/WebCore/inspector/InspectorSettings.cpp b/Source/WebCore/inspector/InspectorSettings.cpp new file mode 100644 index 0000000..3ebc3ab --- /dev/null +++ b/Source/WebCore/inspector/InspectorSettings.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "config.h" +#include "InspectorSettings.h" + +#if ENABLE(INSPECTOR) + +#include "InspectorClient.h" + +namespace WebCore { + +const char* InspectorSettings::MonitoringXHREnabled = "xhrMonitor"; +const char* InspectorSettings::ProfilerAlwaysEnabled = "profilerEnabled"; +const char* InspectorSettings::DebuggerAlwaysEnabled = "debuggerEnabled"; +const char* InspectorSettings::InspectorStartsAttached = "inspectorStartsAttached"; +const char* InspectorSettings::InspectorAttachedHeight = "inspectorAttachedHeight"; + +InspectorSettings::InspectorSettings(InspectorClient* client) + : m_client(client) +{ + registerBoolean(MonitoringXHREnabled, false); + registerBoolean(ProfilerAlwaysEnabled, false); + registerBoolean(DebuggerAlwaysEnabled, false); + registerBoolean(InspectorStartsAttached, true); + registerLong(InspectorAttachedHeight, 300); +} + +bool InspectorSettings::getBoolean(const String& name) +{ + String value; + m_client->populateSetting(name, &value); + if (value.isEmpty()) + value = m_defaultValues.get(name); + return value == "true"; +} + +void InspectorSettings::setBoolean(const String& name, bool value) +{ + m_client->storeSetting(name, value ? "true" : "false"); +} + +long InspectorSettings::getLong(const String& name) +{ + String value; + m_client->populateSetting(name, &value); + if (value.isEmpty()) + value = m_defaultValues.get(name); + return value.toInt(); +} + +void InspectorSettings::setLong(const String& name, long value) +{ + m_client->storeSetting(name, String::number(value)); +} + +void InspectorSettings::registerBoolean(const String& name, bool defaultValue) +{ + m_defaultValues.set(name, defaultValue ? "true" : "false"); +} + +void InspectorSettings::registerLong(const String& name, long defaultValue) +{ + m_defaultValues.set(name, String::number(defaultValue)); +} + +} // namespace WebCore + +#endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorSettings.h b/Source/WebCore/inspector/InspectorSettings.h new file mode 100644 index 0000000..717d11f --- /dev/null +++ b/Source/WebCore/inspector/InspectorSettings.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InspectorSettings_h +#define InspectorSettings_h + +#if ENABLE(INSPECTOR) + +#include "PlatformString.h" + +#include <wtf/HashMap.h> +#include <wtf/text/StringHash.h> + +namespace WebCore { + +class InspectorClient; + +class InspectorSettings { +public: + static const char* MonitoringXHREnabled; + static const char* ProfilerAlwaysEnabled; + static const char* DebuggerAlwaysEnabled; + static const char* InspectorStartsAttached; + static const char* InspectorAttachedHeight; + + InspectorSettings(InspectorClient* client); + + bool getBoolean(const String& name); + void setBoolean(const String& name, bool value); + + long getLong(const String& name); + void setLong(const String& name, long value); + +private: + void registerBoolean(const String& name, bool defaultValue); + void registerLong(const String& name, long defaultValue); + + typedef HashMap<String, String> Dictionary; + Dictionary m_defaultValues; + InspectorClient* m_client; +}; + +} // namespace WebCore + +#endif // ENABLE(INSPECTOR) +#endif // !defined(InspectorSettings_h) diff --git a/Source/WebCore/inspector/InspectorState.cpp b/Source/WebCore/inspector/InspectorState.cpp index 0865648..1b74518 100644 --- a/Source/WebCore/inspector/InspectorState.cpp +++ b/Source/WebCore/inspector/InspectorState.cpp @@ -32,24 +32,22 @@ #if ENABLE(INSPECTOR) #include "InspectorClient.h" -#include "InspectorController.h" namespace WebCore { InspectorState::InspectorState(InspectorClient* client) : m_client(client) { - registerBoolean(monitoringXHR, false, "monitoringXHREnabled", "xhrMonitor"); - registerBoolean(timelineProfilerEnabled, false, "timelineProfilerEnabled", String()); - registerBoolean(searchingForNode, false, "searchingForNodeEnabled", String()); - registerBoolean(profilerAlwaysEnabled, false, String(), "profilerEnabled"); - registerBoolean(debuggerAlwaysEnabled, false, String(), "debuggerEnabled"); - registerBoolean(inspectorStartsAttached, true, String(), "InspectorStartsAttached"); - registerLong(inspectorAttachedHeight, InspectorController::defaultAttachedHeight, String(), "inspectorAttachedHeight"); - registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState", String()); - registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled", String()); - registerBoolean(userInitiatedProfiling, false, "userInitiatedProfiling", String()); - registerObject(stickyBreakpoints, String(), String()); + // Pure reload state + registerBoolean(userInitiatedProfiling, false, String()); + registerBoolean(timelineProfilerEnabled, false, String()); + registerBoolean(searchingForNode, false, String()); + registerObject(stickyBreakpoints, String()); + + // Should go away + registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled"); + registerBoolean(monitoringXHR, false, "monitoringXHREnabled"); + registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState"); } void InspectorState::restoreFromInspectorCookie(const String& json) @@ -82,32 +80,6 @@ PassRefPtr<InspectorObject> InspectorState::generateStateObjectForFrontend() return stateObject.release(); } -void InspectorState::loadFromSettings() -{ - for (PropertyMap::iterator i = m_properties.begin(); i != m_properties.end(); ++i) { - if (i->second.m_preferenceName.length()) { - String value; - m_client->populateSetting(i->second.m_preferenceName, &value); - switch (i->second.m_value->type()) { - case InspectorValue::TypeBoolean: - if (value.length()) - i->second.m_value = InspectorBasicValue::create(value == "true"); - break; - case InspectorValue::TypeString: - i->second.m_value = InspectorString::create(value); - break; - case InspectorValue::TypeNumber: - if (value.length()) - i->second.m_value = InspectorBasicValue::create((double)value.toInt()); - break; - default: - ASSERT(false); - break; - } - } - } -} - void InspectorState::updateCookie() { RefPtr<InspectorObject> cookieObject = InspectorObject::create(); @@ -116,13 +88,11 @@ void InspectorState::updateCookie() m_client->updateInspectorStateCookie(cookieObject->toJSONString()); } -void InspectorState::setValue(InspectorPropertyId id, PassRefPtr<InspectorValue> value, const String& stringValue) +void InspectorState::setValue(InspectorPropertyId id, PassRefPtr<InspectorValue> value) { PropertyMap::iterator i = m_properties.find(id); ASSERT(i != m_properties.end()); i->second.m_value = value; - if (i->second.m_preferenceName.length()) - m_client->storeSetting(i->second.m_preferenceName, stringValue); updateCookie(); } @@ -166,37 +136,34 @@ void InspectorState::setObject(InspectorPropertyId id, PassRefPtr<InspectorObjec ASSERT(i != m_properties.end()); Property& property = i->second; property.m_value = value; - if (property.m_preferenceName.length()) - m_client->storeSetting(property.m_preferenceName, value->toJSONString()); updateCookie(); } -void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias, const String& preferenceName) +void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias) { - m_properties.set(propertyId, Property::create(InspectorBasicValue::create(value), frontendAlias, preferenceName)); + m_properties.set(propertyId, Property::create(InspectorBasicValue::create(value), frontendAlias)); } -void InspectorState::registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias, const String& preferenceName) +void InspectorState::registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias) { - m_properties.set(propertyId, Property::create(InspectorString::create(value), frontendAlias, preferenceName)); + m_properties.set(propertyId, Property::create(InspectorString::create(value), frontendAlias)); } -void InspectorState::registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias, const String& preferenceName) +void InspectorState::registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias) { - m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value), frontendAlias, preferenceName)); + m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value), frontendAlias)); } -void InspectorState::registerObject(InspectorPropertyId propertyId, const String& frontendAlias, const String& preferenceName) +void InspectorState::registerObject(InspectorPropertyId propertyId, const String& frontendAlias) { - m_properties.set(propertyId, Property::create(InspectorObject::create(), frontendAlias, preferenceName)); + m_properties.set(propertyId, Property::create(InspectorObject::create(), frontendAlias)); } -InspectorState::Property InspectorState::Property::create(PassRefPtr<InspectorValue> value, const String& frontendAlias, const String& preferenceName) +InspectorState::Property InspectorState::Property::create(PassRefPtr<InspectorValue> value, const String& frontendAlias) { Property property; property.m_value = value; property.m_frontendAlias = frontendAlias; - property.m_preferenceName = preferenceName; return property; } diff --git a/Source/WebCore/inspector/InspectorState.h b/Source/WebCore/inspector/InspectorState.h index 4f57da7..3142c92 100644 --- a/Source/WebCore/inspector/InspectorState.h +++ b/Source/WebCore/inspector/InspectorState.h @@ -47,11 +47,6 @@ public: monitoringXHR = 1, timelineProfilerEnabled, searchingForNode, - profilerAlwaysEnabled, - debuggerAlwaysEnabled, - lastActivePanel, - inspectorStartsAttached, - inspectorAttachedHeight, pauseOnExceptionsState, consoleMessagesEnabled, userInitiatedProfiling, @@ -63,7 +58,6 @@ public: PassRefPtr<InspectorObject> generateStateObjectForFrontend(); void restoreFromInspectorCookie(const String& jsonString); - void loadFromSettings(); String getFrontendAlias(InspectorPropertyId propertyId); bool getBoolean(InspectorPropertyId propertyId); @@ -71,28 +65,27 @@ public: long getLong(InspectorPropertyId propertyId); PassRefPtr<InspectorObject> getObject(InspectorPropertyId id); - void setBoolean(InspectorPropertyId propertyId, bool value) { setValue(propertyId, InspectorBasicValue::create(value), value ? "true" : "false"); } - void setString(InspectorPropertyId propertyId, const String& value) { setValue(propertyId, InspectorString::create(value), value); } - void setLong(InspectorPropertyId propertyId, long value) { setValue(propertyId, InspectorBasicValue::create((double)value), String::number(value)); } + void setBoolean(InspectorPropertyId propertyId, bool value) { setValue(propertyId, InspectorBasicValue::create(value)); } + void setString(InspectorPropertyId propertyId, const String& value) { setValue(propertyId, InspectorString::create(value)); } + void setLong(InspectorPropertyId propertyId, long value) { setValue(propertyId, InspectorBasicValue::create((double)value)); } void setObject(InspectorPropertyId propertyId, PassRefPtr<InspectorObject> value); private: void updateCookie(); - void setValue(InspectorPropertyId propertyId, PassRefPtr<InspectorValue> value, const String& stringValue); + void setValue(InspectorPropertyId propertyId, PassRefPtr<InspectorValue> value); struct Property { - static Property create(PassRefPtr<InspectorValue> value, const String& frontendAlias, const String& preferenceName); + static Property create(PassRefPtr<InspectorValue> value, const String& frontendAlias); String m_frontendAlias; - String m_preferenceName; RefPtr<InspectorValue> m_value; }; typedef HashMap<long, Property> PropertyMap; PropertyMap m_properties; - void registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias, const String& preferenceName); - void registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias, const String& preferenceName); - void registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias, const String& preferenceName); - void registerObject(InspectorPropertyId propertyId, const String& frontendAlias, const String& preferenceName); + void registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias); + void registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias); + void registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias); + void registerObject(InspectorPropertyId propertyId, const String& frontendAlias); InspectorClient* m_client; }; diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.cpp b/Source/WebCore/inspector/InspectorTimelineAgent.cpp index 74739e1..081a5f0 100644 --- a/Source/WebCore/inspector/InspectorTimelineAgent.cpp +++ b/Source/WebCore/inspector/InspectorTimelineAgent.cpp @@ -209,12 +209,11 @@ void InspectorTimelineAgent::didScheduleResourceRequest(const String& url) addRecordToTimeline(record.release(), ScheduleResourceRequestTimelineRecordType); } -void InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, bool isMainResource, - const ResourceRequest& request) +void InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, const ResourceRequest& request) { pushGCEventRecords(); RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); - record->setObject("data", TimelineRecordFactory::createResourceSendRequestData(identifier, isMainResource, request)); + record->setObject("data", TimelineRecordFactory::createResourceSendRequestData(identifier, request)); record->setNumber("type", ResourceSendRequestTimelineRecordType); setHeapSizeStatistic(record.get()); m_frontend->addRecordToTimeline(record.release()); diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.h b/Source/WebCore/inspector/InspectorTimelineAgent.h index bc1e027..33e2737 100644 --- a/Source/WebCore/inspector/InspectorTimelineAgent.h +++ b/Source/WebCore/inspector/InspectorTimelineAgent.h @@ -119,7 +119,7 @@ public: void didMarkLoadEvent(); void didScheduleResourceRequest(const String& url); - void willSendResourceRequest(unsigned long, bool isMainResource, const ResourceRequest&); + void willSendResourceRequest(unsigned long, const ResourceRequest&); void willReceiveResourceResponse(unsigned long, const ResourceResponse&); void didReceiveResourceResponse(); void didFinishLoadingResource(unsigned long, bool didFail, double finishTime); diff --git a/Source/WebCore/inspector/ScriptDebugListener.h b/Source/WebCore/inspector/ScriptDebugListener.h index 5973402..a28cabb 100644 --- a/Source/WebCore/inspector/ScriptDebugListener.h +++ b/Source/WebCore/inspector/ScriptDebugListener.h @@ -46,7 +46,7 @@ class ScriptDebugListener { public: virtual ~ScriptDebugListener() { } - virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType) = 0; + virtual void didParseSource(const String& sourceID, const String& url, const String& data, int lineOffset, int columnOffset, ScriptWorldType) = 0; virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) = 0; virtual void didPause(ScriptState*) = 0; virtual void didContinue() = 0; diff --git a/Source/WebCore/inspector/TimelineRecordFactory.cpp b/Source/WebCore/inspector/TimelineRecordFactory.cpp index 7f339cd..dd7f2be 100644 --- a/Source/WebCore/inspector/TimelineRecordFactory.cpp +++ b/Source/WebCore/inspector/TimelineRecordFactory.cpp @@ -129,13 +129,12 @@ PassRefPtr<InspectorObject> TimelineRecordFactory::createScheduleResourceRequest return data.release(); } -PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceSendRequestData(unsigned long identifier, bool isMainResource, const ResourceRequest& request) +PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceSendRequestData(unsigned long identifier, const ResourceRequest& request) { RefPtr<InspectorObject> data = InspectorObject::create(); data->setNumber("identifier", identifier); data->setString("url", request.url().string()); data->setString("requestMethod", request.httpMethod()); - data->setBoolean("isMainResource", isMainResource); return data.release(); } diff --git a/Source/WebCore/inspector/TimelineRecordFactory.h b/Source/WebCore/inspector/TimelineRecordFactory.h index 5d4cb77..fafeae6 100644 --- a/Source/WebCore/inspector/TimelineRecordFactory.h +++ b/Source/WebCore/inspector/TimelineRecordFactory.h @@ -64,8 +64,7 @@ namespace WebCore { static PassRefPtr<InspectorObject> createMarkTimelineData(const String&); - static PassRefPtr<InspectorObject> createResourceSendRequestData(unsigned long identifier, - bool isMainResource, const ResourceRequest&); + static PassRefPtr<InspectorObject> createResourceSendRequestData(unsigned long identifier, const ResourceRequest&); static PassRefPtr<InspectorObject> createScheduleResourceRequestData(const String&); diff --git a/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js b/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js index f5147e3..e7aa188 100644 --- a/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js +++ b/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js @@ -167,7 +167,7 @@ WebInspector.ApplicationCacheItemsView.prototype = { this._emptyMsgElement.addStyleClass("hidden"); this.deleteButton.visible = true; - var totalSizeString = Number.bytesToString(this._size, WebInspector.UIString); + var totalSizeString = Number.bytesToString(this._size); this._treeElement.subtitle = WebInspector.UIString("%s (%s)", lastPathComponent, totalSizeString); // FIXME: For Chrome, put creationTime and updateTime somewhere. @@ -223,7 +223,7 @@ WebInspector.ApplicationCacheItemsView.prototype = { var resource = this._resources[i]; data[0] = resource.name; data[1] = resource.type; - data[2] = Number.bytesToString(resource.size, WebInspector.UIString); + data[2] = Number.bytesToString(resource.size); var node = new WebInspector.DataGridNode(data); node.resource = resource; node.selectable = true; diff --git a/Source/WebCore/inspector/front-end/AuditLauncherView.js b/Source/WebCore/inspector/front-end/AuditLauncherView.js index d4bbf90..c140589 100644 --- a/Source/WebCore/inspector/front-end/AuditLauncherView.js +++ b/Source/WebCore/inspector/front-end/AuditLauncherView.js @@ -53,24 +53,6 @@ WebInspector.AuditLauncherView = function(runnerCallback) } WebInspector.AuditLauncherView.prototype = { - updateResourceTrackingState: function(isTracking) - { - if (!this._auditPresentStateLabelElement) - return; - - if (isTracking) { - this._auditPresentStateLabelElement.nodeValue = WebInspector.UIString("Audit Present State"); - this._auditPresentStateElement.disabled = false; - this._auditPresentStateElement.parentElement.removeStyleClass("disabled"); - } else { - this._resetResourceCount(); - this._auditPresentStateLabelElement.nodeValue = WebInspector.UIString("Audit Present State (Resource Tracking must be enabled)"); - this._auditPresentStateElement.disabled = true; - this._auditPresentStateElement.parentElement.addStyleClass("disabled"); - this.auditReloadedStateElement.checked = true; - } - }, - get totalResources() { return this._totalResources; @@ -100,20 +82,21 @@ WebInspector.AuditLauncherView.prototype = { _resetResourceCount: function() { this.loadedResources = 0; - - // We never receive a resourceStarted notification for the main resource - // (see InspectorController.willSendRequest()) - this.totalResources = 1; + this.totalResources = 0; }, resourceStarted: function(resource) { - ++this.totalResources; + // Ignore long-living WebSockets for the sake of progress indicator, as we won't be waiting them anyway. + if (resource.type !== WebInspector.Resource.Type.WebSocket) + ++this.totalResources; }, resourceFinished: function(resource) { - ++this.loadedResources; + // See resorceStarted for details. + if (resource.type !== WebInspector.Resource.Type.WebSocket) + ++this.loadedResources; }, reset: function() @@ -237,7 +220,7 @@ WebInspector.AuditLauncherView.prototype = { this._auditPresentStateElement.name = "audit-mode"; this._auditPresentStateElement.type = "radio"; this._auditPresentStateElement.checked = true; - this._auditPresentStateLabelElement = document.createTextNode(""); + this._auditPresentStateLabelElement = document.createTextNode(WebInspector.UIString("Audit Present State")); labelElement.appendChild(this._auditPresentStateElement); labelElement.appendChild(this._auditPresentStateLabelElement); this._buttonContainerElement.appendChild(labelElement); @@ -267,7 +250,6 @@ WebInspector.AuditLauncherView.prototype = { this._contentElement.appendChild(this._buttonContainerElement); this._selectAllClicked(this._selectAllCheckboxElement.checked); - this.updateResourceTrackingState(); this._updateButton(); this._updateResourceProgress(); }, diff --git a/Source/WebCore/inspector/front-end/AuditRules.js b/Source/WebCore/inspector/front-end/AuditRules.js index 3f79c25..7aa891f 100644 --- a/Source/WebCore/inspector/front-end/AuditRules.js +++ b/Source/WebCore/inspector/front-end/AuditRules.js @@ -92,13 +92,13 @@ WebInspector.AuditRules.GzipRule.prototype = { } var savings = 2 * size / 3; totalSavings += savings; - summary.addChild(String.sprintf("%s could save ~%s", WebInspector.AuditRuleResult.linkifyDisplayName(resource.url), Number.bytesToString(savings, WebInspector.UIString))); + summary.addChild(String.sprintf("%s could save ~%s", WebInspector.AuditRuleResult.linkifyDisplayName(resource.url), Number.bytesToString(savings))); result.violationCount++; } } if (!totalSavings) return callback(null); - summary.value = String.sprintf("Compressing the following resources with gzip could reduce their transfer size by about two thirds (~%s):", Number.bytesToString(totalSavings, WebInspector.UIString)); + summary.value = String.sprintf("Compressing the following resources with gzip could reduce their transfer size by about two thirds (~%s):", Number.bytesToString(totalSavings)); callback(result); }, @@ -966,7 +966,7 @@ WebInspector.AuditRules.CookieSizeRule.prototype = { for (var i = 0, len = sortedCookieSizes.length; i < len; ++i) { var maxCookieSize = sortedCookieSizes[i].maxCookieSize; if (maxCookieSize > this._maxBytesThreshold) - hugeCookieDomains.push(WebInspector.AuditRuleResult.resourceDomain(sortedCookieSizes[i].domain) + ": " + Number.bytesToString(maxCookieSize, WebInspector.UIString)); + hugeCookieDomains.push(WebInspector.AuditRuleResult.resourceDomain(sortedCookieSizes[i].domain) + ": " + Number.bytesToString(maxCookieSize)); } var bigAvgCookieDomains = []; @@ -975,9 +975,9 @@ WebInspector.AuditRules.CookieSizeRule.prototype = { var domain = sortedCookieSizes[i].domain; var avgCookieSize = sortedCookieSizes[i].avgCookieSize; if (avgCookieSize > this._avgBytesThreshold && avgCookieSize < this._maxBytesThreshold) - bigAvgCookieDomains.push(WebInspector.AuditRuleResult.resourceDomain(domain) + ": " + Number.bytesToString(avgCookieSize, WebInspector.UIString)); + bigAvgCookieDomains.push(WebInspector.AuditRuleResult.resourceDomain(domain) + ": " + Number.bytesToString(avgCookieSize)); } - result.addChild(String.sprintf("The average cookie size for all requests on this page is %s", Number.bytesToString(avgAllCookiesSize, WebInspector.UIString))); + result.addChild(String.sprintf("The average cookie size for all requests on this page is %s", Number.bytesToString(avgAllCookiesSize))); var message; if (hugeCookieDomains.length) { @@ -1027,7 +1027,7 @@ WebInspector.AuditRules.StaticCookielessRule.prototype = { if (badUrls.length < this._minResources) return; - var entry = result.addChild(String.sprintf("%s of cookies were sent with the following static resources. Serve these static resources from a domain that does not set cookies:", Number.bytesToString(cookieBytes, WebInspector.UIString)), true); + var entry = result.addChild(String.sprintf("%s of cookies were sent with the following static resources. Serve these static resources from a domain that does not set cookies:", Number.bytesToString(cookieBytes)), true); entry.addURLs(badUrls); result.violationCount = badUrls.length; }, diff --git a/Source/WebCore/inspector/front-end/AuditsPanel.js b/Source/WebCore/inspector/front-end/AuditsPanel.js index 096f8ce..c639f47 100644 --- a/Source/WebCore/inspector/front-end/AuditsPanel.js +++ b/Source/WebCore/inspector/front-end/AuditsPanel.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -129,9 +129,7 @@ WebInspector.AuditsPanel.prototype = { _executeAudit: function(categories, resultCallback) { - var resources = []; - for (var id in WebInspector.networkResources) - resources.push(WebInspector.networkResources[id]); + var resources = WebInspector.networkResources; var rulesRemaining = 0; for (var i = 0; i < categories.length; ++i) @@ -248,12 +246,6 @@ WebInspector.AuditsPanel.prototype = { x.show(this.viewsContainerElement); }, - show: function() - { - WebInspector.Panel.prototype.show.call(this); - this._updateLauncherViewControls(!WebInspector.panels.resources || WebInspector.panels.resources.resourceTrackingEnabled); - }, - reset: function() { this._launcherView.reset(); @@ -271,12 +263,6 @@ WebInspector.AuditsPanel.prototype = { this.viewsContainerElement.style.left = width + "px"; }, - _updateLauncherViewControls: function(isTracking) - { - if (this._launcherView) - this._launcherView.updateResourceTrackingState(isTracking); - }, - _clearButtonClicked: function() { this.auditsItemTreeElement.reveal(); diff --git a/Source/WebCore/inspector/front-end/Breakpoint.js b/Source/WebCore/inspector/front-end/Breakpoint.js index 0a888d2..e5e1768 100644 --- a/Source/WebCore/inspector/front-end/Breakpoint.js +++ b/Source/WebCore/inspector/front-end/Breakpoint.js @@ -37,7 +37,6 @@ WebInspector.Breakpoint = function(debuggerModel, breakpointId, sourceID, url, l this.sourceID = sourceID; this._enabled = enabled; this._condition = condition || ""; - this._sourceText = ""; this._hit = false; this._debuggerModel = debuggerModel; } @@ -56,17 +55,6 @@ WebInspector.Breakpoint.prototype = { WebInspector.debuggerModel.setBreakpoint(this.sourceID, this.line, enabled, this.condition); }, - get sourceText() - { - return this._sourceText; - }, - - set sourceText(text) - { - this._sourceText = text; - this.dispatchEventToListeners("label-changed"); - }, - get condition() { return this._condition; @@ -99,14 +87,19 @@ WebInspector.Breakpoint.prototype = { populateLabelElement: function(element) { - var displayName = this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)"); - var labelElement = document.createTextNode(displayName + ":" + this.line); - element.appendChild(labelElement); + function didGetSourceLine(text) + { + var displayName = this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)"); + var labelElement = document.createTextNode(displayName + ":" + this.line); + element.appendChild(labelElement); - var sourceTextElement = document.createElement("div"); - sourceTextElement.textContent = this.sourceText; - sourceTextElement.className = "source-text monospace"; - element.appendChild(sourceTextElement); + var sourceTextElement = document.createElement("div"); + sourceTextElement.textContent = text; + sourceTextElement.className = "source-text monospace"; + element.appendChild(sourceTextElement); + } + var script = this._debuggerModel.scriptForSourceID(this.sourceID); + script.sourceLine(this.line, didGetSourceLine.bind(this)); }, remove: function() diff --git a/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js b/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js index 619525c..408c5ba 100644 --- a/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js +++ b/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js @@ -265,24 +265,24 @@ WebInspector.EventListenerBreakpointsSidebarPane = function() WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.EventListenerBreakpointAdded, this._breakpointAdded, this); this._breakpointItems = {}; - this._createCategory("Keyboard", "listener", ["keydown", "keyup", "keypress", "textInput"]); - this._createCategory("Mouse", "listener", ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"]); + this._createCategory(WebInspector.UIString("Keyboard"), "listener", ["keydown", "keyup", "keypress", "textInput"]); + this._createCategory(WebInspector.UIString("Mouse"), "listener", ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"]); // FIXME: uncomment following once inspector stops being drop targer in major ports. // Otherwise, inspector page reacts on drop event and tries to load the event data. - // this._createCategory("Drag", "listener", ["drag", "drop", "dragstart", "dragend", "dragenter", "dragleave", "dragover"]); - this._createCategory("Control", "listener", ["resize", "scroll", "zoom", "focus", "blur", "select", "change", "submit", "reset"]); - this._createCategory("Clipboard", "listener", ["copy", "cut", "paste", "beforecopy", "beforecut", "beforepaste"]); - this._createCategory("Load", "listener", ["load", "unload", "abort", "error"]); - this._createCategory("DOM Mutation", "listener", ["DOMActivate", "DOMFocusIn", "DOMFocusOut", "DOMAttrModified", "DOMCharacterDataModified", "DOMNodeInserted", "DOMNodeInsertedIntoDocument", "DOMNodeRemoved", "DOMNodeRemovedFromDocument", "DOMSubtreeModified", "DOMContentLoaded"]); - this._createCategory("Device", "listener", ["deviceorientation", "devicemotion"]); - this._createCategory("Timer", "instrumentation", ["setTimer", "clearTimer", "timerFired"]); + // this._createCategory(WebInspector.UIString("Drag"), "listener", ["drag", "drop", "dragstart", "dragend", "dragenter", "dragleave", "dragover"]); + this._createCategory(WebInspector.UIString("Control"), "listener", ["resize", "scroll", "zoom", "focus", "blur", "select", "change", "submit", "reset"]); + this._createCategory(WebInspector.UIString("Clipboard"), "listener", ["copy", "cut", "paste", "beforecopy", "beforecut", "beforepaste"]); + this._createCategory(WebInspector.UIString("Load"), "listener", ["load", "unload", "abort", "error"]); + this._createCategory(WebInspector.UIString("DOM Mutation"), "listener", ["DOMActivate", "DOMFocusIn", "DOMFocusOut", "DOMAttrModified", "DOMCharacterDataModified", "DOMNodeInserted", "DOMNodeInsertedIntoDocument", "DOMNodeRemoved", "DOMNodeRemovedFromDocument", "DOMSubtreeModified", "DOMContentLoaded"]); + this._createCategory(WebInspector.UIString("Device"), "listener", ["deviceorientation", "devicemotion"]); + this._createCategory(WebInspector.UIString("Timer"), "instrumentation", ["setTimer", "clearTimer", "timerFired"]); } WebInspector.EventListenerBreakpointsSidebarPane.prototype = { _createCategory: function(name, type, eventNames) { var categoryItem = {}; - categoryItem.element = new TreeElement(WebInspector.UIString(name)); + categoryItem.element = new TreeElement(name); this.categoriesTreeOutline.appendChild(categoryItem.element); categoryItem.element.listItemElement.addStyleClass("event-category"); categoryItem.element.selectable = true; diff --git a/Source/WebCore/inspector/front-end/ConsoleView.js b/Source/WebCore/inspector/front-end/ConsoleView.js index c98552d..a40030e 100644 --- a/Source/WebCore/inspector/front-end/ConsoleView.js +++ b/Source/WebCore/inspector/front-end/ConsoleView.js @@ -97,9 +97,63 @@ WebInspector.ConsoleView = function(drawer) "node": this._formatnode, "string": this._formatstring }; + + this._registerConsoleDomainDispatcher(); } WebInspector.ConsoleView.prototype = { + _registerConsoleDomainDispatcher: function() { + var console = this; + var dispatcher = { + addConsoleMessage: function(payload) + { + var consoleMessage = new WebInspector.ConsoleMessage( + payload.source, + payload.type, + payload.level, + payload.line, + payload.url, + payload.repeatCount, + payload.message, + payload.parameters, + payload.stackTrace, + payload.requestId); + console.addMessage(consoleMessage); + }, + + updateConsoleMessageExpiredCount: function(count) + { + var message = String.sprintf(WebInspector.UIString("%d console messages are not shown."), count); + console.addMessage(WebInspector.ConsoleMessage.createTextMessage(message, WebInspector.ConsoleMessage.MessageLevel.Warning)); + }, + + updateConsoleMessageRepeatCount: function(count) + { + var msg = console.previousMessage; + var prevRepeatCount = msg.totalRepeatCount; + + if (!console.commandSincePreviousMessage) { + msg.repeatDelta = count - prevRepeatCount; + msg.repeatCount = msg.repeatCount + msg.repeatDelta; + msg.totalRepeatCount = count; + msg._updateRepeatCount(); + console._incrementErrorWarningCount(msg); + } else { + var msgCopy = new WebInspector.ConsoleMessage(msg.source, msg.type, msg.level, msg.line, msg.url, count - prevRepeatCount, msg._messageText, msg._parameters, msg._stackTrace, msg._requestId); + msgCopy.totalRepeatCount = count; + msgCopy._formatMessage(); + console.addMessage(msgCopy); + } + }, + + consoleMessagesCleared: function() + { + console.clearMessages(); + } + } + InspectorBackend.registerDomainDispatcher("Console", dispatcher); + }, + _updateFilter: function(e) { var isMac = WebInspector.isMac(); @@ -247,25 +301,6 @@ WebInspector.ConsoleView.prototype = { this._scheduleScrollIntoView(); }, - updateMessageRepeatCount: function(count) - { - var msg = this.previousMessage; - var prevRepeatCount = msg.totalRepeatCount; - - if (!this.commandSincePreviousMessage) { - msg.repeatDelta = count - prevRepeatCount; - msg.repeatCount = msg.repeatCount + msg.repeatDelta; - msg.totalRepeatCount = count; - msg._updateRepeatCount(); - this._incrementErrorWarningCount(msg); - } else { - var msgCopy = new WebInspector.ConsoleMessage(msg.source, msg.type, msg.level, msg.line, msg.url, count - prevRepeatCount, msg._messageText, msg._parameters, msg._stackTrace, msg._requestId); - msgCopy.totalRepeatCount = count; - msgCopy._formatMessage(); - this.addMessage(msgCopy); - } - }, - _incrementErrorWarningCount: function(msg) { switch (msg.level) { @@ -668,7 +703,7 @@ WebInspector.ConsoleMessage.prototype = { messageText = document.createTextNode(this._messageText); break; case WebInspector.ConsoleMessage.MessageType.NetworkError: - var resource = this._requestId && WebInspector.panels.network.resources[this._requestId]; + var resource = this._requestId && WebInspector.networkResourceById(this._requestId); if (resource) { stackTrace = resource.stackTrace; diff --git a/Source/WebCore/inspector/front-end/CookieItemsView.js b/Source/WebCore/inspector/front-end/CookieItemsView.js index 75c7f84..dc76b39 100644 --- a/Source/WebCore/inspector/front-end/CookieItemsView.js +++ b/Source/WebCore/inspector/front-end/CookieItemsView.js @@ -101,9 +101,10 @@ WebInspector.CookieItemsView.prototype = { this._emptyMsgElement.addStyleClass("hidden"); if (isAdvanced) { this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d cookies (%s)"), this._cookies.length, - Number.bytesToString(this._totalSize, WebInspector.UIString)); + Number.bytesToString(this._totalSize)); this._deleteButton.visible = true; } + this._cookiesTable.updateWidths(); }, _filterCookiesForDomain: function(allCookies) diff --git a/Source/WebCore/inspector/front-end/DOMAgent.js b/Source/WebCore/inspector/front-end/DOMAgent.js index 89822a3..e4fc7ad 100644 --- a/Source/WebCore/inspector/front-end/DOMAgent.js +++ b/Source/WebCore/inspector/front-end/DOMAgent.js @@ -300,7 +300,7 @@ WebInspector.DOMAgent = function() { this._window = new WebInspector.DOMWindow(this); this._idToDOMNode = null; this.document = null; - InspectorBackend.registerDomainDispatcher("DOM", this); + InspectorBackend.registerDomainDispatcher("DOM", new WebInspector.DOMDispatcher(this)); } WebInspector.DOMAgent.prototype = { @@ -351,7 +351,7 @@ WebInspector.DOMAgent.prototype = { elem.updateTitle(); }, - attributesUpdated: function(nodeId, attrsArray) + _attributesUpdated: function(nodeId, attrsArray) { var node = this._idToDOMNode[nodeId]; node._setAttributesPayload(attrsArray); @@ -359,7 +359,7 @@ WebInspector.DOMAgent.prototype = { this.document._fireDomEvent("DOMAttrModified", event); }, - characterDataModified: function(nodeId, newValue) + _characterDataModified: function(nodeId, newValue) { var node = this._idToDOMNode[nodeId]; node._nodeValue = newValue; @@ -373,13 +373,7 @@ WebInspector.DOMAgent.prototype = { return this._idToDOMNode[nodeId]; }, - didCommitLoad: function() - { - // Cleanup elements panel early on inspected page refresh. - this.setDocument(null); - }, - - setDocument: function(payload) + _setDocument: function(payload) { this._idToDOMNode = {}; if (payload && "id" in payload) { @@ -392,13 +386,13 @@ WebInspector.DOMAgent.prototype = { WebInspector.panels.elements.setDocument(this.document); }, - setDetachedRoot: function(payload) + _setDetachedRoot: function(payload) { var root = new WebInspector.DOMNode(this.document, payload); this._idToDOMNode[payload.id] = root; }, - setChildNodes: function(parentId, payloads) + _setChildNodes: function(parentId, payloads) { var parent = this._idToDOMNode[parentId]; parent._setChildrenPayload(payloads); @@ -415,7 +409,7 @@ WebInspector.DOMAgent.prototype = { } }, - childNodeCountUpdated: function(nodeId, newValue) + _childNodeCountUpdated: function(nodeId, newValue) { var node = this._idToDOMNode[nodeId]; node._childNodeCount = newValue; @@ -425,7 +419,7 @@ WebInspector.DOMAgent.prototype = { treeElement.hasChildren = newValue; }, - childNodeInserted: function(parentId, prevId, payload) + _childNodeInserted: function(parentId, prevId, payload) { var parent = this._idToDOMNode[parentId]; var prev = this._idToDOMNode[prevId]; @@ -435,7 +429,7 @@ WebInspector.DOMAgent.prototype = { this.document._fireDomEvent("DOMNodeInserted", event); }, - childNodeRemoved: function(parentId, nodeId) + _childNodeRemoved: function(parentId, nodeId) { var parent = this._idToDOMNode[parentId]; var node = this._idToDOMNode[nodeId]; @@ -457,31 +451,82 @@ WebInspector.DOMAgent.prototype = { } } -WebInspector.ApplicationCache = {} - -WebInspector.ApplicationCache.getApplicationCachesAsync = function(callback) +WebInspector.DOMDispatcher = function(domAgent) { - function mycallback(applicationCaches) + this._domAgent = domAgent; +} + +WebInspector.DOMDispatcher.prototype = { + setDocument: function(payload) { - // FIXME: Currently, this list only returns a single application cache. - if (applicationCaches) - callback(applicationCaches); - } + this._domAgent._setDocument(payload); + }, + + attributesUpdated: function(nodeId, attrsArray) + { + this._domAgent._attributesUpdated(nodeId, attrsArray); + }, - InspectorBackend.getApplicationCaches(mycallback); + characterDataModified: function(nodeId, newValue) + { + this._domAgent._characterDataModified(nodeId, newValue); + }, + + setChildNodes: function(parentId, payloads) + { + this._domAgent._setChildNodes(parentId, payloads); + }, + + setDetachedRoot: function(payload) + { + this._domAgent._setDetachedRoot(payload); + }, + + childNodeCountUpdated: function(nodeId, newValue) + { + this._domAgent._childNodeCountUpdated(nodeId, newValue); + }, + + childNodeInserted: function(parentId, prevId, payload) + { + this._domAgent._childNodeInserted(parentId, prevId, payload); + }, + + childNodeRemoved: function(parentId, nodeId) + { + this._domAgent._childNodeRemoved(parentId, nodeId); + } } -WebInspector.ApplicationCache.updateApplicationCacheStatus = function(status) +WebInspector.ApplicationCacheDispatcher = function() { - WebInspector.panels.resources.updateApplicationCacheStatus(status); } -WebInspector.ApplicationCache.updateNetworkState = function(isNowOnline) -{ - WebInspector.panels.resources.updateNetworkState(isNowOnline); +WebInspector.ApplicationCacheDispatcher.prototype = { + getApplicationCachesAsync: function(callback) + { + function mycallback(applicationCaches) + { + // FIXME: Currently, this list only returns a single application cache. + if (applicationCaches) + callback(applicationCaches); + } + + InspectorBackend.getApplicationCaches(mycallback); + }, + + updateApplicationCacheStatus: function(status) + { + WebInspector.panels.resources.updateApplicationCacheStatus(status); + }, + + updateNetworkState: function(isNowOnline) + { + WebInspector.panels.resources.updateNetworkState(isNowOnline); + } } -InspectorBackend.registerDomainDispatcher("ApplicationCache", WebInspector.ApplicationCache); +InspectorBackend.registerDomainDispatcher("ApplicationCache", new WebInspector.ApplicationCacheDispatcher()); WebInspector.Cookies = {} diff --git a/Source/WebCore/inspector/front-end/DOMStorage.js b/Source/WebCore/inspector/front-end/DOMStorage.js index aa14a9c..d3d2226 100644 --- a/Source/WebCore/inspector/front-end/DOMStorage.js +++ b/Source/WebCore/inspector/front-end/DOMStorage.js @@ -70,26 +70,33 @@ WebInspector.DOMStorage.prototype = { } } -WebInspector.DOMStorage.addDOMStorage = function(payload) -{ - if (!WebInspector.panels.resources) - return; - var domStorage = new WebInspector.DOMStorage( - payload.id, - payload.host, - payload.isLocalStorage); - WebInspector.panels.resources.addDOMStorage(domStorage); -} -WebInspector.DOMStorage.selectDOMStorage = function(o) +WebInspector.DOMStorageDispatcher = function() { - WebInspector.showPanel("resources"); - WebInspector.panels.resources.selectDOMStorage(o); } -WebInspector.DOMStorage.updateDOMStorage = function(storageId) -{ - WebInspector.panels.resources.updateDOMStorage(storageId); +WebInspector.DOMStorageDispatcher.prototype = { + addDOMStorage: function(payload) + { + if (!WebInspector.panels.resources) + return; + var domStorage = new WebInspector.DOMStorage( + payload.id, + payload.host, + payload.isLocalStorage); + WebInspector.panels.resources.addDOMStorage(domStorage); + }, + + selectDOMStorage: function(o) + { + WebInspector.showPanel("resources"); + WebInspector.panels.resources.selectDOMStorage(o); + }, + + updateDOMStorage: function(storageId) + { + WebInspector.panels.resources.updateDOMStorage(storageId); + } } -InspectorBackend.registerDomainDispatcher("DOMStorage", WebInspector.DOMStorage); +InspectorBackend.registerDomainDispatcher("DOMStorage", new WebInspector.DOMStorageDispatcher()); diff --git a/Source/WebCore/inspector/front-end/Database.js b/Source/WebCore/inspector/front-end/Database.js index 0b00330..faa17fa 100644 --- a/Source/WebCore/inspector/front-end/Database.js +++ b/Source/WebCore/inspector/front-end/Database.js @@ -34,8 +34,6 @@ WebInspector.Database = function(id, domain, name, version) this._version = version; } -WebInspector.Database._callbacks = {}; - WebInspector.Database.prototype = { get id() { @@ -94,50 +92,58 @@ WebInspector.Database.prototype = { onError(WebInspector.UIString("Database not found.")); return; } - WebInspector.Database._callbacks[transactionId] = {"onSuccess": onSuccess, "onError": onError}; + WebInspector.DatabaseDispatcher._callbacks[transactionId] = {"onSuccess": onSuccess, "onError": onError}; } InspectorBackend.executeSQL(this._id, query, callback); } } -WebInspector.Database.addDatabase = function(payload) +WebInspector.DatabaseDispatcher = function() { - if (!WebInspector.panels.resources) - return; - var database = new WebInspector.Database( - payload.id, - payload.domain, - payload.name, - payload.version); - WebInspector.panels.resources.addDatabase(database); } -WebInspector.Database.selectDatabase = function(o) -{ - WebInspector.showPanel("resources"); - WebInspector.panels.resources.selectDatabase(o); -} +WebInspector.DatabaseDispatcher._callbacks = {}; -WebInspector.Database.sqlTransactionSucceeded = function(transactionId, columnNames, values) -{ - if (!WebInspector.Database._callbacks[transactionId]) - return; +WebInspector.DatabaseDispatcher.prototype = { + addDatabase: function(payload) + { + if (!WebInspector.panels.resources) + return; + var database = new WebInspector.Database( + payload.id, + payload.domain, + payload.name, + payload.version); + WebInspector.panels.resources.addDatabase(database); + }, - var callback = WebInspector.Database._callbacks[transactionId].onSuccess; - delete WebInspector.Database._callbacks[transactionId]; - if (callback) - callback(columnNames, values); -} + selectDatabase: function(o) + { + WebInspector.showPanel("resources"); + WebInspector.panels.resources.selectDatabase(o); + }, -WebInspector.Database.sqlTransactionFailed = function(transactionId, errorObj) -{ - if (!WebInspector.Database._callbacks[transactionId]) - return; + sqlTransactionSucceeded: function(transactionId, columnNames, values) + { + if (!WebInspector.DatabaseDispatcher._callbacks[transactionId]) + return; + + var callback = WebInspector.DatabaseDispatcher._callbacks[transactionId].onSuccess; + delete WebInspector.DatabaseDispatcher._callbacks[transactionId]; + if (callback) + callback(columnNames, values); + }, + + sqlTransactionFailed: function(transactionId, errorObj) + { + if (!WebInspector.DatabaseDispatcher._callbacks[transactionId]) + return; - var callback = WebInspector.Database._callbacks[transactionId].onError; - delete WebInspector.Database._callbacks[transactionId]; - if (callback) - callback(errorObj); + var callback = WebInspector.DatabaseDispatcher._callbacks[transactionId].onError; + delete WebInspector.DatabaseDispatcher._callbacks[transactionId]; + if (callback) + callback(errorObj); + } } -InspectorBackend.registerDomainDispatcher("Database", WebInspector.Database); +InspectorBackend.registerDomainDispatcher("Database", new WebInspector.DatabaseDispatcher()); diff --git a/Source/WebCore/inspector/front-end/DebuggerModel.js b/Source/WebCore/inspector/front-end/DebuggerModel.js index 5ab0e2d..8f5bcf7 100644 --- a/Source/WebCore/inspector/front-end/DebuggerModel.js +++ b/Source/WebCore/inspector/front-end/DebuggerModel.js @@ -30,12 +30,12 @@ WebInspector.DebuggerModel = function() { - InspectorBackend.registerDomainDispatcher("Debugger", this); - this._paused = false; this._breakpoints = {}; this._sourceIDAndLineToBreakpointId = {}; this._scripts = {}; + + InspectorBackend.registerDomainDispatcher("Debugger", new WebInspector.DebuggerDispatcher(this)); } WebInspector.DebuggerModel.Events = { @@ -86,11 +86,6 @@ WebInspector.DebuggerModel.prototype = { this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointRemoved, breakpointId); }, - breakpointResolved: function(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber) - { - this._breakpointSetOnBackend(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber, true); - }, - _breakpointSetOnBackend: function(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber, restored) { var sourceIDAndLine = this._encodeSourceIDAndLine(sourceID, lineNumber); @@ -161,9 +156,7 @@ WebInspector.DebuggerModel.prototype = { return scripts; }, - // All the methods below are InspectorBackend notification handlers. - - pausedScript: function(details) + _pausedScript: function(details) { this._paused = true; if ("_continueToLineBreakpointId" in this) { @@ -182,7 +175,7 @@ WebInspector.DebuggerModel.prototype = { this._lastHitBreakpoint = breakpoint; }, - resumedScript: function() + _resumedScript: function() { this._paused = false; this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerResumed); @@ -193,9 +186,42 @@ WebInspector.DebuggerModel.prototype = { delete this._lastHitBreakpoint; }, - attachDebuggerWhenShown: function() + _parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, scriptWorldType) + { + var script = new WebInspector.Script(sourceID, sourceURL, "", lineOffset, columnOffset, undefined, undefined, scriptWorldType); + this._scripts[sourceID] = script; + this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, sourceID); + }, + + _failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage) + { + var script = new WebInspector.Script(null, sourceURL, source, startingLine, errorLine, errorMessage, undefined); + this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, script); + } +} + +WebInspector.DebuggerModel.prototype.__proto__ = WebInspector.Object.prototype; + +WebInspector.DebuggerEventTypes = { + JavaScriptPause: 0, + JavaScriptBreakpoint: 1, + NativeBreakpoint: 2 +}; + +WebInspector.DebuggerDispatcher = function(debuggerModel) +{ + this._debuggerModel = debuggerModel; +} + +WebInspector.DebuggerDispatcher.prototype = { + pausedScript: function(details) + { + this._debuggerModel._pausedScript(details); + }, + + resumedScript: function() { - WebInspector.panels.scripts.attachDebuggerWhenShown(); + this._debuggerModel._resumedScript(); }, debuggerWasEnabled: function() @@ -208,17 +234,19 @@ WebInspector.DebuggerModel.prototype = { WebInspector.panels.scripts.debuggerWasDisabled(); }, - parsedScriptSource: function(sourceID, sourceURL, source, startingLine, scriptWorldType) + parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, scriptWorldType) { - var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, undefined, undefined, scriptWorldType); - this._scripts[sourceID] = script; - this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, sourceID); + this._debuggerModel._parsedScriptSource(sourceID, sourceURL, lineOffset, columnOffset, scriptWorldType); }, failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage) { - var script = new WebInspector.Script(null, sourceURL, source, startingLine, errorLine, errorMessage, undefined); - this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, script); + this._debuggerModel._failedToParseScriptSource(sourceURL, source, startingLine, errorLine, errorMessage); + }, + + breakpointResolved: function(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber) + { + this._debuggerModel._breakpointSetOnBackend(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber, true); }, didCreateWorker: function() @@ -233,11 +261,3 @@ WebInspector.DebuggerModel.prototype = { workersPane.removeWorker.apply(workersPane, arguments); } } - -WebInspector.DebuggerModel.prototype.__proto__ = WebInspector.Object.prototype; - -WebInspector.DebuggerEventTypes = { - JavaScriptPause: 0, - JavaScriptBreakpoint: 1, - NativeBreakpoint: 2 -}; diff --git a/Source/WebCore/inspector/front-end/ExtensionServer.js b/Source/WebCore/inspector/front-end/ExtensionServer.js index 373c855..1320efb 100644 --- a/Source/WebCore/inspector/front-end/ExtensionServer.js +++ b/Source/WebCore/inspector/front-end/ExtensionServer.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -288,7 +288,7 @@ WebInspector.ExtensionServer.prototype = { var id = message.id; var resource = null; - resource = WebInspector.networkResources[id] || WebInspector.resourceForURL(id); + resource = WebInspector.networkResourceById(id) || WebInspector.resourceForURL(id); if (!resource) return this._status.E_NOTFOUND(typeof id + ": " + id); @@ -318,7 +318,7 @@ WebInspector.ExtensionServer.prototype = { }; this._dispatchCallback(message.requestId, port, response); } - var resource = WebInspector.networkResources[message.id]; + var resource = WebInspector.networkResourceById(message.id); if (!resource) return this._status.E_NOTFOUND(message.id); resource.requestContent(onContentAvailable.bind(this)); diff --git a/Source/WebCore/inspector/front-end/FileSystemView.js b/Source/WebCore/inspector/front-end/FileSystemView.js index 14ecf46..56f21a4 100644 --- a/Source/WebCore/inspector/front-end/FileSystemView.js +++ b/Source/WebCore/inspector/front-end/FileSystemView.js @@ -28,34 +28,38 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.FileSystem = {} +WebInspector.FileSystemDispatcher = function() +{ +} // Keep in sync with Type in AsyncFileSystem.h -WebInspector.FileSystem.TEMPORARY = 0; -WebInspector.FileSystem.PERSISTENT = 1; +WebInspector.FileSystemDispatcher.TEMPORARY = 0; +WebInspector.FileSystemDispatcher.PERSISTENT = 1; -WebInspector.FileSystem.getFileSystemPathsAsync = function(origin) -{ - InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystem.PERSISTENT, origin); - InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystem.TEMPORARY, origin); -} +WebInspector.FileSystemDispatcher.prototype = { + getFileSystemPathsAsync: function(origin) + { + InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystemDispatcher.PERSISTENT, origin); + InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystemDispatcher.TEMPORARY, origin); + }, -WebInspector.FileSystem.didGetFileSystemPath = function(root, type, origin) -{ - WebInspector.panels.resources.updateFileSystemPath(root, type, origin); -} + didGetFileSystemPath: function(root, type, origin) + { + WebInspector.panels.resources.updateFileSystemPath(root, type, origin); + }, -WebInspector.FileSystem.didGetFileSystemError = function(type, origin) -{ - WebInspector.panels.resources.updateFileSystemError(type, origin); -} + didGetFileSystemError: function(type, origin) + { + WebInspector.panels.resources.updateFileSystemError(type, origin); + }, -WebInspector.FileSystem.didGetFileSystemDisabled = function() -{ - WebInspector.panels.resources.setFileSystemDisabled(); + didGetFileSystemDisabled: function() + { + WebInspector.panels.resources.setFileSystemDisabled(); + } } -InspectorBackend.registerDomainDispatcher("FileSystem", WebInspector.FileSystem); +InspectorBackend.registerDomainDispatcher("FileSystem", new WebInspector.FileSystemDispatcher()); WebInspector.FileSystemView = function(treeElement, fileSystemOrigin) { diff --git a/Source/WebCore/inspector/front-end/HAREntry.js b/Source/WebCore/inspector/front-end/HAREntry.js index 6dfbd1b..4d690b3 100644 --- a/Source/WebCore/inspector/front-end/HAREntry.js +++ b/Source/WebCore/inspector/front-end/HAREntry.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -204,7 +204,7 @@ WebInspector.HARLog.prototype = { version: webKitVersion ? webKitVersion[1] : "n/a" }, pages: this._buildPages(), - entries: Object.keys(WebInspector.networkResources).map(this._convertResource.bind(this)) + entries: WebInspector.networkResources.map(this._convertResource.bind(this)) } }, @@ -228,11 +228,11 @@ WebInspector.HARLog.prototype = { } }, - _convertResource: function(id) + _convertResource: function(resource) { - var entry = (new WebInspector.HAREntry(WebInspector.networkResources[id])).build(); + var entry = (new WebInspector.HAREntry(resource)).build(); if (this.includeResourceIds) - entry._resourceId = id; + entry._resourceId = resource.identifier; return entry; }, diff --git a/Source/WebCore/inspector/front-end/ImageView.js b/Source/WebCore/inspector/front-end/ImageView.js index 54a16bb..917a9da 100644 --- a/Source/WebCore/inspector/front-end/ImageView.js +++ b/Source/WebCore/inspector/front-end/ImageView.js @@ -70,12 +70,7 @@ WebInspector.ImageView.prototype = { var infoListElement = document.createElement("dl"); infoListElement.className = "infoList"; - function onResourceContent(element, content) - { - imagePreviewElement.setAttribute("src", this.resource.contentURL); - } - this.resource.requestContent(onResourceContent.bind(this)); - + this.resource.populateImageSource(imagePreviewElement); function onImageLoad() { @@ -87,7 +82,7 @@ WebInspector.ImageView.prototype = { var imageProperties = [ { name: WebInspector.UIString("Dimensions"), value: WebInspector.UIString("%d × %d", imagePreviewElement.naturalWidth, imagePreviewElement.naturalHeight) }, - { name: WebInspector.UIString("File size"), value: Number.bytesToString(resourceSize, WebInspector.UIString) }, + { name: WebInspector.UIString("File size"), value: Number.bytesToString(resourceSize) }, { name: WebInspector.UIString("MIME type"), value: this.resource.mimeType } ]; @@ -100,6 +95,13 @@ WebInspector.ImageView.prototype = { dd.textContent = imageProperties[i].value; infoListElement.appendChild(dd); } + var dt = document.createElement("dt"); + dt.textContent = WebInspector.UIString("URL"); + infoListElement.appendChild(dt); + var dd = document.createElement("dd"); + dd.appendChild(WebInspector.linkifyURLAsNode(this.resource.url)); + infoListElement.appendChild(dd); + this._container.appendChild(infoListElement); } imagePreviewElement.addEventListener("load", onImageLoad.bind(this), false); diff --git a/Source/WebCore/inspector/front-end/NetworkManager.js b/Source/WebCore/inspector/front-end/NetworkManager.js index b1ec97c..a657377 100644 --- a/Source/WebCore/inspector/front-end/NetworkManager.js +++ b/Source/WebCore/inspector/front-end/NetworkManager.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,8 +30,9 @@ WebInspector.NetworkManager = function(resourceTreeModel) { - this._resourcesById = {}; + this._inflightResources = {}; this._resourceTreeModel = resourceTreeModel; + this._lastIdentifierForCachedResource = 0; InspectorBackend.registerDomainDispatcher("Network", this); } @@ -86,20 +87,21 @@ WebInspector.NetworkManager.updateResourceWithCachedResource = function(resource } WebInspector.NetworkManager.prototype = { - identifierForInitialRequest: function(identifier, url, loader, callStack) + reset: function() { - var resource = this._createResource(identifier, url, loader, callStack); - - // It is important to bind resource url early (before scripts compile). - this._resourceTreeModel.bindResourceURL(resource); + WebInspector.panels.network.clear(); + WebInspector.panels.resources.clear(); + this._resourceTreeModel.reloadCachedResources(); + }, - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceStarted(resource); + identifierForInitialRequest: function(identifier, url, loader, callStack) + { + this._startResource(this._resourceTreeModel.createResource(identifier, url, loader, callStack)); }, willSendRequest: function(identifier, time, request, redirectResponse) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -107,24 +109,22 @@ WebInspector.NetworkManager.prototype = { // See http/tests/misc/will-send-request-returns-null-on-redirect.html var isRedirect = !redirectResponse.isNull && request.url.length; if (isRedirect) { - resource.endTime = time; this.didReceiveResponse(identifier, time, "Other", redirectResponse); - resource = this._appendRedirect(resource.identifier, request.url); + resource = this._appendRedirect(resource.identifier, time, request.url); } WebInspector.NetworkManager.updateResourceWithRequest(resource, request); resource.startTime = time; - if (isRedirect) { - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceStarted(resource); - } else + if (isRedirect) + this._startResource(resource); + else WebInspector.panels.network.refreshResource(resource); }, markResourceAsCached: function(identifier) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -134,7 +134,7 @@ WebInspector.NetworkManager.prototype = { didReceiveResponse: function(identifier, time, resourceType, response) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -149,7 +149,7 @@ WebInspector.NetworkManager.prototype = { didReceiveContentLength: function(identifier, time, lengthReceived) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -161,54 +161,44 @@ WebInspector.NetworkManager.prototype = { didFinishLoading: function(identifier, finishTime) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; - resource.endTime = finishTime; - resource.finished = true; - - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceFinished(resource); - WebInspector.extensionServer.notifyResourceFinished(resource); - delete this._resourcesById[identifier]; + this._finishResource(resource, finishTime); }, didFailLoading: function(identifier, time, localizedDescription) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; resource.failed = true; resource.localizedFailDescription = localizedDescription; - resource.finished = true; - resource.endTime = time; - - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceFinished(resource); - WebInspector.extensionServer.notifyResourceFinished(resource); - delete this._resourcesById[identifier]; + this._finishResource(resource, time); }, didLoadResourceFromMemoryCache: function(time, cachedResource) { - var resource = this._createResource(null, cachedResource.url, cachedResource.loader); + var resource = this._resourceTreeModel.createResource("cached:" + ++this._lastIdentifierForCachedResource, cachedResource.url, cachedResource.loader); WebInspector.NetworkManager.updateResourceWithCachedResource(resource, cachedResource); resource.cached = true; resource.requestMethod = "GET"; - resource.startTime = resource.responseReceivedTime = resource.endTime = time; - resource.finished = true; - - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceStarted(resource); - WebInspector.panels.audits.resourceFinished(resource); + this._startResource(resource); + resource.startTime = resource.responseReceivedTime = time; + this._finishResource(resource, time); this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource); }, + frameDetachedFromParent: function(frameId) + { + this._resourceTreeModel.frameDetachedFromParent(frameId); + }, + setInitialContent: function(identifier, sourceString, type) { - var resource = WebInspector.panels.network.resources[identifier]; + var resource = WebInspector.networkResourceById(identifier); if (!resource) return; @@ -226,20 +216,21 @@ WebInspector.NetworkManager.prototype = { if (mainResource) { WebInspector.mainResource = mainResource; mainResource.isMainResource = true; + WebInspector.panels.network.mainResourceChanged(); } } }, didCreateWebSocket: function(identifier, requestURL) { - var resource = this._createResource(identifier, requestURL); + var resource = this._resourceTreeModel.createResource(identifier, requestURL); resource.type = WebInspector.Resource.Type.WebSocket; - WebInspector.panels.network.refreshResource(resource); + this._startResource(resource); }, willSendWebSocketHandshakeRequest: function(identifier, time, request) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -253,7 +244,7 @@ WebInspector.NetworkManager.prototype = { didReceiveWebSocketHandshakeResponse: function(identifier, time, response) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -268,31 +259,44 @@ WebInspector.NetworkManager.prototype = { didCloseWebSocket: function(identifier, time) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; - resource.endTime = time; - - WebInspector.panels.network.refreshResource(resource); + this._finishResource(resource, time); }, - _createResource: function(identifier, url, loader, callStack) + _appendRedirect: function(identifier, time, redirectURL) { - var resource = WebInspector.ResourceTreeModel.createResource(identifier, url, loader, callStack); - this._resourcesById[identifier] = resource; - return resource; + var originalResource = this._inflightResources[identifier]; + var previousRedirects = originalResource.redirects || []; + originalResource.identifier = "redirected:" + identifier + "." + previousRedirects.length; + delete originalResource.redirects; + this._finishResource(originalResource, time); + // We bound resource early, but it happened to be a redirect and won't make it through to + // the resource tree -- so unbind it. + // FIXME: we should bind upon adding to the tree only (encapsulated into ResourceTreeModel), + // Script debugger should do explicit late binding on its own. + this._resourceTreeModel.unbindResourceURL(originalResource); + + var newResource = this._resourceTreeModel.createResource(identifier, redirectURL, originalResource.loader, originalResource.stackTrace); + newResource.redirects = previousRedirects.concat(originalResource); + return newResource; }, - _appendRedirect: function(identifier, redirectURL) + _startResource: function(resource, skipRefresh) { - var originalResource = this._resourcesById[identifier]; - originalResource.finished = true; - originalResource.identifier = null; + this._inflightResources[resource.identifier] = resource; + WebInspector.panels.network.appendResource(resource, skipRefresh); + WebInspector.panels.audits.resourceStarted(resource); + }, - var newResource = this._createResource(identifier, redirectURL, originalResource.loader, originalResource.stackTrace); - newResource.redirects = originalResource.redirects || []; - delete originalResource.redirects; - newResource.redirects.push(originalResource); - return newResource; + _finishResource: function(resource, finishTime) + { + resource.endTime = finishTime; + resource.finished = true; + WebInspector.panels.network.refreshResource(resource); + WebInspector.panels.audits.resourceFinished(resource); + WebInspector.extensionServer.notifyResourceFinished(resource); + delete this._inflightResources[resource.identifier]; } } diff --git a/Source/WebCore/inspector/front-end/NetworkPanel.js b/Source/WebCore/inspector/front-end/NetworkPanel.js index 7b6df8b..28cbd36 100644 --- a/Source/WebCore/inspector/front-end/NetworkPanel.js +++ b/Source/WebCore/inspector/front-end/NetworkPanel.js @@ -1,7 +1,7 @@ /* * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,7 +38,6 @@ WebInspector.NetworkPanel = function() this._resources = []; this._resourcesById = {}; this._resourcesByURL = {}; - this._lastIdentifier = 0; this._staleResources = []; this._resourceGridNodes = {}; this._mainResourceLoadTime = -1; @@ -733,12 +732,6 @@ WebInspector.NetworkPanel.prototype = { this._preserveLogToggle.toggled = !this._preserveLogToggle.toggled; }, - reset: function() - { - if (!this._preserveLogToggle.toggled) - this._reset(); - }, - _reset: function() { this._popoverHelper.hidePopup(); @@ -771,32 +764,34 @@ WebInspector.NetworkPanel.prototype = { get resources() { - return this._resourcesById; + return this._resources; }, - refreshResource: function(resource) + resourceById: function(id) { - if (!resource.identifier) - resource.identifier = "network:" + this._lastIdentifier++; + return this._resourcesById[id]; + }, - if (!this._resourcesById[resource.identifier]) { - this._resources.push(resource); - this._resourcesById[resource.identifier] = resource; - this._resourcesByURL[resource.url] = resource; + appendResource: function(resource) + { + this._resources.push(resource); + this._resourcesById[resource.identifier] = resource; + this._resourcesByURL[resource.url] = resource; - // Pull all the redirects of the main resource upon commit load. - if (resource.redirects) { - for (var i = 0; i < resource.redirects.length; ++i) - this.refreshResource(resource.redirects[i]); - } + // Pull all the redirects of the main resource upon commit load. + if (resource.redirects) { + for (var i = 0; i < resource.redirects.length; ++i) + this.refreshResource(resource.redirects[i]); } + this.refreshResource(resource); + }, + + refreshResource: function(resource) + { this._staleResources.push(resource); this._scheduleRefresh(); - if (!resource) - return; - var oldView = WebInspector.ResourceView.existingResourceViewForResource(resource); if (!oldView) return; @@ -809,6 +804,24 @@ WebInspector.NetworkPanel.prototype = { this.visibleView = newView; }, + clear: function() + { + if (this._preserveLogToggle.toggled) + return; + this._reset(); + }, + + mainResourceChanged: function() + { + if (this._preserveLogToggle.toggled) + return; + + this._reset(); + // Now resurrect the main resource along with all redirects that lead to it. + var resourcesToAppend = (WebInspector.mainResource.redirects || []).concat(WebInspector.mainResource); + resourcesToAppend.forEach(this.appendResource, this); + }, + canShowSourceLine: function(url, line) { return !!this._resourcesByURL[url]; @@ -978,7 +991,7 @@ WebInspector.NetworkPanel.prototype = { _contextMenu: function(event) { // createBlobURL is enabled conditionally, do not expose resource export if it's not available. - if (typeof window.createObjectURL !== "function" || !Preferences.resourceExportEnabled) + if (typeof window.webkitURL.createObjectURL !== "function" || !Preferences.resourceExportEnabled) return; var contextMenu = new WebInspector.ContextMenu(); @@ -1230,7 +1243,7 @@ WebInspector.NetworkTimeCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value, WebInspector.UIString); + return Number.secondsToString(value); }, _lowerBound: function(resource) @@ -1254,7 +1267,7 @@ WebInspector.NetworkTransferTimeCalculator = function() WebInspector.NetworkTransferTimeCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value, WebInspector.UIString); + return Number.secondsToString(value); }, _lowerBound: function(resource) @@ -1278,7 +1291,7 @@ WebInspector.NetworkTransferDurationCalculator = function() WebInspector.NetworkTransferDurationCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value, WebInspector.UIString); + return Number.secondsToString(value); }, _upperBound: function(resource) @@ -1408,15 +1421,7 @@ WebInspector.NetworkDataGridNode.prototype = { if (this._resource.category === WebInspector.resourceCategories.images) { var previewImage = document.createElement("img"); previewImage.className = "image-network-icon-preview"; - - function onResourceContent() - { - previewImage.src = this._resource.contentURL; - } - if (Preferences.useDataURLForResourceImageIcons) - this._resource.requestContent(onResourceContent.bind(this)); - else - previewImage.src = this._resource.url; + this._resource.populateImageSource(previewImage); var iconElement = document.createElement("div"); iconElement.className = "icon"; diff --git a/Source/WebCore/inspector/front-end/ProfileDataGridTree.js b/Source/WebCore/inspector/front-end/ProfileDataGridTree.js index adf34f1..7988674 100644 --- a/Source/WebCore/inspector/front-end/ProfileDataGridTree.js +++ b/Source/WebCore/inspector/front-end/ProfileDataGridTree.js @@ -50,7 +50,7 @@ WebInspector.ProfileDataGridNode.prototype = { { function formatMilliseconds(time) { - return Number.secondsToString(time / 1000, WebInspector.UIString, !Preferences.samplingCPUProfiler); + return Number.secondsToString(time / 1000, !Preferences.samplingCPUProfiler); } var data = {}; diff --git a/Source/WebCore/inspector/front-end/ProfilesPanel.js b/Source/WebCore/inspector/front-end/ProfilesPanel.js index bff5be7..2e0ab28 100644 --- a/Source/WebCore/inspector/front-end/ProfilesPanel.js +++ b/Source/WebCore/inspector/front-end/ProfilesPanel.js @@ -124,7 +124,7 @@ WebInspector.ProfilesPanel = function() this._profiles = []; this._profilerEnabled = Preferences.profilerAlwaysEnabled; this._reset(); - InspectorBackend.registerDomainDispatcher("Profiler", this); + InspectorBackend.registerDomainDispatcher("Profiler", new WebInspector.ProfilerDispatcher(this)); } WebInspector.ProfilesPanel.prototype = { @@ -162,7 +162,7 @@ WebInspector.ProfilesPanel.prototype = { this._populateProfiles(); }, - profilerWasEnabled: function() + _profilerWasEnabled: function() { if (this._profilerEnabled) return; @@ -174,7 +174,7 @@ WebInspector.ProfilesPanel.prototype = { this._populateProfiles(); }, - profilerWasDisabled: function() + _profilerWasDisabled: function() { if (!this._profilerEnabled) return; @@ -183,11 +183,6 @@ WebInspector.ProfilesPanel.prototype = { this._reset(); }, - resetProfiles: function() - { - this._reset(); - }, - _reset: function() { for (var i = 0; i < this._profiles.length; ++i) @@ -262,7 +257,7 @@ WebInspector.ProfilesPanel.prototype = { return escape(text) + '/' + escape(profileTypeId); }, - addProfileHeader: function(profile) + _addProfileHeader: function(profile) { var typeId = profile.typeId; var profileType = this.getProfileType(typeId); @@ -327,7 +322,7 @@ WebInspector.ProfilesPanel.prototype = { } }, - removeProfileHeader: function(profile) + _removeProfileHeader: function(profile) { var typeId = profile.typeId; var profileType = this.getProfileType(typeId); @@ -432,7 +427,7 @@ WebInspector.ProfilesPanel.prototype = { } }, - addHeapSnapshotChunk: function(uid, chunk) + _addHeapSnapshotChunk: function(uid, chunk) { var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)]; if (!profile || profile._loaded || !profile._is_loading) @@ -441,7 +436,7 @@ WebInspector.ProfilesPanel.prototype = { profile._json += chunk; }, - finishHeapSnapshot: function(uid) + _finishHeapSnapshot: function(uid) { var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)]; if (!profile || profile._loaded || !profile._is_loading) @@ -600,7 +595,7 @@ WebInspector.ProfilesPanel.prototype = { var profileHeadersLength = profileHeaders.length; for (var i = 0; i < profileHeadersLength; ++i) if (!this.hasProfile(profileHeaders[i])) - WebInspector.panels.profiles.addProfileHeader(profileHeaders[i]); + this._addProfileHeader(profileHeaders[i]); } InspectorBackend.getProfileHeaders(populateCallback.bind(this)); @@ -616,22 +611,22 @@ WebInspector.ProfilesPanel.prototype = { this.resize(); }, - setRecordingProfile: function(isProfiling) + _setRecordingProfile: function(isProfiling) { this.getProfileType(WebInspector.CPUProfileType.TypeId).setRecordingProfile(isProfiling); if (this.hasTemporaryProfile(WebInspector.CPUProfileType.TypeId) !== isProfiling) { if (!this._temporaryRecordingProfile) { this._temporaryRecordingProfile = { typeId: WebInspector.CPUProfileType.TypeId, - title: WebInspector.UIString("Recording"), + title: WebInspector.UIString("Recording…"), uid: -1, isTemporary: true }; } if (isProfiling) - this.addProfileHeader(this._temporaryRecordingProfile); + this._addProfileHeader(this._temporaryRecordingProfile); else - this.removeProfileHeader(this._temporaryRecordingProfile); + this._removeProfileHeader(this._temporaryRecordingProfile); } this.updateProfileTypeButtons(); } @@ -639,6 +634,49 @@ WebInspector.ProfilesPanel.prototype = { WebInspector.ProfilesPanel.prototype.__proto__ = WebInspector.Panel.prototype; + +WebInspector.ProfilerDispatcher = function(profiler) +{ + this._profiler = profiler; +} + +WebInspector.ProfilerDispatcher.prototype = { + profilerWasEnabled: function() + { + this._profiler._profilerWasEnabled(); + }, + + profilerWasDisabled: function() + { + this._profiler._profilerWasDisabled(); + }, + + resetProfiles: function() + { + this._profiler._reset(); + }, + + addProfileHeader: function(profile) + { + this._profiler._addProfileHeader(profile); + }, + + addHeapSnapshotChunk: function(uid, chunk) + { + this._profiler._addHeapSnapshotChunk(uid, chunk); + }, + + finishHeapSnapshot: function(uid) + { + this._profiler._finishHeapSnapshot(uid); + }, + + setRecordingProfile: function(isProfiling) + { + this._profiler._setRecordingProfile(isProfiling); + } +} + WebInspector.ProfileSidebarTreeElement = function(profile, titleFormat, className) { this.profile = profile; @@ -660,7 +698,7 @@ WebInspector.ProfileSidebarTreeElement.prototype = { ondelete: function() { - this.treeOutline.panel.removeProfileHeader(this.profile); + this.treeOutline.panel._removeProfileHeader(this.profile); return true; }, @@ -720,4 +758,3 @@ WebInspector.ProfileGroupSidebarTreeElement.prototype = { } WebInspector.ProfileGroupSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; - diff --git a/Source/WebCore/inspector/front-end/Resource.js b/Source/WebCore/inspector/front-end/Resource.js index 063ca43..7340645 100644 --- a/Source/WebCore/inspector/front-end/Resource.js +++ b/Source/WebCore/inspector/front-end/Resource.js @@ -55,7 +55,27 @@ WebInspector.Resource.Type = { toUIString: function(type) { - return WebInspector.UIString(WebInspector.Resource.Type.toString(type)); + switch (type) { + case this.Document: + return WebInspector.UIString("Document"); + case this.Stylesheet: + return WebInspector.UIString("Stylesheet"); + case this.Image: + return WebInspector.UIString("Image"); + case this.Font: + return WebInspector.UIString("Font"); + case this.Script: + return WebInspector.UIString("Script"); + case this.XHR: + return WebInspector.UIString("XHR"); + case this.Media: + return WebInspector.UIString("Media"); + case this.WebSocket: + return WebInspector.UIString("WebSocket"); + case this.Other: + default: + return WebInspector.UIString("Other"); + } }, // Returns locale-independent string identifier of resource type (primarily for use in extension API). @@ -658,7 +678,20 @@ WebInspector.Resource.prototype = { this._innerRequestContent(); }, - get contentURL() + populateImageSource: function(image) + { + function onResourceContent() + { + image.src = this._contentURL(); + } + + if (Preferences.useDataURLForResourceImageIcons) + this.requestContent(onResourceContent.bind(this)); + else + image.src = this.url; + }, + + _contentURL: function() { const maxDataUrlSize = 1024 * 1024; // If resource content is not available or won't fit a data URL, fall back to using original URL. diff --git a/Source/WebCore/inspector/front-end/ResourceCookiesView.js b/Source/WebCore/inspector/front-end/ResourceCookiesView.js index e419070..b60b1b6 100644 --- a/Source/WebCore/inspector/front-end/ResourceCookiesView.js +++ b/Source/WebCore/inspector/front-end/ResourceCookiesView.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -56,10 +56,12 @@ WebInspector.ResourceCookiesView.prototype = { if (this._emptyMsgElement) this._emptyMsgElement.parentElement.removeChild(this._emptyMsgElement); - this._cookiesTable = new WebInspector.CookiesTable(null, true, true); - this._cookiesTable.addCookiesFolder(WebInspector.UIString("Request Cookies"), this._resource.requestCookies); - this._cookiesTable.addCookiesFolder(WebInspector.UIString("Response Cookies"), this._resource.responseCookies); - this.element.appendChild(this._cookiesTable.element); + if (!this._cookiesTable) { + this._cookiesTable = new WebInspector.CookiesTable(null, true, true); + this._cookiesTable.addCookiesFolder(WebInspector.UIString("Request Cookies"), this._resource.requestCookies); + this._cookiesTable.addCookiesFolder(WebInspector.UIString("Response Cookies"), this._resource.responseCookies); + this.element.appendChild(this._cookiesTable.element); + } WebInspector.View.prototype.show.call(this, parentElement); this._cookiesTable.updateWidths(); diff --git a/Source/WebCore/inspector/front-end/ResourceTreeModel.js b/Source/WebCore/inspector/front-end/ResourceTreeModel.js index 7c7b86d..b114b94 100644 --- a/Source/WebCore/inspector/front-end/ResourceTreeModel.js +++ b/Source/WebCore/inspector/front-end/ResourceTreeModel.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -31,25 +31,18 @@ WebInspector.ResourceTreeModel = function() { - this._resourcesByURL = {}; - this._resourcesByFrameId = {}; - this._subframes = {}; - InspectorBackend.registerDomainDispatcher("Resources", this); - InspectorBackend.cachedResources(this._processCachedResources.bind(this)); -} - -WebInspector.ResourceTreeModel.createResource = function(identifier, url, loader, stackTrace) -{ - var resource = new WebInspector.Resource(identifier, url); - resource.loader = loader; - if (loader) - resource.documentURL = loader.url; - resource.stackTrace = stackTrace; - - return resource; + this.reloadCachedResources(); } WebInspector.ResourceTreeModel.prototype = { + reloadCachedResources: function() + { + this._resourcesByURL = {}; + this._resourcesByFrameId = {}; + this._subframes = {}; + InspectorBackend.cachedResources(this._processCachedResources.bind(this)); + }, + addOrUpdateFrame: function(frame) { var tmpResource = new WebInspector.Resource(null, frame.url); @@ -175,7 +168,7 @@ WebInspector.ResourceTreeModel.prototype = { preservedResourcesForFrame.push(resource); continue; } - this._unbindResourceURL(resource); + this.unbindResourceURL(resource); } delete this._resourcesByFrameId[frameId]; @@ -201,7 +194,7 @@ WebInspector.ResourceTreeModel.prototype = { return false; }, - _unbindResourceURL: function(resource) + unbindResourceURL: function(resource) { var resourceForURL = this._resourcesByURL[resource.url]; if (!resourceForURL) @@ -226,13 +219,12 @@ WebInspector.ResourceTreeModel.prototype = { _addFramesRecursively: function(framePayload) { - var frameResource = WebInspector.ResourceTreeModel.createResource(null, framePayload.resource.url, framePayload.resource.loader); + var frameResource = this.createResource(null, framePayload.resource.url, framePayload.resource.loader); WebInspector.NetworkManager.updateResourceWithRequest(frameResource, framePayload.resource.request); WebInspector.NetworkManager.updateResourceWithResponse(frameResource, framePayload.resource.response); frameResource.type = WebInspector.Resource.Type["Document"]; frameResource.finished = true; - this.bindResourceURL(frameResource); this.addOrUpdateFrame(framePayload); this.addResourceToFrame(framePayload.id, frameResource); @@ -244,12 +236,24 @@ WebInspector.ResourceTreeModel.prototype = { for (var i = 0; i < framePayload.subresources.length; ++i) { var cachedResource = framePayload.subresources[i]; - var resource = WebInspector.ResourceTreeModel.createResource(null, cachedResource.url, cachedResource.loader); + var resource = this.createResource(null, cachedResource.url, cachedResource.loader); WebInspector.NetworkManager.updateResourceWithCachedResource(resource, cachedResource); resource.finished = true; - this.bindResourceURL(resource); this.addResourceToFrame(framePayload.id, resource); } return frameResource; + }, + + createResource: function(identifier, url, loader, stackTrace) + { + var resource = new WebInspector.Resource(identifier, url); + resource.loader = loader; + if (loader) { + resource.documentURL = loader.url; + this.bindResourceURL(resource); + } + resource.stackTrace = stackTrace; + + return resource; } } diff --git a/Source/WebCore/inspector/front-end/ResourcesPanel.js b/Source/WebCore/inspector/front-end/ResourcesPanel.js index ecb826f..d96989b 100644 --- a/Source/WebCore/inspector/front-end/ResourcesPanel.js +++ b/Source/WebCore/inspector/front-end/ResourcesPanel.js @@ -165,6 +165,12 @@ WebInspector.ResourcesPanel.prototype = { this.sidebarTree.selectedTreeElement.deselect(); }, + clear: function() + { + this.resourcesListTreeElement.removeChildren(); + this.reset(); + }, + addOrUpdateFrame: function(parentFrameId, frameId, title, subtitle) { var frameTreeElement = this._treeElementForFrameId[frameId]; @@ -1005,7 +1011,7 @@ WebInspector.FrameResourceTreeElement.prototype = { if (this._resource.category === WebInspector.resourceCategories.images) { var previewImage = document.createElement("img"); previewImage.className = "image-resource-icon-preview"; - previewImage.src = this._resource.url; + this._resource.populateImageSource(previewImage); var iconElement = document.createElement("div"); iconElement.className = "icon"; @@ -1227,7 +1233,7 @@ WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.Base WebInspector.ResourceRevisionTreeElement = function(storagePanel, revision) { - var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : "(original)"; + var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : WebInspector.UIString("(original)"); WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, "resource-sidebar-tree-item resources-category-" + revision.category.name); if (revision.timestamp) this.tooltip = revision.timestamp.toLocaleString(); diff --git a/Source/WebCore/inspector/front-end/Script.js b/Source/WebCore/inspector/front-end/Script.js index 184fe97..89b2121 100644 --- a/Source/WebCore/inspector/front-end/Script.js +++ b/Source/WebCore/inspector/front-end/Script.js @@ -23,12 +23,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.Script = function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, worldType) +WebInspector.Script = function(sourceID, sourceURL, source, lineOffset, columnOffset, errorLine, errorMessage, worldType) { this.sourceID = sourceID; this.sourceURL = sourceURL; this._source = source; - this.startingLine = startingLine; + this.lineOffset = lineOffset; + this.columnOffset = columnOffset; this.errorLine = errorLine; this.errorMessage = errorMessage; this.worldType = worldType; @@ -57,24 +58,40 @@ WebInspector.Script.WorldType = { EXTENSIONS_WORLD: 1 } -WebInspector.Script.Events = { - SourceChanged: "source-changed" -} - WebInspector.Script.prototype = { + get startingLine() + { + return this.lineOffset + 1; + }, + get linesCount() { if (!this.source) return 0; - if (this._linesCount) - return this._linesCount; - this._linesCount = 0; - var lastIndex = this.source.indexOf("\n"); - while (lastIndex !== -1) { - lastIndex = this.source.indexOf("\n", lastIndex + 1) - this._linesCount++; + if (!this._lineEndings) + this._lineEndings = this._source.findAll("\n"); + return this._lineEndings.length + 1; + }, + + sourceLine: function(lineNumber, callback) + { + function extractSourceLine() + { + lineNumber -= this.startingLine; + callback(this._source.substring(this._lineEndings[lineNumber - 1], this._lineEndings[lineNumber])); + } + + if (this._lineEndings) { + extractSourceLine.call(this); + return; } - return this._linesCount; + + function didRequestSource() + { + this._lineEndings = this._source.findAll("\n"); + extractSourceLine.call(this); + } + this.requestSource(didRequestSource.bind(this)); }, get source() @@ -85,8 +102,20 @@ WebInspector.Script.prototype = { set source(source) { this._source = source; - this.dispatchEventToListeners(WebInspector.Script.Events.SourceChanged); + }, + + requestSource: function(callback) + { + if (this._source) { + callback(this._source); + return; + } + + function didGetScriptSource(source) + { + this._source = source; + callback(this._source); + } + InspectorBackend.getScriptSource(this.sourceID, didGetScriptSource.bind(this)); } } - -WebInspector.Script.prototype.__proto__ = WebInspector.Object.prototype; diff --git a/Source/WebCore/inspector/front-end/ScriptView.js b/Source/WebCore/inspector/front-end/ScriptView.js index 39dae55..d6c1c59 100644 --- a/Source/WebCore/inspector/front-end/ScriptView.js +++ b/Source/WebCore/inspector/front-end/ScriptView.js @@ -29,70 +29,15 @@ WebInspector.ScriptView = function(script) this.element.addStyleClass("script-view"); - this.script = script; - this.script.addEventListener(WebInspector.Script.Events.SourceChanged, this._scriptSourceChanged, this); - - this._frameNeedsSetup = true; - this._sourceFrameSetup = false; - this.sourceFrame = new WebInspector.SourceFrame(this.element, [script], WebInspector.panels.scripts.canEditScripts()); + var contentProvider = new WebInspector.SourceFrameContentProviderForScript(script); + this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, "", WebInspector.panels.scripts.canEditScripts()); } WebInspector.ScriptView.prototype = { - show: function(parentElement) - { - WebInspector.View.prototype.show.call(this, parentElement); - this.setupSourceFrameIfNeeded(); - this.sourceFrame.visible = true; - this.resize(); - }, - - setupSourceFrameIfNeeded: function() - { - if (!this._frameNeedsSetup) - return; - delete this._frameNeedsSetup; - - this.attach(); - - if (this.script.source) - this._sourceFrameSetupFinished(); - else - InspectorBackend.getScriptSource(this.script.sourceID, this._didGetScriptSource.bind(this)); - }, - - _didGetScriptSource: function(source) - { - this.script.source = source || WebInspector.UIString("<source is not available>"); - this._sourceFrameSetupFinished(); - }, - - _sourceFrameSetupFinished: function() - { - this.sourceFrame.setContent("text/javascript", this._prependWhitespace(this.script.source)); - this._sourceFrameSetup = true; - }, - - _prependWhitespace: function(content) { - var prefix = ""; - for (var i = 0; i < this.script.startingLine - 1; ++i) - prefix += "\n"; - return prefix + content; - }, - - attach: function() - { - if (!this.element.parentNode) - document.getElementById("script-resource-views").appendChild(this.element); - }, - - _scriptSourceChanged: function(event) - { - this.sourceFrame.updateContent(this._prependWhitespace(this.script.source)); - }, - // The following methods are pulled from SourceView, since they are // generic and work with ScriptView just fine. + show: WebInspector.SourceView.prototype.show, hide: WebInspector.SourceView.prototype.hide, revealLine: WebInspector.SourceView.prototype.revealLine, highlightLine: WebInspector.SourceView.prototype.highlightLine, @@ -111,3 +56,41 @@ WebInspector.ScriptView.prototype = { } WebInspector.ScriptView.prototype.__proto__ = WebInspector.View.prototype; + + +WebInspector.SourceFrameContentProviderForScript = function(script) +{ + WebInspector.SourceFrameContentProvider.call(this); + this._script = script; +} + +WebInspector.SourceFrameContentProviderForScript.prototype = { + requestContent: function(callback) + { + if (this._script.source) { + callback("text/javascript", this._script.source); + return; + } + + function didRequestSource(content) + { + var source; + if (content) { + var prefix = ""; + for (var i = 0; i < this._script.startingLine - 1; ++i) + prefix += "\n"; + source = prefix + content; + } else + source = WebInspector.UIString("<source is not available>"); + callback("text/javascript", source); + } + this._script.requestSource(didRequestSource.bind(this)); + }, + + scripts: function() + { + return [this._script]; + } +} + +WebInspector.SourceFrameContentProviderForScript.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype; diff --git a/Source/WebCore/inspector/front-end/ScriptsPanel.js b/Source/WebCore/inspector/front-end/ScriptsPanel.js index 138bbda..32212d4 100644 --- a/Source/WebCore/inspector/front-end/ScriptsPanel.js +++ b/Source/WebCore/inspector/front-end/ScriptsPanel.js @@ -218,11 +218,6 @@ WebInspector.ScriptsPanel.prototype = { if (this.visibleView) this.visibleView.show(this.viewsContainerElement); - - if (this._attachDebuggerWhenShown) { - InspectorBackend.enableDebuggerFromFrontend(false); - delete this._attachDebuggerWhenShown; - } }, hide: function() @@ -256,9 +251,6 @@ WebInspector.ScriptsPanel.prototype = { if (resource.finished) { // Resource is finished, bind the script right away. script.resource = resource; - var view = WebInspector.ResourceView.existingResourceViewForResource(resource); - if (view && view.sourceFrame) - view.sourceFrame.addScript(script); } else { // Resource is not finished, bind the script later. if (!resource._scriptsPendingResourceLoad) { @@ -292,7 +284,7 @@ WebInspector.ScriptsPanel.prototype = { return Preferences.canEditScriptSource; }, - editScriptSource: function(editData, commitEditingCallback, cancelEditingCallback) + editScriptSource: function(editData, revertEditingCallback, cancelEditingCallback) { if (!this.canEditScripts()) return; @@ -305,7 +297,16 @@ WebInspector.ScriptsPanel.prototype = { function mycallback(success, newBodyOrErrorMessage, callFrames) { if (success) { - commitEditingCallback(newBodyOrErrorMessage); + var script = WebInspector.debuggerModel.scriptForSourceID(editData.sourceID); + script.source = newBodyOrErrorMessage; + var oldView = script._scriptView + if (oldView) { + script._scriptView = new WebInspector.ScriptView(script); + this.viewRecreated(oldView, script._scriptView); + } + if (script.resource) + script.resource.setContent(newBodyOrErrorMessage, revertEditingCallback); + if (callFrames && callFrames.length) this._debuggerPaused({ data: { callFrames: callFrames } }); } else { @@ -389,15 +390,6 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); }, - attachDebuggerWhenShown: function() - { - if (this.element.parentElement) { - InspectorBackend.enableDebuggerFromFrontend(false); - } else { - this._attachDebuggerWhenShown = true; - } - }, - debuggerWasEnabled: function() { if (this._debuggerEnabled) @@ -460,8 +452,8 @@ WebInspector.ScriptsPanel.prototype = { viewRecreated: function(oldView, newView) { - if (this._visibleView === oldView) - this._visibleView = newView; + if (this.visibleView === oldView) + this.visibleView = newView; }, canShowSourceLine: function(url, line) @@ -527,7 +519,6 @@ WebInspector.ScriptsPanel.prototype = { if (!this.element.parentNode) this.attach(); - view.setupSourceFrameIfNeeded(); return view.sourceFrame; }, @@ -545,10 +536,6 @@ WebInspector.ScriptsPanel.prototype = { if (!view) return null; - if (!view.setupSourceFrameIfNeeded) - return null; - - view.setupSourceFrameIfNeeded(); return view.sourceFrame; }, @@ -862,7 +849,7 @@ WebInspector.ScriptsPanel.prototype = { if (this._debuggerEnabled) InspectorBackend.disableDebugger(true); else - InspectorBackend.enableDebuggerFromFrontend(!!optionalAlways); + InspectorBackend.enableDebugger(!!optionalAlways); }, _togglePauseOnExceptions: function() @@ -892,7 +879,7 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); - InspectorBackend.stepOverStatement(); + InspectorBackend.stepOver(); }, _stepIntoClicked: function() @@ -902,7 +889,7 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); - InspectorBackend.stepIntoStatement(); + InspectorBackend.stepInto(); }, _stepOutClicked: function() @@ -912,7 +899,7 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); - InspectorBackend.stepOutOfFunction(); + InspectorBackend.stepOut(); }, toggleBreakpointsClicked: function() diff --git a/Source/WebCore/inspector/front-end/SourceFrame.js b/Source/WebCore/inspector/front-end/SourceFrame.js index fa8441d..af10f1e 100644 --- a/Source/WebCore/inspector/front-end/SourceFrame.js +++ b/Source/WebCore/inspector/front-end/SourceFrame.js @@ -28,12 +28,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.SourceFrame = function(parentElement, scripts, canEditScripts) +WebInspector.SourceFrame = function(parentElement, contentProvider, url, canEditScripts) { this._parentElement = parentElement; - this._scripts = {}; - for (var i = 0; i < scripts.length; ++i) - this._scripts[scripts[i].sourceID] = scripts[i]; + this._contentProvider = contentProvider; + this._url = url; this._canEditScripts = canEditScripts; this._textModel = new WebInspector.TextEditorModel(); @@ -43,7 +42,6 @@ WebInspector.SourceFrame = function(parentElement, scripts, canEditScripts) this._rowMessages = {}; this._messageBubbles = {}; - this._loaded = false; this._popoverObjectGroup = "popover"; } @@ -51,14 +49,18 @@ WebInspector.SourceFrame.prototype = { set visible(visible) { - this._visible = visible; - this._createViewerIfNeeded(); + if (!this._contentRequested) { + this._contentRequested = true; + this._contentProvider.requestContent(this._createTextViewer.bind(this)); + } if (visible) { if (this._textViewer && this._scrollTop) this._textViewer.element.scrollTop = this._scrollTop; if (this._textViewer && this._scrollLeft) this._textViewer.element.scrollLeft = this._scrollLeft; + if (this._textViewer) + this._textViewer.resize(); } else { this._hidePopup(); if (this._textViewer) { @@ -114,11 +116,6 @@ WebInspector.SourceFrame.prototype = { this._addMessageToSource(msg); }, - addScript: function(script) - { - this._scripts[script.sourceID] = script; - }, - clearMessages: function() { for (var line in this._messageBubbles) { @@ -139,20 +136,6 @@ WebInspector.SourceFrame.prototype = { this._textViewer.revalidateDecorationsAndPaint(); }, - setContent: function(mimeType, content, url) - { - this._loaded = true; - this._textModel.setText(null, content); - this._mimeType = mimeType; - this._url = url; - this._createViewerIfNeeded(); - }, - - updateContent: function(content) - { - this._textModel.setText(null, content); - }, - get textModel() { return this._textModel; @@ -185,10 +168,10 @@ WebInspector.SourceFrame.prototype = { delete this._lineToHighlight; }, - _createViewerIfNeeded: function() + _createTextViewer: function(mimeType, content) { - if (!this._visible || !this._loaded || this._textViewer) - return; + this._content = content; + this._textModel.setText(null, content); this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url); var element = this._textViewer.element; @@ -200,7 +183,7 @@ WebInspector.SourceFrame.prototype = { this._textViewer.beginUpdates(); - this._textViewer.mimeType = this._mimeType; + this._textViewer.mimeType = mimeType; this._addExistingMessagesToSource(); this._updateExecutionLine(); this._updateDiffDecorations(); @@ -222,6 +205,11 @@ WebInspector.SourceFrame.prototype = { delete this._lineToHighlight; } + if (this._delayedFindSearchMatches) { + this._delayedFindSearchMatches(); + delete this._delayedFindSearchMatches; + } + var breakpoints = this._breakpoints(); for (var i = 0; i < breakpoints.length; ++i) this._addBreakpoint(breakpoints[i]); @@ -233,22 +221,35 @@ WebInspector.SourceFrame.prototype = { this._textViewer.editCallback = this._editLine.bind(this); }, - findSearchMatches: function(query) + findSearchMatches: function(query, finishedCallback) { - var ranges = []; + function doFindSearchMatches() + { + var ranges = []; + + // First do case-insensitive search. + var regexObject = createSearchRegex(query); + this._collectRegexMatches(regexObject, ranges); + + // Then try regex search if user knows the / / hint. + try { + if (/^\/.*\/$/.test(query)) + this._collectRegexMatches(new RegExp(query.substring(1, query.length - 1)), ranges); + } catch (e) { + // Silent catch. + } + finishedCallback(ranges); + } - // First do case-insensitive search. - var regexObject = createSearchRegex(query); - this._collectRegexMatches(regexObject, ranges); + if (this._textViewer) + doFindSearchMatches.call(this); + else + this._delayedFindSearchMatches = doFindSearchMatches.bind(this); + }, - // Then try regex search if user knows the / / hint. - try { - if (/^\/.*\/$/.test(query)) - this._collectRegexMatches(new RegExp(query.substring(1, query.length - 1)), ranges); - } catch (e) { - // Silent catch. - } - return ranges; + cancelFindSearchMatches: function() + { + delete this._delayedFindSearchMatches; }, _collectRegexMatches: function(regexObject, ranges) @@ -405,7 +406,7 @@ WebInspector.SourceFrame.prototype = { { var breakpoint = event.data; - if (breakpoint.sourceID in this._scripts) + if (breakpoint.sourceID in this._sourceIDSet()) this._addBreakpoint(breakpoint); }, @@ -418,7 +419,6 @@ WebInspector.SourceFrame.prototype = { breakpoint.addEventListener("condition-changed", this._breakpointChanged, this); breakpoint.addEventListener("removed", this._breakpointRemoved, this); - breakpoint.sourceText = this._textModel.line(breakpoint.line - 1); this._setBreakpointDecoration(breakpoint.line, breakpoint.enabled, !!breakpoint.condition); }, @@ -789,11 +789,12 @@ WebInspector.SourceFrame.prototype = { lineNumber += 1; var lines = []; - for (var i = 0; i < this._textModel.linesCount; ++i) { + var oldLines = this._content.split('\n'); + for (var i = 0; i < oldLines.length; ++i) { if (i === lineNumber - 1) lines.push(newContent); else - lines.push(this._textModel.line(i)); + lines.push(oldLines[i]); } var editData = {}; @@ -817,16 +818,7 @@ WebInspector.SourceFrame.prototype = { _doEditLine: function(editData, cancelEditingCallback) { var revertEditingCallback = this._revertEditLine.bind(this, editData); - var commitEditingCallback = this._commitEditLine.bind(this, editData, revertEditingCallback); - WebInspector.panels.scripts.editScriptSource(editData, commitEditingCallback, cancelEditingCallback); - }, - - _commitEditLine: function(editData, revertEditLineCallback, newContent) - { - var script = this._scripts[editData.sourceID]; - script.source = newContent; - if (script.resource) - script.resource.setContent(newContent, revertEditLineCallback); + WebInspector.panels.scripts.editScriptSource(editData, revertEditingCallback, cancelEditingCallback); }, _setBreakpoint: function(lineNumber, enabled, condition) @@ -841,8 +833,8 @@ WebInspector.SourceFrame.prototype = { _breakpoints: function() { - var scripts = this._scripts; - return WebInspector.debuggerModel.queryBreakpoints(function(b) { return b.sourceID in scripts; }); + var sourceIDSet = this._sourceIDSet(); + return WebInspector.debuggerModel.queryBreakpoints(function(b) { return b.sourceID in sourceIDSet; }); }, _findBreakpoint: function(lineNumber) @@ -855,15 +847,42 @@ WebInspector.SourceFrame.prototype = { { var sourceIDForLine = null; var closestStartingLine = 0; - for (var sourceID in this._scripts) { - var script = this._scripts[sourceID]; - if (script.startingLine <= lineNumber && script.startingLine >= closestStartingLine) { - closestStartingLine = script.startingLine; - sourceIDForLine = sourceID; + var scripts = this._contentProvider.scripts(); + for (var i = 0; i < scripts.length; ++i) { + var startingLine = scripts[i].startingLine; + if (startingLine <= lineNumber && startingLine >= closestStartingLine) { + closestStartingLine = startingLine; + sourceIDForLine = scripts[i].sourceID; } } return sourceIDForLine; + }, + + _sourceIDSet: function() + { + var scripts = this._contentProvider.scripts(); + var sourceIDSet = {}; + for (var i = 0; i < scripts.length; ++i) + sourceIDSet[scripts[i].sourceID] = true; + return sourceIDSet; } } WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype; + + +WebInspector.SourceFrameContentProvider = function() +{ +} + +WebInspector.SourceFrameContentProvider.prototype = { + requestContent: function(callback) + { + // Should be implemented by subclasses. + }, + + scripts: function() + { + // Should be implemented by subclasses. + } +} diff --git a/Source/WebCore/inspector/front-end/SourceView.js b/Source/WebCore/inspector/front-end/SourceView.js index 7a97db2..e78ff94 100644 --- a/Source/WebCore/inspector/front-end/SourceView.js +++ b/Source/WebCore/inspector/front-end/SourceView.js @@ -32,43 +32,29 @@ WebInspector.SourceView = function(resource) this.element.addStyleClass("source"); - var scripts = WebInspector.debuggerModel.scriptsForURL(resource.url); + var contentProvider = new WebInspector.SourceFrameContentProviderForResource(resource); var canEditScripts = WebInspector.panels.scripts.canEditScripts() && resource.type === WebInspector.Resource.Type.Script; - this.sourceFrame = new WebInspector.SourceFrame(this.element, scripts, canEditScripts); - resource.addEventListener("finished", this._resourceLoadingFinished, this); - this._frameNeedsSetup = true; -} - -// This is a map from resource.type to mime types -// found in WebInspector.SourceTokenizer.Registry. -WebInspector.SourceView.DefaultMIMETypeForResourceType = { - 0: "text/html", - 1: "text/css", - 4: "text/javascript" + this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, resource.url, canEditScripts); } WebInspector.SourceView.prototype = { show: function(parentElement) { - WebInspector.ResourceView.prototype.show.call(this, parentElement); - this.setupSourceFrameIfNeeded(); + WebInspector.View.prototype.show.call(this, parentElement); this.sourceFrame.visible = true; - this.resize(); }, hide: function() { this.sourceFrame.visible = false; - if (!this._frameNeedsSetup) - this.sourceFrame.clearLineHighlight(); + this.sourceFrame.clearLineHighlight(); WebInspector.View.prototype.hide.call(this); this._currentSearchResultIndex = -1; }, resize: function() { - if (this.sourceFrame) - this.sourceFrame.resize(); + this.sourceFrame.resize(); }, get scrollTop() @@ -81,42 +67,11 @@ WebInspector.SourceView.prototype = { this.sourceFrame.scrollTop = scrollTop; }, - - setupSourceFrameIfNeeded: function() - { - if (!this._frameNeedsSetup) - return; - - delete this._frameNeedsSetup; - this.resource.requestContent(this._contentLoaded.bind(this)); - }, - hasContent: function() { return true; }, - _contentLoaded: function(content) - { - var mimeType = this._canonicalMimeType(this.resource); - this.sourceFrame.setContent(mimeType, content, this.resource.url); - this._sourceFrameSetupFinished(); - }, - - _canonicalMimeType: function(resource) - { - return WebInspector.SourceView.DefaultMIMETypeForResourceType[resource.type] || resource.mimeType; - }, - - _resourceLoadingFinished: function(event) - { - this._frameNeedsSetup = true; - this._sourceFrameSetup = false; - if (this.visible) - this.setupSourceFrameIfNeeded(); - this.resource.removeEventListener("finished", this._resourceLoadingFinished, this); - }, - // The rest of the methods in this prototype need to be generic enough to work with a ScriptView. // The ScriptView prototype pulls these methods into it's prototype to avoid duplicate code. @@ -125,7 +80,7 @@ WebInspector.SourceView.prototype = { this._currentSearchResultIndex = -1; this._searchResults = []; this.sourceFrame.clearMarkedRange(); - delete this._delayedFindSearchMatches; + this.sourceFrame.cancelFindSearchMatches(); }, performSearch: function(query, finishedCallback) @@ -133,23 +88,13 @@ WebInspector.SourceView.prototype = { // Call searchCanceled since it will reset everything we need before doing a new search. this.searchCanceled(); - this._searchFinishedCallback = finishedCallback; - - function findSearchMatches(query, finishedCallback) + function didFindSearchMatches(searchResults) { - this._searchResults = this.sourceFrame.findSearchMatches(query); + this._searchResults = searchResults; if (this._searchResults) finishedCallback(this, this._searchResults.length); } - - if (!this._sourceFrameSetup) { - // The search is performed in _sourceFrameSetupFinished by calling _delayedFindSearchMatches. - this._delayedFindSearchMatches = findSearchMatches.bind(this, query, finishedCallback); - this.setupSourceFrameIfNeeded(); - return; - } - - findSearchMatches.call(this, query, finishedCallback); + this.sourceFrame.findSearchMatches(query, didFindSearchMatches.bind(this)); }, jumpToFirstSearchResult: function() @@ -198,13 +143,11 @@ WebInspector.SourceView.prototype = { revealLine: function(lineNumber) { - this.setupSourceFrameIfNeeded(); this.sourceFrame.revealLine(lineNumber); }, highlightLine: function(lineNumber) { - this.setupSourceFrameIfNeeded(); this.sourceFrame.highlightLine(lineNumber); }, @@ -225,17 +168,41 @@ WebInspector.SourceView.prototype = { return; this.sourceFrame.markAndRevealRange(foundRange); - }, + } +} + +WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototype; - _sourceFrameSetupFinished: function() + +WebInspector.SourceFrameContentProviderForResource = function(resource) +{ + WebInspector.SourceFrameContentProvider.call(this); + this._resource = resource; +} + +//This is a map from resource.type to mime types +//found in WebInspector.SourceTokenizer.Registry. +WebInspector.SourceFrameContentProviderForResource.DefaultMIMETypeForResourceType = { + 0: "text/html", + 1: "text/css", + 4: "text/javascript" +} + +WebInspector.SourceFrameContentProviderForResource.prototype = { + requestContent: function(callback) { - this._sourceFrameSetup = true; - this.resize(); - if (this._delayedFindSearchMatches) { - this._delayedFindSearchMatches(); - delete this._delayedFindSearchMatches; + function contentLoaded(content) + { + var mimeType = WebInspector.SourceFrameContentProviderForResource.DefaultMIMETypeForResourceType[this._resource.type] || this._resource.mimeType; + callback(mimeType, content); } + this._resource.requestContent(contentLoaded.bind(this)); + }, + + scripts: function() + { + return WebInspector.debuggerModel.scriptsForURL(this._resource.url); } } -WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototype; +WebInspector.SourceFrameContentProviderForResource.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype; diff --git a/Source/WebCore/inspector/front-end/TimelineOverviewPane.js b/Source/WebCore/inspector/front-end/TimelineOverviewPane.js index 55e24c5..0dac916 100644 --- a/Source/WebCore/inspector/front-end/TimelineOverviewPane.js +++ b/Source/WebCore/inspector/front-end/TimelineOverviewPane.js @@ -398,7 +398,7 @@ WebInspector.TimelineOverviewCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value, WebInspector.UIString); + return Number.secondsToString(value); } } diff --git a/Source/WebCore/inspector/front-end/TimelinePanel.js b/Source/WebCore/inspector/front-end/TimelinePanel.js index a661b75..1d8b9c9 100644 --- a/Source/WebCore/inspector/front-end/TimelinePanel.js +++ b/Source/WebCore/inspector/front-end/TimelinePanel.js @@ -83,7 +83,7 @@ WebInspector.TimelinePanel = function() this._calculator = new WebInspector.TimelineCalculator(); this._calculator._showShortEvents = false; - var shortRecordThresholdTitle = Number.secondsToString(WebInspector.TimelinePanel.shortRecordThreshold, WebInspector.UIString); + var shortRecordThresholdTitle = Number.secondsToString(WebInspector.TimelinePanel.shortRecordThreshold); this._showShortRecordsTitleText = WebInspector.UIString("Show the records that are shorter than %s", shortRecordThresholdTitle); this._hideShortRecordsTitleText = WebInspector.UIString("Hide the records that are shorter than %s", shortRecordThresholdTitle); this._createStatusbarButtons(); @@ -99,7 +99,7 @@ WebInspector.TimelinePanel = function() this._markTimelineRecords = []; this._expandOffset = 15; - InspectorBackend.registerDomainDispatcher("Timeline", this); + InspectorBackend.registerDomainDispatcher("Timeline", new WebInspector.TimelineDispatcher(this)); } // Define row height, should be in sync with styles for timeline graphs. @@ -285,20 +285,21 @@ WebInspector.TimelinePanel.prototype = { this._scheduleRefresh(true); }, - timelineProfilerWasStarted: function() + _timelineProfilerWasStarted: function() { this.toggleTimelineButton.toggled = true; }, - timelineProfilerWasStopped: function() + _timelineProfilerWasStopped: function() { this.toggleTimelineButton.toggled = false; }, - addRecordToTimeline: function(record) + _addRecordToTimeline: function(record) { - if (record.type == WebInspector.TimelineAgent.RecordType.ResourceSendRequest && record.data.isMainResource) { - if (this._mainResourceIdentifier != record.data.identifier) { + if (record.type == WebInspector.TimelineAgent.RecordType.ResourceSendRequest) { + var isMainResource = (record.data.identifier === WebInspector.mainResource.identifier); + if (isMainResource && this._mainResourceIdentifier !== record.data.identifier) { // We are loading new main resource -> clear the panel. Check above is necessary since // there may be several resource loads with main resource marker upon redirects, redirects are reported with // the original identifier. @@ -642,6 +643,28 @@ WebInspector.TimelinePanel.prototype = { WebInspector.TimelinePanel.prototype.__proto__ = WebInspector.Panel.prototype; +WebInspector.TimelineDispatcher = function(timelinePanel) +{ + this._timelinePanel = timelinePanel; +} + +WebInspector.TimelineDispatcher.prototype = { + timelineProfilerWasStarted: function() + { + this._timelinePanel._timelineProfilerWasStarted(); + }, + + timelineProfilerWasStopped: function() + { + this._timelinePanel._timelineProfilerWasStopped(); + }, + + addRecordToTimeline: function(record) + { + this._timelinePanel._addRecordToTimeline(record); + } +} + WebInspector.TimelineCategory = function(name, title, color) { this.name = name; @@ -709,7 +732,7 @@ WebInspector.TimelineCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value + this.minimumBoundary - this._absoluteMinimumBoundary, WebInspector.UIString); + return Number.secondsToString(value + this.minimumBoundary - this._absoluteMinimumBoundary); } } @@ -907,7 +930,7 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { label.className = "timeline-aggregated-category timeline-" + index; cell.appendChild(label); var text = document.createElement("span"); - text.textContent = Number.secondsToString(this._aggregatedStats[index] + 0.0001, WebInspector.UIString); + text.textContent = Number.secondsToString(this._aggregatedStats[index] + 0.0001); cell.appendChild(text); } return cell; @@ -918,10 +941,10 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { var contentHelper = new WebInspector.TimelinePanel.PopupContentHelper(this.title); if (this._children && this._children.length) { - contentHelper._appendTextRow(WebInspector.UIString("Self Time"), Number.secondsToString(this._selfTime + 0.0001, WebInspector.UIString)); + contentHelper._appendTextRow(WebInspector.UIString("Self Time"), Number.secondsToString(this._selfTime + 0.0001)); contentHelper._appendElementRow(WebInspector.UIString("Aggregated Time"), this._generateAggregatedInfo()); } - var text = WebInspector.UIString("%s (at %s)", Number.secondsToString(this._lastChildEndTime - this.startTime, WebInspector.UIString), + var text = WebInspector.UIString("%s (at %s)", Number.secondsToString(this._lastChildEndTime - this.startTime), calculator.formatValue(this.startTime - calculator.minimumBoundary)); contentHelper._appendTextRow(WebInspector.UIString("Duration"), text); @@ -929,14 +952,14 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { switch (this.type) { case recordTypes.GCEvent: - contentHelper._appendTextRow(WebInspector.UIString("Collected"), Number.bytesToString(this.data.usedHeapSizeDelta, WebInspector.UIString)); + contentHelper._appendTextRow(WebInspector.UIString("Collected"), Number.bytesToString(this.data.usedHeapSizeDelta)); break; case recordTypes.TimerInstall: case recordTypes.TimerFire: case recordTypes.TimerRemove: contentHelper._appendTextRow(WebInspector.UIString("Timer ID"), this.data.timerId); if (typeof this.timeout === "number") { - contentHelper._appendTextRow(WebInspector.UIString("Timeout"), Number.secondsToString(this.timeout / 1000, WebInspector.UIString)); + contentHelper._appendTextRow(WebInspector.UIString("Timeout"), Number.secondsToString(this.timeout / 1000)); contentHelper._appendTextRow(WebInspector.UIString("Repeats"), !this.singleShot); } break; @@ -977,7 +1000,7 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { contentHelper._appendLinkRow(WebInspector.UIString("Function Call"), this.data.scriptName, this.data.scriptLine); if (this.usedHeapSize) - contentHelper._appendTextRow(WebInspector.UIString("Used Heap Size"), WebInspector.UIString("%s of %s", Number.bytesToString(this.usedHeapSize, WebInspector.UIString), Number.bytesToString(this.totalHeapSize, WebInspector.UIString))); + contentHelper._appendTextRow(WebInspector.UIString("Used Heap Size"), WebInspector.UIString("%s of %s", Number.bytesToString(this.usedHeapSize), Number.bytesToString(this.totalHeapSize))); if (this.callSiteStackTrace && this.callSiteStackTrace.length) contentHelper._appendStackTrace(WebInspector.UIString("Call Site stack"), this.callSiteStackTrace); @@ -992,7 +1015,7 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { { switch (record.type) { case WebInspector.TimelineAgent.RecordType.GCEvent: - return WebInspector.UIString("%s collected", Number.bytesToString(record.data.usedHeapSizeDelta, WebInspector.UIString)); + return WebInspector.UIString("%s collected", Number.bytesToString(record.data.usedHeapSizeDelta)); case WebInspector.TimelineAgent.RecordType.TimerFire: return record.data.scriptName ? WebInspector.linkifyResourceAsNode(record.data.scriptName, "scripts", record.data.scriptLine, "", "") : record.data.timerId; case WebInspector.TimelineAgent.RecordType.FunctionCall: diff --git a/Source/WebCore/inspector/front-end/WebKit.qrc b/Source/WebCore/inspector/front-end/WebKit.qrc index c1008ad..80a6533 100644 --- a/Source/WebCore/inspector/front-end/WebKit.qrc +++ b/Source/WebCore/inspector/front-end/WebKit.qrc @@ -51,7 +51,6 @@ <file>HelpScreen.js</file> <file>ImageView.js</file> <file>InjectedFakeWorker.js</file> - <file>InjectedScript.js</file> <file>InjectedScriptAccess.js</file> <file>inspector.js</file> <file>InspectorFrontendHostStub.js</file> diff --git a/Source/WebCore/inspector/front-end/inspector.html b/Source/WebCore/inspector/front-end/inspector.html index e1590f2..44f096f 100644 --- a/Source/WebCore/inspector/front-end/inspector.html +++ b/Source/WebCore/inspector/front-end/inspector.html @@ -142,7 +142,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="HeapSnapshotView.js"></script> <script type="text/javascript" src="DebuggerModel.js"></script> <script type="text/javascript" src="DOMAgent.js"></script> - <script type="text/javascript" src="InjectedScript.js"></script> <script type="text/javascript" src="InjectedScriptAccess.js"></script> <script type="text/javascript" src="TimelineAgent.js"></script> <script type="text/javascript" src="TimelinePanel.js"></script> diff --git a/Source/WebCore/inspector/front-end/inspector.js b/Source/WebCore/inspector/front-end/inspector.js index 33a75d7..d8a93b1 100644 --- a/Source/WebCore/inspector/front-end/inspector.js +++ b/Source/WebCore/inspector/front-end/inspector.js @@ -443,6 +443,11 @@ var WebInspector = { return this.panels.network.resources; }, + networkResourceById: function(id) + { + return this.panels.network.resourceById(id); + }, + forAllResources: function(callback) { WebInspector.resourceTreeModel.forAllResources(callback); @@ -492,7 +497,7 @@ WebInspector.loaded = function() WebInspector.doLoadedDone = function() { - InspectorBackend.setInjectedScriptSource("(" + injectedScriptConstructor + ");"); + InspectorFrontendHost.loaded(); var platform = WebInspector.platform; document.body.addStyleClass("platform-" + platform); @@ -502,7 +507,6 @@ WebInspector.doLoadedDone = function() var port = WebInspector.port; document.body.addStyleClass("port-" + port); - InspectorFrontendHost.loaded(); WebInspector.settings = new WebInspector.Settings(); this._registerShortcuts(); @@ -618,7 +622,6 @@ WebInspector.doLoadedDone = function() { WebInspector.cssNameCompletions = new WebInspector.CSSCompletions(names); } - // As a DOMAgent method, this needs to happen after the frontend has loaded and the agent is available. InspectorBackend.getSupportedCSSProperties(propertyNamesCallback); } @@ -1175,11 +1178,6 @@ WebInspector.showPanel = function(panel) this.currentPanel = this.panels[panel]; } -WebInspector.consoleMessagesCleared = function() -{ - WebInspector.console.clearMessages(); -} - WebInspector.domContentEventFired = function(time) { this.panels.audits.mainResourceDOMContentTime = time; @@ -1237,33 +1235,6 @@ WebInspector.inspectedURLChanged = function(url) this.extensionServer.notifyInspectedURLChanged(); } -WebInspector.updateConsoleMessageExpiredCount = function(count) -{ - var message = String.sprintf(WebInspector.UIString("%d console messages are not shown."), count); - WebInspector.console.addMessage(WebInspector.ConsoleMessage.createTextMessage(message, WebInspector.ConsoleMessage.MessageLevel.Warning)); -} - -WebInspector.addConsoleMessage = function(payload) -{ - var consoleMessage = new WebInspector.ConsoleMessage( - payload.source, - payload.type, - payload.level, - payload.line, - payload.url, - payload.repeatCount, - payload.message, - payload.parameters, - payload.stackTrace, - payload.requestId); - this.console.addMessage(consoleMessage); -} - -WebInspector.updateConsoleMessageRepeatCount = function(count) -{ - this.console.updateMessageRepeatCount(count); -} - WebInspector.log = function(message, messageLevel) { // remember 'this' for setInterval() callback @@ -1681,6 +1652,12 @@ WebInspector.doPerformSearch = function(query, forceSearch, isBackwardSearch, re this.currentPanel.performSearch(query); } +WebInspector.frontendReused = function() +{ + this.networkManager.reset(); + this.reset(); +} + WebInspector.addNodesToSearchResult = function(nodeIds) { WebInspector.panels.elements.addNodesToSearchResult(nodeIds); diff --git a/Source/WebCore/inspector/front-end/utilities.js b/Source/WebCore/inspector/front-end/utilities.js index 688e080..4320ba8 100644 --- a/Source/WebCore/inspector/front-end/utilities.js +++ b/Source/WebCore/inspector/front-end/utilities.js @@ -388,6 +388,17 @@ String.prototype.hasSubstring = function(string, caseInsensitive) return this.match(new RegExp(string.escapeForRegExp(), "i")); } +String.prototype.findAll = function(string) +{ + var matches = []; + var i = this.indexOf(string); + while (i !== -1) { + matches.push(i); + i = this.indexOf(string, i + string.length); + } + return matches; +} + String.prototype.asParsedURL = function() { // RegExp groups: @@ -643,61 +654,56 @@ function parentNode(node) return node.parentNode; } -Number.millisToString = function(ms, formatterFunction, higherResolution) +Number.millisToString = function(ms, higherResolution) { - return Number.secondsToString(ms / 1000, formatterFunction, higherResolution); + return Number.secondsToString(ms / 1000, higherResolution); } -Number.secondsToString = function(seconds, formatterFunction, higherResolution) +Number.secondsToString = function(seconds, higherResolution) { - if (!formatterFunction) - formatterFunction = String.sprintf; - if (seconds === 0) return "0"; var ms = seconds * 1000; if (higherResolution && ms < 1000) - return formatterFunction("%.3fms", ms); + return WebInspector.UIString("%.3fms", ms); else if (ms < 1000) - return formatterFunction("%.0fms", ms); + return WebInspector.UIString("%.0fms", ms); if (seconds < 60) - return formatterFunction("%.2fs", seconds); + return WebInspector.UIString("%.2fs", seconds); var minutes = seconds / 60; if (minutes < 60) - return formatterFunction("%.1fmin", minutes); + return WebInspector.UIString("%.1fmin", minutes); var hours = minutes / 60; if (hours < 24) - return formatterFunction("%.1fhrs", hours); + return WebInspector.UIString("%.1fhrs", hours); var days = hours / 24; - return formatterFunction("%.1f days", days); + return WebInspector.UIString("%.1f days", days); } -Number.bytesToString = function(bytes, formatterFunction, higherResolution) +Number.bytesToString = function(bytes, higherResolution) { - if (!formatterFunction) - formatterFunction = String.sprintf; if (typeof higherResolution === "undefined") higherResolution = true; if (bytes < 1024) - return formatterFunction("%.0fB", bytes); + return WebInspector.UIString("%.0fB", bytes); var kilobytes = bytes / 1024; if (higherResolution && kilobytes < 1024) - return formatterFunction("%.2fKB", kilobytes); + return WebInspector.UIString("%.2fKB", kilobytes); else if (kilobytes < 1024) - return formatterFunction("%.0fKB", kilobytes); + return WebInspector.UIString("%.0fKB", kilobytes); var megabytes = kilobytes / 1024; if (higherResolution) - return formatterFunction("%.2fMB", megabytes); + return WebInspector.UIString("%.2fMB", megabytes); else - return formatterFunction("%.0fMB", megabytes); + return WebInspector.UIString("%.0fMB", megabytes); } Number.constrain = function(num, min, max) @@ -715,7 +721,7 @@ HTMLTextAreaElement.prototype.moveCursorToEnd = function() this.setSelectionRange(length, length); } -Array.prototype.remove = function(value, onlyFirst) +Object.defineProperty(Array.prototype, "remove", { value: function(value, onlyFirst) { if (onlyFirst) { var index = this.indexOf(value); @@ -729,15 +735,15 @@ Array.prototype.remove = function(value, onlyFirst) if (this[i] === value) this.splice(i, 1); } -} +}}); -Array.prototype.keySet = function() +Object.defineProperty(Array.prototype, "keySet", { value: function() { var keys = {}; for (var i = 0; i < this.length; ++i) keys[this[i]] = true; return keys; -} +}}); Array.diff = function(left, right) { @@ -1050,6 +1056,6 @@ function offerFileForDownload(contents) var builder = new BlobBuilder(); builder.append(contents); var blob = builder.getBlob("application/octet-stream"); - var url = window.createObjectURL(blob); + var url = window.webkitURL.createObjectURL(blob); window.open(url); } diff --git a/Source/WebCore/inspector/xxd.pl b/Source/WebCore/inspector/xxd.pl new file mode 100644 index 0000000..42cf4a2 --- /dev/null +++ b/Source/WebCore/inspector/xxd.pl @@ -0,0 +1,45 @@ +#! /usr/bin/perl
+
+# Copyright (C) 2010 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# # Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# # Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# # Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+$varname = shift;
+$fname = shift;
+$output = shift;
+
+open($input, '<', $fname) or die "Can't open file for read: $fname $!";
+$/ = undef;
+$text = <$input>;
+close($input);
+
+$text = join(', ', map('0x' . unpack("H*", $_), split(undef, $text)));
+
+open($output, '>', $output) or die "Can't open file for write: $output $!";
+print $output "unsigned char $varname\[\] = {\n$text\n};\n";
+close($output);
|