diff options
Diffstat (limited to 'WebCore/inspector')
65 files changed, 2381 insertions, 4042 deletions
diff --git a/WebCore/inspector/CodeGeneratorInspector.pm b/WebCore/inspector/CodeGeneratorInspector.pm index a566576..3a8a6cb 100644 --- a/WebCore/inspector/CodeGeneratorInspector.pm +++ b/WebCore/inspector/CodeGeneratorInspector.pm @@ -43,6 +43,11 @@ $typeTransform{"ApplicationCache"} = { "header" => "InspectorApplicationCacheAgent.h", "domainAccessor" => "m_inspectorController->applicationCacheAgent()", }; +$typeTransform{"FileSystem"} = { + "forward" => "InspectorFileSystemAgent", + "header" => "InspectorFileSystemAgent.h", + "domainAccessor" => "m_inspectorController->fileSystemAgent()", +}; $typeTransform{"Profiler"} = { "forward" => "InspectorProfilerAgent", "header" => "InspectorProfilerAgent.h", diff --git a/WebCore/inspector/ConsoleMessage.cpp b/WebCore/inspector/ConsoleMessage.cpp index 67930cd..03283bf 100644 --- a/WebCore/inspector/ConsoleMessage.cpp +++ b/WebCore/inspector/ConsoleMessage.cpp @@ -33,46 +33,15 @@ #include "InjectedScript.h" #include "InjectedScriptHost.h" +#include "InspectorFrontend.h" #include "InspectorValues.h" +#include "ScriptArguments.h" #include "ScriptCallStack.h" #include "ScriptValue.h" - -#if ENABLE(INSPECTOR) -#include "InspectorFrontend.h" -#endif +#include <wtf/PassOwnPtr.h> namespace WebCore { -ConsoleMessage::CallFrame::CallFrame(const ScriptCallFrame& frame) - : m_functionName(frame.functionName()) - , m_sourceURL(frame.sourceURL()) - , m_lineNumber(frame.lineNumber()) -{ -} - -ConsoleMessage::CallFrame::CallFrame() - : m_lineNumber(0) -{ -} - -bool ConsoleMessage::CallFrame::isEqual(const ConsoleMessage::CallFrame& o) const -{ - return m_functionName == o.m_functionName - && m_sourceURL == o.m_sourceURL - && m_lineNumber == o.m_lineNumber; -} - -#if ENABLE(INSPECTOR) -PassRefPtr<InspectorObject> ConsoleMessage::CallFrame::buildInspectorObject() const -{ - RefPtr<InspectorObject> frame = InspectorObject::create(); - frame->setString("functionName", m_functionName); - frame->setString("sourceURL", m_sourceURL); - frame->setNumber("lineNumber", m_lineNumber); - return frame; -} -#endif - ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u, unsigned g) : m_source(s) , m_type(t) @@ -85,35 +54,26 @@ ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, c { } -ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, ScriptCallStack* callStack, unsigned g, bool storeTrace) +ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, unsigned g) : m_source(s) , m_type(t) , m_level(l) , m_message(m) -#if ENABLE(INSPECTOR) - , m_arguments(callStack->at(0).argumentCount()) - , m_scriptState(callStack->globalState()) -#endif - , m_frames(storeTrace ? callStack->size() : 0) + , m_arguments(arguments) + , m_callStack(callStack) , m_groupLevel(g) , m_repeatCount(1) { - const ScriptCallFrame& lastCaller = callStack->at(0); + const ScriptCallFrame& lastCaller = m_callStack->at(0); m_line = lastCaller.lineNumber(); m_url = lastCaller.sourceURL(); - if (storeTrace) { - for (unsigned i = 0; i < callStack->size(); ++i) - m_frames[i] = ConsoleMessage::CallFrame(callStack->at(i)); - } -#if ENABLE(INSPECTOR) - for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) - m_arguments[i] = lastCaller.argumentAt(i); -#endif + bool storeTrace = (t == TraceMessageType || t == UncaughtExceptionMessageType || t == AssertMessageType); + if (!storeTrace) + m_callStack.clear(); } -#if ENABLE(INSPECTOR) void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost) { RefPtr<InspectorObject> jsonObj = InspectorObject::create(); @@ -125,12 +85,12 @@ void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHo jsonObj->setNumber("groupLevel", static_cast<int>(m_groupLevel)); jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount)); jsonObj->setString("message", m_message); - if (!m_arguments.isEmpty()) { - InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_scriptState.get()); + if (m_arguments && m_arguments->argumentCount()) { + InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_arguments->globalState()); if (!injectedScript.hasNoValue()) { RefPtr<InspectorArray> jsonArgs = InspectorArray::create(); - for (unsigned i = 0; i < m_arguments.size(); ++i) { - RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments[i]); + for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) { + RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments->argumentAt(i)); if (!inspectorValue) { ASSERT_NOT_REACHED(); return; @@ -140,12 +100,8 @@ void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHo jsonObj->setArray("parameters", jsonArgs); } } - if (!m_frames.isEmpty()) { - RefPtr<InspectorArray> frames = InspectorArray::create(); - for (unsigned i = 0; i < m_frames.size(); i++) - frames->pushObject(m_frames.at(i).buildInspectorObject()); - jsonObj->setArray("stackTrace", frames); - } + if (m_callStack) + jsonObj->setArray("stackTrace", m_callStack->buildInspectorObject()); frontend->addConsoleMessage(jsonObj); } @@ -153,32 +109,20 @@ void ConsoleMessage::updateRepeatCountInConsole(InspectorFrontend* frontend) { frontend->updateConsoleMessageRepeatCount(m_repeatCount); } -#endif // ENABLE(INSPECTOR) bool ConsoleMessage::isEqual(ConsoleMessage* msg) const { -#if ENABLE(INSPECTOR) - if (msg->m_arguments.size() != m_arguments.size()) - return false; - if (!msg->m_scriptState.get() && msg->m_arguments.size()) { - ASSERT_NOT_REACHED(); - return false; - } - - for (size_t i = 0; i < m_arguments.size(); ++i) { - if (!m_arguments[i].isEqual(msg->m_scriptState.get(), msg->m_arguments[i])) + if (m_arguments) { + if (!m_arguments->isEqual(msg->m_arguments.get())) return false; - } -#endif // ENABLE(INSPECTOR) - - size_t frameCount = msg->m_frames.size(); - if (frameCount != m_frames.size()) + } else if (msg->m_arguments) return false; - for (size_t i = 0; i < frameCount; ++i) { - if (!m_frames[i].isEqual(msg->m_frames[i])) + if (m_callStack) { + if (!m_callStack->isEqual(msg->m_callStack.get())) return false; - } + } else if (msg->m_callStack) + return false; return msg->m_source == m_source && msg->m_type == m_type diff --git a/WebCore/inspector/ConsoleMessage.h b/WebCore/inspector/ConsoleMessage.h index 6c3f2c7..4e88bec 100644 --- a/WebCore/inspector/ConsoleMessage.h +++ b/WebCore/inspector/ConsoleMessage.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> - * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2009, 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 @@ -32,15 +32,16 @@ #define ConsoleMessage_h #include "Console.h" -#include "KURL.h" #include "ScriptState.h" +#include <wtf/Forward.h> #include <wtf/Vector.h> namespace WebCore { class InjectedScriptHost; class InspectorFrontend; class InspectorObject; +class ScriptArguments; class ScriptCallFrame; class ScriptCallStack; class ScriptValue; @@ -48,12 +49,10 @@ class ScriptValue; class ConsoleMessage : public Noncopyable { public: ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g); - ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, ScriptCallStack*, unsigned g, bool storeTrace = false); + ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, unsigned g); -#if ENABLE(INSPECTOR) void addToFrontend(InspectorFrontend*, InjectedScriptHost*); void updateRepeatCountInConsole(InspectorFrontend* frontend); -#endif void incrementCount() { ++m_repeatCount; } bool isEqual(ConsoleMessage* msg) const; @@ -61,30 +60,12 @@ public: const String& message() const { return m_message; } private: - class CallFrame { - public: - explicit CallFrame(const ScriptCallFrame& frame); - CallFrame(); - bool isEqual(const CallFrame& o) const; -#if ENABLE(INSPECTOR) - PassRefPtr<InspectorObject> buildInspectorObject() const; -#endif - - private: - String m_functionName; - String m_sourceURL; - unsigned m_lineNumber; - }; - MessageSource m_source; MessageType m_type; MessageLevel m_level; String m_message; -#if ENABLE(INSPECTOR) - Vector<ScriptValue> m_arguments; - ScriptStateProtectedPtr m_scriptState; -#endif - Vector<CallFrame> m_frames; + OwnPtr<ScriptArguments> m_arguments; + OwnPtr<ScriptCallStack> m_callStack; unsigned m_line; String m_url; unsigned m_groupLevel; diff --git a/WebCore/inspector/InjectedScriptHost.cpp b/WebCore/inspector/InjectedScriptHost.cpp index 06b25fe..415a2e5 100644 --- a/WebCore/inspector/InjectedScriptHost.cpp +++ b/WebCore/inspector/InjectedScriptHost.cpp @@ -43,7 +43,6 @@ #include "InspectorController.h" #include "InspectorDOMAgent.h" #include "InspectorFrontend.h" -#include "InspectorResource.h" #include "Pasteboard.h" #if ENABLE(JAVASCRIPT_DEBUGGER) diff --git a/WebCore/inspector/Inspector.idl b/WebCore/inspector/Inspector.idl index 331e504..93d5396 100644 --- a/WebCore/inspector/Inspector.idl +++ b/WebCore/inspector/Inspector.idl @@ -46,7 +46,6 @@ module core { [notify] void domContentEventFired(out double time); [notify] void inspectedURLChanged(out String url); [notify] void loadEventFired(out double time); - [notify] void removeResource(out unsigned long identifier); [notify] void reset(); [notify] void resetProfilesPanel(); [notify] void setChildNodes(out long parentId, out Array nodes); @@ -56,7 +55,6 @@ module core { [notify] void timelineProfilerWasStarted(); [notify] void timelineProfilerWasStopped(); [notify] void updateFocusedNode(out long nodeId); - [notify] void updateResource(out Value resource); #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER [notify] void addProfileHeader(out Object header); @@ -100,8 +98,6 @@ module core { [handler=Controller] void setMonitoringXHREnabled(in boolean enable, out boolean newState); - [handler=Controller] void setResourceTrackingEnabled(in boolean enabled, in boolean always, out boolean newState); - [handler=Controller] void getResourceContent(in unsigned long identifier, in boolean encode, out String content); [handler=Controller] void reloadPage(); [handler=Controller] void startTimelineProfiler(); @@ -118,7 +114,7 @@ module core { [notify] void didFailLoading(out long identifier, out double time, out String localizedDescription); [notify] void didLoadResourceFromMemoryCache(out double time, out Object resource); [notify] void setOverrideContent(out long identifier, out String sourceString, out String type); - [notify] void didCommitLoadForFrame(out unsigned long parentFrameId, out Object loader); + [notify] void didCommitLoadForFrame(out Object frame, out Object loader); [notify] void frameDetachedFromParent(out unsigned long frameId); [notify] void didCreateWebSocket(out unsigned long identifier, out String requestURL); @@ -153,8 +149,8 @@ module core { [handler=Controller] void enableProfiler(in boolean always); [handler=Controller] void disableProfiler(in boolean always); - [handler=Profiler] void startProfiling(); - [handler=Profiler] void stopProfiling(); + [handler=Controller] void startProfiling(); + [handler=Controller] void stopProfiling(); [handler=Profiler] void getProfileHeaders(out Array headers); [handler=Profiler] void getProfile(in String type, in unsigned long uid, out Object profile); @@ -196,6 +192,9 @@ module core { [handler=Controller] void hideDOMNodeHighlight(); [handler=Controller] void openInInspectedWindow(in String url); + [handler=Controller] void highlightFrame(in unsigned long frameId); + [handler=Controller] void hideFrameHighlight(); + [handler=DOM] void getStyles(in long nodeId, in boolean authOnly, out Value styles); [handler=DOM] void getAllStyles(out Array styles); [handler=DOM] void getInlineStyle(in long nodeId, out Value style); @@ -217,6 +216,14 @@ module core { [handler=ApplicationCache] void getApplicationCaches(out Value applicationCaches); #endif +#if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM + [handler=FileSystem] void getFileSystemPathAsync(in unsigned int type, in String origin); + [handler=FileSystem] void revealFolderInOS(in String path); + [notify] void didGetFileSystemPath(out String root, out int type, out String origin); + [notify] void didGetFileSystemError(out int type, out String origin); + [notify] void didGetFileSystemDisabled(); +#endif + [handler=Backend] void releaseWrapperObjectGroup(in long injectedScriptId, in String objectGroup); [handler=Controller] void didEvaluateForTestInFrontend(in long testCallId, in String jsonResult); diff --git a/WebCore/inspector/InspectorCSSStore.cpp b/WebCore/inspector/InspectorCSSStore.cpp index b75f11b..08634cb 100644 --- a/WebCore/inspector/InspectorCSSStore.cpp +++ b/WebCore/inspector/InspectorCSSStore.cpp @@ -43,7 +43,6 @@ #include "Frame.h" #include "HTMLHeadElement.h" #include "InspectorController.h" -#include "InspectorResource.h" #include "InspectorResourceAgent.h" #include "Node.h" #include "PlatformString.h" diff --git a/WebCore/inspector/InspectorCSSStore.h b/WebCore/inspector/InspectorCSSStore.h index 25a9d15..0414b58 100644 --- a/WebCore/inspector/InspectorCSSStore.h +++ b/WebCore/inspector/InspectorCSSStore.h @@ -30,7 +30,7 @@ #define InspectorCSSStore_h #include "CSSPropertySourceData.h" -#include "Cache.h" +#include "MemoryCache.h" #include <wtf/Forward.h> #include <wtf/HashMap.h> diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp index 956ef7e..c34130e 100644 --- a/WebCore/inspector/InspectorController.cpp +++ b/WebCore/inspector/InspectorController.cpp @@ -81,6 +81,7 @@ #include "RenderInline.h" #include "ResourceRequest.h" #include "ResourceResponse.h" +#include "ScriptArguments.h" #include "ScriptCallStack.h" #include "ScriptFunctionCall.h" #include "ScriptObject.h" @@ -102,10 +103,6 @@ #include <wtf/StdLibExtras.h> #include <wtf/UnusedParam.h> -#if LEGACY_RESOURCE_TRACKING_ENABLED -#include "InspectorResource.h" -#endif - #if ENABLE(DATABASE) #include "Database.h" #endif @@ -114,6 +111,10 @@ #include "InspectorApplicationCacheAgent.h" #endif +#if ENABLE(FILE_SYSTEM) +#include "InspectorFileSystemAgent.h" +#endif + #if ENABLE(DOM_STORAGE) #include "Storage.h" #include "StorageArea.h" @@ -143,8 +144,6 @@ InspectorController::InspectorController(Page* page, InspectorClient* client) , m_openingFrontend(false) , m_cssStore(new InspectorCSSStore(this)) , m_mainResourceIdentifier(0) - , m_loadEventTime(-1.0) - , m_domContentEventTime(-1.0) , m_expiredConsoleMessageCount(0) , m_groupLevel(0) , m_previousMessage(0) @@ -170,10 +169,6 @@ InspectorController::~InspectorController() ASSERT(!m_inspectedPage); ASSERT(!m_highlightedNode); -#if LEGACY_RESOURCE_TRACKING_ENABLED - deleteAllValues(m_frameResources); -#endif - releaseFrontendLifetimeAgents(); m_inspectorBackend->disconnectController(); @@ -229,13 +224,6 @@ bool InspectorController::searchingForNodeInPage() const return m_state->getBoolean(InspectorState::searchingForNode); } -#if LEGACY_RESOURCE_TRACKING_ENABLED -bool InspectorController::resourceTrackingEnabled() const -{ - return m_state->getBoolean(InspectorState::resourceTrackingEnabled); -} -#endif - void InspectorController::getInspectorState(RefPtr<InspectorObject>* state) { #if ENABLE(JAVASCRIPT_DEBUGGER) @@ -250,6 +238,10 @@ void InspectorController::restoreInspectorStateFromCookie(const String& inspecto m_state->restoreFromInspectorCookie(inspectorStateCookie); if (m_state->getBoolean(InspectorState::timelineProfilerEnabled)) startTimelineProfiler(); +#if ENABLE(JAVASCRIPT_DEBUGGER) + if (m_state->getBoolean(InspectorState::userInitiatedProfiling)) + startUserInitiatedProfiling(); +#endif } void InspectorController::inspect(Node* node) @@ -298,6 +290,17 @@ void InspectorController::highlightDOMNode(long nodeId) highlight(node); } +void InspectorController::highlightFrame(unsigned long frameId) +{ + Frame* mainFrame = m_inspectedPage->mainFrame(); + for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext(mainFrame)) { + if (reinterpret_cast<uintptr_t>(frame) == frameId && frame->ownerElement()) { + highlight(frame->ownerElement()); + return; + } + } +} + void InspectorController::hideHighlight() { if (!enabled()) @@ -325,13 +328,12 @@ void InspectorController::setConsoleMessagesEnabled(bool enabled) m_consoleMessages[i]->addToFrontend(m_frontend.get(), m_injectedScriptHost.get()); } -void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack, const String& message) +void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) { if (!enabled()) return; - bool storeStackTrace = type == TraceMessageType || type == UncaughtExceptionMessageType || type == AssertMessageType; - addConsoleMessage(new ConsoleMessage(source, type, level, message, callStack, m_groupLevel, storeStackTrace)); + addConsoleMessage(new ConsoleMessage(source, type, level, message, arguments, callStack, m_groupLevel)); } void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) @@ -377,11 +379,11 @@ void InspectorController::clearConsoleMessages() m_frontend->consoleMessagesCleared(); } -void InspectorController::startGroup(MessageSource source, ScriptCallStack* callStack, bool collapsed) +void InspectorController::startGroup(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, bool collapsed) { ++m_groupLevel; - addConsoleMessage(new ConsoleMessage(source, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, String(), callStack, m_groupLevel)); + addConsoleMessage(new ConsoleMessage(JSMessageSource, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, "", arguments, callStack, m_groupLevel)); } void InspectorController::endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL) @@ -481,10 +483,7 @@ void InspectorController::connectFrontend() releaseFrontendLifetimeAgents(); m_frontend = new InspectorFrontend(m_client); m_domAgent = InspectorDOMAgent::create(m_cssStore.get(), m_frontend.get()); - -#if !LEGACY_RESOURCE_TRACKING_ENABLED m_resourceAgent = InspectorResourceAgent::create(m_inspectedPage, m_frontend.get()); -#endif #if ENABLE(DATABASE) m_storageAgent = InspectorStorageAgent::create(m_frontend.get()); @@ -500,6 +499,10 @@ void InspectorController::connectFrontend() m_applicationCacheAgent = new InspectorApplicationCacheAgent(this, m_frontend.get()); #endif +#if ENABLE(FILE_SYSTEM) + m_fileSystemAgent = InspectorFileSystemAgent::create(this, m_frontend.get()); +#endif + if (!InspectorInstrumentation::hasFrontends()) ScriptController::setCaptureCallStackForUncaughtExceptions(true); InspectorInstrumentation::frontendCreated(); @@ -509,7 +512,7 @@ void InspectorController::reuseFrontend() { connectFrontend(); restoreDebugger(); - restoreProfiler(); + restoreProfiler(ProfilerRestoreResetAgent); } void InspectorController::show() @@ -568,6 +571,7 @@ void InspectorController::disconnectFrontend() bool debuggerWasEnabled = debuggerEnabled(); disableDebugger(); m_attachDebuggerWhenShown = debuggerWasEnabled; + clearNativeBreakpoints(); #endif setSearchingForNode(false); unbindAllResources(); @@ -577,7 +581,7 @@ void InspectorController::disconnectFrontend() #if ENABLE(JAVASCRIPT_DEBUGGER) m_profilerAgent->setFrontend(0); - m_profilerAgent->stopUserInitiatedProfiling(); + m_profilerAgent->stopUserInitiatedProfiling(true); #endif releaseFrontendLifetimeAgents(); @@ -586,9 +590,7 @@ void InspectorController::disconnectFrontend() void InspectorController::releaseFrontendLifetimeAgents() { -#if !LEGACY_RESOURCE_TRACKING_ENABLED m_resourceAgent.clear(); -#endif // m_domAgent is RefPtr. Remove DOM listeners first to ensure that there are // no references to the DOM agent from the DOM tree. @@ -605,6 +607,12 @@ void InspectorController::releaseFrontendLifetimeAgents() #if ENABLE(OFFLINE_WEB_APPLICATIONS) m_applicationCacheAgent.clear(); #endif + +#if ENABLE(FILE_SYSTEM) + if (m_fileSystemAgent) + m_fileSystemAgent->stop(); + m_fileSystemAgent.clear(); +#endif } void InspectorController::populateScriptObjects() @@ -623,17 +631,6 @@ void InspectorController::populateScriptObjects() m_frontend->profilerWasEnabled(); #endif -#if LEGACY_RESOURCE_TRACKING_ENABLED - ResourcesMap::iterator resourcesEnd = m_resources.end(); - for (ResourcesMap::iterator it = m_resources.begin(); it != resourcesEnd; ++it) - it->second->updateScriptObject(m_frontend.get()); -#endif - - if (m_domContentEventTime != -1.0) - m_frontend->domContentEventFired(m_domContentEventTime); - if (m_loadEventTime != -1.0) - m_frontend->loadEventFired(m_loadEventTime); - m_domAgent->setDocument(m_inspectedPage->mainFrame()->document()); if (m_nodeToFocus) @@ -663,7 +660,7 @@ void InspectorController::populateScriptObjects() m_pendingEvaluateTestCommands.clear(); restoreDebugger(); - restoreProfiler(); + restoreProfiler(ProfilerRestoreNoAction); } void InspectorController::restoreDebugger() @@ -679,24 +676,20 @@ void InspectorController::restoreDebugger() #endif } -void InspectorController::restoreProfiler() +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)) enableProfiler(); + if (action == ProfilerRestoreResetAgent) + m_profilerAgent->resetState(); #endif } void InspectorController::unbindAllResources() { -#if LEGACY_RESOURCE_TRACKING_ENABLED - ResourcesMap::iterator resourcesEnd = m_resources.end(); - for (ResourcesMap::iterator it = m_resources.begin(); it != resourcesEnd; ++it) - it->second->releaseScriptObject(0); -#endif - #if ENABLE(DATABASE) DatabaseResourcesMap::iterator databasesEnd = m_databaseResources.end(); for (DatabaseResourcesMap::iterator it = m_databaseResources.begin(); it != databasesEnd; ++it) @@ -711,36 +704,13 @@ void InspectorController::unbindAllResources() m_timelineAgent->reset(); } -#if LEGACY_RESOURCE_TRACKING_ENABLED -void InspectorController::pruneResources(ResourcesMap* resourceMap, DocumentLoader* loaderToKeep) -{ - ASSERT_ARG(resourceMap, resourceMap); - - ResourcesMap mapCopy(*resourceMap); - ResourcesMap::iterator end = mapCopy.end(); - for (ResourcesMap::iterator it = mapCopy.begin(); it != end; ++it) { - InspectorResource* resource = (*it).second.get(); - if (resource == m_mainResource) - continue; - - if (!loaderToKeep || !resource->isSameLoader(loaderToKeep)) { - removeResource(resource); - if (m_frontend) - resource->releaseScriptObject(m_frontend.get()); - } - } -} -#endif - void InspectorController::didCommitLoad(DocumentLoader* loader) { if (!enabled()) return; -#if !LEGACY_RESOURCE_TRACKING_ENABLED if (m_resourceAgent) m_resourceAgent->didCommitLoad(loader); -#endif ASSERT(m_inspectedPage); @@ -758,13 +728,11 @@ void InspectorController::didCommitLoad(DocumentLoader* loader) if (m_debuggerAgent) m_debuggerAgent->clearForPageNavigation(); - m_nativeBreakpoints.clear(); - m_eventListenerBreakpoints.clear(); - m_XHRBreakpoints.clear(); - m_lastBreakpointId = 0; + clearNativeBreakpoints(); #endif #if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) + m_profilerAgent->stopUserInitiatedProfiling(true); m_profilerAgent->resetState(); #endif @@ -788,32 +756,11 @@ void InspectorController::didCommitLoad(DocumentLoader* loader) #endif if (m_frontend) { -#if LEGACY_RESOURCE_TRACKING_ENABLED - if (!loader->frameLoader()->isLoadingFromCachedPage()) { - ASSERT(m_mainResource && m_mainResource->isSameLoader(loader)); - // We don't add the main resource until its load is committed. This is - // needed to keep the load for a user-entered URL from showing up in the - // list of resources for the page they are navigating away from. - m_mainResource->updateScriptObject(m_frontend.get()); - } else { - // Pages loaded from the page cache are committed before - // m_mainResource is the right resource for this load, so we - // clear it here. It will be re-assigned in - // identifierForInitialRequest. - m_mainResource = 0; - } -#endif m_mainResourceIdentifier = 0; m_frontend->didCommitLoad(); m_domAgent->setDocument(m_inspectedPage->mainFrame()->document()); } } - -#if LEGACY_RESOURCE_TRACKING_ENABLED - for (Frame* frame = loader->frame(); frame; frame = frame->tree()->traverseNext(loader->frame())) - if (ResourcesMap* resourceMap = m_frameResources.get(frame)) - pruneResources(resourceMap, loader); -#endif } void InspectorController::frameDetachedFromParent(Frame* rootFrame) @@ -821,105 +768,19 @@ void InspectorController::frameDetachedFromParent(Frame* rootFrame) if (!enabled()) return; -#if LEGACY_RESOURCE_TRACKING_ENABLED - for (Frame* frame = rootFrame; frame; frame = frame->tree()->traverseNext(rootFrame)) - if (ResourcesMap* resourceMap = m_frameResources.get(frame)) - removeAllResources(resourceMap); -#else if (m_resourceAgent) m_resourceAgent->frameDetachedFromParent(rootFrame); -#endif -} - -#if LEGACY_RESOURCE_TRACKING_ENABLED -void InspectorController::addResource(InspectorResource* resource) -{ - m_resources.set(resource->identifier(), resource); - m_knownResources.add(resource->requestURL()); - - Frame* frame = resource->frame(); - if (!frame) - return; - ResourcesMap* resourceMap = m_frameResources.get(frame); - if (resourceMap) - resourceMap->set(resource->identifier(), resource); - else { - resourceMap = new ResourcesMap; - resourceMap->set(resource->identifier(), resource); - m_frameResources.set(frame, resourceMap); - } -} - -void InspectorController::removeResource(InspectorResource* resource) -{ - m_resources.remove(resource->identifier()); - String requestURL = resource->requestURL(); - if (!requestURL.isNull()) - m_knownResources.remove(requestURL); - - Frame* frame = resource->frame(); - if (!frame) - return; - ResourcesMap* resourceMap = m_frameResources.get(frame); - if (!resourceMap) { - ASSERT_NOT_REACHED(); - return; - } - - resourceMap->remove(resource->identifier()); - if (resourceMap->isEmpty()) { - m_frameResources.remove(frame); - delete resourceMap; - } } -InspectorResource* InspectorController::getTrackedResource(unsigned long identifier) -{ - if (!enabled()) - return 0; - - if (resourceTrackingEnabled()) - return m_resources.get(identifier).get(); - - bool isMainResource = m_mainResource && m_mainResource->identifier() == identifier; - if (isMainResource) - return m_mainResource.get(); - - return 0; -} -#endif - void InspectorController::didLoadResourceFromMemoryCache(DocumentLoader* loader, const CachedResource* cachedResource) { if (!enabled()) return; -#if LEGACY_RESOURCE_TRACKING_ENABLED - // If the resource URL is already known, we don't need to add it again since this is just a cached load. - if (m_knownResources.contains(cachedResource->url())) - return; - - ASSERT(m_inspectedPage); - bool isMainResource = isMainResourceLoader(loader, KURL(ParsedURLString, cachedResource->url())); ensureSettingsLoaded(); - if (!isMainResource && !resourceTrackingEnabled()) - return; - - RefPtr<InspectorResource> resource = InspectorResource::createCached(m_inspectedPage->progress()->createUniqueIdentifier(), loader, cachedResource); - - if (isMainResource) { - m_mainResource = resource; - resource->markMainResource(); - } - - addResource(resource.get()); - if (m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->didLoadResourceFromMemoryCache(loader, cachedResource); -#endif } void InspectorController::identifierForInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request) @@ -932,27 +793,10 @@ void InspectorController::identifierForInitialRequest(unsigned long identifier, if (isMainResource) m_mainResourceIdentifier = identifier; -#if LEGACY_RESOURCE_TRACKING_ENABLED - ensureSettingsLoaded(); - if (!isMainResource && !resourceTrackingEnabled()) - return; - - RefPtr<InspectorResource> resource = InspectorResource::create(identifier, loader, request.url()); - if (isMainResource) { - m_mainResource = resource; - resource->markMainResource(); - } - - addResource(resource.get()); - - if (m_frontend && loader->frameLoader()->isLoadingFromCachedPage() && resource == m_mainResource) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->identifierForInitialRequest(identifier, request.url(), loader); -#endif } void InspectorController::mainResourceFiredDOMContentEvent(DocumentLoader* loader, const KURL& url) @@ -960,11 +804,10 @@ void InspectorController::mainResourceFiredDOMContentEvent(DocumentLoader* loade if (!enabled() || !isMainResourceLoader(loader, url)) return; - m_domContentEventTime = currentTime(); if (m_timelineAgent) m_timelineAgent->didMarkDOMContentEvent(); if (m_frontend) - m_frontend->domContentEventFired(m_domContentEventTime); + m_frontend->domContentEventFired(currentTime()); } void InspectorController::mainResourceFiredLoadEvent(DocumentLoader* loader, const KURL& url) @@ -972,11 +815,10 @@ void InspectorController::mainResourceFiredLoadEvent(DocumentLoader* loader, con if (!enabled() || !isMainResourceLoader(loader, url)) return; - m_loadEventTime = currentTime(); if (m_timelineAgent) m_timelineAgent->didMarkLoadEvent(); if (m_frontend) - m_frontend->loadEventFired(m_loadEventTime); + m_frontend->loadEventFired(currentTime()); } bool InspectorController::isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl) @@ -1000,40 +842,8 @@ void InspectorController::willSendRequest(unsigned long identifier, ResourceRequ if (m_timelineAgent) m_timelineAgent->willSendResourceRequest(identifier, isMainResource, request); -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> resource = getTrackedResource(identifier); - if (!resource) - return; - - if (!redirectResponse.isNull()) { - // Redirect may have empty URL and we'd like to not crash with invalid HashMap entry. - // See http/tests/misc/will-send-request-returns-null-on-redirect.html - if (!request.url().isEmpty()) { - resource->endTiming(0); - resource->updateResponse(redirectResponse); - - // We always store last redirect by the original id key. Rest of the redirects are stored within the last one. - unsigned long id = m_inspectedPage->progress()->createUniqueIdentifier(); - RefPtr<InspectorResource> withRedirect = resource->appendRedirect(id, request.url()); - removeResource(resource.get()); - addResource(withRedirect.get()); - if (isMainResource) { - m_mainResource = withRedirect; - withRedirect->markMainResource(); - } - resource = withRedirect; - } - } - - resource->startTiming(); - resource->updateRequest(request); - - if (resource != m_mainResource && m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->willSendRequest(identifier, request, redirectResponse); -#endif } void InspectorController::markResourceAsCached(unsigned long identifier) @@ -1041,13 +851,8 @@ void InspectorController::markResourceAsCached(unsigned long identifier) if (!enabled()) return; -#if LEGACY_RESOURCE_TRACKING_ENABLED - if (RefPtr<InspectorResource> resource = getTrackedResource(identifier)) - resource->markAsCached(); -#else if (m_resourceAgent) m_resourceAgent->markResourceAsCached(identifier); -#endif } void InspectorController::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response) @@ -1055,18 +860,8 @@ void InspectorController::didReceiveResponse(unsigned long identifier, DocumentL if (!enabled()) return; -#if LEGACY_RESOURCE_TRACKING_ENABLED - if (RefPtr<InspectorResource> resource = getTrackedResource(identifier)) { - resource->updateResponse(response); - - if (resource != m_mainResource && m_frontend) - resource->updateScriptObject(m_frontend.get()); - } - UNUSED_PARAM(loader); -#else if (m_resourceAgent) m_resourceAgent->didReceiveResponse(identifier, loader, response); -#endif if (response.httpStatusCode() >= 400) { String message = makeString("Failed to load resource: the server responded with a status of ", String::number(response.httpStatusCode()), " (", response.httpStatusText(), ')'); @@ -1079,19 +874,8 @@ void InspectorController::didReceiveContentLength(unsigned long identifier, int if (!enabled()) return; -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> resource = getTrackedResource(identifier); - if (!resource) - return; - - resource->addLength(lengthReceived); - - if (resource != m_mainResource && m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->didReceiveContentLength(identifier, lengthReceived); -#endif } void InspectorController::didFinishLoading(unsigned long identifier, double finishTime) @@ -1102,20 +886,8 @@ void InspectorController::didFinishLoading(unsigned long identifier, double fini if (m_timelineAgent) m_timelineAgent->didFinishLoadingResource(identifier, false, finishTime); -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> resource = getTrackedResource(identifier); - if (!resource) - return; - - resource->endTiming(finishTime); - - // No need to mute this event for main resource since it happens after did commit load. - if (m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->didFinishLoading(identifier, finishTime); -#endif } void InspectorController::didFailLoading(unsigned long identifier, const ResourceError& error) @@ -1131,21 +903,8 @@ void InspectorController::didFailLoading(unsigned long identifier, const Resourc message += ": " + error.localizedDescription(); addMessageToConsole(OtherMessageSource, LogMessageType, ErrorMessageLevel, message, 0, error.failingURL()); -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> resource = getTrackedResource(identifier); - if (!resource) - return; - - resource->markFailed(error.localizedDescription()); - resource->endTiming(0); - - // No need to mute this event for main resource since it happens after did commit load. - if (m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->didFailLoading(identifier, error); -#endif } void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber) @@ -1156,22 +915,8 @@ void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identi if (m_state->getBoolean(InspectorState::monitoringXHR)) addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, "XHR finished loading: \"" + url + "\".", sendLineNumber, sendURL); -#if LEGACY_RESOURCE_TRACKING_ENABLED - if (!resourceTrackingEnabled()) - return; - - InspectorResource* resource = m_resources.get(identifier).get(); - if (!resource) - return; - - resource->setOverrideContent(sourceString, InspectorResource::XHR); - - if (m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) - m_resourceAgent->setOverrideContent(identifier, sourceString, InspectorResource::XHR); -#endif + m_resourceAgent->setOverrideContent(identifier, sourceString, "XHR"); } void InspectorController::scriptImported(unsigned long identifier, const String& sourceString) @@ -1179,56 +924,8 @@ void InspectorController::scriptImported(unsigned long identifier, const String& if (!enabled()) return; -#if LEGACY_RESOURCE_TRACKING_ENABLED - if (!resourceTrackingEnabled()) - return; - - InspectorResource* resource = m_resources.get(identifier).get(); - if (!resource) - return; - - resource->setOverrideContent(sourceString, InspectorResource::Script); - - if (m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) - m_resourceAgent->setOverrideContent(identifier, sourceString, InspectorResource::Script); -#endif -} - -#if LEGACY_RESOURCE_TRACKING_ENABLED -void InspectorController::setResourceTrackingEnabled(bool enable) -{ - if (!enabled()) - return; - - ASSERT(m_inspectedPage); - m_state->setBoolean(InspectorState::resourceTrackingEnabled, enable); -} -#endif - -void InspectorController::setResourceTrackingEnabled(bool enable, bool always, bool* newState) -{ -#if LEGACY_RESOURCE_TRACKING_ENABLED - *newState = enable; - - if (always) - m_state->setBoolean(InspectorState::resourceTrackingAlwaysEnabled, enable); - - if (resourceTrackingEnabled() == enable) - return; - - ASSERT(m_inspectedPage); - m_state->setBoolean(InspectorState::resourceTrackingEnabled, enable); - - if (enable) - reloadPage(); -#else - UNUSED_PARAM(enable); - UNUSED_PARAM(always); - UNUSED_PARAM(newState); -#endif + m_resourceAgent->setOverrideContent(identifier, sourceString, "Script"); } void InspectorController::ensureSettingsLoaded() @@ -1238,9 +935,6 @@ void InspectorController::ensureSettingsLoaded() m_settingsLoaded = true; m_state->loadFromSettings(); - - if (m_state->getBoolean(InspectorState::resourceTrackingAlwaysEnabled)) - m_state->setBoolean(InspectorState::resourceTrackingEnabled, true); } void InspectorController::startTimelineProfiler() @@ -1553,67 +1247,27 @@ void InspectorController::didCreateWebSocket(unsigned long identifier, const KUR return; ASSERT(m_inspectedPage); -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> resource = InspectorResource::createWebSocket(identifier, requestURL, documentURL); - addResource(resource.get()); - - if (m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->didCreateWebSocket(identifier, requestURL); UNUSED_PARAM(documentURL); -#endif } void InspectorController::willSendWebSocketHandshakeRequest(unsigned long identifier, const WebSocketHandshakeRequest& request) { -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> resource = getTrackedResource(identifier); - if (!resource) - return; - resource->startTiming(); - resource->updateWebSocketRequest(request); - if (m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->willSendWebSocketHandshakeRequest(identifier, request); -#endif } void InspectorController::didReceiveWebSocketHandshakeResponse(unsigned long identifier, const WebSocketHandshakeResponse& response) { -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> resource = getTrackedResource(identifier); - if (!resource) - return; - // Calling resource->markResponseReceivedTime() here makes resources bar chart confusing, because - // we cannot apply the "latency + download" model of regular resources to WebSocket connections. - // FIXME: Design a new UI for bar charts of WebSocket resources, and record timing here. - resource->updateWebSocketResponse(response); - if (m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->didReceiveWebSocketHandshakeResponse(identifier, response); -#endif } void InspectorController::didCloseWebSocket(unsigned long identifier) { -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> resource = getTrackedResource(identifier); - if (!resource) - return; - - resource->endTiming(0); - if (m_frontend) - resource->updateScriptObject(m_frontend.get()); -#else if (m_resourceAgent) m_resourceAgent->didCloseWebSocket(identifier); -#endif } #endif // ENABLE(WEB_SOCKETS) @@ -1651,6 +1305,7 @@ void InspectorController::startUserInitiatedProfiling() if (!enabled()) return; m_profilerAgent->startUserInitiatedProfiling(); + m_state->setBoolean(InspectorState::userInitiatedProfiling, true); } void InspectorController::stopUserInitiatedProfiling() @@ -1658,6 +1313,7 @@ void InspectorController::stopUserInitiatedProfiling() if (!enabled()) return; m_profilerAgent->stopUserInitiatedProfiling(); + m_state->setBoolean(InspectorState::userInitiatedProfiling, false); } bool InspectorController::profilerEnabled() const @@ -1802,6 +1458,14 @@ String InspectorController::findXHRBreakpoint(const String& url) } return ""; } + +void InspectorController::clearNativeBreakpoints() +{ + m_nativeBreakpoints.clear(); + m_eventListenerBreakpoints.clear(); + m_XHRBreakpoints.clear(); + m_lastBreakpointId = 0; +} #endif void InspectorController::evaluateForTestInFrontend(long callId, const String& script) @@ -2157,22 +1821,6 @@ void InspectorController::setInspectorExtensionAPI(const String& source) m_inspectorExtensionAPI = source; } -void InspectorController::getResourceContent(unsigned long identifier, bool encode, String* content) -{ -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> resource = m_resources.get(identifier); - if (!resource) { - *content = String(); - return; - } - *content = encode ? resource->sourceBytes() : resource->sourceString(); -#else - UNUSED_PARAM(identifier); - UNUSED_PARAM(encode); - UNUSED_PARAM(content); -#endif -} - void InspectorController::reloadPage() { // FIXME: Why do we set the user gesture indicator here? diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h index 80d094f..7dadaa9 100644 --- a/WebCore/inspector/InspectorController.h +++ b/WebCore/inspector/InspectorController.h @@ -80,22 +80,21 @@ class Page; class ResourceRequest; class ResourceResponse; class ResourceError; +class ScriptArguments; class ScriptCallStack; class ScriptProfile; class SharedBuffer; class Storage; class StorageArea; -#define LEGACY_RESOURCE_TRACKING_ENABLED 1 - -#if LEGACY_RESOURCE_TRACKING_ENABLED -class InspectorResource; -#endif - #if ENABLE(OFFLINE_WEB_APPLICATIONS) class InspectorApplicationCacheAgent; #endif +#if ENABLE(FILE_SYSTEM) +class InspectorFileSystemAgent; +#endif + #if ENABLE(WEB_SOCKETS) class WebSocketHandshakeRequest; class WebSocketHandshakeResponse; @@ -103,10 +102,6 @@ class WebSocketHandshakeResponse; class InspectorController : public Noncopyable { public: -#if LEGACY_RESOURCE_TRACKING_ENABLED - typedef HashMap<unsigned long, RefPtr<InspectorResource> > ResourcesMap; - typedef HashMap<RefPtr<Frame>, ResourcesMap*> FrameResourcesMap; -#endif typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap; typedef HashMap<int, RefPtr<InspectorDOMStorageResource> > DOMStorageResourcesMap; @@ -138,6 +133,9 @@ public: void highlightDOMNode(long nodeId); void hideDOMNodeHighlight() { hideHighlight(); } + void highlightFrame(unsigned long frameId); + void hideFrameHighlight() { hideHighlight(); } + void show(); void showPanel(const String&); void close(); @@ -147,8 +145,8 @@ public: void disconnectFrontend(); void setConsoleMessagesEnabled(bool enabled, bool* newState); - void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*, const String& message); - void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID); + void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>); + void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String&); void clearConsoleMessages(); const Vector<OwnPtr<ConsoleMessage> >& consoleMessages() const { return m_consoleMessages; } @@ -175,12 +173,6 @@ public: 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 setResourceTrackingEnabled(bool enabled, bool always, bool* newState); -#if LEGACY_RESOURCE_TRACKING_ENABLED - void setResourceTrackingEnabled(bool enabled); - bool resourceTrackingEnabled() const; -#endif - void ensureSettingsLoaded(); void startTimelineProfiler(); @@ -194,6 +186,10 @@ public: InspectorApplicationCacheAgent* applicationCacheAgent() { return m_applicationCacheAgent.get(); } #endif +#if ENABLE(FILE_SYSTEM) + InspectorFileSystemAgent* fileSystemAgent() { return m_fileSystemAgent.get(); } +#endif + void mainResourceFiredLoadEvent(DocumentLoader*, const KURL&); void mainResourceFiredDOMContentEvent(DocumentLoader*, const KURL&); @@ -222,10 +218,6 @@ public: void didCloseWebSocket(unsigned long identifier); #endif -#if LEGACY_RESOURCE_TRACKING_ENABLED - const ResourcesMap& resources() const { return m_resources; } -#endif - bool hasFrontend() const { return m_frontend; } void drawNodeHighlight(GraphicsContext&) const; @@ -237,7 +229,7 @@ public: void startTiming(const String& title); bool stopTiming(const String& title, double& elapsed); - void startGroup(MessageSource source, ScriptCallStack* callFrame, bool collapsed = false); + void startGroup(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack> callFrame, bool collapsed = false); void endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL); void markTimeline(const String& message); @@ -248,7 +240,9 @@ public: void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL); bool isRecordingUserInitiatedProfile() const; String getCurrentUserInitiatedProfileName(bool incrementProfileNumber = false); + void startProfiling() { startUserInitiatedProfiling(); } void startUserInitiatedProfiling(); + void stopProfiling() { stopUserInitiatedProfiling(); } void stopUserInitiatedProfiling(); void enableProfiler(bool always = false, bool skipRecompile = false); void disableProfiler(bool always = false); @@ -289,9 +283,14 @@ private: friend class InspectorInstrumentation; friend class InjectedScriptHost; + enum ProfilerRestoreAction { + ProfilerRestoreNoAction = 0, + ProfilerRestoreResetAgent = 1 + }; + void populateScriptObjects(); void restoreDebugger(); - void restoreProfiler(); + void restoreProfiler(ProfilerRestoreAction action); void unbindAllResources(); void setSearchingForNode(bool enabled); @@ -308,6 +307,7 @@ private: String findEventListenerBreakpoint(const String& eventName); String findXHRBreakpoint(const String& url); + void clearNativeBreakpoints(); #endif #if ENABLE(DATABASE) void selectDatabase(Database* database); @@ -324,15 +324,6 @@ private: void addConsoleMessage(PassOwnPtr<ConsoleMessage>); -#if LEGACY_RESOURCE_TRACKING_ENABLED - void addResource(InspectorResource*); - void removeResource(InspectorResource*); - InspectorResource* getTrackedResource(unsigned long identifier); - void pruneResources(ResourcesMap*, DocumentLoader* loaderToKeep = 0); - void removeAllResources(ResourcesMap* map) { pruneResources(map); } -#endif - void getResourceContent(unsigned long identifier, bool encode, String* content); - bool isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl); void didEvaluateForTestInFrontend(long callId, const String& jsonResult); @@ -358,17 +349,14 @@ private: #if ENABLE(OFFLINE_WEB_APPLICATIONS) OwnPtr<InspectorApplicationCacheAgent> m_applicationCacheAgent; #endif + +#if ENABLE(FILE_SYSTEM) + RefPtr<InspectorFileSystemAgent> m_fileSystemAgent; +#endif + RefPtr<Node> m_nodeToFocus; -#if LEGACY_RESOURCE_TRACKING_ENABLED - RefPtr<InspectorResource> m_mainResource; - ResourcesMap m_resources; - HashSet<String> m_knownResources; - FrameResourcesMap m_frameResources; -#endif RefPtr<InspectorResourceAgent> m_resourceAgent; unsigned long m_mainResourceIdentifier; - double m_loadEventTime; - double m_domContentEventTime; Vector<OwnPtr<ConsoleMessage> > m_consoleMessages; unsigned m_expiredConsoleMessageCount; HashMap<String, double> m_times; diff --git a/WebCore/inspector/InspectorDOMAgent.cpp b/WebCore/inspector/InspectorDOMAgent.cpp index cfb55fc..9316296 100644 --- a/WebCore/inspector/InspectorDOMAgent.cpp +++ b/WebCore/inspector/InspectorDOMAgent.cpp @@ -568,6 +568,12 @@ void InspectorDOMAgent::setOuterHTML(long nodeId, const String& outerHTML, long* } Node* newNode = previousSibling ? previousSibling->nextSibling() : parentNode->firstChild(); + if (!newNode) { + // The only child node has been deleted. + *newId = 0; + return; + } + *newId = pushNodePathToFrontend(newNode); if (childrenRequested) pushChildNodesToFrontend(*newId); diff --git a/WebCore/inspector/InspectorFileSystemAgent.cpp b/WebCore/inspector/InspectorFileSystemAgent.cpp new file mode 100644 index 0000000..2192fd1 --- /dev/null +++ b/WebCore/inspector/InspectorFileSystemAgent.cpp @@ -0,0 +1,162 @@ +/* + * 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. + */ + +#include "config.h" +#include "InspectorFileSystemAgent.h" + +#if ENABLE(INSPECTOR) && ENABLE(FILE_SYSTEM) + +#include "AsyncFileWriter.h" +#include "Document.h" +#include "FileSystem.h" +#include "FileSystemCallbacks.h" +#include "Frame.h" +#include "FrameTree.h" +#include "InspectorController.h" +#include "InspectorFrontend.h" +#include "LocalFileSystem.h" +#include "Page.h" +#include "RuntimeEnabledFeatures.h" + +namespace WebCore { + +class InspectorFileSystemAgentCallbacks : public AsyncFileSystemCallbacks { +public: + InspectorFileSystemAgentCallbacks(InspectorFileSystemAgent* agent, AsyncFileSystem::Type type, const String& origin) + : m_agent(agent) + , m_type(type) + , m_origin(origin) + { + } + + ~InspectorFileSystemAgentCallbacks() + { + } + + // FileSystemCallbacks is only used for getting filesystem. All other methods are irrelevant and will not be called. + void didSucceed() + { + ASSERT_NOT_REACHED(); + } + + void didOpenFileSystem(const String& name, PassOwnPtr<AsyncFileSystem> fileSystem) + { + // Agent will be alive even if InspectorController is destroyed until callback is run. + m_agent->didGetFileSystemPath(fileSystem->root(), m_type, m_origin); + } + + void didReadMetadata(const FileMetadata&) + { + ASSERT_NOT_REACHED(); + } + + void didReadDirectoryEntry(const String& name, bool isDirectory) + { + ASSERT_NOT_REACHED(); + } + + void didReadDirectoryEntries(bool hasMore) + { + ASSERT_NOT_REACHED(); + } + + void didCreateFileWriter(PassOwnPtr<AsyncFileWriter> writer, long long length) + { + ASSERT_NOT_REACHED(); + } + + void didFail(int code) + { + // FIXME: Is it useful to give back the code to Inspector UI? + m_agent->didGetFileSystemError(m_type, m_origin); + } + +private: + RefPtr<InspectorFileSystemAgent> m_agent; + AsyncFileSystem::Type m_type; + String m_origin; +}; + +InspectorFileSystemAgent::InspectorFileSystemAgent(InspectorController* inspectorController, InspectorFrontend* frontend) + : m_inspectorController(inspectorController) + , m_frontend(frontend) +{ +} + +InspectorFileSystemAgent::~InspectorFileSystemAgent() { } + +void InspectorFileSystemAgent::stop() +{ + m_inspectorController = 0; +} + +void InspectorFileSystemAgent::revealFolderInOS(const String& path) +{ + WebCore::revealFolderInOS(path); +} + +void InspectorFileSystemAgent::getFileSystemPathAsync(unsigned int type, const String& origin) +{ + if (!RuntimeEnabledFeatures::fileSystemEnabled()) { + m_frontend->didGetFileSystemDisabled(); + return; + } + + AsyncFileSystem::Type asyncFileSystemType = static_cast<AsyncFileSystem::Type>(type); + Frame* mainFrame = m_inspectorController->inspectedPage()->mainFrame(); + for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext()) { + Document* document = frame->document(); + if (document && document->securityOrigin()->toString() == origin) { + LocalFileSystem::localFileSystem().readFileSystem(document, asyncFileSystemType, 0, new InspectorFileSystemAgentCallbacks(this, asyncFileSystemType, origin)); + return; + } + } +} + +void InspectorFileSystemAgent::didGetFileSystemPath(const String& root, AsyncFileSystem::Type type, const String& origin) +{ + // When controller is being destroyed, this is set to 0. Agent can live even after m_inspectorController is destroyed. + if (!m_inspectorController) + return; + + m_frontend->didGetFileSystemPath(root, static_cast<unsigned int>(type), origin); +} + +void InspectorFileSystemAgent::didGetFileSystemError(AsyncFileSystem::Type type, const String& origin) +{ + // When controller is being destroyed, this is set to 0. Agent can live even after m_inspectorController is destroyed. + if (!m_inspectorController) + return; + m_frontend->didGetFileSystemError(static_cast<unsigned int>(type), origin); +} + +} // namespace WebCore + +#endif // ENABLE(INSPECTOR) && ENABLE(FILE_SYSTEM) diff --git a/WebCore/inspector/InspectorFileSystemAgent.h b/WebCore/inspector/InspectorFileSystemAgent.h new file mode 100644 index 0000000..a85ad0f --- /dev/null +++ b/WebCore/inspector/InspectorFileSystemAgent.h @@ -0,0 +1,77 @@ +/* + * 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. + */ + +#ifndef InspectorFileSystemAgent_h +#define InspectorFileSystemAgent_h + +#if ENABLE(INSPECTOR) && ENABLE(FILE_SYSTEM) + +#include "AsyncFileSystem.h" +#include "AsyncFileSystemCallbacks.h" +#include <wtf/PassRefPtr.h> + +namespace WebCore { + +class Document; +class InspectorController; +class InspectorFrontend; +class LocalFileSystem; + +class InspectorFileSystemAgent : public RefCounted<InspectorFileSystemAgent> { +public: + static PassRefPtr<InspectorFileSystemAgent> create(InspectorController* inspectorController, InspectorFrontend* frontend) + { + return adoptRef(new InspectorFileSystemAgent(inspectorController, frontend)); + } + + ~InspectorFileSystemAgent(); + void stop(); + + // From Frontend + void getFileSystemPathAsync(unsigned int type, const String& origin); + void revealFolderInOS(const String& path); + + // Backend to Frontend + void didGetFileSystemPath(const String&, AsyncFileSystem::Type, const String& origin); + void didGetFileSystemError(AsyncFileSystem::Type, const String& origin); + void didGetFileSystemDisabled(); + +private: + InspectorFileSystemAgent(InspectorController*, InspectorFrontend*); + void getFileSystemRoot(AsyncFileSystem::Type); + + InspectorController* m_inspectorController; + InspectorFrontend* m_frontend; +}; + +} // namespace WebCore + +#endif // ENABLE(INSPECTOR) && ENABLE(FILE_SYSTEM) +#endif // InspectorFileSystemAgent_h diff --git a/WebCore/inspector/InspectorFrontendHost.cpp b/WebCore/inspector/InspectorFrontendHost.cpp index bc529ea..4b7e13f 100644 --- a/WebCore/inspector/InspectorFrontendHost.cpp +++ b/WebCore/inspector/InspectorFrontendHost.cpp @@ -42,7 +42,6 @@ #include "HitTestResult.h" #include "HTMLFrameOwnerElement.h" #include "InspectorFrontendClient.h" -#include "InspectorResource.h" #include "Page.h" #include "Pasteboard.h" #include "ScriptFunctionCall.h" diff --git a/WebCore/inspector/InspectorProfilerAgent.cpp b/WebCore/inspector/InspectorProfilerAgent.cpp index 71c7231..3f107d6 100644 --- a/WebCore/inspector/InspectorProfilerAgent.cpp +++ b/WebCore/inspector/InspectorProfilerAgent.cpp @@ -95,7 +95,7 @@ void InspectorProfilerAgent::addProfileFinishedMessageToConsole(PassRefPtr<Scrip void InspectorProfilerAgent::addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL) { - String message = makeString("Profile \"webkit-profile://", CPUProfileType, '/', encodeWithURLEscapeSequences(title), "#0 \" started."); + String message = makeString("Profile \"webkit-profile://", CPUProfileType, '/', encodeWithURLEscapeSequences(title), "#0\" started."); m_inspectorController->addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL); } @@ -197,6 +197,8 @@ void InspectorProfilerAgent::resetState() void InspectorProfilerAgent::startUserInitiatedProfiling() { + if (m_recordingUserInitiatedProfile) + return; if (!enabled()) { enable(false); ScriptDebugServer::shared().recompileAllJSFunctions(); @@ -213,8 +215,10 @@ void InspectorProfilerAgent::startUserInitiatedProfiling() toggleRecordButton(true); } -void InspectorProfilerAgent::stopUserInitiatedProfiling() +void InspectorProfilerAgent::stopUserInitiatedProfiling(bool ignoreProfile) { + if (!m_recordingUserInitiatedProfile) + return; m_recordingUserInitiatedProfile = false; String title = getCurrentUserInitiatedProfileName(); #if USE(JSC) @@ -225,8 +229,12 @@ void InspectorProfilerAgent::stopUserInitiatedProfiling() ScriptState* scriptState = 0; #endif RefPtr<ScriptProfile> profile = ScriptProfiler::stop(scriptState, title); - if (profile) - addProfile(profile, 0, String()); + if (profile) { + if (!ignoreProfile) + addProfile(profile, 0, String()); + else + addProfileFinishedMessageToConsole(profile, 0, String()); + } toggleRecordButton(false); } diff --git a/WebCore/inspector/InspectorProfilerAgent.h b/WebCore/inspector/InspectorProfilerAgent.h index 421efb0..c1f5db1 100644 --- a/WebCore/inspector/InspectorProfilerAgent.h +++ b/WebCore/inspector/InspectorProfilerAgent.h @@ -66,10 +66,8 @@ public: void removeProfile(const String& type, unsigned uid); void resetState(); void setFrontend(InspectorFrontend* frontend) { m_frontend = frontend; } - void startProfiling() { startUserInitiatedProfiling(); } void startUserInitiatedProfiling(); - void stopProfiling() { stopUserInitiatedProfiling(); } - void stopUserInitiatedProfiling(); + void stopUserInitiatedProfiling(bool ignoreProfile = false); void takeHeapSnapshot(); void toggleRecordButton(bool isProfiling); diff --git a/WebCore/inspector/InspectorResource.cpp b/WebCore/inspector/InspectorResource.cpp deleted file mode 100644 index 9b3f95d..0000000 --- a/WebCore/inspector/InspectorResource.cpp +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> - * Copyright (C) 2009 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 "InspectorResource.h" - -#if ENABLE(INSPECTOR) - -#include "Base64.h" -#include "Cache.h" -#include "CachedResource.h" -#include "CachedResourceLoader.h" -#include "DocumentLoader.h" -#include "Frame.h" -#include "InspectorFrontend.h" -#include "InspectorResourceAgent.h" -#include "InspectorValues.h" -#include "ResourceLoadTiming.h" -#include "ResourceRequest.h" -#include "ResourceResponse.h" -#include "TextEncoding.h" -#include "WebSocketHandshakeRequest.h" -#include "WebSocketHandshakeResponse.h" - -#include <wtf/Assertions.h> -#include <wtf/text/StringBuffer.h> - -namespace WebCore { - -#if ENABLE(WEB_SOCKETS) -// Create human-readable binary representation, like "01:23:45:67:89:AB:CD:EF". -static String createReadableStringFromBinary(const unsigned char* value, size_t length) -{ - ASSERT(length > 0); - static const char hexDigits[17] = "0123456789ABCDEF"; - size_t bufferSize = length * 3 - 1; - StringBuffer buffer(bufferSize); - size_t index = 0; - for (size_t i = 0; i < length; ++i) { - if (i > 0) - buffer[index++] = ':'; - buffer[index++] = hexDigits[value[i] >> 4]; - buffer[index++] = hexDigits[value[i] & 0xF]; - } - ASSERT(index == bufferSize); - return String::adopt(buffer); -} -#endif - -InspectorResource::InspectorResource(unsigned long identifier, DocumentLoader* loader, const KURL& requestURL) - : m_identifier(identifier) - , m_loader(loader) - , m_frame(loader ? loader->frame() : 0) - , m_requestURL(requestURL) - , m_expectedContentLength(0) - , m_cached(false) - , m_finished(false) - , m_failed(false) - , m_length(0) - , m_responseStatusCode(0) - , m_startTime(-1.0) - , m_responseReceivedTime(-1.0) - , m_endTime(-1.0) - , m_connectionID(0) - , m_connectionReused(false) - , m_isMainResource(false) -#if ENABLE(WEB_SOCKETS) - , m_isWebSocket(false) -#endif -{ -} - -InspectorResource::~InspectorResource() -{ -} - -PassRefPtr<InspectorResource> InspectorResource::appendRedirect(unsigned long identifier, const KURL& redirectURL) -{ - // Last redirect is always a container of all previous ones. Pass this container here. - RefPtr<InspectorResource> redirect = InspectorResource::create(m_identifier, m_loader.get(), redirectURL); - redirect->m_redirects = m_redirects; - redirect->m_redirects.append(this); - redirect->m_changes.set(RedirectsChange); - - m_identifier = identifier; - // Re-send request info with new id. - m_changes.set(RequestChange); - m_redirects.clear(); - return redirect; -} - -PassRefPtr<InspectorResource> InspectorResource::create(unsigned long identifier, DocumentLoader* loader, const KURL& requestURL) -{ - ASSERT(loader); - return adoptRef(new InspectorResource(identifier, loader, requestURL)); -} - -PassRefPtr<InspectorResource> InspectorResource::createCached(unsigned long identifier, DocumentLoader* loader, const CachedResource* cachedResource) -{ - PassRefPtr<InspectorResource> resource = create(identifier, loader, KURL(ParsedURLString, cachedResource->url())); - - resource->m_finished = true; - - resource->updateResponse(cachedResource->response()); - - resource->m_length = cachedResource->encodedSize(); - resource->m_cached = true; - resource->m_startTime = currentTime(); - resource->m_responseReceivedTime = resource->m_startTime; - resource->m_endTime = resource->m_startTime; - - resource->m_changes.setAll(); - - return resource; -} - -#if ENABLE(WEB_SOCKETS) -PassRefPtr<InspectorResource> InspectorResource::createWebSocket(unsigned long identifier, const KURL& requestURL, const KURL& documentURL) -{ - RefPtr<InspectorResource> resource = adoptRef(new InspectorResource(identifier, 0, requestURL)); - resource->markWebSocket(); - resource->m_documentURL = documentURL; - resource->m_changes.setAll(); - return resource.release(); -} -#endif - -void InspectorResource::updateRequest(const ResourceRequest& request) -{ - m_requestHeaderFields = request.httpHeaderFields(); - m_requestMethod = request.httpMethod(); - if (request.httpBody() && !request.httpBody()->isEmpty()) - m_requestFormData = request.httpBody()->flattenToString(); - - m_changes.set(RequestChange); -} - -void InspectorResource::markAsCached() -{ - m_cached = true; -} - -void InspectorResource::updateResponse(const ResourceResponse& response) -{ - m_expectedContentLength = response.expectedContentLength(); - m_mimeType = response.mimeType(); - if (m_mimeType.isEmpty() && response.httpStatusCode() == 304) { - CachedResource* cachedResource = cache()->resourceForURL(response.url().string()); - if (cachedResource) - m_mimeType = cachedResource->response().mimeType(); - } - if (ResourceRawHeaders* headers = response.resourceRawHeaders().get()) { - m_requestHeaderFields = headers->requestHeaders; - m_responseHeaderFields = headers->responseHeaders; - m_changes.set(RequestChange); - } else - m_responseHeaderFields = response.httpHeaderFields(); - m_responseStatusCode = response.httpStatusCode(); - m_responseStatusText = response.httpStatusText(); - m_suggestedFilename = response.suggestedFilename(); - - m_connectionID = response.connectionID(); - m_connectionReused = response.connectionReused(); - m_loadTiming = response.resourceLoadTiming(); - m_cached = m_cached || response.wasCached(); - m_responseReceivedTime = currentTime(); - m_changes.set(TimingChange); - m_changes.set(ResponseChange); - m_changes.set(TypeChange); -} - -#if ENABLE(WEB_SOCKETS) -void InspectorResource::updateWebSocketRequest(const WebSocketHandshakeRequest& request) -{ - m_requestHeaderFields = request.headerFields(); - m_requestMethod = "GET"; // Currently we always use "GET" to request handshake. - m_webSocketRequestKey3.set(new WebSocketHandshakeRequest::Key3(request.key3())); - m_changes.set(RequestChange); - m_changes.set(TypeChange); -} - -void InspectorResource::updateWebSocketResponse(const WebSocketHandshakeResponse& response) -{ - m_responseStatusCode = response.statusCode(); - m_responseStatusText = response.statusText(); - m_responseHeaderFields = response.headerFields(); - m_webSocketChallengeResponse.set(new WebSocketHandshakeResponse::ChallengeResponse(response.challengeResponse())); - m_changes.set(ResponseChange); - m_changes.set(TypeChange); -} -#endif // ENABLE(WEB_SOCKETS) - -static PassRefPtr<InspectorObject> buildHeadersObject(const HTTPHeaderMap& headers) -{ - RefPtr<InspectorObject> object = InspectorObject::create(); - HTTPHeaderMap::const_iterator end = headers.end(); - for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it) { - object->setString(it->first.string(), it->second); - } - return object; -} - -static PassRefPtr<InspectorObject> buildObjectForTiming(ResourceLoadTiming* timing) -{ - RefPtr<InspectorObject> jsonObject = InspectorObject::create(); - jsonObject->setNumber("requestTime", timing->requestTime); - jsonObject->setNumber("proxyStart", timing->proxyStart); - jsonObject->setNumber("proxyEnd", timing->proxyEnd); - jsonObject->setNumber("dnsStart", timing->dnsStart); - jsonObject->setNumber("dnsEnd", timing->dnsEnd); - jsonObject->setNumber("connectStart", timing->connectStart); - jsonObject->setNumber("connectEnd", timing->connectEnd); - jsonObject->setNumber("sslStart", timing->sslStart); - jsonObject->setNumber("sslEnd", timing->sslEnd); - jsonObject->setNumber("sendStart", timing->sendStart); - jsonObject->setNumber("sendEnd", timing->sendEnd); - jsonObject->setNumber("receiveHeadersEnd", timing->receiveHeadersEnd); - return jsonObject; -} - - -void InspectorResource::updateScriptObject(InspectorFrontend* frontend) -{ - if (m_changes.hasChange(NoChange)) - return; - - RefPtr<InspectorObject> jsonObject = InspectorObject::create(); - jsonObject->setNumber("id", m_identifier); - if (m_changes.hasChange(RequestChange)) { - if (m_frame) - m_documentURL = m_frame->document()->url(); - jsonObject->setString("url", m_requestURL.string()); - jsonObject->setString("documentURL", m_documentURL.string()); - RefPtr<InspectorObject> requestHeaders = buildHeadersObject(m_requestHeaderFields); - jsonObject->setObject("requestHeaders", requestHeaders); - jsonObject->setBoolean("mainResource", m_isMainResource); - jsonObject->setString("requestMethod", m_requestMethod); - jsonObject->setString("requestFormData", m_requestFormData); - jsonObject->setBoolean("didRequestChange", true); -#if ENABLE(WEB_SOCKETS) - if (m_webSocketRequestKey3) - jsonObject->setString("webSocketRequestKey3", createReadableStringFromBinary(m_webSocketRequestKey3->value, sizeof(m_webSocketRequestKey3->value))); -#endif - } - - if (m_changes.hasChange(ResponseChange)) { - jsonObject->setString("mimeType", m_mimeType); - jsonObject->setString("suggestedFilename", m_suggestedFilename); - jsonObject->setNumber("expectedContentLength", m_expectedContentLength); - jsonObject->setNumber("statusCode", m_responseStatusCode); - jsonObject->setString("statusText", m_responseStatusText); - RefPtr<InspectorObject> responseHeaders = buildHeadersObject(m_responseHeaderFields); - jsonObject->setObject("responseHeaders", responseHeaders); - jsonObject->setNumber("connectionID", m_connectionID); - jsonObject->setBoolean("connectionReused", m_connectionReused); - jsonObject->setBoolean("cached", m_cached); - if (m_loadTiming && !m_cached) - jsonObject->setObject("timing", buildObjectForTiming(m_loadTiming.get())); -#if ENABLE(WEB_SOCKETS) - if (m_webSocketChallengeResponse) - jsonObject->setString("webSocketChallengeResponse", createReadableStringFromBinary(m_webSocketChallengeResponse->value, sizeof(m_webSocketChallengeResponse->value))); -#endif - jsonObject->setBoolean("didResponseChange", true); - } - - if (m_changes.hasChange(TypeChange)) { - jsonObject->setNumber("type", static_cast<int>(type())); - jsonObject->setBoolean("didTypeChange", true); - } - - if (m_changes.hasChange(LengthChange)) { - jsonObject->setNumber("resourceSize", m_length); - jsonObject->setBoolean("didLengthChange", true); - } - - if (m_changes.hasChange(CompletionChange)) { - jsonObject->setBoolean("failed", m_failed); - jsonObject->setString("localizedFailDescription", m_localizedFailDescription); - jsonObject->setBoolean("finished", m_finished); - jsonObject->setBoolean("didCompletionChange", true); - } - - if (m_changes.hasChange(TimingChange)) { - if (m_startTime > 0) - jsonObject->setNumber("startTime", m_startTime); - if (m_responseReceivedTime > 0) - jsonObject->setNumber("responseReceivedTime", m_responseReceivedTime); - if (m_endTime > 0) - jsonObject->setNumber("endTime", m_endTime); - jsonObject->setBoolean("didTimingChange", true); - } - - if (m_changes.hasChange(RedirectsChange)) { - for (size_t i = 0; i < m_redirects.size(); ++i) - m_redirects[i]->updateScriptObject(frontend); - } - - frontend->updateResource(jsonObject); - m_changes.clearAll(); -} - -void InspectorResource::releaseScriptObject(InspectorFrontend* frontend) -{ - m_changes.setAll(); - - for (size_t i = 0; i < m_redirects.size(); ++i) - m_redirects[i]->releaseScriptObject(frontend); - - if (frontend) - frontend->removeResource(m_identifier); -} - -static InspectorResource::Type cachedResourceType(CachedResource* cachedResource) -{ - if (!cachedResource) - return InspectorResource::Other; - - switch (cachedResource->type()) { - case CachedResource::ImageResource: - return InspectorResource::Image; - case CachedResource::FontResource: - return InspectorResource::Font; - case CachedResource::CSSStyleSheet: -#if ENABLE(XSLT) - case CachedResource::XSLStyleSheet: -#endif - return InspectorResource::Stylesheet; - case CachedResource::Script: - return InspectorResource::Script; - default: - return InspectorResource::Other; - } -} - -InspectorResource::Type InspectorResource::type() const -{ - if (!m_overrideContent.isNull()) - return m_overrideContentType; - -#if ENABLE(WEB_SOCKETS) - if (m_isWebSocket) - return WebSocket; -#endif - - ASSERT(m_loader); - - if (m_loader->frameLoader() && equalIgnoringFragmentIdentifier(m_requestURL, m_loader->frameLoader()->iconURL())) - return Image; - - if (!m_frame) - return Other; - - InspectorResource::Type resourceType = cachedResourceType(InspectorResourceAgent::cachedResource(m_frame.get(), m_requestURL)); - if (equalIgnoringFragmentIdentifier(m_requestURL, m_loader->requestURL()) && resourceType == Other) - return Doc; - - return resourceType; -} - -void InspectorResource::setOverrideContent(const String& data, Type type) -{ - m_overrideContent = data; - m_overrideContentType = type; - m_changes.set(TypeChange); -} - -String InspectorResource::sourceString() const -{ - if (!m_overrideContent.isNull()) - return String(m_overrideContent); - - String result; - if (!InspectorResourceAgent::resourceContent(m_frame.get(), m_requestURL, &result)) - return String(); - return result; -} - -String InspectorResource::sourceBytes() const -{ - Vector<char> out; - if (!m_overrideContent.isNull()) { - Vector<char> data; - String overrideContent = m_overrideContent; - data.append(overrideContent.characters(), overrideContent.length()); - base64Encode(data, out); - return String(out.data(), out.size()); - } - - String result; - if (!InspectorResourceAgent::resourceContentBase64(m_frame.get(), m_requestURL, &result)) - return String(); - return result; -} - -void InspectorResource::startTiming() -{ - m_startTime = currentTime(); - m_changes.set(TimingChange); -} - -void InspectorResource::endTiming(double actualEndTime) -{ - if (actualEndTime) - m_endTime = actualEndTime; - else - m_endTime = currentTime(); - - m_finished = true; - m_changes.set(TimingChange); - m_changes.set(CompletionChange); -} - -void InspectorResource::markFailed(const String& localizedDescription) -{ - m_failed = true; - m_localizedFailDescription = localizedDescription; - m_changes.set(CompletionChange); -} - -void InspectorResource::addLength(int lengthReceived) -{ - m_length += lengthReceived; - m_changes.set(LengthChange); - - // Update load time, otherwise the resource will - // have start time == end time and 0 load duration - // until its loading is completed. - m_endTime = currentTime(); - m_changes.set(TimingChange); -} - -} // namespace WebCore - -#endif // ENABLE(INSPECTOR) diff --git a/WebCore/inspector/InspectorResource.h b/WebCore/inspector/InspectorResource.h deleted file mode 100644 index aa4c3b1..0000000 --- a/WebCore/inspector/InspectorResource.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> - * Copyright (C) 2009 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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 InspectorResource_h -#define InspectorResource_h - -#include "HTTPHeaderMap.h" -#include "KURL.h" -#include "WebSocketHandshakeRequest.h" -#include "WebSocketHandshakeResponse.h" - -#include <wtf/CurrentTime.h> -#include <wtf/OwnPtr.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> -#include <wtf/RefPtr.h> - -namespace WebCore { - - class CachedResource; - class DocumentLoader; - class Frame; - class InspectorFrontend; - class ResourceLoadTiming; - class ResourceRequest; - class ResourceResponse; - -#if ENABLE(WEB_SOCKETS) - class WebSocketHandshakeRequest; - class WebSocketHandshakeResponse; -#endif - - class InspectorResource : public RefCounted<InspectorResource> { - public: - - // Keep these in sync with WebInspector.Resource.Type - enum Type { - Doc, - Stylesheet, - Image, - Font, - Script, - XHR, - Media, - WebSocket, - Other - }; - - static PassRefPtr<InspectorResource> create(unsigned long identifier, DocumentLoader* loader, const KURL& requestURL); - - static PassRefPtr<InspectorResource> createCached(unsigned long identifier, DocumentLoader*, const CachedResource*); - -#if ENABLE(WEB_SOCKETS) - // WebSocket resource doesn't have its loader. For WebSocket resources, m_loader and m_frame will become null. - static PassRefPtr<InspectorResource> createWebSocket(unsigned long identifier, const KURL& requestURL, const KURL& documentURL); -#endif - - ~InspectorResource(); - - PassRefPtr<InspectorResource> appendRedirect(unsigned long identifier, const KURL& redirectURL); - void updateScriptObject(InspectorFrontend* frontend); - void releaseScriptObject(InspectorFrontend* frontend); - - void updateRequest(const ResourceRequest&); - void markAsCached(); - void updateResponse(const ResourceResponse&); - -#if ENABLE(WEB_SOCKETS) - void updateWebSocketRequest(const WebSocketHandshakeRequest&); - void updateWebSocketResponse(const WebSocketHandshakeResponse&); -#endif - - void setOverrideContent(const String& data, Type); - String sourceString() const; - String sourceBytes() const; - - bool isSameLoader(DocumentLoader* loader) const { return loader == m_loader; } - void markMainResource() { m_isMainResource = true; } - unsigned long identifier() const { return m_identifier; } - KURL requestURL() const { return m_requestURL; } - Frame* frame() const { return m_frame.get(); } - const String& mimeType() const { return m_mimeType; } - const HTTPHeaderMap& requestHeaderFields() const { return m_requestHeaderFields; } - const HTTPHeaderMap& responseHeaderFields() const { return m_responseHeaderFields; } - int responseStatusCode() const { return m_responseStatusCode; } - String requestMethod() const { return m_requestMethod; } - String requestFormData() const { return m_requestFormData; } - - void startTiming(); - void endTiming(double actualEndTime); - - void markFailed(const String& localizedDescription); - void addLength(int lengthReceived); - - private: - enum ChangeType { - NoChange = 0, - RequestChange = 1, - ResponseChange = 2, - TypeChange = 4, - LengthChange = 8, - CompletionChange = 16, - TimingChange = 32, - RedirectsChange = 64 - }; - - class Changes { - public: - Changes() : m_change(NoChange) {} - - inline bool hasChange(ChangeType change) - { - return m_change & change || (m_change == NoChange && change == NoChange); - } - inline void set(ChangeType change) - { - m_change = static_cast<ChangeType>(static_cast<unsigned>(m_change) | static_cast<unsigned>(change)); - } - inline void clear(ChangeType change) - { - m_change = static_cast<ChangeType>(static_cast<unsigned>(m_change) & ~static_cast<unsigned>(change)); - } - - inline void setAll() { m_change = static_cast<ChangeType>(127); } - inline void clearAll() { m_change = NoChange; } - - private: - ChangeType m_change; - }; - - InspectorResource(unsigned long identifier, DocumentLoader*, const KURL& requestURL); - Type type() const; - -#if ENABLE(WEB_SOCKETS) - void markWebSocket() { m_isWebSocket = true; } -#endif - - unsigned long m_identifier; - RefPtr<DocumentLoader> m_loader; - RefPtr<Frame> m_frame; - KURL m_requestURL; - KURL m_documentURL; - HTTPHeaderMap m_requestHeaderFields; - HTTPHeaderMap m_responseHeaderFields; - String m_mimeType; - String m_suggestedFilename; - long long m_expectedContentLength; - bool m_cached; - bool m_finished; - bool m_failed; - String m_localizedFailDescription; - int m_length; - int m_responseStatusCode; - String m_responseStatusText; - double m_startTime; - double m_responseReceivedTime; - double m_endTime; - unsigned m_connectionID; - bool m_connectionReused; - RefPtr<ResourceLoadTiming> m_loadTiming; - String m_overrideContent; - Type m_overrideContentType; - Changes m_changes; - bool m_isMainResource; - String m_requestMethod; - String m_requestFormData; - Vector<RefPtr<InspectorResource> > m_redirects; - -#if ENABLE(WEB_SOCKETS) - bool m_isWebSocket; - - // The following fields are not used for resources other than WebSocket. - // We allocate them dynamically to reduce memory consumption for regular resources. - OwnPtr<WebSocketHandshakeRequest::Key3> m_webSocketRequestKey3; - OwnPtr<WebSocketHandshakeResponse::ChallengeResponse> m_webSocketChallengeResponse; -#endif - }; - -} // namespace WebCore - -#endif // InspectorResource_h diff --git a/WebCore/inspector/InspectorResourceAgent.cpp b/WebCore/inspector/InspectorResourceAgent.cpp index 2e965b6..0ed6cba 100644 --- a/WebCore/inspector/InspectorResourceAgent.cpp +++ b/WebCore/inspector/InspectorResourceAgent.cpp @@ -32,13 +32,15 @@ #include "InspectorResourceAgent.h" #include "Base64.h" -#include "Cache.h" +#include "MemoryCache.h" #include "CachedResource.h" #include "CachedResourceLoader.h" #include "Document.h" #include "DocumentLoader.h" #include "Frame.h" #include "FrameLoader.h" +#include "HTMLFrameOwnerElement.h" +#include "HTMLNames.h" #include "HTTPHeaderMap.h" #include "InspectorFrontend.h" #include "InspectorValues.h" @@ -53,6 +55,7 @@ #include "WebSocketHandshakeRequest.h" #include "WebSocketHandshakeResponse.h" +#include <wtf/CurrentTime.h> #include <wtf/ListHashSet.h> #include <wtf/RefPtr.h> #include <wtf/text/StringBuffer.h> @@ -199,10 +202,15 @@ static PassRefPtr<InspectorObject> buildObjectForResourceResponse(const Resource return responseObject; } +static unsigned long frameId(Frame* frame) +{ + return reinterpret_cast<uintptr_t>(frame); +} + static PassRefPtr<InspectorObject> buildObjectForDocumentLoader(DocumentLoader* loader) { RefPtr<InspectorObject> documentLoaderObject = InspectorObject::create(); - documentLoaderObject->setNumber("frameId", reinterpret_cast<uintptr_t>(loader->frame())); + documentLoaderObject->setNumber("frameId", frameId(loader->frame())); documentLoaderObject->setNumber("loaderId", reinterpret_cast<uintptr_t>(loader)); documentLoaderObject->setString("url", loader->requestURL().string()); return documentLoaderObject; @@ -290,6 +298,7 @@ void InspectorResourceAgent::markResourceAsCached(unsigned long identifier) void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response) { + RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(response); String type = "Other"; if (loader) { if (equalIgnoringFragmentIdentifier(response.url(), loader->frameLoader()->iconURL())) @@ -301,9 +310,13 @@ void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, Docume if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && type == "Other") type = "Document"; + + // Use mime type from cached resource in case the one in response is empty. + if (response.mimeType().isEmpty() && cachedResource) + resourceResponse->setString("mimeType", cachedResource->response().mimeType()); } } - m_frontend->didReceiveResponse(identifier, currentTime(), type, buildObjectForResourceResponse(response)); + m_frontend->didReceiveResponse(identifier, currentTime(), type, resourceResponse); } void InspectorResourceAgent::didReceiveContentLength(unsigned long identifier, int lengthReceived) @@ -329,28 +342,30 @@ void InspectorResourceAgent::didLoadResourceFromMemoryCache(DocumentLoader* load m_frontend->didLoadResourceFromMemoryCache(currentTime(), buildObjectForCachedResource(loader, *resource)); } -void InspectorResourceAgent::setOverrideContent(unsigned long identifier, const String& sourceString, InspectorResource::Type type) +void InspectorResourceAgent::setOverrideContent(unsigned long identifier, const String& sourceString, const String& type) { - String typeString; - switch (type) { - case InspectorResource::XHR: - typeString = "XHR"; - break; - case InspectorResource::Script: - typeString = "Script"; - break; - default: - typeString = "Other"; - } + m_frontend->setOverrideContent(identifier, sourceString, type); +} - m_frontend->setOverrideContent(identifier, sourceString, typeString); +static PassRefPtr<InspectorObject> buildObjectForFrame(Frame* frame) +{ + RefPtr<InspectorObject> frameObject = InspectorObject::create(); + frameObject->setNumber("id", frameId(frame)); + frameObject->setNumber("parentId", frameId(frame->tree()->parent())); + if (frame->ownerElement()) { + String name = frame->ownerElement()->getAttribute(HTMLNames::nameAttr); + if (name.isEmpty()) + name = frame->ownerElement()->getAttribute(HTMLNames::idAttr); + frameObject->setString("name", name); + } + frameObject->setString("url", frame->loader()->url().string()); + return frameObject; } static PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame* frame, bool dumpResources) { - RefPtr<InspectorObject> frameObject = InspectorObject::create(); - frameObject->setNumber("parentId", reinterpret_cast<uintptr_t>(frame->tree()->parent())); - frameObject->setNumber("id", reinterpret_cast<uintptr_t>(frame)); + RefPtr<InspectorObject> frameObject = buildObjectForFrame(frame); + if (dumpResources) populateObjectWithFrameResources(frame, frameObject); RefPtr<InspectorArray> childrenArray; @@ -366,13 +381,12 @@ static PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame* frame, bool du void InspectorResourceAgent::didCommitLoad(DocumentLoader* loader) { - Frame* parentFrame = loader->frame()->tree()->parent(); - m_frontend->didCommitLoadForFrame(reinterpret_cast<uintptr_t>(parentFrame), buildObjectForDocumentLoader(loader)); + m_frontend->didCommitLoadForFrame(buildObjectForFrame(loader->frame()), buildObjectForDocumentLoader(loader)); } void InspectorResourceAgent::frameDetachedFromParent(Frame* frame) { - m_frontend->frameDetachedFromParent(reinterpret_cast<uintptr_t>(frame)); + m_frontend->frameDetachedFromParent(frameId(frame)); } #if ENABLE(WEB_SOCKETS) @@ -425,15 +439,25 @@ void InspectorResourceAgent::didCloseWebSocket(unsigned long identifier) } #endif // ENABLE(WEB_SOCKETS) +Frame* InspectorResourceAgent::frameForId(unsigned long frameId) +{ + Frame* mainFrame = m_page->mainFrame(); + for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext(mainFrame)) { + if (reinterpret_cast<uintptr_t>(frame) == frameId) + return frame; + } + return 0; +} + void InspectorResourceAgent::cachedResources(RefPtr<InspectorObject>* object) { *object = buildObjectForFrameTree(m_page->mainFrame(), true); } -void InspectorResourceAgent::resourceContent(unsigned long frameId, const String& url, bool base64Encode, String* content) +void InspectorResourceAgent::resourceContent(unsigned long id, const String& url, bool base64Encode, String* content) { for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame())) { - if (reinterpret_cast<uintptr_t>(frame) != frameId) + if (frameId(frame) != id) continue; if (base64Encode) InspectorResourceAgent::resourceContentBase64(frame, KURL(ParsedURLString, url), content); diff --git a/WebCore/inspector/InspectorResourceAgent.h b/WebCore/inspector/InspectorResourceAgent.h index 1cdd292..e3153bf 100644 --- a/WebCore/inspector/InspectorResourceAgent.h +++ b/WebCore/inspector/InspectorResourceAgent.h @@ -31,7 +31,6 @@ #ifndef InspectorResourceAgent_h #define InspectorResourceAgent_h -#include "InspectorResource.h" #include "PlatformString.h" #include <wtf/PassRefPtr.h> @@ -48,6 +47,7 @@ namespace WebCore { class CachedResource; class Document; class DocumentLoader; +class Frame; class InspectorArray; class InspectorObject; class InspectorFrontend; @@ -85,7 +85,7 @@ public: void didFinishLoading(unsigned long identifier, double finishTime); void didFailLoading(unsigned long identifier, const ResourceError&); void didLoadResourceFromMemoryCache(DocumentLoader*, const CachedResource*); - void setOverrideContent(unsigned long identifier, const String& sourceString, InspectorResource::Type); + void setOverrideContent(unsigned long identifier, const String& sourceString, const String& type); void didCommitLoad(DocumentLoader*); void frameDetachedFromParent(Frame*); @@ -96,6 +96,8 @@ public: void didCloseWebSocket(unsigned long identifier); #endif + Frame* frameForId(unsigned long); + // Called from frontend void cachedResources(RefPtr<InspectorObject>*); void resourceContent(unsigned long frameID, const String& url, bool base64Encode, String* content); diff --git a/WebCore/inspector/InspectorState.cpp b/WebCore/inspector/InspectorState.cpp index e6d3044..df939ba 100644 --- a/WebCore/inspector/InspectorState.cpp +++ b/WebCore/inspector/InspectorState.cpp @@ -39,9 +39,7 @@ namespace WebCore { InspectorState::InspectorState(InspectorClient* client) : m_client(client) { - registerBoolean(monitoringXHR, false, "monitoringXHR", "xhrMonitor"); - registerBoolean(resourceTrackingEnabled, false, "resourceTrackingEnabled", (const char*)0); - registerBoolean(resourceTrackingAlwaysEnabled, false, (const char*)0, "resourceTrackingEnabled"); + registerBoolean(monitoringXHR, false, "monitoringXHREnabled", "xhrMonitor"); registerBoolean(timelineProfilerEnabled, false, "timelineProfilerEnabled", (const char*)0); registerBoolean(searchingForNode, false, "searchingForNodeEnabled", (const char*)0); registerBoolean(profilerAlwaysEnabled, false, (const char*)0, "profilerEnabled"); @@ -50,6 +48,7 @@ InspectorState::InspectorState(InspectorClient* client) registerLong(inspectorAttachedHeight, InspectorController::defaultAttachedHeight, (const char*)0, "inspectorAttachedHeight"); registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState", (const char*)0); registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled", (const char*)0); + registerBoolean(userInitiatedProfiling, false, "userInitiatedProfiling", (const char*)0); } void InspectorState::restoreFromInspectorCookie(const String& json) diff --git a/WebCore/inspector/InspectorState.h b/WebCore/inspector/InspectorState.h index 387f3c7..aa2f1ec 100644 --- a/WebCore/inspector/InspectorState.h +++ b/WebCore/inspector/InspectorState.h @@ -45,8 +45,6 @@ class InspectorState { public: enum InspectorPropertyId { monitoringXHR = 1, - resourceTrackingEnabled, - resourceTrackingAlwaysEnabled, timelineProfilerEnabled, searchingForNode, profilerAlwaysEnabled, @@ -56,6 +54,7 @@ public: inspectorAttachedHeight, pauseOnExceptionsState, consoleMessagesEnabled, + userInitiatedProfiling, lastPropertyId }; diff --git a/WebCore/inspector/ScriptArguments.cpp b/WebCore/inspector/ScriptArguments.cpp new file mode 100644 index 0000000..e30e135 --- /dev/null +++ b/WebCore/inspector/ScriptArguments.cpp @@ -0,0 +1,94 @@ +/* + * 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. + */ + +#include "config.h" +#include "ScriptArguments.h" + +#include "ScriptValue.h" + +namespace WebCore { + +ScriptArguments::ScriptArguments(ScriptState* scriptState, Vector<ScriptValue>& arguments) + : m_scriptState(scriptState) +{ + m_arguments.swap(arguments); +} + +ScriptArguments::~ScriptArguments() +{ +} + +const ScriptValue &ScriptArguments::argumentAt(size_t index) const +{ + ASSERT(m_arguments.size() > index); + return m_arguments[index]; +} + +ScriptState* ScriptArguments::globalState() const +{ + return m_scriptState.get(); +} + +bool ScriptArguments::getFirstArgumentAsString(String& result, bool checkForNullOrUndefined) +{ + if (!argumentCount()) + return false; + + const ScriptValue& value = argumentAt(0); + if (checkForNullOrUndefined && (value.isNull() || value.isUndefined())) + return false; + + if (!globalState()) { + ASSERT_NOT_REACHED(); + return false; + } + + result = value.toString(globalState()); + return true; +} + +bool ScriptArguments::isEqual(ScriptArguments* other) const +{ + if (!other) + return false; + + if (m_arguments.size() != other->m_arguments.size()) + return false; + if (!globalState() && m_arguments.size()) + return false; + + for (size_t i = 0; i < m_arguments.size(); ++i) { + if (!m_arguments[i].isEqual(other->globalState(), other->m_arguments[i])) + return false; + } + return true; +} + +} // namespace WebCore diff --git a/WebCore/inspector/ScriptArguments.h b/WebCore/inspector/ScriptArguments.h new file mode 100644 index 0000000..fdf05ab --- /dev/null +++ b/WebCore/inspector/ScriptArguments.h @@ -0,0 +1,62 @@ +/* + * 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. + */ + +#ifndef ScriptArguments_h +#define ScriptArguments_h + +#include "PlatformString.h" +#include "ScriptState.h" +#include <wtf/Vector.h> + +namespace WebCore { + +class ScriptValue; + +class ScriptArguments { +public: + ScriptArguments(ScriptState*, Vector<ScriptValue>& arguments); + ~ScriptArguments(); + + const ScriptValue& argumentAt(size_t) const; + size_t argumentCount() const { return m_arguments.size(); } + + ScriptState* globalState() const; + + bool getFirstArgumentAsString(WTF::String& result, bool checkForNullOrUndefined = false); + bool isEqual(ScriptArguments*) const; + +private: + ScriptStateProtectedPtr m_scriptState; + Vector<ScriptValue> m_arguments; +}; + +} // namespace WebCore + +#endif // ScriptArguments_h diff --git a/WebCore/inspector/ScriptCallFrame.cpp b/WebCore/inspector/ScriptCallFrame.cpp new file mode 100644 index 0000000..5455d25 --- /dev/null +++ b/WebCore/inspector/ScriptCallFrame.cpp @@ -0,0 +1,66 @@ +/* + * 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. + */ + +#include "config.h" +#include "ScriptCallFrame.h" + +#include "InspectorValues.h" +#include <wtf/RefPtr.h> + +namespace WebCore { + +ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber) + : m_functionName(functionName) + , m_sourceURL(urlString) + , m_lineNumber(lineNumber) +{ +} + +ScriptCallFrame::~ScriptCallFrame() +{ +} + +bool ScriptCallFrame::isEqual(const ScriptCallFrame& o) const +{ + return m_functionName == o.m_functionName + && m_sourceURL == o.m_sourceURL + && m_lineNumber == o.m_lineNumber; +} + +PassRefPtr<InspectorObject> ScriptCallFrame::buildInspectorObject() const +{ + RefPtr<InspectorObject> frame = InspectorObject::create(); + frame->setString("functionName", m_functionName); + frame->setString("sourceURL", m_sourceURL); + frame->setNumber("lineNumber", m_lineNumber); + return frame; +} + +} // namespace WebCore diff --git a/WebCore/inspector/ScriptCallFrame.h b/WebCore/inspector/ScriptCallFrame.h new file mode 100644 index 0000000..60d77e1 --- /dev/null +++ b/WebCore/inspector/ScriptCallFrame.h @@ -0,0 +1,61 @@ +/* + * 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. + */ + +#ifndef ScriptCallFrame_h +#define ScriptCallFrame_h + +#include "PlatformString.h" +#include <wtf/PassRefPtr.h> + +namespace WebCore { + +class InspectorObject; + +class ScriptCallFrame { +public: + ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber); + ~ScriptCallFrame(); + + const String& functionName() const { return m_functionName; } + const String& sourceURL() const { return m_sourceURL; } + unsigned lineNumber() const { return m_lineNumber; } + + bool isEqual(const ScriptCallFrame&) const; + PassRefPtr<InspectorObject> buildInspectorObject() const; + +private: + String m_functionName; + String m_sourceURL; + unsigned m_lineNumber; +}; + +} // namespace WebCore + +#endif // ScriptCallFrame_h diff --git a/WebCore/inspector/ScriptCallStack.cpp b/WebCore/inspector/ScriptCallStack.cpp new file mode 100644 index 0000000..8d010bb --- /dev/null +++ b/WebCore/inspector/ScriptCallStack.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2008, 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 "ScriptCallStack.h" + +#include "InspectorValues.h" + +namespace WebCore { + +ScriptCallStack::ScriptCallStack(Vector<ScriptCallFrame>& frames) +{ + m_frames.swap(frames); +} + +ScriptCallStack::~ScriptCallStack() +{ +} + +const ScriptCallFrame &ScriptCallStack::at(size_t index) +{ + ASSERT(m_frames.size() > index); + return m_frames[index]; +} + +size_t ScriptCallStack::size() +{ + return m_frames.size(); +} + +bool ScriptCallStack::isEqual(ScriptCallStack* o) const +{ + if (!o) + return false; + + size_t frameCount = o->m_frames.size(); + if (frameCount != m_frames.size()) + return false; + + for (size_t i = 0; i < frameCount; ++i) { + if (!m_frames[i].isEqual(o->m_frames[i])) + return false; + } + + return true; +} + +PassRefPtr<InspectorArray> ScriptCallStack::buildInspectorObject() const +{ + RefPtr<InspectorArray> frames = InspectorArray::create(); + for (size_t i = 0; i < m_frames.size(); i++) + frames->pushObject(m_frames.at(i).buildInspectorObject()); + return frames; +} + +} // namespace WebCore diff --git a/WebCore/inspector/ScriptCallStack.h b/WebCore/inspector/ScriptCallStack.h new file mode 100644 index 0000000..54c6bba --- /dev/null +++ b/WebCore/inspector/ScriptCallStack.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2008, 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. + */ + +#ifndef ScriptCallStack_h +#define ScriptCallStack_h + +#include "ScriptCallFrame.h" +#include <wtf/Noncopyable.h> +#include <wtf/Vector.h> + +namespace WebCore { + +class InspectorArray; + +class ScriptCallStack : public Noncopyable { +public: + static const size_t maxCallStackSizeToCapture = 200; + + ScriptCallStack(Vector<ScriptCallFrame>&); + ~ScriptCallStack(); + + const ScriptCallFrame &at(size_t); + size_t size(); + static bool stackTrace(int, const RefPtr<InspectorArray>&); + + bool isEqual(ScriptCallStack*) const; + PassRefPtr<InspectorArray> buildInspectorObject() const; + +private: + Vector<ScriptCallFrame> m_frames; +}; + +} // namespace WebCore + +#endif // ScriptCallStack_h diff --git a/WebCore/inspector/front-end/AuditsPanel.js b/WebCore/inspector/front-end/AuditsPanel.js index b4eb202..096f8ce 100644 --- a/WebCore/inspector/front-end/AuditsPanel.js +++ b/WebCore/inspector/front-end/AuditsPanel.js @@ -203,20 +203,15 @@ WebInspector.AuditsPanel.prototype = { _reloadResources: function(callback) { - this._resourceTrackingCallback = callback; - - if (WebInspector.panels.resources && !WebInspector.panels.resources.resourceTrackingEnabled) { - WebInspector.panels.resources.toggleResourceTracking(false); - this._updateLauncherViewControls(true); - } else - InspectorBackend.reloadPage(); + this._pageReloadCallback = callback; + InspectorBackend.reloadPage(); }, _didMainResourceLoad: function() { - if (this._resourceTrackingCallback) { - var callback = this._resourceTrackingCallback; - delete this._resourceTrackingCallback; + if (this._pageReloadCallback) { + var callback = this._pageReloadCallback; + delete this._pageReloadCallback; callback(); } }, diff --git a/WebCore/inspector/front-end/BreakpointManager.js b/WebCore/inspector/front-end/BreakpointManager.js index 77ba89d..221a777 100644 --- a/WebCore/inspector/front-end/BreakpointManager.js +++ b/WebCore/inspector/front-end/BreakpointManager.js @@ -28,7 +28,6 @@ WebInspector.BreakpointManager = function() { this._breakpoints = {}; this._nativeBreakpoints = {}; - this._domBreakpoints = {}; } WebInspector.BreakpointManager.prototype = { @@ -137,13 +136,12 @@ WebInspector.BreakpointManager.prototype = { var breakpoint = new WebInspector.DOMBreakpoint(this, frontendId, nodeId, domEventType); this._nativeBreakpoints[frontendId] = breakpoint; - this._domBreakpoints[frontendId] = breakpoint; this.dispatchEventToListeners("dom-breakpoint-added", breakpoint); breakpoint.enabled = !disabled; return breakpoint; }, - createEventListenerBreakpoint: function(eventName, disabled) + createEventListenerBreakpoint: function(eventName) { var frontendId = eventName; if (frontendId in this._nativeBreakpoints) @@ -151,7 +149,8 @@ WebInspector.BreakpointManager.prototype = { var breakpoint = new WebInspector.EventListenerBreakpoint(this, frontendId, eventName); this._nativeBreakpoints[frontendId] = breakpoint; - breakpoint.enabled = !disabled; + this.dispatchEventToListeners("event-listener-breakpoint-added", { breakpoint: breakpoint, eventName: eventName }); + breakpoint.enabled = true; return breakpoint; }, @@ -175,8 +174,7 @@ WebInspector.BreakpointManager.prototype = { if (breakpoint.enabled) this._removeNativeBreakpointFromBackend(breakpoint); delete this._nativeBreakpoints[breakpoint._frontendId]; - if (breakpoint._type === "DOM") - delete this._domBreakpoints[breakpoint._frontendId]; + this._updateNativeBreakpointsInSettings(); breakpoint.dispatchEventToListeners("removed"); }, @@ -195,7 +193,7 @@ WebInspector.BreakpointManager.prototype = { _setNativeBreakpointOnBackend: function(breakpoint) { breakpoint._beingSetOnBackend = true; - var data = { type: breakpoint._type, condition: breakpoint._condition() }; + var data = { type: breakpoint._type, condition: breakpoint._condition }; InspectorBackend.setNativeBreakpoint(data, didSetNativeBreakpoint.bind(this)); function didSetNativeBreakpoint(backendBreakpointId) @@ -206,6 +204,7 @@ WebInspector.BreakpointManager.prototype = { this._breakpoints[backendBreakpointId] = breakpoint; } breakpoint.dispatchEventToListeners("enable-changed"); + this._updateNativeBreakpointsInSettings(); } }, @@ -215,6 +214,18 @@ WebInspector.BreakpointManager.prototype = { delete this._breakpoints[breakpoint._backendId] delete breakpoint._backendId; breakpoint.dispatchEventToListeners("enable-changed"); + this._updateNativeBreakpointsInSettings(); + }, + + _updateNativeBreakpointsInSettings: function() + { + var persistentBreakpoints = []; + for (var id in this._nativeBreakpoints) { + var breakpoint = this._nativeBreakpoints[id]; + if (breakpoint._persistentCondition) + persistentBreakpoints.push({ type: breakpoint._type, enabled: breakpoint.enabled, condition: breakpoint._persistentCondition }); + } + WebInspector.settings.nativeBreakpoints = persistentBreakpoints; }, debuggerPaused: function(details) @@ -242,31 +253,60 @@ WebInspector.BreakpointManager.prototype = { delete this._lastHitBreakpoint; }, + restoreBreakpoints: function() + { + var breakpoints = this._persistentBreakpoints(); + for (var i = 0; i < breakpoints.length; ++i) { + if (breakpoints[i].type === "EventListener") + this.createEventListenerBreakpoint(breakpoints[i].condition.eventName); + else if (breakpoints[i].type === "XHR") + this.createXHRBreakpoint(breakpoints[i].condition.url, !breakpoints[i].enabled); + } + }, + restoreDOMBreakpoints: function() { - var domBreakpoints = this._domBreakpoints; - this._domBreakpoints = {}; + function didPushNodeByPathToFrontend(path, nodeId) + { + pathToNodeId[path] = nodeId; + pendingCalls -= 1; + if (pendingCalls) + return; + for (var i = 0; i < breakpoints.length; ++i) { + var breakpoint = breakpoints[i]; + var nodeId = pathToNodeId[breakpoint.condition.path]; + if (nodeId) + this.createDOMBreakpoint(nodeId, breakpoint.condition.type, !breakpoint.enabled); + } + } - var breakpointsToRestore = {}; - for (var frontendId in domBreakpoints) { - var breakpoint = domBreakpoints[frontendId]; - var path = breakpoint._path; - if (!path) + var breakpoints = this._persistentBreakpoints(); + var pathToNodeId = {}; + var pendingCalls = 0; + for (var i = 0; i < breakpoints.length; ++i) { + if (breakpoints[i].type !== "DOM") continue; - if (!breakpointsToRestore[path]) { - breakpointsToRestore[path] = []; - InspectorBackend.pushNodeByPathToFrontend(path, restoreBreakpointsForNode.bind(this, breakpointsToRestore[path])); - } - breakpointsToRestore[path].push(breakpoint); + var path = breakpoints[i].condition.path; + if (path in pathToNodeId) + continue; + pathToNodeId[path] = 0; + pendingCalls += 1; + InspectorBackend.pushNodeByPathToFrontend(path, didPushNodeByPathToFrontend.bind(this, path)); } + }, - function restoreBreakpointsForNode(breakpoints, nodeId) - { - if (!nodeId) - return; - for (var i = 0; i < breakpoints.length; ++i) - this.createDOMBreakpoint(nodeId, breakpoints[i]._domEventType, !breakpoints[i].enabled); + _persistentBreakpoints: function() + { + var result = []; + var breakpoints = WebInspector.settings.nativeBreakpoints; + if (breakpoints instanceof Array) { + for (var i = 0; i < breakpoints.length; ++i) { + var breakpoint = breakpoints[i]; + if ("type" in breakpoint && "condition" in breakpoint) + result.push(breakpoint) + } } + return result; } } @@ -307,7 +347,7 @@ WebInspector.Breakpoint.prototype = { set sourceText(text) { this._sourceText = text; - this.dispatchEventToListeners("text-changed"); + this.dispatchEventToListeners("label-changed"); }, get id() @@ -332,6 +372,11 @@ WebInspector.Breakpoint.prototype = { this.dispatchEventToListeners("condition-changed"); }, + click: function(event) + { + WebInspector.panels.scripts.showSourceLine(this.url, this.line); + }, + compareTo: function(other) { if (this.url != other.url) @@ -341,6 +386,18 @@ WebInspector.Breakpoint.prototype = { return 0; }, + populateLabelElement: function(element) + { + 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); + }, + remove: function() { InspectorBackend.removeBreakpoint(this.sourceID, this.line); @@ -405,20 +462,16 @@ WebInspector.DOMBreakpoint = function(manager, frontendId, nodeId, domEventType) WebInspector.NativeBreakpoint.call(this, manager, frontendId, "DOM"); this._nodeId = nodeId; this._domEventType = domEventType; + this._condition = { nodeId: this._nodeId, type: this._domEventType }; var node = WebInspector.domAgent.nodeForId(this._nodeId); if (node) { node.breakpoints[this._domEventType] = this; - this._path = node.path(); + this._persistentCondition = { path: node.path(), type: this._domEventType }; } } WebInspector.DOMBreakpoint.prototype = { - click: function() - { - WebInspector.updateFocusedNode(this._nodeId); - }, - compareTo: function(other) { return this._compare(this._domEventType, other._domEventType); @@ -426,9 +479,14 @@ WebInspector.DOMBreakpoint.prototype = { populateLabelElement: function(element) { - element.appendChild(WebInspector.panels.elements.linkifyNodeById(this._nodeId)); - element.appendChild(document.createTextNode(" - ")); - element.appendChild(document.createTextNode(WebInspector.domBreakpointTypeLabel(this._domEventType))); + // FIXME: this should belong to the view, not the manager. + var linkifiedNode = WebInspector.panels.elements.linkifyNodeById(this._nodeId); + linkifiedNode.addStyleClass("monospace"); + element.appendChild(linkifiedNode); + var description = document.createElement("div"); + description.className = "source-text"; + description.textContent = WebInspector.domBreakpointTypeLabel(this._domEventType); + element.appendChild(description); }, populateStatusMessageElement: function(element, eventData) @@ -459,11 +517,6 @@ WebInspector.DOMBreakpoint.prototype = { WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s.", substitutions, formatters, "", append); }, - _condition: function() - { - return { nodeId: this._nodeId, type: this._domEventType }; - }, - _onRemove: function() { var node = WebInspector.domAgent.nodeForId(this._nodeId); @@ -478,6 +531,20 @@ WebInspector.EventListenerBreakpoint = function(manager, frontendId, eventName) { WebInspector.NativeBreakpoint.call(this, manager, frontendId, "EventListener"); this._eventName = eventName; + this._condition = { eventName: this._eventName }; + this._persistentCondition = this._condition; +} + +WebInspector.EventListenerBreakpoint.eventNameForUI = function(eventName) +{ + if (!WebInspector.EventListenerBreakpoint._eventNamesForUI) { + WebInspector.EventListenerBreakpoint._eventNamesForUI = { + "instrumentation:setTimer": WebInspector.UIString("Set Timer"), + "instrumentation:clearTimer": WebInspector.UIString("Clear Timer"), + "instrumentation:timerFired": WebInspector.UIString("Timer Fired") + }; + } + return WebInspector.EventListenerBreakpoint._eventNamesForUI[eventName] || eventName.substring(eventName.indexOf(":") + 1); } WebInspector.EventListenerBreakpoint.prototype = { @@ -497,21 +564,9 @@ WebInspector.EventListenerBreakpoint.prototype = { element.appendChild(document.createTextNode(status)); }, - _condition: function() - { - return { eventName: this._eventName }; - }, - _uiEventName: function() { - if (!WebInspector.EventListenerBreakpoint._uiEventNames) { - WebInspector.EventListenerBreakpoint._uiEventNames = { - "instrumentation:setTimer": WebInspector.UIString("Set Timer"), - "instrumentation:clearTimer": WebInspector.UIString("Clear Timer"), - "instrumentation:timerFired": WebInspector.UIString("Timer Fired") - }; - } - return WebInspector.EventListenerBreakpoint._uiEventNames[this._eventName] || this._eventName.substring(this._eventName.indexOf(":") + 1); + return WebInspector.EventListenerBreakpoint.eventNameForUI(this._eventName); } } @@ -521,6 +576,8 @@ WebInspector.XHRBreakpoint = function(manager, frontendId, url) { WebInspector.NativeBreakpoint.call(this, manager, frontendId, "XHR"); this._url = url; + this._condition = { url: this._url }; + this._persistentCondition = this._condition; } WebInspector.XHRBreakpoint.prototype = { @@ -529,6 +586,11 @@ WebInspector.XHRBreakpoint.prototype = { return this._compare(this._url, other._url); }, + populateEditElement: function(element) + { + element.textContent = this._url; + }, + populateLabelElement: function(element) { var label; @@ -537,17 +599,13 @@ WebInspector.XHRBreakpoint.prototype = { else label = WebInspector.UIString("URL contains \"%s\"", this._url); element.appendChild(document.createTextNode(label)); + element.addStyleClass("cursor-auto"); }, populateStatusMessageElement: function(element) { var status = WebInspector.UIString("Paused on a XMLHttpRequest."); element.appendChild(document.createTextNode(status)); - }, - - _condition: function() - { - return { url: this._url }; } } diff --git a/WebCore/inspector/front-end/BreakpointsSidebarPane.js b/WebCore/inspector/front-end/BreakpointsSidebarPane.js index 2151137..f010330 100644 --- a/WebCore/inspector/front-end/BreakpointsSidebarPane.js +++ b/WebCore/inspector/front-end/BreakpointsSidebarPane.js @@ -47,46 +47,56 @@ WebInspector.BreakpointsSidebarPane.prototype = { } }, - addBreakpoint: function(breakpointItem) + addBreakpointItem: function(breakpointItem) { - breakpointItem.addEventListener("removed", this._breakpointRemoved, this); - - var element = breakpointItem.element(); + var element = breakpointItem.element; element._breakpointItem = breakpointItem; + breakpointItem.addEventListener("breakpoint-hit", this.expand, this); + breakpointItem.addEventListener("removed", this._removeListElement.bind(this, element), this); + var currentElement = this.listElement.firstChild; while (currentElement) { - if (currentElement._breakpointItem.compareTo(element._breakpointItem) > 0) { - this.listElement.insertBefore(element, currentElement); + if (currentElement._breakpointItem && currentElement._breakpointItem.compareTo(element._breakpointItem) > 0) break; - } currentElement = currentElement.nextSibling; } - if (!currentElement) - this.listElement.appendChild(element); + this._addListElement(element, currentElement); + if (breakpointItem.click) { + element.addStyleClass("cursor-pointer"); + element.addEventListener("click", breakpointItem.click.bind(breakpointItem), false); + } element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this, breakpointItem), true); + }, + + _contextMenuEventFired: function(breakpointItem, event) + { + var contextMenu = new WebInspector.ContextMenu(); + contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), breakpointItem.remove.bind(breakpointItem)); + contextMenu.show(event); + }, - if (this.emptyElement.parentElement) { - this.bodyElement.removeChild(this.emptyElement); - this.bodyElement.appendChild(this.listElement); + _addListElement: function(element, beforeElement) + { + if (beforeElement) + this.listElement.insertBefore(element, beforeElement); + else { + if (!this.listElement.firstChild) { + this.bodyElement.removeChild(this.emptyElement); + this.bodyElement.appendChild(this.listElement); + } + this.listElement.appendChild(element); } }, - _breakpointRemoved: function(event) + _removeListElement: function(element) { - this.listElement.removeChild(event.target.element()); + this.listElement.removeChild(element); if (!this.listElement.firstChild) { this.bodyElement.removeChild(this.listElement); this.bodyElement.appendChild(this.emptyElement); } - }, - - _contextMenuEventFired: function(breakpointItem, event) - { - var contextMenu = new WebInspector.ContextMenu(); - contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), breakpointItem.remove.bind(breakpointItem)); - contextMenu.show(event); } } @@ -96,36 +106,58 @@ WebInspector.XHRBreakpointsSidebarPane = function() { WebInspector.BreakpointsSidebarPane.call(this, WebInspector.UIString("XHR Breakpoints")); + function addButtonClicked(event) + { + event.stopPropagation(); + this._startEditingBreakpoint(null); + } + var addButton = document.createElement("button"); addButton.className = "add"; - addButton.addEventListener("click", this._showEditBreakpointDialog.bind(this), false); + addButton.addEventListener("click", addButtonClicked.bind(this), false); this.titleElement.appendChild(addButton); - - this.urlInputElement = document.createElement("span"); - this.urlInputElement.className = "breakpoint-condition editing"; } WebInspector.XHRBreakpointsSidebarPane.prototype = { - _showEditBreakpointDialog: function(event) + addBreakpointItem: function(breakpointItem) { - event.stopPropagation(); + WebInspector.BreakpointsSidebarPane.prototype.addBreakpointItem.call(this, breakpointItem); + breakpointItem._labelElement.addEventListener("dblclick", this._startEditingBreakpoint.bind(this, breakpointItem), false); + }, - if (this.urlInputElement.parentElement) + _startEditingBreakpoint: function(breakpointItem) + { + if (this._editingBreakpoint) return; + this._editingBreakpoint = true; if (!this.expanded) this.expanded = true; - this.urlInputElement.textContent = ""; - this.bodyElement.insertBefore(this.urlInputElement, this.bodyElement.firstChild); - WebInspector.startEditing(this.urlInputElement, this._hideEditBreakpointDialog.bind(this, false), this._hideEditBreakpointDialog.bind(this, true)); + var inputElement = document.createElement("span"); + inputElement.className = "breakpoint-condition editing"; + if (breakpointItem) { + breakpointItem.populateEditElement(inputElement); + this.listElement.insertBefore(inputElement, breakpointItem.element); + breakpointItem.element.addStyleClass("hidden"); + } else + this._addListElement(inputElement, this.listElement.firstChild); + + var commitHandler = this._hideEditBreakpointDialog.bind(this, inputElement, true, breakpointItem); + var cancelHandler = this._hideEditBreakpointDialog.bind(this, inputElement, false, breakpointItem); + WebInspector.startEditing(inputElement, commitHandler, cancelHandler); }, - _hideEditBreakpointDialog: function(discard) + _hideEditBreakpointDialog: function(inputElement, accept, breakpointItem) { - if (!discard) - WebInspector.breakpointManager.createXHRBreakpoint(this.urlInputElement.textContent.toLowerCase()); - this.bodyElement.removeChild(this.urlInputElement); + this._removeListElement(inputElement); + this._editingBreakpoint = false; + if (accept) { + if (breakpointItem) + breakpointItem.remove(); + WebInspector.breakpointManager.createXHRBreakpoint(inputElement.textContent.toLowerCase()); + } else if (breakpointItem) + breakpointItem.element.removeStyleClass("hidden"); } } @@ -136,7 +168,6 @@ WebInspector.BreakpointItem = function(breakpoint) this._breakpoint = breakpoint; this._element = document.createElement("li"); - this._element.addEventListener("click", this._breakpointClicked.bind(this), false); var checkboxElement = document.createElement("input"); checkboxElement.className = "checkbox-elem"; @@ -145,16 +176,18 @@ WebInspector.BreakpointItem = function(breakpoint) checkboxElement.addEventListener("click", this._checkboxClicked.bind(this), false); this._element.appendChild(checkboxElement); - if ("populateLabelElement" in this._breakpoint) - this._breakpoint.populateLabelElement(this._element); + this._createLabelElement(); this._breakpoint.addEventListener("enable-changed", this._enableChanged, this); this._breakpoint.addEventListener("hit-state-changed", this._hitStateChanged, this); + this._breakpoint.addEventListener("label-changed", this._labelChanged, this); this._breakpoint.addEventListener("removed", this.dispatchEventToListeners.bind(this, "removed")); + if (breakpoint.click) + this.click = breakpoint.click.bind(breakpoint); } WebInspector.BreakpointItem.prototype = { - element: function() + get element() { return this._element; }, @@ -164,15 +197,14 @@ WebInspector.BreakpointItem.prototype = { return this._breakpoint.compareTo(other._breakpoint); }, - remove: function() + populateEditElement: function(element) { - this._breakpoint.remove(); + this._breakpoint.populateEditElement(element); }, - _breakpointClicked: function(event) + remove: function() { - if ("click" in this._breakpoint) - this._breakpoint.click(); + this._breakpoint.remove(); }, _checkboxClicked: function(event) @@ -191,45 +223,28 @@ WebInspector.BreakpointItem.prototype = { _hitStateChanged: function(event) { - if (event.target.hit) + if (event.target.hit) { this._element.addStyleClass("breakpoint-hit"); - else + this.dispatchEventToListeners("breakpoint-hit"); + } else this._element.removeStyleClass("breakpoint-hit"); - } -} - -WebInspector.BreakpointItem.prototype.__proto__ = WebInspector.Object.prototype; - -WebInspector.JSBreakpointItem = function(breakpoint) -{ - WebInspector.BreakpointItem.call(this, breakpoint); - - var displayName = this._breakpoint.url ? WebInspector.displayNameForURL(this._breakpoint.url) : WebInspector.UIString("(program)"); - var labelElement = document.createTextNode(displayName + ":" + this._breakpoint.line); - this._element.appendChild(labelElement); - - var sourceTextElement = document.createElement("div"); - sourceTextElement.textContent = this._breakpoint.sourceText; - sourceTextElement.className = "source-text monospace"; - this._element.appendChild(sourceTextElement); - - this._breakpoint.addEventListener("text-changed", this._textChanged, this); -} + }, -WebInspector.JSBreakpointItem.prototype = { - _breakpointClicked: function() + _labelChanged: function(event) { - WebInspector.panels.scripts.showSourceLine(this._breakpoint.url, this._breakpoint.line); + this._element.removeChild(this._labelElement); + this._createLabelElement(); }, - _textChanged: function() + _createLabelElement: function() { - var sourceTextElement = this._element.firstChild.nextSibling.nextSibling; - sourceTextElement.textContent = this._breakpoint.sourceText; + this._labelElement = document.createElement("span"); + this._breakpoint.populateLabelElement(this._labelElement); + this._element.appendChild(this._labelElement); } } -WebInspector.JSBreakpointItem.prototype.__proto__ = WebInspector.BreakpointItem.prototype; +WebInspector.BreakpointItem.prototype.__proto__ = WebInspector.Object.prototype; WebInspector.EventListenerBreakpointsSidebarPane = function() { @@ -240,97 +255,116 @@ WebInspector.EventListenerBreakpointsSidebarPane = function() this.categoriesElement.addStyleClass("properties-tree event-listener-breakpoints"); this.categoriesTreeOutline = new TreeOutline(this.categoriesElement); this.bodyElement.appendChild(this.categoriesElement); + + WebInspector.breakpointManager.addEventListener("event-listener-breakpoint-added", this._breakpointAdded, this); + + this._breakpointItems = {}; + this._createCategory("Mouse", "listener", ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"]); + this._createCategory("Keyboard", "listener", ["keydown", "keypress", "keyup"]); + this._createCategory("HTML frame/object", "listener", ["load", "error", "resize", "scroll"]); + this._createCategory("Timer", "instrumentation", ["setTimer", "clearTimer", "timerFired"]); } WebInspector.EventListenerBreakpointsSidebarPane.prototype = { - _populate: function() + _createCategory: function(name, type, eventNames) { - var categories = { - "Mouse": { type: "listener", eventNames: ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"] }, - "Keyboard": { type: "listener", eventNames: ["keydown", "keypress", "keyup"] }, - "HTML frame/object": { type: "listener", eventNames: ["load", "error", "resize", "scroll"] }, - "Timer": { type: "instrumentation", eventNames: ["setTimer", "clearTimer", "timerFired"] } - }; - - for (var category in categories) { - var categoryTreeElement = new TreeElement(WebInspector.UIString(category)); - this.categoriesTreeOutline.appendChild(categoryTreeElement); - categoryTreeElement.listItemElement.addStyleClass("event-category"); - categoryTreeElement.selectable = true; - - var categoryItem = {}; - categoryItem.checkbox = this._createCheckbox(categoryTreeElement, this._categoryCheckboxClicked.bind(this, categoryItem)); - categoryItem.children = {}; - - var categoryType = categories[category].type; - var eventNames = categories[category].eventNames; - for (var i = 0; i < eventNames.length; ++i) { - var eventName = categoryType + ":" + eventNames[i]; - - var breakpoint = WebInspector.breakpointManager.createEventListenerBreakpoint(eventName, true); - if (!breakpoint) - continue; - - var labelElement = document.createElement("div"); - breakpoint.populateLabelElement(labelElement); - var eventNameTreeElement = new TreeElement(labelElement); - categoryTreeElement.appendChild(eventNameTreeElement); - eventNameTreeElement.listItemElement.addStyleClass("source-code"); - eventNameTreeElement.selectable = true; - - var eventNameItem = {}; - eventNameItem.checkbox = this._createCheckbox(eventNameTreeElement, this._eventNameCheckboxClicked.bind(this, categoryItem, eventNameItem)); - eventNameItem.breakpoint = breakpoint; - - breakpoint.addEventListener("enable-changed", this._breakpointEnableChanged.bind(this, categoryItem, eventNameItem), true); - - categoryItem.children[eventName] = eventNameItem; - } + var categoryItem = {}; + categoryItem.element = new TreeElement(WebInspector.UIString(name)); + this.categoriesTreeOutline.appendChild(categoryItem.element); + categoryItem.element.listItemElement.addStyleClass("event-category"); + categoryItem.element.selectable = true; + + categoryItem.checkbox = this._createCheckbox(categoryItem.element); + categoryItem.checkbox.addEventListener("click", this._categoryCheckboxClicked.bind(this, categoryItem), true); + + categoryItem.children = {}; + for (var i = 0; i < eventNames.length; ++i) { + var eventName = type + ":" + eventNames[i]; + + var breakpointItem = {}; + var title = WebInspector.EventListenerBreakpoint.eventNameForUI(eventName); + breakpointItem.element = new TreeElement(title); + categoryItem.element.appendChild(breakpointItem.element); + breakpointItem.element.listItemElement.addStyleClass("source-code"); + breakpointItem.element.selectable = true; + + breakpointItem.checkbox = this._createCheckbox(breakpointItem.element); + breakpointItem.checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind(this, breakpointItem), true); + breakpointItem.parent = categoryItem; + breakpointItem.eventName = eventName; + + this._breakpointItems[eventName] = breakpointItem; + categoryItem.children[eventName] = breakpointItem; } }, - _createCheckbox: function(treeElement, checkboxClickedDelegate) + _createCheckbox: function(treeElement) { var checkbox = document.createElement("input"); checkbox.className = "checkbox-elem"; checkbox.type = "checkbox"; - checkbox.addEventListener("click", checkboxClickedDelegate, true); treeElement.listItemElement.insertBefore(checkbox, treeElement.listItemElement.firstChild); return checkbox; }, _categoryCheckboxClicked: function(categoryItem) { - var checkbox = categoryItem.checkbox; - checkbox.indeterminate = false; + var checked = categoryItem.checkbox.checked; for (var eventName in categoryItem.children) { - var eventNameItem = categoryItem.children[eventName]; - eventNameItem.checkbox.checked = checkbox.checked; - eventNameItem.breakpoint.enabled = checkbox.checked; + var breakpointItem = categoryItem.children[eventName]; + if (breakpointItem.checkbox.checked !== checked) { + breakpointItem.checkbox.checked = checked; + this._breakpointCheckboxClicked(breakpointItem); + } } }, - _eventNameCheckboxClicked: function(categoryItem, eventNameItem) + _breakpointCheckboxClicked: function(breakpointItem) { - this._updateCategoryCheckbox(categoryItem); - eventNameItem.breakpoint.enabled = eventNameItem.checkbox.checked; + if (breakpointItem.checkbox.checked) + WebInspector.breakpointManager.createEventListenerBreakpoint(breakpointItem.eventName); + else + breakpointItem.breakpoint.remove(); }, - _breakpointEnableChanged: function(categoryItem, eventNameItem) + _breakpointAdded: function(event) { - if (eventNameItem.checkbox.checked === eventNameItem.breakpoint.enabled) - return; + var breakpoint = event.data.breakpoint; + var eventName = event.data.eventName; + + var breakpointItem = this._breakpointItems[eventName]; + breakpointItem.breakpoint = breakpoint; + breakpoint.addEventListener("hit-state-changed", this._breakpointHitStateChanged.bind(this, breakpointItem)); + breakpoint.addEventListener("removed", this._breakpointRemoved.bind(this, breakpointItem)); + breakpointItem.checkbox.checked = true; + this._updateCategoryCheckbox(breakpointItem); + }, - eventNameItem.checkbox.checked = eventNameItem.breakpoint.enabled; - this._updateCategoryCheckbox(categoryItem); + _breakpointHitStateChanged: function(breakpointItem, event) + { + if (event.target.hit) { + this.expanded = true; + var categoryItem = breakpointItem.parent; + categoryItem.element.expand(); + breakpointItem.element.listItemElement.addStyleClass("breakpoint-hit"); + } else + breakpointItem.element.listItemElement.removeStyleClass("breakpoint-hit"); }, - _updateCategoryCheckbox: function(categoryItem) + _breakpointRemoved: function(breakpointItem) { + breakpointItem.breakpoint = null; + breakpointItem.checkbox.checked = false; + this._updateCategoryCheckbox(breakpointItem); + }, + + _updateCategoryCheckbox: function(breakpointItem) + { + var categoryItem = breakpointItem.parent; var hasEnabled = false, hasDisabled = false; for (var eventName in categoryItem.children) { - var eventNameItem = categoryItem.children[eventName]; - if (eventNameItem.checkbox.checked) + var breakpointItem = categoryItem.children[eventName]; + if (breakpointItem.checkbox.checked) hasEnabled = true; else hasDisabled = true; @@ -341,8 +375,12 @@ WebInspector.EventListenerBreakpointsSidebarPane.prototype = { reset: function() { - this.categoriesTreeOutline.removeChildren(); - this._populate(); + for (var eventName in this._breakpointItems) { + var breakpointItem = this._breakpointItems[eventName]; + breakpointItem.breakpoint = null; + breakpointItem.checkbox.checked = false; + this._updateCategoryCheckbox(breakpointItem); + } } } diff --git a/WebCore/inspector/front-end/CSSStyleModel.js b/WebCore/inspector/front-end/CSSStyleModel.js index 702c923..542a3b3 100644 --- a/WebCore/inspector/front-end/CSSStyleModel.js +++ b/WebCore/inspector/front-end/CSSStyleModel.js @@ -119,7 +119,7 @@ WebInspector.CSSStyleModel.prototype = { if (!newRulePayload) failureCallback(); else - successCallback(WebInspector.CSSStyleDeclaration.parseRule(newRulePayload), doesAffectSelectedNode); + successCallback(WebInspector.CSSRule.parsePayload(newRulePayload), doesAffectSelectedNode); } InspectorBackend.setRuleSelector(ruleId, newContent, nodeId, callback); @@ -133,7 +133,7 @@ WebInspector.CSSStyleModel.prototype = { // Invalid syntax for a selector failureCallback(); } else { - var styleRule = WebInspector.CSSStyleDeclaration.parseRule(rule); + var styleRule = WebInspector.CSSRule.parsePayload(rule); styleRule.rule = rule; successCallback(styleRule, doesAffectSelectedNode); } diff --git a/WebCore/inspector/front-end/ConsoleView.js b/WebCore/inspector/front-end/ConsoleView.js index deca21c..737b84f 100644 --- a/WebCore/inspector/front-end/ConsoleView.js +++ b/WebCore/inspector/front-end/ConsoleView.js @@ -48,7 +48,7 @@ WebInspector.ConsoleView = function(drawer) this.promptElement.className = "source-code"; this.promptElement.addEventListener("keydown", this._promptKeyDown.bind(this), true); this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), ExpressionStopCharacters + "."); - this.prompt.history = WebInspector.applicationSettings.consoleHistory; + this.prompt.history = WebInspector.settings.consoleHistory; this.topGroup = new WebInspector.ConsoleGroup(null, 0); this.messagesElement.insertBefore(this.topGroup.element, this.promptElement); @@ -218,18 +218,7 @@ WebInspector.ConsoleView.prototype = { { if (msg instanceof WebInspector.ConsoleMessage && !(msg instanceof WebInspector.ConsoleCommandResult)) { this._incrementErrorWarningCount(msg); - - // Add message to the resource panel - if (!Preferences.networkPanelEnabled) { - var resource = WebInspector.resourceForURL(msg.url); - if (resource) { - msg.resource = resource; - if (WebInspector.panels.resources) - WebInspector.panels.resources.addMessageToResource(msg.resource, msg); - } - } else - WebInspector.resourceManager.addConsoleMessage(msg); - + WebInspector.resourceManager.addConsoleMessage(msg); this.commandSincePreviousMessage = false; this.previousMessage = msg; } else if (msg instanceof WebInspector.ConsoleCommand) { @@ -300,10 +289,7 @@ WebInspector.ConsoleView.prototype = { clearMessages: function() { - if (WebInspector.panels.resources) - WebInspector.panels.resources.clearMessages(); - if (WebInspector.resourceManager) - WebInspector.resourceManager.clearConsoleMessages(); + WebInspector.resourceManager.clearConsoleMessages(); this.messages = []; @@ -522,7 +508,7 @@ WebInspector.ConsoleView.prototype = { _enterKeyPressed: function(event) { - if (event.altKey || event.ctrlKey) + if (event.altKey || event.ctrlKey || event.shiftKey) return; event.preventDefault(); @@ -544,7 +530,7 @@ WebInspector.ConsoleView.prototype = { self.prompt.historyOffset = 0; self.prompt.text = ""; - WebInspector.applicationSettings.consoleHistory = self.prompt.history.slice(-30); + WebInspector.settings.consoleHistory = self.prompt.history.slice(-30); self.addMessage(new WebInspector.ConsoleCommandResult(result, commandMessage)); } diff --git a/WebCore/inspector/front-end/DataGrid.js b/WebCore/inspector/front-end/DataGrid.js index bc429d9..902062c 100644 --- a/WebCore/inspector/front-end/DataGrid.js +++ b/WebCore/inspector/front-end/DataGrid.js @@ -53,12 +53,12 @@ WebInspector.DataGrid = function(columns, editCallback, deleteCallback) this.aligned = {}; - var scrollContainer = document.createElement("div"); - scrollContainer.className = "data-container"; - scrollContainer.appendChild(this._dataTable); + this._scrollContainer = document.createElement("div"); + this._scrollContainer.className = "data-container"; + this._scrollContainer.appendChild(this._dataTable); this.element.appendChild(this._headerTable); - this.element.appendChild(scrollContainer); + this.element.appendChild(this._scrollContainer); var headerRow = document.createElement("tr"); var columnGroup = document.createElement("colgroup"); @@ -485,6 +485,16 @@ WebInspector.DataGrid.prototype = { this._columnWidthsInitialized = false; }, + isScrolledToLastRow: function() + { + return this._scrollContainer.scrollTop === this._scrollContainer.scrollHeight - this._scrollContainer.offsetHeight; + }, + + scrollToLastRow: function() + { + this._scrollContainer.scrollTop = this._scrollContainer.scrollHeight - this._scrollContainer.offsetHeight; + }, + _positionResizers: function() { var headerTableColumns = this._headerTableColumnGroup.children; diff --git a/WebCore/inspector/front-end/ElementsTreeOutline.js b/WebCore/inspector/front-end/ElementsTreeOutline.js index 1d546c2..4404051 100644 --- a/WebCore/inspector/front-end/ElementsTreeOutline.js +++ b/WebCore/inspector/front-end/ElementsTreeOutline.js @@ -758,13 +758,18 @@ WebInspector.ElementsTreeElement.prototype = { // Add debbuging-related actions contextMenu.appendSeparator(); + function handlerFunction(nodeId, breakType) + { + WebInspector.breakpointManager.createDOMBreakpoint(nodeId, breakType); + WebInspector.panels.elements.sidebarPanes.domBreakpoints.expand(); + } var node = this.representedObject; for (var key in WebInspector.DOMBreakpointTypes) { var type = WebInspector.DOMBreakpointTypes[key]; var label = WebInspector.domBreakpointTypeContextMenuLabel(type); var breakpoint = node.breakpoints[type]; if (!breakpoint) - var handler = WebInspector.breakpointManager.createDOMBreakpoint.bind(WebInspector.breakpointManager, node.id, type); + var handler = handlerFunction.bind(this, node.id, type); else var handler = breakpoint.remove.bind(breakpoint); contextMenu.appendCheckboxItem(label, handler, !!breakpoint); diff --git a/WebCore/inspector/front-end/EventListenersSidebarPane.js b/WebCore/inspector/front-end/EventListenersSidebarPane.js index 3354191..bc8bb12 100644 --- a/WebCore/inspector/front-end/EventListenersSidebarPane.js +++ b/WebCore/inspector/front-end/EventListenersSidebarPane.js @@ -46,7 +46,7 @@ WebInspector.EventListenersSidebarPane = function() option.label = WebInspector.UIString("Selected Node Only"); this.settingsSelectElement.appendChild(option); - var filter = WebInspector.applicationSettings.eventListenersFilter; + var filter = WebInspector.settings.eventListenersFilter; if (filter === "all") this.settingsSelectElement[0].selected = true; else if (filter === "selected") @@ -107,7 +107,7 @@ WebInspector.EventListenersSidebarPane.prototype = { _changeSetting: function(event) { var selectedOption = this.settingsSelectElement[this.settingsSelectElement.selectedIndex]; - WebInspector.applicationSettings.eventListenersFilter = selectedOption.value; + WebInspector.settings.eventListenersFilter = selectedOption.value; for (var i = 0; i < this.sections.length; ++i) this.sections[i].update(); @@ -137,7 +137,7 @@ WebInspector.EventListenersSection.prototype = { { // A Filtered Array simplifies when to create connectors var filteredEventListeners = this.eventListeners; - if (WebInspector.applicationSettings.eventListenersFilter === "selected") { + if (WebInspector.settings.eventListenersFilter === "selected") { filteredEventListeners = []; for (var i = 0; i < this.eventListeners.length; ++i) { var eventListener = this.eventListeners[i]; @@ -151,12 +151,6 @@ WebInspector.EventListenersSection.prototype = { for (var i = 0; i < length; ++i) { var eventListener = filteredEventListeners[i]; var eventListenerBar = new WebInspector.EventListenerBar(eventListener, this._nodeId); - if (i < length - 1) { - var connector = document.createElement("div"); - connector.className = "event-bar-connector"; - eventListenerBar.element.appendChild(connector); - } - this.eventBars.appendChild(eventListenerBar.element); } }, @@ -178,6 +172,7 @@ WebInspector.EventListenerBar = function(eventListener, nodeId) this._setFunctionSubtitle(); this.editable = false; this.element.className = "event-bar"; /* Changed from "section" */ + this.headerElement.addStyleClass("source-code"); this.propertiesElement.className = "event-properties properties-tree source-code"; /* Changed from "properties" */ } diff --git a/WebCore/inspector/front-end/ExtensionAPI.js b/WebCore/inspector/front-end/ExtensionAPI.js index 5d090b0..7d6d76c 100644 --- a/WebCore/inspector/front-end/ExtensionAPI.js +++ b/WebCore/inspector/front-end/ExtensionAPI.js @@ -197,6 +197,19 @@ PanelImpl.prototype = { callback(new ExtensionSidebarPane(id)); } extensionServer.sendRequest({ command: "createSidebarPane", panel: this._id, id: id, title: title, url: expandURL(url) }, callback && callbackWrapper); + }, + + createWatchExpressionSidebarPane: function(title, callback) + { + var id = "watch-sidebar-" + extensionServer.nextObjectId(); + function callbackWrapper(result) + { + if (result.isError) + callback(result); + else + callback(new WatchExpressionSidebarPane(id)); + } + extensionServer.sendRequest({ command: "createWatchExpressionSidebarPane", panel: this._id, id: id, title: title }, callback && callbackWrapper); } } @@ -204,6 +217,7 @@ function Panel(id) { var impl = new PanelImpl(id); this.createSidebarPane = bind(impl.createSidebarPane, impl); + this.createWatchExpressionSidebarPane = bind(impl.createWatchExpressionSidebarPane, impl); this.onSelectionChanged = new EventSink("panel-objectSelected-" + id); } @@ -235,13 +249,40 @@ ExtensionSidebarPaneImpl.prototype = { } } -function ExtensionSidebarPane(id) +function ExtensionSidebarPane(id, impl) { - var impl = new ExtensionSidebarPaneImpl(id); + if (!impl) + impl = new ExtensionSidebarPaneImpl(id); this.setHeight = bind(impl.setHeight, impl); this.setExpanded = bind(impl.setExpanded, impl); } +function WatchExpressionSidebarPaneImpl(id) +{ + ExtensionSidebarPaneImpl.call(this, id); +} + +WatchExpressionSidebarPaneImpl.prototype = { + setExpression: function(expression, rootTitle) + { + extensionServer.sendRequest({ command: "setWatchSidebarContent", id: this._id, expression: expression, rootTitle: rootTitle, evaluateOnPage: true }); + }, + + setObject: function(jsonObject, rootTitle) + { + extensionServer.sendRequest({ command: "setWatchSidebarContent", id: this._id, expression: jsonObject, rootTitle: rootTitle }); + } +} + +function WatchExpressionSidebarPane(id) +{ + var impl = new WatchExpressionSidebarPaneImpl(id); + ExtensionSidebarPane.call(this, id, impl); + this.setExpression = bind(impl.setExpression, impl); + this.setObject = bind(impl.setObject, impl); + this.onUpdated = new EventSink("watch-sidebar-updated-" + id); +} + function Audits() { } diff --git a/WebCore/inspector/front-end/ExtensionPanel.js b/WebCore/inspector/front-end/ExtensionPanel.js index ba5fa8e..4b42e68 100644 --- a/WebCore/inspector/front-end/ExtensionPanel.js +++ b/WebCore/inspector/front-end/ExtensionPanel.js @@ -80,3 +80,39 @@ WebInspector.ExtensionPanel.prototype = { } WebInspector.ExtensionPanel.prototype.__proto__ = WebInspector.Panel.prototype; + +WebInspector.ExtensionWatchSidebarPane = function(title, id) +{ + WebInspector.SidebarPane.call(this, title); + this._id = id; +} + +WebInspector.ExtensionWatchSidebarPane.prototype = { + setObject: function(object, title) + { + this._setObject(WebInspector.RemoteObject.fromLocalObject(object), title); + }, + + setExpression: function(expression, title) + { + InjectedScriptAccess.getDefault().evaluate(expression, this._onEvaluate.bind(this, title)); + }, + + _onEvaluate: function(title, result) + { + this._setObject(WebInspector.RemoteObject.fromPayload(result), title); + }, + + _setObject: function(object, title) + { + this.bodyElement.removeChildren(); + var section = new WebInspector.ObjectPropertiesSection(object, title, null, true); + if (!title) + section.headerElement.addStyleClass("hidden"); + section.expanded = true; + this.bodyElement.appendChild(section.element); + WebInspector.extensionServer.notifyExtensionWatchSidebarUpdated(this._id); + } +} + +WebInspector.ExtensionWatchSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype; diff --git a/WebCore/inspector/front-end/ExtensionServer.js b/WebCore/inspector/front-end/ExtensionServer.js index 5e593f7..6ffa33a 100644 --- a/WebCore/inspector/front-end/ExtensionServer.js +++ b/WebCore/inspector/front-end/ExtensionServer.js @@ -42,10 +42,12 @@ WebInspector.ExtensionServer = function() this._registerHandler("getPageTimings", this._onGetPageTimings.bind(this)); this._registerHandler("createPanel", this._onCreatePanel.bind(this)); this._registerHandler("createSidebarPane", this._onCreateSidebar.bind(this)); + this._registerHandler("createWatchExpressionSidebarPane", this._onCreateWatchExpressionSidebarPane.bind(this)); this._registerHandler("log", this._onLog.bind(this)); this._registerHandler("evaluateOnInspectedPage", this._onEvaluateOnInspectedPage.bind(this)); this._registerHandler("setSidebarHeight", this._onSetSidebarHeight.bind(this)); this._registerHandler("setSidebarExpanded", this._onSetSidebarExpansion.bind(this)); + this._registerHandler("setWatchSidebarContent", this._onSetWatchSidebarContent.bind(this)); this._registerHandler("addAuditCategory", this._onAddAuditCategory.bind(this)); this._registerHandler("addAuditResult", this._onAddAuditResult.bind(this)); @@ -90,6 +92,11 @@ WebInspector.ExtensionServer.prototype = { this._postNotification("reset"); }, + notifyExtensionWatchSidebarUpdated: function(id) + { + this._postNotification("watch-sidebar-updated-" + id); + }, + startAuditRun: function(category, auditRun) { this._clientObjects[auditRun.id] = auditRun; @@ -161,7 +168,22 @@ WebInspector.ExtensionServer.prototype = { return this._status.OK(); }, - _onCreateSidebar: function(message, port) + _onCreateSidebar: function(message) + { + var sidebar = this._createSidebar(message, WebInspector.SidebarPane); + if (sidebar.isError) + return sidebar; + this._createClientIframe(sidebar.bodyElement, message.url); + return this._status.OK(); + }, + + _onCreateWatchExpressionSidebarPane: function(message) + { + var sidebar = this._createSidebar(message, WebInspector.ExtensionWatchSidebarPane); + return sidebar.isError ? sidebar : this._status.OK(); + }, + + _createSidebar: function(message, constructor) { var panel = WebInspector.panels[message.panel]; if (!panel) @@ -169,12 +191,12 @@ WebInspector.ExtensionServer.prototype = { if (!panel.sidebarElement || !panel.sidebarPanes) return this._status.E_NOTSUPPORTED(); var id = message.id; - var sidebar = new WebInspector.SidebarPane(message.title); + var sidebar = new constructor(message.title, message.id); this._clientObjects[id] = sidebar; panel.sidebarPanes[id] = sidebar; panel.sidebarElement.appendChild(sidebar.element); - this._createClientIframe(sidebar.bodyElement, message.url); - return this._status.OK(); + + return sidebar; }, _createClientIframe: function(parent, url, requestId, port) @@ -205,6 +227,17 @@ WebInspector.ExtensionServer.prototype = { sidebar.collapse(); }, + _onSetWatchSidebarContent: function(message) + { + var sidebar = this._clientObjects[message.id]; + if (!sidebar) + return this._status.E_NOTFOUND(message.id); + if (message.evaluateOnPage) + sidebar.setExpression(message.expression, message.rootTitle); + else + sidebar.setObject(message.expression, message.rootTitle); + }, + _onLog: function(message) { WebInspector.log(message.message); @@ -243,13 +276,9 @@ WebInspector.ExtensionServer.prototype = { resource = WebInspector.networkResources[id] || WebInspector.resourceForURL(id); if (!resource) return this._status.E_NOTFOUND(typeof id + ": " + id); - if (Preferences.networkPanelEnabled) { - WebInspector.panels.storage.showResource(resource, message.line); - WebInspector.showPanel("storage"); - } else { - WebInspector.panels.resources.showResource(resource, message.line); - WebInspector.showPanel("resources"); - } + + WebInspector.panels.storage.showResource(resource, message.line); + WebInspector.showPanel("storage"); }, _dispatchCallback: function(requestId, port, result) @@ -303,7 +332,7 @@ WebInspector.ExtensionServer.prototype = { if (!resource) response.push(this._status.E_NOTFOUND(id)); else - resource.getContent(onContentAvailable.bind(this, id)); + resource.requestContent(onContentAvailable.bind(this, id)); } if (response.length === ids.length) this._dispatchCallback(message.requestId, port, response); diff --git a/WebCore/inspector/front-end/FileSystemView.js b/WebCore/inspector/front-end/FileSystemView.js new file mode 100644 index 0000000..0c6636b --- /dev/null +++ b/WebCore/inspector/front-end/FileSystemView.js @@ -0,0 +1,190 @@ +/* + * 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. + */ + +WebInspector.FileSystem = {} + +// Keep in sync with Type in AsyncFileSystem.h +WebInspector.FileSystem.TEMPORARY = 0; +WebInspector.FileSystem.PERSISTENT = 1; + +WebInspector.FileSystem.getFileSystemPathsAsync = function(origin) +{ + InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystem.PERSISTENT, origin); + InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystem.TEMPORARY, origin); +} + +WebInspector.FileSystemView = function(treeElement, fileSystemOrigin) +{ + WebInspector.View.call(this); + + this.element.addStyleClass("resource-view"); + this._treeElement = treeElement; + this._origin = fileSystemOrigin; + this._tabbedPane = new WebInspector.TabbedPane(this.element); + + this._persistentFileSystemElement = document.createElement("div"); + this._persistentFileSystemElement.className = "resource-view-headers"; + this._tabbedPane.appendTab("persistent", WebInspector.UIString("Persistent File System"), this._persistentFileSystemElement, this._selectFileSystemTab.bind(this, true)); + + this._tempFileSystemElement = document.createElement("div"); + this._tempFileSystemElement.className = "resource-view-headers"; + this._tabbedPane.appendTab("temp", WebInspector.UIString("Temporary File System"), this._tempFileSystemElement, this.selectTemporaryFileSystemTab.bind(this, true)); + + this._temporaryRoot = ""; + this._persistentRoot = ""; + this._isFileSystemDisabled = false; + this._persistentRootError = false; + this._temporaryRootError = false; + this.fileSystemVisible = true; + this._selectFileSystemTab(); + this.refreshFileSystem(); +} + +WebInspector.FileSystemView.prototype = { + show: function(parentElement) + { + WebInspector.View.prototype.show.call(this, parentElement); + this._update(); + }, + + set fileSystemVisible(x) + { + if (x === this._fileSystemVisible) + return; + this._fileSystemVisible = x; + if (x) + this.element.addStyleClass("headers-visible"); + else + this.element.removeStyleClass("headers-visible"); + this._selectFileSystemTab(); + }, + + _update: function() + { + this._selectFileSystemTab(); + WebInspector.FileSystem.getFileSystemPathsAsync(this._origin); + }, + + updateFileSystemPath: function(root, type, origin) + { + if (origin == this._origin && type == WebInspector.FileSystem.PERSISTENT) { + this._persistentRoot = root; + this._persistentRootError = false; + } + + if (origin == this._origin && type == WebInspector.FileSystem.TEMPORARY) { + this._temporaryRoot = root; + this._temporaryRootErrorError = false; + } + + this.refreshFileSystem(); + }, + + updateFileSystemError: function(type, origin) + { + if (type == WebInspector.FileSystem.PERSISTENT) + this._persistentRootError = true; + + if (type == WebInspector.FileSystem.TEMPORARY) + this._temporaryRootError = true; + + this.refreshFileSystem(); + }, + + setFileSystemDisabled: function() + { + this._isFileSystemDisabled = true; + this.refreshFileSystem(); + }, + _selectFileSystemTab: function() + { + this._tabbedPane.selectTabById("persistent"); + }, + + selectTemporaryFileSystemTab: function() + { + this._tabbedPane.selectTabById("temp"); + }, + + _revealPersistentFolderInOS: function() + { + InspectorBackend.revealFolderInOS(this._persistentRoot); + }, + + _revealTemporaryFolderInOS: function() + { + InspectorBackend.revealFolderInOS(this._temporaryRoot); + }, + + _createTextAndButton: function(fileSystemElement, rootPathText, type, isError) + { + fileSystemElement.removeChildren(); + var rootPath = WebInspector.UIString("File System root path not available."); + if (this._isFileSystemDisabled) + rootPath = WebInspector.UIString("File System is disabled."); + else if (isError) + rootPath = WebInspector.UIString("Error in fetching root path for file system."); + else if (rootPathText) + rootPath = rootPathText; + + var rootTextNode = document.createTextNode("Root: " + rootPath.escapeHTML()); + var rootSystemElement = document.createElement("div"); + rootSystemElement.className = "header-value source-code"; + rootSystemElement.appendChild(rootTextNode); + fileSystemElement.appendChild(rootSystemElement); + + if (!isError && rootPathText) { + // Append Browse button iff root path is available and it is not an error. + var contentElement = document.createElement("div"); + contentElement.className = "panel-enabler-view-content"; + fileSystemElement.appendChild(contentElement); + var choicesForm = document.createElement("form"); + contentElement.appendChild(choicesForm); + var enableButton = document.createElement("button"); + enableButton.setAttribute("type", "button"); + enableButton.textContent = WebInspector.UIString("Reveal folder in OS"); + // FIXME: Bind this directly to InspectorBackend. + if (type == WebInspector.FileSystem.PERSISTENT) + enableButton.addEventListener("click", this._revealPersistentFolderInOS.bind(this), false); + if (type == WebInspector.FileSystem.TEMPORARY) + enableButton.addEventListener("click", this._revealTemporaryFolderInOS.bind(this), false); + choicesForm.appendChild(enableButton); + fileSystemElement.appendChild(contentElement); + } + }, + + refreshFileSystem: function() + { + this._createTextAndButton(this._persistentFileSystemElement, this._persistentRoot, WebInspector.FileSystem.PERSISTENT, this._persistentRootError); + this._createTextAndButton(this._tempFileSystemElement, this._temporaryRoot, WebInspector.FileSystem.TEMPORARY, this._temporaryRootError); + }, +} + +WebInspector.FileSystemView.prototype.__proto__ = WebInspector.View.prototype; diff --git a/WebCore/inspector/front-end/ImageView.js b/WebCore/inspector/front-end/ImageView.js index 7cff056..f70fad6 100644 --- a/WebCore/inspector/front-end/ImageView.js +++ b/WebCore/inspector/front-end/ImageView.js @@ -47,15 +47,9 @@ WebInspector.ImageView.prototype = { this._container.className = "image"; this.contentElement.appendChild(this._container); - this.imagePreviewElement = document.createElement("img"); - this.imagePreviewElement.addStyleClass("resource-image-view"); - this._container.appendChild(this.imagePreviewElement); - - function onResourceContent(element, content) - { - this.imagePreviewElement.setAttribute("src", this.resource.contentURL); - } - this.resource.getContent(onResourceContent.bind(this)); + var imagePreviewElement = document.createElement("img"); + imagePreviewElement.addStyleClass("resource-image-view"); + this._container.appendChild(imagePreviewElement); this._container = document.createElement("div"); this._container.className = "info"; @@ -69,18 +63,51 @@ WebInspector.ImageView.prototype = { var infoListElement = document.createElement("dl"); infoListElement.className = "infoList"; - var imageProperties = [ - { name: WebInspector.UIString("Dimensions"), value: WebInspector.UIString("%d × %d", this.imagePreviewElement.naturalWidth, this.imagePreviewElement.height) }, - { name: WebInspector.UIString("File size"), value: Number.bytesToString(this.resource.resourceSize, WebInspector.UIString) }, - { name: WebInspector.UIString("MIME type"), value: this.resource.mimeType } - ]; + function onResourceContent(element, content) + { + imagePreviewElement.setAttribute("src", this.resource.contentURL); + } + this.resource.requestContent(onResourceContent.bind(this)); - var listHTML = ''; - for (var i = 0; i < imageProperties.length; ++i) - listHTML += "<dt>" + imageProperties[i].name + "</dt><dd>" + imageProperties[i].value + "</dd>"; - infoListElement.innerHTML = listHTML; - this._container.appendChild(infoListElement); + function onImageLoad() + { + var content = this.resource.content; + if (content) + var resourceSize = this._base64ToSize(content); + else + var resourceSize = this.resource.resourceSize; + + 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("MIME type"), value: this.resource.mimeType } + ]; + + infoListElement.removeChildren(); + for (var i = 0; i < imageProperties.length; ++i) { + var dt = document.createElement("dt"); + dt.textContent = imageProperties[i].name; + infoListElement.appendChild(dt); + var dd = document.createElement("dd"); + dd.textContent = imageProperties[i].value; + infoListElement.appendChild(dd); + } + this._container.appendChild(infoListElement); + } + imagePreviewElement.addEventListener("load", onImageLoad.bind(this), false); + }, + + _base64ToSize: function(content) + { + if (!content.length) + return 0; + var size = (content.length || 0) * 3 / 4; + if (content.length > 0 && content[content.length - 1] === "=") + size--; + if (content.length > 1 && content[content.length - 2] === "=") + size--; + return size; } } diff --git a/WebCore/inspector/front-end/Images/grayConnectorPoint.png b/WebCore/inspector/front-end/Images/grayConnectorPoint.png Binary files differdeleted file mode 100644 index fddc7ea..0000000 --- a/WebCore/inspector/front-end/Images/grayConnectorPoint.png +++ /dev/null diff --git a/WebCore/inspector/front-end/Images/resourcesSilhouette.png b/WebCore/inspector/front-end/Images/resourcesSilhouette.png Binary files differdeleted file mode 100644 index 9c8bb53..0000000 --- a/WebCore/inspector/front-end/Images/resourcesSilhouette.png +++ /dev/null diff --git a/WebCore/inspector/front-end/Images/whiteConnectorPoint.png b/WebCore/inspector/front-end/Images/whiteConnectorPoint.png Binary files differdeleted file mode 100644 index c8fb1cf..0000000 --- a/WebCore/inspector/front-end/Images/whiteConnectorPoint.png +++ /dev/null diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js index 2d60f69..fff6680 100644 --- a/WebCore/inspector/front-end/InjectedScript.js +++ b/WebCore/inspector/front-end/InjectedScript.js @@ -52,7 +52,6 @@ InjectedScript.prototype = { var objectId; if (typeof object === "object" || typeof object === "function" || this._isHTMLAllCollection(object)) { var id = this._lastBoundObjectId++; - objectId = id; this._idToWrappedObject[id] = object; var group = this._objectGroups[objectGroupName]; diff --git a/WebCore/inspector/front-end/NetworkPanel.js b/WebCore/inspector/front-end/NetworkPanel.js index c666e54..71433af 100644 --- a/WebCore/inspector/front-end/NetworkPanel.js +++ b/WebCore/inspector/front-end/NetworkPanel.js @@ -37,6 +37,7 @@ WebInspector.NetworkPanel = function() this._resources = []; this._resourcesById = {}; + this._resourcesByURL = {}; this._lastIdentifier = 0; this._staleResources = []; this._resourceGridNodes = {}; @@ -55,10 +56,10 @@ WebInspector.NetworkPanel = function() this._viewsContainerElement.className = "hidden"; this.element.appendChild(this._viewsContainerElement); - var closeButtonElement = document.createElement("button"); - closeButtonElement.className = "network-close-button"; - closeButtonElement.addEventListener("click", this._toggleGridMode.bind(this), false); - this._viewsContainerElement.appendChild(closeButtonElement); + this._closeButtonElement = document.createElement("button"); + this._closeButtonElement.id = "network-close-button"; + this._closeButtonElement.addEventListener("click", this._toggleGridMode.bind(this), false); + this._viewsContainerElement.appendChild(this._closeButtonElement); this._createSortingFunctions(); this._createTable(); @@ -67,6 +68,9 @@ WebInspector.NetworkPanel = function() this._createFilterStatusBarItems(); this._createSummaryBar(); + if (!WebInspector.settings.resourcesLargeRows) + this._setLargerResources(WebInspector.settings.resourcesLargeRows); + this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), true); this.calculator = new WebInspector.NetworkTransferTimeCalculator(); @@ -83,7 +87,7 @@ WebInspector.NetworkPanel.prototype = { get statusBarItems() { - return [this._largerResourcesButton.element, this._clearButton.element, this._filterBarElement]; + return [this._largerResourcesButton.element, this._preserveLogToggle.element, this._clearButton.element, this._filterBarElement]; }, isCategoryVisible: function(categoryName) @@ -103,11 +107,13 @@ WebInspector.NetworkPanel.prototype = { this._positionSummaryBar(); }, - updateSidebarWidth: function() + updateSidebarWidth: function(width) { if (!this._viewingResourceMode) return; - WebInspector.Panel.prototype.updateSidebarWidth.apply(this, arguments); + WebInspector.Panel.prototype.updateSidebarWidth.call(this, width); + if (this._summaryBarElement.parentElement === this.element) + this._summaryBarElement.style.width = width + "px"; }, updateMainViewWidth: function(width) @@ -126,28 +132,26 @@ WebInspector.NetworkPanel.prototype = { _positionSummaryBar: function() { // Position the total bar. - const rowHeight = 22; - const summaryBarHeight = 22; - var offsetHeight = this.element.offsetHeight; - - var parentElement = this._summaryBarElement.parentElement; - if (this._summaryBarElement.parentElement !== this.element && offsetHeight > (this._dataGrid.children.length - 1) * rowHeight + summaryBarHeight) { + var fillerRow = this._dataGrid.dataTableBody.lastChild; + if (this._summaryBarElement.parentElement !== this.element && fillerRow.offsetHeight > 0) { // Glue status to bottom. if (this._summaryBarRowNode) { this._dataGrid.removeChild(this._summaryBarRowNode); delete this._summaryBarRowNode; } this._summaryBarElement.addStyleClass("network-summary-bar-bottom"); + this._summaryBarElement.style.setProperty("width", this.sidebarElement.offsetWidth + "px"); this.element.appendChild(this._summaryBarElement); this._dataGrid.element.style.bottom = "20px"; return; } - if (!this._summaryBarRowNode && offsetHeight - summaryBarHeight < this._dataGrid.children.length * rowHeight) { + if (!this._summaryBarRowNode && !fillerRow.offsetHeight) { // Glue status to table. this._summaryBarRowNode = new WebInspector.NetworkTotalGridNode(this._summaryBarElement); this._summaryBarElement.removeStyleClass("network-summary-bar-bottom"); + this._summaryBarElement.style.removeProperty("width"); this._dataGrid.appendChild(this._summaryBarRowNode); this._dataGrid.element.style.bottom = 0; this._sortItems(); @@ -193,7 +197,7 @@ WebInspector.NetworkPanel.prototype = { columns.size.width = "10%"; columns.size.aligned = "right"; - columns.time.titleDOMFragment = this._makeHeaderFragment(WebInspector.UIString("Time"), WebInspector.UIString("Duration")); + columns.time.titleDOMFragment = this._makeHeaderFragment(WebInspector.UIString("Time"), WebInspector.UIString("Latency")); columns.time.sortable = true; columns.time.width = "10%"; columns.time.aligned = "right"; @@ -427,9 +431,7 @@ WebInspector.NetworkPanel.prototype = { selectMultiple = true; this._filter(e.target, selectMultiple); - - var searchField = document.getElementById("search"); - WebInspector.doPerformSearch(searchField.value, WebInspector.shortSearchWasForcedByKeyEvent, false, true); + this._positionSummaryBar(); }, _filter: function(target, selectMultiple) @@ -604,20 +606,16 @@ WebInspector.NetworkPanel.prototype = { this._timelineGrid.addEventDivider(divider); }, - get resourceTrackingEnabled() - { - return this._resourceTrackingEnabled; - }, - _createStatusbarButtons: function() { + this._preserveLogToggle = new WebInspector.StatusBarButton(WebInspector.UIString("Preserve Log upon Navigation"), "record-profile-status-bar-item"); + this._preserveLogToggle.addEventListener("click", this._onPreserveLogClicked.bind(this), false); + this._clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear"), "clear-status-bar-item"); this._clearButton.addEventListener("click", this._reset.bind(this), false); this._largerResourcesButton = new WebInspector.StatusBarButton(WebInspector.UIString("Use small resource rows."), "network-larger-resources-status-bar-item"); - this._largerResourcesButton.toggled = WebInspector.applicationSettings.resourcesLargeRows; - if (!WebInspector.applicationSettings.resourcesLargeRows) - this._setLargerResources(WebInspector.applicationSettings.resourcesLargeRows); + this._largerResourcesButton.toggled = WebInspector.settings.resourcesLargeRows; this._largerResourcesButton.addEventListener("click", this._toggleLargerResources.bind(this), false); }, @@ -713,8 +711,8 @@ WebInspector.NetworkPanel.prototype = { delete this._refreshTimeout; } + var wasScrolledToLastRow = this._dataGrid.isScrolledToLastRow(); var staleItemsLength = this._staleResources.length; - var boundariesChanged = false; for (var i = 0; i < staleItemsLength; ++i) { @@ -745,6 +743,20 @@ WebInspector.NetworkPanel.prototype = { this._sortItems(); this._updateSummaryBar(); this._dataGrid.updateWidths(); + + if (wasScrolledToLastRow) + this._dataGrid.scrollToLastRow(); + }, + + _onPreserveLogClicked: function(e) + { + this._preserveLogToggle.toggled = !this._preserveLogToggle.toggled; + }, + + reset: function() + { + if (!this._preserveLogToggle.toggled) + this._reset(); }, _reset: function() @@ -760,6 +772,7 @@ WebInspector.NetworkPanel.prototype = { this._resources = []; this._resourcesById = {}; + this._resourcesByURL = {}; this._staleResources = []; this._resourceGridNodes = {}; @@ -772,6 +785,7 @@ WebInspector.NetworkPanel.prototype = { this._mainResourceDOMContentTime = -1; this._viewsContainerElement.removeChildren(); + this._viewsContainerElement.appendChild(this._closeButtonElement); this._resetSummaryBar(); }, @@ -780,17 +794,23 @@ WebInspector.NetworkPanel.prototype = { return this._resourcesById; }, - addResource: function(resource) + refreshResource: function(resource) { - this._resources.push(resource); if (!resource.identifier) resource.identifier = "network:" + this._lastIdentifier++; - this._resourcesById[resource.identifier] = resource; - this.refreshResource(resource); - }, - refreshResource: function(resource) - { + if (!this._resourcesById[resource.identifier]) { + 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]); + } + } + this._staleResources.push(resource); this._scheduleRefresh(); @@ -819,11 +839,12 @@ WebInspector.NetworkPanel.prototype = { canShowSourceLine: function(url, line) { - return false; + return !!this._resourcesByURL[url]; }, showSourceLine: function(url, line) { + this._showResource(this._resourcesByURL[url], line); }, _showResource: function(resource, line) @@ -870,8 +891,8 @@ WebInspector.NetworkPanel.prototype = { _toggleLargerResources: function() { - WebInspector.applicationSettings.resourcesLargeRows = !WebInspector.applicationSettings.resourcesLargeRows; - this._setLargerResources(WebInspector.applicationSettings.resourcesLargeRows); + WebInspector.settings.resourcesLargeRows = !WebInspector.settings.resourcesLargeRows; + this._setLargerResources(WebInspector.settings.resourcesLargeRows); }, _setLargerResources: function(enabled) @@ -888,6 +909,7 @@ WebInspector.NetworkPanel.prototype = { this._timelineGrid.element.removeStyleClass("small"); this._viewsContainerElement.removeStyleClass("small"); } + this._positionSummaryBar(); }, _getPopoverAnchor: function(element) @@ -996,6 +1018,7 @@ WebInspector.NetworkPanel.prototype = { this._viewsContainerElement.addStyleClass("hidden"); this.sidebarElement.style.right = 0; this.sidebarElement.style.removeProperty("width"); + this._summaryBarElement.style.removeProperty("width"); } if (this._briefGrid) { @@ -1467,7 +1490,7 @@ WebInspector.NetworkDataGridNode.prototype = { previewImage.src = this._resource.contentURL; } if (Preferences.useDataURLForResourceImageIcons) - this._resource.getContent(onResourceContent.bind(this)); + this._resource.requestContent(onResourceContent.bind(this)); else previewImage.src = this._resource.url; diff --git a/WebCore/inspector/front-end/Panel.js b/WebCore/inspector/front-end/Panel.js index ec9250c..4c42a60 100644 --- a/WebCore/inspector/front-end/Panel.js +++ b/WebCore/inspector/front-end/Panel.js @@ -34,7 +34,7 @@ WebInspector.Panel = function(name) this.element.addStyleClass(name); this._panelName = name; - WebInspector.applicationSettings.installApplicationSetting(this._sidebarWidthSettingName(), undefined); + WebInspector.settings.installApplicationSetting(this._sidebarWidthSettingName(), undefined); } // Should by in sync with style declarations. @@ -377,7 +377,7 @@ WebInspector.Panel.prototype = { restoreSidebarWidth: function() { - var sidebarWidth = WebInspector.applicationSettings[this._sidebarWidthSettingName()]; + var sidebarWidth = WebInspector.settings[this._sidebarWidthSettingName()]; this.updateSidebarWidth(sidebarWidth); }, @@ -385,7 +385,7 @@ WebInspector.Panel.prototype = { { if (!this.sidebarElement) return; - WebInspector.applicationSettings[this._sidebarWidthSettingName()] = this.sidebarElement.offsetWidth; + WebInspector.settings[this._sidebarWidthSettingName()] = this.sidebarElement.offsetWidth; }, updateMainViewWidth: function(width) diff --git a/WebCore/inspector/front-end/ProfilesPanel.js b/WebCore/inspector/front-end/ProfilesPanel.js index ca02f9e..0aa4174 100644 --- a/WebCore/inspector/front-end/ProfilesPanel.js +++ b/WebCore/inspector/front-end/ProfilesPanel.js @@ -386,6 +386,20 @@ WebInspector.ProfilesPanel.prototype = { return result; }, + hasTemporaryProfile: function(typeId) + { + var profilesCount = this._profiles.length; + for (var i = 0; i < profilesCount; ++i) + if (this._profiles[i].typeId === typeId && this._profiles[i].isTemporary) + return true; + return false; + }, + + hasProfile: function(profile) + { + return !!this._profilesIdMap[this._makeKey(profile.uid, profile.typeId)]; + }, + updateProfile: function(profile) { var profilesCount = this._profiles.length; @@ -443,12 +457,12 @@ WebInspector.ProfilesPanel.prototype = { if (!(titleKey in this._profileGroupsForLinks)) this._profileGroupsForLinks[titleKey] = 0; - groupNumber = ++this._profileGroupsForLinks[titleKey]; + var groupNumber = ++this._profileGroupsForLinks[titleKey]; if (groupNumber > 2) // The title is used in the console message announcing that a profile has started so it gets // incremented twice as often as it's displayed - title += " " + WebInspector.UIString("Run %d", groupNumber / 2); + title += " " + WebInspector.UIString("Run %d", (groupNumber + 1) / 2); } return title; @@ -538,10 +552,11 @@ WebInspector.ProfilesPanel.prototype = { profileHeaders.sort(function(a, b) { return a.uid - b.uid; }); var profileHeadersLength = profileHeaders.length; for (var i = 0; i < profileHeadersLength; ++i) - WebInspector.addProfileHeader(profileHeaders[i]); + if (!this.hasProfile(profileHeaders[i])) + WebInspector.addProfileHeader(profileHeaders[i]); } - InspectorBackend.getProfileHeaders(populateCallback); + InspectorBackend.getProfileHeaders(populateCallback.bind(this)); this._profilesWereRequested = true; }, diff --git a/WebCore/inspector/front-end/PropertiesSection.js b/WebCore/inspector/front-end/PropertiesSection.js index 1ca52ce..88cb1a2 100644 --- a/WebCore/inspector/front-end/PropertiesSection.js +++ b/WebCore/inspector/front-end/PropertiesSection.js @@ -31,8 +31,9 @@ WebInspector.PropertiesSection = function(title, subtitle) { WebInspector.Section.call(this, title, subtitle); + this.headerElement.addStyleClass("monospace"); this.propertiesElement = document.createElement("ol"); - this.propertiesElement.className = "properties properties-tree source-code"; + this.propertiesElement.className = "properties properties-tree monospace"; this.propertiesElement.tabIndex = 0; this.propertiesTreeOutline = new TreeOutline(this.propertiesElement); this.propertiesTreeOutline.section = this; diff --git a/WebCore/inspector/front-end/PropertiesSidebarPane.js b/WebCore/inspector/front-end/PropertiesSidebarPane.js index 75d6a48..b9c212a 100644 --- a/WebCore/inspector/front-end/PropertiesSidebarPane.js +++ b/WebCore/inspector/front-end/PropertiesSidebarPane.js @@ -54,7 +54,7 @@ WebInspector.PropertiesSidebarPane.prototype = { var title = prototype.description; if (title.match(/Prototype$/)) title = title.replace(/Prototype$/, ""); - var section = new WebInspector.ObjectPropertiesSection(prototype, title, WebInspector.UIString("Prototype")); + var section = new WebInspector.ObjectPropertiesSection(prototype, title); self.sections.push(section); body.appendChild(section.element); } diff --git a/WebCore/inspector/front-end/RemoteObject.js b/WebCore/inspector/front-end/RemoteObject.js index 003d483..4d6736c 100644 --- a/WebCore/inspector/front-end/RemoteObject.js +++ b/WebCore/inspector/front-end/RemoteObject.js @@ -41,6 +41,11 @@ WebInspector.RemoteObject.fromPrimitiveValue = function(value) return new WebInspector.RemoteObject(null, typeof value, value); } +WebInspector.RemoteObject.fromLocalObject = function(value) +{ + return new WebInspector.LocalJSONObject(value); +} + WebInspector.RemoteObject.resolveNode = function(node, callback) { function mycallback(object) @@ -136,3 +141,62 @@ WebInspector.RemoteObjectProperty = function(name, value) this.name = name; this.value = value; } + +// The below is a wrapper around a local object that provides an interface comaptible +// with RemoteObject, to be used by the UI code (primarily ObjectPropertiesSection). +// Note that only JSON-compliant objects are currently supported, as there's no provision +// for traversing prototypes, extracting class names via constuctor, handling properties +// or functions. + +WebInspector.LocalJSONObject = function(value) +{ + this._value = value; +} + +WebInspector.LocalJSONObject.prototype = { + get description() + { + var type = this.type; + switch (type) { + case "array": + return "[" + this._value.length + "]"; + case "object": + return this.hasChildren ? "{...}" : "{ }"; + default: + return JSON.stringify(this._value); + } + }, + + get type() + { + if (this._value === null) + return "null"; + if (this._value instanceof Array) + return "array"; + return typeof this._value; + }, + + get hasChildren() + { + return typeof this._value === "object" && this._value !== null && Object.keys(this._value).length; + }, + + getOwnProperties: function(abbreviate, callback) + { + return this.getProperties(false, abbreviate, callback); + }, + + getProperties: function(ignoreHasOwnProperty, abbreviate, callback) + { + function buildProperty(propName) + { + return new WebInspector.RemoteObjectProperty(propName, new WebInspector.LocalJSONObject(this._value[propName])); + } + callback(Object.keys(this._value).map(buildProperty.bind(this))); + }, + + isError: function() + { + return false; + } +} diff --git a/WebCore/inspector/front-end/Resource.js b/WebCore/inspector/front-end/Resource.js index 1a2ce96..24af165 100644 --- a/WebCore/inspector/front-end/Resource.js +++ b/WebCore/inspector/front-end/Resource.js @@ -25,7 +25,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - WebInspector.Resource = function(identifier, url) { this.identifier = identifier; @@ -256,7 +255,7 @@ WebInspector.Resource.prototype = { this._checkWarnings(); this.dispatchEventToListeners("finished"); if (this._pendingContentCallbacks.length) - this._requestContent(); + this._innerRequestContent(); } }, @@ -288,6 +287,20 @@ WebInspector.Resource.prototype = { set cached(x) { this._cached = x; + if (x) + delete this._timing; + }, + + + get timing() + { + return this._timing; + }, + + set timing(x) + { + if (!this._cached) + this._timing = x; }, get mimeType() @@ -332,7 +345,7 @@ WebInspector.Resource.prototype = { this.category = WebInspector.resourceCategories.xhr; break; case WebInspector.Resource.Type.WebSocket: - this.category = WebInspector.resourceCategories.websocket; + this.category = WebInspector.resourceCategories.websockets; break; case WebInspector.Resource.Type.Other: default: @@ -603,12 +616,17 @@ WebInspector.Resource.prototype = { WebInspector.console.addMessage(msg); }, + get content() + { + return this._content; + }, + set content(content) { this._content = content; }, - getContent: function(callback) + requestContent: function(callback) { if (this._content) { callback(this._content, this._contentEncoded); @@ -616,7 +634,7 @@ WebInspector.Resource.prototype = { } this._pendingContentCallbacks.push(callback); if (this.finished) - this._requestContent(); + this._innerRequestContent(); }, get contentURL() @@ -629,7 +647,7 @@ WebInspector.Resource.prototype = { return "data:" + this.mimeType + (this._contentEncoded ? ";base64," : ",") + this._content; }, - _requestContent: function() + _innerRequestContent: function() { if (this._contentRequested) return; @@ -643,52 +661,10 @@ WebInspector.Resource.prototype = { for (var i = 0; i < callbacks.length; ++i) callbacks[i](this._content, this._contentEncoded); this._pendingContentCallbacks.length = 0; + delete this._contentRequested; } - WebInspector.ResourceManager.getContent(this, this._contentEncoded, onResourceContent.bind(this)); + WebInspector.ResourceManager.requestContent(this, this._contentEncoded, onResourceContent.bind(this)); } } WebInspector.Resource.prototype.__proto__ = WebInspector.Object.prototype; - -WebInspector.Resource.CompareByStartTime = function(a, b) -{ - return a.startTime - b.startTime; -} - -WebInspector.Resource.CompareByResponseReceivedTime = function(a, b) -{ - var aVal = a.responseReceivedTime; - var bVal = b.responseReceivedTime; - if (aVal === -1 ^ bVal === -1) - return bVal - aVal; - return aVal - bVal; -} - -WebInspector.Resource.CompareByEndTime = function(a, b) -{ - var aVal = a.endTime; - var bVal = b.endTime; - if (aVal === -1 ^ bVal === -1) - return bVal - aVal; - return aVal - bVal; -} - -WebInspector.Resource.CompareByDuration = function(a, b) -{ - return a.duration - b.duration; -} - -WebInspector.Resource.CompareByLatency = function(a, b) -{ - return a.latency - b.latency; -} - -WebInspector.Resource.CompareBySize = function(a, b) -{ - return a.resourceSize - b.resourceSize; -} - -WebInspector.Resource.CompareByTransferSize = function(a, b) -{ - return a.transferSize - b.transferSize; -} diff --git a/WebCore/inspector/front-end/ResourceManager.js b/WebCore/inspector/front-end/ResourceManager.js index 62273ee..bb34561 100644 --- a/WebCore/inspector/front-end/ResourceManager.js +++ b/WebCore/inspector/front-end/ResourceManager.js @@ -63,15 +63,11 @@ WebInspector.ResourceManager.prototype = { identifierForInitialRequest: function(identifier, url, loader) { var resource = this._createResource(identifier, url, loader); - if (loader.url === url) { - resource.isMainResource = true; - WebInspector.mainResource = resource; - } // It is important to bind resource url early (before scripts compile). this._bindResourceURL(resource); - WebInspector.panels.network.addResource(resource); + WebInspector.panels.network.refreshResource(resource); WebInspector.panels.audits.resourceStarted(resource); }, @@ -79,7 +75,8 @@ WebInspector.ResourceManager.prototype = { { var resource = new WebInspector.Resource(identifier, url); resource.loader = loader; - resource.documentURL = loader.url; + if (loader) + resource.documentURL = loader.url; this._resourcesById[identifier] = resource; return resource; @@ -104,7 +101,7 @@ WebInspector.ResourceManager.prototype = { resource.startTime = time; if (isRedirect) { - WebInspector.panels.network.addResource(resource); + WebInspector.panels.network.refreshResource(resource); WebInspector.panels.audits.resourceStarted(resource); } else WebInspector.panels.network.refreshResource(resource); @@ -228,9 +225,11 @@ WebInspector.ResourceManager.prototype = { var resource = this._createResource(null, cachedResource.url, cachedResource.loader); this._updateResourceWithCachedResource(resource, cachedResource); resource.cached = true; + resource.requestMethod = "GET"; resource.startTime = resource.responseReceivedTime = resource.endTime = time; + resource.finished = true; - WebInspector.panels.network.addResource(resource); + WebInspector.panels.network.refreshResource(resource); WebInspector.panels.audits.resourceStarted(resource); WebInspector.panels.audits.resourceFinished(resource); this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource); @@ -251,12 +250,20 @@ WebInspector.ResourceManager.prototype = { resource.type = WebInspector.Resource.Type[type]; resource.content = sourceString; + WebInspector.panels.storage.refreshResource(resource); WebInspector.panels.network.refreshResource(resource); }, - didCommitLoadForFrame: function(parentFrameId, loader) + didCommitLoadForFrame: function(frame, loader) { - this._resourceTreeModel.didCommitLoadForFrame(parentFrameId, loader); + this._resourceTreeModel.didCommitLoadForFrame(frame, loader); + if (!frame.parentId) { + var mainResource = this.resourceForURL(frame.url); + if (mainResource) { + WebInspector.mainResource = mainResource; + mainResource.isMainResource = true; + } + } }, frameDetachedFromParent: function(frameId) @@ -266,11 +273,9 @@ WebInspector.ResourceManager.prototype = { didCreateWebSocket: function(identifier, requestURL) { - this.identifierForInitialRequest(identifier, requestURL); - var resource = this._resourcesById[identifier]; + var resource = this._createResource(identifier, requestURL); resource.type = WebInspector.Resource.Type.WebSocket; - - WebInspector.panels.network.addResource(resource); + WebInspector.panels.network.refreshResource(resource); }, willSendWebSocketHandshakeRequest: function(identifier, time, request) @@ -314,12 +319,12 @@ WebInspector.ResourceManager.prototype = { _processCachedResources: function(mainFramePayload) { - var mainResource = this._addFramesRecursively(null, mainFramePayload); + var mainResource = this._addFramesRecursively(mainFramePayload); WebInspector.mainResource = mainResource; mainResource.isMainResource = true; }, - _addFramesRecursively: function(parentFrameId, framePayload) + _addFramesRecursively: function(framePayload) { var frameResource = this._createResource(null, framePayload.resource.url, framePayload.resource.loader); this._updateResourceWithRequest(frameResource, framePayload.resource.request); @@ -328,11 +333,11 @@ WebInspector.ResourceManager.prototype = { frameResource.finished = true; this._bindResourceURL(frameResource); - this._resourceTreeModel.addOrUpdateFrame(parentFrameId, framePayload.id, frameResource.displayName); + this._resourceTreeModel.addOrUpdateFrame(framePayload); this._resourceTreeModel.addResourceToFrame(framePayload.id, frameResource); for (var i = 0; framePayload.children && i < framePayload.children.length; ++i) - this._addFramesRecursively(framePayload.id, framePayload.children[i]); + this._addFramesRecursively(framePayload.children[i]); if (!framePayload.subresources) return; @@ -469,13 +474,9 @@ WebInspector.ResourceManager.existingResourceViewForResource = function(resource return resource._resourcesView; } -WebInspector.ResourceManager.getContent = function(resource, base64Encode, callback) +WebInspector.ResourceManager.requestContent = function(resource, base64Encode, callback) { - // FIXME: eventually, cached resources will have no identifiers. - if (resource.loader) - InspectorBackend.resourceContent(resource.loader.frameId, resource.url, base64Encode, callback); - else - InspectorBackend.getResourceContent(resource.identifier, base64Encode, callback); + InspectorBackend.resourceContent(resource.loader.frameId, resource.url, base64Encode, callback); } WebInspector.ResourceTreeModel = function() @@ -485,29 +486,29 @@ WebInspector.ResourceTreeModel = function() } WebInspector.ResourceTreeModel.prototype = { - addOrUpdateFrame: function(parentFrameId, frameId, displayName) + addOrUpdateFrame: function(frame) { - WebInspector.panels.storage.addOrUpdateFrame(parentFrameId, frameId, displayName); - var subframes = this._subframes[parentFrameId]; + var tmpResource = new WebInspector.Resource(null, frame.url); + WebInspector.panels.storage.addOrUpdateFrame(frame.parentId, frame.id, frame.name, tmpResource.displayName); + var subframes = this._subframes[frame.parentId]; if (!subframes) { subframes = {}; - this._subframes[parentFrameId || 0] = subframes; + this._subframes[frame.parentId || 0] = subframes; } - subframes[frameId] = true; + subframes[frame.id] = true; }, - didCommitLoadForFrame: function(parentFrameId, loader) + didCommitLoadForFrame: function(frame, loader) { - // parentFrameId === 0 is when main frame navigation happens. - this._clearChildFramesAndResources(parentFrameId ? loader.frameId : 0, loader.loaderId); + // frame.parentId === 0 is when main frame navigation happens. + this._clearChildFramesAndResources(frame.parentId ? frame.id : 0, loader.loaderId); - var tmpResource = new WebInspector.Resource(null, loader.url); - this.addOrUpdateFrame(parentFrameId, loader.frameId, tmpResource.displayName); + this.addOrUpdateFrame(frame); - var resourcesForFrame = this._resourcesByFrameId[loader.frameId]; + var resourcesForFrame = this._resourcesByFrameId[frame.id]; for (var i = 0; resourcesForFrame && i < resourcesForFrame.length; ++i) { WebInspector.resourceManager._bindResourceURL(resourcesForFrame[i]); - WebInspector.panels.storage.addResourceToFrame(loader.frameId, resourcesForFrame[i]); + WebInspector.panels.storage.addResourceToFrame(frame.id, resourcesForFrame[i]); } }, diff --git a/WebCore/inspector/front-end/ResourceView.js b/WebCore/inspector/front-end/ResourceView.js index ffb229d..3ca7fcc 100644 --- a/WebCore/inspector/front-end/ResourceView.js +++ b/WebCore/inspector/front-end/ResourceView.js @@ -147,7 +147,7 @@ WebInspector.ResourceView.prototype = { _selectTab: function() { - var preferredTab = WebInspector.applicationSettings.resourceViewTab; + var preferredTab = WebInspector.settings.resourceViewTab; if (this._headersVisible && this._cookiesView && preferredTab === "cookies") this._selectCookiesTab(); else if (this._headersVisible && (!this.hasContentTab() || preferredTab === "headers")) @@ -159,14 +159,14 @@ WebInspector.ResourceView.prototype = { _selectHeadersTab: function(updatePrefs) { if (updatePrefs) - WebInspector.applicationSettings.resourceViewTab = "headers"; + WebInspector.settings.resourceViewTab = "headers"; this.tabbedPane.selectTabById("headers"); }, selectContentTab: function(updatePrefs) { if (updatePrefs) - WebInspector.applicationSettings.resourceViewTab = "content"; + WebInspector.settings.resourceViewTab = "content"; this._innerSelectContentTab(); }, @@ -179,7 +179,7 @@ WebInspector.ResourceView.prototype = { _selectCookiesTab: function(updatePrefs) { if (updatePrefs) - WebInspector.applicationSettings.resourceViewTab = "cookies"; + WebInspector.settings.resourceViewTab = "cookies"; this.tabbedPane.selectTabById("cookies"); this._cookiesView.resize(); }, diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js deleted file mode 100644 index b35fc4b..0000000 --- a/WebCore/inspector/front-end/ResourcesPanel.js +++ /dev/null @@ -1,1938 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> - * - * 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE 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 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. - */ - -WebInspector.ResourcesPanel = function() -{ - WebInspector.Panel.call(this, "resources"); - this.resourceURLMap = {}; - this._items = []; - this._staleItems = []; - - this._createPanelEnabler(); - - this.viewsContainerElement = document.createElement("div"); - this.viewsContainerElement.id = "resource-views"; - this.element.appendChild(this.viewsContainerElement); - - this.createFilterPanel(); - this.createInterface(); - - this._createStatusbarButtons(); - this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), true); - - this.reset(); - this.filter(this.filterAllElement, false); - this.graphsTreeElement.children[0].select(); - this._resourceTrackingEnabled = false; - - this.sidebarElement.addEventListener("contextmenu", this._contextMenu.bind(this), true); -} - -WebInspector.ResourcesPanel.prototype = { - get toolbarItemLabel() - { - return WebInspector.UIString("Resources"); - }, - - get statusBarItems() - { - return [this.enableToggleButton.element, this.largerResourcesButton.element, this.sortingSelectElement]; - }, - - get categories() - { - return WebInspector.resourceCategories; - }, - - createItemTreeElement: function(item) - { - return new WebInspector.ResourceSidebarTreeElement(item); - }, - - createItemGraph: function(item) - { - return new WebInspector.ResourceGraph(item); - }, - - isCategoryVisible: function(categoryName) - { - return (this.itemsGraphsElement.hasStyleClass("filter-all") || this.itemsGraphsElement.hasStyleClass("filter-" + categoryName.toLowerCase())); - }, - - get items() - { - return this._items; - }, - - createInterface: function() - { - this.containerElement = document.createElement("div"); - this.containerElement.id = "resources-container"; - this.containerElement.addEventListener("scroll", this._updateDividersLabelBarPosition.bind(this), false); - this.element.appendChild(this.containerElement); - - this.createSidebar(this.containerElement, this.element); - this.sidebarElement.id = "resources-sidebar"; - this.populateSidebar(); - - this._containerContentElement = document.createElement("div"); - this._containerContentElement.id = "resources-container-content"; - this.containerElement.appendChild(this._containerContentElement); - - this.summaryBar = new WebInspector.SummaryBar(this.categories); - this.summaryBar.element.id = "resources-summary"; - this._containerContentElement.appendChild(this.summaryBar.element); - - this._timelineGrid = new WebInspector.TimelineGrid(); - this._containerContentElement.appendChild(this._timelineGrid.element); - this.itemsGraphsElement = this._timelineGrid.itemsGraphsElement; - }, - - createFilterPanel: function() - { - this.filterBarElement = document.createElement("div"); - this.filterBarElement.id = "resources-filter"; - this.filterBarElement.className = "scope-bar"; - this.element.appendChild(this.filterBarElement); - - function createFilterElement(category) - { - if (category === "all") - var label = WebInspector.UIString("All"); - else if (this.categories[category]) - var label = this.categories[category].title; - - var categoryElement = document.createElement("li"); - categoryElement.category = category; - categoryElement.addStyleClass(category); - categoryElement.appendChild(document.createTextNode(label)); - categoryElement.addEventListener("click", this._updateFilter.bind(this), false); - this.filterBarElement.appendChild(categoryElement); - - return categoryElement; - } - - this.filterAllElement = createFilterElement.call(this, "all"); - - // Add a divider - var dividerElement = document.createElement("div"); - dividerElement.addStyleClass("scope-bar-divider"); - this.filterBarElement.appendChild(dividerElement); - - for (var category in this.categories) - createFilterElement.call(this, category); - }, - - showCategory: function(category) - { - var filterClass = "filter-" + category.toLowerCase(); - this.itemsGraphsElement.addStyleClass(filterClass); - this.itemsTreeElement.childrenListElement.addStyleClass(filterClass); - }, - - hideCategory: function(category) - { - var filterClass = "filter-" + category.toLowerCase(); - this.itemsGraphsElement.removeStyleClass(filterClass); - this.itemsTreeElement.childrenListElement.removeStyleClass(filterClass); - }, - - filter: function(target, selectMultiple) - { - function unselectAll() - { - for (var i = 0; i < this.filterBarElement.childNodes.length; ++i) { - var child = this.filterBarElement.childNodes[i]; - if (!child.category) - continue; - - child.removeStyleClass("selected"); - this.hideCategory(child.category); - } - } - - if (target === this.filterAllElement) { - if (target.hasStyleClass("selected")) { - // We can't unselect All, so we break early here - return; - } - - // If All wasn't selected, and now is, unselect everything else. - unselectAll.call(this); - } else { - // Something other than All is being selected, so we want to unselect All. - if (this.filterAllElement.hasStyleClass("selected")) { - this.filterAllElement.removeStyleClass("selected"); - this.hideCategory("all"); - } - } - - if (!selectMultiple) { - // If multiple selection is off, we want to unselect everything else - // and just select ourselves. - unselectAll.call(this); - - target.addStyleClass("selected"); - this.showCategory(target.category); - return; - } - - if (target.hasStyleClass("selected")) { - // If selectMultiple is turned on, and we were selected, we just - // want to unselect ourselves. - target.removeStyleClass("selected"); - this.hideCategory(target.category); - } else { - // If selectMultiple is turned on, and we weren't selected, we just - // want to select ourselves. - target.addStyleClass("selected"); - this.showCategory(target.category); - } - }, - - _updateFilter: function(e) - { - var isMac = WebInspector.isMac(); - var selectMultiple = false; - if (isMac && e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey) - selectMultiple = true; - if (!isMac && e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey) - selectMultiple = true; - - this.filter(e.target, selectMultiple); - - // When we are updating our filtering, scroll to the top so we don't end up - // in blank graph under all the resources. - this.containerElement.scrollTop = 0; - - var searchField = document.getElementById("search"); - WebInspector.doPerformSearch(searchField.value, WebInspector.shortSearchWasForcedByKeyEvent, false, true); - }, - - _updateDividersLabelBarPosition: function() - { - const scrollTop = this.containerElement.scrollTop; - const offsetHeight = this.summaryBar.element.offsetHeight; - const dividersTop = (scrollTop < offsetHeight ? offsetHeight : scrollTop); - this._timelineGrid.setScrollAndDividerTop(scrollTop, dividersTop); - }, - - get needsRefresh() - { - return this._needsRefresh; - }, - - set needsRefresh(x) - { - if (this._needsRefresh === x) - return; - - this._needsRefresh = x; - - if (x) { - if (this.visible && !("_refreshTimeout" in this)) - this._refreshTimeout = setTimeout(this.refresh.bind(this), 500); - } else { - if ("_refreshTimeout" in this) { - clearTimeout(this._refreshTimeout); - delete this._refreshTimeout; - } - } - }, - - refreshIfNeeded: function() - { - if (this.needsRefresh) - this.refresh(); - }, - - resize: function() - { - WebInspector.Panel.prototype.resize.call(this); - - this.updateGraphDividersIfNeeded(); - }, - - invalidateAllItems: function() - { - this._staleItems = this._items.slice(); - }, - - get calculator() - { - return this._calculator; - }, - - set calculator(x) - { - if (!x || this._calculator === x) - return; - - this._calculator = x; - this._calculator.reset(); - - this._staleItems = this._items.slice(); - this.refresh(); - }, - - addItem: function(item) - { - this._items.push(item); - this.refreshItem(item); - }, - - removeItem: function(item) - { - this._items.remove(item, true); - - if (item._itemsTreeElement) { - this.itemsTreeElement.removeChild(item._itemsTreeElement); - this.itemsGraphsElement.removeChild(item._itemsTreeElement._itemGraph.graphElement); - } - - delete item._itemsTreeElement; - this.adjustScrollPosition(); - }, - - refreshItem: function(item) - { - this._staleItems.push(item); - this.needsRefresh = true; - }, - - revealAndSelectItem: function(item) - { - if (item._itemsTreeElement) { - item._itemsTreeElement.reveal(); - item._itemsTreeElement.select(true); - } - }, - - sortItems: function(sortingFunction) - { - var sortedElements = [].concat(this.itemsTreeElement.children); - sortedElements.sort(sortingFunction); - - var sortedElementsLength = sortedElements.length; - for (var i = 0; i < sortedElementsLength; ++i) { - var treeElement = sortedElements[i]; - if (treeElement === this.itemsTreeElement.children[i]) - continue; - - var wasSelected = treeElement.selected; - this.itemsTreeElement.removeChild(treeElement); - this.itemsTreeElement.insertChild(treeElement, i); - if (wasSelected) - treeElement.select(true); - - var graphElement = treeElement._itemGraph.graphElement; - this.itemsGraphsElement.insertBefore(graphElement, this.itemsGraphsElement.children[i]); - } - }, - - adjustScrollPosition: function() - { - // Prevent the container from being scrolled off the end. - if ((this.containerElement.scrollTop + this.containerElement.offsetHeight) > this.sidebarElement.offsetHeight) - this.containerElement.scrollTop = (this.sidebarElement.offsetHeight - this.containerElement.offsetHeight); - }, - - addEventDivider: function(divider) - { - this._timelineGrid.addEventDivider(divider); - }, - - hideEventDividers: function() - { - this._timelineGrid.hideEventDividers(); - }, - - showEventDividers: function() - { - this._timelineGrid.showEventDividers(); - }, - - populateSidebar: function() - { - this.timeGraphItem = new WebInspector.SidebarTreeElement("resources-time-graph-sidebar-item", WebInspector.UIString("Time")); - this.timeGraphItem.onselect = this._graphSelected.bind(this); - - var transferTimeCalculator = new WebInspector.ResourceTransferTimeCalculator(); - var transferDurationCalculator = new WebInspector.ResourceTransferDurationCalculator(); - - this.timeGraphItem.sortingOptions = [ - { name: WebInspector.UIString("Sort by Start Time"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByAscendingStartTime, calculator: transferTimeCalculator, optionName: "startTime" }, - { name: WebInspector.UIString("Sort by Response Time"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByAscendingResponseReceivedTime, calculator: transferTimeCalculator, optionName: "responseTime" }, - { name: WebInspector.UIString("Sort by End Time"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByAscendingEndTime, calculator: transferTimeCalculator, optionName: "endTime" }, - { name: WebInspector.UIString("Sort by Duration"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingDuration, calculator: transferDurationCalculator, optionName: "duration" }, - { name: WebInspector.UIString("Sort by Latency"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingLatency, calculator: transferDurationCalculator, optionName: "latency" }, - ]; - - this.timeGraphItem.isBarOpaqueAtLeft = false; - this.timeGraphItem.selectedSortingOptionIndex = 1; - - this.sizeGraphItem = new WebInspector.SidebarTreeElement("resources-size-graph-sidebar-item", WebInspector.UIString("Size")); - this.sizeGraphItem.onselect = this._graphSelected.bind(this); - - var transferSizeCalculator = new WebInspector.ResourceTransferSizeCalculator(); - this.sizeGraphItem.sortingOptions = [ - { name: WebInspector.UIString("Sort by Transfer Size"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingTransferSize, calculator: transferSizeCalculator, optionName: "transferSize" }, - { name: WebInspector.UIString("Sort by Size"), sortingFunction: WebInspector.ResourceSidebarTreeElement.CompareByDescendingSize, calculator: transferSizeCalculator, optionName: "size" }, - ]; - - this.sizeGraphItem.isBarOpaqueAtLeft = true; - this.sizeGraphItem.selectedSortingOptionIndex = 0; - - this.graphsTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("GRAPHS"), {}, true); - this.sidebarTree.appendChild(this.graphsTreeElement); - - this.graphsTreeElement.appendChild(this.timeGraphItem); - this.graphsTreeElement.appendChild(this.sizeGraphItem); - this.graphsTreeElement.expand(); - - this.itemsTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("RESOURCES"), {}, true); - this.sidebarTree.appendChild(this.itemsTreeElement); - - this.itemsTreeElement.expand(); - }, - - get resourceTrackingEnabled() - { - return this._resourceTrackingEnabled; - }, - - _createPanelEnabler: function() - { - var panelEnablerHeading = WebInspector.UIString("You need to enable resource tracking to use this panel."); - var panelEnablerDisclaimer = WebInspector.UIString("Enabling resource tracking will reload the page and make page loading slower."); - var panelEnablerButton = WebInspector.UIString("Enable resource tracking"); - - this.panelEnablerView = new WebInspector.PanelEnablerView("resources", panelEnablerHeading, panelEnablerDisclaimer, panelEnablerButton); - this.panelEnablerView.addEventListener("enable clicked", this._enableResourceTracking, this); - - this.element.appendChild(this.panelEnablerView.element); - - this.enableToggleButton = new WebInspector.StatusBarButton("", "enable-toggle-status-bar-item"); - this.enableToggleButton.addEventListener("click", this.toggleResourceTracking.bind(this), false); - }, - - _createStatusbarButtons: function() - { - this.largerResourcesButton = new WebInspector.StatusBarButton(WebInspector.UIString("Use small resource rows."), "resources-larger-resources-status-bar-item"); - - this.largerResourcesButton.toggled = WebInspector.applicationSettings.resourcesLargeRows; - if (!WebInspector.applicationSettings.resourcesLargeRows) - this._setLargerResources(WebInspector.applicationSettings.resourcesLargeRows); - this._loadSortOptions(); - - this.largerResourcesButton.addEventListener("click", this._toggleLargerResources.bind(this), false); - this.sortingSelectElement = document.createElement("select"); - this.sortingSelectElement.className = "status-bar-item"; - this.sortingSelectElement.addEventListener("change", this._changeSortingFunction.bind(this), false); - }, - - _loadSortOptions: function() - { - var newOptions = WebInspector.applicationSettings.resourcesSortOptions; - if (!newOptions) - return; - - this._loadSortOptionForGraph(this.timeGraphItem, newOptions.timeOption || "responseTime"); - this._loadSortOptionForGraph(this.sizeGraphItem, newOptions.sizeOption || "transferSize"); - }, - - _loadSortOptionForGraph: function(graphItem, newOptionName) - { - var sortingOptions = graphItem.sortingOptions; - for (var i = 0; i < sortingOptions.length; ++i) { - if (sortingOptions[i].optionName === newOptionName) { - graphItem.selectedSortingOptionIndex = i; - // Propagate the option change down to the currently selected option. - if (this._lastSelectedGraphTreeElement === graphItem) { - this._lastSelectedGraphTreeElement = null; - this._graphSelected(graphItem); - } - } - } - }, - - get mainResourceLoadTime() - { - return this._mainResourceLoadTime || -1; - }, - - set mainResourceLoadTime(x) - { - if (this._mainResourceLoadTime === x) - return; - - this._mainResourceLoadTime = x; - - // Update the dividers to draw the new line - this.updateGraphDividersIfNeeded(true); - }, - - get mainResourceDOMContentTime() - { - return this._mainResourceDOMContentTime || -1; - }, - - set mainResourceDOMContentTime(x) - { - if (this._mainResourceDOMContentTime === x) - return; - - this._mainResourceDOMContentTime = x; - - this.updateGraphDividersIfNeeded(true); - }, - - show: function() - { - WebInspector.Panel.prototype.show.call(this); - - this._updateDividersLabelBarPosition(); - this.refreshIfNeeded(); - - var visibleView = this.visibleView; - if (this.visibleResource) { - this.visibleView.headersVisible = true; - this.visibleView.show(this.viewsContainerElement); - } else if (visibleView) - visibleView.show(); - - // Hide any views that are visible that are not this panel's current visible view. - // This can happen when a ResourceView is visible in the Scripts panel then switched - // to the this panel. - var resourcesLength = this._resources.length; - for (var i = 0; i < resourcesLength; ++i) { - var resource = this._resources[i]; - var view = resource._resourcesView; - if (!view || view === visibleView) - continue; - view.visible = false; - } - }, - - get searchableViews() - { - var views = []; - - const visibleView = this.visibleView; - if (visibleView && visibleView.performSearch) - views.push(visibleView); - - var resourcesLength = this._resources.length; - for (var i = 0; i < resourcesLength; ++i) { - var resource = this._resources[i]; - if (!resource._itemsTreeElement || !resource._itemsTreeElement.selectable) - continue; - var resourceView = WebInspector.ResourceManager.resourceViewForResource(resource); - if (!resourceView.performSearch || resourceView === visibleView) - continue; - views.push(resourceView); - } - - return views; - }, - - get searchResultsSortFunction() - { - const resourceTreeElementSortFunction = this.sortingFunction; - - function sortFuction(a, b) - { - return resourceTreeElementSortFunction(a.resource._itemsTreeElement, b.resource._itemsTreeElement); - } - - return sortFuction; - }, - - searchMatchFound: function(view, matches) - { - view.resource._itemsTreeElement.searchMatches = matches; - }, - - searchCanceled: function(startingNewSearch) - { - WebInspector.Panel.prototype.searchCanceled.call(this, startingNewSearch); - - if (startingNewSearch || !this._resources) - return; - - for (var i = 0; i < this._resources.length; ++i) { - var resource = this._resources[i]; - if (resource._itemsTreeElement) - resource._itemsTreeElement.updateErrorsAndWarnings(); - } - }, - - performSearch: function(query) - { - for (var i = 0; i < this._resources.length; ++i) { - var resource = this._resources[i]; - if (resource._itemsTreeElement) - resource._itemsTreeElement.resetBubble(); - } - - WebInspector.Panel.prototype.performSearch.call(this, query); - }, - - get visibleView() - { - if (this.visibleResource) - return this.visibleResource._resourcesView; - return this._resourceTrackingEnabled ? null : this.panelEnablerView; - }, - - get sortingFunction() - { - return this._sortingFunction; - }, - - set sortingFunction(x) - { - this._sortingFunction = x; - this._sortResourcesIfNeeded(); - }, - - refresh: function() - { - this.needsRefresh = false; - - var staleItemsLength = this._staleItems.length; - - var boundariesChanged = false; - - for (var i = 0; i < staleItemsLength; ++i) { - var item = this._staleItems[i]; - if (!item._itemsTreeElement) { - // Create the timeline tree element and graph. - item._itemsTreeElement = this.createItemTreeElement(item); - item._itemsTreeElement._itemGraph = this.createItemGraph(item); - - this.itemsTreeElement.appendChild(item._itemsTreeElement); - this.itemsGraphsElement.appendChild(item._itemsTreeElement._itemGraph.graphElement); - } - - if (item._itemsTreeElement.refresh) - item._itemsTreeElement.refresh(); - - if (this.calculator.updateBoundaries(item)) - boundariesChanged = true; - } - - if (boundariesChanged) { - // The boundaries changed, so all item graphs are stale. - this._staleItems = this._items.slice(); - staleItemsLength = this._staleItems.length; - } - - - const isBarOpaqueAtLeft = this.sidebarTree.selectedTreeElement && this.sidebarTree.selectedTreeElement.isBarOpaqueAtLeft; - for (var i = 0; i < staleItemsLength; ++i) - this._staleItems[i]._itemsTreeElement._itemGraph.refresh(this.calculator, isBarOpaqueAtLeft); - - this._staleItems = []; - - this.updateGraphDividersIfNeeded(); - - this._sortResourcesIfNeeded(); - this._updateSummaryGraph(); - }, - - _updateSummaryGraph: function() - { - this.summaryBar.update(this._resources); - }, - - resourceTrackingWasEnabled: function() - { - this._resourceTrackingEnabled = true; - this.reset(); - this.restoreSidebarWidth(); - }, - - resourceTrackingWasDisabled: function() - { - this._resourceTrackingEnabled = false; - this.reset(); - }, - - reset: function() - { - this._popoverHelper.hidePopup(); - this.closeVisibleResource(); - - delete this.currentQuery; - this.searchCanceled(); - - if (this._resources) { - var resourcesLength = this._resources.length; - for (var i = 0; i < resourcesLength; ++i) { - var resource = this._resources[i]; - - resource.warnings = 0; - resource.errors = 0; - - delete resource._resourcesView; - } - } - - // Begin reset timeline - this.containerElement.scrollTop = 0; - - if (this._calculator) - this._calculator.reset(); - - if (this._items) { - var itemsLength = this._items.length; - for (var i = 0; i < itemsLength; ++i) { - var item = this._items[i]; - delete item._itemsTreeElement; - } - } - - this._items = []; - this._staleItems = []; - - this.itemsTreeElement.removeChildren(); - this.itemsGraphsElement.removeChildren(); - - this.updateGraphDividersIfNeeded(true); - // End reset timeline. - - this.mainResourceLoadTime = -1; - this.mainResourceDOMContentTime = -1; - - this.viewsContainerElement.removeChildren(); - - this.summaryBar.reset(); - - if (this._resourceTrackingEnabled) { - this.enableToggleButton.title = WebInspector.UIString("Resource tracking enabled. Click to disable."); - this.enableToggleButton.toggled = true; - this.largerResourcesButton.visible = true; - this.sortingSelectElement.removeStyleClass("hidden"); - this.panelEnablerView.visible = false; - } else { - this.enableToggleButton.title = WebInspector.UIString("Resource tracking disabled. Click to enable."); - this.enableToggleButton.toggled = false; - this.largerResourcesButton.visible = false; - this.sortingSelectElement.addStyleClass("hidden"); - this.panelEnablerView.visible = true; - } - this.resourceURLMap = {}; - }, - - addResource: function(resource) - { - this.resourceURLMap[resource.url] = resource; - this._resources.push(resource); - }, - - removeResource: function(resource) - { - if (this.visibleView === resource._resourcesView) - this.closeVisibleResource(); - - this.removeItem(resource); - - resource.warnings = 0; - resource.errors = 0; - - delete resource._resourcesView; - delete this.resourceURLMap[resource.url]; - }, - - addMessageToResource: function(resource, msg) - { - if (!resource) - return; - - switch (msg.level) { - case WebInspector.ConsoleMessage.MessageLevel.Warning: - resource.warnings += msg.repeatDelta; - break; - case WebInspector.ConsoleMessage.MessageLevel.Error: - resource.errors += msg.repeatDelta; - break; - } - - if (!this.currentQuery && resource._itemsTreeElement) - resource._itemsTreeElement.updateErrorsAndWarnings(); - - var view = WebInspector.ResourceManager.resourceViewForResource(resource); - if (view.addMessage) - view.addMessage(msg); - }, - - clearMessages: function() - { - var resourcesLength = this._resources.length; - for (var i = 0; i < resourcesLength; ++i) { - var resource = this._resources[i]; - resource.warnings = 0; - resource.errors = 0; - - if (!this.currentQuery && resource._itemsTreeElement) - resource._itemsTreeElement.updateErrorsAndWarnings(); - - var view = resource._resourcesView; - if (!view || !view.clearMessages) - continue; - view.clearMessages(); - } - }, - - refreshResource: function(resource) - { - this._recreateViewForResourceIfNeeded(resource); - this.refreshItem(resource); - }, - - _recreateViewForResourceIfNeeded: function(resource) - { - if (!resource || !resource._resourcesView) - return; - - if (WebInspector.ResourceManager.resourceViewTypeMatchesResource(resource, resource._resourcesView)) - return; - var newView = WebInspector.ResourceManager.createResourceView(resource); - - if (!this.currentQuery && resource._itemsTreeElement) - resource._itemsTreeElement.updateErrorsAndWarnings(); - - var oldView = resource._resourcesView; - var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null; - - resource._resourcesView.detach(); - delete resource._resourcesView; - - resource._resourcesView = newView; - - newView.headersVisible = oldView.headersVisible; - - if (oldViewParentNode) - newView.show(oldViewParentNode); - - WebInspector.panels.scripts.viewRecreated(oldView, newView); - }, - - canShowSourceLine: function(url, line) - { - return this._resourceTrackingEnabled && !!WebInspector.resourceForURL(url); - }, - - showSourceLine: function(url, line) - { - this.showResource(WebInspector.resourceForURL(url), line); - }, - - showResource: function(resource, line) - { - if (!resource) - return; - - this._popoverHelper.hidePopup(); - - this.containerElement.addStyleClass("viewing-resource"); - - if (this.visibleResource && this.visibleResource._resourcesView) - this.visibleResource._resourcesView.hide(); - - var view = WebInspector.ResourceManager.resourceViewForResource(resource); - view.headersVisible = true; - view.show(this.viewsContainerElement); - - if (line) { - view.selectContentTab(true); - if (view.revealLine) - view.revealLine(line); - if (view.highlightLine) - view.highlightLine(line); - } - - this.revealAndSelectItem(resource); - - this.visibleResource = resource; - - this.updateSidebarWidth(); - }, - - showView: function(view) - { - if (!view) - return; - this.showResource(view.resource); - }, - - closeVisibleResource: function() - { - this.containerElement.removeStyleClass("viewing-resource"); - this._updateDividersLabelBarPosition(); - - if (this.visibleResource && this.visibleResource._resourcesView) - this.visibleResource._resourcesView.hide(); - delete this.visibleResource; - - if (this._lastSelectedGraphTreeElement) - this._lastSelectedGraphTreeElement.select(true); - - this.updateSidebarWidth(); - }, - - _sortResourcesIfNeeded: function() - { - this.sortItems(this.sortingFunction); - }, - - updateGraphDividersIfNeeded: function(force) - { - var proceed = true; - if (!this.visible) { - this.needsRefresh = true; - proceed = false; - } else - proceed = this._timelineGrid.updateDividers(force, this.calculator); - - if (!proceed) - return; - - if (this.calculator.startAtZero || !this.calculator.computePercentageFromEventTime) { - // If our current sorting method starts at zero, that means it shows all - // resources starting at the same point, and so onLoad event and DOMContent - // event lines really wouldn't make much sense here, so don't render them. - // Additionally, if the calculator doesn't have the computePercentageFromEventTime - // function defined, we are probably sorting by size, and event times aren't relevant - // in this case. - return; - } - - this._timelineGrid.removeEventDividers(); - if (this.mainResourceLoadTime !== -1) { - var percent = this.calculator.computePercentageFromEventTime(this.mainResourceLoadTime); - - var loadDivider = document.createElement("div"); - loadDivider.className = "resources-event-divider resources-red-divider"; - - var loadDividerPadding = document.createElement("div"); - loadDividerPadding.className = "resources-event-divider-padding"; - loadDividerPadding.style.left = percent + "%"; - loadDividerPadding.title = WebInspector.UIString("Load event fired"); - loadDividerPadding.appendChild(loadDivider); - - this.addEventDivider(loadDividerPadding); - } - - if (this.mainResourceDOMContentTime !== -1) { - var percent = this.calculator.computePercentageFromEventTime(this.mainResourceDOMContentTime); - - var domContentDivider = document.createElement("div"); - domContentDivider.className = "resources-event-divider resources-blue-divider"; - - var domContentDividerPadding = document.createElement("div"); - domContentDividerPadding.className = "resources-event-divider-padding"; - domContentDividerPadding.style.left = percent + "%"; - domContentDividerPadding.title = WebInspector.UIString("DOMContent event fired"); - domContentDividerPadding.appendChild(domContentDivider); - - this.addEventDivider(domContentDividerPadding); - } - }, - - _graphSelected: function(treeElement) - { - if (this._lastSelectedGraphTreeElement) - this._lastSelectedGraphTreeElement.selectedSortingOptionIndex = this.sortingSelectElement.selectedIndex; - - this._lastSelectedGraphTreeElement = treeElement; - - this.sortingSelectElement.removeChildren(); - for (var i = 0; i < treeElement.sortingOptions.length; ++i) { - var sortingOption = treeElement.sortingOptions[i]; - var option = document.createElement("option"); - option.label = sortingOption.name; - option.sortingFunction = sortingOption.sortingFunction; - option.calculator = sortingOption.calculator; - option.optionName = sortingOption.optionName; - this.sortingSelectElement.appendChild(option); - } - - this.sortingSelectElement.selectedIndex = treeElement.selectedSortingOptionIndex; - this._doChangeSortingFunction(); - - this.closeVisibleResource(); - this.containerElement.scrollTop = 0; - - if (treeElement === this.sizeGraphItem) - this.hideEventDividers(); - else - this.showEventDividers(); - }, - - _toggleLargerResources: function() - { - if (!this.itemsTreeElement._childrenListNode) - return; - - WebInspector.applicationSettings.resourcesLargeRows = !WebInspector.applicationSettings.resourcesLargeRows; - this._setLargerResources(this.itemsTreeElement.smallChildren); - }, - - _setLargerResources: function(enabled) - { - this.largerResourcesButton.toggled = enabled; - this.itemsTreeElement.smallChildren = !enabled; - if (!enabled) { - this.itemsGraphsElement.addStyleClass("small"); - this.largerResourcesButton.title = WebInspector.UIString("Use large resource rows."); - this.adjustScrollPosition(); - } else { - this.itemsGraphsElement.removeStyleClass("small"); - this.largerResourcesButton.title = WebInspector.UIString("Use small resource rows."); - } - }, - - _changeSortingFunction: function() - { - this._doChangeSortingFunction(); - WebInspector.applicationSettings.resourcesSortOptions = {timeOption: this._selectedOptionNameForGraph(this.timeGraphItem), sizeOption: this._selectedOptionNameForGraph(this.sizeGraphItem)}; - }, - - _selectedOptionNameForGraph: function(graphItem) - { - return graphItem.sortingOptions[graphItem.selectedSortingOptionIndex].optionName; - }, - - _doChangeSortingFunction: function() - { - var selectedIndex = this.sortingSelectElement.selectedIndex; - if (this._lastSelectedGraphTreeElement) - this._lastSelectedGraphTreeElement.selectedSortingOptionIndex = selectedIndex; - var selectedOption = this.sortingSelectElement[selectedIndex]; - this.sortingFunction = selectedOption.sortingFunction; - this.calculator = this.summaryBar.calculator = selectedOption.calculator; - }, - - setSidebarWidth: function(width) - { - if (this.visibleResource) { - this.containerElement.style.width = width + "px"; - this.sidebarElement.style.removeProperty("width"); - } else { - this.sidebarElement.style.width = width + "px"; - this.containerElement.style.removeProperty("width"); - } - - this.sidebarResizeElement.style.left = (width - 3) + "px"; - }, - - updateMainViewWidth: function(width) - { - this.viewsContainerElement.style.left = width + "px"; - this._containerContentElement.style.left = width + "px"; - this.resize(); - }, - - _enableResourceTracking: function() - { - if (this._resourceTrackingEnabled) - return; - this.toggleResourceTracking(this.panelEnablerView.alwaysEnabled); - }, - - toggleResourceTracking: function(optionalAlways) - { - function callback(newState) { - if (newState) - WebInspector.panels.resources.resourceTrackingWasEnabled(); - else - WebInspector.panels.resources.resourceTrackingWasDisabled(); - } - - if (this._resourceTrackingEnabled) { - this.largerResourcesButton.visible = false; - this.sortingSelectElement.visible = false; - WebInspector.resources = {}; - this.resourceURLMap = {}; - InspectorBackend.setResourceTrackingEnabled(false, true, callback); - } else { - this.largerResourcesButton.visible = true; - this.sortingSelectElement.visible = true; - InspectorBackend.setResourceTrackingEnabled(true, !!optionalAlways, callback); - } - }, - - get _resources() - { - return this.items; - }, - - elementsToRestoreScrollPositionsFor: function() - { - return [ this.containerElement ]; - }, - - _getPopoverAnchor: function(element) - { - var anchor = element.enclosingNodeOrSelfWithClass("resources-graph-bar") || element.enclosingNodeOrSelfWithClass("resources-graph-label"); - if (!anchor) - return null; - var resource = anchor.parentElement.resource; - return resource && resource.timing ? anchor : null; - }, - - _showPopover: function(anchor) - { - var tableElement = document.createElement("table"); - var resource = anchor.parentElement.resource; - var rows = []; - - function addRow(title, start, end, color) - { - var row = {}; - row.title = title; - row.start = start; - row.end = end; - rows.push(row); - } - - if (resource.timing.proxyStart !== -1) - addRow(WebInspector.UIString("Proxy"), resource.timing.proxyStart, resource.timing.proxyEnd); - - if (resource.timing.dnsStart !== -1) { - addRow(WebInspector.UIString("DNS Lookup"), resource.timing.dnsStart, resource.timing.dnsEnd); - } - - if (resource.timing.connectStart !== -1) { - if (resource.connectionReused) - addRow(WebInspector.UIString("Blocking"), resource.timing.connectStart, resource.timing.connectEnd); - else { - var connectStart = resource.timing.connectStart; - // Connection includes DNS, subtract it here. - if (resource.timing.dnsStart !== -1) - connectStart += resource.timing.dnsEnd - resource.timing.dnsStart; - addRow(WebInspector.UIString("Connecting"), connectStart, resource.timing.connectEnd); - } - } - - if (resource.timing.sslStart !== -1) - addRow(WebInspector.UIString("SSL"), resource.timing.sslStart, resource.timing.sslEnd); - - var sendStart = resource.timing.sendStart; - if (resource.timing.sslStart !== -1) - sendStart += resource.timing.sslEnd - resource.timing.sslStart; - - addRow(WebInspector.UIString("Sending"), resource.timing.sendStart, resource.timing.sendEnd); - addRow(WebInspector.UIString("Waiting"), resource.timing.sendEnd, resource.timing.receiveHeadersEnd); - addRow(WebInspector.UIString("Receiving"), (resource.responseReceivedTime - resource.timing.requestTime) * 1000, (resource.endTime - resource.timing.requestTime) * 1000); - - const chartWidth = 200; - var total = (resource.endTime - resource.timing.requestTime) * 1000; - var scale = chartWidth / total; - - for (var i = 0; i < rows.length; ++i) { - var tr = document.createElement("tr"); - tableElement.appendChild(tr); - - var td = document.createElement("td"); - td.textContent = rows[i].title; - tr.appendChild(td); - - td = document.createElement("td"); - td.width = chartWidth + "px"; - - var row = document.createElement("div"); - row.className = "resource-timing-row"; - td.appendChild(row); - - var bar = document.createElement("span"); - bar.className = "resource-timing-bar"; - bar.style.left = scale * rows[i].start + "px"; - bar.style.right = scale * (total - rows[i].end) + "px"; - bar.style.backgroundColor = rows[i].color; - bar.textContent = "\u200B"; // Important for 0-time items to have 0 width. - row.appendChild(bar); - - var title = document.createElement("span"); - title.className = "resource-timing-bar-title"; - if (total - rows[i].end < rows[i].start) - title.style.right = (scale * (total - rows[i].end) + 3) + "px"; - else - title.style.left = (scale * rows[i].start + 3) + "px"; - title.textContent = Number.millisToString(rows[i].end - rows[i].start); - row.appendChild(title); - - tr.appendChild(td); - } - - var popover = new WebInspector.Popover(tableElement); - popover.show(anchor); - return popover; - }, - - hide: function() - { - WebInspector.Panel.prototype.hide.call(this); - this._popoverHelper.hidePopup(); - }, - - _contextMenu: function(event) - { - var contextMenu = new WebInspector.ContextMenu(); - var resourceTreeItem = event.target.enclosingNodeOrSelfWithClass("resource-sidebar-tree-item"); - var resource; - if (resourceTreeItem && resourceTreeItem.treeElement) - resource = resourceTreeItem.treeElement.representedObject; - - var needSeparator = false; - // createObjectURL is enabled conditionally, do not expose resource export if it's not available. - if (typeof window.createObjectURL === "function" && Preferences.resourceExportEnabled) { - if (resource) - contextMenu.appendItem(WebInspector.UIString("Export to HAR"), this._exportResource.bind(this, resource)); - contextMenu.appendItem(WebInspector.UIString("Export all to HAR"), this._exportAll.bind(this)); - needSeparator = true; - } - - if (resource && resource.category === WebInspector.resourceCategories.xhr) { - if (needSeparator) - contextMenu.appendSeparator(); - contextMenu.appendItem(WebInspector.UIString("Set XHR Breakpoint"), WebInspector.breakpointManager.createXHRBreakpoint.bind(WebInspector.breakpointManager, resource.url)); - } - - contextMenu.show(event); - }, - - _exportAll: function() - { - var harArchive = { - log: (new WebInspector.HARLog()).build() - } - offerFileForDownload(JSON.stringify(harArchive)); - }, - - _exportResource: function(resource) - { - var har = (new WebInspector.HAREntry(resource)).build(); - offerFileForDownload(JSON.stringify(har)); - } -} - -WebInspector.ResourcesPanel.prototype.__proto__ = WebInspector.Panel.prototype; - -WebInspector.ResourceBaseCalculator = function() -{ -} - -WebInspector.ResourceBaseCalculator.prototype = { - computeSummaryValues: function(items) - { - var total = 0; - var categoryValues = {}; - - var itemsLength = items.length; - for (var i = 0; i < itemsLength; ++i) { - var item = items[i]; - var value = this._value(item); - if (typeof value === "undefined") - continue; - if (!(item.category.name in categoryValues)) - categoryValues[item.category.name] = 0; - categoryValues[item.category.name] += value; - total += value; - } - - return {categoryValues: categoryValues, total: total}; - }, - - computeBarGraphPercentages: function(item) - { - return {start: 0, middle: 0, end: (this._value(item) / this.boundarySpan) * 100}; - }, - - computeBarGraphLabels: function(item) - { - const label = this.formatValue(this._value(item)); - return {left: label, right: label, tooltip: label}; - }, - - get boundarySpan() - { - return this.maximumBoundary - this.minimumBoundary; - }, - - updateBoundaries: function(item) - { - this.minimumBoundary = 0; - - var value = this._value(item); - if (typeof this.maximumBoundary === "undefined" || value > this.maximumBoundary) { - this.maximumBoundary = value; - return true; - } - return false; - }, - - reset: function() - { - delete this.minimumBoundary; - delete this.maximumBoundary; - }, - - _value: function(item) - { - return 0; - }, - - formatValue: function(value) - { - return value.toString(); - } -} - -WebInspector.ResourceTimeCalculator = function(startAtZero) -{ - WebInspector.ResourceBaseCalculator.call(this); - this.startAtZero = startAtZero; -} - -WebInspector.ResourceTimeCalculator.prototype = { - computeSummaryValues: function(resources) - { - var resourcesByCategory = {}; - var resourcesLength = resources.length; - for (var i = 0; i < resourcesLength; ++i) { - var resource = resources[i]; - if (!(resource.category.name in resourcesByCategory)) - resourcesByCategory[resource.category.name] = []; - resourcesByCategory[resource.category.name].push(resource); - } - - var earliestStart; - var latestEnd; - var categoryValues = {}; - for (var category in resourcesByCategory) { - resourcesByCategory[category].sort(WebInspector.Resource.CompareByTime); - categoryValues[category] = 0; - - var segment = {start: -1, end: -1}; - - var categoryResources = resourcesByCategory[category]; - var resourcesLength = categoryResources.length; - for (var i = 0; i < resourcesLength; ++i) { - var resource = categoryResources[i]; - if (resource.startTime === -1 || resource.endTime === -1) - continue; - - if (typeof earliestStart === "undefined") - earliestStart = resource.startTime; - else - earliestStart = Math.min(earliestStart, resource.startTime); - - if (typeof latestEnd === "undefined") - latestEnd = resource.endTime; - else - latestEnd = Math.max(latestEnd, resource.endTime); - - if (resource.startTime <= segment.end) { - segment.end = Math.max(segment.end, resource.endTime); - continue; - } - - categoryValues[category] += segment.end - segment.start; - - segment.start = resource.startTime; - segment.end = resource.endTime; - } - - // Add the last segment - categoryValues[category] += segment.end - segment.start; - } - - return {categoryValues: categoryValues, total: latestEnd - earliestStart}; - }, - - computeBarGraphPercentages: function(resource) - { - if (resource.startTime !== -1) - var start = ((resource.startTime - this.minimumBoundary) / this.boundarySpan) * 100; - else - var start = 0; - - if (resource.responseReceivedTime !== -1) - var middle = ((resource.responseReceivedTime - this.minimumBoundary) / this.boundarySpan) * 100; - else - var middle = (this.startAtZero ? start : 100); - - if (resource.endTime !== -1) - var end = ((resource.endTime - this.minimumBoundary) / this.boundarySpan) * 100; - else - var end = (this.startAtZero ? middle : 100); - - if (this.startAtZero) { - end -= start; - middle -= start; - start = 0; - } - - return {start: start, middle: middle, end: end}; - }, - - computePercentageFromEventTime: function(eventTime) - { - // This function computes a percentage in terms of the total loading time - // of a specific event. If startAtZero is set, then this is useless, and we - // want to return 0. - if (eventTime !== -1 && !this.startAtZero) - return ((eventTime - this.minimumBoundary) / this.boundarySpan) * 100; - - return 0; - }, - - computeBarGraphLabels: function(resource) - { - var rightLabel = ""; - if (resource.responseReceivedTime !== -1 && resource.endTime !== -1) - rightLabel = this.formatValue(resource.endTime - resource.responseReceivedTime); - - var hasLatency = resource.latency > 0; - if (hasLatency) - var leftLabel = this.formatValue(resource.latency); - else - var leftLabel = rightLabel; - - if (resource.timing) - return {left: leftLabel, right: rightLabel}; - - if (hasLatency && rightLabel) { - var total = this.formatValue(resource.duration); - var tooltip = WebInspector.UIString("%s latency, %s download (%s total)", leftLabel, rightLabel, total); - } else if (hasLatency) - var tooltip = WebInspector.UIString("%s latency", leftLabel); - else if (rightLabel) - var tooltip = WebInspector.UIString("%s download", rightLabel); - - if (resource.cached) - tooltip = WebInspector.UIString("%s (from cache)", tooltip); - return {left: leftLabel, right: rightLabel, tooltip: tooltip}; - }, - - updateBoundaries: function(resource) - { - var didChange = false; - - var lowerBound; - if (this.startAtZero) - lowerBound = 0; - else - lowerBound = this._lowerBound(resource); - - if (lowerBound !== -1 && (typeof this.minimumBoundary === "undefined" || lowerBound < this.minimumBoundary)) { - this.minimumBoundary = lowerBound; - didChange = true; - } - - var upperBound = this._upperBound(resource); - if (upperBound !== -1 && (typeof this.maximumBoundary === "undefined" || upperBound > this.maximumBoundary)) { - this.maximumBoundary = upperBound; - didChange = true; - } - - return didChange; - }, - - formatValue: function(value) - { - return Number.secondsToString(value, WebInspector.UIString); - }, - - _lowerBound: function(resource) - { - return 0; - }, - - _upperBound: function(resource) - { - return 0; - } -} - -WebInspector.ResourceTimeCalculator.prototype.__proto__ = WebInspector.ResourceBaseCalculator.prototype; - -WebInspector.ResourceTransferTimeCalculator = function() -{ - WebInspector.ResourceTimeCalculator.call(this, false); -} - -WebInspector.ResourceTransferTimeCalculator.prototype = { - formatValue: function(value) - { - return Number.secondsToString(value, WebInspector.UIString); - }, - - _lowerBound: function(resource) - { - return resource.startTime; - }, - - _upperBound: function(resource) - { - return resource.endTime; - } -} - -WebInspector.ResourceTransferTimeCalculator.prototype.__proto__ = WebInspector.ResourceTimeCalculator.prototype; - -WebInspector.ResourceTransferDurationCalculator = function() -{ - WebInspector.ResourceTimeCalculator.call(this, true); -} - -WebInspector.ResourceTransferDurationCalculator.prototype = { - formatValue: function(value) - { - return Number.secondsToString(value, WebInspector.UIString); - }, - - _upperBound: function(resource) - { - return resource.duration; - } -} - -WebInspector.ResourceTransferDurationCalculator.prototype.__proto__ = WebInspector.ResourceTimeCalculator.prototype; - -WebInspector.ResourceTransferSizeCalculator = function() -{ - WebInspector.ResourceBaseCalculator.call(this); -} - -WebInspector.ResourceTransferSizeCalculator.prototype = { - computeBarGraphLabels: function(resource) - { - var networkBytes = this._networkBytes(resource); - var resourceBytes = this._value(resource); - if (networkBytes && networkBytes !== resourceBytes) { - // Transferred size is not the same as reported resource length. - var networkBytesString = this.formatValue(networkBytes); - var left = networkBytesString; - var right = this.formatValue(resourceBytes); - var tooltip = right ? WebInspector.UIString("%s (%s transferred)", right, networkBytesString) : right; - } else { - var left = this.formatValue(resourceBytes); - var right = left; - var tooltip = left; - } - if (resource.cached) - tooltip = WebInspector.UIString("%s (from cache)", tooltip); - return {left: left, right: right, tooltip: tooltip}; - }, - - computeBarGraphPercentages: function(item) - { - const resourceBytesAsPercent = (this._value(item) / this.boundarySpan) * 100; - const networkBytesAsPercent = this._networkBytes(item) ? (this._networkBytes(item) / this.boundarySpan) * 100 : resourceBytesAsPercent; - return {start: 0, middle: networkBytesAsPercent, end: resourceBytesAsPercent}; - }, - - _value: function(resource) - { - return resource.resourceSize; - }, - - _networkBytes: function(resource) - { - return resource.transferSize; - }, - - formatValue: function(value) - { - return Number.bytesToString(value, WebInspector.UIString); - } -} - -WebInspector.ResourceTransferSizeCalculator.prototype.__proto__ = WebInspector.ResourceBaseCalculator.prototype; - -WebInspector.ResourceSidebarTreeElement = function(resource) -{ - this.resource = resource; - - this.createIconElement(); - - WebInspector.SidebarTreeElement.call(this, "resource-sidebar-tree-item", "", "", resource); - - this.refreshTitles(); -} - -WebInspector.ResourceSidebarTreeElement.prototype = { - onattach: function() - { - WebInspector.SidebarTreeElement.prototype.onattach.call(this); - - this._listItemNode.addStyleClass("resources-category-" + this.resource.category.name); - this._listItemNode.draggable = true; - - // FIXME: should actually add handler to parent, to be resolved via - // https://bugs.webkit.org/show_bug.cgi?id=30227 - this._listItemNode.addEventListener("dragstart", this.ondragstart.bind(this), false); - this.updateErrorsAndWarnings(); - }, - - onselect: function() - { - WebInspector.panels.resources.showResource(this.resource); - }, - - ondblclick: function(event) - { - InspectorBackend.openInInspectedWindow(this.resource.url); - }, - - ondragstart: function(event) { - event.dataTransfer.setData("text/plain", this.resource.url); - event.dataTransfer.setData("text/uri-list", this.resource.url + "\r\n"); - event.dataTransfer.effectAllowed = "copy"; - return true; - }, - - get mainTitle() - { - return this.resource.displayName; - }, - - set mainTitle(x) - { - // Do nothing. - }, - - get subtitle() - { - var subtitle = this.resource.displayDomain; - - if (this.resource.path && this.resource.lastPathComponent) { - var lastPathComponentIndex = this.resource.path.lastIndexOf("/" + this.resource.lastPathComponent); - if (lastPathComponentIndex != -1) - subtitle += this.resource.path.substring(0, lastPathComponentIndex); - } - - return subtitle; - }, - - set subtitle(x) - { - // Do nothing. - }, - - get selectable() - { - return WebInspector.panels.resources.isCategoryVisible(this.resource.category.name); - }, - - createIconElement: function() - { - var previousIconElement = this.iconElement; - - if (this.resource.category === WebInspector.resourceCategories.images) { - var previewImage = document.createElement("img"); - previewImage.className = "image-resource-icon-preview"; - - function onResourceContent() - { - previewImage.src = this.resource.contentURL; - } - if (Preferences.useDataURLForResourceImageIcons) - this.resource.getContent(onResourceContent.bind(this)); - else - previewImage.src = this.resource.url; - - this.iconElement = document.createElement("div"); - this.iconElement.className = "icon"; - this.iconElement.appendChild(previewImage); - } else { - this.iconElement = document.createElement("img"); - this.iconElement.className = "icon"; - } - - if (previousIconElement) - previousIconElement.parentNode.replaceChild(this.iconElement, previousIconElement); - }, - - refresh: function() - { - this.refreshTitles(); - - if (!this._listItemNode.hasStyleClass("resources-category-" + this.resource.category.name)) { - this._listItemNode.removeMatchingStyleClasses("resources-category-\\w+"); - this._listItemNode.addStyleClass("resources-category-" + this.resource.category.name); - - this.createIconElement(); - } - - this.tooltip = this.resource.url; - }, - - resetBubble: function() - { - this.bubbleText = ""; - this.bubbleElement.removeStyleClass("search-matches"); - this.bubbleElement.removeStyleClass("warning"); - this.bubbleElement.removeStyleClass("error"); - }, - - set searchMatches(matches) - { - this.resetBubble(); - - if (!matches) - return; - - this.bubbleText = matches; - this.bubbleElement.addStyleClass("search-matches"); - }, - - updateErrorsAndWarnings: function() - { - this.resetBubble(); - - if (this.resource.warnings || this.resource.errors) - this.bubbleText = (this.resource.warnings + this.resource.errors); - - if (this.resource.warnings) - this.bubbleElement.addStyleClass("warning"); - - if (this.resource.errors) - this.bubbleElement.addStyleClass("error"); - } -} - -WebInspector.ResourceSidebarTreeElement.CompareByAscendingStartTime = function(a, b) -{ - return WebInspector.Resource.CompareByStartTime(a.resource, b.resource) - || WebInspector.Resource.CompareByEndTime(a.resource, b.resource) - || WebInspector.Resource.CompareByResponseReceivedTime(a.resource, b.resource); -} - -WebInspector.ResourceSidebarTreeElement.CompareByAscendingResponseReceivedTime = function(a, b) -{ - return WebInspector.Resource.CompareByResponseReceivedTime(a.resource, b.resource) - || WebInspector.Resource.CompareByStartTime(a.resource, b.resource) - || WebInspector.Resource.CompareByEndTime(a.resource, b.resource); -} - -WebInspector.ResourceSidebarTreeElement.CompareByAscendingEndTime = function(a, b) -{ - return WebInspector.Resource.CompareByEndTime(a.resource, b.resource) - || WebInspector.Resource.CompareByStartTime(a.resource, b.resource) - || WebInspector.Resource.CompareByResponseReceivedTime(a.resource, b.resource); -} - -WebInspector.ResourceSidebarTreeElement.CompareByDescendingDuration = function(a, b) -{ - return -1 * WebInspector.Resource.CompareByDuration(a.resource, b.resource); -} - -WebInspector.ResourceSidebarTreeElement.CompareByDescendingLatency = function(a, b) -{ - return -1 * WebInspector.Resource.CompareByLatency(a.resource, b.resource); -} - -WebInspector.ResourceSidebarTreeElement.CompareByDescendingSize = function(a, b) -{ - return -1 * WebInspector.Resource.CompareBySize(a.resource, b.resource); -} - -WebInspector.ResourceSidebarTreeElement.CompareByDescendingTransferSize = function(a, b) -{ - return -1 * WebInspector.Resource.CompareByTransferSize(a.resource, b.resource); -} - -WebInspector.ResourceSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; - -WebInspector.ResourceGraph = function(resource) -{ - this.resource = resource; - - this._graphElement = document.createElement("div"); - this._graphElement.className = "resources-graph-side"; - this._graphElement.addEventListener("mouseover", this.refreshLabelPositions.bind(this), false); - - if (this.resource.cached) - this._graphElement.addStyleClass("resource-cached"); - - this._barAreaElement = document.createElement("div"); - this._barAreaElement.className = "resources-graph-bar-area hidden"; - this._barAreaElement.resource = resource; - this._graphElement.appendChild(this._barAreaElement); - - this._barLeftElement = document.createElement("div"); - this._barLeftElement.className = "resources-graph-bar waiting"; - this._barAreaElement.appendChild(this._barLeftElement); - - this._barRightElement = document.createElement("div"); - this._barRightElement.className = "resources-graph-bar"; - this._barAreaElement.appendChild(this._barRightElement); - - this._labelLeftElement = document.createElement("div"); - this._labelLeftElement.className = "resources-graph-label waiting"; - this._barAreaElement.appendChild(this._labelLeftElement); - - this._labelRightElement = document.createElement("div"); - this._labelRightElement.className = "resources-graph-label"; - this._barAreaElement.appendChild(this._labelRightElement); - - this._graphElement.addStyleClass("resources-category-" + resource.category.name); -} - -WebInspector.ResourceGraph.prototype = { - get graphElement() - { - return this._graphElement; - }, - - refreshLabelPositions: function() - { - this._labelLeftElement.style.removeProperty("left"); - this._labelLeftElement.style.removeProperty("right"); - this._labelLeftElement.removeStyleClass("before"); - this._labelLeftElement.removeStyleClass("hidden"); - - this._labelRightElement.style.removeProperty("left"); - this._labelRightElement.style.removeProperty("right"); - this._labelRightElement.removeStyleClass("after"); - this._labelRightElement.removeStyleClass("hidden"); - - const labelPadding = 10; - const barRightElementOffsetWidth = this._barRightElement.offsetWidth; - const barLeftElementOffsetWidth = this._barLeftElement.offsetWidth; - - if (this._isBarOpaqueAtLeft) { - var leftBarWidth = barLeftElementOffsetWidth - labelPadding; - var rightBarWidth = (barRightElementOffsetWidth - barLeftElementOffsetWidth) - labelPadding; - } else { - var leftBarWidth = (barLeftElementOffsetWidth - barRightElementOffsetWidth) - labelPadding; - var rightBarWidth = barRightElementOffsetWidth - labelPadding; - } - - const labelLeftElementOffsetWidth = this._labelLeftElement.offsetWidth; - const labelRightElementOffsetWidth = this._labelRightElement.offsetWidth; - - const labelBefore = (labelLeftElementOffsetWidth > leftBarWidth); - const labelAfter = (labelRightElementOffsetWidth > rightBarWidth); - const graphElementOffsetWidth = this._graphElement.offsetWidth; - - if (labelBefore && (graphElementOffsetWidth * (this._percentages.start / 100)) < (labelLeftElementOffsetWidth + 10)) - var leftHidden = true; - - if (labelAfter && (graphElementOffsetWidth * ((100 - this._percentages.end) / 100)) < (labelRightElementOffsetWidth + 10)) - var rightHidden = true; - - if (barLeftElementOffsetWidth == barRightElementOffsetWidth) { - // The left/right label data are the same, so a before/after label can be replaced by an on-bar label. - if (labelBefore && !labelAfter) - leftHidden = true; - else if (labelAfter && !labelBefore) - rightHidden = true; - } - - if (labelBefore) { - if (leftHidden) - this._labelLeftElement.addStyleClass("hidden"); - this._labelLeftElement.style.setProperty("right", (100 - this._percentages.start) + "%"); - this._labelLeftElement.addStyleClass("before"); - } else { - this._labelLeftElement.style.setProperty("left", this._percentages.start + "%"); - this._labelLeftElement.style.setProperty("right", (100 - this._percentages.middle) + "%"); - } - - if (labelAfter) { - if (rightHidden) - this._labelRightElement.addStyleClass("hidden"); - this._labelRightElement.style.setProperty("left", this._percentages.end + "%"); - this._labelRightElement.addStyleClass("after"); - } else { - this._labelRightElement.style.setProperty("left", this._percentages.middle + "%"); - this._labelRightElement.style.setProperty("right", (100 - this._percentages.end) + "%"); - } - }, - - refresh: function(calculator, isBarOpaqueAtLeft) - { - var percentages = calculator.computeBarGraphPercentages(this.resource); - var labels = calculator.computeBarGraphLabels(this.resource); - - this._percentages = percentages; - - this._barAreaElement.removeStyleClass("hidden"); - - if (!this._graphElement.hasStyleClass("resources-category-" + this.resource.category.name)) { - this._graphElement.removeMatchingStyleClasses("resources-category-\\w+"); - this._graphElement.addStyleClass("resources-category-" + this.resource.category.name); - } - - this._barLeftElement.style.setProperty("left", percentages.start + "%"); - this._barRightElement.style.setProperty("right", (100 - percentages.end) + "%"); - - if (!isBarOpaqueAtLeft) { - this._barLeftElement.style.setProperty("right", (100 - percentages.end) + "%"); - this._barRightElement.style.setProperty("left", percentages.middle + "%"); - - if (this._isBarOpaqueAtLeft != isBarOpaqueAtLeft) { - this._barLeftElement.addStyleClass("waiting"); - this._barRightElement.removeStyleClass("waiting-right"); - this._labelLeftElement.addStyleClass("waiting"); - this._labelRightElement.removeStyleClass("waiting-right"); - } - } else { - this._barLeftElement.style.setProperty("right", (100 - percentages.middle) + "%"); - this._barRightElement.style.setProperty("left", percentages.start + "%"); - - if (this._isBarOpaqueAtLeft != isBarOpaqueAtLeft) { - this._barLeftElement.removeStyleClass("waiting"); - this._barRightElement.addStyleClass("waiting-right"); - this._labelLeftElement.removeStyleClass("waiting"); - this._labelRightElement.addStyleClass("waiting-right"); - } - } - - this._isBarOpaqueAtLeft = isBarOpaqueAtLeft; - - this._labelLeftElement.textContent = labels.left; - this._labelRightElement.textContent = labels.right; - - var tooltip = (labels.tooltip || ""); - this._barLeftElement.title = tooltip; - this._labelLeftElement.title = tooltip; - this._labelRightElement.title = tooltip; - this._barRightElement.title = tooltip; - - if (this.resource.cached && !this._graphElement.hasStyleClass("resource-cached")) - this._graphElement.addStyleClass("resource-cached"); - } -} diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js index 8125c1e..66260f9 100644 --- a/WebCore/inspector/front-end/ScriptsPanel.js +++ b/WebCore/inspector/front-end/ScriptsPanel.js @@ -376,7 +376,7 @@ WebInspector.ScriptsPanel.prototype = { InjectedScriptAccess.get(callFrame.worldId).evaluateInCallFrame(callFrame.id, code, objectGroup, evalCallback); }, - debuggerPaused: function(details) + debuggerPaused: function(callFrames) { WebInspector.breakpointManager.removeOneTimeBreakpoint(); this._paused = true; @@ -385,8 +385,8 @@ WebInspector.ScriptsPanel.prototype = { this._updateDebuggerButtons(); - this.sidebarPanes.callstack.update(details.callFrames, this._sourceIDMap); - this.sidebarPanes.callstack.selectedCallFrame = details.callFrames[0]; + this.sidebarPanes.callstack.update(callFrames, this._sourceIDMap); + this.sidebarPanes.callstack.selectedCallFrame = callFrames[0]; WebInspector.currentPanel = this; window.focus(); @@ -608,7 +608,7 @@ WebInspector.ScriptsPanel.prototype = { var url = scriptOrResource.url || scriptOrResource.sourceURL; if (url && !options.initialLoad) - WebInspector.applicationSettings.lastViewedScriptFile = url; + WebInspector.settings.lastViewedScriptFile = url; if (!options.fromBackForwardAction) { var oldIndex = this._currentBackForwardIndex; @@ -702,16 +702,22 @@ WebInspector.ScriptsPanel.prototype = { else script.filesSelectOption = option; - // Call _showScriptOrResource if the option we just appended ended up being selected. - // This will happen for the first item added to the menu. - if (select.options[select.selectedIndex] === option) + if (select.options[select.selectedIndex] === option) { + // Call _showScriptOrResource if the option we just appended ended up being selected. + // This will happen for the first item added to the menu. this._showScriptOrResource(option.representedObject, {initialLoad: true}); - else { - // if not first item, check to see if this was the last viewed + } else { + // If not first item, check to see if this was the last viewed var url = option.representedObject.url || option.representedObject.sourceURL; - var lastURL = WebInspector.applicationSettings.lastViewedScriptFile; - if (url && url === lastURL) - this._showScriptOrResource(option.representedObject, {initialLoad: true}); + var lastURL = WebInspector.settings.lastViewedScriptFile; + if (url && url === lastURL) { + // For resources containing multiple <script> tags, we first report them separately and + // then glue them all together. They all share url and there is no need to show them all one + // by one. + var isResource = !!option.representedObject.url; + if (isResource || !this.visibleView || !this.visibleView.script || this.visibleView.script.sourceURL !== url) + this._showScriptOrResource(option.representedObject, {initialLoad: true}); + } } if (script.worldType === WebInspector.Script.WorldType.EXTENSIONS_WORLD) diff --git a/WebCore/inspector/front-end/Settings.js b/WebCore/inspector/front-end/Settings.js index 3fb81f5..4fd0c83 100644 --- a/WebCore/inspector/front-end/Settings.js +++ b/WebCore/inspector/front-end/Settings.js @@ -45,7 +45,7 @@ var Preferences = { onlineDetectionEnabled: true, nativeInstrumentationEnabled: false, resourceExportEnabled: false, - networkPanelEnabled: false, + fileSystemEnabled: false, useDataURLForResourceImageIcons: true } @@ -64,11 +64,15 @@ WebInspector.Settings = function() this.installApplicationSetting("lastActivePanel", "elements"); this.installProjectSetting("breakpoints", {}); + this.installProjectSetting("nativeBreakpoints", []); } WebInspector.Settings.prototype = { installApplicationSetting: function(key, defaultValue) { + if (key in this) + return; + this.__defineGetter__(key, this._get.bind(this, key, defaultValue)); this.__defineSetter__(key, this._set.bind(this, key)); }, @@ -79,6 +83,14 @@ WebInspector.Settings.prototype = { this.__defineSetter__(key, this._setProjectSetting.bind(this, key)); }, + inspectedURLChanged: function(url) + { + var fragmentIndex = url.indexOf("#"); + if (fragmentIndex !== -1) + url = url.substring(0, fragmentIndex); + this._inspectedURL = url; + }, + _get: function(key, defaultValue) { if (key in window.localStorage) { @@ -108,11 +120,7 @@ WebInspector.Settings.prototype = { _formatProjectKey: function(key) { - var url = this._mainResourceURL; - var fragmentIndex = url.indexOf("#"); - if (fragmentIndex !== -1) - url = url.substring(0, fragmentIndex); - return key + "." + url; + return key + ":" + this._inspectedURL; } } diff --git a/WebCore/inspector/front-end/SourceView.js b/WebCore/inspector/front-end/SourceView.js index bfdc058..c7a35f7 100644 --- a/WebCore/inspector/front-end/SourceView.js +++ b/WebCore/inspector/front-end/SourceView.js @@ -84,7 +84,7 @@ WebInspector.SourceView.prototype = { this.attach(); delete this._frameNeedsSetup; - this.resource.getContent(this._contentLoaded.bind(this)); + this.resource.requestContent(this._contentLoaded.bind(this)); }, hasContentTab: function() diff --git a/WebCore/inspector/front-end/StoragePanel.js b/WebCore/inspector/front-end/StoragePanel.js index 2fa54c2..eb4eabb 100644 --- a/WebCore/inspector/front-end/StoragePanel.js +++ b/WebCore/inspector/front-end/StoragePanel.js @@ -31,37 +31,37 @@ WebInspector.StoragePanel = function(database) { WebInspector.Panel.call(this, "storage"); + WebInspector.settings.installApplicationSetting("resourcesLastSelectedItem", {}); + this.createSidebar(); this.sidebarElement.addStyleClass("outline-disclosure filter-all children small"); this.sidebarTreeElement.removeStyleClass("sidebar-tree"); - if (Preferences.networkPanelEnabled) { - this.resourcesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Frames"), "frame-storage-tree-item"); - this.sidebarTree.appendChild(this.resourcesListTreeElement); - this.resourcesListTreeElement.expand(); - this._treeElementForFrameId = {}; - } + this.resourcesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Frames"), "Frames", "frame-storage-tree-item"); + this.sidebarTree.appendChild(this.resourcesListTreeElement); + this._treeElementForFrameId = {}; - this.databasesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Databases"), "database-storage-tree-item"); + this.databasesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Databases"), "Databases", "database-storage-tree-item"); this.sidebarTree.appendChild(this.databasesListTreeElement); - this.databasesListTreeElement.expand(); - this.localStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Local Storage"), "domstorage-storage-tree-item local-storage"); + this.localStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Local Storage"), "LocalStorage", "domstorage-storage-tree-item local-storage"); this.sidebarTree.appendChild(this.localStorageListTreeElement); - this.localStorageListTreeElement.expand(); - this.sessionStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Session Storage"), "domstorage-storage-tree-item session-storage"); + this.sessionStorageListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Session Storage"), "SessionStorage", "domstorage-storage-tree-item session-storage"); this.sidebarTree.appendChild(this.sessionStorageListTreeElement); - this.sessionStorageListTreeElement.expand(); - this.cookieListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Cookies"), "cookie-storage-tree-item"); + this.cookieListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Cookies"), "Cookies", "cookie-storage-tree-item"); this.sidebarTree.appendChild(this.cookieListTreeElement); - this.cookieListTreeElement.expand(); - - this.applicationCacheListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Application Cache"), "application-cache-storage-tree-item"); + + this.applicationCacheListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Application Cache"), "ApplicationCache", "application-cache-storage-tree-item"); this.sidebarTree.appendChild(this.applicationCacheListTreeElement); - this.applicationCacheListTreeElement.expand(); + if (Preferences.fileSystemEnabled) { + this.fileSystemListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("File System"), "FileSystem", "file-system-storage-tree-item"); + this.sidebarTree.appendChild(this.fileSystemListTreeElement); + this.fileSystemListTreeElement.expand(); + } + this.storageViews = document.createElement("div"); this.storageViews.id = "storage-views"; this.element.appendChild(this.storageViews); @@ -72,12 +72,17 @@ WebInspector.StoragePanel = function(database) this._databases = []; this._domStorage = []; this._cookieViews = {}; + this._origins = {}; + this._domains = {}; + + this.sidebarElement.addEventListener("mousemove", this._onmousemove.bind(this), false); + this.sidebarElement.addEventListener("mouseout", this._onmouseout.bind(this), false); } WebInspector.StoragePanel.prototype = { get toolbarItemLabel() { - return Preferences.networkPanelEnabled ? WebInspector.UIString("Resources") : WebInspector.UIString("Storage"); + return WebInspector.UIString("Resources"); }, get statusBarItems() @@ -85,8 +90,48 @@ WebInspector.StoragePanel.prototype = { return [this.storageViewStatusBarItemsContainer]; }, + elementsToRestoreScrollPositionsFor: function() + { + return [this.sidebarElement]; + }, + + show: function() + { + WebInspector.Panel.prototype.show.call(this); + + if (this.visibleView instanceof WebInspector.ResourceView) { + // SourceViews are shared between the panels. + this.visibleView.headersVisible = false; + this.visibleView.show(this.storageViews); + } + + if (this._initializedDefaultSelection) + return; + + this._initializedDefaultSelection = true; + var itemURL = WebInspector.settings.resourcesLastSelectedItem; + if (itemURL) { + for (var treeElement = this.sidebarTree.children[0]; treeElement; treeElement = treeElement.traverseNextTreeElement(false, this.sidebarTree, true)) { + if (treeElement.itemURL === itemURL) { + treeElement.select(); + treeElement.reveal(); + return; + } + } + } + this._initDefaultSelection(); + }, + + _initDefaultSelection: function() + { + if (WebInspector.mainResource && this.resourcesListTreeElement && this.resourcesListTreeElement.expanded) + this.showResource(WebInspector.mainResource); + }, + reset: function() { + this._origins = {}; + this._domains = {}; for (var i = 0; i < this._databases.length; ++i) { var database = this._databases[i]; delete database._tableViews; @@ -102,7 +147,9 @@ WebInspector.StoragePanel.prototype = { this._domStorage = []; this._cookieViews = {}; - + + this._fileSystemView = null; + this._applicationCacheView = null; delete this._cachedApplicationCacheViewStatus; @@ -111,7 +158,8 @@ WebInspector.StoragePanel.prototype = { this.sessionStorageListTreeElement.removeChildren(); this.cookieListTreeElement.removeChildren(); this.applicationCacheListTreeElement.removeChildren(); - + if (Preferences.fileSystemEnabled) + this.fileSystemListTreeElement.removeChildren(); this.storageViews.removeChildren(); this.storageViewStatusBarItemsContainer.removeChildren(); @@ -120,11 +168,11 @@ WebInspector.StoragePanel.prototype = { this.sidebarTree.selectedTreeElement.deselect(); }, - addOrUpdateFrame: function(parentFrameId, frameId, displayName) + addOrUpdateFrame: function(parentFrameId, frameId, title, subtitle) { var frameTreeElement = this._treeElementForFrameId[frameId]; if (frameTreeElement) { - frameTreeElement.displayName = displayName; + frameTreeElement.setTitles(title, subtitle); return; } @@ -134,7 +182,7 @@ WebInspector.StoragePanel.prototype = { return; } - var frameTreeElement = new WebInspector.FrameTreeElement(this, frameId, displayName); + var frameTreeElement = new WebInspector.FrameTreeElement(this, frameId, title, subtitle); this._treeElementForFrameId[frameId] = frameTreeElement; // Insert in the alphabetical order, first frames, then resources. @@ -145,7 +193,7 @@ WebInspector.StoragePanel.prototype = { parentTreeElement.insertChild(frameTreeElement, i); return; } - if (child.displayName.localeCompare(frameTreeElement.displayName) > 0) { + if (child.nameForSorting.localeCompare(frameTreeElement.nameForSorting) > 0) { parentTreeElement.insertChild(frameTreeElement, i); return; } @@ -165,6 +213,11 @@ WebInspector.StoragePanel.prototype = { addResourceToFrame: function(frameId, resource) { + this.addDocumentURL(resource.documentURL); + + if (resource.statusCode >= 301 && resource.statusCode <= 303) + return; + var frameTreeElement = this._treeElementForFrameId[frameId]; if (!frameTreeElement) { // This is a frame's main resource, it will be retained @@ -197,6 +250,16 @@ WebInspector.StoragePanel.prototype = { frameTreeElement.removeChildren(); }, + refreshResource: function(resource) + { + // FIXME: do not add XHR in the first place based on the native instrumentation. + if (resource.type === WebInspector.Resource.Type.XHR) { + var resourceTreeElement = this._findTreeElementForResource(resource); + if (resourceTreeElement) + resourceTreeElement.parent.removeChild(resourceTreeElement); + } + }, + addDatabase: function(database) { this._databases.push(database); @@ -205,11 +268,33 @@ WebInspector.StoragePanel.prototype = { database._databasesTreeElement = databaseTreeElement; this.databasesListTreeElement.appendChild(databaseTreeElement); }, - - addCookieDomain: function(domain) + + addDocumentURL: function(url) { - var cookieDomainTreeElement = new WebInspector.CookieTreeElement(this, domain); - this.cookieListTreeElement.appendChild(cookieDomainTreeElement); + var parsedURL = url.asParsedURL(); + if (!parsedURL) + return; + + var domain = parsedURL.host; + if (!this._domains[domain]) { + this._domains[domain] = true; + + var cookieDomainTreeElement = new WebInspector.CookieTreeElement(this, domain); + this.cookieListTreeElement.appendChild(cookieDomainTreeElement); + + var applicationCacheTreeElement = new WebInspector.ApplicationCacheTreeElement(this, domain); + this.applicationCacheListTreeElement.appendChild(applicationCacheTreeElement); + } + + if (Preferences.fileSystemEnabled) { + // FIXME: This should match the SecurityOrigin::toString(), add a test for this. + var securityOrigin = parsedURL.scheme + "://" + parsedURL.host + (parsedURL.port ? (":" + parsedURL.port) : ""); + if (!this._origins[securityOrigin]) { + this._origins[securityOrigin] = true; + var fileSystemTreeElement = new WebInspector.FileSystemTreeElement(this, securityOrigin); + this.fileSystemListTreeElement.appendChild(fileSystemTreeElement); + } + } }, addDOMStorage: function(domStorage) @@ -223,12 +308,6 @@ WebInspector.StoragePanel.prototype = { this.sessionStorageListTreeElement.appendChild(domStorageTreeElement); }, - addApplicationCache: function(domain) - { - var applicationCacheTreeElement = new WebInspector.ApplicationCacheTreeElement(this, domain); - this.applicationCacheListTreeElement.appendChild(applicationCacheTreeElement); - }, - selectDatabase: function(databaseId) { var database; @@ -258,6 +337,15 @@ WebInspector.StoragePanel.prototype = { showSourceLine: function(url, line) { + var resource = WebInspector.resourceManager.resourceForURL(url); + if (resource.type === WebInspector.Resource.Type.XHR) { + // Show XHRs in the network panel only. + if (WebInspector.panels.network && WebInspector.panels.network.canShowSourceLine(url, line)) { + WebInspector.currentPanel = WebInspector.panels.network; + WebInspector.panels.network.showSourceLine(url, line); + } + return; + } this.showResource(WebInspector.resourceManager.resourceForURL(url), line); }, @@ -291,7 +379,7 @@ WebInspector.StoragePanel.prototype = { { if (!database) return; - + var view; if (tableName) { if (!("_tableViews" in database)) @@ -352,6 +440,12 @@ WebInspector.StoragePanel.prototype = { this._applicationCacheView.updateStatus(this._cachedApplicationCacheViewStatus); }, + showFileSystem: function(treeElement, origin) + { + this._fileSystemView = new WebInspector.FileSystemView(treeElement, origin); + this._innerShowView(this._fileSystemView); + }, + showCategoryView: function(categoryName) { if (!this._categoryView) @@ -500,6 +594,24 @@ WebInspector.StoragePanel.prototype = { this._applicationCacheView.updateStatus(status); }, + updateFileSystemPath: function(root, type, origin) + { + if (this._fileSystemView && this._fileSystemView === this.visibleView) + this._fileSystemView.updateFileSystemPath(root, type, origin); + }, + + updateFileSystemError: function(type, origin) + { + if (this._fileSystemView && this._fileSystemView === this.visibleView) + this._fileSystemView.updateFileSystemError(type, origin); + }, + + setFileSystemDisabled: function() + { + if (this._fileSystemView && this._fileSystemView === this.visibleView) + this._fileSystemView.setFileSystemDisabled(); + }, + updateNetworkState: function(isNowOnline) { if (this._applicationCacheView && this._applicationCacheView === this.visibleView) @@ -536,9 +648,6 @@ WebInspector.StoragePanel.prototype = { { var views = []; - if (!Preferences.networkPanelEnabled) - return views; - const visibleView = this.visibleView; if (visibleView instanceof WebInspector.ResourceView && visibleView.performSearch) views.push(visibleView); @@ -576,13 +685,13 @@ WebInspector.StoragePanel.prototype = { { function isAncestor(ancestor, object) { - console.error("There should be no calls to isAncestor, but there was one for ", object); + // Redirects, XHRs do not belong to the tree, it is fine to silently return false here. return false; } function getParent(object) { - console.error("There should be no calls to getParent, but there was one for ", object); + // Redirects, XHRs do not belong to the tree, it is fine to silently return false here. return null; } @@ -617,6 +726,39 @@ WebInspector.StoragePanel.prototype = { { if (view) this.showResource(view.resource); + }, + + _onmousemove: function(event) + { + var nodeUnderMouse = document.elementFromPoint(event.pageX, event.pageY); + if (!nodeUnderMouse) + return; + + var listNode = nodeUnderMouse.enclosingNodeOrSelfWithNodeName("li"); + if (!listNode) + return; + + var element = listNode.treeElement; + if (this._previousHoveredElement === element) + return; + + if (this._previousHoveredElement) { + this._previousHoveredElement.hovered = false; + delete this._previousHoveredElement; + } + + if (element instanceof WebInspector.FrameTreeElement) { + this._previousHoveredElement = element; + element.hovered = true; + } + }, + + _onmouseout: function(event) + { + if (this._previousHoveredElement) { + this._previousHoveredElement.hovered = false; + delete this._previousHoveredElement; + } } } @@ -650,12 +792,24 @@ WebInspector.BaseStorageTreeElement.prototype = { this.listItemElement.appendChild(this.titleElement); }, + onselect: function() + { + var itemURL = this.itemURL; + if (itemURL) + WebInspector.settings.resourcesLastSelectedItem = itemURL; + }, + onreveal: function() { if (this.listItemElement) this.listItemElement.scrollIntoViewIfNeeded(false); }, + get titleText() + { + return this._titleText; + }, + set titleText(titleText) { this._titleText = titleText; @@ -675,42 +829,109 @@ WebInspector.BaseStorageTreeElement.prototype = { WebInspector.BaseStorageTreeElement.prototype.__proto__ = TreeElement.prototype; -WebInspector.StorageCategoryTreeElement = function(storagePanel, categoryName, iconClass) +WebInspector.StorageCategoryTreeElement = function(storagePanel, categoryName, settingsKey, iconClass) { WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, categoryName, iconClass, true); + this._expandedSettingKey = "resources" + settingsKey + "Expanded"; + WebInspector.settings.installApplicationSetting(this._expandedSettingKey, settingsKey === "Frames"); this._categoryName = categoryName; } WebInspector.StorageCategoryTreeElement.prototype = { + get itemURL() + { + return "category://" + this._categoryName; + }, + onselect: function() { + WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showCategoryView(this._categoryName); + }, + + onattach: function() + { + WebInspector.BaseStorageTreeElement.prototype.onattach.call(this); + if (WebInspector.settings[this._expandedSettingKey]) + this.expand(); + }, + + onexpand: function() + { + WebInspector.settings[this._expandedSettingKey] = true; + }, + + oncollapse: function() + { + WebInspector.settings[this._expandedSettingKey] = false; } } WebInspector.StorageCategoryTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; -WebInspector.FrameTreeElement = function(storagePanel, frameId, displayName) +WebInspector.FrameTreeElement = function(storagePanel, frameId, title, subtitle) { - WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, displayName, "frame-storage-tree-item"); + WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, "", "frame-storage-tree-item"); this._frameId = frameId; - this._displayName = displayName; + this.setTitles(title, subtitle); } WebInspector.FrameTreeElement.prototype = { + get itemURL() + { + return "frame://" + encodeURI(this._displayName); + }, + + onattach: function() + { + WebInspector.BaseStorageTreeElement.prototype.onattach.call(this); + if (this._titleToSetOnAttach || this._subtitleToSetOnAttach) { + this.setTitles(this._titleToSetOnAttach, this._subtitleToSetOnAttach); + delete this._titleToSetOnAttach; + delete this._subtitleToSetOnAttach; + } + }, + onselect: function() { + WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showCategoryView(this._displayName); + + this.listItemElement.removeStyleClass("hovered"); + InspectorBackend.hideFrameHighlight(); }, - get displayName() + get nameForSorting() { - return this._displayName; + return this._nameForSorting; }, - set displayName(displayName) + setTitles: function(title, subtitle) + { + this._nameForSorting = (title ? title : "") + (subtitle ? subtitle : ""); + if (this.parent) { + if (title) + this.titleElement.textContent = title; + if (subtitle) { + var subtitleElement = document.createElement("span"); + subtitleElement.className = "base-storage-tree-element-subtitle"; + subtitleElement.textContent = "(" + subtitle + ")"; + this.titleElement.appendChild(subtitleElement); + } + } else { + this._titleToSetOnAttach = title; + this._subtitleToSetOnAttach = subtitle; + } + }, + + set hovered(hovered) { - this._displayName = displayName; - this.titleText = displayName; + if (hovered) { + this.listItemElement.addStyleClass("hovered"); + InspectorBackend.highlightFrame(this._frameId); + } else { + this.listItemElement.removeStyleClass("hovered"); + InspectorBackend.hideFrameHighlight(); + } } } WebInspector.FrameTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; @@ -724,8 +945,14 @@ WebInspector.FrameResourceTreeElement = function(storagePanel, resource) } WebInspector.FrameResourceTreeElement.prototype = { + get itemURL() + { + return this._resource.url; + }, + onselect: function() { + WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel._showResourceView(this._resource); }, @@ -836,8 +1063,14 @@ WebInspector.DatabaseTreeElement = function(storagePanel, database) } WebInspector.DatabaseTreeElement.prototype = { + get itemURL() + { + return "database://" + encodeURI(this._database.name); + }, + onselect: function() { + WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showDatabase(this._database); }, @@ -872,8 +1105,14 @@ WebInspector.DatabaseTableTreeElement = function(storagePanel, database, tableNa } WebInspector.DatabaseTableTreeElement.prototype = { + get itemURL() + { + return "database://" + encodeURI(this._database.name) + "/" + encodeURI(this._tableName); + }, + onselect: function() { + WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showDatabase(this._database, this._tableName); } } @@ -886,8 +1125,14 @@ WebInspector.DOMStorageTreeElement = function(storagePanel, domStorage, classNam } WebInspector.DOMStorageTreeElement.prototype = { + get itemURL() + { + return "storage://" + this._domStorage.domain + "/" + (this._domStorage.isLocalStorage ? "local" : "session"); + }, + onselect: function() { + WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showDOMStorage(this._domStorage); } } @@ -900,8 +1145,14 @@ WebInspector.CookieTreeElement = function(storagePanel, cookieDomain) } WebInspector.CookieTreeElement.prototype = { + get itemURL() + { + return "cookies://" + this._cookieDomain; + }, + onselect: function() { + WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showCookies(this, this._cookieDomain); } } @@ -914,13 +1165,40 @@ WebInspector.ApplicationCacheTreeElement = function(storagePanel, appcacheDomain } WebInspector.ApplicationCacheTreeElement.prototype = { + get itemURL() + { + return "appcache://" + this._appcacheDomain; + }, + onselect: function() { + WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); this._storagePanel.showApplicationCache(this, this._appcacheDomain); } } WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; +WebInspector.FileSystemTreeElement = function(storagePanel, origin) +{ + WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, origin, "file-system-storage-tree-item"); + this._origin = origin; +} + +WebInspector.FileSystemTreeElement.prototype = { + get itemURL() + { + return "file-system://" + encodeURI(this._origin); + }, + + onselect: function() + { + WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); + this._storagePanel.showFileSystem(this, this._origin); + } +} + +WebInspector.FileSystemTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; + WebInspector.StorageCategoryView = function() { WebInspector.View.call(this); diff --git a/WebCore/inspector/front-end/StylesSidebarPane.js b/WebCore/inspector/front-end/StylesSidebarPane.js index cc97520..6d1b541 100644 --- a/WebCore/inspector/front-end/StylesSidebarPane.js +++ b/WebCore/inspector/front-end/StylesSidebarPane.js @@ -60,7 +60,7 @@ WebInspector.StylesSidebarPane = function(computedStylePane) this.settingsSelectElement.addEventListener("click", function(event) { event.stopPropagation() }, false); this.settingsSelectElement.addEventListener("change", this._changeSetting.bind(this), false); - var format = WebInspector.applicationSettings.colorFormat; + var format = WebInspector.settings.colorFormat; if (format === "hex") this.settingsSelectElement[0].selected = true; else if (format === "rgb") @@ -465,7 +465,7 @@ WebInspector.StylesSidebarPane.prototype = { // Select the correct color format setting again, since it needs to be selected. var selectedIndex = 0; for (var i = 0; i < options.length; ++i) { - if (options[i].value === WebInspector.applicationSettings.colorFormat) { + if (options[i].value === WebInspector.settings.colorFormat) { selectedIndex = i; break; } @@ -477,7 +477,7 @@ WebInspector.StylesSidebarPane.prototype = { _changeColorFormat: function(event) { var selectedOption = this.settingsSelectElement[this.settingsSelectElement.selectedIndex]; - WebInspector.applicationSettings.colorFormat = selectedOption.value; + WebInspector.settings.colorFormat = selectedOption.value; for (var pseudoId in this.sections) { var sections = this.sections[pseudoId]; @@ -562,15 +562,15 @@ WebInspector.ComputedStyleSidebarPane = function() var showInheritedCheckbox = new WebInspector.Checkbox(WebInspector.UIString("Show inherited"), "sidebar-pane-subtitle"); this.titleElement.appendChild(showInheritedCheckbox.element); - if (WebInspector.applicationSettings.showInheritedComputedStyleProperties) { + if (WebInspector.settings.showInheritedComputedStyleProperties) { this.bodyElement.addStyleClass("show-inherited"); showInheritedCheckbox.checked = true; } function showInheritedToggleFunction(event) { - WebInspector.applicationSettings.showInheritedComputedStyleProperties = showInheritedCheckbox.checked; - if (WebInspector.applicationSettings.showInheritedComputedStyleProperties) + WebInspector.settings.showInheritedComputedStyleProperties = showInheritedCheckbox.checked; + if (WebInspector.settings.showInheritedComputedStyleProperties) this.bodyElement.addStyleClass("show-inherited"); else this.bodyElement.removeStyleClass("show-inherited"); @@ -1010,8 +1010,9 @@ WebInspector.BlankStylePropertiesSection.prototype = { editingSelectorCommitted: function(element, newContent, oldContent, context) { var self = this; - function successCallback(styleRule, doesSelectorAffectSelectedNode) + function successCallback(newRule, doesSelectorAffectSelectedNode) { + var styleRule = { section: self, style: newRule.style, selectorText: newRule.selectorText, sourceURL: newRule.sourceURL, rule: newRule }; self.makeNormal(styleRule); if (!doesSelectorAffectSelectedNode) { @@ -1200,9 +1201,9 @@ WebInspector.StylePropertyTreeElement.prototype = { var format; if (Preferences.showColorNicknames && color.nickname) format = "nickname"; - else if (WebInspector.applicationSettings.colorFormat === "rgb") + else if (WebInspector.settings.colorFormat === "rgb") format = (color.simple ? "rgb" : "rgba"); - else if (WebInspector.applicationSettings.colorFormat === "hsl") + else if (WebInspector.settings.colorFormat === "hsl") format = (color.simple ? "hsl" : "hsla"); else if (color.simple) format = (color.hasShortHex() ? "shorthex" : "hex"); diff --git a/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js b/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js index 11b0e03..44063a3 100644 --- a/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js +++ b/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js @@ -39,7 +39,7 @@ WebInspector.WatchExpressionsSidebarPane.prototype = { { this.bodyElement.removeChildren(); - this.expanded = WebInspector.applicationSettings.watchExpressions.length > 0; + this.expanded = WebInspector.settings.watchExpressions.length > 0; this.section = new WebInspector.WatchExpressionsSection(); this.bodyElement.appendChild(this.section.element); @@ -77,7 +77,7 @@ WebInspector.WatchExpressionsSection = function() WebInspector.ObjectPropertiesSection.call(this); - this.watchExpressions = WebInspector.applicationSettings.watchExpressions; + this.watchExpressions = WebInspector.settings.watchExpressions; this.headerElement.className = "hidden"; this.editable = true; @@ -181,7 +181,7 @@ WebInspector.WatchExpressionsSection.prototype = { if (this.watchExpressions[i]) toSave.push(this.watchExpressions[i]); - WebInspector.applicationSettings.watchExpressions = toSave; + WebInspector.settings.watchExpressions = toSave; return toSave.length; } } diff --git a/WebCore/inspector/front-end/WebKit.qrc b/WebCore/inspector/front-end/WebKit.qrc index 481f8b3..ebdd4f6 100644 --- a/WebCore/inspector/front-end/WebKit.qrc +++ b/WebCore/inspector/front-end/WebKit.qrc @@ -41,6 +41,7 @@ <file>ExtensionPanel.js</file> <file>ExtensionRegistryStub.js</file> <file>ExtensionServer.js</file> + <file>FileSystemView.js</file> <file>FontView.js</file> <file>GoToLineDialog.js</file> <file>HAREntry.js</file> @@ -70,7 +71,6 @@ <file>Resource.js</file> <file>ResourceCategory.js</file> <file>ResourceManager.js</file> - <file>ResourcesPanel.js</file> <file>ResourceView.js</file> <file>ScopeChainSidebarPane.js</file> <file>Script.js</file> @@ -167,7 +167,6 @@ <file>Images/goArrow.png</file> <file>Images/graphLabelCalloutLeft.png</file> <file>Images/graphLabelCalloutRight.png</file> - <file>Images/grayConnectorPoint.png</file> <file>Images/largerResourcesButtonGlyph.png</file> <file>Images/localStorage.png</file> <file>Images/networkIcon.png</file> @@ -198,7 +197,6 @@ <file>Images/resourcePlainIcon.png</file> <file>Images/resourcePlainIconSmall.png</file> <file>Images/resourcesIcon.png</file> - <file>Images/resourcesSilhouette.png</file> <file>Images/resourcesSizeGraphIcon.png</file> <file>Images/resourcesTimeGraphIcon.png</file> <file>Images/scriptsIcon.png</file> @@ -273,7 +271,6 @@ <file>Images/warningMediumIcon.png</file> <file>Images/warningOrangeDot.png</file> <file>Images/warningsErrors.png</file> - <file>Images/whiteConnectorPoint.png</file> <file alias="DebuggerScript.js">../../bindings/v8/DebuggerScript.js</file> </qresource> </RCC> diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css index 429e749..b26b748 100644 --- a/WebCore/inspector/front-end/inspector.css +++ b/WebCore/inspector/front-end/inspector.css @@ -508,7 +508,7 @@ body.drawer-visible #drawer { } .monospace { - font-size: 10px; + font-size: 10px !important; font-family: monospace; } @@ -519,17 +519,17 @@ body.platform-mac .monospace, body.platform-mac .source-code { /* Keep .platform-mac to make the rule more specific than the general one above. */ body.platform-mac.platform-mac-snowleopard .monospace, body.platform-mac.platform-mac-snowleopard .source-code { - font-size: 11px; + font-size: 11px !important; font-family: Menlo, monospace; } body.platform-windows .monospace, body.platform-windows .source-code { - font-size: 12px; + font-size: 12px !important; font-family: Consolas, Lucida Console, monospace; } body.platform-linux .monospace, body.platform-linux .source-code { - font-size: 11px; + font-size: 11px !important; font-family: dejavu sans mono, monospace; } @@ -1176,7 +1176,7 @@ body.platform-linux .monospace, body.platform-linux .source-code { .source-code { font-family: monospace; - font-size: 10px; + font-size: 10px !important; white-space: pre-wrap; } @@ -1311,26 +1311,21 @@ body.inactive .placard.selected { margin-top: 1px; } -.section:nth-last-of-type(1), .event-bar:nth-last-of-type(1) { - margin-bottom: 1px; -} - .watch-expressions-buttons-container { text-align: center; } -.event-bar:first-child { - margin-top: 1px; +.events-pane .section:not(:nth-of-type(1)) { + border-top: 1px solid rgb(191, 191, 191); } -.event-bar:nth-last-of-type(1) .header { - border-bottom: 1px solid rgb(163, 163, 163); +.event-bar:first-child { + margin-top: 1px; } .section .header { - padding: 2px 8px 4px 18px; - border-top: 1px solid rgb(145, 160, 192); - background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(162, 177, 207)), to(rgb(120, 138, 177))); + color: black; + padding: 0 8px 0 18px; min-height: 18px; white-space: nowrap; -webkit-background-origin: padding; @@ -1339,22 +1334,23 @@ body.inactive .placard.selected { .section .header::before { position: absolute; - top: 4px; + top: 2px; left: 7px; width: 8px; height: 8px; - content: url(Images/treeRightTriangleWhite.png); + content: url(Images/treeRightTriangleBlack.png); + opacity: 0.8; } .section.expanded .header::before { - content: url(Images/treeDownTriangleWhite.png); + content: url(Images/treeDownTriangleBlack.png); } .section .header .title, .event-bar .header .title { - color: white; - font-weight: bold; + font-weight: normal; word-wrap: break-word; white-space: normal; + line-height: 18px; } .section .header .title.blank-title { @@ -1371,10 +1367,8 @@ body.inactive .placard.selected { .section .header .subtitle, .event-bar .header .subtitle { float: right; - font-size: 10px; margin-left: 5px; max-width: 55%; - color: rgba(255, 255, 255, 0.7); text-overflow: ellipsis; overflow: hidden; } @@ -1389,6 +1383,7 @@ body.inactive .placard.selected { .section.expanded .properties, .event-bar.expanded .event-properties { display: block; + padding-left: 16px; } .section.no-affect .properties li { @@ -1401,7 +1396,7 @@ body.inactive .placard.selected { .properties-tree { margin: 0; - padding: 2px 6px 3px; + padding: 0 6px 2px; list-style: none; min-height: 18px; } @@ -1453,19 +1448,23 @@ body.inactive .placard.selected { } .event-listener-breakpoints .event-category { - font-size: 12px; + font-size: 11px; font-weight: bold; - color: rgb(110, 110, 110); + color: rgb(96, 96, 96); + padding-top: 2px; } .event-listener-breakpoints.properties-tree .children li { - margin-left: 17px; + margin-left: 12px; + height: 16px; } .event-listener-breakpoints .checkbox-elem { + font-size: 10px; float: left; - margin-top: 1px; - margin-left: 0px; + top: -2px; + position: relative; + left: -1px; } .section .event-bars { @@ -1478,38 +1477,21 @@ body.inactive .placard.selected { .event-bar { position: relative; -} - -.event-bar-connector { - position: absolute; - left: 75%; - bottom: -7px; - margin-left: -7px; - content: url(Images/grayConnectorPoint.png); - z-index: 3; -} - -.event-bar.expanded .event-bar-connector { - content: url(Images/whiteConnectorPoint.png); + left: 10px; } .event-bars .event-bar .header { - padding: 2px 8px 4px 18px; - border-top: 1px solid rgb(163, 163, 163); - background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(243, 243, 243)), to(rgb(207, 207, 207))); - min-height: 18px; + padding: 0 8px 0 18px; + min-height: 16px; + opacity: 1.0; white-space: nowrap; -webkit-background-origin: padding; -webkit-background-clip: padding; } -.event-bars .event-bar.expanded .header { - border-bottom: 1px solid rgb(163, 163, 163); -} - .event-bars .event-bar .header .title { - font-weight: bold; - color: #333; + font-weight: normal; + color: black; text-shadow: white 0 1px 0; } @@ -1519,7 +1501,7 @@ body.inactive .placard.selected { .event-bars .event-bar .header::before { position: absolute; - top: 4px; + top: 2px; left: 7px; width: 8px; height: 8px; @@ -1744,11 +1726,12 @@ li.editing .swatch, li.editing .enabled-button, li.editing-sub-part .delete-but font-style: italic; font-size: 10px; padding: 6px; - color: gray; + color: black; } .pane > .body .placard + .info { - border-top: 1px solid gray + border-top: 1px solid rgb(189, 189, 189); + background-color: rgb(255, 255, 194); } .pane.expanded > .body, .pane.expanded > .growbar { @@ -1932,6 +1915,11 @@ body.inactive .sidebar { content: url(Images/applicationCache.png); } +/* FIXME: Make separate png for file-system */ +.file-system-storage-tree-item .icon { + content: url(Images/applicationCache.png); +} + #storage-views { position: absolute; top: 0; @@ -1963,18 +1951,18 @@ body.inactive .sidebar { font-weight: bold; } -.storage.panel .sidebar li .selection { +.storage.panel .sidebar li.selected .selection { background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(162, 177, 207)), to(rgb(120, 138, 177))); border-top: 1px solid #979797; height: 17px; } -.storage.panel .sidebar :focus li .selection { +.storage.panel .sidebar :focus li.selected .selection { background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(92, 147, 213)), to(rgb(21, 83, 170))); border-top: 1px solid rgb(68, 128, 200); } -body.inactive .storage.panel .sidebar li .selection { +body.inactive .storage.panel .sidebar li.selected .selection { background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(180, 180, 180)), to(rgb(138, 138, 138))); border-top: 1px solid rgb(151, 151, 151); } @@ -1993,6 +1981,16 @@ body.inactive .storage.panel .sidebar li .selection { top: 1px; } +li.selected .base-storage-tree-element-subtitle { + color: white; +} + +.base-storage-tree-element-subtitle { + padding-left: 2px; + color: rgb(80, 80, 80); + text-shadow: none; +} + .storage.panel .status { float: right; height: 16px; @@ -2494,10 +2492,6 @@ body.inactive .panel-enabler-view button:not(.status-bar-item), .panel-enabler-v -webkit-gradient(linear, left top, left bottom, from(rgb(252, 252, 252)), to(rgb(223, 223, 223))); } -.panel-enabler-view.resources img { - content: url(Images/resourcesSilhouette.png); -} - .panel-enabler-view.scripts img { content: url(Images/scriptsSilhouette.png); } @@ -2677,8 +2671,8 @@ button.enable-toggle-status-bar-item.toggled-on .glyph { background: transparent; text-shadow: rgba(255, 255, 255, 0.5) 0 1px 0; vertical-align: middle; - padding: 1px 7px 2px; - height: 18px; + padding: 3px 7px 2px; + height: 21px; border: 1px solid transparent; border-bottom: none; } @@ -4095,7 +4089,7 @@ button.enable-toggle-status-bar-item .glyph { } ol.breakpoint-list { - -webkit-padding-start: 2px; + -webkit-padding-start: 0; list-style: none; margin: 0; } @@ -4104,9 +4098,8 @@ ol.breakpoint-list { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; - margin: 4px 0; - color: rgb(33%, 33%, 33%); - cursor: pointer; + padding: 2px 0; + color: black; } .breakpoint-list li:hover { @@ -4128,8 +4121,8 @@ ol.breakpoint-list { margin: 2px 0 0px 20px; } -.breakpoint-list .breakpoint-hit { - background-color: yellow; +.pane .breakpoint-hit { + background-color: rgb(255, 255, 194); } .webkit-html-js-node, .webkit-html-css-node { @@ -4391,3 +4384,11 @@ a.worker-item:hover { text-decoration: underline; cursor: pointer; } + +.cursor-pointer { + cursor: pointer; +} + +.cursor-auto { + cursor: auto; +}
\ No newline at end of file diff --git a/WebCore/inspector/front-end/inspector.html b/WebCore/inspector/front-end/inspector.html index 96d0cfe..c681531 100644 --- a/WebCore/inspector/front-end/inspector.html +++ b/WebCore/inspector/front-end/inspector.html @@ -69,6 +69,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="DataGrid.js"></script> <script type="text/javascript" src="CookieItemsView.js"></script> <script type="text/javascript" src="ApplicationCacheItemsView.js"></script> + <script type="text/javascript" src="FileSystemView.js"></script> <script type="text/javascript" src="Script.js"></script> <script type="text/javascript" src="BreakpointManager.js"></script> <script type="text/javascript" src="SidebarPane.js"></script> @@ -95,7 +96,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="SummaryBar.js"></script> <script type="text/javascript" src="ElementsPanel.js"></script> <script type="text/javascript" src="NetworkPanel.js"></script> - <script type="text/javascript" src="ResourcesPanel.js"></script> <script type="text/javascript" src="InjectedFakeWorker.js"></script> <script type="text/javascript" src="ScriptsPanel.js"></script> <script type="text/javascript" src="StoragePanel.js"></script> diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js index f5a70c8..8323cad 100644 --- a/WebCore/inspector/front-end/inspector.js +++ b/WebCore/inspector/front-end/inspector.js @@ -50,8 +50,6 @@ var WebInspector = { resources: {}, - cookieDomains: {}, - applicationCacheDomains: {}, missingLocalizedStrings: {}, pendingDispatches: 0, @@ -181,7 +179,7 @@ var WebInspector = { for (var panelName in WebInspector.panels) { if (WebInspector.panels[panelName] === x) { - WebInspector.applicationSettings.lastActivePanel = panelName; + WebInspector.settings.lastActivePanel = panelName; this._panelHistory.setPanel(panelName); } } @@ -192,7 +190,7 @@ var WebInspector = { var pane = new WebInspector.BreakpointsSidebarPane(WebInspector.UIString("Breakpoints")); function breakpointAdded(event) { - pane.addBreakpoint(new WebInspector.JSBreakpointItem(event.data)); + pane.addBreakpointItem(new WebInspector.BreakpointItem(event.data)); } WebInspector.breakpointManager.addEventListener("breakpoint-added", breakpointAdded); return pane; @@ -203,7 +201,7 @@ var WebInspector = { var pane = new WebInspector.BreakpointsSidebarPane(WebInspector.UIString("DOM Breakpoints")); function breakpointAdded(event) { - pane.addBreakpoint(new WebInspector.BreakpointItem(event.data)); + pane.addBreakpointItem(new WebInspector.BreakpointItem(event.data)); } WebInspector.breakpointManager.addEventListener("dom-breakpoint-added", breakpointAdded); return pane; @@ -214,7 +212,7 @@ var WebInspector = { var pane = new WebInspector.XHRBreakpointsSidebarPane(); function breakpointAdded(event) { - pane.addBreakpoint(new WebInspector.BreakpointItem(event.data)); + pane.addBreakpointItem(new WebInspector.BreakpointItem(event.data)); } WebInspector.breakpointManager.addEventListener("xhr-breakpoint-added", breakpointAdded); return pane; @@ -226,15 +224,9 @@ var WebInspector = { if (hiddenPanels.indexOf("elements") === -1) this.panels.elements = new WebInspector.ElementsPanel(); - if (Preferences.networkPanelEnabled) { - if (hiddenPanels.indexOf("storage") === -1 && hiddenPanels.indexOf("databases") === -1) - this.panels.storage = new WebInspector.StoragePanel(); - if (hiddenPanels.indexOf("network") === -1) - this.panels.network = new WebInspector.NetworkPanel(); - } else if (hiddenPanels.indexOf("resources") === -1) - this.panels.resources = new WebInspector.ResourcesPanel(); - - if (Preferences.networkPanelEnabled && hiddenPanels.indexOf("network") === -1) + if (hiddenPanels.indexOf("storage") === -1 && hiddenPanels.indexOf("databases") === -1) + this.panels.storage = new WebInspector.StoragePanel(); + if (hiddenPanels.indexOf("network") === -1) this.panels.network = new WebInspector.NetworkPanel(); if (hiddenPanels.indexOf("scripts") === -1) this.panels.scripts = new WebInspector.ScriptsPanel(); @@ -246,12 +238,6 @@ var WebInspector = { if (Preferences.heapProfilerPresent) this.panels.profiles.registerProfileType(new WebInspector.HeapSnapshotProfileType()); } - - if (!Preferences.networkPanelEnabled) { - if (hiddenPanels.indexOf("storage") === -1 && hiddenPanels.indexOf("databases") === -1) - this.panels.storage = new WebInspector.StoragePanel(); - } - if (hiddenPanels.indexOf("audits") === -1) this.panels.audits = new WebInspector.AuditsPanel(); if (hiddenPanels.indexOf("console") === -1) @@ -455,29 +441,17 @@ var WebInspector = { get networkResources() { - if (Preferences.networkPanelEnabled) - return this.panels.network.resources; - else - return this.resources; + return this.panels.network.resources; }, forAllResources: function(callback) { - if (Preferences.networkPanelEnabled) - WebInspector.resourceManager.forAllResources(callback); - else { - for (var id in this.resources) { - if (callback(this.resources[id])) - return; - } - } + WebInspector.resourceManager.forAllResources(callback); }, resourceForURL: function(url) { - if (Preferences.networkPanelEnabled) - return this.resourceManager.resourceForURL(url); - return this.panels.resources.resourceURLMap[url]; + return this.resourceManager.resourceForURL(url); } } @@ -530,7 +504,7 @@ WebInspector.doLoadedDone = function() document.body.addStyleClass("port-" + port); InspectorFrontendHost.loaded(); - WebInspector.applicationSettings = new WebInspector.Settings(); + WebInspector.settings = new WebInspector.Settings(); this._registerShortcuts(); @@ -544,8 +518,7 @@ WebInspector.doLoadedDone = function() // this.changes = new WebInspector.ChangesView(this.drawer); // TODO: Remove class="hidden" from inspector.html on button#changes-status-bar-item this.drawer.visibleView = this.console; - if (Preferences.networkPanelEnabled) - this.resourceManager = new WebInspector.ResourceManager(); + this.resourceManager = new WebInspector.ResourceManager(); this.domAgent = new WebInspector.DOMAgent(); this.resourceCategories = { @@ -555,7 +528,7 @@ WebInspector.doLoadedDone = function() scripts: new WebInspector.ResourceCategory("scripts", WebInspector.UIString("Scripts"), "rgb(255,121,0)"), xhr: new WebInspector.ResourceCategory("xhr", WebInspector.UIString("XHR"), "rgb(231,231,10)"), fonts: new WebInspector.ResourceCategory("fonts", WebInspector.UIString("Fonts"), "rgb(255,82,62)"), - websocket: new WebInspector.ResourceCategory("websockets", WebInspector.UIString("WebSocket"), "rgb(186,186,186)"), // FIXME: Decide the color. + websockets: new WebInspector.ResourceCategory("websockets", WebInspector.UIString("WebSocket"), "rgb(186,186,186)"), // FIXME: Decide the color. other: new WebInspector.ResourceCategory("other", WebInspector.UIString("Other"), "rgb(186,186,186)") }; @@ -573,10 +546,9 @@ WebInspector.doLoadedDone = function() for (var panelName in this.panels) previousToolbarItem = WebInspector.addPanelToolbarIcon(toolbarElement, this.panels[panelName], previousToolbarItem); - if (Preferences.networkPanelEnabled) { - this.panels.storage._toolbarItem.removeStyleClass("storage"); - this.panels.storage._toolbarItem.addStyleClass("resources"); - } + // FIXME: fix this once renamed StoragePanel.js to ResourcesPanel.js + this.panels.storage._toolbarItem.removeStyleClass("storage"); + this.panels.storage._toolbarItem.addStyleClass("resources"); this.Tips = { ResourceNotCompressed: {id: 0, message: WebInspector.UIString("You could save bandwidth by having your web server compress this transfer with gzip or zlib.")} @@ -630,19 +602,13 @@ WebInspector.doLoadedDone = function() WebInspector.monitoringXHREnabled = inspectorState.monitoringXHREnabled; if ("pauseOnExceptionsState" in inspectorState) WebInspector.panels.scripts.updatePauseOnExceptionsState(inspectorState.pauseOnExceptionsState); - if (WebInspector.panels.resources) { - if (inspectorState.resourceTrackingEnabled) - WebInspector.panels.resources.resourceTrackingWasEnabled(); - else - WebInspector.panels.resources.resourceTrackingWasDisabled(); - } } InspectorBackend.getInspectorState(populateInspectorState); function onPopulateScriptObjects() { if (!WebInspector.currentPanel) - WebInspector.showPanel(WebInspector.applicationSettings.lastActivePanel); + WebInspector.showPanel(WebInspector.settings.lastActivePanel); } InspectorBackend.populateScriptObjects(onPopulateScriptObjects); @@ -844,13 +810,8 @@ WebInspector.openResource = function(resourceURL, inResourcesPanel) { var resource = WebInspector.resourceForURL(resourceURL); if (inResourcesPanel && resource) { - if (Preferences.networkPanelEnabled) { - WebInspector.panels.storage.showResource(resource); - WebInspector.showPanel("storage"); - } else { - WebInspector.panels.resources.showResource(resource); - WebInspector.showPanel("resources"); - } + WebInspector.panels.storage.showResource(resource); + WebInspector.showPanel("storage"); } else InspectorBackend.openInInspectedWindow(resource ? resource.url : resourceURL); } @@ -1245,6 +1206,10 @@ WebInspector.showChanges = function() WebInspector.showPanel = function(panel) { + // FIXME: fix this once renamed StoragePanel.js to ResourcesPanel.js + if (panel === "resources") + panel = "storage"; + if (!(panel in this.panels)) panel = "elements"; this.currentPanel = this.panels[panel]; @@ -1267,85 +1232,8 @@ WebInspector.selectDOMStorage = function(o) WebInspector.panels.storage.selectDOMStorage(o); } -WebInspector.updateResource = function(payload) -{ - if (Preferences.networkPanelEnabled) - return; - - var identifier = payload.id; - var resource = this.resources[identifier]; - if (!resource) { - resource = new WebInspector.Resource(identifier, payload.url); - this.resources[identifier] = resource; - this.panels.resources.addResource(resource); - this.panels.audits.resourceStarted(resource); - } - - if (payload.didRequestChange) { - resource.requestHeaders = payload.requestHeaders; - resource.mainResource = payload.mainResource; - resource.requestMethod = payload.requestMethod; - resource.requestFormData = payload.requestFormData; - resource.documentURL = payload.documentURL; - if (typeof payload.webSocketRequestKey3 !== "undefined") - resource.webSocketRequestKey3 = payload.webSocketRequestKey3; - - if (resource.mainResource) - this.mainResource = resource; - - var parsedURL = payload.documentURL.asParsedURL(); - if (parsedURL) { - this._addCookieDomain(parsedURL.host); - this._addAppCacheDomain(parsedURL.host); - } - } - - if (payload.didResponseChange) { - resource.mimeType = payload.mimeType; - resource.suggestedFilename = payload.suggestedFilename; - resource.expectedContentLength = payload.expectedContentLength; - resource.statusCode = payload.statusCode; - resource.statusText = payload.statusText; - resource.suggestedFilename = payload.suggestedFilename; - resource.responseHeaders = payload.responseHeaders; - resource.connectionID = payload.connectionID; - resource.connectionReused = payload.connectionReused; - resource.timing = payload.timing; - resource.cached = payload.cached; - if (typeof payload.webSocketChallengeResponse !== "undefined") - resource.webSocketChallengeResponse = payload.webSocketChallengeResponse; - } - - if (payload.didTypeChange) - resource.type = payload.type; - - if (payload.didLengthChange) - resource.resourceSize = payload.resourceSize; - - if (payload.didCompletionChange) { - resource.failed = payload.failed; - resource.localizedFailDescription = payload.localizedFailDescription; - resource.finished = payload.finished; - if (this.panels.audits) - this.panels.audits.resourceFinished(resource); - this.extensionServer.notifyResourceFinished(resource); - } - - if (payload.didTimingChange) { - if (payload.startTime) - resource.startTime = payload.startTime; - if (payload.responseReceivedTime) - resource.responseReceivedTime = payload.responseReceivedTime; - if (payload.endTime) - resource.endTime = payload.endTime; - } - this.panels.resources.refreshResource(resource); -} - WebInspector.domContentEventFired = function(time) { - if (this.panels.resources) - this.panels.resources.mainResourceDOMContentTime = time; this.panels.audits.mainResourceDOMContentTime = time; if (this.panels.network) this.panels.network.mainResourceDOMContentTime = time; @@ -1354,29 +1242,12 @@ WebInspector.domContentEventFired = function(time) WebInspector.loadEventFired = function(time) { - if (this.panels.resources) - this.panels.resources.mainResourceLoadTime = time; this.panels.audits.mainResourceLoadTime = time; if (this.panels.network) this.panels.network.mainResourceLoadTime = time; this.mainResourceLoadTime = time; } -WebInspector.removeResource = function(identifier) -{ - if (Preferences.networkPanelEnabled) - return; - - var resource = this.resources[identifier]; - if (!resource) - return; - - delete this.resources[identifier]; - - if (this.panels.resources) - this.panels.resources.removeResource(resource); -} - WebInspector.addDatabase = function(payload) { if (!this.panels.storage) @@ -1389,30 +1260,6 @@ WebInspector.addDatabase = function(payload) this.panels.storage.addDatabase(database); } -WebInspector._addCookieDomain = function(domain) -{ - // Eliminate duplicate domains from the list. - if (domain in this.cookieDomains) - return; - this.cookieDomains[domain] = true; - - if (!this.panels.storage) - return; - this.panels.storage.addCookieDomain(domain); -} - -WebInspector._addAppCacheDomain = function(domain) -{ - // Eliminate duplicate domains from the list. - if (domain in this.applicationCacheDomains) - return; - this.applicationCacheDomains[domain] = true; - - if (!this.panels.storage) - return; - this.panels.storage.addApplicationCache(domain); -} - WebInspector.addDOMStorage = function(payload) { if (!this.panels.storage) @@ -1434,6 +1281,21 @@ WebInspector.updateApplicationCacheStatus = function(status) this.panels.storage.updateApplicationCacheStatus(status); } +WebInspector.didGetFileSystemPath = function(root, type, origin) +{ + this.panels.storage.updateFileSystemPath(root, type, origin); +} + +WebInspector.didGetFileSystemError = function(type, origin) +{ + this.panels.storage.updateFileSystemError(type, origin); +} + +WebInspector.didGetFileSystemDisabled = function() +{ + this.panels.storage.setFileSystemDisabled(); +} + WebInspector.updateNetworkState = function(isNowOnline) { this.panels.storage.updateNetworkState(isNowOnline); @@ -1491,7 +1353,7 @@ WebInspector.failedToParseScriptSource = function(sourceURL, source, startingLin WebInspector.pausedScript = function(details) { - this.panels.scripts.debuggerPaused(details); + this.panels.scripts.debuggerPaused(details.callFrames); this.breakpointManager.debuggerPaused(details); InspectorFrontendHost.bringToFront(); } @@ -1513,15 +1375,12 @@ WebInspector.reset = function() } this.resources = {}; - this.cookieDomains = {}; - this.applicationCacheDomains = {}; this.highlightDOMNode(0); - if (!Preferences.networkPanelEnabled) - delete this.mainResource; - this.console.clearMessages(); this.extensionServer.notifyInspectorReset(); + + this.breakpointManager.restoreBreakpoints(); } WebInspector.resetProfilesPanel = function() @@ -1538,7 +1397,12 @@ WebInspector.bringToFront = function() WebInspector.inspectedURLChanged = function(url) { InspectorFrontendHost.inspectedURLChanged(url); + this.settings.inspectedURLChanged(url); this.extensionServer.notifyInspectedURLChanged(); + if (!this._breakpointsRestored) { + this.breakpointManager.restoreBreakpoints(); + this._breakpointsRestored = true; + } } WebInspector.didCommitLoad = function() @@ -1669,7 +1533,7 @@ WebInspector.addProfileHeader = function(profile) WebInspector.setRecordingProfile = function(isProfiling) { this.panels.profiles.getProfileType(WebInspector.CPUProfileType.TypeId).setRecordingProfile(isProfiling); - if (this._previousIsProfiling !== isProfiling) { + if (this.panels.profiles.hasTemporaryProfile(WebInspector.CPUProfileType.TypeId) !== isProfiling) { if (!this._temporaryRecordingProfile) { this._temporaryRecordingProfile = { typeId: WebInspector.CPUProfileType.TypeId, @@ -1678,7 +1542,6 @@ WebInspector.setRecordingProfile = function(isProfiling) isTemporary: true }; } - this._previousIsProfiling = isProfiling; if (isProfiling) this.panels.profiles.addProfileHeader(this._temporaryRecordingProfile); else @@ -1749,13 +1612,14 @@ WebInspector.displayNameForURL = function(url) WebInspector._choosePanelToShowSourceLine = function(url, line, preferredPanel) { preferredPanel = preferredPanel || "resources"; - if (Preferences.networkPanelEnabled && preferredPanel === "resources") + // FIXME: remove this once StoragePanel renamed to ResourcesPanel + if (preferredPanel === "resources") preferredPanel = "storage"; var panel = this.panels[preferredPanel]; if (panel && panel.canShowSourceLine(url, line)) return panel; - panel = Preferences.networkPanelEnabled ? this.panels.storage : this.panels.resources; + panel = this.panels.storage; return panel.canShowSourceLine(url, line) ? panel : null; } @@ -1777,6 +1641,7 @@ WebInspector.linkifyStringAsFragment = function(string) { var container = document.createDocumentFragment(); var linkStringRegEx = /(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\/\/|www\.)[\w$\-_+*'=\|\/\\(){}[\]%@&#~,:;.!?]{2,}[\w$\-_+*=\|\/\\({%@&#~]/; + var lineColumnRegEx = /:(\d+)(:(\d+))?$/; while (string) { var linkString = linkStringRegEx.exec(string); @@ -1794,8 +1659,17 @@ WebInspector.linkifyStringAsFragment = function(string) title = WebInspector.panels.profiles.displayTitleForProfileLink(profileStringMatches[2], profileStringMatches[1]); var realURL = (linkString.indexOf("www.") === 0 ? "http://" + linkString : linkString); + var lineColumnMatch = lineColumnRegEx.exec(realURL); + if (lineColumnMatch) + realURL = realURL.substring(0, realURL.length - lineColumnMatch[0].length); + var hasResourceWithURL = !!WebInspector.resourceForURL(realURL); - container.appendChild(WebInspector.linkifyURLAsNode(realURL, title, null, hasResourceWithURL)); + var urlNode = WebInspector.linkifyURLAsNode(realURL, title, null, hasResourceWithURL); + container.appendChild(urlNode); + if (lineColumnMatch) { + urlNode.setAttribute("line_number", lineColumnMatch[1]); + urlNode.setAttribute("preferred_panel", "scripts"); + } string = string.substring(linkIndex + linkString.length, string.length); } diff --git a/WebCore/inspector/front-end/networkPanel.css b/WebCore/inspector/front-end/networkPanel.css index 215681f..1e0e813 100644 --- a/WebCore/inspector/front-end/networkPanel.css +++ b/WebCore/inspector/front-end/networkPanel.css @@ -2,7 +2,7 @@ -webkit-mask-image: url(Images/largerResourcesButtonGlyph.png); } -.network.panel .data-grid { +.network-sidebar .data-grid { border: none; position: absolute; top: 0; @@ -12,17 +12,17 @@ font-size: 11px; } -.network.panel .data-grid table.data { +.network-sidebar .data-grid table.data { -webkit-background-size: 1px 82px; background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), color-stop(0.5, rgba(0, 0, 0, 0)), color-stop(0.5, rgba(0, 0, 0, 0.05)), to(rgba(0, 0, 0, 0.05))); font-size: 11px; } -.network.panel .data-grid.small table.data { +.network-sidebar .data-grid.small table.data { -webkit-background-size: 1px 42px; } -.network.panel .data-grid td { +.network-sidebar .data-grid td:not(.network-summary) { line-height: 17px; height: 37px; border-right: 1px solid rgb(210, 210, 210); @@ -30,34 +30,34 @@ vertical-align: middle; } -.network.panel .data-grid.small td { +.network-sidebar .data-grid.small td { height: 17px; } -.network.panel .data-grid th { +.network-sidebar .data-grid th { border-bottom: 1px solid rgb(64%, 64%, 64%); height: 30px; font-size: 11px; font-weight: bold; } -.network.panel .data-grid.small th { +.network-sidebar .data-grid.small th { height: 22px; } -.network.panel .data-grid th, .network.panel .data-grid th.sort-descending, .network.panel .data-grid th.sort-ascending { +.network-sidebar .data-grid th, .network.panel .data-grid th.sort-descending, .network.panel .data-grid th.sort-ascending { background: -webkit-gradient(linear, left top, left bottom, from(rgb(236, 236, 236)), to(rgb(217, 217, 217))); } -.network.panel .data-grid .data-container { +.network-sidebar .data-grid .data-container { top: 31px; } -.network.panel .data-grid.small .data-container { +.network-sidebar .data-grid.small .data-container { top: 23px; } -.network.panel .data-grid select { +.network-sidebar .data-grid select { -webkit-appearance: none; background-color: transparent; border: none; @@ -66,32 +66,32 @@ font-weight: bold; } -.network.panel .data-grid tr.filler { +.network-sidebar .data-grid tr.filler { background-color: white; } -.network.panel .data-grid td.name-column { +.network-sidebar .data-grid td.name-column { font-weight: bold; } -.network.panel .data-grid td.method-column, -.network.panel .data-grid td.status-column, -.network.panel .data-grid td.type-column, -.network.panel .data-grid td.size-column, -.network.panel .data-grid td.time-column { +.network-sidebar .data-grid td.method-column, +.network-sidebar .data-grid td.status-column, +.network-sidebar .data-grid td.type-column, +.network-sidebar .data-grid td.size-column, +.network-sidebar .data-grid td.time-column { background-color: rgba(0, 0, 0, 0.07); } -.network.panel .data-grid td.size-column, -.network.panel .data-grid td.time-column { +.network-sidebar .data-grid td.size-column, +.network-sidebar .data-grid td.time-column { text-align: right; } -.network.panel .small .network-graph-side { +.network-sidebar .small .network-graph-side { height: 14px; } -.network.panel .data-grid th.sortable:active { +.network-sidebar .data-grid th.sortable:active { background-image: none; } @@ -104,66 +104,66 @@ color: grey; } -.network.panel .data-grid.small .network-cell-subtitle, -.network.panel .data-grid.small .network-header-subtitle +.network-sidebar .data-grid.small .network-cell-subtitle, +.network-sidebar .data-grid.small .network-header-subtitle { display: none; } /* Resource preview icons */ -.network.panel .data-grid .icon { +.network-sidebar .data-grid .icon { content: url(Images/resourcePlainIcon.png); } -.network.panel .data-grid.small .icon { +.network-sidebar .data-grid.small .icon { content: url(Images/resourcePlainIconSmall.png); } -.network.panel .network-category-scripts .icon { +.network-sidebar .network-category-scripts .icon { content: url(Images/resourceJSIcon.png); } -.network.panel .data-grid.small .network-category-scripts .icon { +.network-sidebar .data-grid.small .network-category-scripts .icon { content: url(Images/resourceDocumentIconSmall.png); } -.network.panel .network-category-documents .icon { +.network-sidebar .network-category-documents .icon { content: url(Images/resourceDocumentIcon.png); } -.network.panel .data-grid.small .network-category-documents .icon { +.network-sidebar .data-grid.small .network-category-documents .icon { content: url(Images/resourceDocumentIconSmall.png); } -.network.panel .network-category-stylesheets .icon { +.network-sidebar .network-category-stylesheets .icon { content: url(Images/resourceCSSIcon.png); } -.network.panel .data-grid.small .network-category-stylesheets .icon { +.network-sidebar .data-grid.small .network-category-stylesheets .icon { content: url(Images/resourceDocumentIconSmall.png); } -.network.panel .network-category-images .icon { +.network-sidebar .network-category-images .icon { position: relative; background-image: url(Images/resourcePlainIcon.png); background-repeat: no-repeat; content: ""; } -.network.panel .network-category-images .icon { +.network-sidebar .network-category-images .icon { position: relative; background-image: url(Images/resourcePlainIcon.png); background-repeat: no-repeat; content: ""; } -.network.panel .data-grid.small .network-category-images .icon { +.network-sidebar .data-grid.small .network-category-images .icon { background-image: url(Images/resourcePlainIconSmall.png); content: ""; } -.network.panel .data-grid .icon { +.network-sidebar .data-grid .icon { float: left; width: 32px; height: 32px; @@ -171,12 +171,12 @@ margin-right: 3px; } -.network.panel .data-grid.small .icon { +.network-sidebar .data-grid.small .icon { width: 16px; height: 16px; } -.network.panel .image-network-icon-preview { +.network-sidebar .image-network-icon-preview { position: absolute; margin: auto; top: 3px; @@ -189,7 +189,7 @@ min-height: 1px; } -.network.panel .data-grid.small .image-network-icon-preview { +.network-sidebar .data-grid.small .image-network-icon-preview { top: 2px; bottom: 1px; left: 3px; @@ -407,7 +407,7 @@ z-index: 300; } -.network.panel .network-timeline-grid.small .network-event-divider { +.network-sidebar .network-timeline-grid.small .network-event-divider { top: 23px; } @@ -419,40 +419,40 @@ background-color: rgba(0, 0, 255, 0.5); } -.network.panel .resources-dividers { +.network-sidebar .resources-dividers { z-index: 0; } -.network.panel .resources-dividers-label-bar { +.network-sidebar .resources-dividers-label-bar { background-color: transparent; border: none; height: 30px; pointer-events: none; } -.network.panel .network-timeline-grid.small .resources-dividers-label-bar { +.network-sidebar .network-timeline-grid.small .resources-dividers-label-bar { height: 23px; } -.network.panel .resources-divider-label { +.network-sidebar .resources-divider-label { top: 0px; margin-top: -4px; color: black; } -.network.panel .resources-dividers-label-bar .resources-divider { +.network-sidebar .resources-dividers-label-bar .resources-divider { top: 23px; } -.network.panel .network-timeline-grid.small .resources-dividers-label-bar .resources-divider { +.network-sidebar .network-timeline-grid.small .resources-dividers-label-bar .resources-divider { top: 15px; } -.network.panel .resources-divider.first .resources-divider-label { +.network-sidebar .resources-divider.first .resources-divider-label { display: none; } -.network.panel .resources-dividers-label-bar .resources-divider.first { +.network-sidebar .resources-dividers-label-bar .resources-divider.first { background-color: transparent; } @@ -487,10 +487,12 @@ height: 20px; font-size: 11px; font-weight: bold; - padding-top: 1px; + padding-top: 3px; padding-left: 10px; z-index: 2000; white-space: pre; + overflow : hidden; + text-overflow : ellipsis; } .network-summary-bar-bottom { @@ -505,14 +507,14 @@ white-space: pre; } -.network.panel .data-grid td.network-summary { +.network-sidebar .data-grid td.network-summary { padding: 0; } /* Viewer */ -.network.panel.viewing-resource .data-grid td, -.network.panel.viewing-resource .data-grid th { +.network.panel.viewing-resource .network-sidebar .data-grid td, +.network.panel.viewing-resource .network-sidebar .data-grid th { border-right: none; } @@ -544,7 +546,7 @@ left: 0; } -.network-close-button { +#network-close-button { position: absolute; width: 14px; height: 14px; @@ -552,21 +554,39 @@ background-position: 0 0; background-color: transparent; border: 0 none transparent; - top: 4px; - right: 5px; + top: 8px; + left: 5px; z-index: 10; + display: none; +} + +#network-views.small #network-close-button { + top: 4px; +} + +#network-close-button:hover { + background-position: 14px 0; +} + +#network-close-button:active { + background-position: 28px 0; } -.network.panel .data-grid.full-grid-mode .viewer-column { +.network.panel.viewing-resource #network-close-button { + display: block; +} + + +.network-sidebar .data-grid.full-grid-mode .viewer-column { display: none; } -.network.panel .data-grid.brief-grid-mode .viewer-column, -.network.panel .data-grid.brief-grid-mode .method-column, -.network.panel .data-grid.brief-grid-mode .status-column, -.network.panel .data-grid.brief-grid-mode .type-column, -.network.panel .data-grid.brief-grid-mode .size-column, -.network.panel .data-grid.brief-grid-mode .time-column { +.network-sidebar .data-grid.brief-grid-mode .viewer-column, +.network-sidebar .data-grid.brief-grid-mode .method-column, +.network-sidebar .data-grid.brief-grid-mode .status-column, +.network-sidebar .data-grid.brief-grid-mode .type-column, +.network-sidebar .data-grid.brief-grid-mode .size-column, +.network-sidebar .data-grid.brief-grid-mode .time-column { display: none; } @@ -574,12 +594,12 @@ display: none; } -.network.panel .data-grid.viewing-resource-mode .method-column, -.network.panel .data-grid.viewing-resource-mode .status-column, -.network.panel .data-grid.viewing-resource-mode .type-column, -.network.panel .data-grid.viewing-resource-mode .size-column, -.network.panel .data-grid.viewing-resource-mode .time-column, -.network.panel .data-grid.viewing-resource-mode .timeline-column { +.network-sidebar .data-grid.viewing-resource-mode .method-column, +.network-sidebar .data-grid.viewing-resource-mode .status-column, +.network-sidebar .data-grid.viewing-resource-mode .type-column, +.network-sidebar .data-grid.viewing-resource-mode .size-column, +.network-sidebar .data-grid.viewing-resource-mode .time-column, +.network-sidebar .data-grid.viewing-resource-mode .timeline-column { display: none; } @@ -595,7 +615,7 @@ display: none; } -.network.panel.viewing-resource .data-grid-resizer { +.network.panel.viewing-resource .network-sidebar .data-grid-resizer { display: none; } @@ -604,19 +624,17 @@ padding-top: 5px; } -#network-views .resource-view.headers-visible .resource-view-content { - top: 31px; -} - -#network-views.small .resource-view.headers-visible .resource-view-content { - top: 23px; -} - -#network-views .resource-view-headers { +#network-views .resource-view-headers, +#network-views .resource-view-content, +#network-views .resource-view-cookies +{ top: 31px; } -#network-views.small .resource-view-headers { +#network-views.small .resource-view-headers, +#network-views.small .resource-view-content, +#network-views.small .resource-view-cookies +{ top: 23px; } @@ -627,12 +645,13 @@ #network-views .resource-view .tabbed-pane-header { height: 31px; - padding-top: 11px; + padding-top: 8px; + padding-left: 25px; } #network-views.small .resource-view .tabbed-pane-header { height: 23px; - padding-top: 3px; + padding-top: 0; } .network.panel.viewing-resource .data-grid .data-container { |