diff options
Diffstat (limited to 'WebCore/inspector')
40 files changed, 837 insertions, 424 deletions
diff --git a/WebCore/inspector/CodeGeneratorInspector.pm b/WebCore/inspector/CodeGeneratorInspector.pm index cadfaac..afaddec 100644 --- a/WebCore/inspector/CodeGeneratorInspector.pm +++ b/WebCore/inspector/CodeGeneratorInspector.pm @@ -6,6 +6,7 @@ package CodeGeneratorInspector; use strict; +use Class::Struct; use File::stat; my %typeTransform; @@ -21,56 +22,56 @@ $typeTransform{"Object"} = { "retVal" => "PassRefPtr<InspectorObject>", "forward" => "InspectorObject", "header" => "InspectorValues.h", - "push" => "push" + "accessorSuffix" => "" }; $typeTransform{"Array"} = { "param" => "PassRefPtr<InspectorArray>", "retVal" => "PassRefPtr<InspectorArray>", "forward" => "InspectorArray", "header" => "InspectorValues.h", - "push" => "push" + "accessorSuffix" => "" }; $typeTransform{"Value"} = { "param" => "PassRefPtr<InspectorValue>", "retVal" => "PassRefPtr<InspectorValue>", "forward" => "InspectorValue", "header" => "InspectorValues.h", - "push" => "push" + "accessorSuffix" => "" }; $typeTransform{"String"} = { "param" => "const String&", "retVal" => "String", "forward" => "String", "header" => "PlatformString.h", - "push" => "pushString" + "accessorSuffix" => "String" }; $typeTransform{"long"} = { "param" => "long", "retVal" => "long", "forward" => "", "header" => "", - "push" => "pushNumber" + "accessorSuffix" => "Number" }; $typeTransform{"int"} = { "param" => "int", "retVal" => "int", "forward" => "", "header" => "", - "push" => "pushNumber" + "accessorSuffix" => "Number", }; $typeTransform{"unsigned long"} = { "param" => "unsigned long", "retVal" => "unsigned long", "forward" => "", "header" => "", - "push" => "pushNumber" + "accessorSuffix" => "Number" }; $typeTransform{"boolean"} = { "param" => "bool", "retVal"=> "bool", "forward" => "", "header" => "", - "push" => "pushBool" + "accessorSuffix" => "Bool" }; $typeTransform{"void"} = { "retVal" => "void", @@ -88,26 +89,22 @@ EOF my $codeGenerator; my $outputDir; +my $outputHeadersDir; my $writeDependencies; my $verbose; my $namespace; -my $fileName; -my %discoveredTypes; -my @classDefinition; -my @functionDefinitions; +my $frontendClassName; +my %frontendTypes; +my %frontendMethods; +my @frontendMethodsImpl; +my $frontendConstructor; +my $frontendFooter; -sub typeSpec -{ - my $param = shift; - my $retValue = shift; - - my $type = $typeTransform{$param->type}->{$retValue ? "retVal" : "param"}; - $discoveredTypes{$param->type} = 1; - $type or die "invalid type specification \"" . $param->type ."\""; - return $type; -} +my $callId = new domSignature(); # it is just structure for describing parameters from IDLStructure.pm. +$callId->type("long"); +$callId->name("callId"); # Default constructor sub new @@ -117,6 +114,7 @@ sub new $codeGenerator = shift; $outputDir = shift; + $outputHeadersDir = shift; shift; # $useLayerOnTop shift; # $preprocessor $writeDependencies = shift; @@ -133,6 +131,7 @@ sub GenerateModule my $dataNode = shift; $namespace = $dataNode->module; + $namespace =~ s/core/WebCore/; } # Params: 'idlDocument' struct @@ -143,103 +142,126 @@ sub GenerateInterface my $defines = shift; my $className = $interface->name; - $fileName = $className; - - $discoveredTypes{"String"} = 1; - $discoveredTypes{"InspectorClient"} = 1; - $discoveredTypes{"PassRefPtr"} = 1; - - push(@classDefinition, "class $className {"); - push(@classDefinition, "public:"); - push(@classDefinition, " $className(InspectorClient* inspectorClient) : m_inspectorClient(inspectorClient) { }"); - push(@classDefinition, ""); - push(@classDefinition, generateFunctionsDeclarations($interface, $className)); - push(@classDefinition, ""); - push(@classDefinition, "private:"); - push(@classDefinition, " void sendSimpleMessageToFrontend(const String&);"); - push(@classDefinition, " InspectorClient* m_inspectorClient;"); - push(@classDefinition, "};"); - - push(@functionDefinitions, "void ${className}::sendSimpleMessageToFrontend(const String& functionName)"); - push(@functionDefinitions, "{"); - push(@functionDefinitions, " RefPtr<InspectorArray> arguments = InspectorArray::create();"); - push(@functionDefinitions, " arguments->pushString(functionName);"); - push(@functionDefinitions, " m_inspectorClient->sendMessageToFrontend(arguments->toJSONString());"); - push(@functionDefinitions, "}"); + + $frontendClassName = "Remote" . $className . "Frontend"; + $frontendConstructor = " ${frontendClassName}(InspectorClient* inspectorClient) : m_inspectorClient(inspectorClient) { }"; + $frontendFooter = " InspectorClient* m_inspectorClient;"; + $frontendTypes{"String"} = 1; + $frontendTypes{"InspectorClient"} = 1; + $frontendTypes{"PassRefPtr"} = 1; + + generateFunctions($interface); } -sub generateFunctionsDeclarations +sub generateFunctions { my $interface = shift; - my $className = shift; - my @functionDeclarations; foreach my $function (@{$interface->functions}) { - my $functionName = $function->signature->name; - my $abstract = $function->signature->extendedAttributes->{"abstract"}; - my $arguments = ""; - foreach my $parameter (@{$function->parameters}) { - $parameter->name or die "empty argument name specified for function ${className}::$functionName and argument type " . $parameter->type; - $arguments = $arguments . ", " if ($arguments); - $arguments = $arguments . typeSpec($parameter) . " " . $parameter->name; - } - my $signature = " " . typeSpec($function->signature, 1) . " $functionName($arguments)"; - push(@functionDeclarations, $abstract ? "$signature = 0;" : "$signature;"); - push(@functionDefinitions, generateFunctionsImpl($className, $function, $arguments)) if !$abstract; + generateFrontendFunction($function); } - return @functionDeclarations; } -sub generateHeader +sub generateFrontendFunction { - my @headerContent = split("\r", $licenseTemplate); - push(@headerContent, "#ifndef ${fileName}_h"); - push(@headerContent, "#define ${fileName}_h"); - push(@headerContent, ""); - - my @forwardHeaders; - foreach my $type (keys %discoveredTypes) { - push(@forwardHeaders, "#include <" . $typeTransform{$type}->{"forwardHeader"} . ">") if !$typeTransform{$type}->{"forwardHeader"} eq ""; + my $function = shift; + + my $functionName; + my $notify = $function->signature->extendedAttributes->{"notify"}; + if ($notify) { + $functionName = $function->signature->name; + } else { + my $customResponse = $function->signature->extendedAttributes->{"customResponse"}; + $functionName = $customResponse ? $customResponse : "did" . ucfirst($function->signature->name); } - push(@headerContent, sort @forwardHeaders); - push(@headerContent, ""); - push(@headerContent, "namespace $namespace {"); - push(@headerContent, ""); - - my @forwardDeclarations; - foreach my $type (keys %discoveredTypes) { - push(@forwardDeclarations, "class " . $typeTransform{$type}->{"forward"} . ";") if !$typeTransform{$type}->{"forward"} eq ""; + + my @argsFiltered = grep($_->direction eq "out", @{$function->parameters}); # just keep only out parameters for frontend interface. + unshift(@argsFiltered, $callId) if !$notify; # Add callId as the first argument for all frontend did* methods. + map($frontendTypes{$_->type} = 1, @argsFiltered); # register required types. + my $arguments = join(", ", map($typeTransform{$_->type}->{"param"} . " " . $_->name, @argsFiltered)); # prepare arguments for function signature. + my @pushArguments = map(" arguments->push" . $typeTransform{$_->type}->{"accessorSuffix"} . "(" . $_->name . ");", @argsFiltered); + + my $signature = " void ${functionName}(${arguments});"; + if (!$frontendMethods{${signature}}) { + $frontendMethods{${signature}} = 1; + + my @function; + push(@function, "void ${frontendClassName}::${functionName}(${arguments})"); + push(@function, "{"); + push(@function, " RefPtr<InspectorArray> arguments = InspectorArray::create();"); + push(@function, " arguments->pushString(\"$functionName\");"); + push(@function, @pushArguments); + push(@function, " m_inspectorClient->sendMessageToFrontend(arguments->toJSONString());"); + push(@function, "}"); + push(@function, ""); + push(@frontendMethodsImpl, @function); } - push(@headerContent, sort @forwardDeclarations); - - push(@headerContent, ""); - push(@headerContent, @classDefinition); - push(@headerContent, ""); - push(@headerContent, "} // namespace $namespace"); - push(@headerContent, ""); - push(@headerContent, "#endif // !defined(${fileName}_h)"); - push(@headerContent, ""); - return @headerContent; +} + +sub generateHeader +{ + my $className = shift; + my $types = shift; + my $constructor = shift; + my $methods = shift; + my $footer = shift; + + my $forwardHeaders = join("\n", sort(map("#include <" . $typeTransform{$_}->{"forwardHeader"} . ">", grep($typeTransform{$_}->{"forwardHeader"}, keys %{$types})))); + my $forwardDeclarations = join("\n", sort(map("class " . $typeTransform{$_}->{"forward"} . ";", grep($typeTransform{$_}->{"forward"}, keys %{$types})))); + my $methodsDeclarations = join("\n", keys %{$methods}); + + my $headerBody = << "EOF"; +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#ifndef ${className}_h +#define ${className}_h + +${forwardHeaders} + +namespace $namespace { + +$forwardDeclarations + +class $className { +public: +$constructor + +$methodsDeclarations + +private: +$footer +}; + +} // namespace $namespace +#endif // !defined(${className}_h) + +EOF + return $headerBody; } sub generateSource { + my $className = shift; + my $types = shift; + my $methods = shift; + my @sourceContent = split("\r", $licenseTemplate); push(@sourceContent, "\n#include \"config.h\""); - push(@sourceContent, "#include \"Remote$fileName.h\""); + push(@sourceContent, "#include \"$className.h\""); push(@sourceContent, ""); push(@sourceContent, "#if ENABLE(INSPECTOR)"); push(@sourceContent, ""); my %headers; - foreach my $type (keys %discoveredTypes) { + foreach my $type (keys %{$types}) { $headers{"#include \"" . $typeTransform{$type}->{"header"} . "\""} = 1 if !$typeTransform{$type}->{"header"} eq ""; } push(@sourceContent, sort keys %headers); push(@sourceContent, ""); push(@sourceContent, "namespace $namespace {"); push(@sourceContent, ""); - push(@sourceContent, @functionDefinitions); + push(@sourceContent, @{$methods}); push(@sourceContent, ""); push(@sourceContent, "} // namespace $namespace"); push(@sourceContent, ""); @@ -248,51 +270,20 @@ sub generateSource return @sourceContent; } -sub generateFunctionsImpl -{ - my $className = shift; - my $function = shift; - my $arguments = shift; - - my @func; - - my $functionName = $function->signature->name; - - push(@func, typeSpec($function->signature, 1) . " " . $className . "::" . $functionName . "(" . $arguments . ")"); - push(@func, "{"); - - my $numParameters = @{$function->parameters}; - if ($numParameters > 0) { - push(@func, " RefPtr<InspectorArray> arguments = InspectorArray::create();"); - push(@func, " arguments->pushString(\"$functionName\");"); - foreach my $parameter (@{$function->parameters}) { - my $pushCall = $typeTransform{$parameter->type}->{"push"}; - push(@func, " arguments->$pushCall(" . $parameter->name . ");"); - } - push(@func, " m_inspectorClient->sendMessageToFrontend(arguments->toJSONString());"); - } else { - push(@func, " sendSimpleMessageToFrontend(\"$functionName\");"); - } - - push(@func, "}"); - push(@func, ""); - return @func; -} - sub finish { my $object = shift; - open(my $SOURCE, ">$outputDir/Remote$fileName.cpp") || die "Couldn't open file $outputDir/Remote$fileName.cpp"; - open(my $HEADER, ">$outputDir/Remote$fileName.h") || die "Couldn't open file $outputDir/Remote$fileName.h"; - - print $SOURCE join("\n", generateSource()); + open(my $SOURCE, ">$outputDir/$frontendClassName.cpp") || die "Couldn't open file $outputDir/$frontendClassName.cpp"; + print $SOURCE join("\n", generateSource($frontendClassName, \%frontendTypes, \@frontendMethodsImpl)); close($SOURCE); undef($SOURCE); - print $HEADER join("\n", generateHeader()); + open(my $HEADER, ">$outputHeadersDir/$frontendClassName.h") || die "Couldn't open file $outputHeadersDir/$frontendClassName.h"; + print $HEADER generateHeader($frontendClassName, \%frontendTypes, $frontendConstructor, \%frontendMethods, $frontendFooter); close($HEADER); undef($HEADER); + } 1; diff --git a/WebCore/inspector/ConsoleMessage.cpp b/WebCore/inspector/ConsoleMessage.cpp index 934e2e9..79b5115 100644 --- a/WebCore/inspector/ConsoleMessage.cpp +++ b/WebCore/inspector/ConsoleMessage.cpp @@ -40,6 +40,34 @@ 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; +} + +ScriptObject ConsoleMessage::CallFrame::buildObject(InspectorFrontend* frontend) const +{ + ScriptObject frame = frontend->newScriptObject(); + frame.set("functionName", m_functionName); + frame.set("sourceURL", m_sourceURL.string()); + frame.set("lineNumber", m_lineNumber); + return frame; +} + ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u, unsigned g) : m_source(s) , m_type(t) @@ -52,10 +80,11 @@ ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, c { } -ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, ScriptCallStack* callStack, unsigned g, bool storeTrace) +ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, ScriptCallStack* callStack, unsigned g, bool storeTrace) : 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()) @@ -68,12 +97,9 @@ ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, S m_line = lastCaller.lineNumber(); m_url = lastCaller.sourceURL().string(); - // FIXME: For now, just store function names as strings. - // As ScriptCallStack start storing line number and source URL for all - // frames, refactor to use that, as well. if (storeTrace) { for (unsigned i = 0; i < callStack->size(); ++i) - m_frames[i] = callStack->at(i).functionName(); + m_frames[i] = ConsoleMessage::CallFrame(callStack->at(i)); } #if ENABLE(INSPECTOR) @@ -93,15 +119,26 @@ void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHo jsonObj.set("url", m_url); jsonObj.set("groupLevel", static_cast<int>(m_groupLevel)); jsonObj.set("repeatCount", static_cast<int>(m_repeatCount)); - Vector<RefPtr<SerializedScriptValue> > arguments; + jsonObj.set("message", m_message); if (!m_arguments.isEmpty()) { + ScriptArray jsonArgs = frontend->newScriptArray(); InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_scriptState.get()); for (unsigned i = 0; i < m_arguments.size(); ++i) { RefPtr<SerializedScriptValue> serializedValue = injectedScript.wrapForConsole(m_arguments[i]); - arguments.append(serializedValue); + if (!jsonArgs.set(i, serializedValue.get())) { + ASSERT_NOT_REACHED(); + return; + } } - } - frontend->addConsoleMessage(jsonObj, m_frames, arguments, m_message); + jsonObj.set("parameters", jsonArgs); + } + if (!m_frames.isEmpty()) { + ScriptArray frames = frontend->newScriptArray(); + for (unsigned i = 0; i < m_frames.size(); i++) + frames.set(i, m_frames.at(i).buildObject(frontend)); + jsonObj.set("stackTrace", frames); + } + frontend->addConsoleMessage(jsonObj); } void ConsoleMessage::updateRepeatCountInConsole(InspectorFrontend* frontend) @@ -133,7 +170,7 @@ bool ConsoleMessage::isEqual(ScriptState* state, ConsoleMessage* msg) const return false; for (size_t i = 0; i < frameCount; ++i) { - if (m_frames[i] != msg->m_frames[i]) + if (!m_frames[i].isEqual(msg->m_frames[i])) return false; } diff --git a/WebCore/inspector/ConsoleMessage.h b/WebCore/inspector/ConsoleMessage.h index 77a010c..3848dbf 100644 --- a/WebCore/inspector/ConsoleMessage.h +++ b/WebCore/inspector/ConsoleMessage.h @@ -32,6 +32,7 @@ #define ConsoleMessage_h #include "Console.h" +#include "KURL.h" #include "ScriptObject.h" #include "ScriptState.h" @@ -40,13 +41,14 @@ namespace WebCore { class InjectedScriptHost; class InspectorFrontend; +class ScriptCallFrame; class ScriptCallStack; class ScriptString; class ConsoleMessage : public Noncopyable { public: - ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g); - ConsoleMessage(MessageSource, MessageType, MessageLevel, ScriptCallStack*, unsigned g, bool storeTrace = false); + 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); #if ENABLE(INSPECTOR) void addToFrontend(InspectorFrontend*, InjectedScriptHost*); @@ -59,6 +61,19 @@ public: const String& message() const { return m_message; } private: + class CallFrame { + public: + explicit CallFrame(const ScriptCallFrame& frame); + CallFrame(); + bool isEqual(const CallFrame& o) const; + ScriptObject buildObject(InspectorFrontend* frontend) const; + + private: + String m_functionName; + KURL m_sourceURL; + unsigned m_lineNumber; + }; + MessageSource m_source; MessageType m_type; MessageLevel m_level; @@ -67,7 +82,7 @@ private: Vector<ScriptValue> m_arguments; ScriptStateProtectedPtr m_scriptState; #endif - Vector<ScriptString> m_frames; + Vector<CallFrame> m_frames; unsigned m_line; String m_url; unsigned m_groupLevel; diff --git a/WebCore/inspector/Inspector.idl b/WebCore/inspector/Inspector.idl new file mode 100644 index 0000000..3c96db1 --- /dev/null +++ b/WebCore/inspector/Inspector.idl @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> + * 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 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. + */ + +module core { + interface [Conditional=INSPECTOR] Inspector { + [notify] void addRecordToTimeline(out Object record); + [notify] void addNodesToSearchResult(out Array nodeIds); + [notify] void attributesUpdated(out long id, out Array attributes); + [notify] void childNodeCountUpdated(out long id, out int newValue); + [notify] void childNodeInserted(out long parentId, out long prevId, out Object node); + [notify] void childNodeRemoved(out long parentId, out long id); + [notify] void setChildNodes(out long parentId, out Array nodes); + [notify] void setDetachedRoot(out Object root); + [notify] void setDocument(out Value root); + + void storeLastActivePanel(in String panelName); + + void saveApplicationSettings(in String settings); + void saveSessionSettings(in String settings); + + void enableSearchingForNode(); + void disableSearchingForNode(); + + void enableMonitoringXHR(); + void disableMonitoringXHR(); + + void enableResourceTracking(in boolean always); + void disableResourceTracking(in boolean always); + void getResourceContent(in long callId, in unsigned long identifier); + void reloadPage(); + + void startTimelineProfiler(); + void stopTimelineProfiler(); + +#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER + void enableDebugger(in boolean always); + void disableDebugger(in boolean always); + + void setBreakpoint(in long callId, in String sourceID, in unsigned long lineNumber, in boolean enabled, in String condition); + void removeBreakpoint(in String sourceID, in unsigned long lineNumber); + void activateBreakpoints(); + void deactivateBreakpoints(); + + void pause(); + void resume(); + + void stepOverStatement(); + void stepIntoStatement(); + void stepOutOfFunction(); + + void setPauseOnExceptionsState(in long pauseOnExceptionsState); + + void editScriptSource(in long callId, in String sourceID, in String newContent); + void getScriptSource(in long callId, in String sourceID); + + void enableProfiler(in boolean always); + void disableProfiler(in boolean always); + + void startProfiling(); + void stopProfiling(); + + void getProfileHeaders(in long callId); + void getProfile(in long callId, in unsigned long uid); + + void removeProfile(in unsigned long uid); + void clearProfiles(); + + void takeHeapSnapshot(); +#endif + void setInjectedScriptSource(in String scriptSource); + void dispatchOnInjectedScript(in long callId, in long injectedScriptId, in String methodName, in String arguments, in boolean async); + + void addScriptToEvaluateOnLoad(in String scriptSource); + void removeAllScriptsToEvaluateOnLoad(); + + void getChildNodes(in long callId, in long nodeId); + [customResponse=didApplyDomChange] void setAttribute(in long callId, in long elementId, in String name, in String value, out boolean success); + [customResponse=didApplyDomChange] void removeAttribute(in long callId, in long elementId, in String name, out boolean success); + void setTextNodeValue(in long callId, in long nodeId, in String value); + void getEventListenersForNode(in long callId, in long nodeId, out long nodeId, out Array listenersArray); + void copyNode(in long nodeId); + void removeNode(in long callId, in long nodeId, out long nodeId); + void changeTagName(in long callId, in long nodeId, in String newTagName, out long nodeId); + void getOuterHTML(in long callId, in long nodeId, out String outerHTML); + void setOuterHTML(in long callId, in long nodeId, in String outerHTML, out long nodeId); + void addInspectedNode(in long nodeId); + void performSearch(in String query, in boolean runSynchronously); + void searchCanceled(); + void pushNodeByPathToFrontend(in long callId, in String path, out long nodeId); + + void clearConsoleMessages(); + + void highlightDOMNode(in long nodeId); + void hideDOMNodeHighlight(); + + void getStyles(in long callId, in long nodeId, in boolean authOnly, out Value styles); + void getAllStyles(in long callId, out Array styles); + void getInlineStyle(in long callId, in long nodeId, out Value style); + void getComputedStyle(in long callId, in long nodeId, out Value style); + void getStyleSheet(in long callId, in long styleSheetId, out Value styleSheet); + void getRuleRangesForStyleSheetId(in long callId, in long styleSheetId); + void applyStyleText(in long callId, in long styleId, in String styleText, in String propertyName, out boolean success, out Value style, out Array changedProperties); + void setStyleText(in long callId, in long styleId, in String styleText, out boolean success); + void setStyleProperty(in long callId, in long styleId, in String name, in String value, out boolean success); + void toggleStyleEnabled(in long callId, in long styleId, in String propertyName, in boolean disabled, out Value style); + void setRuleSelector(in long callId, in long ruleId, in String selector, in long selectedNodeId, out Value rule, out boolean selectorAffectsNode); + void addRule(in long callId, in String selector, in long selectedNodeId, out Value rule, out boolean selectorAffectsNode); + + void getCookies(in long callId); + void deleteCookie(in String cookieName, in String domain); + +#if defined(ENABLE_OFFLINE_WEB_APPLICATIONS) && ENABLE_OFFLINE_WEB_APPLICATIONS + void getApplicationCaches(in long callId); +#endif + + void releaseWrapperObjectGroup(in long injectedScriptId, in String objectGroup); + void didEvaluateForTestInFrontend(in long callId, in String jsonResult); + +#if defined(ENABLE_DATABASE) && ENABLE_DATABASE + void getDatabaseTableNames(in long callId, in long databaseId); +#endif + +#if defined(ENABLE_DOM_STORAGE) && ENABLE_DOM_STORAGE + void getDOMStorageEntries(in long callId, in long storageId); + void setDOMStorageItem(in long callId, in long storageId, in String key, in String value); + void removeDOMStorageItem(in long callId, in long storageId, in String key); +#endif + }; +} diff --git a/WebCore/inspector/InspectorBackend.cpp b/WebCore/inspector/InspectorBackend.cpp index 57ee19f..9f71307 100644 --- a/WebCore/inspector/InspectorBackend.cpp +++ b/WebCore/inspector/InspectorBackend.cpp @@ -86,13 +86,13 @@ InspectorBackend::~InspectorBackend() void InspectorBackend::saveApplicationSettings(const String& settings) { if (m_inspectorController) - m_inspectorController->setSetting(InspectorController::frontendSettingsSettingName(), settings); + m_inspectorController->saveApplicationSettings(settings); } void InspectorBackend::saveSessionSettings(const String& settings) { if (m_inspectorController) - m_inspectorController->setSessionSettings(settings); + m_inspectorController->saveSessionSettings(settings); } void InspectorBackend::storeLastActivePanel(const String& panelName) @@ -104,25 +104,25 @@ void InspectorBackend::storeLastActivePanel(const String& panelName) void InspectorBackend::enableSearchingForNode() { if (m_inspectorController) - m_inspectorController->setSearchingForNode(true); + m_inspectorController->enableSearchingForNode(); } void InspectorBackend::disableSearchingForNode() { if (m_inspectorController) - m_inspectorController->setSearchingForNode(false); + m_inspectorController->disableSearchingForNode(); } void InspectorBackend::enableMonitoringXHR() { if (m_inspectorController) - m_inspectorController->setMonitoringXHR(true); + m_inspectorController->enableMonitoringXHR(); } void InspectorBackend::disableMonitoringXHR() { if (m_inspectorController) - m_inspectorController->setMonitoringXHR(false); + m_inspectorController->disableMonitoringXHR(); } void InspectorBackend::enableResourceTracking(bool always) @@ -139,21 +139,14 @@ void InspectorBackend::disableResourceTracking(bool always) void InspectorBackend::getResourceContent(long callId, unsigned long identifier) { - InspectorFrontend* frontend = inspectorFrontend(); - if (!frontend) - return; - - RefPtr<InspectorResource> resource = m_inspectorController->resources().get(identifier); - if (resource) - frontend->didGetResourceContent(callId, resource->sourceString()); - else - frontend->didGetResourceContent(callId, ""); + if (m_inspectorController) + m_inspectorController->getResourceContent(callId, identifier); } void InspectorBackend::reloadPage() { if (m_inspectorController) - m_inspectorController->m_inspectedPage->mainFrame()->redirectScheduler()->scheduleRefresh(true); + m_inspectorController->reloadPage(); } void InspectorBackend::startTimelineProfiler() @@ -196,45 +189,44 @@ void InspectorBackend::removeBreakpoint(const String& sourceID, unsigned lineNum void InspectorBackend::activateBreakpoints() { - ScriptDebugServer::shared().setBreakpointsActivated(true); + ScriptDebugServer::shared().activateBreakpoints(); } void InspectorBackend::deactivateBreakpoints() { - ScriptDebugServer::shared().setBreakpointsActivated(false); + ScriptDebugServer::shared().deactivateBreakpoints(); } -void InspectorBackend::pauseInDebugger() +void InspectorBackend::pause() { - ScriptDebugServer::shared().pauseProgram(); + ScriptDebugServer::shared().pause(); } -void InspectorBackend::resumeDebugger() +void InspectorBackend::resume() { if (m_inspectorController) - m_inspectorController->resumeDebugger(); + m_inspectorController->resume(); } -void InspectorBackend::stepOverStatementInDebugger() +void InspectorBackend::stepOverStatement() { ScriptDebugServer::shared().stepOverStatement(); } -void InspectorBackend::stepIntoStatementInDebugger() +void InspectorBackend::stepIntoStatement() { ScriptDebugServer::shared().stepIntoStatement(); } -void InspectorBackend::stepOutOfFunctionInDebugger() +void InspectorBackend::stepOutOfFunction() { ScriptDebugServer::shared().stepOutOfFunction(); } void InspectorBackend::setPauseOnExceptionsState(long pauseState) { - ScriptDebugServer::shared().setPauseOnExceptionsState(static_cast<ScriptDebugServer::PauseOnExceptionsState>(pauseState)); - if (InspectorFrontend* frontend = inspectorFrontend()) - frontend->updatePauseOnExceptionsState(ScriptDebugServer::shared().pauseOnExceptionsState()); + if (m_inspectorController) + m_inspectorController->setPauseOnExceptionsState(pauseState); } void InspectorBackend::editScriptSource(long callId, const String& sourceID, const String& newContent) @@ -368,11 +360,8 @@ void InspectorBackend::getEventListenersForNode(long callId, long nodeId) void InspectorBackend::copyNode(long nodeId) { - Node* node = nodeForId(nodeId); - if (!node) - return; - String markup = createMarkup(node); - Pasteboard::generalPasteboard()->writePlainText(markup); + if (InspectorDOMAgent* domAgent = inspectorDOMAgent()) + domAgent->copyNode(nodeId); } void InspectorBackend::removeNode(long callId, long nodeId) @@ -419,13 +408,8 @@ void InspectorBackend::searchCanceled() void InspectorBackend::pushNodeByPathToFrontend(long callId, const String& path) { - InspectorDOMAgent* domAgent = inspectorDOMAgent(); - InspectorFrontend* frontend = inspectorFrontend(); - if (!domAgent || !frontend) - return; - - long id = domAgent->pushNodeByPathToFrontend(path); - frontend->didPushNodeByPathToFrontend(callId, id); + if (InspectorDOMAgent* domAgent = inspectorDOMAgent()) + domAgent->pushNodeByPathToFrontend(callId, path); } void InspectorBackend::clearConsoleMessages() @@ -508,14 +492,14 @@ void InspectorBackend::addRule(long callId, const String& selector, long selecte void InspectorBackend::highlightDOMNode(long nodeId) { - if (Node* node = nodeForId(nodeId)) - m_inspectorController->highlight(node); + if (m_inspectorController) + m_inspectorController->highlightDOMNode(nodeId); } void InspectorBackend::hideDOMNodeHighlight() { if (m_inspectorController) - m_inspectorController->hideHighlight(); + m_inspectorController->hideDOMNodeHighlight(); } #if ENABLE(OFFLINE_WEB_APPLICATIONS) @@ -613,13 +597,6 @@ InspectorFrontend* InspectorBackend::inspectorFrontend() return m_inspectorController->m_frontend.get(); } -Node* InspectorBackend::nodeForId(long nodeId) -{ - if (InspectorDOMAgent* domAgent = inspectorDOMAgent()) - return domAgent->nodeForId(nodeId); - return 0; -} - void InspectorBackend::addScriptToEvaluateOnLoad(const String& source) { if (m_inspectorController) diff --git a/WebCore/inspector/InspectorBackend.h b/WebCore/inspector/InspectorBackend.h index 47cfdc7..78d34b6 100644 --- a/WebCore/inspector/InspectorBackend.h +++ b/WebCore/inspector/InspectorBackend.h @@ -86,12 +86,12 @@ public: void activateBreakpoints(); void deactivateBreakpoints(); - void pauseInDebugger(); - void resumeDebugger(); + void pause(); + void resume(); - void stepOverStatementInDebugger(); - void stepIntoStatementInDebugger(); - void stepOutOfFunctionInDebugger(); + void stepOverStatement(); + void stepIntoStatement(); + void stepOutOfFunction(); void setPauseOnExceptionsState(long pauseState); diff --git a/WebCore/inspector/InspectorBackend.idl b/WebCore/inspector/InspectorBackend.idl index 1fc8a16..3c460a1 100644 --- a/WebCore/inspector/InspectorBackend.idl +++ b/WebCore/inspector/InspectorBackend.idl @@ -60,12 +60,12 @@ module core { void activateBreakpoints(); void deactivateBreakpoints(); - void pauseInDebugger(); - void resumeDebugger(); + void pause(); + void resume(); - void stepOverStatementInDebugger(); - void stepIntoStatementInDebugger(); - void stepOutOfFunctionInDebugger(); + void stepOverStatement(); + void stepIntoStatement(); + void stepOutOfFunction(); void setPauseOnExceptionsState(in long pauseOnExceptionsState); diff --git a/WebCore/inspector/InspectorCSSStore.cpp b/WebCore/inspector/InspectorCSSStore.cpp index 413fb8b..9dffef9 100644 --- a/WebCore/inspector/InspectorCSSStore.cpp +++ b/WebCore/inspector/InspectorCSSStore.cpp @@ -41,7 +41,7 @@ #include "InspectorController.h" #include "InspectorResource.h" #include "PlatformString.h" -#include "RemoteInspectorFrontend2.h" +#include "RemoteInspectorFrontend.h" #include "StyleSheetList.h" namespace WebCore { @@ -95,13 +95,13 @@ CSSStyleSheet* InspectorCSSStore::inspectorStyleSheet(Document* ownerDocument, b if (!ec) ownerDocument->head()->appendChild(styleElement, ec); if (ec) { - m_inspectorController->inspectorFrontend2()->didAddRule(callId, InspectorValue::null(), false); + m_inspectorController->remoteInspectorFrontend()->didAddRule(callId, InspectorValue::null(), false); return 0; } StyleSheetList* styleSheets = ownerDocument->styleSheets(); StyleSheet* styleSheet = styleSheets->item(styleSheets->length() - 1); if (!styleSheet->isCSSStyleSheet()) { - m_inspectorController->inspectorFrontend2()->didAddRule(callId, InspectorValue::null(), false); + m_inspectorController->remoteInspectorFrontend()->didAddRule(callId, InspectorValue::null(), false); return 0; } CSSStyleSheet* inspectorStyleSheet = static_cast<CSSStyleSheet*>(styleSheet); diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp index ed25696..8879b8e 100644 --- a/WebCore/inspector/InspectorController.cpp +++ b/WebCore/inspector/InspectorController.cpp @@ -68,7 +68,7 @@ #include "Page.h" #include "ProgressTracker.h" #include "Range.h" -#include "RemoteInspectorFrontend2.h" +#include "RemoteInspectorFrontend.h" #include "RenderInline.h" #include "ResourceRequest.h" #include "ResourceResponse.h" @@ -129,6 +129,8 @@ static const char* const inspectorAttachedHeightName = "inspectorAttachedHeight" static const char* const lastActivePanelSettingName = "lastActivePanel"; static const char* const monitoringXHRSettingName = "xhrMonitor"; +int connectedFrontendCount = 0; + const String& InspectorController::frontendSettingsSettingName() { DEFINE_STATIC_LOCAL(String, settingName, ("frontendSettings")); @@ -216,7 +218,6 @@ InspectorController::~InspectorController() ASSERT(!m_highlightedNode); deleteAllValues(m_frameResources); - deleteAllValues(m_consoleMessages); ASSERT(s_inspectorControllerCount); --s_inspectorControllerCount; @@ -266,7 +267,12 @@ void InspectorController::setSetting(const String& key, const String& value) m_client->storeSetting(key, value); } -void InspectorController::setSessionSettings(const String& settingsJSON) +void InspectorController::saveApplicationSettings(const String& settings) +{ + setSetting(InspectorController::frontendSettingsSettingName(), settings); +} + +void InspectorController::saveSessionSettings(const String& settingsJSON) { m_sessionSettings = InspectorValue::parseJSON(settingsJSON); } @@ -312,6 +318,13 @@ void InspectorController::highlight(Node* node) m_client->highlight(node); } +void InspectorController::highlightDOMNode(long nodeId) +{ + Node* node = 0; + if (m_domAgent && (node = m_domAgent->nodeForId(nodeId))) + highlight(node); +} + void InspectorController::hideHighlight() { if (!enabled()) @@ -325,12 +338,13 @@ bool InspectorController::windowVisible() return m_frontend; } -void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack) +void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack, const String& message) { if (!enabled()) return; - addConsoleMessage(callStack->state(), new ConsoleMessage(source, type, level, callStack, m_groupLevel, type == TraceMessageType)); + bool storeStackTrace = type == TraceMessageType || type == UncaughtExceptionMessageType || type == AssertMessageType; + addConsoleMessage(callStack->state(), new ConsoleMessage(source, type, level, message, callStack, m_groupLevel, storeStackTrace)); } void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID) @@ -341,18 +355,17 @@ void InspectorController::addMessageToConsole(MessageSource source, MessageType addConsoleMessage(0, new ConsoleMessage(source, type, level, message, lineNumber, sourceID, m_groupLevel)); } -void InspectorController::addConsoleMessage(ScriptState* scriptState, ConsoleMessage* consoleMessage) +void InspectorController::addConsoleMessage(ScriptState* scriptState, PassOwnPtr<ConsoleMessage> consoleMessage) { ASSERT(enabled()); ASSERT_ARG(consoleMessage, consoleMessage); - if (m_previousMessage && m_previousMessage->isEqual(scriptState, consoleMessage)) { + if (m_previousMessage && m_previousMessage->isEqual(scriptState, consoleMessage.get())) { m_previousMessage->incrementCount(); - delete consoleMessage; if (m_frontend) m_previousMessage->updateRepeatCountInConsole(m_frontend.get()); } else { - m_previousMessage = consoleMessage; + m_previousMessage = consoleMessage.get(); m_consoleMessages.append(consoleMessage); if (m_frontend) m_previousMessage->addToFrontend(m_frontend.get(), m_injectedScriptHost.get()); @@ -360,15 +373,12 @@ void InspectorController::addConsoleMessage(ScriptState* scriptState, ConsoleMes if (!m_frontend && m_consoleMessages.size() >= maximumConsoleMessages) { m_expiredConsoleMessageCount += expireConsoleMessagesStep; - for (size_t i = 0; i < expireConsoleMessagesStep; ++i) - delete m_consoleMessages[i]; m_consoleMessages.remove(0, expireConsoleMessagesStep); } } void InspectorController::clearConsoleMessages() { - deleteAllValues(m_consoleMessages); m_consoleMessages.clear(); m_expiredConsoleMessageCount = 0; m_previousMessage = 0; @@ -384,7 +394,7 @@ void InspectorController::startGroup(MessageSource source, ScriptCallStack* call { ++m_groupLevel; - addConsoleMessage(callStack->state(), new ConsoleMessage(source, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, callStack, m_groupLevel)); + addConsoleMessage(callStack->state(), new ConsoleMessage(source, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, String(), callStack, m_groupLevel)); } void InspectorController::endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL) @@ -486,10 +496,10 @@ void InspectorController::connectFrontend(const ScriptObject& webInspector) m_openingFrontend = false; releaseFrontendLifetimeAgents(); m_frontend = new InspectorFrontend(webInspector, m_client); - m_frontend2 = new InspectorFrontend2(m_client); - m_domAgent = InspectorDOMAgent::create(m_cssStore.get(), m_frontend2.get()); + m_remoteFrontend = new RemoteInspectorFrontend(m_client); + m_domAgent = InspectorDOMAgent::create(m_cssStore.get(), m_remoteFrontend.get()); if (m_timelineAgent) - m_timelineAgent->resetFrontendProxyObject(m_frontend2.get()); + m_timelineAgent->resetFrontendProxyObject(m_remoteFrontend.get()); // Initialize Web Inspector title. m_frontend->inspectedURLChanged(m_inspectedPage->mainFrame()->loader()->url().string()); @@ -523,6 +533,10 @@ void InspectorController::connectFrontend(const ScriptObject& webInspector) #if ENABLE(OFFLINE_WEB_APPLICATIONS) m_applicationCacheAgent = new InspectorApplicationCacheAgent(this, m_frontend.get()); #endif + + if (!connectedFrontendCount) + ScriptController::setCaptureCallStackForUncaughtExceptions(true); + connectedFrontendCount++; } void InspectorController::show() @@ -572,6 +586,10 @@ void InspectorController::disconnectFrontend() return; m_frontend.clear(); + connectedFrontendCount--; + if (!connectedFrontendCount) + ScriptController::setCaptureCallStackForUncaughtExceptions(false); + #if ENABLE(JAVASCRIPT_DEBUGGER) // If the window is being closed with the debugger enabled, // remember this state to re-enable debugger on the next window @@ -1163,7 +1181,7 @@ void InspectorController::startTimelineProfiler() if (m_timelineAgent) return; - m_timelineAgent = new InspectorTimelineAgent(m_frontend2.get()); + m_timelineAgent = new InspectorTimelineAgent(m_remoteFrontend.get()); if (m_frontend) m_frontend->timelineProfilerWasStarted(); m_client->timelineProfilerWasStarted(); @@ -1746,13 +1764,20 @@ void InspectorController::getScriptSource(long callId, const String& sourceID) m_frontend->didGetScriptSource(callId, scriptSource); } -void InspectorController::resumeDebugger() +void InspectorController::resume() { if (!m_debuggerEnabled) return; ScriptDebugServer::shared().continueProgram(); } +void InspectorController::setPauseOnExceptionsState(long pauseState) +{ + ScriptDebugServer::shared().setPauseOnExceptionsState(static_cast<ScriptDebugServer::PauseOnExceptionsState>(pauseState)); + if (m_frontend) + m_frontend->updatePauseOnExceptionsState(ScriptDebugServer::shared().pauseOnExceptionsState()); +} + PassRefPtr<SerializedScriptValue> InspectorController::currentCallFrames() { if (!m_pausedScriptState) @@ -2159,6 +2184,23 @@ void InspectorController::removeAllScriptsToEvaluateOnLoad() m_scriptsToEvaluateOnLoad.clear(); } +void InspectorController::getResourceContent(long callId, unsigned long identifier) +{ + if (!m_frontend) + return; + + RefPtr<InspectorResource> resource = m_resources.get(identifier); + if (resource) + m_frontend->didGetResourceContent(callId, resource->sourceString()); + else + m_frontend->didGetResourceContent(callId, ""); +} + +void InspectorController::reloadPage() +{ + m_inspectedPage->mainFrame()->redirectScheduler()->scheduleRefresh(true); +} + } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h index 9bb6c7d..76b88f1 100644 --- a/WebCore/inspector/InspectorController.h +++ b/WebCore/inspector/InspectorController.h @@ -69,7 +69,6 @@ class InspectorCSSStore; class InspectorDOMStorageResource; class InspectorDatabaseResource; class InspectorFrontend; -class InspectorFrontend2; class InspectorFrontendClient; class InspectorResource; class InspectorTimelineAgent; @@ -78,6 +77,7 @@ class InspectorWorkerResource; class KURL; class Node; class Page; +class RemoteInspectorFrontend; class ResourceRequest; class ResourceResponse; class ResourceError; @@ -127,14 +127,19 @@ public: bool enabled() const; Page* inspectedPage() const { return m_inspectedPage; } + void reloadPage(); String setting(const String& key) const; void setSetting(const String& key, const String& value); - void setSessionSettings(const String&); + void saveApplicationSettings(const String& settings); + void saveSessionSettings(const String&); + void inspect(Node*); void highlight(Node*); void hideHighlight(); + void highlightDOMNode(long nodeId); + void hideDOMNodeHighlight() { hideHighlight(); } void show(); void showPanel(SpecialPanels); @@ -146,10 +151,10 @@ public: void connectFrontend(const ScriptObject& webInspector); void disconnectFrontend(); - void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*); + void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*, const String& message = String()); void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID); void clearConsoleMessages(); - const Vector<ConsoleMessage*>& consoleMessages() const { return m_consoleMessages; } + const Vector<OwnPtr<ConsoleMessage> >& consoleMessages() const { return m_consoleMessages; } bool searchingForNodeInPage() const { return m_searchingForNode; } void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); @@ -220,7 +225,7 @@ public: const ResourcesMap& resources() const { return m_resources; } InspectorResource* resourceForURL(const String& url); InspectorFrontend* inspectorFrontend() { return m_frontend.get(); } - InspectorFrontend2* inspectorFrontend2() { return m_frontend2.get(); } + RemoteInspectorFrontend* remoteInspectorFrontend() { return m_remoteFrontend.get(); } void drawNodeHighlight(GraphicsContext&) const; @@ -246,6 +251,8 @@ public: String getCurrentUserInitiatedProfileName(bool incrementProfileNumber); void startUserInitiatedProfiling(Timer<InspectorController>* = 0); void stopUserInitiatedProfiling(); + void startProfiling() { startUserInitiatedProfiling(); } + void stopProfiling() { stopUserInitiatedProfiling(); } void enableProfiler(bool always = false, bool skipRecompile = false); void disableProfiler(bool always = false); @@ -260,7 +267,8 @@ public: void editScriptSource(long callId, const String& sourceID, const String& newContent); void getScriptSource(long callId, const String& sourceID); - void resumeDebugger(); + void resume(); + void setPauseOnExceptionsState(long pauseState); PassRefPtr<SerializedScriptValue> currentCallFrames(); virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType); @@ -288,7 +296,12 @@ private: // Following are used from InspectorBackend and internally. void setSearchingForNode(bool enabled); + void enableSearchingForNode() { setSearchingForNode(true); } + void disableSearchingForNode() { setSearchingForNode(false); } + void setMonitoringXHR(bool enabled); + void enableMonitoringXHR() { setMonitoringXHR(true); } + void disableMonitoringXHR() { setMonitoringXHR(false); } void storeLastActivePanel(const String& panelName); InspectorDOMAgent* domAgent() { return m_domAgent.get(); } void releaseFrontendLifetimeAgents(); @@ -319,11 +332,12 @@ private: void focusNode(); - void addConsoleMessage(ScriptState*, ConsoleMessage*); + void addConsoleMessage(ScriptState*, PassOwnPtr<ConsoleMessage>); void addResource(InspectorResource*); void removeResource(InspectorResource*); InspectorResource* getTrackedResource(unsigned long identifier); + void getResourceContent(long callId, unsigned long identifier); void pruneResources(ResourcesMap*, DocumentLoader* loaderToKeep = 0); void removeAllResources(ResourcesMap* map) { pruneResources(map); } @@ -345,7 +359,7 @@ private: OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient; bool m_openingFrontend; OwnPtr<InspectorFrontend> m_frontend; - OwnPtr<InspectorFrontend2> m_frontend2; + OwnPtr<RemoteInspectorFrontend> m_remoteFrontend; RefPtr<InspectorDOMAgent> m_domAgent; OwnPtr<InspectorCSSStore> m_cssStore; OwnPtr<InspectorTimelineAgent> m_timelineAgent; @@ -359,7 +373,7 @@ private: ResourcesMap m_resources; HashSet<String> m_knownResources; FrameResourcesMap m_frameResources; - Vector<ConsoleMessage*> m_consoleMessages; + Vector<OwnPtr<ConsoleMessage> > m_consoleMessages; unsigned m_expiredConsoleMessageCount; HashMap<String, double> m_times; HashMap<String, unsigned> m_counts; diff --git a/WebCore/inspector/InspectorDOMAgent.cpp b/WebCore/inspector/InspectorDOMAgent.cpp index 46bc938..e3d1bf5 100644 --- a/WebCore/inspector/InspectorDOMAgent.cpp +++ b/WebCore/inspector/InspectorDOMAgent.cpp @@ -58,8 +58,9 @@ #include "MutationEvent.h" #include "Node.h" #include "NodeList.h" +#include "Pasteboard.h" #include "PlatformString.h" -#include "RemoteInspectorFrontend2.h" +#include "RemoteInspectorFrontend.h" #include "RenderStyle.h" #include "RenderStyleConstants.h" #include "ScriptEventListener.h" @@ -70,6 +71,8 @@ #include "XPathResult.h" #endif +#include "markup.h" + #include <wtf/text/CString.h> #include <wtf/HashSet.h> #include <wtf/ListHashSet.h> @@ -195,7 +198,7 @@ public: } -InspectorDOMAgent::InspectorDOMAgent(InspectorCSSStore* cssStore, InspectorFrontend2* frontend) +InspectorDOMAgent::InspectorDOMAgent(InspectorCSSStore* cssStore, RemoteInspectorFrontend* frontend) : EventListener(InspectorDOMAgentType) , m_cssStore(cssStore) , m_frontend(frontend) @@ -354,14 +357,6 @@ void InspectorDOMAgent::pushChildNodesToFrontend(long nodeId) m_frontend->setChildNodes(nodeId, children.release()); } -long InspectorDOMAgent::pushNodeByPathToFrontend(const String& path) -{ - Node* node = nodeForPath(path); - if (!node) - return 0; - return pushNodePathToFrontend(node); -} - long InspectorDOMAgent::inspectedNode(unsigned long num) { if (num < m_inspectedNodes.size()) @@ -1635,6 +1630,28 @@ void InspectorDOMAgent::reportNodesAsSearchResults(ListHashSet<Node*>& resultCol m_frontend->addNodesToSearchResult(nodeIds.release()); } +void InspectorDOMAgent::copyNode(long nodeId) +{ + Node* node = nodeForId(nodeId); + if (!node) + return; + String markup = createMarkup(node); + Pasteboard::generalPasteboard()->writePlainText(markup); +} + +void InspectorDOMAgent::pushNodeByPathToFrontend(long callId, const String& path) +{ + if (!m_frontend) + return; + + long id = 0; + Node* node = nodeForPath(path); + if (node) + id = pushNodePathToFrontend(node); + + m_frontend->didPushNodeByPathToFrontend(callId, id); +} + } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/WebCore/inspector/InspectorDOMAgent.h b/WebCore/inspector/InspectorDOMAgent.h index 33c5f64..efa27e0 100644 --- a/WebCore/inspector/InspectorDOMAgent.h +++ b/WebCore/inspector/InspectorDOMAgent.h @@ -57,7 +57,11 @@ namespace WebCore { class Element; class Event; class InspectorDOMAgent; +<<<<<<< HEAD:WebCore/inspector/InspectorDOMAgent.h class InspectorFrontend2; +======= + class RemoteInspectorFrontend; +>>>>>>> webkit.org at r63859:WebCore/inspector/InspectorDOMAgent.h class MatchJob; class NameNodeMap; class Node; @@ -80,7 +84,7 @@ namespace WebCore { class InspectorDOMAgent : public EventListener { public: - static PassRefPtr<InspectorDOMAgent> create(InspectorCSSStore* cssStore, InspectorFrontend2* frontend) + static PassRefPtr<InspectorDOMAgent> create(InspectorCSSStore* cssStore, RemoteInspectorFrontend* frontend) { return adoptRef(new InspectorDOMAgent(cssStore, frontend)); } @@ -92,7 +96,7 @@ namespace WebCore { : 0; } - InspectorDOMAgent(InspectorCSSStore* cssStore, InspectorFrontend2* frontend); + InspectorDOMAgent(InspectorCSSStore* cssStore, RemoteInspectorFrontend* frontend); ~InspectorDOMAgent(); void reset(); @@ -138,8 +142,9 @@ namespace WebCore { Node* nodeForId(long nodeId); long pushNodePathToFrontend(Node* node); void pushChildNodesToFrontend(long nodeId); - long pushNodeByPathToFrontend(const String& path); + void pushNodeByPathToFrontend(long callId, const String& path); long inspectedNode(unsigned long num); + void copyNode(long nodeId); private: static CSSStyleSheet* getParentStyleSheet(CSSStyleDeclaration*); @@ -195,7 +200,7 @@ namespace WebCore { void discardBindings(); InspectorCSSStore* m_cssStore; - InspectorFrontend2* m_frontend; + RemoteInspectorFrontend* m_frontend; NodeToIdMap m_documentNodeToIdMap; // Owns node mappings for dangling nodes. Vector<NodeToIdMap*> m_danglingNodeToIdMaps; diff --git a/WebCore/inspector/InspectorFrontend.cpp b/WebCore/inspector/InspectorFrontend.cpp index f9a29b6..5925741 100644 --- a/WebCore/inspector/InspectorFrontend.cpp +++ b/WebCore/inspector/InspectorFrontend.cpp @@ -32,7 +32,6 @@ #if ENABLE(INSPECTOR) -#include "ConsoleMessage.h" #include "Frame.h" #include "InjectedScript.h" #include "InjectedScriptHost.h" @@ -112,26 +111,11 @@ void InspectorFrontend::updateConsoleMessageExpiredCount(unsigned count) function.call(); } -void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, const Vector<RefPtr<SerializedScriptValue> >& arguments, const String& message) +void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj) { ScriptFunctionCall function(m_webInspector, "dispatch"); function.appendArgument("addConsoleMessage"); function.appendArgument(messageObj); - if (!frames.isEmpty()) { - for (unsigned i = 0; i < frames.size(); ++i) - function.appendArgument(frames[i]); - } else if (!arguments.isEmpty()) { - for (unsigned i = 0; i < arguments.size(); ++i) { - ScriptValue scriptValue = ScriptValue::deserialize(scriptState(), arguments[i].get()); - if (scriptValue.hasNoValue()) { - ASSERT_NOT_REACHED(); - return; - } - function.appendArgument(scriptValue); - } - } else { - function.appendArgument(message); - } function.call(); } diff --git a/WebCore/inspector/InspectorFrontend.h b/WebCore/inspector/InspectorFrontend.h index e32f40c..e6567be 100644 --- a/WebCore/inspector/InspectorFrontend.h +++ b/WebCore/inspector/InspectorFrontend.h @@ -68,7 +68,7 @@ namespace WebCore { void populateSessionSettings(const String& settings); void updateConsoleMessageExpiredCount(unsigned count); - void addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, const Vector<RefPtr<SerializedScriptValue> >& arguments, const String& message); + void addConsoleMessage(const ScriptObject& messageObj); void updateConsoleMessageRepeatCount(unsigned count); void clearConsoleMessages(); diff --git a/WebCore/inspector/InspectorFrontend2.idl b/WebCore/inspector/InspectorFrontend2.idl deleted file mode 100644 index b96d715..0000000 --- a/WebCore/inspector/InspectorFrontend2.idl +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -module WebCore { - - interface [Conditional=INSPECTOR, JS] InspectorFrontend2 { - // TimelineAgent - void addRecordToTimeline(in Object record); - - // DOMAgent - void addNodesToSearchResult(in Array nodeIds); - void attributesUpdated(in long id, in Array attributes); - void childNodeCountUpdated(in long id, in int newValue); - void childNodeInserted(in long parentId, in long prevId, in Object node); - void childNodeRemoved(in long parentId, in long id); - void didAddRule(in long callId, in Value rule, in boolean selectorAffectsNode); - void didApplyDomChange(in long callId, in boolean success); - void didApplyStyleText(in long callId, in boolean success, in Value style, in Array changedProperties); - void didChangeTagName(in long callId, in long nodeId); - void didGetAllStyles(in long callId, in Array styles); - void didGetChildNodes(in long callId); - void didGetComputedStyle(in long callId, in Value style); - void didGetEventListenersForNode(in long callId, in long nodeId, in Array listenersArray); - void didGetInlineStyle(in long callId, in Value style); - void didGetOuterHTML(in long callId, in String outerHTML); - void didGetStyleSheet(in long callId, in Value styleSheet); - void didGetStyles(in long callId, in Value styles); - void didRemoveNode(in long callId, in long nodeId); - void didSetOuterHTML(in long callId, in long nodeId); - void didSetRuleSelector(in long callId, in Value rule, in boolean selectorAffectsNode); - void didSetStyleProperty(in long callId, in boolean success); - void didSetStyleText(in long callId, in boolean success); - void didToggleStyleEnabled(in long callId, in Value style); - void setChildNodes(in long parentId, in Array nodes); - void setDetachedRoot(in Object root); - void setDocument(in Value root); - }; -} diff --git a/WebCore/inspector/InspectorResource.cpp b/WebCore/inspector/InspectorResource.cpp index 91a57e0..6a5919c 100644 --- a/WebCore/inspector/InspectorResource.cpp +++ b/WebCore/inspector/InspectorResource.cpp @@ -64,6 +64,7 @@ InspectorResource::InspectorResource(unsigned long identifier, DocumentLoader* l , m_loadEventTime(-1.0) , m_domContentEventTime(-1.0) , m_connectionID(0) + , m_connectionReused(false) , m_isMainResource(false) { } @@ -131,6 +132,7 @@ void InspectorResource::updateResponse(const ResourceResponse& response) m_suggestedFilename = response.suggestedFilename(); m_connectionID = response.connectionID(); + m_connectionReused = response.connectionReused(); m_loadTiming = response.resourceLoadTiming(); m_cached = response.wasCached(); @@ -183,6 +185,7 @@ void InspectorResource::updateScriptObject(InspectorFrontend* frontend) populateHeadersObject(&responseHeaders, m_responseHeaderFields); jsonObject.set("responseHeaders", responseHeaders); jsonObject.set("connectionID", m_connectionID); + jsonObject.set("connectionReused", m_connectionReused); jsonObject.set("cached", m_cached); if (m_loadTiming && !m_cached) jsonObject.set("timing", buildObjectForTiming(frontend, m_loadTiming.get())); @@ -394,9 +397,9 @@ ScriptObject InspectorResource::buildObjectForTiming(InspectorFrontend* frontend jsonObject.set("proxyDuration", timing->proxyStart == -1 ? -1 : (timing->proxyEnd - timing->proxyStart) / 1000.0); jsonObject.set("dnsDuration", timing->dnsStart == -1 ? -1 : (timing->dnsEnd - timing->dnsStart) / 1000.0); jsonObject.set("connectDuration", timing->connectStart == -1 ? -1 : (timing->connectEnd - timing->connectStart) / 1000.0); + jsonObject.set("sslDuration", timing->sslStart == -1 ? -1 : (timing->sslEnd - timing->sslStart) / 1000.0); jsonObject.set("sendDuration", (timing->sendEnd - timing->sendStart) / 1000.0); jsonObject.set("waitDuration", (timing->receiveHeadersEnd - timing->sendEnd) / 1000.0); - jsonObject.set("sslDuration", (timing->sslEnd - timing->sslStart) / 1000.0); return jsonObject; } diff --git a/WebCore/inspector/InspectorResource.h b/WebCore/inspector/InspectorResource.h index ed9ec37..48e1a20 100644 --- a/WebCore/inspector/InspectorResource.h +++ b/WebCore/inspector/InspectorResource.h @@ -174,6 +174,7 @@ namespace WebCore { double m_loadEventTime; double m_domContentEventTime; unsigned m_connectionID; + bool m_connectionReused; RefPtr<ResourceLoadTiming> m_loadTiming; ScriptString m_overrideContent; Type m_overrideContentType; diff --git a/WebCore/inspector/InspectorTimelineAgent.cpp b/WebCore/inspector/InspectorTimelineAgent.cpp index 31513d1..b5cff68 100644 --- a/WebCore/inspector/InspectorTimelineAgent.cpp +++ b/WebCore/inspector/InspectorTimelineAgent.cpp @@ -35,7 +35,7 @@ #include "Event.h" #include "IntRect.h" -#include "RemoteInspectorFrontend2.h" +#include "RemoteInspectorFrontend.h" #include "ResourceRequest.h" #include "ResourceResponse.h" #include "TimelineRecordFactory.h" @@ -46,7 +46,7 @@ namespace WebCore { int InspectorTimelineAgent::s_instanceCount = 0; -InspectorTimelineAgent::InspectorTimelineAgent(InspectorFrontend2* frontend) +InspectorTimelineAgent::InspectorTimelineAgent(RemoteInspectorFrontend* frontend) : m_frontend(frontend) { ++s_instanceCount; @@ -279,7 +279,7 @@ void InspectorTimelineAgent::reset() m_recordStack.clear(); } -void InspectorTimelineAgent::resetFrontendProxyObject(InspectorFrontend2* frontend) +void InspectorTimelineAgent::resetFrontendProxyObject(RemoteInspectorFrontend* frontend) { ASSERT(frontend); reset(); diff --git a/WebCore/inspector/InspectorTimelineAgent.h b/WebCore/inspector/InspectorTimelineAgent.h index 9a5cb98..16d7b83 100644 --- a/WebCore/inspector/InspectorTimelineAgent.h +++ b/WebCore/inspector/InspectorTimelineAgent.h @@ -42,7 +42,7 @@ namespace WebCore { class Event; -class InspectorFrontend2; +class RemoteInspectorFrontend; class IntRect; class ResourceRequest; class ResourceResponse; @@ -74,11 +74,11 @@ enum TimelineRecordType { class InspectorTimelineAgent : ScriptGCEventListener, public Noncopyable { public: - InspectorTimelineAgent(InspectorFrontend2* frontend); + InspectorTimelineAgent(RemoteInspectorFrontend* frontend); ~InspectorTimelineAgent(); void reset(); - void resetFrontendProxyObject(InspectorFrontend2*); + void resetFrontendProxyObject(RemoteInspectorFrontend*); // Methods called from WebCore. void willCallFunction(const String& scriptName, int scriptLine); @@ -152,7 +152,7 @@ private: void pushGCEventRecords(); - InspectorFrontend2* m_frontend; + RemoteInspectorFrontend* m_frontend; Vector<TimelineRecordEntry> m_recordStack; static int s_instanceCount; diff --git a/WebCore/inspector/InspectorValues.cpp b/WebCore/inspector/InspectorValues.cpp index f95116c..90a40f9 100644 --- a/WebCore/inspector/InspectorValues.cpp +++ b/WebCore/inspector/InspectorValues.cpp @@ -550,6 +550,7 @@ void InspectorBasicValue::writeJSON(Vector<UChar>* output) const output->append(falseString, 5); } else if (type() == TypeDouble) { String value = String::format("%f", m_doubleValue); + value.replace(',', '.'); output->append(value.characters(), value.length()); } } @@ -650,6 +651,12 @@ void InspectorArray::writeJSON(Vector<UChar>* output) const output->append(']'); } +PassRefPtr<InspectorValue> InspectorArray::get(size_t index) +{ + ASSERT(index < m_data.size()); + return m_data[index]; +} + } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/WebCore/inspector/InspectorValues.h b/WebCore/inspector/InspectorValues.h index 30ba95a..a0c0c2d 100644 --- a/WebCore/inspector/InspectorValues.h +++ b/WebCore/inspector/InspectorValues.h @@ -198,7 +198,9 @@ public: void pushNumber(double); void pushString(const String&); void push(PassRefPtr<InspectorValue>); - unsigned length() { return m_data.size(); } + unsigned length() const { return m_data.size(); } + + PassRefPtr<InspectorValue> get(size_t index); virtual void writeJSON(Vector<UChar>* output) const; diff --git a/WebCore/inspector/JavaScriptCallFrame.idl b/WebCore/inspector/JavaScriptCallFrame.idl index 28f4f34..225059d 100644 --- a/WebCore/inspector/JavaScriptCallFrame.idl +++ b/WebCore/inspector/JavaScriptCallFrame.idl @@ -25,7 +25,11 @@ module inspector { - interface [Conditional=JAVASCRIPT_DEBUGGER, OmitConstructor] JavaScriptCallFrame { + interface [ + Conditional=JAVASCRIPT_DEBUGGER, + OmitConstructor, + DontCheckEnums + ] JavaScriptCallFrame { // Scope type const unsigned short GLOBAL_SCOPE = 0; diff --git a/WebCore/inspector/front-end/AbstractTimelinePanel.js b/WebCore/inspector/front-end/AbstractTimelinePanel.js index 1b5f6ce..187ef86 100644 --- a/WebCore/inspector/front-end/AbstractTimelinePanel.js +++ b/WebCore/inspector/front-end/AbstractTimelinePanel.js @@ -202,6 +202,9 @@ WebInspector.AbstractTimelinePanel.prototype = { // 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); }, updateGraphDividersIfNeeded: function(force) diff --git a/WebCore/inspector/front-end/ConsoleView.js b/WebCore/inspector/front-end/ConsoleView.js index 8bb71e6..d4119a1 100644 --- a/WebCore/inspector/front-end/ConsoleView.js +++ b/WebCore/inspector/front-end/ConsoleView.js @@ -275,9 +275,9 @@ WebInspector.ConsoleView.prototype = { msg._updateRepeatCount(); this._incrementErrorWarningCount(msg); } else { - msgCopy = new WebInspector.ConsoleMessage(msg.source, msg.type, msg.level, msg.line, msg.url, msg.groupLevel, count - prevRepeatCount); + var msgCopy = new WebInspector.ConsoleMessage(msg.source, msg.type, msg.level, msg.line, msg.url, msg.groupLevel, count - prevRepeatCount, msg._messageText, msg._parameters, msg._stackTrace); msgCopy.totalRepeatCount = count; - msgCopy.setMessageBody(msg.args); + msgCopy._formatMessage(); this.addMessage(msgCopy); } }, @@ -645,7 +645,7 @@ WebInspector.ConsoleView.prototype = { WebInspector.ConsoleView.prototype.__proto__ = WebInspector.View.prototype; -WebInspector.ConsoleMessage = function(source, type, level, line, url, groupLevel, repeatCount) +WebInspector.ConsoleMessage = function(source, type, level, line, url, groupLevel, repeatCount, message, parameters, stackTrace) { this.source = source; this.type = type; @@ -656,29 +656,56 @@ WebInspector.ConsoleMessage = function(source, type, level, line, url, groupLeve this.repeatCount = repeatCount; this.repeatDelta = repeatCount; this.totalRepeatCount = repeatCount; - if (arguments.length > 7) - this.setMessageBody(Array.prototype.slice.call(arguments, 7)); + this._messageText = message; + this._parameters = parameters; + this._stackTrace = stackTrace; + this._formatMessage(); +} + +WebInspector.ConsoleMessage.createTextMessage = function(text, level) +{ + level = level || WebInspector.ConsoleMessage.MessageLevel.Log; + return new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageType.Log, level, 0, null, null, 1, null, [text], null); } WebInspector.ConsoleMessage.prototype = { - setMessageBody: function(args) + _formatMessage: function() { - this.args = args; switch (this.type) { + case WebInspector.ConsoleMessage.MessageType.Assert: case WebInspector.ConsoleMessage.MessageType.Trace: - var span = document.createElement("span"); - span.className = "console-formatted-trace source-code"; - var stack = Array.prototype.slice.call(args); - var funcNames = stack.map(function(f) { - return f || WebInspector.UIString("(anonymous function)"); - }); - span.appendChild(document.createTextNode(funcNames.join("\n"))); - this.formattedMessage = span; + case WebInspector.ConsoleMessage.MessageType.UncaughtException: + var ol = document.createElement("ol"); + ol.addStyleClass("stack-trace"); + if (this.type === WebInspector.ConsoleMessage.MessageType.Trace) + ol.addStyleClass("trace-message"); + var treeOutline = new TreeOutline(ol); + + var root = treeOutline; + if (this.type === WebInspector.ConsoleMessage.MessageType.UncaughtException || + this.type === WebInspector.ConsoleMessage.MessageType.Assert) { + var messageText; + if (this.type === WebInspector.ConsoleMessage.MessageType.Assert) + messageText = this._format(this._parameters); + else + messageText = document.createTextNode(this._messageText); + + var content = document.createElement("div"); + this._addMessageHeader(content, messageText); + root = new TreeElement(content, null, true); + content.treeElementForTest = root; + treeOutline.appendChild(root); + } + + this._populateStackTraceTreeElement(root); + this.formattedMessage = ol; break; case WebInspector.ConsoleMessage.MessageType.Object: - this.formattedMessage = this._format(["%O", args[0]]); + var obj = this._parameters ? this._parameters[0] : undefined; + this.formattedMessage = this._format(["%O", obj]); break; default: + var args = this._parameters || [this._messageText]; this.formattedMessage = this._format(args); break; } @@ -822,34 +849,52 @@ WebInspector.ConsoleMessage.prototype = { return element; } - if (this.url && this.url !== "undefined") { - var urlElement = document.createElement("a"); - urlElement.className = "console-message-url webkit-html-resource-link"; - urlElement.href = this.url; - urlElement.lineNumber = this.line; + if (this.type === WebInspector.ConsoleMessage.MessageType.Trace || + this.type === WebInspector.ConsoleMessage.MessageType.Assert || + this.type === WebInspector.ConsoleMessage.MessageType.UncaughtException) + element.appendChild(this.formattedMessage); + else + this._addMessageHeader(element, this.formattedMessage); + + if (this.repeatCount > 1) + this._updateRepeatCount(); + + return element; + }, + + _populateStackTraceTreeElement: function(parentTreeElement) + { + for (var i = 0; i < this._stackTrace.length; i++) { + var frame = this._stackTrace[i]; - if (this.source === WebInspector.ConsoleMessage.MessageSource.JS) - urlElement.preferredPanel = "scripts"; + var content = document.createElement("div"); + var messageTextElement = document.createElement("span"); + messageTextElement.className = "console-message-text source-code"; + var functionName = frame.functionName || WebInspector.UIString("(anonymous function)"); + messageTextElement.appendChild(document.createTextNode(functionName)); + content.appendChild(messageTextElement); - if (this.line > 0) - urlElement.textContent = WebInspector.displayNameForURL(this.url) + ":" + this.line; - else - urlElement.textContent = WebInspector.displayNameForURL(this.url); + var urlElement = WebInspector.linkifyResourceAsNode(frame.sourceURL, "scripts", frame.lineNumber, "console-message-url"); + content.appendChild(urlElement); - element.appendChild(urlElement); + var treeElement = new TreeElement(content); + parentTreeElement.appendChild(treeElement); + } + }, + + _addMessageHeader: function(parentElement, formattedMessage) + { + if (this.url && this.url !== "undefined") { + var urlElement = WebInspector.linkifyResourceAsNode(this.url, "scripts", this.line, "console-message-url"); + parentElement.appendChild(urlElement); } var messageTextElement = document.createElement("span"); messageTextElement.className = "console-message-text source-code"; if (this.type === WebInspector.ConsoleMessage.MessageType.Assert) messageTextElement.appendChild(document.createTextNode(WebInspector.UIString("Assertion failed: "))); - messageTextElement.appendChild(this.formattedMessage); - element.appendChild(messageTextElement); - - if (this.repeatCount > 1) - this._updateRepeatCount(); - - return element; + messageTextElement.appendChild(formattedMessage); + parentElement.appendChild(messageTextElement); }, _updateRepeatCount: function() { @@ -890,6 +935,7 @@ WebInspector.ConsoleMessage.prototype = { var typeString; switch (this.type) { case WebInspector.ConsoleMessage.MessageType.Log: + case WebInspector.ConsoleMessage.MessageType.UncaughtException: typeString = "Log"; break; case WebInspector.ConsoleMessage.MessageType.Object: @@ -969,7 +1015,8 @@ WebInspector.ConsoleMessage.MessageType = { StartGroupCollapsed: 4, EndGroup: 5, Assert: 6, - Result: 7 + UncaughtException: 7, + Result: 8 } WebInspector.ConsoleMessage.MessageLevel = { @@ -1001,14 +1048,6 @@ WebInspector.ConsoleCommand.prototype = { } } -WebInspector.ConsoleTextMessage = function(text, level) -{ - level = level || WebInspector.ConsoleMessage.MessageLevel.Log; - WebInspector.ConsoleMessage.call(this, WebInspector.ConsoleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageType.Log, level, 0, null, null, 1, text); -} - -WebInspector.ConsoleTextMessage.prototype.__proto__ = WebInspector.ConsoleMessage.prototype; - WebInspector.ConsoleCommandResult = function(result, exception, originatingCommand) { var level = (exception ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log); @@ -1023,7 +1062,7 @@ WebInspector.ConsoleCommandResult = function(result, exception, originatingComma this.originatingCommand = originatingCommand; - WebInspector.ConsoleMessage.call(this, WebInspector.ConsoleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageType.Result, level, line, url, null, 1, message); + WebInspector.ConsoleMessage.call(this, WebInspector.ConsoleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageType.Result, level, line, url, null, 1, null, [message]); } WebInspector.ConsoleCommandResult.prototype = { diff --git a/WebCore/inspector/front-end/ElementsPanel.js b/WebCore/inspector/front-end/ElementsPanel.js index cd7cbd2..48eb4c0 100644 --- a/WebCore/inspector/front-end/ElementsPanel.js +++ b/WebCore/inspector/front-end/ElementsPanel.js @@ -99,7 +99,7 @@ WebInspector.ElementsPanel = function() this.sidebarResizeElement.addEventListener("mousedown", this.rightSidebarResizerDragStart.bind(this), false); this._nodeSearchButton = new WebInspector.StatusBarButton(WebInspector.UIString("Select an element in the page to inspect it."), "node-search-status-bar-item"); - this._nodeSearchButton.addEventListener("click", this._nodeSearchButtonClicked.bind(this), false); + this._nodeSearchButton.addEventListener("click", this.toggleSearchingForNode.bind(this), false); this.element.appendChild(this.contentElement); this.element.appendChild(this.sidebarElement); @@ -453,7 +453,7 @@ WebInspector.ElementsPanel.prototype = { } WebInspector.showConsole(); - WebInspector.console.addMessage(new WebInspector.ConsoleTextMessage(builder.join("\n"))); + WebInspector.console.addMessage(WebInspector.ConsoleMessage.createTextMessage(builder.join("\n"))); }, get rootDOMNode() @@ -1092,7 +1092,7 @@ WebInspector.ElementsPanel.prototype = { var isNodeSearchKey = event.ctrlKey && !event.metaKey && !event.altKey && event.shiftKey; if (isNodeSearchKey) { - this._nodeSearchButtonClicked(event); + this.toggleSearchingForNode(); event.handled = true; return; } @@ -1136,7 +1136,7 @@ WebInspector.ElementsPanel.prototype = { this.treeOutline.updateSelection(); }, - _nodeSearchButtonClicked: function(event) + toggleSearchingForNode: function() { if (!this._nodeSearchButton.toggled) InspectorBackend.enableSearchingForNode(); diff --git a/WebCore/inspector/front-end/ElementsTreeOutline.js b/WebCore/inspector/front-end/ElementsTreeOutline.js index 1b84b83..7247ba0 100644 --- a/WebCore/inspector/front-end/ElementsTreeOutline.js +++ b/WebCore/inspector/front-end/ElementsTreeOutline.js @@ -1205,8 +1205,9 @@ WebInspector.ElementsTreeElement.prototype = { html += "=​\""; if (linkify && (name === "src" || name === "href")) { + var rewrittenHref = this._rewriteAttrHref(node, value); value = value.replace(/([\/;:\)\]\}])/g, "$1\u200B"); - html += linkify(this._rewriteAttrHref(node, value), value, "webkit-html-attribute-value", node.nodeName.toLowerCase() === "a"); + html += linkify(rewrittenHref, value, "webkit-html-attribute-value", node.nodeName.toLowerCase() === "a"); } else { value = value.escapeHTML().replace(/([\/;:\)\]\}])/g, "$1​"); html += "<span class=\"webkit-html-attribute-value\">" + value + "</span>"; diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js index 5d9d065..9e16dad 100644 --- a/WebCore/inspector/front-end/InjectedScript.js +++ b/WebCore/inspector/front-end/InjectedScript.js @@ -544,6 +544,8 @@ InjectedScript._type = function(obj) return "array"; if (obj instanceof inspectedWindow.HTMLCollection) return "array"; + if (inspectedWindow.jQuery && obj instanceof inspectedWindow.jQuery) + return "array"; if (obj instanceof inspectedWindow.Error) return "error"; return type; diff --git a/WebCore/inspector/front-end/InjectedScriptAccess.js b/WebCore/inspector/front-end/InjectedScriptAccess.js index 90daab7..0e4cc2e 100644 --- a/WebCore/inspector/front-end/InjectedScriptAccess.js +++ b/WebCore/inspector/front-end/InjectedScriptAccess.js @@ -58,7 +58,7 @@ InjectedScriptAccess._installHandler = function(methodName, async) if (!isException) callback(result); else - WebInspector.console.addMessage(new WebInspector.ConsoleTextMessage("Error dispatching: " + methodName)); + WebInspector.console.addMessage(WebInspector.ConsoleMessage.createTextMessage("Error dispatching: " + methodName)); } var callId = WebInspector.Callback.wrap(myCallback); diff --git a/WebCore/inspector/front-end/InspectorBackendStub.js b/WebCore/inspector/front-end/InspectorBackendStub.js index 761e876..857e026 100644 --- a/WebCore/inspector/front-end/InspectorBackendStub.js +++ b/WebCore/inspector/front-end/InspectorBackendStub.js @@ -184,7 +184,7 @@ WebInspector.InspectorBackendStub.prototype = { this._breakpointsActivated = false; }, - pauseInDebugger: function() + pause: function() { }, @@ -203,7 +203,7 @@ WebInspector.InspectorBackendStub.prototype = { WebInspector.didGetScriptSource(callId, null); }, - resumeDebugger: function() + resume: function() { }, @@ -243,15 +243,15 @@ WebInspector.InspectorBackendStub.prototype = { return []; }, - stepIntoStatementInDebugger: function() + stepIntoStatement: function() { }, - stepOutOfFunctionInDebugger: function() + stepOutOfFunction: function() { }, - stepOverStatementInDebugger: function() + stepOverStatement: function() { }, diff --git a/WebCore/inspector/front-end/Resource.js b/WebCore/inspector/front-end/Resource.js index 2ae23a0..06a610d 100644 --- a/WebCore/inspector/front-end/Resource.js +++ b/WebCore/inspector/front-end/Resource.js @@ -308,6 +308,17 @@ WebInspector.Resource.prototype = { } }, + get cached() + { + return this._cached; + }, + + set cached(x) + { + this._cached = x; + this.dispatchEventToListeners("cached changed"); + }, + get mimeType() { return this._mimeType; @@ -587,9 +598,14 @@ WebInspector.Resource.prototype = { if (!this._mimeTypeIsConsistentWithType()) msg = new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.Other, WebInspector.ConsoleMessage.MessageType.Log, - WebInspector.ConsoleMessage.MessageLevel.Warning, -1, this.url, null, 1, - String.sprintf(WebInspector.Warnings.IncorrectMIMEType.message, - WebInspector.Resource.Type.toString(this.type), this.mimeType)); + WebInspector.ConsoleMessage.MessageLevel.Warning, + -1, + this.url, + null, + 1, + String.sprintf(WebInspector.Warnings.IncorrectMIMEType.message, WebInspector.Resource.Type.toString(this.type), this.mimeType), + null, + null); break; } diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js index 8af1505..b02a277 100644 --- a/WebCore/inspector/front-end/ResourcesPanel.js +++ b/WebCore/inspector/front-end/ResourcesPanel.js @@ -228,7 +228,7 @@ WebInspector.ResourcesPanel.prototype = { var resourcesLength = this._resources.length; for (var i = 0; i < resourcesLength; ++i) { var resource = this._resources[i]; - if (!resource._itemsTreeElement) + if (!resource._itemsTreeElement || !resource._itemsTreeElement.selectable) continue; var resourceView = this.resourceViewForResource(resource); if (!resourceView.performSearch || resourceView === visibleView) @@ -751,13 +751,49 @@ WebInspector.ResourcesPanel.prototype = { { var tableElement = document.createElement("table"); var resource = anchor.parentElement.resource; - var data = [WebInspector.UIString("Blocking"), resource.timing.requestTime === 0 ? "?" : Number.secondsToString(Math.max(resource.timing.requestTime - resource.startTime, 0)), - WebInspector.UIString("Proxy"), resource.timing.proxyDuration == -1 ? WebInspector.UIString("(none)") : Number.secondsToString(resource.timing.proxyDuration), - WebInspector.UIString("DNS Lookup"), resource.timing.dnsDuration == -1 ? WebInspector.UIString("(reused)") : Number.secondsToString(resource.timing.dnsDuration), - WebInspector.UIString("Connecting"), resource.timing.connectDuration == -1 ? WebInspector.UIString("(reused)") : Number.secondsToString(resource.timing.connectDuration), - WebInspector.UIString("Sending"), Number.secondsToString(resource.timing.sendDuration), - WebInspector.UIString("Waiting"), Number.secondsToString(resource.timing.waitDuration), - WebInspector.UIString("Receiving"), Number.secondsToString(resource.endTime - resource.responseReceivedTime)]; + var data = []; + + if (resource.timing.proxyDuration !== -1) { + data.push(WebInspector.UIString("Proxy")); + data.push(Number.secondsToString(resource.timing.proxyDuration)); + } + + if (resource.timing.dnsDuration !== -1) { + data.push(WebInspector.UIString("DNS Lookup")); + data.push(Number.secondsToString(resource.timing.dnsDuration)); + } + + if (resource.timing.connectDuration !== -1) { + if (resource.connectionReused) { + data.push(WebInspector.UIString("Blocking")); + data.push(Number.secondsToString(resource.timing.connectDuration)); + } else { + data.push(WebInspector.UIString("Connecting")); + // Connection includes DNS, subtract it here. + var connectDuration = resource.timing.connectDuration; + if (resource.timing.dnsDuration !== -1) + connectDuration -= resource.timing.dnsDuration; + data.push(Number.secondsToString(connectDuration)); + } + } + + if (resource.timing.sslDuration !== -1) { + data.push(WebInspector.UIString("SSL")); + data.push(Number.secondsToString(resource.timing.sslDuration)); + } + + data.push(WebInspector.UIString("Sending")); + data.push(Number.secondsToString(resource.timing.sendDuration)); + + data.push(WebInspector.UIString("Waiting")); + // Waiting includes SSL, subtract it here. + var waitDuration = resource.timing.waitDuration; + if (resource.timing.sslDuration !== -1) + waitDuration -= resource.timing.sslDuration; + data.push(Number.secondsToString(waitDuration)); + + data.push(WebInspector.UIString("Receiving")); + data.push(Number.secondsToString(resource.endTime - resource.responseReceivedTime)); for (var i = 0; i < data.length; i += 2) { var tr = document.createElement("tr"); @@ -1252,8 +1288,7 @@ WebInspector.ResourceGraph = function(resource) this._graphElement.className = "resources-graph-side"; this._graphElement.addEventListener("mouseover", this.refreshLabelPositions.bind(this), false); - if (resource.cached) - this._graphElement.addStyleClass("resource-cached"); + this._cachedChanged(); this._barAreaElement = document.createElement("div"); this._barAreaElement.className = "resources-graph-bar-area hidden"; @@ -1277,6 +1312,8 @@ WebInspector.ResourceGraph = function(resource) this._barAreaElement.appendChild(this._labelRightElement); this._graphElement.addStyleClass("resources-category-" + resource.category.name); + + resource.addEventListener("cached changed", this._cachedChanged, this); } WebInspector.ResourceGraph.prototype = { @@ -1400,5 +1437,11 @@ WebInspector.ResourceGraph.prototype = { this._labelLeftElement.title = tooltip; this._labelRightElement.title = tooltip; this._barRightElement.title = tooltip; + }, + + _cachedChanged: function() + { + if (this.resource.cached) + this._graphElement.addStyleClass("resource-cached"); } } diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js index 3c4a0be..7a1a4d5 100644 --- a/WebCore/inspector/front-end/ScriptsPanel.js +++ b/WebCore/inspector/front-end/ScriptsPanel.js @@ -158,6 +158,8 @@ WebInspector.ScriptsPanel = function() this.enableToggleButton = new WebInspector.StatusBarButton("", "enable-toggle-status-bar-item"); this.enableToggleButton.addEventListener("click", this._toggleDebugging.bind(this), false); + if (Preferences.debuggerAlwaysEnabled) + this.enableToggleButton.element.addStyleClass("hidden"); this._pauseOnExceptionButton = new WebInspector.StatusBarButton("", "scripts-pause-on-exceptions-status-bar-item", 3); this._pauseOnExceptionButton.addEventListener("click", this._togglePauseOnExceptions.bind(this), false); @@ -931,11 +933,11 @@ WebInspector.ScriptsPanel.prototype = { if (this._paused) { this._paused = false; this._waitingToPause = false; - InspectorBackend.resumeDebugger(); + InspectorBackend.resume(); } else { this._stepping = false; this._waitingToPause = true; - InspectorBackend.pauseInDebugger(); + InspectorBackend.pause(); } this._clearInterface(); @@ -948,7 +950,7 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); - InspectorBackend.stepOverStatementInDebugger(); + InspectorBackend.stepOverStatement(); }, _stepIntoClicked: function() @@ -958,7 +960,7 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); - InspectorBackend.stepIntoStatementInDebugger(); + InspectorBackend.stepIntoStatement(); }, _stepOutClicked: function() @@ -968,7 +970,7 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); - InspectorBackend.stepOutOfFunctionInDebugger(); + InspectorBackend.stepOutOfFunction(); }, _toggleBreakpointsClicked: function() diff --git a/WebCore/inspector/front-end/Settings.js b/WebCore/inspector/front-end/Settings.js index 11f456c..39c1e1e 100644 --- a/WebCore/inspector/front-end/Settings.js +++ b/WebCore/inspector/front-end/Settings.js @@ -42,7 +42,8 @@ var Preferences = { showColorNicknames: true, debuggerAlwaysEnabled: false, profilerAlwaysEnabled: false, - auditsPanelEnabled: true + auditsPanelEnabled: true, + appCacheEnabled: true } WebInspector.populateApplicationSettings = function(settingsString) diff --git a/WebCore/inspector/front-end/SourceCSSTokenizer.js b/WebCore/inspector/front-end/SourceCSSTokenizer.js index 1d8a784..2179982 100644 --- a/WebCore/inspector/front-end/SourceCSSTokenizer.js +++ b/WebCore/inspector/front-end/SourceCSSTokenizer.js @@ -73,8 +73,10 @@ WebInspector.SourceCSSTokenizer = function() "-webkit-animation-iteration-count", "-webkit-animation-name", "-webkit-animation-play-state", "-webkit-animation-timing-function", "-webkit-appearance", "-webkit-backface-visibility", "-webkit-background-clip", "-webkit-background-composite", "-webkit-background-origin", "-webkit-background-size", - "-webkit-binding", "-webkit-border-fit", "-webkit-border-horizontal-spacing", "-webkit-border-image", - "-webkit-border-radius", "-webkit-border-vertical-spacing", "-webkit-box-align", "-webkit-box-direction", + "-webkit-binding", "-webkit-border-end", "-webkit-border-end-color", "-webkit-border-end-style", "-webkit-border-end-width", + "-webkit-border-fit", "-webkit-border-horizontal-spacing", "-webkit-border-image", + "-webkit-border-radius", "-webkit-border-start", "-webkit-border-start-color", "-webkit-border-start-style", + "-webkit-border-start-width","-webkit-border-vertical-spacing", "-webkit-box-align", "-webkit-box-direction", "-webkit-box-flex", "-webkit-box-flex-group", "-webkit-box-lines", "-webkit-box-ordinal-group", "-webkit-box-orient", "-webkit-box-pack", "-webkit-box-reflect", "-webkit-box-shadow", "-webkit-box-sizing", "-webkit-column-break-after", "-webkit-column-break-before", "-webkit-column-break-inside", "-webkit-column-count", diff --git a/WebCore/inspector/front-end/StoragePanel.js b/WebCore/inspector/front-end/StoragePanel.js index 2733907..03a099f 100644 --- a/WebCore/inspector/front-end/StoragePanel.js +++ b/WebCore/inspector/front-end/StoragePanel.js @@ -49,9 +49,11 @@ WebInspector.StoragePanel = function(database) this.sidebarTree.appendChild(this.cookieListTreeElement); this.cookieListTreeElement.expand(); - this.applicationCacheListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("APPLICATION CACHE"), {}, true); - this.sidebarTree.appendChild(this.applicationCacheListTreeElement); - this.applicationCacheListTreeElement.expand(); + if (Preferences.appCacheEnabled) { + this.applicationCacheListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("APPLICATION CACHE"), {}, true); + this.sidebarTree.appendChild(this.applicationCacheListTreeElement); + this.applicationCacheListTreeElement.expand(); + } this.storageViews = document.createElement("div"); this.storageViews.id = "storage-views"; @@ -108,7 +110,9 @@ WebInspector.StoragePanel.prototype = { this.localStorageListTreeElement.removeChildren(); this.sessionStorageListTreeElement.removeChildren(); this.cookieListTreeElement.removeChildren(); - this.applicationCacheListTreeElement.removeChildren(); + + if (Preferences.appCacheEnabled) + this.applicationCacheListTreeElement.removeChildren(); this.storageViews.removeChildren(); @@ -146,6 +150,8 @@ WebInspector.StoragePanel.prototype = { addApplicationCache: function(domain) { + if (!Preferences.appCacheEnabled) + return; var applicationCacheTreeElement = new WebInspector.ApplicationCacheSidebarTreeElement(domain); this.applicationCacheListTreeElement.appendChild(applicationCacheTreeElement); }, diff --git a/WebCore/inspector/front-end/TimelinePanel.js b/WebCore/inspector/front-end/TimelinePanel.js index 1f12625..8900d8d 100644 --- a/WebCore/inspector/front-end/TimelinePanel.js +++ b/WebCore/inspector/front-end/TimelinePanel.js @@ -841,10 +841,8 @@ WebInspector.TimelinePanel.FormattedRecord = function(record, parentRecord, pane this._selfTime = this.endTime - this.startTime; this._lastChildEndTime = this.endTime; this.originalRecordForTests = record; - if (record.stackTrace && record.stackTrace.length) { - this.callerScriptName = record.stackTrace[0].scriptName; - this.callerScriptLine = record.stackTrace[0].lineNumber; - } + if (record.stackTrace && record.stackTrace.length) + this.stackTrace = record.stackTrace; this.totalHeapSize = record.totalHeapSize; this.usedHeapSize = record.usedHeapSize; @@ -877,8 +875,7 @@ WebInspector.TimelinePanel.FormattedRecord = function(record, parentRecord, pane } else if (record.type === recordTypes.TimerFire) { var timerInstalledRecord = panel._timerRecords[record.data.timerId]; if (timerInstalledRecord) { - this.callSiteScriptName = timerInstalledRecord.callerScriptName; - this.callSiteScriptLine = timerInstalledRecord.callerScriptLine; + this.callSiteStackTrace = timerInstalledRecord.stackTrace; this.timeout = timerInstalledRecord.timeout; this.singleShot = timerInstalledRecord.singleShot; } @@ -940,8 +937,6 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { contentHelper._appendTextRow(WebInspector.UIString("Timeout"), Number.secondsToString(this.timeout / 1000, WebInspector.UIString)); contentHelper._appendTextRow(WebInspector.UIString("Repeats"), !this.singleShot); } - if (typeof this.callSiteScriptLine === "number") - contentHelper._appendLinkRow(WebInspector.UIString("Call Site"), this.callSiteScriptName, this.callSiteScriptLine); break; case recordTypes.FunctionCall: contentHelper._appendLinkRow(WebInspector.UIString("Location"), this.data.scriptName, this.data.scriptLine); @@ -979,12 +974,15 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { if (this.data.scriptName && this.type !== recordTypes.FunctionCall) contentHelper._appendLinkRow(WebInspector.UIString("Function Call"), this.data.scriptName, this.data.scriptLine); - if (this.callerScriptName && this.type !== recordTypes.GCEvent) - contentHelper._appendLinkRow(WebInspector.UIString("Caller"), this.callerScriptName, this.callerScriptLine); - if (this.usedHeapSize) contentHelper._appendTextRow(WebInspector.UIString("Used Heap Size"), WebInspector.UIString("%s of %s", Number.bytesToString(this.usedHeapSize, WebInspector.UIString), Number.bytesToString(this.totalHeapSize, WebInspector.UIString))); + if (this.callSiteStackTrace && this.callSiteStackTrace.length) + contentHelper._appendStackTrace(WebInspector.UIString("Call Site stack"), this.callSiteStackTrace); + + if (this.stackTrace) + contentHelper._appendStackTrace(WebInspector.UIString("Call Stack"), this.stackTrace); + return contentHelper._contentTable; }, @@ -1003,10 +1001,10 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { return record.data.width + "\u2009\u00d7\u2009" + record.data.height; case WebInspector.TimelineAgent.RecordType.TimerInstall: case WebInspector.TimelineAgent.RecordType.TimerRemove: - return this.callerScriptName ? WebInspector.linkifyResourceAsNode(this.callerScriptName, "scripts", this.callerScriptLine, "", "") : record.data.timerId; + return this.stackTrace ? WebInspector.linkifyResourceAsNode(this.stackTrace[0].scriptName, "scripts", this.stackTrace[0].lineNumber, "", "") : record.data.timerId; case WebInspector.TimelineAgent.RecordType.ParseHTML: case WebInspector.TimelineAgent.RecordType.RecalculateStyles: - return this.callerScriptName ? WebInspector.linkifyResourceAsNode(this.callerScriptName, "scripts", this.callerScriptLine, "", "") : null; + return this.stackTrace ? WebInspector.linkifyResourceAsNode(this.stackTrace[0].scriptName, "scripts", this.stackTrace[0].lineNumber, "", "") : null; case WebInspector.TimelineAgent.RecordType.EvaluateScript: return record.data.url ? WebInspector.linkifyResourceAsNode(record.data.url, "scripts", record.data.lineNumber, "", "") : null; case WebInspector.TimelineAgent.RecordType.XHRReadyStateChange: @@ -1075,11 +1073,15 @@ WebInspector.TimelinePanel.PopupContentHelper.prototype = { this._contentTable.appendChild(row); }, - _appendElementRow: function(title, content) + _appendElementRow: function(title, content, titleStyle) { var row = document.createElement("tr"); - row.appendChild(this._createCell(title, "timeline-details-row-title")); + var titleCell = this._createCell(title, "timeline-details-row-title"); + if (titleStyle) + titleCell.addStyleClass(titleStyle); + row.appendChild(titleCell); var cell = document.createElement("td"); + cell.className = "timeline-details"; cell.appendChild(content); row.appendChild(cell); this._contentTable.appendChild(row); @@ -1089,6 +1091,24 @@ WebInspector.TimelinePanel.PopupContentHelper.prototype = { { var link = WebInspector.linkifyResourceAsNode(scriptName, "scripts", scriptLine, "timeline-details"); this._appendElementRow(title, link); + }, + + _appendStackTrace: function(title, stackTrace) + { + this._appendTextRow("", ""); + var framesTable = document.createElement("table"); + for (var i = 0; i < stackTrace.length; ++i) { + var stackFrame = stackTrace[i]; + var row = document.createElement("tr"); + row.className = "timeline-details"; + row.appendChild(this._createCell(stackFrame.functionName ? stackFrame.functionName : WebInspector.UIString("(anonymous function)"), "timeline-function-name")); + row.appendChild(this._createCell(" @ ")); + var linkCell = document.createElement("td"); + linkCell.appendChild(WebInspector.linkifyResourceAsNode(stackFrame.scriptName, "scripts", stackFrame.lineNumber, "timeline-details")); + row.appendChild(linkCell); + framesTable.appendChild(row); + } + this._appendElementRow(title, framesTable, "timeline-stacktrace-title"); } } diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css index d8e29e8..f1ee49f 100644 --- a/WebCore/inspector/front-end/inspector.css +++ b/WebCore/inspector/front-end/inspector.css @@ -711,6 +711,11 @@ body.platform-linux .monospace, body.platform-linux .source-code { content: url(Images/treeDownTriangleBlack.png); } +.console-message.repeated-message > ol.stack-trace { + margin-top: -14px; + margin-left: 18px; +} + .console-group-messages .section .header .title { color: black; font-weight: normal; @@ -1164,6 +1169,7 @@ body.platform-linux .monospace, body.platform-linux .source-code { margin-left: -12px; } +.stack-trace li.parent::before, .outline-disclosure li.parent::before { content: url(Images/treeRightTriangleBlack.png); float: left; @@ -1173,26 +1179,32 @@ body.platform-linux .monospace, body.platform-linux .source-code { padding-right: 2px; } +.stack-trace li.parent::before, .outline-disclosure li.parent::before { content: url(Images/treeRightTriangleBlack.png); } +.stack-trace ol:focus li.parent.selected::before, .outline-disclosure ol:focus li.parent.selected::before { content: url(Images/treeRightTriangleWhite.png); } +.stack-trace li.parent.expanded::before, .outline-disclosure li.parent.expanded::before { content: url(Images/treeDownTriangleBlack.png); } +.stack-trace ol:focus li.parent.expanded.selected::before, .outline-disclosure ol:focus li.parent.expanded.selected::before { content: url(Images/treeDownTriangleWhite.png); } +.stack-trace ol.children, .outline-disclosure ol.children { display: none; } +.stack-trace ol.children.expanded, .outline-disclosure ol.children.expanded { display: block; } @@ -1372,14 +1384,18 @@ body.inactive .placard.selected { margin-left: 1px; } -.section .properties ol, .event-properties ol { +.section .properties ol, .event-properties ol, .stack-trace ol, ol.stack-trace { display: none; margin: 0; -webkit-padding-start: 12px; list-style: none; } -.section .properties ol.expanded, .event-properties ol.expanded { +ol.stack-trace { + -webkit-padding-start: 0px; +} + +.section .properties ol.expanded, .event-properties ol.expanded, .stack-trace ol, ol.stack-trace { display: block; } @@ -1474,7 +1490,7 @@ body.inactive .placard.selected { outline: 1px solid rgb(66%, 66%, 66%) !important; background-color: white; -webkit-user-modify: read-write-plaintext-only; - text-overflow: clip; + text-overflow: clip !important; padding-left: 2px; margin-left: -2px; padding-right: 2px; @@ -3677,6 +3693,15 @@ body.inactive .sidebar-tree-item.selected .bubble.search-matches { .timeline-details { -webkit-user-select: text; + vertical-align: top; +} + +.timeline-function-name { + text-align: right; +} + +.timeline-stacktrace-title { + padding-top: 4px; } .timeline-details-row-title { diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js index 89d1ae0..5ec7081 100644 --- a/WebCore/inspector/front-end/inspector.js +++ b/WebCore/inspector/front-end/inspector.js @@ -1071,6 +1071,14 @@ WebInspector.elementDragEnd = function(event) event.preventDefault(); } +WebInspector.toggleSearchingForNode = function() +{ + if (this.panels.elements) { + this.showElementsPanel(); + this.panels.elements.toggleSearchingForNode(); + } +} + WebInspector.showConsole = function() { this.drawer.showView(this.console); @@ -1159,7 +1167,6 @@ WebInspector.updateResource = function(identifier, payload) resource.mainResource = payload.mainResource; resource.requestMethod = payload.requestMethod; resource.requestFormData = payload.requestFormData; - resource.cached = payload.cached; resource.documentURL = payload.documentURL; if (resource.mainResource) @@ -1182,7 +1189,9 @@ WebInspector.updateResource = function(identifier, payload) 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 (payload.didTypeChange) { @@ -1455,10 +1464,10 @@ WebInspector.didCommitLoad = function() WebInspector.updateConsoleMessageExpiredCount = function(count) { var message = String.sprintf(WebInspector.UIString("%d console messages are not shown."), count); - WebInspector.console.addMessage(new WebInspector.ConsoleTextMessage(message, WebInspector.ConsoleMessage.MessageLevel.Warning)); + WebInspector.console.addMessage(WebInspector.ConsoleMessage.createTextMessage(message, WebInspector.ConsoleMessage.MessageLevel.Warning)); } -WebInspector.addConsoleMessage = function(payload, opt_args) +WebInspector.addConsoleMessage = function(payload) { var consoleMessage = new WebInspector.ConsoleMessage( payload.source, @@ -1467,8 +1476,10 @@ WebInspector.addConsoleMessage = function(payload, opt_args) payload.line, payload.url, payload.groupLevel, - payload.repeatCount); - consoleMessage.setMessageBody(Array.prototype.slice.call(arguments, 1)); + payload.repeatCount, + payload.message, + payload.parameters, + payload.stackTrace); this.console.addMessage(consoleMessage); } @@ -1536,7 +1547,9 @@ WebInspector.log = function(message, messageLevel) null, null, repeatCount, - message); + null, + [message], + null); self.console.addMessage(msg); } @@ -1830,8 +1843,12 @@ WebInspector._searchKeyDown = function(event) WebInspector.performSearch = function(event) { - var query = event.target.value; var forceSearch = event.keyIdentifier === "Enter"; + this.doPerformSearch(event.target.value, forceSearch, event.shiftKey, false); +} + +WebInspector.doPerformSearch = function(query, forceSearch, isBackwardSearch, repeatSearch) +{ var isShortSearch = (query.length < 3); // Clear a leftover short search flag due to a non-conflicting forced search. @@ -1863,11 +1880,15 @@ WebInspector.performSearch = function(event) return; } - if (query === this.currentPanel.currentQuery && this.currentPanel.currentQuery === this.currentQuery) { + if (!repeatSearch && query === this.currentPanel.currentQuery && this.currentPanel.currentQuery === this.currentQuery) { // When this is the same query and a forced search, jump to the next // search result for a good user experience. - if (forceSearch && this.currentPanel.jumpToNextSearchResult) - this.currentPanel.jumpToNextSearchResult(); + if (forceSearch) { + if (!isBackwardSearch && this.currentPanel.jumpToNextSearchResult) + this.currentPanel.jumpToNextSearchResult(); + else if (isBackwardSearch && this.currentPanel.jumpToPreviousSearchResult) + this.currentPanel.jumpToPreviousSearchResult(); + } return; } diff --git a/WebCore/inspector/front-end/treeoutline.js b/WebCore/inspector/front-end/treeoutline.js index 297bbab..5891401 100644 --- a/WebCore/inspector/front-end/treeoutline.js +++ b/WebCore/inspector/front-end/treeoutline.js @@ -482,8 +482,7 @@ TreeElement.prototype = { set title(x) { this._title = x; - if (this._listItemNode) - this._listItemNode.innerHTML = x; + this._setListItemNodeContent(); }, get tooltip() { @@ -548,6 +547,20 @@ TreeElement.prototype = { this._shouldRefreshChildren = x; if (x && this.expanded) this.expand(); + }, + + _setListItemNodeContent: function() + { + if (!this._listItemNode) + return; + if (!this._title || typeof this._title === "string") + this._listItemNode.innerHTML = this._title; + else { + this._listItemNode.removeChildren(); + if (this._title.parentNode) + this._title.parentNode.removeChild(this._title); + this._listItemNode.appendChild(this._title); + } } } @@ -566,7 +579,7 @@ TreeElement.prototype._attach = function() this._listItemNode = this.treeOutline._childrenListNode.ownerDocument.createElement("li"); this._listItemNode.treeElement = this; - this._listItemNode.innerHTML = this._title; + this._setListItemNodeContent(); this._listItemNode.title = this._tooltip ? this._tooltip : ""; if (this.hidden) diff --git a/WebCore/inspector/front-end/utilities.js b/WebCore/inspector/front-end/utilities.js index 1312e5b..6e7c725 100644 --- a/WebCore/inspector/front-end/utilities.js +++ b/WebCore/inspector/front-end/utilities.js @@ -188,8 +188,9 @@ Element.prototype.removeStyleClass = function(className) if (index === -1) return; - var newClassName = " " + this.className + " "; - this.className = newClassName.replace(" " + className + " ", " "); + this.className = this.className.split(" ").filter(function(s) { + return s && s !== className; + }).join(" "); } Element.prototype.removeMatchingStyleClasses = function(classNameRegex) |