summaryrefslogtreecommitdiffstats
path: root/WebCore/inspector
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/inspector')
-rw-r--r--WebCore/inspector/CodeGeneratorInspector.pm267
-rw-r--r--WebCore/inspector/ConsoleMessage.cpp3
-rw-r--r--WebCore/inspector/ConsoleMessage.h3
-rw-r--r--WebCore/inspector/InjectedScript.cpp11
-rw-r--r--WebCore/inspector/InjectedScript.h7
-rw-r--r--WebCore/inspector/InjectedScriptHost.cpp14
-rw-r--r--WebCore/inspector/InjectedScriptHost.h7
-rw-r--r--WebCore/inspector/InjectedScriptHost.idl2
-rw-r--r--WebCore/inspector/Inspector.idl228
-rw-r--r--WebCore/inspector/InspectorApplicationCacheAgent.cpp59
-rw-r--r--WebCore/inspector/InspectorApplicationCacheAgent.h20
-rw-r--r--WebCore/inspector/InspectorBackend.cpp533
-rw-r--r--WebCore/inspector/InspectorBackend.h120
-rw-r--r--WebCore/inspector/InspectorCSSStore.cpp10
-rw-r--r--WebCore/inspector/InspectorCSSStore.h5
-rw-r--r--WebCore/inspector/InspectorClient.h2
-rw-r--r--WebCore/inspector/InspectorController.cpp685
-rw-r--r--WebCore/inspector/InspectorController.h109
-rw-r--r--WebCore/inspector/InspectorDOMAgent.cpp256
-rw-r--r--WebCore/inspector/InspectorDOMAgent.h44
-rw-r--r--WebCore/inspector/InspectorDOMStorageResource.cpp15
-rw-r--r--WebCore/inspector/InspectorDOMStorageResource.h8
-rw-r--r--WebCore/inspector/InspectorDatabaseResource.cpp34
-rw-r--r--WebCore/inspector/InspectorDatabaseResource.h48
-rw-r--r--WebCore/inspector/InspectorDebuggerAgent.cpp296
-rw-r--r--WebCore/inspector/InspectorDebuggerAgent.h102
-rw-r--r--WebCore/inspector/InspectorFrontend.cpp625
-rw-r--r--WebCore/inspector/InspectorFrontend.h172
-rw-r--r--WebCore/inspector/InspectorFrontendClient.h2
-rw-r--r--WebCore/inspector/InspectorFrontendClientLocal.cpp10
-rw-r--r--WebCore/inspector/InspectorFrontendHost.cpp4
-rw-r--r--WebCore/inspector/InspectorResource.cpp132
-rw-r--r--WebCore/inspector/InspectorResource.h10
-rw-r--r--WebCore/inspector/InspectorStorageAgent.cpp229
-rw-r--r--WebCore/inspector/InspectorStorageAgent.h62
-rw-r--r--WebCore/inspector/InspectorValues.cpp12
-rw-r--r--WebCore/inspector/InspectorValues.h4
-rw-r--r--WebCore/inspector/ScriptDebugListener.h3
-rw-r--r--WebCore/inspector/TimelineRecordFactory.cpp2
-rw-r--r--WebCore/inspector/front-end/ApplicationCacheItemsView.js45
-rw-r--r--WebCore/inspector/front-end/BreakpointManager.js1
-rw-r--r--WebCore/inspector/front-end/Callback.js10
-rw-r--r--WebCore/inspector/front-end/ConsoleView.js1
-rw-r--r--WebCore/inspector/front-end/DOMAgent.js26
-rw-r--r--WebCore/inspector/front-end/DOMStorage.js3
-rw-r--r--WebCore/inspector/front-end/Database.js33
-rw-r--r--WebCore/inspector/front-end/DatabaseQueryView.js6
-rw-r--r--WebCore/inspector/front-end/DatabaseTableView.js4
-rw-r--r--WebCore/inspector/front-end/ElementsPanel.js2
-rw-r--r--WebCore/inspector/front-end/ElementsTreeOutline.js2
-rw-r--r--WebCore/inspector/front-end/ExtensionServer.js4
-rw-r--r--WebCore/inspector/front-end/InjectedScript.js39
-rw-r--r--WebCore/inspector/front-end/InjectedScriptAccess.js8
-rw-r--r--WebCore/inspector/front-end/InspectorBackendStub.js8
-rw-r--r--WebCore/inspector/front-end/ProfilesPanel.js2
-rw-r--r--WebCore/inspector/front-end/ResourcesPanel.js2
-rw-r--r--WebCore/inspector/front-end/ScriptView.js1
-rw-r--r--WebCore/inspector/front-end/ScriptsPanel.js7
-rw-r--r--WebCore/inspector/front-end/Settings.js1
-rw-r--r--WebCore/inspector/front-end/StoragePanel.js24
-rw-r--r--WebCore/inspector/front-end/inspector.js63
-rw-r--r--WebCore/inspector/front-end/utilities.js3
62 files changed, 1724 insertions, 2726 deletions
diff --git a/WebCore/inspector/CodeGeneratorInspector.pm b/WebCore/inspector/CodeGeneratorInspector.pm
index 5488dbd..9d0af53 100644
--- a/WebCore/inspector/CodeGeneratorInspector.pm
+++ b/WebCore/inspector/CodeGeneratorInspector.pm
@@ -14,9 +14,33 @@ $typeTransform{"InspectorClient"} = {
"forward" => "InspectorClient",
"header" => "InspectorClient.h",
};
-$typeTransform{"InspectorBackend"} = {
+$typeTransform{"Backend"} = {
"forward" => "InspectorBackend",
"header" => "InspectorBackend.h",
+ "handlerAccessor" => "m_inspectorController->inspectorBackend()",
+};
+$typeTransform{"Controller"} = {
+ "forwardHeader" => "InspectorController.h",
+ "handlerAccessor" => "m_inspectorController",
+};
+$typeTransform{"Debug"} = {
+ "forward" => "InspectorDebuggerAgent",
+ "header" => "InspectorDebuggerAgent.h",
+ "handlerAccessor" => "m_inspectorController->debuggerAgent()",
+};
+$typeTransform{"DOM"} = {
+ "forward" => "InspectorDOMAgent",
+ "header" => "InspectorDOMAgent.h",
+ "handlerAccessor" => "m_inspectorController->domAgent()",
+};
+$typeTransform{"ApplicationCache"} = {
+ "forward" => "InspectorApplicationCacheAgent",
+ "header" => "InspectorApplicationCacheAgent.h",
+ "handlerAccessor" => "m_inspectorController->applicationCacheAgent()",
+};
+$typeTransform{"Frontend"} = {
+ "forward" => "RemoteInspectorFrontend",
+ "header" => "RemoteInspectorFrontend.h",
};
$typeTransform{"PassRefPtr"} = {
"forwardHeader" => "wtf/PassRefPtr.h",
@@ -24,6 +48,8 @@ $typeTransform{"PassRefPtr"} = {
$typeTransform{"Object"} = {
"param" => "PassRefPtr<InspectorObject>",
"retVal" => "PassRefPtr<InspectorObject>",
+ "variable" => "RefPtr<InspectorObject>",
+ "defaultValue" => "InspectorObject::create()",
"forward" => "InspectorObject",
"header" => "InspectorValues.h",
"accessorSuffix" => ""
@@ -31,6 +57,8 @@ $typeTransform{"Object"} = {
$typeTransform{"Array"} = {
"param" => "PassRefPtr<InspectorArray>",
"retVal" => "PassRefPtr<InspectorArray>",
+ "variable" => "RefPtr<InspectorArray>",
+ "defaultValue" => "InspectorArray::create()",
"forward" => "InspectorArray",
"header" => "InspectorValues.h",
"accessorSuffix" => ""
@@ -38,41 +66,55 @@ $typeTransform{"Array"} = {
$typeTransform{"Value"} = {
"param" => "PassRefPtr<InspectorValue>",
"retVal" => "PassRefPtr<InspectorValue>",
+ "variable" => "RefPtr<InspectorValue>",
+ "defaultValue" => "InspectorValue::null()",
"forward" => "InspectorValue",
"header" => "InspectorValues.h",
"accessorSuffix" => ""
};
$typeTransform{"String"} = {
"param" => "const String&",
- "retVal" => "String",
- "forward" => "String",
+ "variable" => "String",
+ "forwardHeader" => "wtf/Forward.h",
"header" => "PlatformString.h",
"accessorSuffix" => "String"
};
$typeTransform{"long"} = {
"param" => "long",
- "retVal" => "long",
+ "variable" => "long",
+ "defaultValue" => "0",
"forward" => "",
"header" => "",
"accessorSuffix" => "Number"
};
$typeTransform{"int"} = {
"param" => "int",
- "retVal" => "int",
+ "variable" => "int",
+ "defaultValue" => "0",
"forward" => "",
"header" => "",
"accessorSuffix" => "Number",
};
$typeTransform{"unsigned long"} = {
"param" => "unsigned long",
- "retVal" => "unsigned long",
+ "variable" => "unsigned long",
+ "defaultValue" => "0u",
+ "forward" => "",
+ "header" => "",
+ "accessorSuffix" => "Number"
+};
+$typeTransform{"unsigned int"} = {
+ "param" => "unsigned int",
+ "variable" => "unsigned int",
+ "defaultValue" => "0u",
"forward" => "",
"header" => "",
"accessorSuffix" => "Number"
};
$typeTransform{"boolean"} = {
"param" => "bool",
- "retVal"=> "bool",
+ "variable"=> "bool",
+ "defaultValue" => "false",
"forward" => "",
"header" => "",
"accessorSuffix" => "Bool"
@@ -163,12 +205,14 @@ sub GenerateInterface
$backendClassName = $className . "BackendDispatcher";
my @backendHead;
- push(@backendHead, " ${backendClassName}(InspectorBackend* inspectorBackend) : m_inspectorBackend(inspectorBackend) { }");
+ push(@backendHead, " ${backendClassName}(InspectorController* inspectorController) : m_inspectorController(inspectorController) { }");
+ push(@backendHead, " void reportProtocolError(const long callId, const String& method, const String& errorText) const;");
push(@backendHead, " void dispatch(const String& message);");
push(@backendHead, "private:");
$backendConstructor = join("\n", @backendHead);
- $backendFooter = " InspectorBackend* m_inspectorBackend;";
- $backendTypes{"InspectorBackend"} = 1;
+ $backendFooter = " InspectorController* m_inspectorController;";
+ $backendTypes{"Controller"} = 1;
+ $backendTypes{"InspectorClient"} = 1;
$backendTypes{"PassRefPtr"} = 1;
$backendTypes{"Array"} = 1;
@@ -185,20 +229,16 @@ sub generateFunctions
generateBackendFunction($function);
}
push(@backendMethodsImpl, generateBackendDispatcher());
+ push(@backendMethodsImpl, generateBackendReportProtocolError());
}
sub generateFrontendFunction
{
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);
- }
+ return if !$notify;
+ my $functionName = $notify ? $function->signature->name : "did" . ucfirst($function->signature->name);
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.
@@ -214,9 +254,10 @@ sub generateFrontendFunction
push(@function, "void ${frontendClassName}::${functionName}(${arguments})");
push(@function, "{");
push(@function, " RefPtr<InspectorArray> arguments = InspectorArray::create();");
- push(@function, " arguments->pushString(\"$functionName\");");
+ push(@function, " arguments->pushString(\"" . ($notify ? $functionName : "processResponse") . "\");");
push(@function, @pushArguments);
push(@function, " m_inspectorClient->sendMessageToFrontend(arguments->toJSONString());");
+
push(@function, "}");
push(@function, "");
push(@frontendMethodsImpl, @function);
@@ -228,12 +269,12 @@ sub generateBackendPrivateFunctions
my $privateFunctions = << "EOF";
static String formatWrongArgumentsCountMessage(unsigned expected, unsigned actual)
{
- return String::format(\"Wrong number of parameters: %d (expected: %d)\", actual, expected);
+ return String::format("Wrong number of parameters: %d (expected: %d)", actual, expected);
}
static String formatWrongArgumentTypeMessage(unsigned position, const char* name, const char* expectedType)
{
- return String::format(\"Failed to convert parameter %d (%s) to %s\", position, name, expectedType);
+ return String::format("Failed to convert parameter %d (%s) to %s", position, name, expectedType);
}
EOF
push(@backendMethodsImpl, $privateFunctions);
@@ -246,95 +287,153 @@ sub generateBackendFunction
my $functionName = $function->signature->name;
- my @argsFiltered = grep($_->direction eq "in", @{$function->parameters});
- map($backendTypes{$_->type} = 1, @argsFiltered); # register required types
- my $arguments = join(", ", map($typeTransform{$_->type}->{"param"} . " " . $_->name, @argsFiltered));
+ map($backendTypes{$_->type} = 1, @{$function->parameters}); # register required types
+ my @inArgs = grep($_->direction eq "in", @{$function->parameters});
+ my @outArgs = grep($_->direction eq "out", @{$function->parameters});
- my $signature = " void ${functionName}(PassRefPtr<InspectorArray> args, String* exception);";
+ my $signature = " void ${functionName}(PassRefPtr<InspectorArray> args);";
!$backendMethods{${signature}} || die "Duplicate function was detected for signature '$signature'.";
$backendMethods{${signature}} = $functionName;
my @function;
- push(@function, "void ${backendClassName}::${functionName}(PassRefPtr<InspectorArray> args, String* exception)");
+ push(@function, "void ${backendClassName}::${functionName}(PassRefPtr<InspectorArray> args)");
push(@function, "{");
- my $i = 1; # zero element is the method name.
- my $expectedParametersCount = scalar(@argsFiltered);
- my $expectedParametersCountWithMethodName = scalar(@argsFiltered) + 1;
+ push(@function, " DEFINE_STATIC_LOCAL(String, backendFunctionName, (\"$functionName\"));");
+ push(@function, " long callId = 0;");
+ push(@function, "");
+
+ my $expectedParametersCount = scalar(@inArgs);
+ my $expectedParametersCountWithMethodName = scalar(@inArgs) + 1;
push(@function, " if (args->length() != $expectedParametersCountWithMethodName) {");
- push(@function, " *exception = formatWrongArgumentsCountMessage(args->length() - 1, $expectedParametersCount);");
push(@function, " ASSERT_NOT_REACHED();");
+ push(@function, " reportProtocolError(callId, backendFunctionName, formatWrongArgumentsCountMessage(args->length() - 1, $expectedParametersCount));");
push(@function, " return;");
push(@function, " }");
+ push(@function, "");
- foreach my $parameter (@argsFiltered) {
- my $parameterType = $parameter->type;
- push(@function, " " . $typeTransform{$parameterType}->{"retVal"} . " " . $parameter->name . ";");
- push(@function, " if (!args->get(" . $i . ")->as" . $typeTransform{$parameterType}->{"accessorSuffix"} . "(&" . $parameter->name . ")) {");
- push(@function, " *exception = formatWrongArgumentTypeMessage($i, \"" . $parameter->name . "\", \"$parameterType\");");
+ my $i = 1; # zero element is the method name.
+ foreach my $parameter (@inArgs) {
+ my $type = $parameter->type;
+ my $argumentType = $typeTransform{$type}->{$typeTransform{$type}->{"retVal"} ? "retVal" : "variable"};
+ push(@function, " $argumentType " . $parameter->name . ";") if !($parameter->name eq "callId");
+ push(@function, " if (!args->get($i)->as" . $typeTransform{$type}->{"accessorSuffix"} . "(&" . $parameter->name . ")) {");
push(@function, " ASSERT_NOT_REACHED();");
+ push(@function, " reportProtocolError(callId, backendFunctionName, formatWrongArgumentTypeMessage($i, \"" . $parameter->name . "\", \"$type\"));");
push(@function, " return;");
push(@function, " }");
+ push(@function, "");
++$i;
}
- push(@function, " m_inspectorBackend->$functionName(" . join(", ", map($_->name, @argsFiltered)) . ");");
+
+ my $handler = $function->signature->extendedAttributes->{"handler"} || "Controller";
+ my $handlerAccessor = $typeTransform{$handler}->{"handlerAccessor"};
+ $backendTypes{$handler} = 1;
+ push(@function, " if (!$handlerAccessor) {");
+ push(@function, " reportProtocolError(callId, backendFunctionName, \"Error: $handler handler is not available.\");");
+ push(@function, " return;");
+ push(@function, " }");
+ push(@function, "");
+
+
+ foreach (@outArgs) { # declare local variables for out arguments.
+ my $initializer = $typeTransform{$_->type}->{"defaultValue"} ? " = " . $typeTransform{$_->type}->{"defaultValue"} : "";
+ push(@function, " " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . "$initializer;");
+ }
+
+ my $args = join(", ", (grep(!($_ eq "callId"), map($_->name, @inArgs)), map("&" . $_->name, @outArgs)));
+ push(@function, " $handlerAccessor->$functionName($args);");
+
+ # The results of function call should be transfered back to frontend.
+ if (scalar(grep($_->name eq "callId", @inArgs))) {
+ my @pushArguments = map(" arguments->push" . $typeTransform{$_->type}->{"accessorSuffix"} . "(" . $_->name . ");", @outArgs);
+
+ push(@function, "");
+ push(@function, " // use InspectorFrontend as a marker of WebInspector availability");
+ push(@function, " if (m_inspectorController->hasFrontend()) {");
+ push(@function, " RefPtr<InspectorArray> arguments = InspectorArray::create();");
+ push(@function, " arguments->pushString(\"processResponse\");");
+ push(@function, " arguments->pushNumber(callId);");
+ push(@function, @pushArguments);
+ push(@function, " m_inspectorController->inspectorClient()->sendMessageToFrontend(arguments->toJSONString());");
+ push(@function, " }");
+ }
push(@function, "}");
push(@function, "");
push(@backendMethodsImpl, @function);
}
+sub generateBackendReportProtocolError
+{
+ my $reportProtocolError = << "EOF";
+
+void ${backendClassName}::reportProtocolError(const long callId, const String& method, const String& errorText) const
+{
+ RefPtr<InspectorArray> arguments = InspectorArray::create();
+ arguments->pushString("reportProtocolError");
+ arguments->pushNumber(callId);
+ arguments->pushString(method);
+ arguments->pushString(errorText);
+ m_inspectorController->inspectorClient()->sendMessageToFrontend(arguments->toJSONString());
+}
+EOF
+ return split("\n", $reportProtocolError);
+}
+
sub generateBackendDispatcher
{
my @body;
my @methods = map($backendMethods{$_}, keys %backendMethods);
- my @mapEntries = map("dispatchMap.add(\"$_\", &${backendClassName}::$_);", @methods);
-
- push(@body, "void ${backendClassName}::dispatch(const String& message)");
- push(@body, "{");
- push(@body, " String exception;");
- push(@body, " typedef void (${backendClassName}::*CallHandler)(PassRefPtr<InspectorArray> args, String* exception);");
- push(@body, " typedef HashMap<String, CallHandler> DispatchMap;");
- push(@body, " DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );");
- push(@body, " if (dispatchMap.isEmpty()) {");
- push(@body, map(" $_", @mapEntries));
- push(@body, " }");
- push(@body, "");
- push(@body, " RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);");
- push(@body, " if (!parsedMessage) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " exception = \"Error: Invalid message format. Message should be in JSON format.\";");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " RefPtr<InspectorArray> messageArray = parsedMessage->asArray();");
- push(@body, " if (!messageArray) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " exception = \"Error: Invalid message format. The message should be a JSONified array of arguments.\";");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " if (!messageArray->length()) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " exception = \"Error: Invalid message format. Empty message was received.\";");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " String methodName;");
- push(@body, " if (!messageArray->get(0)->asString(&methodName)) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " exception = \"Error: Invalid message format. The first element of the message should be method name.\";");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " HashMap<String, CallHandler>::iterator it = dispatchMap.find(methodName);");
- push(@body, " if (it == dispatchMap.end()) {");
- push(@body, " ASSERT_NOT_REACHED();");
- push(@body, " exception = String::format(\"Error: Invalid method name. '%s' wasn't found.\", methodName.utf8().data());");
- push(@body, " return;");
- push(@body, " }");
- push(@body, "");
- push(@body, " ((*this).*it->second)(messageArray, &exception);");
- push(@body, "}");
- return @body;
+ my @mapEntries = map(" dispatchMap.add(\"$_\", &${backendClassName}::$_);", @methods);
+ my $mapEntries = join("\n", @mapEntries);
+
+ my $backendDispatcherBody = << "EOF";
+void ${backendClassName}::dispatch(const String& message)
+{
+ typedef void (${backendClassName}::*CallHandler)(PassRefPtr<InspectorArray> args);
+ typedef HashMap<String, CallHandler> DispatchMap;
+ DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );
+ if (dispatchMap.isEmpty()) {
+$mapEntries
+ }
+
+ RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);
+ if (!parsedMessage) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", "Error: Invalid message format. Message should be in JSON format.");
+ return;
+ }
+
+ RefPtr<InspectorArray> messageArray = parsedMessage->asArray();
+ if (!messageArray) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", "Error: Invalid message format. The message should be a JSONified array of arguments.");
+ return;
+ }
+
+ if (!messageArray->length()) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", "Error: Invalid message format. Empty message was received.");
+ return;
+ }
+
+ String methodName;
+ if (!messageArray->get(0)->asString(&methodName)) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", "Error: Invalid message format. The first element of the message should be method name.");
+ return;
+ }
+
+ HashMap<String, CallHandler>::iterator it = dispatchMap.find(methodName);
+ if (it == dispatchMap.end()) {
+ ASSERT_NOT_REACHED();
+ reportProtocolError(0, "dispatch", String::format("Error: Invalid method name. '%s' wasn't found.", methodName.utf8().data()));
+ return;
+ }
+
+ ((*this).*it->second)(messageArray);
+}
+EOF
+ return split("\n", $backendDispatcherBody);
}
sub generateHeader
diff --git a/WebCore/inspector/ConsoleMessage.cpp b/WebCore/inspector/ConsoleMessage.cpp
index 9c0b783..059dea4 100644
--- a/WebCore/inspector/ConsoleMessage.cpp
+++ b/WebCore/inspector/ConsoleMessage.cpp
@@ -33,10 +33,9 @@
#include "InjectedScript.h"
#include "InjectedScriptHost.h"
-#include "InspectorFrontend.h"
#include "InspectorValues.h"
#include "ScriptCallStack.h"
-#include "ScriptObject.h"
+#include "ScriptValue.h"
#if ENABLE(INSPECTOR)
#include "RemoteInspectorFrontend.h"
diff --git a/WebCore/inspector/ConsoleMessage.h b/WebCore/inspector/ConsoleMessage.h
index cb5e6f0..e286f0a 100644
--- a/WebCore/inspector/ConsoleMessage.h
+++ b/WebCore/inspector/ConsoleMessage.h
@@ -33,7 +33,6 @@
#include "Console.h"
#include "KURL.h"
-#include "ScriptObject.h"
#include "ScriptState.h"
#include <wtf/Vector.h>
@@ -44,7 +43,7 @@ class InspectorObject;
class RemoteInspectorFrontend;
class ScriptCallFrame;
class ScriptCallStack;
-class ScriptString;
+class ScriptValue;
class ConsoleMessage : public Noncopyable {
public:
diff --git a/WebCore/inspector/InjectedScript.cpp b/WebCore/inspector/InjectedScript.cpp
index 5f2fb74..3f4d819 100644
--- a/WebCore/inspector/InjectedScript.cpp
+++ b/WebCore/inspector/InjectedScript.cpp
@@ -35,7 +35,6 @@
#include "InspectorValues.h"
#include "PlatformString.h"
-#include "SerializedScriptValue.h"
#include "ScriptFunctionCall.h"
namespace WebCore {
@@ -45,7 +44,7 @@ InjectedScript::InjectedScript(ScriptObject injectedScriptObject)
{
}
-void InjectedScript::dispatch(long callId, const String& methodName, const String& arguments, bool async, RefPtr<SerializedScriptValue>* result, bool* hadException)
+void InjectedScript::dispatch(const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException)
{
ASSERT(!hasNoValue());
if (!canAccessInspectedWindow()) {
@@ -56,21 +55,19 @@ void InjectedScript::dispatch(long callId, const String& methodName, const Strin
ScriptFunctionCall function(m_injectedScriptObject, "dispatch");
function.appendArgument(methodName);
function.appendArgument(arguments);
- if (async)
- function.appendArgument(callId);
*hadException = false;
ScriptValue resultValue = function.call(*hadException);
if (!*hadException)
- *result = resultValue.serialize(m_injectedScriptObject.scriptState());
+ *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState());
}
#if ENABLE(JAVASCRIPT_DEBUGGER)
-PassRefPtr<SerializedScriptValue> InjectedScript::callFrames()
+PassRefPtr<InspectorValue> InjectedScript::callFrames()
{
ASSERT(!hasNoValue());
ScriptFunctionCall function(m_injectedScriptObject, "callFrames");
ScriptValue callFramesValue = function.call();
- return callFramesValue.serialize(m_injectedScriptObject.scriptState());
+ return callFramesValue.toInspectorValue(m_injectedScriptObject.scriptState());
}
#endif
diff --git a/WebCore/inspector/InjectedScript.h b/WebCore/inspector/InjectedScript.h
index f6b6e19..17389ba 100644
--- a/WebCore/inspector/InjectedScript.h
+++ b/WebCore/inspector/InjectedScript.h
@@ -33,14 +33,13 @@
#include "InjectedScriptHost.h"
#include "ScriptObject.h"
+#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
class InspectorValue;
-class SerializedScriptValue;
-class String;
class InjectedScript {
public:
@@ -49,9 +48,9 @@ public:
bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); }
- void dispatch(long callId, const String& methodName, const String& arguments, bool async, RefPtr<SerializedScriptValue>* result, bool* hadException);
+ void dispatch(const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException);
#if ENABLE(JAVASCRIPT_DEBUGGER)
- PassRefPtr<SerializedScriptValue> callFrames();
+ PassRefPtr<InspectorValue> callFrames();
#endif
PassRefPtr<InspectorValue> wrapForConsole(ScriptValue);
void releaseWrapperObjectGroup(const String&);
diff --git a/WebCore/inspector/InjectedScriptHost.cpp b/WebCore/inspector/InjectedScriptHost.cpp
index e8a9fee..37512be 100644
--- a/WebCore/inspector/InjectedScriptHost.cpp
+++ b/WebCore/inspector/InjectedScriptHost.cpp
@@ -42,9 +42,9 @@
#include "InspectorClient.h"
#include "InspectorController.h"
#include "InspectorDOMAgent.h"
-#include "InspectorFrontend.h"
#include "InspectorResource.h"
#include "Pasteboard.h"
+#include "RemoteInspectorFrontend.h"
#if ENABLE(JAVASCRIPT_DEBUGGER)
#include "ScriptDebugServer.h"
@@ -98,7 +98,7 @@ Node* InjectedScriptHost::nodeForId(long nodeId)
long InjectedScriptHost::pushNodePathToFrontend(Node* node, bool withChildren, bool selectInUI)
{
- InspectorFrontend* frontend = inspectorFrontend();
+ RemoteInspectorFrontend* frontend = remoteFrontend();
InspectorDOMAgent* domAgent = inspectorDOMAgent();
if (!domAgent || !frontend)
return 0;
@@ -142,12 +142,6 @@ void InjectedScriptHost::selectDOMStorage(Storage* storage)
}
#endif
-void InjectedScriptHost::reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException)
-{
- if (InspectorFrontend* frontend = inspectorFrontend())
- frontend->didDispatchOnInjectedScript(callId, result, isException);
-}
-
InjectedScript InjectedScriptHost::injectedScriptForId(long id)
{
return m_idToInjectedScript.get(id);
@@ -178,11 +172,11 @@ InspectorDOMAgent* InjectedScriptHost::inspectorDOMAgent()
return m_inspectorController->domAgent();
}
-InspectorFrontend* InjectedScriptHost::inspectorFrontend()
+RemoteInspectorFrontend* InjectedScriptHost::remoteFrontend()
{
if (!m_inspectorController)
return 0;
- return m_inspectorController->m_frontend.get();
+ return m_inspectorController->m_remoteFrontend.get();
}
pair<long, ScriptObject> InjectedScriptHost::injectScript(const String& source, ScriptState* scriptState)
diff --git a/WebCore/inspector/InjectedScriptHost.h b/WebCore/inspector/InjectedScriptHost.h
index b942148..997f340 100644
--- a/WebCore/inspector/InjectedScriptHost.h
+++ b/WebCore/inspector/InjectedScriptHost.h
@@ -43,9 +43,9 @@ namespace WebCore {
class Database;
class InjectedScript;
class InspectorDOMAgent;
-class InspectorFrontend;
class Node;
-class SerializedScriptValue;
+class RemoteInspectorFrontend;
+class ScriptObject;
class Storage;
class InjectedScriptHost : public RefCounted<InjectedScriptHost>
@@ -82,7 +82,6 @@ public:
void didCreateWorker(long id, const String& url, bool isSharedWorker);
void didDestroyWorker(long id);
#endif
- void reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException);
pair<long, ScriptObject> injectScript(const String& source, ScriptState*);
InjectedScript injectedScriptFor(ScriptState*);
@@ -95,7 +94,7 @@ public:
private:
InjectedScriptHost(InspectorController* inspectorController);
InspectorDOMAgent* inspectorDOMAgent();
- InspectorFrontend* inspectorFrontend();
+ RemoteInspectorFrontend* remoteFrontend();
ScriptObject createInjectedScript(const String& source, ScriptState* scriptState, long id);
InspectorController* m_inspectorController;
diff --git a/WebCore/inspector/InjectedScriptHost.idl b/WebCore/inspector/InjectedScriptHost.idl
index 21af938..9b2ed6c 100644
--- a/WebCore/inspector/InjectedScriptHost.idl
+++ b/WebCore/inspector/InjectedScriptHost.idl
@@ -44,7 +44,6 @@ module core {
#endif
#if defined(ENABLE_DATABASE) && ENABLE_DATABASE
- [Custom] DOMObject databaseForId(in long databaseId);
[Custom] void selectDatabase(in DOMObject database);
#endif
@@ -57,6 +56,5 @@ module core {
void didDestroyWorker(in long id);
long nextWorkerId();
#endif
- [Custom] void reportDidDispatchOnInjectedScript(in long callId, in DOMObject result, in boolean isException);
};
}
diff --git a/WebCore/inspector/Inspector.idl b/WebCore/inspector/Inspector.idl
index 155bfcd..9d3d102 100644
--- a/WebCore/inspector/Inspector.idl
+++ b/WebCore/inspector/Inspector.idl
@@ -36,126 +36,186 @@ module core {
[notify] void addRecordToTimeline(out Object record);
[notify] void addNodesToSearchResult(out Array nodeIds);
[notify] void attributesUpdated(out long id, out Array attributes);
+ [notify] void bringToFront();
[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 close();
+ [notify] void didCommitLoad();
+ [notify] void evaluateForTestInFrontend(out long testCallId, out String script);
+ [notify] void inspectedPageDestroyed();
+ [notify] void inspectedURLChanged(out String url);
+ [notify] void monitoringXHRWasEnabled();
+ [notify] void monitoringXHRWasDisabled();
+ [notify] void populateApplicationSettings(out String settings);
+ [notify] void populateInterface();
+ [notify] void populateSessionSettings(out String settings);
+ [notify] void removeResource(out unsigned long identifier);
+ [notify] void reset();
+ [notify] void resetProfilesPanel();
+ [notify] void resourceTrackingWasEnabled();
+ [notify] void resourceTrackingWasDisabled();
+ [notify] void searchingForNodeWasEnabled();
+ [notify] void searchingForNodeWasDisabled();
[notify] void setChildNodes(out long parentId, out Array nodes);
[notify] void setDetachedRoot(out Object root);
[notify] void setDocument(out Value root);
+ [notify] void showPanel(out String panel);
+ [notify] void timelineProfilerWasStarted();
+ [notify] void timelineProfilerWasStopped();
[notify] void updateConsoleMessageExpiredCount(out unsigned long count);
[notify] void updateConsoleMessageRepeatCount(out unsigned long count);
+ [notify] void updateFocusedNode(out long nodeId);
+ [notify] void updateResource(out Value resource);
- void storeLastActivePanel(in String panelName);
+#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
+ [notify] void addProfileHeader(out Object header);
+ [notify] void attachDebuggerWhenShown();
+ [notify] void debuggerWasEnabled();
+ [notify] void debuggerWasDisabled();
+ [notify] void failedToParseScriptSource(out String url, out String data, out int firstLine, out int errorLine, out String errorMessage);
+ [notify] void parsedScriptSource(out String sourceID, out String url, out String data, out int firstLine, out int scriptWorldType);
+ [notify] void pausedScript(out Value callFrames);
+ [notify] void profilerWasEnabled();
+ [notify] void profilerWasDisabled();
+ [notify] void restoredBreakpoint(out String sourceID, out String url, out int line, out boolean enabled, out String condition);
+ [notify] void resumedScript();
+ [notify] void setRecordingProfile(out boolean isProfiling);
+ [notify] void updatePauseOnExceptionsState(out long state);
+#endif
+#if defined(ENABLE_DATABASE) && ENABLE_DATABASE
+ [notify] void addDatabase(out Object database);
+ [notify] void selectDatabase(out int databaseId);
+#endif
+#if defined(ENABLE_DOM_STORAGE) && ENABLE_DOM_STORAGE
+ [notify] void addDOMStorage(out Object storage);
+ [notify] void updateDOMStorage(out int storageId);
+ [notify] void selectDOMStorage(out int storageId);
+#endif
+#if defined(ENABLE_OFFLINE_WEB_APPLICATIONS) && ENABLE_OFFLINE_WEB_APPLICATIONS
+ [notify] void updateApplicationCacheStatus(out int status);
+ [notify] void updateNetworkState(out boolean isNowOnline);
+#endif
+#if defined(ENABLE_WORKERS) && ENABLE_WORKERS
+ [notify] void didCreateWorker(out long id, out String url, out boolean isShared);
+ [notify] void didDestroyWorker(out long id);
+#endif
- void saveApplicationSettings(in String settings);
- void saveSessionSettings(in String settings);
+ [handler=Controller] void storeLastActivePanel(in String panelName);
- void enableSearchingForNode();
- void disableSearchingForNode();
+ [handler=Controller] void saveApplicationSettings(in String settings);
+ [handler=Controller] void saveSessionSettings(in String settings);
- void enableMonitoringXHR();
- void disableMonitoringXHR();
+ [handler=Controller] void enableSearchingForNode();
+ [handler=Controller] void disableSearchingForNode();
- void enableResourceTracking(in boolean always);
- void disableResourceTracking(in boolean always);
- void getResourceContent(in long callId, in unsigned long identifier);
- void reloadPage();
+ [handler=Controller] void enableMonitoringXHR();
+ [handler=Controller] void disableMonitoringXHR();
- void startTimelineProfiler();
- void stopTimelineProfiler();
+ [handler=Controller] void enableResourceTracking(in boolean always);
+ [handler=Controller] void disableResourceTracking(in boolean always);
+ [handler=Controller] void getResourceContent(in long callId, in unsigned long identifier, out String content);
+ [handler=Controller] void reloadPage();
+
+ [handler=Controller] void startTimelineProfiler();
+ [handler=Controller] void stopTimelineProfiler();
#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
- void enableDebugger(in boolean always);
- void disableDebugger(in boolean always);
+ [handler=Backend] void enableDebugger(in boolean always);
+ [handler=Controller] 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();
+ [handler=Debug] void setBreakpoint(in long callId, in String sourceID, in unsigned int lineNumber, in boolean enabled, in String condition, out boolean success, out unsigned int actualLineNumber);
+ [handler=Debug] void removeBreakpoint(in String sourceID, in unsigned long lineNumber);
+ [handler=Debug] void activateBreakpoints();
+ [handler=Debug] void deactivateBreakpoints();
- void pause();
- void resume();
+ [handler=Debug] void pause();
+ [handler=Debug] void resume();
- void stepOverStatement();
- void stepIntoStatement();
- void stepOutOfFunction();
+ [handler=Debug] void stepOverStatement();
+ [handler=Debug] void stepIntoStatement();
+ [handler=Debug] void stepOutOfFunction();
- void setPauseOnExceptionsState(in long pauseOnExceptionsState);
+ [handler=Debug] void setPauseOnExceptionsState(in long pauseOnExceptionsState);
- void editScriptSource(in long callId, in String sourceID, in String newContent);
- void getScriptSource(in long callId, in String sourceID);
+ [handler=Debug] void editScriptSource(in long callId, in String sourceID, in String newContent, out boolean success, out String result, out Value newCallFrames);
+ [handler=Debug] void getScriptSource(in long callId, in String sourceID, out String scriptSource);
- void enableProfiler(in boolean always);
- void disableProfiler(in boolean always);
+ [handler=Controller] void enableProfiler(in boolean always);
+ [handler=Controller] void disableProfiler(in boolean always);
- void startProfiling();
- void stopProfiling();
+ [handler=Controller] void startProfiling();
+ [handler=Controller] void stopProfiling();
- void getProfileHeaders(in long callId);
- void getProfile(in long callId, in unsigned long uid);
+ [handler=Controller] void getProfileHeaders(in long callId, out Array headers);
+ [handler=Controller] void getProfile(in long callId, in unsigned long uid, out Object profile);
- void removeProfile(in unsigned long uid);
- void clearProfiles();
+ [handler=Controller] void removeProfile(in unsigned long uid);
+ [handler=Controller] void clearProfiles();
- void takeHeapSnapshot();
+ [handler=Backend] void takeHeapSnapshot();
+ [handler=Backend] void getProfilerLogLines(in long callId, in long inPosition, out long outPosition, out String log);
#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(in long callId);
-
- 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 getRuleRanges(in long callId, in long styleSheetId, out Value ranges);
- 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);
+ [handler=Backend] void setInjectedScriptSource(in String scriptSource);
+ [handler=Backend] void dispatchOnInjectedScript(in long callId, in long injectedScriptId, in String methodName, in String arguments, out Value result, out boolean isException);
+ [handler=Controller] void addScriptToEvaluateOnLoad(in String scriptSource);
+ [handler=Controller] void removeAllScriptsToEvaluateOnLoad();
+
+ [handler=DOM] void getChildNodes(in long callId, in long nodeId);
+ [handler=DOM] void setAttribute(in long callId, in long elementId, in String name, in String value, out boolean success);
+ [handler=DOM] void removeAttribute(in long callId, in long elementId, in String name, out boolean success);
+ [handler=DOM] void setTextNodeValue(in long callId, in long nodeId, in String value, out boolean success);
+ [handler=DOM] void getEventListenersForNode(in long callId, in long nodeId, out long outNodeId, out Array listenersArray);
+ [handler=DOM] void copyNode(in long nodeId);
+ [handler=DOM] void removeNode(in long callId, in long nodeId, out long outNodeId);
+ [handler=DOM] void changeTagName(in long callId, in long nodeId, in String newTagName, out long outNodeId);
+ [handler=DOM] void getOuterHTML(in long callId, in long nodeId, out String outerHTML);
+ [handler=DOM] void setOuterHTML(in long callId, in long nodeId, in String outerHTML, out long outNodeId);
+ [handler=DOM] void addInspectedNode(in long nodeId);
+ [handler=DOM] void performSearch(in String query, in boolean runSynchronously);
+ [handler=DOM] void searchCanceled();
+ [handler=DOM] void pushNodeByPathToFrontend(in long callId, in String path, out long nodeId);
+
+ [handler=Backend] void clearConsoleMessages(in long callId);
+
+ [handler=Controller] void highlightDOMNode(in long nodeId);
+ [handler=Controller] void hideDOMNodeHighlight();
+
+ [handler=DOM] void getStyles(in long callId, in long nodeId, in boolean authOnly, out Value styles);
+ [handler=DOM] void getAllStyles(in long callId, out Array styles);
+ [handler=DOM] void getInlineStyle(in long callId, in long nodeId, out Value style);
+ [handler=DOM] void getComputedStyle(in long callId, in long nodeId, out Value style);
+ [handler=DOM] void getStyleSheet(in long callId, in long styleSheetId, out Object styleSheet);
+ [handler=DOM] void getRuleRanges(in long callId, in long styleSheetId, out Value ranges);
+ [handler=DOM] void applyStyleText(in long callId, in long styleId, in String styleText, in String propertyName, out boolean success, out Value style, out Array changedProperties);
+ [handler=DOM] void setStyleText(in long callId, in long styleId, in String styleText, out boolean success);
+ [handler=DOM] void setStyleProperty(in long callId, in long styleId, in String name, in String value, out boolean success);
+ [handler=DOM] void toggleStyleEnabled(in long callId, in long styleId, in String propertyName, in boolean disabled, out Value style);
+ [handler=DOM] void setRuleSelector(in long callId, in long ruleId, in String selector, in long selectedNodeId, out Value rule, out boolean selectorAffectsNode);
+ [handler=DOM] void addRule(in long callId, in String selector, in long selectedNodeId, out Value rule, out boolean selectorAffectsNode);
+
+ [handler=Controller] void getCookies(in long callId, out Array cookies, out String cookiesString);
+ [handler=Controller] void deleteCookie(in String cookieName, in String domain);
#if defined(ENABLE_OFFLINE_WEB_APPLICATIONS) && ENABLE_OFFLINE_WEB_APPLICATIONS
- void getApplicationCaches(in long callId);
+ [handler=ApplicationCache] void getApplicationCaches(in long callId, out Value applicationCaches);
#endif
- void releaseWrapperObjectGroup(in long injectedScriptId, in String objectGroup);
- void didEvaluateForTestInFrontend(in long callId, in String jsonResult);
+ [handler=Backend] void releaseWrapperObjectGroup(in long injectedScriptId, in String objectGroup);
+ [handler=Controller] void didEvaluateForTestInFrontend(in long testCallId, in String jsonResult);
#if defined(ENABLE_DATABASE) && ENABLE_DATABASE
- void getDatabaseTableNames(in long callId, in long databaseId);
+ [handler=Backend] void getDatabaseTableNames(in long callId, in long databaseId, out Array tableNames);
+ [handler=Backend] void executeSQL(in long callId, in long databaseId, in String query, out boolean success, out long transactionId);
+ [notify] void sqlTransactionSucceeded(out long transactionId, out Value columnNames, out Value values);
+ [notify] void sqlTransactionFailed(out long transactionId, out Value sqlError);
#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);
+ [handler=Controller] void getDOMStorageEntries(in long callId, in long storageId, out Array entries);
+ [handler=Controller] void setDOMStorageItem(in long callId, in long storageId, in String key, in String value, out boolean success);
+ [handler=Controller] void removeDOMStorageItem(in long callId, in long storageId, in String key, out boolean success);
#endif
+
};
}
diff --git a/WebCore/inspector/InspectorApplicationCacheAgent.cpp b/WebCore/inspector/InspectorApplicationCacheAgent.cpp
index 1ea7556..b95c0e1 100644
--- a/WebCore/inspector/InspectorApplicationCacheAgent.cpp
+++ b/WebCore/inspector/InspectorApplicationCacheAgent.cpp
@@ -33,15 +33,14 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "InspectorController.h"
-#include "InspectorFrontend.h"
+#include "InspectorValues.h"
#include "Page.h"
+#include "RemoteInspectorFrontend.h"
#include "ResourceResponse.h"
-#include "ScriptArray.h"
-#include "ScriptObject.h"
namespace WebCore {
-InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InspectorController* inspectorController, InspectorFrontend* frontend)
+InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InspectorController* inspectorController, RemoteInspectorFrontend* frontend)
: m_inspectorController(inspectorController)
, m_frontend(frontend)
{
@@ -62,52 +61,48 @@ void InspectorApplicationCacheAgent::updateNetworkState(bool isNowOnline)
m_frontend->updateNetworkState(isNowOnline);
}
-void InspectorApplicationCacheAgent::getApplicationCaches(long callId)
+void InspectorApplicationCacheAgent::getApplicationCaches(RefPtr<InspectorValue>* applicationCaches)
{
DocumentLoader* documentLoader = m_inspectorController->inspectedPage()->mainFrame()->loader()->documentLoader();
- if (!documentLoader) {
- m_frontend->didGetApplicationCaches(callId, ScriptValue::undefined());
- return;
- }
-
- ApplicationCacheHost* host = documentLoader->applicationCacheHost();
- ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
-
- ApplicationCacheHost::ResourceInfoList resources;
- host->fillResourceList(&resources);
+ if (documentLoader) {
+ ApplicationCacheHost* host = documentLoader->applicationCacheHost();
+ ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
- m_frontend->didGetApplicationCaches(callId, buildObjectForApplicationCache(resources, info));
+ ApplicationCacheHost::ResourceInfoList resources;
+ host->fillResourceList(&resources);
+ *applicationCaches = buildObjectForApplicationCache(resources, info);
+ }
}
-ScriptObject InspectorApplicationCacheAgent::buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList& applicationCacheResources, const ApplicationCacheHost::CacheInfo& applicationCacheInfo)
+PassRefPtr<InspectorObject> InspectorApplicationCacheAgent::buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList& applicationCacheResources, const ApplicationCacheHost::CacheInfo& applicationCacheInfo)
{
- ScriptObject value = m_frontend->newScriptObject();
- value.set("size", applicationCacheInfo.m_size);
- value.set("manifest", applicationCacheInfo.m_manifest.string());
- value.set("lastPathComponent", applicationCacheInfo.m_manifest.lastPathComponent());
- value.set("creationTime", applicationCacheInfo.m_creationTime);
- value.set("updateTime", applicationCacheInfo.m_updateTime);
- value.set("resources", buildArrayForApplicationCacheResources(applicationCacheResources));
+ RefPtr<InspectorObject> value = InspectorObject::create();
+ value->setNumber("size", applicationCacheInfo.m_size);
+ value->setString("manifest", applicationCacheInfo.m_manifest.string());
+ value->setString("lastPathComponent", applicationCacheInfo.m_manifest.lastPathComponent());
+ value->setNumber("creationTime", applicationCacheInfo.m_creationTime);
+ value->setNumber("updateTime", applicationCacheInfo.m_updateTime);
+ value->set("resources", buildArrayForApplicationCacheResources(applicationCacheResources));
return value;
}
-ScriptArray InspectorApplicationCacheAgent::buildArrayForApplicationCacheResources(const ApplicationCacheHost::ResourceInfoList& applicationCacheResources)
+PassRefPtr<InspectorArray> InspectorApplicationCacheAgent::buildArrayForApplicationCacheResources(const ApplicationCacheHost::ResourceInfoList& applicationCacheResources)
{
- ScriptArray resources = m_frontend->newScriptArray();
+ RefPtr<InspectorArray> resources = InspectorArray::create();
ApplicationCacheHost::ResourceInfoList::const_iterator end = applicationCacheResources.end();
ApplicationCacheHost::ResourceInfoList::const_iterator it = applicationCacheResources.begin();
for (int i = 0; it != end; ++it, i++)
- resources.set(i, buildObjectForApplicationCacheResource(*it));
+ resources->push(buildObjectForApplicationCacheResource(*it));
return resources;
}
-ScriptObject InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource(const ApplicationCacheHost::ResourceInfo& resourceInfo)
+PassRefPtr<InspectorObject> InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource(const ApplicationCacheHost::ResourceInfo& resourceInfo)
{
- ScriptObject value = m_frontend->newScriptObject();
- value.set("name", resourceInfo.m_resource.string());
- value.set("size", resourceInfo.m_size);
+ RefPtr<InspectorObject> value = InspectorObject::create();
+ value->setString("name", resourceInfo.m_resource.string());
+ value->setNumber("size", resourceInfo.m_size);
String types;
if (resourceInfo.m_isMaster)
@@ -125,7 +120,7 @@ ScriptObject InspectorApplicationCacheAgent::buildObjectForApplicationCacheResou
if (resourceInfo.m_isExplicit)
types.append("Explicit ");
- value.set("type", types);
+ value->setString("type", types);
return value;
}
diff --git a/WebCore/inspector/InspectorApplicationCacheAgent.h b/WebCore/inspector/InspectorApplicationCacheAgent.h
index 33cc2ed..3338f84 100644
--- a/WebCore/inspector/InspectorApplicationCacheAgent.h
+++ b/WebCore/inspector/InspectorApplicationCacheAgent.h
@@ -29,18 +29,20 @@
#include "ApplicationCacheHost.h"
#include <wtf/Noncopyable.h>
+#include <wtf/PassRefPtr.h>
namespace WebCore {
+class InspectorArray;
class InspectorController;
-class InspectorFrontend;
+class InspectorObject;
+class InspectorValue;
+class RemoteInspectorFrontend;
class ResourceResponse;
-class ScriptArray;
-class ScriptObject;
class InspectorApplicationCacheAgent : public Noncopyable {
public:
- InspectorApplicationCacheAgent(InspectorController* inspectorController, InspectorFrontend* frontend);
+ InspectorApplicationCacheAgent(InspectorController* inspectorController, RemoteInspectorFrontend* frontend);
~InspectorApplicationCacheAgent() { }
// Backend to Frontend
@@ -49,15 +51,15 @@ public:
void updateNetworkState(bool isNowOnline);
// From Frontend
- void getApplicationCaches(long callId);
+ void getApplicationCaches(RefPtr<InspectorValue>* applicationCaches);
private:
- ScriptObject buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList&, const ApplicationCacheHost::CacheInfo&);
- ScriptArray buildArrayForApplicationCacheResources(const ApplicationCacheHost::ResourceInfoList&);
- ScriptObject buildObjectForApplicationCacheResource(const ApplicationCacheHost::ResourceInfo&);
+ PassRefPtr<InspectorObject> buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList&, const ApplicationCacheHost::CacheInfo&);
+ PassRefPtr<InspectorArray> buildArrayForApplicationCacheResources(const ApplicationCacheHost::ResourceInfoList&);
+ PassRefPtr<InspectorObject> buildObjectForApplicationCacheResource(const ApplicationCacheHost::ResourceInfo&);
InspectorController* m_inspectorController;
- InspectorFrontend* m_frontend;
+ RemoteInspectorFrontend* m_frontend;
};
} // namespace WebCore
diff --git a/WebCore/inspector/InspectorBackend.cpp b/WebCore/inspector/InspectorBackend.cpp
index f27b812..0a18e1c 100644
--- a/WebCore/inspector/InspectorBackend.cpp
+++ b/WebCore/inspector/InspectorBackend.cpp
@@ -36,41 +36,16 @@
#include "Database.h"
#endif
-#include "Element.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "HTMLFrameOwnerElement.h"
#include "InjectedScript.h"
#include "InjectedScriptHost.h"
-#include "InspectorClient.h"
#include "InspectorController.h"
#include "InspectorDOMAgent.h"
-#include "InspectorFrontend.h"
-#include "InspectorResource.h"
-#include "Page.h"
-#include "Pasteboard.h"
+#include "InspectorStorageAgent.h"
#include "RemoteInspectorFrontend.h"
-#include "ScriptArray.h"
#include "ScriptBreakpoint.h"
+#include "ScriptProfiler.h"
#include "SerializedScriptValue.h"
-#if ENABLE(DOM_STORAGE)
-#include "Storage.h"
-#endif
-
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-#include "ScriptDebugServer.h"
-#endif
-
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
-#include "InspectorApplicationCacheAgent.h"
-#endif
-
-#include "markup.h"
-
-#include <wtf/RefPtr.h>
-#include <wtf/StdLibExtras.h>
-
using namespace std;
namespace WebCore {
@@ -84,83 +59,6 @@ InspectorBackend::~InspectorBackend()
{
}
-void InspectorBackend::saveApplicationSettings(const String& settings)
-{
- if (m_inspectorController)
- m_inspectorController->saveApplicationSettings(settings);
-}
-
-void InspectorBackend::saveSessionSettings(const String& settings)
-{
- if (m_inspectorController)
- m_inspectorController->saveSessionSettings(settings);
-}
-
-void InspectorBackend::storeLastActivePanel(const String& panelName)
-{
- if (m_inspectorController)
- m_inspectorController->storeLastActivePanel(panelName);
-}
-
-void InspectorBackend::enableSearchingForNode()
-{
- if (m_inspectorController)
- m_inspectorController->enableSearchingForNode();
-}
-
-void InspectorBackend::disableSearchingForNode()
-{
- if (m_inspectorController)
- m_inspectorController->disableSearchingForNode();
-}
-
-void InspectorBackend::enableMonitoringXHR()
-{
- if (m_inspectorController)
- m_inspectorController->enableMonitoringXHR();
-}
-
-void InspectorBackend::disableMonitoringXHR()
-{
- if (m_inspectorController)
- m_inspectorController->disableMonitoringXHR();
-}
-
-void InspectorBackend::enableResourceTracking(bool always)
-{
- if (m_inspectorController)
- m_inspectorController->enableResourceTracking(always);
-}
-
-void InspectorBackend::disableResourceTracking(bool always)
-{
- if (m_inspectorController)
- m_inspectorController->disableResourceTracking(always);
-}
-
-void InspectorBackend::getResourceContent(long callId, unsigned long identifier)
-{
- if (m_inspectorController)
- m_inspectorController->getResourceContent(callId, identifier);
-}
-
-void InspectorBackend::reloadPage()
-{
- if (m_inspectorController)
- m_inspectorController->reloadPage();
-}
-
-void InspectorBackend::startTimelineProfiler()
-{
- if (m_inspectorController)
- m_inspectorController->startTimelineProfiler();
-}
-
-void InspectorBackend::stopTimelineProfiler()
-{
- if (m_inspectorController)
- m_inspectorController->stopTimelineProfiler();
-}
#if ENABLE(JAVASCRIPT_DEBUGGER)
@@ -170,143 +68,27 @@ void InspectorBackend::enableDebugger(bool always)
m_inspectorController->enableDebuggerFromFrontend(always);
}
-void InspectorBackend::disableDebugger(bool always)
-{
- if (m_inspectorController)
- m_inspectorController->disableDebugger(always);
-}
-
-void InspectorBackend::setBreakpoint(long callId, const String& sourceID, unsigned lineNumber, bool enabled, const String& condition)
-{
- if (m_inspectorController)
- m_inspectorController->setBreakpoint(callId, sourceID, lineNumber, enabled, condition);
-}
-
-void InspectorBackend::removeBreakpoint(const String& sourceID, unsigned lineNumber)
-{
- if (m_inspectorController)
- m_inspectorController->removeBreakpoint(sourceID, lineNumber);
-}
-
-void InspectorBackend::activateBreakpoints()
-{
- ScriptDebugServer::shared().activateBreakpoints();
-}
-
-void InspectorBackend::deactivateBreakpoints()
-{
- ScriptDebugServer::shared().deactivateBreakpoints();
-}
-
-void InspectorBackend::pause()
-{
- ScriptDebugServer::shared().pause();
-}
-
-void InspectorBackend::resume()
-{
- if (m_inspectorController)
- m_inspectorController->resume();
-}
-
-void InspectorBackend::stepOverStatement()
-{
- ScriptDebugServer::shared().stepOverStatement();
-}
-
-void InspectorBackend::stepIntoStatement()
-{
- ScriptDebugServer::shared().stepIntoStatement();
-}
-
-void InspectorBackend::stepOutOfFunction()
-{
- ScriptDebugServer::shared().stepOutOfFunction();
-}
-
-void InspectorBackend::setPauseOnExceptionsState(long pauseState)
-{
- if (m_inspectorController)
- m_inspectorController->setPauseOnExceptionsState(pauseState);
-}
-
-void InspectorBackend::editScriptSource(long callId, const String& sourceID, const String& newContent)
-{
- if (m_inspectorController)
- m_inspectorController->editScriptSource(callId, sourceID, newContent);
-}
-
-void InspectorBackend::getScriptSource(long callId, const String& sourceID)
-{
- if (m_inspectorController)
- m_inspectorController->getScriptSource(callId, sourceID);
-}
-
-void InspectorBackend::enableProfiler(bool always)
-{
- if (m_inspectorController)
- m_inspectorController->enableProfiler(always);
-}
-
-void InspectorBackend::disableProfiler(bool always)
-{
- if (m_inspectorController)
- m_inspectorController->disableProfiler(always);
-}
-
-void InspectorBackend::startProfiling()
-{
- if (m_inspectorController)
- m_inspectorController->startUserInitiatedProfiling();
-}
-
-void InspectorBackend::stopProfiling()
-{
- if (m_inspectorController)
- m_inspectorController->stopUserInitiatedProfiling();
-}
-
-void InspectorBackend::getProfileHeaders(long callId)
-{
- if (m_inspectorController)
- m_inspectorController->getProfileHeaders(callId);
-}
-
-void InspectorBackend::getProfile(long callId, unsigned uid)
-{
- if (m_inspectorController)
- m_inspectorController->getProfile(callId, uid);
-}
-
-void InspectorBackend::removeProfile(unsigned uid)
-{
- if (m_inspectorController)
- m_inspectorController->removeProfile(uid);
-}
-
-void InspectorBackend::clearProfiles()
+void InspectorBackend::takeHeapSnapshot()
{
- if (m_inspectorController)
- m_inspectorController->clearProfiles();
+ ScriptProfiler::takeHeapSnapshot();
}
-void InspectorBackend::takeHeapSnapshot()
+void InspectorBackend::getProfilerLogLines(long position, long* outPosition, String* data)
{
- if (m_inspectorController)
- m_inspectorController->takeHeapSnapshot();
+ // FIXME: we should make inspector dispatcher pluggable, so that embedders could contribute APIs instead of polluting the core one
+ // https://bugs.webkit.org/show_bug.cgi?id=43357
+ *outPosition = ScriptProfiler::getProfilerLogLines(position, data);
}
#endif
void InspectorBackend::setInjectedScriptSource(const String& source)
{
- if (m_inspectorController)
- m_inspectorController->injectedScriptHost()->setInjectedScriptSource(source);
+ m_inspectorController->injectedScriptHost()->setInjectedScriptSource(source);
}
-void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async)
+void InspectorBackend::dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException)
{
- InspectorFrontend* frontend = inspectorFrontend();
- if (!frontend)
+ if (!remoteFrontend())
return;
// FIXME: explicitly pass injectedScriptId along with node id to the frontend.
@@ -321,305 +103,50 @@ void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScript
if (injectedScript.hasNoValue())
return;
- RefPtr<SerializedScriptValue> result;
- bool hadException = false;
- injectedScript.dispatch(callId, methodName, arguments, async, &result, &hadException);
- if (async)
- return; // InjectedScript will return result asynchronously by means of ::reportDidDispatchOnInjectedScript.
- frontend->didDispatchOnInjectedScript(callId, result.get(), hadException);
-}
-
-void InspectorBackend::getChildNodes(long callId, long nodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->getChildNodes(callId, nodeId);
-}
-
-void InspectorBackend::setAttribute(long callId, long elementId, const String& name, const String& value)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->setAttribute(callId, elementId, name, value);
-}
-
-void InspectorBackend::removeAttribute(long callId, long elementId, const String& name)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->removeAttribute(callId, elementId, name);
-}
-
-void InspectorBackend::setTextNodeValue(long callId, long nodeId, const String& value)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->setTextNodeValue(callId, nodeId, value);
-}
-
-void InspectorBackend::getEventListenersForNode(long callId, long nodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->getEventListenersForNode(callId, nodeId);
-}
-
-void InspectorBackend::copyNode(long nodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->copyNode(nodeId);
-}
-
-void InspectorBackend::removeNode(long callId, long nodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->removeNode(callId, nodeId);
-}
-
-void InspectorBackend::changeTagName(long callId, long nodeId, const String& tagName)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->changeTagName(callId, nodeId, tagName);
-}
-
-void InspectorBackend::getOuterHTML(long callId, long nodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->getOuterHTML(callId, nodeId);
-}
-
-void InspectorBackend::setOuterHTML(long callId, long nodeId, const String& outerHTML)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->setOuterHTML(callId, nodeId, outerHTML);
-}
-
-void InspectorBackend::addInspectedNode(long nodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->addInspectedNode(nodeId);
-}
-
-void InspectorBackend::performSearch(const String& query, bool runSynchronously)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->performSearch(query, runSynchronously);
-}
-
-void InspectorBackend::searchCanceled()
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->searchCanceled();
-}
-
-void InspectorBackend::pushNodeByPathToFrontend(long callId, const String& path)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->pushNodeByPathToFrontend(callId, path);
-}
-
-void InspectorBackend::clearConsoleMessages(long callId)
-{
- if (m_inspectorController) {
- m_inspectorController->clearConsoleMessages();
- if (RemoteInspectorFrontend* frontend = remoteFrontend())
- frontend->didClearConsoleMessages(callId);
- }
-}
-
-void InspectorBackend::getStyles(long callId, long nodeId, bool authorOnly)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->getStyles(callId, nodeId, authorOnly);
-}
-
-void InspectorBackend::getAllStyles(long callId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->getAllStyles(callId);
-}
-
-void InspectorBackend::getInlineStyle(long callId, long nodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->getInlineStyle(callId, nodeId);
-}
-
-void InspectorBackend::getComputedStyle(long callId, long nodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->getComputedStyle(callId, nodeId);
-}
-
-void InspectorBackend::getStyleSheet(long callId, long styleSheetId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->getStyleSheet(callId, styleSheetId);
-}
-
-void InspectorBackend::getRuleRanges(long callId, long styleSheetId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->getRuleRanges(callId, styleSheetId);
-}
-
-void InspectorBackend::applyStyleText(long callId, long styleId, const String& styleText, const String& propertyName)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->applyStyleText(callId, styleId, styleText, propertyName);
-}
-
-void InspectorBackend::setStyleText(long callId, long styleId, const String& cssText)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->setStyleText(callId, styleId, cssText);
-}
-
-void InspectorBackend::setStyleProperty(long callId, long styleId, const String& name, const String& value)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->setStyleProperty(callId, styleId, name, value);
-}
-
-void InspectorBackend::toggleStyleEnabled(long callId, long styleId, const String& propertyName, bool disabled)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->toggleStyleEnabled(callId, styleId, propertyName, disabled);
-}
-
-void InspectorBackend::setRuleSelector(long callId, long ruleId, const String& selector, long selectedNodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->setRuleSelector(callId, ruleId, selector, selectedNodeId);
-}
-
-void InspectorBackend::addRule(long callId, const String& selector, long selectedNodeId)
-{
- if (InspectorDOMAgent* domAgent = inspectorDOMAgent())
- domAgent->addRule(callId, selector, selectedNodeId);
-}
-
-void InspectorBackend::highlightDOMNode(long nodeId)
-{
- if (m_inspectorController)
- m_inspectorController->highlightDOMNode(nodeId);
+ injectedScript.dispatch(methodName, arguments, result, hadException);
}
-void InspectorBackend::hideDOMNodeHighlight()
+void InspectorBackend::clearConsoleMessages()
{
- if (m_inspectorController)
- m_inspectorController->hideDOMNodeHighlight();
-}
-
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
-void InspectorBackend::getApplicationCaches(long callId)
-{
- if (InspectorApplicationCacheAgent* agent = inspectorApplicationCacheAgent())
- agent->getApplicationCaches(callId);
-}
-#endif
-
-void InspectorBackend::getCookies(long callId)
-{
- if (!m_inspectorController)
- return;
- m_inspectorController->getCookies(callId);
-}
-
-void InspectorBackend::deleteCookie(const String& cookieName, const String& domain)
-{
- if (!m_inspectorController)
- return;
- m_inspectorController->deleteCookie(cookieName, domain);
+ m_inspectorController->clearConsoleMessages();
}
void InspectorBackend::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup)
{
- if (!m_inspectorController)
- return;
m_inspectorController->injectedScriptHost()->releaseWrapperObjectGroup(injectedScriptId, objectGroup);
}
-void InspectorBackend::didEvaluateForTestInFrontend(long callId, const String& jsonResult)
-{
- if (m_inspectorController)
- m_inspectorController->didEvaluateForTestInFrontend(callId, jsonResult);
-}
-
#if ENABLE(DATABASE)
-void InspectorBackend::getDatabaseTableNames(long callId, long databaseId)
-{
- if (InspectorFrontend* frontend = inspectorFrontend()) {
- ScriptArray result = frontend->newScriptArray();
- Database* database = m_inspectorController->databaseForId(databaseId);
- if (database) {
- Vector<String> tableNames = database->tableNames();
- unsigned length = tableNames.size();
- for (unsigned i = 0; i < length; ++i)
- result.set(i, tableNames[i]);
- }
- frontend->didGetDatabaseTableNames(callId, result);
+void InspectorBackend::getDatabaseTableNames(long databaseId, RefPtr<InspectorArray>* names)
+{
+ Database* database = m_inspectorController->databaseForId(databaseId);
+ if (database) {
+ Vector<String> tableNames = database->tableNames();
+ unsigned length = tableNames.size();
+ for (unsigned i = 0; i < length; ++i)
+ (*names)->pushString(tableNames[i]);
}
}
-#endif
-#if ENABLE(DOM_STORAGE)
-void InspectorBackend::getDOMStorageEntries(long callId, long storageId)
+void InspectorBackend::executeSQL(long databaseId, const String& query, bool* success, long* transactionId)
{
- if (m_inspectorController)
- m_inspectorController->getDOMStorageEntries(callId, storageId);
-}
-
-void InspectorBackend::setDOMStorageItem(long callId, long storageId, const String& key, const String& value)
-{
- if (m_inspectorController)
- m_inspectorController->setDOMStorageItem(callId, storageId, key, value);
-}
-
-void InspectorBackend::removeDOMStorageItem(long callId, long storageId, const String& key)
-{
- if (m_inspectorController)
- m_inspectorController->removeDOMStorageItem(callId, storageId, key);
-}
-#endif
+ Database* database = m_inspectorController->databaseForId(databaseId);
+ if (!m_inspectorController->m_storageAgent || !database) {
+ *success = false;
+ return;
+ }
-InspectorDOMAgent* InspectorBackend::inspectorDOMAgent()
-{
- if (!m_inspectorController)
- return 0;
- return m_inspectorController->domAgent();
+ *transactionId = m_inspectorController->m_storageAgent->executeSQL(database, query);
+ *success = true;
}
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
-InspectorApplicationCacheAgent* InspectorBackend::inspectorApplicationCacheAgent()
-{
- if (!m_inspectorController)
- return 0;
- return m_inspectorController->applicationCacheAgent();
-}
#endif
-InspectorFrontend* InspectorBackend::inspectorFrontend()
-{
- if (!m_inspectorController)
- return 0;
- return m_inspectorController->m_frontend.get();
-}
-
RemoteInspectorFrontend* InspectorBackend::remoteFrontend()
{
- if (!m_inspectorController)
- return 0;
return m_inspectorController->m_remoteFrontend.get();
}
-void InspectorBackend::addScriptToEvaluateOnLoad(const String& source)
-{
- if (m_inspectorController)
- m_inspectorController->addScriptToEvaluateOnLoad(source);
-}
-
-void InspectorBackend::removeAllScriptsToEvaluateOnLoad()
-{
- if (m_inspectorController)
- m_inspectorController->removeAllScriptsToEvaluateOnLoad();
-}
-
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InspectorBackend.h b/WebCore/inspector/InspectorBackend.h
index 16d53c0..63c4a09 100644
--- a/WebCore/inspector/InspectorBackend.h
+++ b/WebCore/inspector/InspectorBackend.h
@@ -37,14 +37,10 @@
namespace WebCore {
-class CachedResource;
-class Database;
class InspectorApplicationCacheAgent;
class InspectorDOMAgent;
class InspectorFrontend;
-class Node;
class RemoteInspectorFrontend;
-class Storage;
class InspectorBackend : public RefCounted<InspectorBackend>
{
@@ -57,131 +53,33 @@ public:
~InspectorBackend();
InspectorController* inspectorController() { return m_inspectorController; }
+ InspectorDOMAgent* inspectorDOMAgent() { return m_inspectorController->domAgent(); }
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ InspectorApplicationCacheAgent* inspectorApplicationCacheAgent() { return m_inspectorController->applicationCacheAgent(); }
+#endif
void disconnectController() { m_inspectorController = 0; }
- void saveApplicationSettings(const String&);
- void saveSessionSettings(const String&);
-
- void storeLastActivePanel(const String& panelName);
-
- void enableSearchingForNode();
- void disableSearchingForNode();
-
- void enableMonitoringXHR();
- void disableMonitoringXHR();
-
- void enableResourceTracking(bool always);
- void disableResourceTracking(bool always);
- void getResourceContent(long callId, unsigned long identifier);
- void reloadPage();
-
- void startTimelineProfiler();
- void stopTimelineProfiler();
-
#if ENABLE(JAVASCRIPT_DEBUGGER)
void enableDebugger(bool always);
- void disableDebugger(bool always);
-
- void setBreakpoint(long callId, const String& sourceID, unsigned lineNumber, bool enabled, const String& condition);
- void removeBreakpoint(const String& sourceID, unsigned lineNumber);
- void activateBreakpoints();
- void deactivateBreakpoints();
-
- void pause();
- void resume();
-
- void stepOverStatement();
- void stepIntoStatement();
- void stepOutOfFunction();
-
- void setPauseOnExceptionsState(long pauseState);
-
- void editScriptSource(long callId, const String& sourceID, const String& newContent);
- void getScriptSource(long callId, const String& sourceID);
-
- void enableProfiler(bool always);
- void disableProfiler(bool always);
-
- void startProfiling();
- void stopProfiling();
-
- void getProfileHeaders(long callId);
- void getProfile(long callId, unsigned uid);
-
- void removeProfile(unsigned uid);
- void clearProfiles();
-
void takeHeapSnapshot();
+ void getProfilerLogLines(long position, long* outPosition, String* data);
#endif
void setInjectedScriptSource(const String& source);
- void dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async);
- void addScriptToEvaluateOnLoad(const String& source);
- void removeAllScriptsToEvaluateOnLoad();
-
- void getChildNodes(long callId, long nodeId);
- void setAttribute(long callId, long elementId, const String& name, const String& value);
- void removeAttribute(long callId, long elementId, const String& name);
- void setTextNodeValue(long callId, long nodeId, const String& value);
- void getEventListenersForNode(long callId, long nodeId);
- void copyNode(long nodeId);
- void removeNode(long callId, long nodeId);
- void changeTagName(long callId, long nodeId, const String& tagName);
- void getOuterHTML(long callId, long nodeId);
- void setOuterHTML(long callId, long nodeId, const String& outerHTML);
- void addInspectedNode(long nodeId);
- void performSearch(const String& query, bool runSynchronously);
- void searchCanceled();
- void pushNodeByPathToFrontend(long callId, const String& path);
-
- void clearConsoleMessages(long callId);
-
- void getStyles(long callId, long nodeId, bool authOnly);
- void getAllStyles(long callId);
- void getInlineStyle(long callId, long nodeId);
- void getComputedStyle(long callId, long nodeId);
- void getStyleSheet(long callId, long styleSheetId);
- void getRuleRanges(long callId, long styleSheetId);
- void applyStyleText(long callId, long styleId, const String& styleText, const String& propertyName);
- void setStyleText(long callId, long styleId, const String& cssText);
- void setStyleProperty(long callId, long styleId, const String& name, const String& value);
- void toggleStyleEnabled(long callId, long styleId, const String& propertyName, bool disabled);
- void setRuleSelector(long callId, long ruleId, const String& selector, long selectedNodeId);
- void addRule(long callId, const String& selector, long selectedNodeId);
-
- void highlightDOMNode(long nodeId);
- void hideDOMNodeHighlight();
-
- void getCookies(long callId);
- void deleteCookie(const String& cookieName, const String& domain);
-
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- void getApplicationCaches(long callId);
-#endif
+ void dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException);
+ void clearConsoleMessages();
// Generic code called from custom implementations.
void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup);
- void didEvaluateForTestInFrontend(long callId, const String& jsonResult);
#if ENABLE(DATABASE)
- void getDatabaseTableNames(long callId, long databaseId);
-#endif
-
-#if ENABLE(DOM_STORAGE)
- void getDOMStorageEntries(long callId, long storageId);
- void setDOMStorageItem(long callId, long storageId, const String& key, const String& value);
- void removeDOMStorageItem(long callId, long storageId, const String& key);
+ void getDatabaseTableNames(long databaseId, RefPtr<InspectorArray>* names);
+ void executeSQL(long databaseId, const String& query, bool* success, long* transactionId);
#endif
private:
InspectorBackend(InspectorController* inspectorController);
- InspectorDOMAgent* inspectorDOMAgent();
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- InspectorApplicationCacheAgent* inspectorApplicationCacheAgent();
-#endif
- InspectorFrontend* inspectorFrontend();
RemoteInspectorFrontend* remoteFrontend();
- Node* nodeForId(long nodeId);
InspectorController* m_inspectorController;
};
diff --git a/WebCore/inspector/InspectorCSSStore.cpp b/WebCore/inspector/InspectorCSSStore.cpp
index d098230..16d2508 100644
--- a/WebCore/inspector/InspectorCSSStore.cpp
+++ b/WebCore/inspector/InspectorCSSStore.cpp
@@ -81,7 +81,7 @@ void InspectorCSSStore::removeDocument(Document* doc)
m_documentNodeToInspectorStyleSheetMap.remove(doc);
}
-CSSStyleSheet* InspectorCSSStore::inspectorStyleSheet(Document* ownerDocument, bool createIfAbsent, long callId)
+CSSStyleSheet* InspectorCSSStore::inspectorStyleSheet(Document* ownerDocument, bool createIfAbsent)
{
DocumentToStyleSheetMap::iterator it = m_documentNodeToInspectorStyleSheetMap.find(ownerDocument);
if (it != m_documentNodeToInspectorStyleSheetMap.end())
@@ -94,16 +94,12 @@ CSSStyleSheet* InspectorCSSStore::inspectorStyleSheet(Document* ownerDocument, b
styleElement->setAttribute("type", "text/css", ec);
if (!ec)
ownerDocument->head()->appendChild(styleElement, ec);
- if (ec) {
- m_inspectorController->remoteInspectorFrontend()->didAddRule(callId, InspectorValue::null(), false);
+ if (ec)
return 0;
- }
StyleSheetList* styleSheets = ownerDocument->styleSheets();
StyleSheet* styleSheet = styleSheets->item(styleSheets->length() - 1);
- if (!styleSheet->isCSSStyleSheet()) {
- m_inspectorController->remoteInspectorFrontend()->didAddRule(callId, InspectorValue::null(), false);
+ if (!styleSheet->isCSSStyleSheet())
return 0;
- }
CSSStyleSheet* inspectorStyleSheet = static_cast<CSSStyleSheet*>(styleSheet);
m_documentNodeToInspectorStyleSheetMap.set(ownerDocument, inspectorStyleSheet);
return inspectorStyleSheet;
diff --git a/WebCore/inspector/InspectorCSSStore.h b/WebCore/inspector/InspectorCSSStore.h
index 4f7df00..2a05d71 100644
--- a/WebCore/inspector/InspectorCSSStore.h
+++ b/WebCore/inspector/InspectorCSSStore.h
@@ -30,7 +30,7 @@
#define InspectorCSSStore_h
#include "StringHash.h"
-
+#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>
@@ -44,7 +44,6 @@ class CSSStyleDeclaration;
class CSSRuleList;
class CSSStyleRule;
class CSSStyleSheet;
-class String;
class StyleBase;
typedef std::pair<String, String> PropertyValueAndPriority;
@@ -71,7 +70,7 @@ public:
CSSStyleSheet* styleSheetForId(long styleSheetId);
CSSStyleRule* ruleForId(long styleRuleId);
DisabledStyleDeclaration* disabledStyleForId(long styleId, bool createIfAbsent);
- CSSStyleSheet* inspectorStyleSheet(Document* ownerDocument, bool createIfAbsent, long callId);
+ CSSStyleSheet* inspectorStyleSheet(Document* ownerDocument, bool createIfAbsent);
void removeDocument(Document*);
long bindRule(CSSStyleRule* rule);
diff --git a/WebCore/inspector/InspectorClient.h b/WebCore/inspector/InspectorClient.h
index 61900bb..acd8b28 100644
--- a/WebCore/inspector/InspectorClient.h
+++ b/WebCore/inspector/InspectorClient.h
@@ -27,13 +27,13 @@
#define InspectorClient_h
#include "InspectorController.h"
+#include <wtf/Forward.h>
namespace WebCore {
class InspectorController;
class Node;
class Page;
-class String;
class InspectorClient {
public:
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index 369b40b..0b59617 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -61,11 +61,12 @@
#include "InspectorFrontendClient.h"
#include "InspectorDOMStorageResource.h"
#include "InspectorDatabaseResource.h"
-#include "InspectorFrontend.h"
+#include "InspectorDebuggerAgent.h"
#include "InspectorResource.h"
+#include "InspectorStorageAgent.h"
+#include "InspectorTimelineAgent.h"
#include "InspectorValues.h"
#include "InspectorWorkerResource.h"
-#include "InspectorTimelineAgent.h"
#include "Page.h"
#include "ProgressTracker.h"
#include "Range.h"
@@ -73,7 +74,6 @@
#include "RenderInline.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
-#include "ScriptBreakpoint.h"
#include "ScriptCallStack.h"
#include "ScriptFunctionCall.h"
#include "ScriptObject.h"
@@ -89,7 +89,6 @@
#include <wtf/text/CString.h>
#include <wtf/CurrentTime.h>
#include <wtf/ListHashSet.h>
-#include <wtf/MD5.h>
#include <wtf/RefCounted.h>
#include <wtf/StdLibExtras.h>
@@ -108,14 +107,6 @@
#if ENABLE(JAVASCRIPT_DEBUGGER)
#include "ScriptDebugServer.h"
-#if USE(JSC)
-#include <runtime/JSLock.h>
-#include <runtime/UString.h>
-#include "JSScriptProfile.h"
-#else
-#include "ScriptScope.h"
-#include "V8ScriptProfile.h"
-#endif
#endif
using namespace std;
@@ -128,10 +119,15 @@ static const char* const resourceTrackingEnabledSettingName = "resourceTrackingE
static const char* const debuggerEnabledSettingName = "debuggerEnabled";
static const char* const profilerEnabledSettingName = "profilerEnabled";
static const char* const inspectorAttachedHeightName = "inspectorAttachedHeight";
-static const char* const lastActivePanelSettingName = "lastActivePanel";
+static const char* const lastActivePanel = "lastActivePanel";
+const char* const InspectorController::ElementsPanel = "elements";
+const char* const InspectorController::ConsolePanel = "console";
+const char* const InspectorController::ScriptsPanel = "scripts";
+const char* const InspectorController::ProfilesPanel = "profiles";
+
static const char* const monitoringXHRSettingName = "xhrMonitor";
-int connectedFrontendCount = 0;
+static int connectedFrontendCount = 0;
const String& InspectorController::frontendSettingsSettingName()
{
@@ -153,39 +149,13 @@ static const unsigned expireConsoleMessagesStep = 100;
static unsigned s_inspectorControllerCount;
-namespace {
-
-String md5Base16(const String& string)
-{
- static const char digits[] = "0123456789abcdef";
-
- MD5 md5;
- md5.addBytes(reinterpret_cast<const uint8_t*>(string.characters()), string.length() * 2);
- Vector<uint8_t, 16> digest;
- md5.checksum(digest);
-
- Vector<char, 32> result;
- for (int i = 0; i < 16; ++i) {
- result.append(digits[(digest[i] >> 4) & 0xf]);
- result.append(digits[digest[i] & 0xf]);
- }
- return String(result.data(), result.size());
-}
-
-String formatBreakpointId(const String& sourceID, unsigned lineNumber)
-{
- return String::format("%s:%d", sourceID.utf8().data(), lineNumber);
-}
-
-}
-
InspectorController::InspectorController(Page* page, InspectorClient* client)
: m_inspectedPage(page)
, m_client(client)
, m_openingFrontend(false)
, m_cssStore(new InspectorCSSStore(this))
, m_expiredConsoleMessageCount(0)
- , m_showAfterVisible(CurrentPanel)
+ , m_showAfterVisible(lastActivePanel)
, m_sessionSettings(InspectorObject::create())
, m_groupLevel(0)
, m_searchingForNode(false)
@@ -194,13 +164,10 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
, m_resourceTrackingEnabled(false)
, m_settingsLoaded(false)
, m_inspectorBackend(InspectorBackend::create(this))
- , m_inspectorBackendDispatcher(new InspectorBackendDispatcher(m_inspectorBackend.get()))
+ , m_inspectorBackendDispatcher(new InspectorBackendDispatcher(this))
, m_injectedScriptHost(InjectedScriptHost::create(this))
#if ENABLE(JAVASCRIPT_DEBUGGER)
- , m_debuggerEnabled(false)
, m_attachDebuggerWhenShown(false)
- , m_pausedScriptState(0)
- , m_breakpointsLoaded(false)
, m_profilerEnabled(!WTF_USE_JSC)
, m_recordingUserInitiatedProfile(false)
, m_currentUserInitiatedProfileNumber(-1)
@@ -233,11 +200,14 @@ InspectorController::~InspectorController()
void InspectorController::inspectedPageDestroyed()
{
- if (m_frontend)
- m_frontend->inspectedPageDestroyed();
+ if (m_remoteFrontend)
+ m_remoteFrontend->inspectedPageDestroyed();
hideHighlight();
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+ m_debuggerAgent.clear();
+#endif
ASSERT(m_inspectedPage);
m_inspectedPage = 0;
@@ -291,7 +261,7 @@ void InspectorController::inspect(Node* node)
node = node->parentNode();
m_nodeToFocus = node;
- if (!m_frontend) {
+ if (!m_remoteFrontend) {
m_showAfterVisible = ElementsPanel;
return;
}
@@ -304,11 +274,11 @@ void InspectorController::focusNode()
if (!enabled())
return;
- ASSERT(m_frontend);
+ ASSERT(m_remoteFrontend);
ASSERT(m_nodeToFocus);
long id = m_domAgent->pushNodePathToFrontend(m_nodeToFocus.get());
- m_frontend->updateFocusedNode(id);
+ m_remoteFrontend->updateFocusedNode(id);
m_nodeToFocus = 0;
}
@@ -338,7 +308,7 @@ void InspectorController::hideHighlight()
bool InspectorController::windowVisible()
{
- return m_frontend;
+ return m_remoteFrontend;
}
void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack, const String& message)
@@ -365,16 +335,16 @@ void InspectorController::addConsoleMessage(ScriptState* scriptState, PassOwnPtr
if (m_previousMessage && m_previousMessage->isEqual(scriptState, consoleMessage.get())) {
m_previousMessage->incrementCount();
- if (m_frontend)
+ if (m_remoteFrontend)
m_previousMessage->updateRepeatCountInConsole(m_remoteFrontend.get());
} else {
m_previousMessage = consoleMessage.get();
m_consoleMessages.append(consoleMessage);
- if (m_frontend)
+ if (m_remoteFrontend)
m_previousMessage->addToFrontend(m_remoteFrontend.get(), m_injectedScriptHost.get());
}
- if (!m_frontend && m_consoleMessages.size() >= maximumConsoleMessages) {
+ if (!m_remoteFrontend && m_consoleMessages.size() >= maximumConsoleMessages) {
m_expiredConsoleMessageCount += expireConsoleMessagesStep;
m_consoleMessages.remove(0, expireConsoleMessagesStep);
}
@@ -416,7 +386,7 @@ void InspectorController::markTimeline(const String& message)
void InspectorController::storeLastActivePanel(const String& panelName)
{
- setSetting(lastActivePanelSettingName, panelName);
+ setSetting(lastActivePanel, panelName);
}
void InspectorController::mouseDidMoveOverElement(const HitTestResult& result, unsigned)
@@ -458,18 +428,19 @@ void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame)
if (m_inspectorFrontendClient && frame == m_inspectedPage->mainFrame())
m_inspectorFrontendClient->windowObjectCleared();
- if (!enabled())
- return;
-
- if (m_frontend && frame != m_inspectedPage->mainFrame())
- m_injectedScriptHost->discardInjectedScripts();
- if (m_scriptsToEvaluateOnLoad.size()) {
- ScriptState* scriptState = mainWorldScriptState(frame);
- for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin();
- it != m_scriptsToEvaluateOnLoad.end(); ++it) {
- m_injectedScriptHost->injectScript(*it, scriptState);
+ if (enabled()) {
+ if (m_remoteFrontend && frame == m_inspectedPage->mainFrame())
+ m_injectedScriptHost->discardInjectedScripts();
+ if (m_scriptsToEvaluateOnLoad.size()) {
+ ScriptState* scriptState = mainWorldScriptState(frame);
+ for (Vector<String>::iterator it = m_scriptsToEvaluateOnLoad.begin();
+ it != m_scriptsToEvaluateOnLoad.end(); ++it) {
+ m_injectedScriptHost->injectScript(*it, scriptState);
+ }
}
}
+ if (!m_inspectorExtensionAPI.isEmpty())
+ m_injectedScriptHost->injectScript(m_inspectorExtensionAPI, mainWorldScriptState(frame));
}
void InspectorController::setSearchingForNode(bool enabled)
@@ -479,11 +450,11 @@ void InspectorController::setSearchingForNode(bool enabled)
m_searchingForNode = enabled;
if (!m_searchingForNode)
hideHighlight();
- if (m_frontend) {
+ if (m_remoteFrontend) {
if (enabled)
- m_frontend->searchingForNodeWasEnabled();
+ m_remoteFrontend->searchingForNodeWasEnabled();
else
- m_frontend->searchingForNodeWasDisabled();
+ m_remoteFrontend->searchingForNodeWasDisabled();
}
}
@@ -493,31 +464,35 @@ void InspectorController::setMonitoringXHR(bool enabled)
return;
m_monitoringXHR = enabled;
setSetting(monitoringXHRSettingName, enabled ? "true" : "false");
- if (m_frontend) {
+ if (m_remoteFrontend) {
if (enabled)
- m_frontend->monitoringXHRWasEnabled();
+ m_remoteFrontend->monitoringXHRWasEnabled();
else
- m_frontend->monitoringXHRWasDisabled();
+ m_remoteFrontend->monitoringXHRWasDisabled();
}
}
-void InspectorController::connectFrontend(const ScriptObject& webInspector)
+void InspectorController::connectFrontend()
{
m_openingFrontend = false;
releaseFrontendLifetimeAgents();
- m_frontend = new InspectorFrontend(webInspector, m_client);
m_remoteFrontend = new RemoteInspectorFrontend(m_client);
m_domAgent = InspectorDOMAgent::create(m_cssStore.get(), m_remoteFrontend.get());
+
+#if ENABLE(DATABASE)
+ m_storageAgent = InspectorStorageAgent::create(m_remoteFrontend.get());
+#endif
+
if (m_timelineAgent)
m_timelineAgent->resetFrontendProxyObject(m_remoteFrontend.get());
// Initialize Web Inspector title.
- m_frontend->inspectedURLChanged(m_inspectedPage->mainFrame()->loader()->url().string());
+ m_remoteFrontend->inspectedURLChanged(m_inspectedPage->mainFrame()->loader()->url().string());
populateScriptObjects();
#if ENABLE(JAVASCRIPT_DEBUGGER)
- if (ScriptDebugServer::shared().isDebuggerAlwaysEnabled()) {
+ if (InspectorDebuggerAgent::isDebuggerAlwaysEnabled()) {
// FIXME (40364): This will force pushing script sources to frontend even if script
// panel is inactive.
enableDebuggerFromFrontend(false);
@@ -531,17 +506,15 @@ void InspectorController::connectFrontend(const ScriptObject& webInspector)
}
#endif
- if (m_showAfterVisible == CurrentPanel) {
- String lastActivePanelSetting = setting(lastActivePanelSettingName);
- m_showAfterVisible = specialPanelForJSName(lastActivePanelSetting);
- }
+ if (m_showAfterVisible == lastActivePanel)
+ m_showAfterVisible = setting(lastActivePanel);
if (m_nodeToFocus)
focusNode();
showPanel(m_showAfterVisible);
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- m_applicationCacheAgent = new InspectorApplicationCacheAgent(this, m_frontend.get());
+ m_applicationCacheAgent = new InspectorApplicationCacheAgent(this, m_remoteFrontend.get());
#endif
if (!connectedFrontendCount)
@@ -557,44 +530,44 @@ void InspectorController::show()
if (m_openingFrontend)
return;
- if (m_frontend)
- m_frontend->bringToFront();
+ if (m_remoteFrontend)
+ m_remoteFrontend->bringToFront();
else {
m_openingFrontend = true;
m_client->openInspectorFrontend(this);
}
}
-void InspectorController::showPanel(SpecialPanels panel)
+void InspectorController::showPanel(const String& panel)
{
if (!enabled())
return;
show();
- if (!m_frontend) {
+ if (!m_remoteFrontend) {
m_showAfterVisible = panel;
return;
}
- if (panel == CurrentPanel)
+ if (panel == lastActivePanel)
return;
- m_frontend->showPanel(panel);
+ m_remoteFrontend->showPanel(panel);
}
void InspectorController::close()
{
- if (!m_frontend)
+ if (!m_remoteFrontend)
return;
- m_frontend->close();
+ m_remoteFrontend->close();
}
void InspectorController::disconnectFrontend()
{
- if (!m_frontend)
+ if (!m_remoteFrontend)
return;
- m_frontend.clear();
+ m_remoteFrontend.clear();
connectedFrontendCount--;
if (!connectedFrontendCount)
@@ -604,7 +577,7 @@ void InspectorController::disconnectFrontend()
// If the window is being closed with the debugger enabled,
// remember this state to re-enable debugger on the next window
// opening.
- bool debuggerWasEnabled = m_debuggerEnabled;
+ bool debuggerWasEnabled = debuggerEnabled();
disableDebugger();
m_attachDebuggerWhenShown = debuggerWasEnabled;
#endif
@@ -612,7 +585,7 @@ void InspectorController::disconnectFrontend()
unbindAllResources();
stopTimelineProfiler();
- m_showAfterVisible = CurrentPanel;
+ m_showAfterVisible = lastActivePanel;
hideHighlight();
@@ -631,6 +604,9 @@ void InspectorController::releaseFrontendLifetimeAgents()
if (m_domAgent)
m_domAgent->reset();
m_domAgent.clear();
+ if (m_storageAgent)
+ m_storageAgent->clearFrontend();
+ m_storageAgent.clear();
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
m_applicationCacheAgent.clear();
@@ -639,29 +615,29 @@ void InspectorController::releaseFrontendLifetimeAgents()
void InspectorController::populateScriptObjects()
{
- ASSERT(m_frontend);
- if (!m_frontend)
+ ASSERT(m_remoteFrontend);
+ if (!m_remoteFrontend)
return;
- m_frontend->populateApplicationSettings(setting(frontendSettingsSettingName()));
+ m_remoteFrontend->populateApplicationSettings(setting(frontendSettingsSettingName()));
if (m_resourceTrackingEnabled)
- m_frontend->resourceTrackingWasEnabled();
+ m_remoteFrontend->resourceTrackingWasEnabled();
if (m_searchingForNode)
- m_frontend->searchingForNodeWasEnabled();
+ m_remoteFrontend->searchingForNodeWasEnabled();
if (m_monitoringXHR)
- m_frontend->monitoringXHRWasEnabled();
+ m_remoteFrontend->monitoringXHRWasEnabled();
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (m_profilerEnabled)
- m_frontend->profilerWasEnabled();
+ m_remoteFrontend->profilerWasEnabled();
#endif
ResourcesMap::iterator resourcesEnd = m_resources.end();
for (ResourcesMap::iterator it = m_resources.begin(); it != resourcesEnd; ++it)
- it->second->updateScriptObject(m_frontend.get());
+ it->second->updateScriptObject(m_remoteFrontend.get());
m_domAgent->setDocument(m_inspectedPage->mainFrame()->document());
@@ -672,31 +648,33 @@ void InspectorController::populateScriptObjects()
m_consoleMessages[i]->addToFrontend(m_remoteFrontend.get(), m_injectedScriptHost.get());
#if ENABLE(JAVASCRIPT_DEBUGGER)
- if (m_debuggerEnabled)
- m_frontend->updatePauseOnExceptionsState(ScriptDebugServer::shared().pauseOnExceptionsState());
+ if (debuggerEnabled())
+ m_remoteFrontend->updatePauseOnExceptionsState(ScriptDebugServer::shared().pauseOnExceptionsState());
#endif
#if ENABLE(DATABASE)
DatabaseResourcesMap::iterator databasesEnd = m_databaseResources.end();
for (DatabaseResourcesMap::iterator it = m_databaseResources.begin(); it != databasesEnd; ++it)
- it->second->bind(m_frontend.get());
+ it->second->bind(m_remoteFrontend.get());
#endif
#if ENABLE(DOM_STORAGE)
DOMStorageResourcesMap::iterator domStorageEnd = m_domStorageResources.end();
for (DOMStorageResourcesMap::iterator it = m_domStorageResources.begin(); it != domStorageEnd; ++it)
- it->second->bind(m_frontend.get());
+ it->second->bind(m_remoteFrontend.get());
#endif
#if ENABLE(WORKERS)
WorkersMap::iterator workersEnd = m_workers.end();
- for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it)
- m_frontend->didCreateWorker(*it->second);
+ for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it) {
+ InspectorWorkerResource* worker = it->second.get();
+ m_remoteFrontend->didCreateWorker(worker->id(), worker->url(), worker->isSharedWorker());
+ }
#endif
- m_frontend->populateSessionSettings(m_sessionSettings->toJSONString());
- m_frontend->populateInterface();
+ m_remoteFrontend->populateSessionSettings(m_sessionSettings->toJSONString());
+ m_remoteFrontend->populateInterface();
// Dispatch pending frontend commands
for (Vector<pair<long, String> >::iterator it = m_pendingEvaluateTestCommands.begin(); it != m_pendingEvaluateTestCommands.end(); ++it)
- m_frontend->evaluateForTestInFrontend((*it).first, (*it).second);
+ m_remoteFrontend->evaluateForTestInFrontend((*it).first, (*it).second);
m_pendingEvaluateTestCommands.clear();
}
@@ -733,8 +711,8 @@ void InspectorController::pruneResources(ResourcesMap* resourceMap, DocumentLoad
if (!loaderToKeep || !resource->isSameLoader(loaderToKeep)) {
removeResource(resource);
- if (m_frontend)
- resource->releaseScriptObject(m_frontend.get());
+ if (m_remoteFrontend)
+ resource->releaseScriptObject(m_remoteFrontend.get());
}
}
}
@@ -747,8 +725,8 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
ASSERT(m_inspectedPage);
if (loader->frame() == m_inspectedPage->mainFrame()) {
- if (m_frontend)
- m_frontend->inspectedURLChanged(loader->url().string());
+ if (m_remoteFrontend)
+ m_remoteFrontend->inspectedURLChanged(loader->url().string());
m_injectedScriptHost->discardInjectedScripts();
clearConsoleMessages();
@@ -756,18 +734,15 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
m_times.clear();
m_counts.clear();
#if ENABLE(JAVASCRIPT_DEBUGGER)
- m_sourceIDToURL.clear();
- m_scriptIDToContent.clear();
- m_stickyBreakpoints.clear();
- m_breakpointsMapping.clear();
- m_breakpointsLoaded = false;
+ if (m_debuggerAgent)
+ m_debuggerAgent->clearForPageNavigation();
#endif
#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
m_profiles.clear();
m_currentUserInitiatedProfileNumber = 1;
m_nextUserInitiatedProfileNumber = 1;
- if (m_frontend)
- m_frontend->resetProfilesPanel();
+ if (m_remoteFrontend)
+ m_remoteFrontend->resetProfilesPanel();
#endif
// unbindAllResources should be called before database and DOM storage
// resources are cleared so that it has a chance to unbind them.
@@ -775,8 +750,8 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
m_cssStore->reset();
m_sessionSettings = InspectorObject::create();
- if (m_frontend) {
- m_frontend->reset();
+ if (m_remoteFrontend) {
+ m_remoteFrontend->reset();
m_domAgent->reset();
}
#if ENABLE(WORKERS)
@@ -789,13 +764,13 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
m_domStorageResources.clear();
#endif
- if (m_frontend) {
+ if (m_remoteFrontend) {
if (!loader->frameLoader()->isLoadingFromCachedPage()) {
ASSERT(m_mainResource && m_mainResource->isSameLoader(loader));
// We don't add the main resource until its load is committed. This is
// needed to keep the load for a user-entered URL from showing up in the
// list of resources for the page they are navigating away from.
- m_mainResource->updateScriptObject(m_frontend.get());
+ m_mainResource->updateScriptObject(m_remoteFrontend.get());
} else {
// Pages loaded from the page cache are committed before
// m_mainResource is the right resource for this load, so we
@@ -803,7 +778,7 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
// identifierForInitialRequest.
m_mainResource = 0;
}
- m_frontend->didCommitLoad();
+ m_remoteFrontend->didCommitLoad();
m_domAgent->setDocument(m_inspectedPage->mainFrame()->document());
}
}
@@ -906,8 +881,8 @@ void InspectorController::didLoadResourceFromMemoryCache(DocumentLoader* loader,
addResource(resource.get());
- if (m_frontend)
- resource->updateScriptObject(m_frontend.get());
+ if (m_remoteFrontend)
+ resource->updateScriptObject(m_remoteFrontend.get());
}
void InspectorController::identifierForInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
@@ -930,8 +905,8 @@ void InspectorController::identifierForInitialRequest(unsigned long identifier,
addResource(resource.get());
- if (m_frontend && loader->frameLoader()->isLoadingFromCachedPage() && resource == m_mainResource)
- resource->updateScriptObject(m_frontend.get());
+ if (m_remoteFrontend && loader->frameLoader()->isLoadingFromCachedPage() && resource == m_mainResource)
+ resource->updateScriptObject(m_remoteFrontend.get());
}
void InspectorController::mainResourceFiredDOMContentEvent(DocumentLoader* loader, const KURL& url)
@@ -943,8 +918,8 @@ void InspectorController::mainResourceFiredDOMContentEvent(DocumentLoader* loade
m_mainResource->markDOMContentEventTime();
if (m_timelineAgent)
m_timelineAgent->didMarkDOMContentEvent();
- if (m_frontend)
- m_mainResource->updateScriptObject(m_frontend.get());
+ if (m_remoteFrontend)
+ m_mainResource->updateScriptObject(m_remoteFrontend.get());
}
}
@@ -957,8 +932,8 @@ void InspectorController::mainResourceFiredLoadEvent(DocumentLoader* loader, con
m_mainResource->markLoadEventTime();
if (m_timelineAgent)
m_timelineAgent->didMarkLoadEvent();
- if (m_frontend)
- m_mainResource->updateScriptObject(m_frontend.get());
+ if (m_remoteFrontend)
+ m_mainResource->updateScriptObject(m_remoteFrontend.get());
}
}
@@ -1005,8 +980,8 @@ void InspectorController::willSendRequest(unsigned long identifier, ResourceRequ
resource->startTiming();
resource->updateRequest(request);
- if (resource != m_mainResource && m_frontend)
- resource->updateScriptObject(m_frontend.get());
+ if (resource != m_mainResource && m_remoteFrontend)
+ resource->updateScriptObject(m_remoteFrontend.get());
}
void InspectorController::didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
@@ -1017,8 +992,8 @@ void InspectorController::didReceiveResponse(unsigned long identifier, const Res
if (RefPtr<InspectorResource> resource = getTrackedResource(identifier)) {
resource->updateResponse(response);
- if (resource != m_mainResource && m_frontend)
- resource->updateScriptObject(m_frontend.get());
+ if (resource != m_mainResource && m_remoteFrontend)
+ resource->updateScriptObject(m_remoteFrontend.get());
}
if (response.httpStatusCode() >= 400) {
// The ugly code below is due to that String::format() is not utf8-safe at the moment.
@@ -1039,8 +1014,8 @@ void InspectorController::didReceiveContentLength(unsigned long identifier, int
resource->addLength(lengthReceived);
- if (resource != m_mainResource && m_frontend)
- resource->updateScriptObject(m_frontend.get());
+ if (resource != m_mainResource && m_remoteFrontend)
+ resource->updateScriptObject(m_remoteFrontend.get());
}
void InspectorController::didFinishLoading(unsigned long identifier)
@@ -1058,8 +1033,8 @@ void InspectorController::didFinishLoading(unsigned long identifier)
resource->endTiming();
// No need to mute this event for main resource since it happens after did commit load.
- if (m_frontend)
- resource->updateScriptObject(m_frontend.get());
+ if (m_remoteFrontend)
+ resource->updateScriptObject(m_remoteFrontend.get());
}
void InspectorController::didFailLoading(unsigned long identifier, const ResourceError& error)
@@ -1083,8 +1058,8 @@ void InspectorController::didFailLoading(unsigned long identifier, const Resourc
resource->endTiming();
// No need to mute this event for main resource since it happens after did commit load.
- if (m_frontend)
- resource->updateScriptObject(m_frontend.get());
+ if (m_remoteFrontend)
+ resource->updateScriptObject(m_remoteFrontend.get());
}
void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
@@ -1104,8 +1079,8 @@ void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identi
resource->setOverrideContent(sourceString, InspectorResource::XHR);
- if (m_frontend)
- resource->updateScriptObject(m_frontend.get());
+ if (m_remoteFrontend)
+ resource->updateScriptObject(m_remoteFrontend.get());
}
void InspectorController::scriptImported(unsigned long identifier, const String& sourceString)
@@ -1119,8 +1094,8 @@ void InspectorController::scriptImported(unsigned long identifier, const String&
resource->setOverrideContent(ScriptString(sourceString), InspectorResource::Script);
- if (m_frontend)
- resource->updateScriptObject(m_frontend.get());
+ if (m_remoteFrontend)
+ resource->updateScriptObject(m_remoteFrontend.get());
}
void InspectorController::enableResourceTracking(bool always, bool reload)
@@ -1136,8 +1111,8 @@ void InspectorController::enableResourceTracking(bool always, bool reload)
ASSERT(m_inspectedPage);
m_resourceTrackingEnabled = true;
- if (m_frontend)
- m_frontend->resourceTrackingWasEnabled();
+ if (m_remoteFrontend)
+ m_remoteFrontend->resourceTrackingWasEnabled();
m_client->resourceTrackingWasEnabled();
if (reload)
@@ -1154,8 +1129,8 @@ void InspectorController::disableResourceTracking(bool always)
ASSERT(m_inspectedPage);
m_resourceTrackingEnabled = false;
- if (m_frontend)
- m_frontend->resourceTrackingWasDisabled();
+ if (m_remoteFrontend)
+ m_remoteFrontend->resourceTrackingWasDisabled();
m_client->resourceTrackingWasDisabled();
}
@@ -1184,8 +1159,8 @@ void InspectorController::startTimelineProfiler()
return;
m_timelineAgent = new InspectorTimelineAgent(m_remoteFrontend.get());
- if (m_frontend)
- m_frontend->timelineProfilerWasStarted();
+ if (m_remoteFrontend)
+ m_remoteFrontend->timelineProfilerWasStarted();
m_client->timelineProfilerWasStarted();
}
@@ -1198,8 +1173,8 @@ void InspectorController::stopTimelineProfiler()
return;
m_timelineAgent = 0;
- if (m_frontend)
- m_frontend->timelineProfilerWasStopped();
+ if (m_remoteFrontend)
+ m_remoteFrontend->timelineProfilerWasStopped();
m_client->timelineProfilerWasStopped();
}
@@ -1231,14 +1206,14 @@ private:
void InspectorController::postWorkerNotificationToFrontend(const InspectorWorkerResource& worker, InspectorController::WorkerAction action)
{
- if (!m_frontend)
+ if (!m_remoteFrontend)
return;
switch (action) {
case InspectorController::WorkerCreated:
- m_frontend->didCreateWorker(worker);
+ m_remoteFrontend->didCreateWorker(worker.id(), worker.url(), worker.isSharedWorker());
break;
case InspectorController::WorkerDestroyed:
- m_frontend->didDestroyWorker(worker);
+ m_remoteFrontend->didDestroyWorker(worker.id());
break;
}
}
@@ -1250,7 +1225,7 @@ void InspectorController::didCreateWorker(intptr_t id, const String& url, bool i
RefPtr<InspectorWorkerResource> workerResource(InspectorWorkerResource::create(id, url, isSharedWorker));
m_workers.set(id, workerResource);
- if (m_inspectedPage && m_frontend)
+ if (m_inspectedPage && m_remoteFrontend)
m_inspectedPage->mainFrame()->document()->postTask(PostWorkerNotificationToFrontendTask::create(workerResource, InspectorController::WorkerCreated));
}
@@ -1262,7 +1237,7 @@ void InspectorController::didDestroyWorker(intptr_t id)
WorkersMap::iterator workerResource = m_workers.find(id);
if (workerResource == m_workers.end())
return;
- if (m_inspectedPage && m_frontend)
+ if (m_inspectedPage && m_remoteFrontend)
m_inspectedPage->mainFrame()->document()->postTask(PostWorkerNotificationToFrontendTask::create(workerResource->second, InspectorController::WorkerDestroyed));
m_workers.remove(workerResource);
}
@@ -1271,12 +1246,12 @@ void InspectorController::didDestroyWorker(intptr_t id)
#if ENABLE(DATABASE)
void InspectorController::selectDatabase(Database* database)
{
- if (!m_frontend)
+ if (!m_remoteFrontend)
return;
for (DatabaseResourcesMap::iterator it = m_databaseResources.begin(); it != m_databaseResources.end(); ++it) {
if (it->second->database() == database) {
- m_frontend->selectDatabase(it->first);
+ m_remoteFrontend->selectDatabase(it->first);
break;
}
}
@@ -1290,7 +1265,7 @@ Database* InspectorController::databaseForId(long databaseId)
return it->second->database();
}
-void InspectorController::didOpenDatabase(Database* database, const String& domain, const String& name, const String& version)
+void InspectorController::didOpenDatabase(PassRefPtr<Database> database, const String& domain, const String& name, const String& version)
{
if (!enabled())
return;
@@ -1300,16 +1275,13 @@ void InspectorController::didOpenDatabase(Database* database, const String& doma
m_databaseResources.set(resource->id(), resource);
// Resources are only bound while visible.
- if (m_frontend)
- resource->bind(m_frontend.get());
+ if (m_remoteFrontend)
+ resource->bind(m_remoteFrontend.get());
}
#endif
-void InspectorController::getCookies(long callId)
+void InspectorController::getCookies(RefPtr<InspectorArray>* cookies, WTF::String* cookiesString)
{
- if (!m_frontend)
- return;
-
// If we can get raw cookies.
ListHashSet<Cookie> rawCookiesList;
@@ -1343,36 +1315,37 @@ void InspectorController::getCookies(long callId)
}
}
- if (!rawCookiesImplemented)
- m_frontend->didGetCookies(callId, m_frontend->newScriptArray(), stringCookiesList);
- else
- m_frontend->didGetCookies(callId, buildArrayForCookies(rawCookiesList), String());
+ if (rawCookiesImplemented)
+ *cookies = buildArrayForCookies(rawCookiesList);
+ else {
+ *cookiesString = stringCookiesList;
+ }
}
-ScriptArray InspectorController::buildArrayForCookies(ListHashSet<Cookie>& cookiesList)
+PassRefPtr<InspectorArray> InspectorController::buildArrayForCookies(ListHashSet<Cookie>& cookiesList)
{
- ScriptArray cookies = m_frontend->newScriptArray();
+ RefPtr<InspectorArray> cookies = InspectorArray::create();
ListHashSet<Cookie>::iterator end = cookiesList.end();
ListHashSet<Cookie>::iterator it = cookiesList.begin();
for (int i = 0; it != end; ++it, i++)
- cookies.set(i, buildObjectForCookie(*it));
+ cookies->push(buildObjectForCookie(*it));
return cookies;
}
-ScriptObject InspectorController::buildObjectForCookie(const Cookie& cookie)
+PassRefPtr<InspectorObject> InspectorController::buildObjectForCookie(const Cookie& cookie)
{
- ScriptObject value = m_frontend->newScriptObject();
- value.set("name", cookie.name);
- value.set("value", cookie.value);
- value.set("domain", cookie.domain);
- value.set("path", cookie.path);
- value.set("expires", cookie.expires);
- value.set("size", (cookie.name.length() + cookie.value.length()));
- value.set("httpOnly", cookie.httpOnly);
- value.set("secure", cookie.secure);
- value.set("session", cookie.session);
+ RefPtr<InspectorObject> value = InspectorObject::create();
+ value->setString("name", cookie.name);
+ value->setString("value", cookie.value);
+ value->setString("domain", cookie.domain);
+ value->setString("path", cookie.path);
+ value->setNumber("expires", cookie.expires);
+ value->setNumber("size", (cookie.name.length() + cookie.value.length()));
+ value->setBool("httpOnly", cookie.httpOnly);
+ value->setBool("secure", cookie.secure);
+ value->setBool("session", cookie.session);
return value;
}
@@ -1403,14 +1376,14 @@ void InspectorController::didUseDOMStorage(StorageArea* storageArea, bool isLoca
m_domStorageResources.set(resource->id(), resource);
// Resources are only bound while visible.
- if (m_frontend)
- resource->bind(m_frontend.get());
+ if (m_remoteFrontend)
+ resource->bind(m_remoteFrontend.get());
}
void InspectorController::selectDOMStorage(Storage* storage)
{
ASSERT(storage);
- if (!m_frontend)
+ if (!m_remoteFrontend)
return;
Frame* frame = storage->frame();
@@ -1425,15 +1398,11 @@ void InspectorController::selectDOMStorage(Storage* storage)
}
}
if (storageResourceId)
- m_frontend->selectDOMStorage(storageResourceId);
+ m_remoteFrontend->selectDOMStorage(storageResourceId);
}
-void InspectorController::getDOMStorageEntries(long callId, long storageId)
+void InspectorController::getDOMStorageEntries(long storageId, RefPtr<InspectorArray>* entries)
{
- if (!m_frontend)
- return;
-
- ScriptArray jsonArray = m_frontend->newScriptArray();
InspectorDOMStorageResource* storageResource = getDOMStorageResourceForId(storageId);
if (storageResource) {
storageResource->startReportingChangesToFrontend();
@@ -1441,42 +1410,31 @@ void InspectorController::getDOMStorageEntries(long callId, long storageId)
for (unsigned i = 0; i < domStorage->length(); ++i) {
String name(domStorage->key(i));
String value(domStorage->getItem(name));
- ScriptArray entry = m_frontend->newScriptArray();
- entry.set(0, name);
- entry.set(1, value);
- jsonArray.set(i, entry);
+ RefPtr<InspectorArray> entry = InspectorArray::create();
+ entry->pushString(name);
+ entry->pushString(value);
+ (*entries)->push(entry);
}
}
- m_frontend->didGetDOMStorageEntries(callId, jsonArray);
}
-void InspectorController::setDOMStorageItem(long callId, long storageId, const String& key, const String& value)
+void InspectorController::setDOMStorageItem(long storageId, const String& key, const String& value, bool* success)
{
- if (!m_frontend)
- return;
-
- bool success = false;
InspectorDOMStorageResource* storageResource = getDOMStorageResourceForId(storageId);
if (storageResource) {
ExceptionCode exception = 0;
storageResource->domStorage()->setItem(key, value, exception);
- success = !exception;
+ *success = !exception;
}
- m_frontend->didSetDOMStorageItem(callId, success);
}
-void InspectorController::removeDOMStorageItem(long callId, long storageId, const String& key)
+void InspectorController::removeDOMStorageItem(long storageId, const String& key, bool* success)
{
- if (!m_frontend)
- return;
-
- bool success = false;
InspectorDOMStorageResource* storageResource = getDOMStorageResourceForId(storageId);
if (storageResource) {
storageResource->domStorage()->removeItem(key);
- success = true;
+ *success = true;
}
- m_frontend->didRemoveDOMStorageItem(callId, success);
}
InspectorDOMStorageResource* InspectorController::getDOMStorageResourceForId(long storageId)
@@ -1497,11 +1455,8 @@ void InspectorController::addProfile(PassRefPtr<ScriptProfile> prpProfile, unsig
RefPtr<ScriptProfile> profile = prpProfile;
m_profiles.add(profile->uid(), profile);
- if (m_frontend) {
-#if USE(JSC)
- JSC::JSLock lock(JSC::SilenceAssertionsOnly);
-#endif
- m_frontend->addProfileHeader(createProfileHeader(*profile));
+ if (m_remoteFrontend) {
+ m_remoteFrontend->addProfileHeader(createProfileHeader(*profile));
}
addProfileFinishedMessageToConsole(profile, lineNumber, sourceURL);
@@ -1511,11 +1466,7 @@ void InspectorController::addProfileFinishedMessageToConsole(PassRefPtr<ScriptPr
{
RefPtr<ScriptProfile> profile = prpProfile;
-#if USE(JSC)
- String title = ustringToString(profile->title());
-#else
String title = profile->title();
-#endif
String message = String::format("Profile \"webkit-profile://%s/%s#%d\" finished.", CPUProfileType, encodeWithURLEscapeSequences(title).utf8().data(), profile->uid());
addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL);
}
@@ -1545,45 +1496,28 @@ void InspectorController::clearProfiles()
m_nextUserInitiatedProfileNumber = 1;
}
-void InspectorController::getProfileHeaders(long callId)
+void InspectorController::getProfileHeaders(RefPtr<InspectorArray>* headers)
{
- if (!m_frontend)
- return;
- ScriptArray result = m_frontend->newScriptArray();
ProfilesMap::iterator profilesEnd = m_profiles.end();
- int i = 0;
for (ProfilesMap::iterator it = m_profiles.begin(); it != profilesEnd; ++it)
- result.set(i++, createProfileHeader(*it->second));
- m_frontend->didGetProfileHeaders(callId, result);
+ (*headers)->push(createProfileHeader(*it->second));
}
-void InspectorController::getProfile(long callId, unsigned uid)
+void InspectorController::getProfile(unsigned uid, RefPtr<InspectorObject>* profileObject)
{
- if (!m_frontend)
- return;
ProfilesMap::iterator it = m_profiles.find(uid);
if (it != m_profiles.end()) {
-#if USE(JSC)
- m_frontend->didGetProfile(callId, toJS(m_frontend->scriptState(), it->second.get()));
-#else
- ScriptScope scope(m_frontend->scriptState());
- m_frontend->didGetProfile(callId, toV8(it->second.get()));
-#endif
+ *profileObject = createProfileHeader(*it->second);
+ (*profileObject)->set("head", it->second->buildInspectorObjectForHead());
}
}
-ScriptObject InspectorController::createProfileHeader(const ScriptProfile& profile)
+PassRefPtr<InspectorObject> InspectorController::createProfileHeader(const ScriptProfile& profile)
{
-#if USE(JSC)
- String title = ustringToString(profile.title());
-#else
- String title = profile.title();
-#endif
-
- ScriptObject header = m_frontend->newScriptObject();
- header.set("title", title);
- header.set("uid", profile.uid());
- header.set("typeId", String(CPUProfileType));
+ RefPtr<InspectorObject> header = InspectorObject::create();
+ header->setString("title", profile.title());
+ header->setNumber("uid", profile.uid());
+ header->setString("typeId", String(CPUProfileType));
return header;
}
@@ -1651,9 +1585,9 @@ void InspectorController::stopUserInitiatedProfiling()
void InspectorController::toggleRecordButton(bool isProfiling)
{
- if (!m_frontend)
+ if (!m_remoteFrontend)
return;
- m_frontend->setRecordingProfile(isProfiling);
+ m_remoteFrontend->setRecordingProfile(isProfiling);
}
void InspectorController::enableProfiler(bool always, bool skipRecompile)
@@ -1669,8 +1603,8 @@ void InspectorController::enableProfiler(bool always, bool skipRecompile)
if (!skipRecompile)
ScriptDebugServer::shared().recompileAllJSFunctionsSoon();
- if (m_frontend)
- m_frontend->profilerWasEnabled();
+ if (m_remoteFrontend)
+ m_remoteFrontend->profilerWasEnabled();
}
void InspectorController::disableProfiler(bool always)
@@ -1685,33 +1619,23 @@ void InspectorController::disableProfiler(bool always)
ScriptDebugServer::shared().recompileAllJSFunctionsSoon();
- if (m_frontend)
- m_frontend->profilerWasDisabled();
-}
-
-void InspectorController::takeHeapSnapshot()
-{
- if (!enabled())
- return;
-
- ScriptProfiler::takeHeapSnapshot();
+ if (m_remoteFrontend)
+ m_remoteFrontend->profilerWasDisabled();
}
#endif
#if ENABLE(JAVASCRIPT_DEBUGGER)
void InspectorController::enableDebuggerFromFrontend(bool always)
{
- ASSERT(!m_debuggerEnabled);
+ ASSERT(!debuggerEnabled());
if (always)
setSetting(debuggerEnabledSettingName, "true");
ASSERT(m_inspectedPage);
- ScriptDebugServer::shared().clearBreakpoints();
- ScriptDebugServer::shared().addListener(this, m_inspectedPage);
+ m_debuggerAgent = InspectorDebuggerAgent::create(this, m_remoteFrontend.get());
- m_debuggerEnabled = true;
- m_frontend->debuggerWasEnabled();
+ m_remoteFrontend->debuggerWasEnabled();
}
void InspectorController::enableDebugger()
@@ -1719,13 +1643,13 @@ void InspectorController::enableDebugger()
if (!enabled())
return;
- if (m_debuggerEnabled)
+ if (debuggerEnabled())
return;
- if (!m_frontend)
+ if (!m_remoteFrontend)
m_attachDebuggerWhenShown = true;
else {
- m_frontend->attachDebuggerWhenShown();
+ m_remoteFrontend->attachDebuggerWhenShown();
m_attachDebuggerWhenShown = false;
}
}
@@ -1740,163 +1664,27 @@ void InspectorController::disableDebugger(bool always)
ASSERT(m_inspectedPage);
- ScriptDebugServer::shared().removeListener(this, m_inspectedPage);
+ m_debuggerAgent.clear();
- m_debuggerEnabled = false;
m_attachDebuggerWhenShown = false;
- m_pausedScriptState = 0;
-
- if (m_frontend)
- m_frontend->debuggerWasDisabled();
-}
-
-void InspectorController::editScriptSource(long callId, const String& sourceID, const String& newContent)
-{
- String result;
- bool success = ScriptDebugServer::shared().editScriptSource(sourceID, newContent, result);
- RefPtr<SerializedScriptValue> callFrames;
- if (success)
- callFrames = currentCallFrames();
- m_frontend->didEditScriptSource(callId, success, result, callFrames.get());
-}
-void InspectorController::getScriptSource(long callId, const String& sourceID)
-{
- if (!m_frontend)
- return;
- String scriptSource = m_scriptIDToContent.get(sourceID);
- m_frontend->didGetScriptSource(callId, scriptSource);
+ if (m_remoteFrontend)
+ m_remoteFrontend->debuggerWasDisabled();
}
void InspectorController::resume()
{
- if (!m_debuggerEnabled)
- return;
- ScriptDebugServer::shared().continueProgram();
+ if (m_debuggerAgent)
+ m_debuggerAgent->resume();
}
-
-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)
- return 0;
- InjectedScript injectedScript = m_injectedScriptHost->injectedScriptFor(m_pausedScriptState);
- if (injectedScript.hasNoValue()) {
- ASSERT_NOT_REACHED();
- return 0;
- }
- return injectedScript.callFrames();
-}
-
-void InspectorController::setBreakpoint(long callId, const String& sourceID, unsigned lineNumber, bool enabled, const String& condition)
-{
- ScriptBreakpoint breakpoint(enabled, condition);
- unsigned actualLineNumber = 0;
- bool success = ScriptDebugServer::shared().setBreakpoint(sourceID, breakpoint, lineNumber, &actualLineNumber);
- m_frontend->didSetBreakpoint(callId, success, actualLineNumber);
- if (!success)
- return;
-
- String url = m_sourceIDToURL.get(sourceID);
- if (url.isEmpty())
- return;
-
- String breakpointId = formatBreakpointId(sourceID, actualLineNumber);
- m_breakpointsMapping.set(breakpointId, actualLineNumber);
-
- String key = md5Base16(url);
- HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(key);
- if (it == m_stickyBreakpoints.end())
- it = m_stickyBreakpoints.set(key, SourceBreakpoints()).first;
- it->second.set(actualLineNumber, breakpoint);
- saveBreakpoints();
-}
-
-void InspectorController::removeBreakpoint(const String& sourceID, unsigned lineNumber)
-{
- ScriptDebugServer::shared().removeBreakpoint(sourceID, lineNumber);
-
- String url = m_sourceIDToURL.get(sourceID);
- if (url.isEmpty())
- return;
-
- String breakpointId = formatBreakpointId(sourceID, lineNumber);
- HashMap<String, unsigned>::iterator mappingIt = m_breakpointsMapping.find(breakpointId);
- if (mappingIt == m_breakpointsMapping.end())
- return;
- unsigned stickyLine = mappingIt->second;
- m_breakpointsMapping.remove(mappingIt);
-
- HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
- if (it == m_stickyBreakpoints.end())
- return;
-
- it->second.remove(stickyLine);
- saveBreakpoints();
-}
-
// JavaScriptDebugListener functions
-void InspectorController::didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType worldType)
-{
- // Don't send script content to the front end until it's really needed.
- m_frontend->parsedScriptSource(sourceID, url, "", firstLine, worldType);
-
- m_scriptIDToContent.set(sourceID, data);
-
- if (url.isEmpty())
- return;
-
- loadBreakpoints();
- HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
- if (it != m_stickyBreakpoints.end()) {
- for (SourceBreakpoints::iterator breakpointIt = it->second.begin(); breakpointIt != it->second.end(); ++breakpointIt) {
- int lineNumber = breakpointIt->first;
- if (firstLine > lineNumber)
- continue;
- unsigned actualLineNumber = 0;
- bool success = ScriptDebugServer::shared().setBreakpoint(sourceID, breakpointIt->second, lineNumber, &actualLineNumber);
- if (!success)
- continue;
- m_frontend->restoredBreakpoint(sourceID, url, actualLineNumber, breakpointIt->second.enabled, breakpointIt->second.condition);
- String breakpointId = formatBreakpointId(sourceID, actualLineNumber);
- m_breakpointsMapping.set(breakpointId, lineNumber);
- }
- }
- m_sourceIDToURL.set(sourceID, url);
-}
-
-void InspectorController::failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage)
-{
- m_frontend->failedToParseScriptSource(url, data, firstLine, errorLine, errorMessage);
-}
-
-void InspectorController::didPause(ScriptState* scriptState)
-{
- ASSERT(scriptState && !m_pausedScriptState);
- m_pausedScriptState = scriptState;
- RefPtr<SerializedScriptValue> callFrames = currentCallFrames();
- m_frontend->pausedScript(callFrames.get());
-}
-
-void InspectorController::didContinue()
-{
- m_pausedScriptState = 0;
- m_frontend->resumedScript();
-}
-
#endif
void InspectorController::evaluateForTestInFrontend(long callId, const String& script)
{
- if (m_frontend)
- m_frontend->evaluateForTestInFrontend(callId, script);
+ if (m_remoteFrontend)
+ m_remoteFrontend->evaluateForTestInFrontend(callId, script);
else
m_pendingEvaluateTestCommands.append(pair<long, String>(callId, script));
}
@@ -1916,39 +1704,16 @@ void InspectorController::didEvaluateForTestInFrontend(long callId, const String
String InspectorController::breakpointsSettingKey()
{
DEFINE_STATIC_LOCAL(String, keyPrefix, ("breakpoints:"));
- return keyPrefix + md5Base16(m_mainResource->requestURL());
+ return keyPrefix + InspectorDebuggerAgent::md5Base16(m_mainResource->requestURL());
}
-void InspectorController::loadBreakpoints()
+PassRefPtr<InspectorValue> InspectorController::loadBreakpoints()
{
- if (m_breakpointsLoaded)
- return;
- m_breakpointsLoaded = true;
-
- RefPtr<InspectorValue> parsedSetting = InspectorValue::parseJSON(setting(breakpointsSettingKey()));
- if (!parsedSetting)
- return;
- RefPtr<InspectorObject> breakpoints = parsedSetting->asObject();
- if (!breakpoints)
- return;
- for (InspectorObject::iterator it = breakpoints->begin(); it != breakpoints->end(); ++it) {
- RefPtr<InspectorObject> breakpointsForURL = it->second->asObject();
- if (!breakpointsForURL)
- continue;
- HashMap<String, SourceBreakpoints>::iterator sourceBreakpointsIt = m_stickyBreakpoints.set(it->first, SourceBreakpoints()).first;
- ScriptBreakpoint::sourceBreakpointsFromInspectorObject(breakpointsForURL, &sourceBreakpointsIt->second);
- }
+ return InspectorValue::parseJSON(setting(breakpointsSettingKey()));
}
-void InspectorController::saveBreakpoints()
+void InspectorController::saveBreakpoints(PassRefPtr<InspectorObject> breakpoints)
{
- RefPtr<InspectorObject> breakpoints = InspectorObject::create();
- for (HashMap<String, SourceBreakpoints>::iterator it(m_stickyBreakpoints.begin()); it != m_stickyBreakpoints.end(); ++it) {
- if (it->second.isEmpty())
- continue;
- RefPtr<InspectorObject> breakpointsForURL = ScriptBreakpoint::inspectorObjectFromSourceBreakpoints(it->second);
- breakpoints->set(it->first, breakpointsForURL);
- }
setSetting(breakpointsSettingKey(), breakpoints->toJSONString());
}
#endif
@@ -2136,27 +1901,6 @@ bool InspectorController::stopTiming(const String& title, double& elapsed)
return true;
}
-InspectorController::SpecialPanels InspectorController::specialPanelForJSName(const String& panelName)
-{
- if (panelName == "elements")
- return ElementsPanel;
- if (panelName == "resources")
- return ResourcesPanel;
- if (panelName == "scripts")
- return ScriptsPanel;
- if (panelName == "timeline")
- return TimelinePanel;
- if (panelName == "profiles")
- return ProfilesPanel;
- if (panelName == "storage" || panelName == "databases")
- return StoragePanel;
- if (panelName == "audits")
- return AuditsPanel;
- if (panelName == "console")
- return ConsolePanel;
- return ElementsPanel;
-}
-
InjectedScript InspectorController::injectedScriptForNodeId(long id)
{
@@ -2188,16 +1932,15 @@ void InspectorController::removeAllScriptsToEvaluateOnLoad()
m_scriptsToEvaluateOnLoad.clear();
}
-void InspectorController::getResourceContent(long callId, unsigned long identifier)
+void InspectorController::setInspectorExtensionAPI(const String& source)
{
- if (!m_frontend)
- return;
+ m_inspectorExtensionAPI = source;
+}
+void InspectorController::getResourceContent(unsigned long identifier, String* content)
+{
RefPtr<InspectorResource> resource = m_resources.get(identifier);
- if (resource)
- m_frontend->didGetResourceContent(callId, resource->sourceString());
- else
- m_frontend->didGetResourceContent(callId, "");
+ *content = resource ? resource->sourceString() : String();
}
void InspectorController::reloadPage()
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index 176dd11..faddedb 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -33,12 +33,8 @@
#include "Cookie.h"
#include "InspectorDOMAgent.h"
#include "PlatformString.h"
-#include "ScriptArray.h"
-#include "ScriptBreakpoint.h"
-#include "ScriptObject.h"
#include "ScriptProfile.h"
#include "ScriptState.h"
-#include "ScriptValue.h"
#include "StringHash.h"
#include "Timer.h"
#include <wtf/HashMap.h>
@@ -47,10 +43,6 @@
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-#include "ScriptDebugListener.h"
-#endif
-
namespace WebCore {
class CachedResource;
@@ -63,15 +55,18 @@ class GraphicsContext;
class HitTestResult;
class InjectedScript;
class InjectedScriptHost;
+class InspectorArray;
class InspectorBackend;
class InspectorBackendDispatcher;
class InspectorClient;
class InspectorCSSStore;
class InspectorDOMStorageResource;
class InspectorDatabaseResource;
-class InspectorFrontend;
+class InspectorDebuggerAgent;
class InspectorFrontendClient;
+class InspectorObject;
class InspectorResource;
+class InspectorStorageAgent;
class InspectorTimelineAgent;
class InspectorValue;
class InspectorWorkerResource;
@@ -92,36 +87,24 @@ class StorageArea;
class InspectorApplicationCacheAgent;
#endif
-class InspectorController
-#if ENABLE(JAVASCRIPT_DEBUGGER)
- : ScriptDebugListener, public Noncopyable
-#else
- : public Noncopyable
-#endif
- {
+class InspectorController : public Noncopyable {
public:
typedef HashMap<unsigned long, RefPtr<InspectorResource> > ResourcesMap;
typedef HashMap<RefPtr<Frame>, ResourcesMap*> FrameResourcesMap;
typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap;
typedef HashMap<int, RefPtr<InspectorDOMStorageResource> > DOMStorageResourcesMap;
- typedef enum {
- AuditsPanel,
- CurrentPanel,
- ConsolePanel,
- ElementsPanel,
- ResourcesPanel,
- ScriptsPanel,
- TimelinePanel,
- ProfilesPanel,
- StoragePanel
- } SpecialPanels;
+ static const char* const ConsolePanel;
+ static const char* const ElementsPanel;
+ static const char* const ProfilesPanel;
+ static const char* const ScriptsPanel;
InspectorController(Page*, InspectorClient*);
~InspectorController();
InspectorBackend* inspectorBackend() { return m_inspectorBackend.get(); }
InspectorBackendDispatcher* inspectorBackendDispatcher() { return m_inspectorBackendDispatcher.get(); }
+ InspectorClient* inspectorClient() { return m_client; }
InjectedScriptHost* injectedScriptHost() { return m_injectedScriptHost.get(); }
void inspectedPageDestroyed();
@@ -144,13 +127,13 @@ public:
void hideDOMNodeHighlight() { hideHighlight(); }
void show();
- void showPanel(SpecialPanels);
+ void showPanel(const String&);
void close();
// We are in transition from JS transport via webInspector to native
// transport via InspectorClient. After migration, webInspector parameter should
// be removed.
- void connectFrontend(const ScriptObject& webInspector);
+ void connectFrontend();
void disconnectFrontend();
void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*, const String& message = String());
@@ -192,7 +175,7 @@ public:
void stopTimelineProfiler();
InspectorTimelineAgent* timelineAgent() { return m_timelineAgent.get(); }
- void getCookies(long callId);
+ void getCookies(RefPtr<InspectorArray>* cookies, WTF::String* cookiesString);
void deleteCookie(const String& cookieName, const String& domain);
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
@@ -214,20 +197,19 @@ public:
#endif
#if ENABLE(DATABASE)
- void didOpenDatabase(Database*, const String& domain, const String& name, const String& version);
+ void didOpenDatabase(PassRefPtr<Database>, const String& domain, const String& name, const String& version);
#endif
#if ENABLE(DOM_STORAGE)
void didUseDOMStorage(StorageArea* storageArea, bool isLocalStorage, Frame* frame);
void selectDOMStorage(Storage* storage);
- void getDOMStorageEntries(long callId, long storageId);
- void setDOMStorageItem(long callId, long storageId, const String& key, const String& value);
- void removeDOMStorageItem(long callId, long storageId, const String& key);
+ void getDOMStorageEntries(long storageId, RefPtr<InspectorArray>* entries);
+ void setDOMStorageItem(long storageId, const String& key, const String& value, bool* success);
+ void removeDOMStorageItem(long storageId, const String& key, bool* success);
#endif
const ResourcesMap& resources() const { return m_resources; }
InspectorResource* resourceForURL(const String& url);
- InspectorFrontend* inspectorFrontend() { return m_frontend.get(); }
- RemoteInspectorFrontend* remoteInspectorFrontend() { return m_remoteFrontend.get(); }
+ bool hasFrontend() const { return m_remoteFrontend; }
void drawNodeHighlight(GraphicsContext&) const;
@@ -260,30 +242,19 @@ public:
void disableProfiler(bool always = false);
bool profilerEnabled() const { return enabled() && m_profilerEnabled; }
- void takeHeapSnapshot();
-
void enableDebugger();
void disableDebugger(bool always = false);
- bool debuggerEnabled() const { return m_debuggerEnabled; }
-
- void editScriptSource(long callId, const String& sourceID, const String& newContent);
- void getScriptSource(long callId, const String& sourceID);
-
+ bool debuggerEnabled() const { return m_debuggerAgent; }
+ InspectorDebuggerAgent* debuggerAgent() const { return m_debuggerAgent.get(); }
void resume();
- void setPauseOnExceptionsState(long pauseState);
- PassRefPtr<SerializedScriptValue> currentCallFrames();
-
- virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType);
- virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
- virtual void didPause(ScriptState*);
- virtual void didContinue();
#endif
- void evaluateForTestInFrontend(long callId, const String& script);
+ void evaluateForTestInFrontend(long testCallId, const String& script);
InjectedScript injectedScriptForNodeId(long id);
void addScriptToEvaluateOnLoad(const String& source);
void removeAllScriptsToEvaluateOnLoad();
+ void setInspectorExtensionAPI(const String& source);
static const String& inspectorStartsAttachedSettingName();
@@ -291,6 +262,7 @@ private:
static const String& frontendSettingsSettingName();
friend class InspectorBackend;
+ friend class InspectorBackendDispatcher;
friend class InjectedScriptHost;
void populateScriptObjects();
@@ -309,17 +281,14 @@ private:
void releaseFrontendLifetimeAgents();
#if ENABLE(JAVASCRIPT_DEBUGGER)
- void setBreakpoint(long callId, const String& sourceID, unsigned lineNumber, bool enabled, const String& condition);
- void removeBreakpoint(const String& sourceID, unsigned lineNumber);
-
typedef HashMap<unsigned int, RefPtr<ScriptProfile> > ProfilesMap;
void startUserInitiatedProfilingSoon();
void toggleRecordButton(bool);
void enableDebuggerFromFrontend(bool always);
- void getProfileHeaders(long callId);
- void getProfile(long callId, unsigned uid);
- ScriptObject createProfileHeader(const ScriptProfile& profile);
+ void getProfileHeaders(RefPtr<InspectorArray>* headers);
+ void getProfile(unsigned uid, RefPtr<InspectorObject>* profileObject);
+ PassRefPtr<InspectorObject> createProfileHeader(const ScriptProfile& profile);
#endif
#if ENABLE(DATABASE)
void selectDatabase(Database* database);
@@ -329,8 +298,8 @@ private:
InspectorDOMStorageResource* getDOMStorageResourceForId(long storageId);
#endif
- ScriptObject buildObjectForCookie(const Cookie&);
- ScriptArray buildArrayForCookies(ListHashSet<Cookie>&);
+ PassRefPtr<InspectorObject> buildObjectForCookie(const Cookie&);
+ PassRefPtr<InspectorArray> buildArrayForCookies(ListHashSet<Cookie>&);
void focusNode();
@@ -339,30 +308,29 @@ private:
void addResource(InspectorResource*);
void removeResource(InspectorResource*);
InspectorResource* getTrackedResource(unsigned long identifier);
- void getResourceContent(long callId, unsigned long identifier);
+ void getResourceContent(unsigned long identifier, String* content);
void pruneResources(ResourcesMap*, DocumentLoader* loaderToKeep = 0);
void removeAllResources(ResourcesMap* map) { pruneResources(map); }
bool isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl);
- SpecialPanels specialPanelForJSName(const String& panelName);
-
void didEvaluateForTestInFrontend(long callId, const String& jsonResult);
#if ENABLE(JAVASCRIPT_DEBUGGER)
+ friend class InspectorDebuggerAgent;
String breakpointsSettingKey();
- void loadBreakpoints();
- void saveBreakpoints();
+ PassRefPtr<InspectorValue> loadBreakpoints();
+ void saveBreakpoints(PassRefPtr<InspectorObject> breakpoints);
#endif
Page* m_inspectedPage;
InspectorClient* m_client;
OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient;
bool m_openingFrontend;
- OwnPtr<InspectorFrontend> m_frontend;
OwnPtr<RemoteInspectorFrontend> m_remoteFrontend;
RefPtr<InspectorDOMAgent> m_domAgent;
+ RefPtr<InspectorStorageAgent> m_storageAgent;
OwnPtr<InspectorCSSStore> m_cssStore;
OwnPtr<InspectorTimelineAgent> m_timelineAgent;
@@ -385,7 +353,7 @@ private:
#if ENABLE(DOM_STORAGE)
DOMStorageResourcesMap m_domStorageResources;
#endif
- SpecialPanels m_showAfterVisible;
+ String m_showAfterVisible;
RefPtr<Node> m_highlightedNode;
#if ENABLE(INSPECTOR)
RefPtr<InspectorValue> m_sessionSettings;
@@ -405,15 +373,10 @@ private:
Vector<pair<long, String> > m_pendingEvaluateTestCommands;
Vector<String> m_scriptsToEvaluateOnLoad;
+ String m_inspectorExtensionAPI;
#if ENABLE(JAVASCRIPT_DEBUGGER)
- bool m_debuggerEnabled;
bool m_attachDebuggerWhenShown;
- ScriptState* m_pausedScriptState;
- HashMap<String, String> m_sourceIDToURL;
- HashMap<String, String> m_scriptIDToContent;
- HashMap<String, SourceBreakpoints> m_stickyBreakpoints;
- HashMap<String, unsigned> m_breakpointsMapping;
- bool m_breakpointsLoaded;
+ OwnPtr<InspectorDebuggerAgent> m_debuggerAgent;
bool m_profilerEnabled;
bool m_recordingUserInitiatedProfile;
diff --git a/WebCore/inspector/InspectorDOMAgent.cpp b/WebCore/inspector/InspectorDOMAgent.cpp
index 075944a..7cf0a82 100644
--- a/WebCore/inspector/InspectorDOMAgent.cpp
+++ b/WebCore/inspector/InspectorDOMAgent.cpp
@@ -384,10 +384,9 @@ Node* InspectorDOMAgent::nodeForId(long id)
return 0;
}
-void InspectorDOMAgent::getChildNodes(long callId, long nodeId)
+void InspectorDOMAgent::getChildNodes(long nodeId)
{
pushChildNodesToFrontend(nodeId);
- m_frontend->didGetChildNodes(callId);
}
long InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush)
@@ -432,72 +431,56 @@ long InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush)
return map->get(nodeToPush);
}
-void InspectorDOMAgent::setAttribute(long callId, long elementId, const String& name, const String& value)
+void InspectorDOMAgent::setAttribute(long elementId, const String& name, const String& value, bool* success)
{
Node* node = nodeForId(elementId);
if (node && (node->nodeType() == Node::ELEMENT_NODE)) {
Element* element = static_cast<Element*>(node);
ExceptionCode ec = 0;
element->setAttribute(name, value, ec);
- m_frontend->didApplyDomChange(callId, ec == 0);
- } else {
- m_frontend->didApplyDomChange(callId, false);
+ *success = !ec;
}
}
-void InspectorDOMAgent::removeAttribute(long callId, long elementId, const String& name)
+void InspectorDOMAgent::removeAttribute(long elementId, const String& name, bool* success)
{
Node* node = nodeForId(elementId);
if (node && (node->nodeType() == Node::ELEMENT_NODE)) {
Element* element = static_cast<Element*>(node);
ExceptionCode ec = 0;
element->removeAttribute(name, ec);
- m_frontend->didApplyDomChange(callId, ec == 0);
- } else {
- m_frontend->didApplyDomChange(callId, false);
+ *success = !ec;
}
}
-void InspectorDOMAgent::removeNode(long callId, long nodeId)
+void InspectorDOMAgent::removeNode(long nodeId, long* outNodeId)
{
Node* node = nodeForId(nodeId);
- if (!node) {
- m_frontend->didRemoveNode(callId, 0);
+ if (!node)
return;
- }
Node* parentNode = node->parentNode();
- if (!parentNode) {
- m_frontend->didRemoveNode(callId, 0);
+ if (!parentNode)
return;
- }
ExceptionCode ec = 0;
parentNode->removeChild(node, ec);
- if (ec) {
- m_frontend->didRemoveNode(callId, 0);
+ if (ec)
return;
- }
- m_frontend->didRemoveNode(callId, nodeId);
+ *outNodeId = nodeId;
}
-void InspectorDOMAgent::changeTagName(long callId, long nodeId, const String& tagName)
+void InspectorDOMAgent::changeTagName(long nodeId, const String& tagName, long* newId)
{
Node* oldNode = nodeForId(nodeId);
- if (!oldNode || !oldNode->isElementNode()) {
- m_frontend->didChangeTagName(callId, 0);
+ if (!oldNode || !oldNode->isElementNode())
return;
- }
-
- bool childrenRequested = m_childrenRequested.contains(nodeId);
ExceptionCode ec = 0;
RefPtr<Element> newElem = oldNode->document()->createElement(tagName, ec);
- if (ec) {
- m_frontend->didChangeTagName(callId, 0);
+ if (ec)
return;
- }
// Copy over the original node's attributes.
Element* oldElem = static_cast<Element*>(oldNode);
@@ -515,36 +498,28 @@ void InspectorDOMAgent::changeTagName(long callId, long nodeId, const String& ta
parent->insertBefore(newElem, oldNode->nextSibling(), ec);
parent->removeChild(oldNode, ec);
- if (ec) {
- m_frontend->didChangeTagName(callId, 0);
+ if (ec)
return;
- }
- long newId = pushNodePathToFrontend(newElem.get());
- if (childrenRequested)
- pushChildNodesToFrontend(newId);
- m_frontend->didChangeTagName(callId, newId);
+ *newId = pushNodePathToFrontend(newElem.get());
+ if (m_childrenRequested.contains(nodeId))
+ pushChildNodesToFrontend(*newId);
}
-void InspectorDOMAgent::getOuterHTML(long callId, long nodeId)
+void InspectorDOMAgent::getOuterHTML(long nodeId, WTF::String* outerHTML)
{
Node* node = nodeForId(nodeId);
- if (!node || !node->isHTMLElement()) {
- m_frontend->didGetOuterHTML(callId, "");
+ if (!node || !node->isHTMLElement())
return;
- }
- HTMLElement* htmlElement = static_cast<HTMLElement*>(node);
- m_frontend->didGetOuterHTML(callId, htmlElement->outerHTML());
+ *outerHTML = static_cast<HTMLElement*>(node)->outerHTML();
}
-void InspectorDOMAgent::setOuterHTML(long callId, long nodeId, const String& outerHTML)
+void InspectorDOMAgent::setOuterHTML(long nodeId, const String& outerHTML, long* newId)
{
Node* node = nodeForId(nodeId);
- if (!node || !node->isHTMLElement()) {
- m_frontend->didSetOuterHTML(callId, 0);
+ if (!node || !node->isHTMLElement())
return;
- }
bool childrenRequested = m_childrenRequested.contains(nodeId);
Node* previousSibling = node->previousSibling();
@@ -554,41 +529,35 @@ void InspectorDOMAgent::setOuterHTML(long callId, long nodeId, const String& out
ExceptionCode ec = 0;
htmlElement->setOuterHTML(outerHTML, ec);
if (ec)
- m_frontend->didSetOuterHTML(callId, 0);
+ return;
Node* newNode = previousSibling ? previousSibling->nextSibling() : parentNode->firstChild();
- long newId = pushNodePathToFrontend(newNode);
+ *newId = pushNodePathToFrontend(newNode);
if (childrenRequested)
- pushChildNodesToFrontend(newId);
-
- m_frontend->didSetOuterHTML(callId, newId);
+ pushChildNodesToFrontend(*newId);
}
-void InspectorDOMAgent::setTextNodeValue(long callId, long nodeId, const String& value)
+void InspectorDOMAgent::setTextNodeValue(long nodeId, const String& value, bool* success)
{
Node* node = nodeForId(nodeId);
if (node && (node->nodeType() == Node::TEXT_NODE)) {
Text* text_node = static_cast<Text*>(node);
ExceptionCode ec = 0;
text_node->replaceWholeText(value, ec);
- m_frontend->didApplyDomChange(callId, ec == 0);
- } else {
- m_frontend->didApplyDomChange(callId, false);
+ *success = !ec;
}
}
-void InspectorDOMAgent::getEventListenersForNode(long callId, long nodeId)
+void InspectorDOMAgent::getEventListenersForNode(long nodeId, long* outNodeId, RefPtr<InspectorArray>* listenersArray)
{
Node* node = nodeForId(nodeId);
- RefPtr<InspectorArray> listenersArray = InspectorArray::create();
+ *outNodeId = nodeId;
EventTargetData* d;
// Quick break if a null node or no listeners at all
- if (!node || !(d = node->eventTargetData())) {
- m_frontend->didGetEventListenersForNode(callId, nodeId, listenersArray.release());
+ if (!node || !(d = node->eventTargetData()))
return;
- }
// Get the list of event types this Node is concerned with
Vector<AtomicString> eventTypes;
@@ -599,10 +568,8 @@ void InspectorDOMAgent::getEventListenersForNode(long callId, long nodeId)
// Quick break if no useful listeners
size_t eventTypesLength = eventTypes.size();
- if (eventTypesLength == 0) {
- m_frontend->didGetEventListenersForNode(callId, nodeId, listenersArray.release());
+ if (!eventTypesLength)
return;
- }
// The Node's Event Ancestors (not including self)
Vector<RefPtr<ContainerNode> > ancestors;
@@ -633,7 +600,7 @@ void InspectorDOMAgent::getEventListenersForNode(long callId, long nodeId)
for (size_t j = 0; j < vector.size(); ++j) {
const RegisteredEventListener& listener = vector[j];
if (listener.useCapture)
- listenersArray->push(buildObjectForEventListener(listener, info.eventType, info.node));
+ (*listenersArray)->push(buildObjectForEventListener(listener, info.eventType, info.node));
}
}
@@ -644,11 +611,9 @@ void InspectorDOMAgent::getEventListenersForNode(long callId, long nodeId)
for (size_t j = 0; j < vector.size(); ++j) {
const RegisteredEventListener& listener = vector[j];
if (!listener.useCapture)
- listenersArray->push(buildObjectForEventListener(listener, info.eventType, info.node));
+ (*listenersArray)->push(buildObjectForEventListener(listener, info.eventType, info.node));
}
}
-
- m_frontend->didGetEventListenersForNode(callId, nodeId, listenersArray.release());
}
void InspectorDOMAgent::addInspectedNode(long nodeId)
@@ -1006,19 +971,15 @@ void InspectorDOMAgent::didModifyDOMAttr(Element* element)
m_frontend->attributesUpdated(id, buildArrayForElementAttributes(element));
}
-void InspectorDOMAgent::getStyles(long callId, long nodeId, bool authorOnly)
+void InspectorDOMAgent::getStyles(long nodeId, bool authorOnly, RefPtr<InspectorValue>* styles)
{
Node* node = nodeForId(nodeId);
- if (!node || node->nodeType() != Node::ELEMENT_NODE) {
- m_frontend->didGetStyles(callId, InspectorValue::null());
+ if (!node || node->nodeType() != Node::ELEMENT_NODE)
return;
- }
DOMWindow* defaultView = node->ownerDocument()->defaultView();
- if (!defaultView) {
- m_frontend->didGetStyles(callId, InspectorValue::null());
+ if (!defaultView)
return;
- }
Element* element = static_cast<Element*>(node);
RefPtr<CSSComputedStyleDeclaration> computedStyleInfo = computedStyle(node, true); // Support the viewing of :visited information in computed style.
@@ -1050,41 +1011,35 @@ void InspectorDOMAgent::getStyles(long callId, long nodeId, bool authorOnly)
parentElement = parentElement->parentElement();
currentStyle = parentStyle;
}
- m_frontend->didGetStyles(callId, result.release());
+ *styles = result.release();
}
-void InspectorDOMAgent::getAllStyles(long callId)
+void InspectorDOMAgent::getAllStyles(RefPtr<InspectorArray>* styles)
{
- RefPtr<InspectorArray> result = InspectorArray::create();
for (ListHashSet<RefPtr<Document> >::iterator it = m_documents.begin(); it != m_documents.end(); ++it) {
StyleSheetList* list = (*it)->styleSheets();
for (unsigned i = 0; i < list->length(); ++i) {
StyleSheet* styleSheet = list->item(i);
if (styleSheet->isCSSStyleSheet())
- result->push(buildObjectForStyleSheet((*it).get(), static_cast<CSSStyleSheet*>(styleSheet)));
+ (*styles)->push(buildObjectForStyleSheet((*it).get(), static_cast<CSSStyleSheet*>(styleSheet)));
}
}
- m_frontend->didGetAllStyles(callId, result.release());
}
-void InspectorDOMAgent::getStyleSheet(long callId, long styleSheetId)
+void InspectorDOMAgent::getStyleSheet(long styleSheetId, RefPtr<InspectorObject>* styleSheetObject)
{
CSSStyleSheet* styleSheet = cssStore()->styleSheetForId(styleSheetId);
if (styleSheet && styleSheet->doc())
- m_frontend->didGetStyleSheet(callId, buildObjectForStyleSheet(styleSheet->doc(), styleSheet));
- else
- m_frontend->didGetStyleSheet(callId, InspectorObject::create());
+ *styleSheetObject = buildObjectForStyleSheet(styleSheet->doc(), styleSheet);
}
-void InspectorDOMAgent::getRuleRanges(long callId, long styleSheetId)
+void InspectorDOMAgent::getRuleRanges(long styleSheetId, RefPtr<InspectorValue>* ruleRange)
{
CSSStyleSheet* styleSheet = cssStore()->styleSheetForId(styleSheetId);
if (styleSheet && styleSheet->doc()) {
HashMap<long, SourceRange> ruleRanges = cssStore()->getRuleRanges(styleSheet);
- if (!ruleRanges.size()) {
- m_frontend->didGetStyleSheet(callId, InspectorObject::create());
+ if (!ruleRanges.size())
return;
- }
RefPtr<InspectorObject> result = InspectorObject::create();
for (HashMap<long, SourceRange>::iterator it = ruleRanges.begin(); it != ruleRanges.end(); ++it) {
if (it->second.second) {
@@ -1096,39 +1051,30 @@ void InspectorDOMAgent::getRuleRanges(long callId, long styleSheetId)
bodyRange->setNumber("end", it->second.second);
}
}
- m_frontend->didGetRuleRanges(callId, result);
- } else
- m_frontend->didGetRuleRanges(callId, InspectorValue::null());
+ *ruleRange = result.release();
+ }
}
-void InspectorDOMAgent::getInlineStyle(long callId, long nodeId)
+void InspectorDOMAgent::getInlineStyle(long nodeId, RefPtr<InspectorValue>* style)
{
Node* node = nodeForId(nodeId);
- if (!node || node->nodeType() != Node::ELEMENT_NODE) {
- m_frontend->didGetInlineStyle(callId, InspectorValue::null());
+ if (!node || node->nodeType() != Node::ELEMENT_NODE)
return;
- }
- Element* element = static_cast<Element*>(node);
- m_frontend->didGetInlineStyle(callId, buildObjectForStyle(element->style(), true));
+ *style = buildObjectForStyle(static_cast<Element*>(node)->style(), true);
}
-void InspectorDOMAgent::getComputedStyle(long callId, long nodeId)
+void InspectorDOMAgent::getComputedStyle(long nodeId, RefPtr<InspectorValue>* style)
{
Node* node = nodeForId(nodeId);
- if (!node || node->nodeType() != Node::ELEMENT_NODE) {
- m_frontend->didGetComputedStyle(callId, InspectorValue::null());
+ if (!node || node->nodeType() != Node::ELEMENT_NODE)
return;
- }
DOMWindow* defaultView = node->ownerDocument()->defaultView();
- if (!defaultView) {
- m_frontend->didGetComputedStyle(callId, InspectorValue::null());
+ if (!defaultView)
return;
- }
Element* element = static_cast<Element*>(node);
- RefPtr<CSSStyleDeclaration> computedStyle = defaultView->getComputedStyle(element, "");
- m_frontend->didGetComputedStyle(callId, buildObjectForStyle(computedStyle.get(), false));
+ *style = buildObjectForStyle(defaultView->getComputedStyle(element, "").get(), false);
}
PassRefPtr<InspectorObject> InspectorDOMAgent::buildObjectForAttributeStyles(Element* element)
@@ -1174,13 +1120,11 @@ PassRefPtr<InspectorArray> InspectorDOMAgent::buildArrayForPseudoElements(Elemen
return result.release();
}
-void InspectorDOMAgent::applyStyleText(long callId, long styleId, const String& styleText, const String& propertyName)
+void InspectorDOMAgent::applyStyleText(long styleId, const String& styleText, const String& propertyName, bool* success, RefPtr<InspectorValue>* styleObject, RefPtr<InspectorArray>* changedPropertiesArray)
{
CSSStyleDeclaration* style = cssStore()->styleForId(styleId);
- if (!style) {
- m_frontend->didApplyStyleText(callId, false, InspectorValue::null(), InspectorArray::create());
+ if (!style)
return;
- }
// Remove disabled property entry for property with given name.
DisabledStyleDeclaration* disabledStyle = cssStore()->disabledStyleForId(styleId, false);
@@ -1207,24 +1151,19 @@ void InspectorDOMAgent::applyStyleText(long callId, long styleId, const String&
if (!ec)
style->removeProperty(propertyName, ec);
- if (ec) {
- m_frontend->didApplyStyleText(callId, false, InspectorValue::null(), InspectorArray::create());
+ if (ec)
return;
- }
}
// Notify caller that the property was successfully deleted.
if (!styleTextLength) {
- RefPtr<InspectorArray> changedProperties = InspectorArray::create();
- changedProperties->pushString(propertyName);
- m_frontend->didApplyStyleText(callId, true, InspectorValue::null(), changedProperties.release());
+ (*changedPropertiesArray)->pushString(propertyName);
+ *success = true;
return;
}
- if (!tempStyle->length()) {
- m_frontend->didApplyStyleText(callId, false, InspectorValue::null(), InspectorArray::create());
+ if (!tempStyle->length())
return;
- }
// Iterate of the properties on the test element's style declaration and
// add them to the real style declaration. We take care to move shorthands.
@@ -1258,41 +1197,37 @@ void InspectorDOMAgent::applyStyleText(long callId, long styleId, const String&
disabledStyle->remove(name);
changedProperties.append(name);
}
- m_frontend->didApplyStyleText(callId, true, buildObjectForStyle(style, true), toArray(changedProperties));
+ *success = true;
+ *styleObject = buildObjectForStyle(style, true);
+ *changedPropertiesArray = toArray(changedProperties);
}
-void InspectorDOMAgent::setStyleText(long callId, long styleId, const String& cssText)
+void InspectorDOMAgent::setStyleText(long styleId, const String& cssText, bool* success)
{
CSSStyleDeclaration* style = cssStore()->styleForId(styleId);
- if (!style) {
- m_frontend->didSetStyleText(callId, false);
+ if (!style)
return;
- }
ExceptionCode ec = 0;
style->setCssText(cssText, ec);
- m_frontend->didSetStyleText(callId, !ec);
+ *success = !ec;
}
-void InspectorDOMAgent::setStyleProperty(long callId, long styleId, const String& name, const String& value)
+void InspectorDOMAgent::setStyleProperty(long styleId, const String& name, const String& value, bool* success)
{
CSSStyleDeclaration* style = cssStore()->styleForId(styleId);
- if (!style) {
- m_frontend->didSetStyleProperty(callId, false);
+ if (!style)
return;
- }
ExceptionCode ec = 0;
style->setProperty(name, value, ec);
- m_frontend->didSetStyleProperty(callId, !ec);
+ *success = !ec;
}
-void InspectorDOMAgent::toggleStyleEnabled(long callId, long styleId, const String& propertyName, bool disabled)
+void InspectorDOMAgent::toggleStyleEnabled(long styleId, const String& propertyName, bool disabled, RefPtr<InspectorValue>* styleObject)
{
CSSStyleDeclaration* style = cssStore()->styleForId(styleId);
- if (!style) {
- m_frontend->didToggleStyleEnabled(callId, InspectorValue::null());
+ if (!style)
return;
- }
DisabledStyleDeclaration* disabledStyle = cssStore()->disabledStyleForId(styleId, true);
@@ -1308,30 +1243,24 @@ void InspectorDOMAgent::toggleStyleEnabled(long callId, long styleId, const Stri
if (!ec)
disabledStyle->remove(propertyName);
}
- if (ec) {
- m_frontend->didToggleStyleEnabled(callId, InspectorValue::null());
+ if (ec)
return;
- }
- m_frontend->didToggleStyleEnabled(callId, buildObjectForStyle(style, true));
+ *styleObject = buildObjectForStyle(style, true);
}
-void InspectorDOMAgent::setRuleSelector(long callId, long ruleId, const String& selector, long selectedNodeId)
+void InspectorDOMAgent::setRuleSelector(long ruleId, const String& selector, long selectedNodeId, RefPtr<InspectorValue>* ruleObject, bool* selectorAffectsNode)
{
CSSStyleRule* rule = cssStore()->ruleForId(ruleId);
- if (!rule) {
- m_frontend->didSetRuleSelector(callId, InspectorValue::null(), false);
+ if (!rule)
return;
- }
Node* node = nodeForId(selectedNodeId);
CSSStyleSheet* styleSheet = rule->parentStyleSheet();
ExceptionCode ec = 0;
styleSheet->addRule(selector, rule->style()->cssText(), ec);
- if (ec) {
- m_frontend->didSetRuleSelector(callId, InspectorValue::null(), false);
+ if (ec)
return;
- }
CSSStyleRule* newRule = static_cast<CSSStyleRule*>(styleSheet->item(styleSheet->length() - 1));
for (unsigned i = 0; i < styleSheet->length(); ++i) {
@@ -1341,35 +1270,31 @@ void InspectorDOMAgent::setRuleSelector(long callId, long ruleId, const String&
}
}
- if (ec) {
- m_frontend->didSetRuleSelector(callId, InspectorValue::null(), false);
+ if (ec)
return;
- }
- m_frontend->didSetRuleSelector(callId, buildObjectForRule(node->ownerDocument(), newRule), ruleAffectsNode(newRule, node));
+ *selectorAffectsNode = ruleAffectsNode(newRule, node);
+ *ruleObject = buildObjectForRule(node->ownerDocument(), newRule);
}
-void InspectorDOMAgent::addRule(long callId, const String& selector, long selectedNodeId)
+void InspectorDOMAgent::addRule(const String& selector, long selectedNodeId, RefPtr<InspectorValue>* ruleObject, bool* selectorAffectsNode)
{
Node* node = nodeForId(selectedNodeId);
- if (!node) {
- m_frontend->didAddRule(callId, InspectorValue::null(), false);
+ if (!node)
return;
- }
- CSSStyleSheet* styleSheet = cssStore()->inspectorStyleSheet(node->ownerDocument(), true, callId);
+ CSSStyleSheet* styleSheet = cssStore()->inspectorStyleSheet(node->ownerDocument(), true);
if (!styleSheet)
return; // could not add a stylesheet to the ownerDocument
ExceptionCode ec = 0;
styleSheet->addRule(selector, "", ec);
- if (ec) {
- m_frontend->didAddRule(callId, InspectorValue::null(), false);
+ if (ec)
return;
- }
CSSStyleRule* newRule = static_cast<CSSStyleRule*>(styleSheet->item(styleSheet->length() - 1));
- m_frontend->didAddRule(callId, buildObjectForRule(node->ownerDocument(), newRule), ruleAffectsNode(newRule, node));
+ *selectorAffectsNode = ruleAffectsNode(newRule, node);
+ *ruleObject = buildObjectForRule(node->ownerDocument(), newRule);
}
PassRefPtr<InspectorObject> InspectorDOMAgent::buildObjectForStyle(CSSStyleDeclaration* style, bool bind)
@@ -1471,7 +1396,7 @@ PassRefPtr<InspectorObject> InspectorDOMAgent::buildObjectForRule(Document* owne
bool isUser = parentStyleSheet && parentStyleSheet->ownerNode() && parentStyleSheet->ownerNode()->nodeName() == "#document";
result->setBool("isUserAgent", isUserAgent);
result->setBool("isUser", isUser);
- result->setBool("isViaInspector", rule->parentStyleSheet() == cssStore()->inspectorStyleSheet(ownerDocument, false, -1));
+ result->setBool("isViaInspector", rule->parentStyleSheet() == cssStore()->inspectorStyleSheet(ownerDocument, false));
// Bind editable scripts only.
bool bind = !isUserAgent && !isUser;
@@ -1642,17 +1567,10 @@ void InspectorDOMAgent::copyNode(long nodeId)
Pasteboard::generalPasteboard()->writePlainText(markup);
}
-void InspectorDOMAgent::pushNodeByPathToFrontend(long callId, const String& path)
+void InspectorDOMAgent::pushNodeByPathToFrontend(const String& path, long* nodeId)
{
- if (!m_frontend)
- return;
-
- long id = 0;
- Node* node = nodeForPath(path);
- if (node)
- id = pushNodePathToFrontend(node);
-
- m_frontend->didPushNodeByPathToFrontend(callId, id);
+ if (Node* node = nodeForPath(path))
+ *nodeId = pushNodePathToFrontend(node);
}
} // namespace WebCore
diff --git a/WebCore/inspector/InspectorDOMAgent.h b/WebCore/inspector/InspectorDOMAgent.h
index 38b7034..bae65f5 100644
--- a/WebCore/inspector/InspectorDOMAgent.h
+++ b/WebCore/inspector/InspectorDOMAgent.h
@@ -100,32 +100,32 @@ namespace WebCore {
virtual bool operator==(const EventListener& other);
// Methods called from the frontend for DOM nodes inspection.
- void getChildNodes(long callId, long nodeId);
- void setAttribute(long callId, long elementId, const String& name, const String& value);
- void removeAttribute(long callId, long elementId, const String& name);
- void removeNode(long callId, long nodeId);
- void changeTagName(long callId, long nodeId, const String& tagName);
- void getOuterHTML(long callId, long nodeId);
- void setOuterHTML(long callId, long nodeId, const String& outerHTML);
- void setTextNodeValue(long callId, long nodeId, const String& value);
- void getEventListenersForNode(long callId, long nodeId);
+ void getChildNodes(long nodeId);
+ void setAttribute(long elementId, const String& name, const String& value, bool* success);
+ void removeAttribute(long elementId, const String& name, bool* success);
+ void removeNode(long nodeId, long* outNodeId);
+ void changeTagName(long nodeId, const String& tagName, long* newId);
+ void getOuterHTML(long nodeId, WTF::String* outerHTML);
+ void setOuterHTML(long nodeId, const String& outerHTML, long* newId);
+ void setTextNodeValue(long nodeId, const String& value, bool* success);
+ void getEventListenersForNode(long nodeId, long* outNodeId, RefPtr<InspectorArray>* listenersArray);
void addInspectedNode(long nodeId);
void performSearch(const String& whitespaceTrimmedQuery, bool runSynchronously);
void searchCanceled();
// Methods called from the frontend for CSS styles inspection.
- void getStyles(long callId, long nodeId, bool authorOnly);
- void getAllStyles(long callId);
- void getInlineStyle(long callId, long nodeId);
- void getComputedStyle(long callId, long nodeId);
- void getStyleSheet(long callId, long styleSheetId);
- void getRuleRanges(long callId, long styleSheetId);
- void applyStyleText(long callId, long styleId, const String& styleText, const String& propertyName);
- void setStyleText(long callId, long styleId, const String& cssText);
- void setStyleProperty(long callId, long styleId, const String& name, const String& value);
- void toggleStyleEnabled(long callId, long styleId, const String& propertyName, bool disabled);
- void setRuleSelector(long callId, long ruleId, const String& selector, long selectedNodeId);
- void addRule(long callId, const String& selector, long selectedNodeId);
+ void getStyles(long nodeId, bool authorOnly, RefPtr<InspectorValue>* styles);
+ void getAllStyles(RefPtr<InspectorArray>* styles);
+ void getInlineStyle(long nodeId, RefPtr<InspectorValue>* styles);
+ void getComputedStyle(long nodeId, RefPtr<InspectorValue>* styles);
+ void getStyleSheet(long styleSheetId, RefPtr<InspectorObject>* styleSheetObject);
+ void getRuleRanges(long styleSheetId, RefPtr<InspectorValue>* ruleRange);
+ void applyStyleText(long styleId, const String& styleText, const String& propertyName, bool* success, RefPtr<InspectorValue>* styleObject, RefPtr<InspectorArray>* changedProperties);
+ void setStyleText(long styleId, const String& cssText, bool* success);
+ void setStyleProperty(long styleId, const String& name, const String& value, bool* success);
+ void toggleStyleEnabled(long styleId, const String& propertyName, bool disabled, RefPtr<InspectorValue>* styleObject);
+ void setRuleSelector(long ruleId, const String& selector, long selectedNodeId, RefPtr<InspectorValue>* ruleObject, bool* selectorAffectsNode);
+ void addRule(const String& selector, long selectedNodeId, RefPtr<InspectorValue>* ruleObject, bool* selectorAffectsNode);
// Methods called from the InspectorController.
void setDocument(Document* document);
@@ -138,7 +138,7 @@ namespace WebCore {
Node* nodeForId(long nodeId);
long pushNodePathToFrontend(Node* node);
void pushChildNodesToFrontend(long nodeId);
- void pushNodeByPathToFrontend(long callId, const String& path);
+ void pushNodeByPathToFrontend(const String& path, long* nodeId);
long inspectedNode(unsigned long num);
void copyNode(long nodeId);
diff --git a/WebCore/inspector/InspectorDOMStorageResource.cpp b/WebCore/inspector/InspectorDOMStorageResource.cpp
index af0530a..61095a0 100644
--- a/WebCore/inspector/InspectorDOMStorageResource.cpp
+++ b/WebCore/inspector/InspectorDOMStorageResource.cpp
@@ -34,12 +34,11 @@
#include "InspectorDOMStorageResource.h"
-#include "Document.h"
#include "DOMWindow.h"
#include "EventNames.h"
#include "Frame.h"
-#include "InspectorFrontend.h"
-#include "ScriptObject.h"
+#include "InspectorValues.h"
+#include "RemoteInspectorFrontend.h"
#include "Storage.h"
#include "StorageEvent.h"
@@ -65,15 +64,15 @@ bool InspectorDOMStorageResource::isSameHostAndType(Frame* frame, bool isLocalSt
return equalIgnoringCase(m_frame->document()->securityOrigin()->host(), frame->document()->securityOrigin()->host()) && m_isLocalStorage == isLocalStorage;
}
-void InspectorDOMStorageResource::bind(InspectorFrontend* frontend)
+void InspectorDOMStorageResource::bind(RemoteInspectorFrontend* frontend)
{
ASSERT(!m_frontend);
m_frontend = frontend;
- ScriptObject jsonObject = frontend->newScriptObject();
- jsonObject.set("host", m_frame->document()->securityOrigin()->host());
- jsonObject.set("isLocalStorage", m_isLocalStorage);
- jsonObject.set("id", m_id);
+ RefPtr<InspectorObject> jsonObject = InspectorObject::create();
+ jsonObject->setString("host", m_frame->document()->securityOrigin()->host());
+ jsonObject->setBool("isLocalStorage", m_isLocalStorage);
+ jsonObject->setNumber("id", m_id);
frontend->addDOMStorage(jsonObject);
}
diff --git a/WebCore/inspector/InspectorDOMStorageResource.h b/WebCore/inspector/InspectorDOMStorageResource.h
index 2b18b24..a47e74c 100644
--- a/WebCore/inspector/InspectorDOMStorageResource.h
+++ b/WebCore/inspector/InspectorDOMStorageResource.h
@@ -34,8 +34,6 @@
#if ENABLE(DOM_STORAGE)
#include "EventListener.h"
-#include "ScriptObject.h"
-#include "ScriptState.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -45,7 +43,7 @@ namespace WebCore {
class Storage;
class Frame;
- class InspectorFrontend;
+ class RemoteInspectorFrontend;
class InspectorDOMStorageResource : public EventListener {
public:
@@ -58,7 +56,7 @@ namespace WebCore {
return listener->type() == InspectorDOMStorageResourceType ? static_cast<const InspectorDOMStorageResource*>(listener) : 0;
}
- void bind(InspectorFrontend* frontend);
+ void bind(RemoteInspectorFrontend* frontend);
void unbind();
void startReportingChangesToFrontend();
@@ -76,7 +74,7 @@ namespace WebCore {
RefPtr<Storage> m_domStorage;
bool m_isLocalStorage;
RefPtr<Frame> m_frame;
- InspectorFrontend* m_frontend;
+ RemoteInspectorFrontend* m_frontend;
int m_id;
bool m_reportingChangesToFrontend;
diff --git a/WebCore/inspector/InspectorDatabaseResource.cpp b/WebCore/inspector/InspectorDatabaseResource.cpp
index cec0e28..036148f 100644
--- a/WebCore/inspector/InspectorDatabaseResource.cpp
+++ b/WebCore/inspector/InspectorDatabaseResource.cpp
@@ -33,18 +33,21 @@
#if ENABLE(DATABASE) && ENABLE(INSPECTOR)
#include "Database.h"
-#include "Document.h"
-#include "Frame.h"
-#include "InspectorFrontend.h"
-#include "ScriptObject.h"
+#include "InspectorValues.h"
+#include "RemoteInspectorFrontend.h"
namespace WebCore {
-int InspectorDatabaseResource::s_nextUnusedId = 1;
+static int nextUnusedId = 1;
-InspectorDatabaseResource::InspectorDatabaseResource(Database* database, const String& domain, const String& name, const String& version)
+PassRefPtr<InspectorDatabaseResource> InspectorDatabaseResource::create(PassRefPtr<Database> database, const String& domain, const String& name, const String& version)
+{
+ return adoptRef(new InspectorDatabaseResource(database, domain, name, version));
+}
+
+InspectorDatabaseResource::InspectorDatabaseResource(PassRefPtr<Database> database, const String& domain, const String& name, const String& version)
: m_database(database)
- , m_id(s_nextUnusedId++)
+ , m_id(nextUnusedId++)
, m_domain(domain)
, m_name(name)
, m_version(version)
@@ -52,18 +55,19 @@ InspectorDatabaseResource::InspectorDatabaseResource(Database* database, const S
{
}
-void InspectorDatabaseResource::bind(InspectorFrontend* frontend)
+void InspectorDatabaseResource::bind(RemoteInspectorFrontend* frontend)
{
if (m_scriptObjectCreated)
return;
- ScriptObject jsonObject = frontend->newScriptObject();
- jsonObject.set("id", m_id);
- jsonObject.set("domain", m_domain);
- jsonObject.set("name", m_name);
- jsonObject.set("version", m_version);
- if (frontend->addDatabase(jsonObject))
- m_scriptObjectCreated = true;
+ RefPtr<InspectorObject> jsonObject = InspectorObject::create();
+ jsonObject->setNumber("id", m_id);
+ jsonObject->setString("domain", m_domain);
+ jsonObject->setString("name", m_name);
+ jsonObject->setString("version", m_version);
+
+ frontend->addDatabase(jsonObject);
+ m_scriptObjectCreated = true;
}
void InspectorDatabaseResource::unbind()
diff --git a/WebCore/inspector/InspectorDatabaseResource.h b/WebCore/inspector/InspectorDatabaseResource.h
index f82d898..8e0e1b3 100644
--- a/WebCore/inspector/InspectorDatabaseResource.h
+++ b/WebCore/inspector/InspectorDatabaseResource.h
@@ -32,41 +32,33 @@
#define InspectorDatabaseResource_h
#if ENABLE(DATABASE)
-
-#include "Database.h"
-#include "ScriptObject.h"
-#include "ScriptState.h"
-
+#include "PlatformString.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
- class InspectorFrontend;
-
- class InspectorDatabaseResource : public RefCounted<InspectorDatabaseResource> {
- public:
- static PassRefPtr<InspectorDatabaseResource> create(Database* database, const String& domain, const String& name, const String& version)
- {
- return adoptRef(new InspectorDatabaseResource(database, domain, name, version));
- }
+class Database;
+class RemoteInspectorFrontend;
+
+class InspectorDatabaseResource : public RefCounted<InspectorDatabaseResource> {
+public:
+ static PassRefPtr<InspectorDatabaseResource> create(PassRefPtr<Database> database, const String& domain, const String& name, const String& version);
- void bind(InspectorFrontend* frontend);
- void unbind();
- Database* database() { return m_database.get(); }
- long id() const { return m_id; }
- private:
- InspectorDatabaseResource(Database*, const String& domain, const String& name, const String& version);
-
- RefPtr<Database> m_database;
- int m_id;
- String m_domain;
- String m_name;
- String m_version;
- bool m_scriptObjectCreated;
+ void bind(RemoteInspectorFrontend* frontend);
+ void unbind();
+ Database* database() { return m_database.get(); }
+ long id() const { return m_id; }
+private:
+ InspectorDatabaseResource(PassRefPtr<Database>, const String& domain, const String& name, const String& version);
- static int s_nextUnusedId;
- };
+ RefPtr<Database> m_database;
+ int m_id;
+ String m_domain;
+ String m_name;
+ String m_version;
+ bool m_scriptObjectCreated;
+};
} // namespace WebCore
diff --git a/WebCore/inspector/InspectorDebuggerAgent.cpp b/WebCore/inspector/InspectorDebuggerAgent.cpp
new file mode 100644
index 0000000..b70ddbf
--- /dev/null
+++ b/WebCore/inspector/InspectorDebuggerAgent.cpp
@@ -0,0 +1,296 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InspectorDebuggerAgent.h"
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+#include "InjectedScript.h"
+#include "InjectedScriptHost.h"
+#include "InspectorValues.h"
+#include "PlatformString.h"
+#include "RemoteInspectorFrontend.h"
+#include "ScriptDebugServer.h"
+#include <wtf/MD5.h>
+
+namespace WebCore {
+
+static String formatBreakpointId(const String& sourceID, unsigned lineNumber)
+{
+ return String::format("%s:%d", sourceID.utf8().data(), lineNumber);
+}
+
+PassOwnPtr<InspectorDebuggerAgent> InspectorDebuggerAgent::create(InspectorController* inspectorController, RemoteInspectorFrontend* remoteFrontend)
+{
+ OwnPtr<InspectorDebuggerAgent> agent = adoptPtr(new InspectorDebuggerAgent(inspectorController, remoteFrontend));
+ ScriptDebugServer::shared().clearBreakpoints();
+ ScriptDebugServer::shared().addListener(agent.get(), inspectorController->inspectedPage());
+ return agent.release();
+}
+
+InspectorDebuggerAgent::InspectorDebuggerAgent(InspectorController* inspectorController, RemoteInspectorFrontend* remoteFrontend)
+ : m_inspectorController(inspectorController)
+ , m_remoteFrontend(remoteFrontend)
+ , m_pausedScriptState(0)
+ , m_breakpointsLoaded(false)
+{
+}
+
+InspectorDebuggerAgent::~InspectorDebuggerAgent()
+{
+ ScriptDebugServer::shared().removeListener(this, m_inspectorController->inspectedPage());
+ m_pausedScriptState = 0;
+}
+
+bool InspectorDebuggerAgent::isDebuggerAlwaysEnabled()
+{
+ return ScriptDebugServer::shared().isDebuggerAlwaysEnabled();
+}
+
+void InspectorDebuggerAgent::activateBreakpoints()
+{
+ ScriptDebugServer::shared().activateBreakpoints();
+}
+
+void InspectorDebuggerAgent::deactivateBreakpoints()
+{
+ ScriptDebugServer::shared().deactivateBreakpoints();
+}
+
+void InspectorDebuggerAgent::setBreakpoint(const String& sourceID, unsigned lineNumber, bool enabled, const String& condition, bool* success, unsigned int* actualLineNumber)
+{
+ ScriptBreakpoint breakpoint(enabled, condition);
+ *success = ScriptDebugServer::shared().setBreakpoint(sourceID, breakpoint, lineNumber, actualLineNumber);
+ if (!*success)
+ return;
+
+ String url = m_sourceIDToURL.get(sourceID);
+ if (url.isEmpty())
+ return;
+
+ String breakpointId = formatBreakpointId(sourceID, *actualLineNumber);
+ m_breakpointsMapping.set(breakpointId, *actualLineNumber);
+
+ String key = md5Base16(url);
+ HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(key);
+ if (it == m_stickyBreakpoints.end())
+ it = m_stickyBreakpoints.set(key, SourceBreakpoints()).first;
+ it->second.set(*actualLineNumber, breakpoint);
+ saveBreakpoints();
+}
+
+void InspectorDebuggerAgent::removeBreakpoint(const String& sourceID, unsigned lineNumber)
+{
+ ScriptDebugServer::shared().removeBreakpoint(sourceID, lineNumber);
+
+ String url = m_sourceIDToURL.get(sourceID);
+ if (url.isEmpty())
+ return;
+
+ String breakpointId = formatBreakpointId(sourceID, lineNumber);
+ HashMap<String, unsigned>::iterator mappingIt = m_breakpointsMapping.find(breakpointId);
+ if (mappingIt == m_breakpointsMapping.end())
+ return;
+ unsigned stickyLine = mappingIt->second;
+ m_breakpointsMapping.remove(mappingIt);
+
+ HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
+ if (it == m_stickyBreakpoints.end())
+ return;
+
+ it->second.remove(stickyLine);
+ saveBreakpoints();
+}
+
+void InspectorDebuggerAgent::editScriptSource(const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames)
+{
+ if ((*success = ScriptDebugServer::shared().editScriptSource(sourceID, newContent, *result)))
+ *newCallFrames = currentCallFrames();
+}
+
+void InspectorDebuggerAgent::getScriptSource(const String& sourceID, String* scriptSource)
+{
+ *scriptSource = m_scriptIDToContent.get(sourceID);
+}
+
+void InspectorDebuggerAgent::pause()
+{
+ ScriptDebugServer::shared().pause();
+}
+
+void InspectorDebuggerAgent::resume()
+{
+ ScriptDebugServer::shared().continueProgram();
+}
+
+void InspectorDebuggerAgent::stepOverStatement()
+{
+ ScriptDebugServer::shared().stepOverStatement();
+}
+
+void InspectorDebuggerAgent::stepIntoStatement()
+{
+ ScriptDebugServer::shared().stepIntoStatement();
+}
+
+void InspectorDebuggerAgent::stepOutOfFunction()
+{
+ ScriptDebugServer::shared().stepOutOfFunction();
+}
+
+void InspectorDebuggerAgent::setPauseOnExceptionsState(long pauseState)
+{
+ ScriptDebugServer::shared().setPauseOnExceptionsState(static_cast<ScriptDebugServer::PauseOnExceptionsState>(pauseState));
+ m_remoteFrontend->updatePauseOnExceptionsState(ScriptDebugServer::shared().pauseOnExceptionsState());
+}
+
+void InspectorDebuggerAgent::clearForPageNavigation()
+{
+ m_sourceIDToURL.clear();
+ m_scriptIDToContent.clear();
+ m_stickyBreakpoints.clear();
+ m_breakpointsMapping.clear();
+ m_breakpointsLoaded = false;
+}
+
+String InspectorDebuggerAgent::md5Base16(const String& string)
+{
+ static const char digits[] = "0123456789abcdef";
+
+ MD5 md5;
+ md5.addBytes(reinterpret_cast<const uint8_t*>(string.characters()), string.length() * 2);
+ Vector<uint8_t, 16> digest;
+ md5.checksum(digest);
+
+ Vector<char, 32> result;
+ for (int i = 0; i < 16; ++i) {
+ result.append(digits[(digest[i] >> 4) & 0xf]);
+ result.append(digits[digest[i] & 0xf]);
+ }
+ return String(result.data(), result.size());
+}
+
+PassRefPtr<InspectorValue> InspectorDebuggerAgent::currentCallFrames()
+{
+ if (!m_pausedScriptState)
+ return InspectorValue::null();
+ InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(m_pausedScriptState);
+ if (injectedScript.hasNoValue()) {
+ ASSERT_NOT_REACHED();
+ return InspectorValue::null();
+ }
+ return injectedScript.callFrames();
+}
+
+void InspectorDebuggerAgent::loadBreakpoints()
+{
+ if (m_breakpointsLoaded)
+ return;
+ m_breakpointsLoaded = true;
+
+ RefPtr<InspectorValue> parsedSetting = m_inspectorController->loadBreakpoints();
+ if (!parsedSetting)
+ return;
+ RefPtr<InspectorObject> breakpoints = parsedSetting->asObject();
+ if (!breakpoints)
+ return;
+ for (InspectorObject::iterator it = breakpoints->begin(); it != breakpoints->end(); ++it) {
+ RefPtr<InspectorObject> breakpointsForURL = it->second->asObject();
+ if (!breakpointsForURL)
+ continue;
+ HashMap<String, SourceBreakpoints>::iterator sourceBreakpointsIt = m_stickyBreakpoints.set(it->first, SourceBreakpoints()).first;
+ ScriptBreakpoint::sourceBreakpointsFromInspectorObject(breakpointsForURL, &sourceBreakpointsIt->second);
+ }
+}
+
+void InspectorDebuggerAgent::saveBreakpoints()
+{
+ RefPtr<InspectorObject> breakpoints = InspectorObject::create();
+ for (HashMap<String, SourceBreakpoints>::iterator it(m_stickyBreakpoints.begin()); it != m_stickyBreakpoints.end(); ++it) {
+ if (it->second.isEmpty())
+ continue;
+ RefPtr<InspectorObject> breakpointsForURL = ScriptBreakpoint::inspectorObjectFromSourceBreakpoints(it->second);
+ breakpoints->set(it->first, breakpointsForURL);
+ }
+ m_inspectorController->saveBreakpoints(breakpoints);
+}
+
+// JavaScriptDebugListener functions
+
+void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType worldType)
+{
+ // Don't send script content to the front end until it's really needed.
+ m_remoteFrontend->parsedScriptSource(sourceID, url, "", firstLine, worldType);
+
+ m_scriptIDToContent.set(sourceID, data);
+
+ if (url.isEmpty())
+ return;
+
+ loadBreakpoints();
+ HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
+ if (it != m_stickyBreakpoints.end()) {
+ for (SourceBreakpoints::iterator breakpointIt = it->second.begin(); breakpointIt != it->second.end(); ++breakpointIt) {
+ int lineNumber = breakpointIt->first;
+ if (firstLine > lineNumber)
+ continue;
+ unsigned actualLineNumber = 0;
+ bool success = ScriptDebugServer::shared().setBreakpoint(sourceID, breakpointIt->second, lineNumber, &actualLineNumber);
+ if (!success)
+ continue;
+ m_remoteFrontend->restoredBreakpoint(sourceID, url, actualLineNumber, breakpointIt->second.enabled, breakpointIt->second.condition);
+ String breakpointId = formatBreakpointId(sourceID, actualLineNumber);
+ m_breakpointsMapping.set(breakpointId, lineNumber);
+ }
+ }
+ m_sourceIDToURL.set(sourceID, url);
+}
+
+void InspectorDebuggerAgent::failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage)
+{
+ m_remoteFrontend->failedToParseScriptSource(url, data, firstLine, errorLine, errorMessage);
+}
+
+void InspectorDebuggerAgent::didPause(ScriptState* scriptState)
+{
+ ASSERT(scriptState && !m_pausedScriptState);
+ m_pausedScriptState = scriptState;
+ RefPtr<InspectorValue> callFrames = currentCallFrames();
+ m_remoteFrontend->pausedScript(callFrames.get());
+}
+
+void InspectorDebuggerAgent::didContinue()
+{
+ m_pausedScriptState = 0;
+ m_remoteFrontend->resumedScript();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
diff --git a/WebCore/inspector/InspectorDebuggerAgent.h b/WebCore/inspector/InspectorDebuggerAgent.h
new file mode 100644
index 0000000..5428eb2
--- /dev/null
+++ b/WebCore/inspector/InspectorDebuggerAgent.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorDebuggerAgent_h
+#define InspectorDebuggerAgent_h
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+#include "ScriptBreakpoint.h"
+#include "ScriptDebugListener.h"
+#include "ScriptState.h"
+#include "StringHash.h"
+#include <wtf/Forward.h>
+#include <wtf/HashMap.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+class InjectedScriptHost;
+class InspectorController;
+class InspectorValue;
+class RemoteInspectorFrontend;
+
+class InspectorDebuggerAgent : public ScriptDebugListener, public Noncopyable {
+public:
+ static PassOwnPtr<InspectorDebuggerAgent> create(InspectorController*, RemoteInspectorFrontend*);
+ virtual ~InspectorDebuggerAgent();
+
+ static bool isDebuggerAlwaysEnabled();
+
+ void activateBreakpoints();
+ void deactivateBreakpoints();
+ void setBreakpoint(const String& sourceID, unsigned lineNumber, bool enabled, const String& condition, bool* success, unsigned int* actualLineNumber);
+ void removeBreakpoint(const String& sourceID, unsigned lineNumber);
+
+ void editScriptSource(const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames);
+ void getScriptSource(const String& sourceID, String* scriptSource);
+
+ void pause();
+ void resume();
+ void stepOverStatement();
+ void stepIntoStatement();
+ void stepOutOfFunction();
+
+ void setPauseOnExceptionsState(long pauseState);
+
+ void clearForPageNavigation();
+
+ static String md5Base16(const String& string);
+
+private:
+ InspectorDebuggerAgent(InspectorController*, RemoteInspectorFrontend*);
+
+ PassRefPtr<InspectorValue> currentCallFrames();
+
+ void loadBreakpoints();
+ void saveBreakpoints();
+
+ virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType);
+ virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
+ virtual void didPause(ScriptState*);
+ virtual void didContinue();
+
+ InspectorController* m_inspectorController;
+ RemoteInspectorFrontend* m_remoteFrontend;
+ ScriptState* m_pausedScriptState;
+ HashMap<String, String> m_sourceIDToURL;
+ HashMap<String, String> m_scriptIDToContent;
+ HashMap<String, SourceBreakpoints> m_stickyBreakpoints;
+ HashMap<String, unsigned> m_breakpointsMapping;
+ bool m_breakpointsLoaded;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
+
+#endif // !defined(InspectorDebuggerAgent_h)
diff --git a/WebCore/inspector/InspectorFrontend.cpp b/WebCore/inspector/InspectorFrontend.cpp
deleted file mode 100644
index 5925741..0000000
--- a/WebCore/inspector/InspectorFrontend.cpp
+++ /dev/null
@@ -1,625 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "InspectorFrontend.h"
-
-#if ENABLE(INSPECTOR)
-
-#include "Frame.h"
-#include "InjectedScript.h"
-#include "InjectedScriptHost.h"
-#include "InspectorClient.h"
-#include "InspectorController.h"
-#include "InspectorWorkerResource.h"
-#include "Node.h"
-#include "ScriptFunctionCall.h"
-#include "ScriptObject.h"
-#include "ScriptState.h"
-#include "ScriptString.h"
-#include "ScriptValue.h"
-#include "SerializedScriptValue.h"
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
-InspectorFrontend::InspectorFrontend(ScriptObject webInspector, InspectorClient* inspectorClient)
- : m_webInspector(webInspector)
- , m_inspectorClient(inspectorClient)
-{
-}
-
-InspectorFrontend::~InspectorFrontend()
-{
- m_webInspector = ScriptObject();
-}
-
-void InspectorFrontend::close()
-{
- ScriptFunctionCall function(m_webInspector, "close");
- function.call();
-}
-
-void InspectorFrontend::inspectedPageDestroyed()
-{
- ScriptFunctionCall function(m_webInspector, "inspectedPageDestroyed");
- function.call();
-}
-
-ScriptArray InspectorFrontend::newScriptArray()
-{
- return ScriptArray::createNew(scriptState());
-}
-
-ScriptObject InspectorFrontend::newScriptObject()
-{
- return ScriptObject::createNew(scriptState());
-}
-
-void InspectorFrontend::didCommitLoad()
-{
- callSimpleFunction("didCommitLoad");
-}
-
-void InspectorFrontend::populateApplicationSettings(const String& settings)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("populateApplicationSettings");
- function.appendArgument(settings);
- function.call();
-}
-
-void InspectorFrontend::populateSessionSettings(const String& settings)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("populateSessionSettings");
- function.appendArgument(settings);
- function.call();
-}
-
-void InspectorFrontend::updateConsoleMessageExpiredCount(unsigned count)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("updateConsoleMessageExpiredCount");
- function.appendArgument(count);
- function.call();
-}
-
-void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("addConsoleMessage");
- function.appendArgument(messageObj);
- function.call();
-}
-
-void InspectorFrontend::updateConsoleMessageRepeatCount(unsigned count)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("updateConsoleMessageRepeatCount");
- function.appendArgument(count);
- function.call();
-}
-
-void InspectorFrontend::clearConsoleMessages()
-{
- callSimpleFunction("clearConsoleMessages");
-}
-
-bool InspectorFrontend::updateResource(unsigned long identifier, const ScriptObject& resourceObj)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("updateResource");
- function.appendArgument(identifier);
- function.appendArgument(resourceObj);
- bool hadException = false;
- function.call(hadException);
- return !hadException;
-}
-
-void InspectorFrontend::removeResource(unsigned long identifier)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("removeResource");
- function.appendArgument(identifier);
- function.call();
-}
-
-void InspectorFrontend::didGetResourceContent(long callId, const String& content)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didGetResourceContent");
- function.appendArgument(callId);
- function.appendArgument(content);
- function.call();
-}
-
-void InspectorFrontend::updateFocusedNode(long nodeId)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("updateFocusedNode");
- function.appendArgument(nodeId);
- function.call();
-}
-
-void InspectorFrontend::showPanel(int panel)
-{
- const char* showFunctionName;
- switch (panel) {
- case InspectorController::AuditsPanel:
- showFunctionName = "showAuditsPanel";
- break;
- case InspectorController::ConsolePanel:
- showFunctionName = "showConsolePanel";
- break;
- case InspectorController::ElementsPanel:
- showFunctionName = "showElementsPanel";
- break;
- case InspectorController::ResourcesPanel:
- showFunctionName = "showResourcesPanel";
- break;
- case InspectorController::TimelinePanel:
- showFunctionName = "showTimelinePanel";
- break;
- case InspectorController::ProfilesPanel:
- showFunctionName = "showProfilesPanel";
- break;
- case InspectorController::ScriptsPanel:
- showFunctionName = "showScriptsPanel";
- break;
- case InspectorController::StoragePanel:
- showFunctionName = "showStoragePanel";
- break;
- default:
- ASSERT_NOT_REACHED();
- showFunctionName = 0;
- }
-
- if (showFunctionName)
- callSimpleFunction(showFunctionName);
-}
-
-void InspectorFrontend::populateInterface()
-{
- callSimpleFunction("populateInterface");
-}
-
-void InspectorFrontend::reset()
-{
- callSimpleFunction("reset");
-}
-
-void InspectorFrontend::resetProfilesPanel()
-{
- callSimpleFunction("resetProfilesPanel");
-}
-
-void InspectorFrontend::bringToFront()
-{
- callSimpleFunction("bringToFront");
-}
-
-void InspectorFrontend::inspectedURLChanged(const String& url)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("inspectedURLChanged");
- function.appendArgument(url);
- function.call();
-}
-
-void InspectorFrontend::resourceTrackingWasEnabled()
-{
- callSimpleFunction("resourceTrackingWasEnabled");
-}
-
-void InspectorFrontend::resourceTrackingWasDisabled()
-{
- callSimpleFunction("resourceTrackingWasDisabled");
-}
-
-void InspectorFrontend::searchingForNodeWasEnabled()
-{
- callSimpleFunction("searchingForNodeWasEnabled");
-}
-
-void InspectorFrontend::searchingForNodeWasDisabled()
-{
- callSimpleFunction("searchingForNodeWasDisabled");
-}
-
-void InspectorFrontend::monitoringXHRWasEnabled()
-{
- callSimpleFunction("monitoringXHRWasEnabled");
-}
-
-void InspectorFrontend::monitoringXHRWasDisabled()
-{
- callSimpleFunction("monitoringXHRWasDisabled");
-}
-
-void InspectorFrontend::updatePauseOnExceptionsState(long state)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("updatePauseOnExceptionsState");
- function.appendArgument(state);
- function.call();
-}
-
-void InspectorFrontend::timelineProfilerWasStarted()
-{
- callSimpleFunction("timelineProfilerWasStarted");
-}
-
-void InspectorFrontend::timelineProfilerWasStopped()
-{
- callSimpleFunction("timelineProfilerWasStopped");
-}
-
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-void InspectorFrontend::attachDebuggerWhenShown()
-{
- callSimpleFunction("attachDebuggerWhenShown");
-}
-
-void InspectorFrontend::debuggerWasEnabled()
-{
- callSimpleFunction("debuggerWasEnabled");
-}
-
-void InspectorFrontend::debuggerWasDisabled()
-{
- callSimpleFunction("debuggerWasDisabled");
-}
-
-void InspectorFrontend::didSetBreakpoint(long callId, bool success, unsigned line)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didSetBreakpoint");
- function.appendArgument(callId);
- function.appendArgument(success);
- function.appendArgument(line);
- function.call();
-}
-
-void InspectorFrontend::parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine, int scriptWorldType)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("parsedScriptSource");
- function.appendArgument(sourceID);
- function.appendArgument(url);
- function.appendArgument(data);
- function.appendArgument(firstLine);
- function.appendArgument(scriptWorldType);
- function.call();
-}
-
-void InspectorFrontend::restoredBreakpoint(const String& sourceID, const String& url, int line, bool enabled, const String& condition)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("restoredBreakpoint");
- function.appendArgument(sourceID);
- function.appendArgument(url);
- function.appendArgument(line);
- function.appendArgument(enabled);
- function.appendArgument(condition);
- function.call();
-}
-
-void InspectorFrontend::failedToParseScriptSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("failedToParseScriptSource");
- function.appendArgument(url);
- function.appendArgument(data);
- function.appendArgument(firstLine);
- function.appendArgument(errorLine);
- function.appendArgument(errorMessage);
- function.call();
-}
-
-void InspectorFrontend::pausedScript(SerializedScriptValue* callFrames)
-{
- ScriptValue callFramesValue = ScriptValue::deserialize(scriptState(), callFrames);
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("pausedScript");
- function.appendArgument(callFramesValue);
- function.call();
-}
-
-void InspectorFrontend::resumedScript()
-{
- callSimpleFunction("resumedScript");
-}
-
-void InspectorFrontend::didEditScriptSource(long callId, bool success, const String& result, SerializedScriptValue* newCallFrames)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didEditScriptSource");
- function.appendArgument(callId);
- function.appendArgument(success);
- function.appendArgument(result);
- if (success && newCallFrames) {
- ScriptValue newCallFramesValue = ScriptValue::deserialize(scriptState(), newCallFrames);
- ASSERT(!newCallFramesValue .hasNoValue());
- function.appendArgument(newCallFramesValue);
- }
- function.call();
-}
-
-void InspectorFrontend::didGetScriptSource(long callId, const String& result)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didGetScriptSource");
- function.appendArgument(callId);
- function.appendArgument(result);
- function.call();
-}
-
-void InspectorFrontend::profilerWasEnabled()
-{
- callSimpleFunction("profilerWasEnabled");
-}
-
-void InspectorFrontend::profilerWasDisabled()
-{
- callSimpleFunction("profilerWasDisabled");
-}
-
-void InspectorFrontend::addProfileHeader(const ScriptValue& profile)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("addProfileHeader");
- function.appendArgument(profile);
- function.call();
-}
-
-void InspectorFrontend::setRecordingProfile(bool isProfiling)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("setRecordingProfile");
- function.appendArgument(isProfiling);
- function.call();
-}
-
-void InspectorFrontend::didGetProfileHeaders(long callId, const ScriptArray& headers)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didGetProfileHeaders");
- function.appendArgument(callId);
- function.appendArgument(headers);
- function.call();
-}
-
-void InspectorFrontend::didGetProfile(long callId, const ScriptValue& profile)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didGetProfile");
- function.appendArgument(callId);
- function.appendArgument(profile);
- function.call();
-}
-#endif
-
-void InspectorFrontend::didPushNodeByPathToFrontend(long callId, long nodeId)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didPushNodeByPathToFrontend");
- function.appendArgument(callId);
- function.appendArgument(nodeId);
- function.call();
-}
-
-#if ENABLE(WORKERS)
-void InspectorFrontend::didCreateWorker(const InspectorWorkerResource& worker)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didCreateWorker");
- function.appendArgument(worker.id());
- function.appendArgument(worker.url());
- function.appendArgument(worker.isSharedWorker());
- function.call();
-}
-
-void InspectorFrontend::didDestroyWorker(const InspectorWorkerResource& worker)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didDestroyWorker");
- function.appendArgument(worker.id());
- function.call();
-}
-#endif // ENABLE(WORKERS)
-
-void InspectorFrontend::didGetCookies(long callId, const ScriptArray& cookies, const String& cookiesString)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didGetCookies");
- function.appendArgument(callId);
- function.appendArgument(cookies);
- function.appendArgument(cookiesString);
- function.call();
-}
-
-void InspectorFrontend::didDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didDispatchOnInjectedScript");
- function.appendArgument(callId);
- if (isException)
- function.appendArgument("");
- else {
- ScriptValue resultValue = ScriptValue::deserialize(scriptState(), result);
- function.appendArgument(resultValue);
- }
- function.appendArgument(isException);
- function.call();
-}
-
-#if ENABLE(DATABASE)
-bool InspectorFrontend::addDatabase(const ScriptObject& dbObject)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("addDatabase");
- function.appendArgument(dbObject);
- bool hadException = false;
- function.call(hadException);
- return !hadException;
-}
-
-void InspectorFrontend::selectDatabase(int databaseId)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("selectDatabase");
- function.appendArgument(databaseId);
- function.call();
-}
-
-void InspectorFrontend::didGetDatabaseTableNames(long callId, const ScriptArray& tableNames)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didGetDatabaseTableNames");
- function.appendArgument(callId);
- function.appendArgument(tableNames);
- function.call();
-}
-#endif
-
-#if ENABLE(DOM_STORAGE)
-bool InspectorFrontend::addDOMStorage(const ScriptObject& domStorageObj)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("addDOMStorage");
- function.appendArgument(domStorageObj);
- bool hadException = false;
- function.call(hadException);
- return !hadException;
-}
-
-void InspectorFrontend::selectDOMStorage(long storageId)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("selectDOMStorage");
- function.appendArgument(storageId);
- function.call();
-}
-
-void InspectorFrontend::didGetDOMStorageEntries(long callId, const ScriptArray& entries)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didGetDOMStorageEntries");
- function.appendArgument(callId);
- function.appendArgument(entries);
- function.call();
-}
-
-void InspectorFrontend::didSetDOMStorageItem(long callId, bool success)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didSetDOMStorageItem");
- function.appendArgument(callId);
- function.appendArgument(success);
- function.call();
-}
-
-void InspectorFrontend::didRemoveDOMStorageItem(long callId, bool success)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didRemoveDOMStorageItem");
- function.appendArgument(callId);
- function.appendArgument(success);
- function.call();
-}
-
-void InspectorFrontend::updateDOMStorage(long storageId)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("updateDOMStorage");
- function.appendArgument(storageId);
- function.call();
-}
-#endif
-
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
-void InspectorFrontend::didGetApplicationCaches(long callId, const ScriptValue& applicationCaches)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("didGetApplicationCaches");
- function.appendArgument(callId);
- function.appendArgument(applicationCaches);
- function.call();
-}
-
-void InspectorFrontend::updateApplicationCacheStatus(int status)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("updateApplicationCacheStatus");
- function.appendArgument(status);
- function.call();
-}
-
-void InspectorFrontend::updateNetworkState(bool isNowOnline)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("updateNetworkState");
- function.appendArgument(isNowOnline);
- function.call();
-}
-#endif
-
-void InspectorFrontend::contextMenuItemSelected(int itemId)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("contextMenuItemSelected");
- function.appendArgument(itemId);
- function.call();
-}
-
-void InspectorFrontend::contextMenuCleared()
-{
- callSimpleFunction("contextMenuCleared");
-}
-
-void InspectorFrontend::evaluateForTestInFrontend(long callId, const String& script)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument("evaluateForTestInFrontend");
- function.appendArgument(callId);
- function.appendArgument(script);
- function.call();
-}
-
-void InspectorFrontend::callSimpleFunction(const String& functionName)
-{
- ScriptFunctionCall function(m_webInspector, "dispatch");
- function.appendArgument(functionName);
- function.call();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InspectorFrontend.h b/WebCore/inspector/InspectorFrontend.h
deleted file mode 100644
index e6567be..0000000
--- a/WebCore/inspector/InspectorFrontend.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef InspectorFrontend_h
-#define InspectorFrontend_h
-
-#include "InspectorValues.h"
-#include "ScriptArray.h"
-#include "ScriptObject.h"
-#include "ScriptState.h"
-#include <wtf/PassOwnPtr.h>
-
-namespace WebCore {
- class ConsoleMessage;
- class Database;
- class Frame;
- class InspectorClient;
- class InspectorResource;
- class InspectorWorkerResource;
- class Node;
- class ScriptString;
- class SerializedScriptValue;
- class Storage;
-
- class InspectorFrontend : public Noncopyable {
- public:
- // We are in transition from JS transport via webInspector to native
- // transport via inspectorClient. After migration, webInspector parameter should
- // be removed.
- InspectorFrontend(ScriptObject webInspector, InspectorClient* inspectorClient);
- ~InspectorFrontend();
-
- void close();
- void inspectedPageDestroyed();
-
- ScriptArray newScriptArray();
- ScriptObject newScriptObject();
-
- void didCommitLoad();
-
- void populateApplicationSettings(const String& settings);
- void populateSessionSettings(const String& settings);
-
- void updateConsoleMessageExpiredCount(unsigned count);
- void addConsoleMessage(const ScriptObject& messageObj);
- void updateConsoleMessageRepeatCount(unsigned count);
- void clearConsoleMessages();
-
- bool updateResource(unsigned long identifier, const ScriptObject& resourceObj);
- void removeResource(unsigned long identifier);
- void didGetResourceContent(long callId, const String& content);
-
- void updateFocusedNode(long nodeId);
- void showPanel(int panel);
- void populateInterface();
- void reset();
- void resetProfilesPanel();
-
- void bringToFront();
- void inspectedURLChanged(const String&);
-
- void resourceTrackingWasEnabled();
- void resourceTrackingWasDisabled();
-
- void searchingForNodeWasEnabled();
- void searchingForNodeWasDisabled();
-
- void monitoringXHRWasEnabled();
- void monitoringXHRWasDisabled();
-
- void updatePauseOnExceptionsState(long state);
-
-#if ENABLE(JAVASCRIPT_DEBUGGER)
- void attachDebuggerWhenShown();
- void debuggerWasEnabled();
- void debuggerWasDisabled();
-
- void didSetBreakpoint(long callId, bool success, unsigned line);
-
- void parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine, int scriptWorldType);
- void restoredBreakpoint(const String& sourceID, const String& url, int line, bool enabled, const String& condition);
- void failedToParseScriptSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
- void pausedScript(SerializedScriptValue* callFrames);
- void resumedScript();
-
- void didEditScriptSource(long callId, bool success, const String& result, SerializedScriptValue* newCallFrames);
- void didGetScriptSource(long callId, const String& result);
-
- void profilerWasEnabled();
- void profilerWasDisabled();
- void addProfileHeader(const ScriptValue& profile);
- void setRecordingProfile(bool isProfiling);
- void didGetProfileHeaders(long callId, const ScriptArray& headers);
- void didGetProfile(long callId, const ScriptValue& profile);
-#endif
-
-#if ENABLE(DATABASE)
- bool addDatabase(const ScriptObject& dbObj);
- void selectDatabase(int databaseId);
- void didGetDatabaseTableNames(long callId, const ScriptArray& tableNames);
-#endif
-
-#if ENABLE(DOM_STORAGE)
- bool addDOMStorage(const ScriptObject& domStorageObj);
- void selectDOMStorage(long storageId);
- void didGetDOMStorageEntries(long callId, const ScriptArray& entries);
- void didSetDOMStorageItem(long callId, bool success);
- void didRemoveDOMStorageItem(long callId, bool success);
- void updateDOMStorage(long storageId);
-#endif
-
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
- void updateApplicationCacheStatus(int status);
- void updateNetworkState(bool isNowOnline);
- void didGetApplicationCaches(long callId, const ScriptValue& applicationCaches);
-#endif
-
- void didPushNodeByPathToFrontend(long callId, long nodeId);
-
- void timelineProfilerWasStarted();
- void timelineProfilerWasStopped();
-
-#if ENABLE(WORKERS)
- void didCreateWorker(const InspectorWorkerResource&);
- void didDestroyWorker(const InspectorWorkerResource&);
-#endif // ENABLE(WORKER)
-
- void didGetCookies(long callId, const ScriptArray& cookies, const String& cookiesString);
- void didDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException);
-
- void contextMenuItemSelected(int itemId);
- void contextMenuCleared();
-
- ScriptState* scriptState() const { return m_webInspector.scriptState(); }
-
- void evaluateForTestInFrontend(long callId, const String& script);
-
- private:
- void callSimpleFunction(const String& functionName);
- ScriptObject m_webInspector;
- InspectorClient* m_inspectorClient;
- };
-
-} // namespace WebCore
-
-#endif // !defined(InspectorFrontend_h)
diff --git a/WebCore/inspector/InspectorFrontendClient.h b/WebCore/inspector/InspectorFrontendClient.h
index c20eb10..cbbbc53 100644
--- a/WebCore/inspector/InspectorFrontendClient.h
+++ b/WebCore/inspector/InspectorFrontendClient.h
@@ -31,13 +31,13 @@
#ifndef InspectorFrontendClient_h
#define InspectorFrontendClient_h
+#include <wtf/Forward.h>
#include <wtf/Vector.h>
namespace WebCore {
class ContextMenuItem;
class Event;
-class String;
class InspectorFrontendClient {
public:
diff --git a/WebCore/inspector/InspectorFrontendClientLocal.cpp b/WebCore/inspector/InspectorFrontendClientLocal.cpp
index f6f7811..b45dd34 100644
--- a/WebCore/inspector/InspectorFrontendClientLocal.cpp
+++ b/WebCore/inspector/InspectorFrontendClientLocal.cpp
@@ -39,7 +39,6 @@
#include "FrameView.h"
#include "InspectorBackendDispatcher.h"
#include "InspectorController.h"
-#include "InspectorFrontend.h"
#include "InspectorFrontendHost.h"
#include "Page.h"
#include "PlatformString.h"
@@ -80,14 +79,7 @@ void InspectorFrontendClientLocal::windowObjectCleared()
void InspectorFrontendClientLocal::frontendLoaded()
{
bringToFront();
- // Create InspectorFrontend and set it to InspectorController.
- ASSERT(m_frontendScriptState);
- ScriptObject webInspectorObj;
- if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) {
- ASSERT_NOT_REACHED();
- return;
- }
- m_inspectorController->connectFrontend(webInspectorObj);
+ m_inspectorController->connectFrontend();
}
void InspectorFrontendClientLocal::requestAttachWindow()
diff --git a/WebCore/inspector/InspectorFrontendHost.cpp b/WebCore/inspector/InspectorFrontendHost.cpp
index 0dacde6..f9bf176 100644
--- a/WebCore/inspector/InspectorFrontendHost.cpp
+++ b/WebCore/inspector/InspectorFrontendHost.cpp
@@ -195,9 +195,7 @@ void InspectorFrontendHost::moveWindowBy(float x, float y) const
void InspectorFrontendHost::setExtensionAPI(const String& script)
{
InspectorController* inspector = m_frontendPage->inspectorController();
-
- inspector->removeAllScriptsToEvaluateOnLoad();
- inspector->addScriptToEvaluateOnLoad(script);
+ inspector->setInspectorExtensionAPI(script);
}
String InspectorFrontendHost::localizedStringsURL()
diff --git a/WebCore/inspector/InspectorResource.cpp b/WebCore/inspector/InspectorResource.cpp
index 69618c3..9259d79 100644
--- a/WebCore/inspector/InspectorResource.cpp
+++ b/WebCore/inspector/InspectorResource.cpp
@@ -38,12 +38,12 @@
#include "DocLoader.h"
#include "DocumentLoader.h"
#include "Frame.h"
-#include "InspectorFrontend.h"
+#include "InspectorValues.h"
+#include "RemoteInspectorFrontend.h"
#include "ResourceLoadTiming.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "TextEncoding.h"
-#include "ScriptObject.h"
namespace WebCore {
@@ -146,80 +146,100 @@ void InspectorResource::updateResponse(const ResourceResponse& response)
m_changes.set(TypeChange);
}
-static void populateHeadersObject(ScriptObject* object, const HTTPHeaderMap& headers)
+static PassRefPtr<InspectorObject> buildHeadersObject(const HTTPHeaderMap& headers)
{
+ RefPtr<InspectorObject> object = InspectorObject::create();
HTTPHeaderMap::const_iterator end = headers.end();
for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it) {
- object->set(it->first.string(), it->second);
+ object->setString(it->first.string(), it->second);
}
+ return object;
}
-void InspectorResource::updateScriptObject(InspectorFrontend* frontend)
+static PassRefPtr<InspectorObject> buildObjectForTiming(ResourceLoadTiming* timing)
+{
+ RefPtr<InspectorObject> jsonObject = InspectorObject::create();
+ jsonObject->setNumber("requestTime", timing->requestTime);
+ jsonObject->setNumber("proxyStart", timing->proxyStart);
+ jsonObject->setNumber("proxyEnd", timing->proxyEnd);
+ jsonObject->setNumber("dnsStart", timing->dnsStart);
+ jsonObject->setNumber("dnsEnd", timing->dnsEnd);
+ jsonObject->setNumber("connectStart", timing->connectStart);
+ jsonObject->setNumber("connectEnd", timing->connectEnd);
+ jsonObject->setNumber("sslStart", timing->sslStart);
+ jsonObject->setNumber("sslEnd", timing->sslEnd);
+ jsonObject->setNumber("sendStart", timing->sendStart);
+ jsonObject->setNumber("sendEnd", timing->sendEnd);
+ jsonObject->setNumber("receiveHeadersEnd", timing->receiveHeadersEnd);
+ return jsonObject;
+}
+
+
+void InspectorResource::updateScriptObject(RemoteInspectorFrontend* frontend)
{
if (m_changes.hasChange(NoChange))
return;
- ScriptObject jsonObject = frontend->newScriptObject();
+ RefPtr<InspectorObject> jsonObject = InspectorObject::create();
+ jsonObject->setNumber("id", m_identifier);
if (m_changes.hasChange(RequestChange)) {
- jsonObject.set("url", m_requestURL.string());
- jsonObject.set("documentURL", m_frame->document()->url().string());
- jsonObject.set("host", m_requestURL.host());
- jsonObject.set("path", m_requestURL.path());
- jsonObject.set("lastPathComponent", m_requestURL.lastPathComponent());
- ScriptObject requestHeaders = frontend->newScriptObject();
- populateHeadersObject(&requestHeaders, m_requestHeaderFields);
- jsonObject.set("requestHeaders", requestHeaders);
- jsonObject.set("mainResource", m_isMainResource);
- jsonObject.set("requestMethod", m_requestMethod);
- jsonObject.set("requestFormData", m_requestFormData);
- jsonObject.set("didRequestChange", true);
+ jsonObject->setString("url", m_requestURL.string());
+ jsonObject->setString("documentURL", m_frame->document()->url().string());
+ jsonObject->setString("host", m_requestURL.host());
+ jsonObject->setString("path", m_requestURL.path());
+ jsonObject->setString("lastPathComponent", m_requestURL.lastPathComponent());
+ RefPtr<InspectorObject> requestHeaders = buildHeadersObject(m_requestHeaderFields);
+ jsonObject->set("requestHeaders", requestHeaders);
+ jsonObject->setBool("mainResource", m_isMainResource);
+ jsonObject->setString("requestMethod", m_requestMethod);
+ jsonObject->setString("requestFormData", m_requestFormData);
+ jsonObject->setBool("didRequestChange", true);
}
if (m_changes.hasChange(ResponseChange)) {
- jsonObject.set("mimeType", m_mimeType);
- jsonObject.set("suggestedFilename", m_suggestedFilename);
- jsonObject.set("expectedContentLength", m_expectedContentLength);
- jsonObject.set("statusCode", m_responseStatusCode);
- jsonObject.set("statusText", m_responseStatusText);
- ScriptObject responseHeaders = frontend->newScriptObject();
- populateHeadersObject(&responseHeaders, m_responseHeaderFields);
- jsonObject.set("responseHeaders", responseHeaders);
- jsonObject.set("connectionID", m_connectionID);
- jsonObject.set("connectionReused", m_connectionReused);
- jsonObject.set("cached", m_cached);
+ jsonObject->setString("mimeType", m_mimeType);
+ jsonObject->setString("suggestedFilename", m_suggestedFilename);
+ jsonObject->setNumber("expectedContentLength", m_expectedContentLength);
+ jsonObject->setNumber("statusCode", m_responseStatusCode);
+ jsonObject->setString("statusText", m_responseStatusText);
+ RefPtr<InspectorObject> responseHeaders = buildHeadersObject(m_responseHeaderFields);
+ jsonObject->set("responseHeaders", responseHeaders);
+ jsonObject->setNumber("connectionID", m_connectionID);
+ jsonObject->setBool("connectionReused", m_connectionReused);
+ jsonObject->setBool("cached", m_cached);
if (m_loadTiming && !m_cached)
- jsonObject.set("timing", buildObjectForTiming(frontend, m_loadTiming.get()));
- jsonObject.set("didResponseChange", true);
+ jsonObject->set("timing", buildObjectForTiming(m_loadTiming.get()));
+ jsonObject->setBool("didResponseChange", true);
}
if (m_changes.hasChange(TypeChange)) {
- jsonObject.set("type", static_cast<int>(type()));
- jsonObject.set("didTypeChange", true);
+ jsonObject->setNumber("type", static_cast<int>(type()));
+ jsonObject->setBool("didTypeChange", true);
}
if (m_changes.hasChange(LengthChange)) {
- jsonObject.set("resourceSize", m_length);
- jsonObject.set("didLengthChange", true);
+ jsonObject->setNumber("resourceSize", m_length);
+ jsonObject->setBool("didLengthChange", true);
}
if (m_changes.hasChange(CompletionChange)) {
- jsonObject.set("failed", m_failed);
- jsonObject.set("finished", m_finished);
- jsonObject.set("didCompletionChange", true);
+ jsonObject->setBool("failed", m_failed);
+ jsonObject->setBool("finished", m_finished);
+ jsonObject->setBool("didCompletionChange", true);
}
if (m_changes.hasChange(TimingChange)) {
if (m_startTime > 0)
- jsonObject.set("startTime", m_startTime);
+ jsonObject->setNumber("startTime", m_startTime);
if (m_responseReceivedTime > 0)
- jsonObject.set("responseReceivedTime", m_responseReceivedTime);
+ jsonObject->setNumber("responseReceivedTime", m_responseReceivedTime);
if (m_endTime > 0)
- jsonObject.set("endTime", m_endTime);
+ jsonObject->setNumber("endTime", m_endTime);
if (m_loadEventTime > 0)
- jsonObject.set("loadEventTime", m_loadEventTime);
+ jsonObject->setNumber("loadEventTime", m_loadEventTime);
if (m_domContentEventTime > 0)
- jsonObject.set("domContentEventTime", m_domContentEventTime);
- jsonObject.set("didTimingChange", true);
+ jsonObject->setNumber("domContentEventTime", m_domContentEventTime);
+ jsonObject->setBool("didTimingChange", true);
}
if (m_changes.hasChange(RedirectsChange)) {
@@ -227,11 +247,11 @@ void InspectorResource::updateScriptObject(InspectorFrontend* frontend)
m_redirects[i]->updateScriptObject(frontend);
}
- if (frontend->updateResource(m_identifier, jsonObject))
- m_changes.clearAll();
+ frontend->updateResource(jsonObject);
+ m_changes.clearAll();
}
-void InspectorResource::releaseScriptObject(InspectorFrontend* frontend)
+void InspectorResource::releaseScriptObject(RemoteInspectorFrontend* frontend)
{
m_changes.setAll();
@@ -390,24 +410,6 @@ void InspectorResource::addLength(int lengthReceived)
m_changes.set(TimingChange);
}
-ScriptObject InspectorResource::buildObjectForTiming(InspectorFrontend* frontend, ResourceLoadTiming* timing)
-{
- ScriptObject jsonObject = frontend->newScriptObject();
- jsonObject.set("requestTime", timing->requestTime);
- jsonObject.set("proxyStart", timing->proxyStart);
- jsonObject.set("proxyEnd", timing->proxyEnd);
- jsonObject.set("dnsStart", timing->dnsStart);
- jsonObject.set("dnsEnd", timing->dnsEnd);
- jsonObject.set("connectStart", timing->connectStart);
- jsonObject.set("connectEnd", timing->connectEnd);
- jsonObject.set("sslStart", timing->sslStart);
- jsonObject.set("sslEnd", timing->sslEnd);
- jsonObject.set("sendStart", timing->sendStart);
- jsonObject.set("sendEnd", timing->sendEnd);
- jsonObject.set("receiveHeadersEnd", timing->receiveHeadersEnd);
- return jsonObject;
-}
-
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InspectorResource.h b/WebCore/inspector/InspectorResource.h
index 48e1a20..4c12ea0 100644
--- a/WebCore/inspector/InspectorResource.h
+++ b/WebCore/inspector/InspectorResource.h
@@ -33,8 +33,6 @@
#include "HTTPHeaderMap.h"
#include "KURL.h"
-#include "ScriptObject.h"
-#include "ScriptState.h"
#include "ScriptString.h"
#include <wtf/CurrentTime.h>
@@ -47,8 +45,8 @@ namespace WebCore {
class CachedResource;
class DocumentLoader;
- class InspectorFrontend;
class Frame;
+ class RemoteInspectorFrontend;
class ResourceLoadTiming;
class ResourceRequest;
class ResourceResponse;
@@ -78,8 +76,8 @@ namespace WebCore {
~InspectorResource();
PassRefPtr<InspectorResource> appendRedirect(unsigned long identifier, const KURL& redirectURL);
- void updateScriptObject(InspectorFrontend* frontend);
- void releaseScriptObject(InspectorFrontend* frontend);
+ void updateScriptObject(RemoteInspectorFrontend* frontend);
+ void releaseScriptObject(RemoteInspectorFrontend* frontend);
void updateRequest(const ResourceRequest&);
void updateResponse(const ResourceResponse&);
@@ -151,8 +149,6 @@ namespace WebCore {
Type cachedResourceType() const;
CachedResource* cachedResource() const;
- ScriptObject buildObjectForTiming(InspectorFrontend*, ResourceLoadTiming*);
-
unsigned long m_identifier;
RefPtr<DocumentLoader> m_loader;
RefPtr<Frame> m_frame;
diff --git a/WebCore/inspector/InspectorStorageAgent.cpp b/WebCore/inspector/InspectorStorageAgent.cpp
new file mode 100644
index 0000000..f95b392
--- /dev/null
+++ b/WebCore/inspector/InspectorStorageAgent.cpp
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "InspectorStorageAgent.h"
+
+#if ENABLE(INSPECTOR) && ENABLE(DATABASE)
+
+#include "Database.h"
+#include "ExceptionCode.h"
+#include "InspectorValues.h"
+#include "SQLError.h"
+#include "SQLStatementCallback.h"
+#include "SQLStatementErrorCallback.h"
+#include "SQLResultSetRowList.h"
+#include "SQLTransaction.h"
+#include "SQLTransactionCallback.h"
+#include "SQLTransactionErrorCallback.h"
+#include "SQLValue.h"
+#include "RemoteInspectorFrontend.h"
+#include "VoidCallback.h"
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+namespace {
+
+long lastTransactionId = 0;
+
+void reportTransactionFailed(InspectorStorageAgent* agent, long transactionId, SQLError* error)
+{
+ if (!agent->frontend())
+ return;
+ RefPtr<InspectorObject> errorObject = InspectorObject::create();
+ errorObject->setString("message", error->message());
+ errorObject->setNumber("code", error->code());
+ agent->frontend()->sqlTransactionFailed(transactionId, errorObject);
+}
+
+class StatementCallback : public SQLStatementCallback {
+public:
+ static PassRefPtr<StatementCallback> create(long transactionId, PassRefPtr<InspectorStorageAgent> agent)
+ {
+ return adoptRef(new StatementCallback(transactionId, agent));
+ }
+
+ virtual ~StatementCallback() { }
+
+ virtual bool handleEvent(SQLTransaction*, SQLResultSet* resultSet)
+ {
+ if (!m_agent->frontend())
+ return true;
+
+ SQLResultSetRowList* rowList = resultSet->rows();
+
+ RefPtr<InspectorArray> columnNames = InspectorArray::create();
+ const Vector<String>& columns = rowList->columnNames();
+ for (size_t i = 0; i < columns.size(); ++i)
+ columnNames->pushString(columns[i]);
+
+ RefPtr<InspectorArray> values = InspectorArray::create();
+ const Vector<SQLValue>& data = rowList->values();
+ for (size_t i = 0; i < data.size(); ++i) {
+ const SQLValue& value = rowList->values()[i];
+ switch (value.type()) {
+ case SQLValue::StringValue: values->pushString(value.string()); break;
+ case SQLValue::NumberValue: values->pushNumber(value.number()); break;
+ case SQLValue::NullValue: values->push(InspectorValue::null()); break;
+ }
+ }
+ m_agent->frontend()->sqlTransactionSucceeded(m_transactionId, columnNames, values);
+ return true;
+ }
+
+private:
+ StatementCallback(long transactionId, PassRefPtr<InspectorStorageAgent> agent)
+ : m_transactionId(transactionId)
+ , m_agent(agent) { }
+ long m_transactionId;
+ RefPtr<InspectorStorageAgent> m_agent;
+};
+
+class StatementErrorCallback : public SQLStatementErrorCallback {
+public:
+ static PassRefPtr<StatementErrorCallback> create(long transactionId, PassRefPtr<InspectorStorageAgent> agent)
+ {
+ return adoptRef(new StatementErrorCallback(transactionId, agent));
+ }
+
+ virtual ~StatementErrorCallback() { }
+
+ virtual bool handleEvent(SQLTransaction*, SQLError* error)
+ {
+ reportTransactionFailed(m_agent.get(), m_transactionId, error);
+ return true;
+ }
+
+private:
+ StatementErrorCallback(long transactionId, RefPtr<InspectorStorageAgent> agent)
+ : m_transactionId(transactionId)
+ , m_agent(agent) { }
+ long m_transactionId;
+ RefPtr<InspectorStorageAgent> m_agent;
+};
+
+class TransactionCallback : public SQLTransactionCallback {
+public:
+ static PassRefPtr<TransactionCallback> create(const String& sqlStatement, long transactionId, PassRefPtr<InspectorStorageAgent> agent)
+ {
+ return adoptRef(new TransactionCallback(sqlStatement, transactionId, agent));
+ }
+
+ virtual ~TransactionCallback() { }
+
+ virtual bool handleEvent(SQLTransaction* transaction)
+ {
+ if (!m_agent->frontend())
+ return true;
+
+ Vector<SQLValue> sqlValues;
+ RefPtr<SQLStatementCallback> callback(StatementCallback::create(m_transactionId, m_agent));
+ RefPtr<SQLStatementErrorCallback> errorCallback(StatementErrorCallback::create(m_transactionId, m_agent));
+ ExceptionCode ec = 0;
+ transaction->executeSQL(m_sqlStatement, sqlValues, callback.release(), errorCallback.release(), ec);
+ return true;
+ }
+private:
+ TransactionCallback(const String& sqlStatement, long transactionId, PassRefPtr<InspectorStorageAgent> agent)
+ : m_sqlStatement(sqlStatement)
+ , m_transactionId(transactionId)
+ , m_agent(agent) { }
+ String m_sqlStatement;
+ long m_transactionId;
+ RefPtr<InspectorStorageAgent> m_agent;
+};
+
+class TransactionErrorCallback : public SQLTransactionErrorCallback {
+public:
+ static PassRefPtr<TransactionErrorCallback> create(long transactionId, PassRefPtr<InspectorStorageAgent> agent)
+ {
+ return adoptRef(new TransactionErrorCallback(transactionId, agent));
+ }
+
+ virtual ~TransactionErrorCallback() { }
+
+ virtual bool handleEvent(SQLError* error)
+ {
+ reportTransactionFailed(m_agent.get(), m_transactionId, error);
+ return true;
+ }
+private:
+ TransactionErrorCallback(long transactionId, PassRefPtr<InspectorStorageAgent> agent)
+ : m_transactionId(transactionId)
+ , m_agent(agent) { }
+ long m_transactionId;
+ RefPtr<InspectorStorageAgent> m_agent;
+};
+
+class TransactionSuccessCallback : public VoidCallback {
+public:
+ static PassRefPtr<TransactionSuccessCallback> create()
+ {
+ return adoptRef(new TransactionSuccessCallback());
+ }
+
+ virtual ~TransactionSuccessCallback() { }
+
+ virtual void handleEvent() { }
+
+private:
+ TransactionSuccessCallback() { }
+};
+
+} // namespace
+
+InspectorStorageAgent::InspectorStorageAgent(RemoteInspectorFrontend* frontend)
+ : m_frontend(frontend)
+{
+}
+
+InspectorStorageAgent::~InspectorStorageAgent()
+{
+}
+
+long InspectorStorageAgent::executeSQL(Database* database, const String& query)
+{
+ long transactionId = ++lastTransactionId;
+ RefPtr<SQLTransactionCallback> callback(TransactionCallback::create(query, transactionId, this));
+ RefPtr<SQLTransactionErrorCallback> errorCallback(TransactionErrorCallback::create(transactionId, this));
+ RefPtr<VoidCallback> successCallback(TransactionSuccessCallback::create());
+ database->transaction(callback.release(), errorCallback.release(), successCallback.release());
+ return transactionId;
+}
+
+void InspectorStorageAgent::clearFrontend()
+{
+ m_frontend = 0;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR) && ENABLE(DATABASE)
diff --git a/WebCore/inspector/InspectorStorageAgent.h b/WebCore/inspector/InspectorStorageAgent.h
new file mode 100644
index 0000000..b47e0d3
--- /dev/null
+++ b/WebCore/inspector/InspectorStorageAgent.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorStorageAgent_h
+#define InspectorStorageAgent_h
+
+#include "PlatformString.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebCore {
+
+class Database;
+class RemoteInspectorFrontend;
+
+class InspectorStorageAgent : public RefCounted<InspectorStorageAgent> {
+public:
+ static PassRefPtr<InspectorStorageAgent> create(RemoteInspectorFrontend* frontend)
+ {
+ return adoptRef(new InspectorStorageAgent(frontend));
+ }
+
+ virtual ~InspectorStorageAgent();
+
+ long executeSQL(Database*, const String& query);
+
+ RemoteInspectorFrontend* frontend() { return m_frontend; }
+ void clearFrontend();
+
+private:
+ InspectorStorageAgent(RemoteInspectorFrontend*);
+
+ RemoteInspectorFrontend* m_frontend;
+};
+
+} // namespace WebCore
+
+#endif // !defined(InspectorStorageAgent_h)
diff --git a/WebCore/inspector/InspectorValues.cpp b/WebCore/inspector/InspectorValues.cpp
index d488b50..dad84ac 100644
--- a/WebCore/inspector/InspectorValues.cpp
+++ b/WebCore/inspector/InspectorValues.cpp
@@ -494,6 +494,11 @@ bool InspectorValue::asNumber(unsigned long*) const
return false;
}
+bool InspectorValue::asNumber(unsigned int*) const
+{
+ return false;
+}
+
bool InspectorValue::asString(String*) const
{
return false;
@@ -566,6 +571,13 @@ bool InspectorBasicValue::asNumber(unsigned long* output) const
return true;
}
+bool InspectorBasicValue::asNumber(unsigned int* output) const
+{
+ if (type() != TypeDouble)
+ return false;
+ *output = static_cast<unsigned int>(m_doubleValue);
+ return true;
+}
void InspectorBasicValue::writeJSON(Vector<UChar>* output) const
{
diff --git a/WebCore/inspector/InspectorValues.h b/WebCore/inspector/InspectorValues.h
index 940bab9..f6556d7 100644
--- a/WebCore/inspector/InspectorValues.h
+++ b/WebCore/inspector/InspectorValues.h
@@ -36,6 +36,7 @@
#include "PlatformString.h"
#include "StringHash.h"
+#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
@@ -44,7 +45,6 @@ namespace WebCore {
class InspectorArray;
class InspectorObject;
-class String;
class InspectorValue : public RefCounted<InspectorValue> {
public:
@@ -71,6 +71,7 @@ public:
virtual bool asNumber(double* output) const;
virtual bool asNumber(long* output) const;
virtual bool asNumber(unsigned long* output) const;
+ virtual bool asNumber(unsigned int* output) const;
virtual bool asString(String* output) const;
virtual PassRefPtr<InspectorObject> asObject();
virtual PassRefPtr<InspectorArray> asArray();
@@ -109,6 +110,7 @@ public:
virtual bool asNumber(double* output) const;
virtual bool asNumber(long* output) const;
virtual bool asNumber(unsigned long* output) const;
+ virtual bool asNumber(unsigned int* output) const;
virtual void writeJSON(Vector<UChar>* output) const;
diff --git a/WebCore/inspector/ScriptDebugListener.h b/WebCore/inspector/ScriptDebugListener.h
index 539b000..5973402 100644
--- a/WebCore/inspector/ScriptDebugListener.h
+++ b/WebCore/inspector/ScriptDebugListener.h
@@ -33,11 +33,10 @@
#if ENABLE(JAVASCRIPT_DEBUGGER)
#include "ScriptState.h"
+#include <wtf/Forward.h>
namespace WebCore {
-class String;
-
enum ScriptWorldType {
MAIN_WORLD = 0,
EXTENSIONS_WORLD
diff --git a/WebCore/inspector/TimelineRecordFactory.cpp b/WebCore/inspector/TimelineRecordFactory.cpp
index 8b4a97f..ad9fdec 100644
--- a/WebCore/inspector/TimelineRecordFactory.cpp
+++ b/WebCore/inspector/TimelineRecordFactory.cpp
@@ -34,12 +34,10 @@
#if ENABLE(INSPECTOR)
#include "Event.h"
-#include "InspectorFrontend.h"
#include "InspectorValues.h"
#include "IntRect.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
-#include "ScriptArray.h"
#include "ScriptCallStack.h"
namespace WebCore {
diff --git a/WebCore/inspector/front-end/ApplicationCacheItemsView.js b/WebCore/inspector/front-end/ApplicationCacheItemsView.js
index 029f83b..f450938 100644
--- a/WebCore/inspector/front-end/ApplicationCacheItemsView.js
+++ b/WebCore/inspector/front-end/ApplicationCacheItemsView.js
@@ -41,12 +41,14 @@ WebInspector.ApplicationCacheItemsView = function(treeElement, appcacheDomain)
this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
- this.connectivityIcon = document.createElement("img");
- this.connectivityIcon.className = "storage-application-cache-connectivity-icon";
- this.connectivityIcon.src = "";
- this.connectivityMessage = document.createElement("span");
- this.connectivityMessage.className = "storage-application-cache-connectivity";
- this.connectivityMessage.textContent = "";
+ if (Preferences.onlineDetectionEnabled) {
+ this.connectivityIcon = document.createElement("img");
+ this.connectivityIcon.className = "storage-application-cache-connectivity-icon";
+ this.connectivityIcon.src = "";
+ this.connectivityMessage = document.createElement("span");
+ this.connectivityMessage.className = "storage-application-cache-connectivity";
+ this.connectivityMessage.textContent = "";
+ }
this.divider = document.createElement("span");
this.divider.className = "status-bar-item status-bar-divider";
@@ -72,11 +74,18 @@ WebInspector.ApplicationCacheItemsView = function(treeElement, appcacheDomain)
WebInspector.ApplicationCacheItemsView.prototype = {
get statusBarItems()
{
- return [
- this.refreshButton.element, this.deleteButton.element,
- this.connectivityIcon, this.connectivityMessage, this.divider,
- this.statusIcon, this.statusMessage
- ];
+ if (Preferences.onlineDetectionEnabled) {
+ return [
+ this.refreshButton.element, this.deleteButton.element,
+ this.connectivityIcon, this.connectivityMessage, this.divider,
+ this.statusIcon, this.statusMessage
+ ];
+ } else {
+ return [
+ this.refreshButton.element, this.deleteButton.element, this.divider,
+ this.statusIcon, this.statusMessage
+ ];
+ }
},
show: function(parentElement)
@@ -114,12 +123,14 @@ WebInspector.ApplicationCacheItemsView.prototype = {
updateNetworkState: function(isNowOnline)
{
- if (isNowOnline) {
- this.connectivityIcon.src = "Images/successGreenDot.png";
- this.connectivityMessage.textContent = WebInspector.UIString("Online");
- } else {
- this.connectivityIcon.src = "Images/errorRedDot.png";
- this.connectivityMessage.textContent = WebInspector.UIString("Offline");
+ if (Preferences.onlineDetectionEnabled) {
+ if (isNowOnline) {
+ this.connectivityIcon.src = "Images/successGreenDot.png";
+ this.connectivityMessage.textContent = WebInspector.UIString("Online");
+ } else {
+ this.connectivityIcon.src = "Images/errorRedDot.png";
+ this.connectivityMessage.textContent = WebInspector.UIString("Offline");
+ }
}
},
diff --git a/WebCore/inspector/front-end/BreakpointManager.js b/WebCore/inspector/front-end/BreakpointManager.js
index 709a9c2..21fa6a4 100644
--- a/WebCore/inspector/front-end/BreakpointManager.js
+++ b/WebCore/inspector/front-end/BreakpointManager.js
@@ -213,4 +213,3 @@ WebInspector.Breakpoint.prototype = {
WebInspector.Breakpoint.prototype.__proto__ = WebInspector.Object.prototype;
-WebInspector.didSetBreakpoint = WebInspector.Callback.processCallback;
diff --git a/WebCore/inspector/front-end/Callback.js b/WebCore/inspector/front-end/Callback.js
index 8ae7f95..d8163fe 100644
--- a/WebCore/inspector/front-end/Callback.js
+++ b/WebCore/inspector/front-end/Callback.js
@@ -42,15 +42,21 @@ WebInspector.Callback.prototype = {
return callbackId;
},
- processCallback: function(callbackId, opt_vararg)
+ processResponse: function(callbackId, opt_vararg)
{
var args = Array.prototype.slice.call(arguments, 1);
var callback = this._callbacks[callbackId];
callback.apply(null, args);
delete this._callbacks[callbackId];
+ },
+
+ removeResponseCallbackEntry: function(callbackId)
+ {
+ delete this._callbacks[callbackId];
}
}
WebInspector.Callback._INSTANCE = new WebInspector.Callback();
WebInspector.Callback.wrap = WebInspector.Callback._INSTANCE.wrap.bind(WebInspector.Callback._INSTANCE);
-WebInspector.Callback.processCallback = WebInspector.Callback._INSTANCE.processCallback.bind(WebInspector.Callback._INSTANCE);
+WebInspector.processResponse = WebInspector.Callback._INSTANCE.processResponse.bind(WebInspector.Callback._INSTANCE);
+WebInspector.removeResponseCallbackEntry = WebInspector.Callback._INSTANCE.removeResponseCallbackEntry.bind(WebInspector.Callback._INSTANCE);
diff --git a/WebCore/inspector/front-end/ConsoleView.js b/WebCore/inspector/front-end/ConsoleView.js
index e16c89e..6a4e0d3 100644
--- a/WebCore/inspector/front-end/ConsoleView.js
+++ b/WebCore/inspector/front-end/ConsoleView.js
@@ -1128,4 +1128,3 @@ WebInspector.ConsoleGroup.prototype = {
}
}
-WebInspector.didClearConsoleMessages = WebInspector.Callback.processCallback;
diff --git a/WebCore/inspector/front-end/DOMAgent.js b/WebCore/inspector/front-end/DOMAgent.js
index bcbe91e..c41d038 100644
--- a/WebCore/inspector/front-end/DOMAgent.js
+++ b/WebCore/inspector/front-end/DOMAgent.js
@@ -681,29 +681,3 @@ WebInspector.childNodeRemoved = function()
this.domAgent._childNodeRemoved.apply(this.domAgent, arguments);
}
-WebInspector.didGetApplicationCaches = WebInspector.Callback.processCallback;
-WebInspector.didGetCookies = WebInspector.Callback.processCallback;
-WebInspector.didGetChildNodes = WebInspector.Callback.processCallback;
-WebInspector.didPerformSearch = WebInspector.Callback.processCallback;
-WebInspector.didApplyDomChange = WebInspector.Callback.processCallback;
-WebInspector.didRemoveAttribute = WebInspector.Callback.processCallback;
-WebInspector.didSetTextNodeValue = WebInspector.Callback.processCallback;
-WebInspector.didRemoveNode = WebInspector.Callback.processCallback;
-WebInspector.didChangeTagName = WebInspector.Callback.processCallback;
-WebInspector.didGetOuterHTML = WebInspector.Callback.processCallback;
-WebInspector.didSetOuterHTML = WebInspector.Callback.processCallback;
-WebInspector.didPushNodeByPathToFrontend = WebInspector.Callback.processCallback;
-WebInspector.didGetEventListenersForNode = WebInspector.Callback.processCallback;
-
-WebInspector.didGetStyles = WebInspector.Callback.processCallback;
-WebInspector.didGetAllStyles = WebInspector.Callback.processCallback;
-WebInspector.didGetStyleSheet = WebInspector.Callback.processCallback;
-WebInspector.didGetRuleRanges = WebInspector.Callback.processCallback;
-WebInspector.didGetInlineStyle = WebInspector.Callback.processCallback;
-WebInspector.didGetComputedStyle = WebInspector.Callback.processCallback;
-WebInspector.didApplyStyleText = WebInspector.Callback.processCallback;
-WebInspector.didSetStyleText = WebInspector.Callback.processCallback;
-WebInspector.didSetStyleProperty = WebInspector.Callback.processCallback;
-WebInspector.didToggleStyleEnabled = WebInspector.Callback.processCallback;
-WebInspector.didSetRuleSelector = WebInspector.Callback.processCallback;
-WebInspector.didAddRule = WebInspector.Callback.processCallback;
diff --git a/WebCore/inspector/front-end/DOMStorage.js b/WebCore/inspector/front-end/DOMStorage.js
index c5f658d..5c28e29 100644
--- a/WebCore/inspector/front-end/DOMStorage.js
+++ b/WebCore/inspector/front-end/DOMStorage.js
@@ -73,6 +73,3 @@ WebInspector.DOMStorage.prototype = {
}
}
-WebInspector.didGetDOMStorageEntries = WebInspector.Callback.processCallback;
-WebInspector.didSetDOMStorageItem = WebInspector.Callback.processCallback;
-WebInspector.didRemoveDOMStorageItem = WebInspector.Callback.processCallback;
diff --git a/WebCore/inspector/front-end/Database.js b/WebCore/inspector/front-end/Database.js
index a0dc9ca..45b7a0e 100644
--- a/WebCore/inspector/front-end/Database.js
+++ b/WebCore/inspector/front-end/Database.js
@@ -34,6 +34,9 @@ WebInspector.Database = function(id, domain, name, version)
this._version = version;
}
+WebInspector.Database.successCallbacks = {};
+WebInspector.Database.errorCallbacks = {};
+
WebInspector.Database.prototype = {
get id()
{
@@ -87,17 +90,33 @@ WebInspector.Database.prototype = {
executeSql: function(query, onSuccess, onError)
{
- function callback(result)
+ function callback(success, transactionId)
{
- if (!(result instanceof Array)) {
- onError(result);
+ if (!success) {
+ onError(WebInspector.UIString("Database not found."));
return;
}
- onSuccess(result);
+ WebInspector.Database.successCallbacks[transactionId] = onSuccess;
+ WebInspector.Database.errorCallbacks[transactionId] = onError;
}
- // FIXME: execute the query in the frame the DB comes from.
- InjectedScriptAccess.getDefault().executeSql(this._id, query, callback);
+ InspectorBackend.executeSQL(WebInspector.Callback.wrap(callback), this._id, query);
}
}
-WebInspector.didGetDatabaseTableNames = WebInspector.Callback.processCallback;
+WebInspector.sqlTransactionSucceeded = function(transactionId, columnNames, values)
+{
+ var callback = WebInspector.Database.successCallbacks[transactionId];
+ if (!callback)
+ return;
+ delete WebInspector.Database.successCallbacks[transactionId];
+ callback(columnNames, values);
+}
+
+WebInspector.sqlTransactionFailed = function(transactionId, errorObj)
+{
+ var callback = WebInspector.Database.errorCallbacks[transactionId];
+ if (!callback)
+ return;
+ delete WebInspector.Database.errorCallbacks[transactionId];
+ callback(errorObj);
+}
diff --git a/WebCore/inspector/front-end/DatabaseQueryView.js b/WebCore/inspector/front-end/DatabaseQueryView.js
index 38c8df4..a179eaa 100644
--- a/WebCore/inspector/front-end/DatabaseQueryView.js
+++ b/WebCore/inspector/front-end/DatabaseQueryView.js
@@ -137,9 +137,9 @@ WebInspector.DatabaseQueryView.prototype = {
this.database.executeSql(query, this._queryFinished.bind(this, query), this._queryError.bind(this, query));
},
- _queryFinished: function(query, result)
+ _queryFinished: function(query, columnNames, values)
{
- var dataGrid = WebInspector.panels.storage.dataGridForResult(result);
+ var dataGrid = WebInspector.panels.storage.dataGridForResult(columnNames, values);
var trimmedQuery = query.trim();
if (dataGrid) {
@@ -154,7 +154,7 @@ WebInspector.DatabaseQueryView.prototype = {
_queryError: function(query, error)
{
- if (error.code == 1)
+ if (error.message)
var message = error.message;
else if (error.code == 2)
var message = WebInspector.UIString("Database no longer has expected version.");
diff --git a/WebCore/inspector/front-end/DatabaseTableView.js b/WebCore/inspector/front-end/DatabaseTableView.js
index cd66ab7..9e6d374 100644
--- a/WebCore/inspector/front-end/DatabaseTableView.js
+++ b/WebCore/inspector/front-end/DatabaseTableView.js
@@ -54,11 +54,11 @@ WebInspector.DatabaseTableView.prototype = {
this.database.executeSql("SELECT * FROM " + this.tableName, this._queryFinished.bind(this), this._queryError.bind(this));
},
- _queryFinished: function(result)
+ _queryFinished: function(columnNames, values)
{
this.element.removeChildren();
- var dataGrid = WebInspector.panels.storage.dataGridForResult(result);
+ var dataGrid = WebInspector.panels.storage.dataGridForResult(columnNames, values);
if (!dataGrid) {
var emptyMsgElement = document.createElement("div");
emptyMsgElement.className = "storage-table-empty";
diff --git a/WebCore/inspector/front-end/ElementsPanel.js b/WebCore/inspector/front-end/ElementsPanel.js
index 09a84f7..6713ddc 100644
--- a/WebCore/inspector/front-end/ElementsPanel.js
+++ b/WebCore/inspector/front-end/ElementsPanel.js
@@ -179,12 +179,12 @@ WebInspector.ElementsPanel.prototype = {
this.recentlyModifiedNodes = [];
delete this.currentQuery;
- this.searchCanceled();
},
setDocument: function(inspectedRootDocument)
{
this.reset();
+ this.searchCanceled();
if (!inspectedRootDocument)
return;
diff --git a/WebCore/inspector/front-end/ElementsTreeOutline.js b/WebCore/inspector/front-end/ElementsTreeOutline.js
index 3cd22ae..87d85c1 100644
--- a/WebCore/inspector/front-end/ElementsTreeOutline.js
+++ b/WebCore/inspector/front-end/ElementsTreeOutline.js
@@ -683,7 +683,7 @@ WebInspector.ElementsTreeElement.prototype = {
return;
if (this.treeOutline.showInElementsPanelEnabled) {
- WebInspector.showElementsPanel();
+ WebInspector.showPanel("elements");
WebInspector.panels.elements.focusedDOMNode = this.representedObject;
}
diff --git a/WebCore/inspector/front-end/ExtensionServer.js b/WebCore/inspector/front-end/ExtensionServer.js
index 2d2eab1..2abe1db 100644
--- a/WebCore/inspector/front-end/ExtensionServer.js
+++ b/WebCore/inspector/front-end/ExtensionServer.js
@@ -213,7 +213,7 @@ WebInspector.ExtensionServer.prototype = {
if (!resource)
return this._status.E_NOTFOUND(typeof id + ": " + id);
WebInspector.panels.resources.showResource(resource, message.line);
- WebInspector.showResourcesPanel();
+ WebInspector.showPanel("resources");
},
_dispatchCallback: function(requestId, port, result)
@@ -317,3 +317,5 @@ WebInspector.addExtensions = function(extensions)
{
WebInspector.extensionServer._addExtensions(extensions);
}
+
+WebInspector.extensionServer = new WebInspector.ExtensionServer();
diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js
index 3a114c0..b8bf9f2 100644
--- a/WebCore/inspector/front-end/InjectedScript.js
+++ b/WebCore/inspector/front-end/InjectedScript.js
@@ -472,45 +472,6 @@ InjectedScript.CallFrameProxy.prototype = {
}
}
-InjectedScript.executeSql = function(callId, databaseId, query)
-{
- function successCallback(tx, result)
- {
- var rows = result.rows;
- var result = [];
- var length = rows.length;
- for (var i = 0; i < length; ++i) {
- var data = {};
- result.push(data);
- var row = rows.item(i);
- for (var columnIdentifier in row) {
- // FIXME: (Bug 19439) We should specially format SQL NULL here
- // (which is represented by JavaScript null here, and turned
- // into the string "null" by the String() function).
- var text = row[columnIdentifier];
- data[columnIdentifier] = String(text);
- }
- }
- InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, result, false);
- }
-
- function errorCallback(tx, error)
- {
- InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, error, false);
- }
-
- function queryTransaction(tx)
- {
- tx.executeSql(query, null, successCallback, errorCallback);
- }
-
- var database = InjectedScriptHost.databaseForId(databaseId);
- if (!database)
- errorCallback(null, { code : 2 }); // Return as unexpected version.
- database.transaction(queryTransaction, errorCallback);
- return true;
-}
-
InjectedScript._isDefined = function(object)
{
return object || InjectedScript._isHTMLAllCollection(object);
diff --git a/WebCore/inspector/front-end/InjectedScriptAccess.js b/WebCore/inspector/front-end/InjectedScriptAccess.js
index 59aa70c..b5aa9c7 100644
--- a/WebCore/inspector/front-end/InjectedScriptAccess.js
+++ b/WebCore/inspector/front-end/InjectedScriptAccess.js
@@ -66,7 +66,7 @@ InjectedScriptAccess._installHandler = function(methodName, async)
}
var callId = WebInspector.Callback.wrap(myCallback);
- InspectorBackend.dispatchOnInjectedScript(callId, this._injectedScriptId, methodName, argsString, !!async);
+ InspectorBackend.dispatchOnInjectedScript(callId, this._injectedScriptId, methodName, argsString);
};
}
@@ -84,9 +84,3 @@ InjectedScriptAccess._installHandler("getPrototypes");
InjectedScriptAccess._installHandler("openInInspectedWindow");
InjectedScriptAccess._installHandler("pushNodeToFrontend");
InjectedScriptAccess._installHandler("setPropertyValue");
-
-// Some methods can't run synchronously even on the injected script side (such as DB transactions).
-// Mark them as asynchronous here.
-InjectedScriptAccess._installHandler("executeSql", true);
-
-WebInspector.didDispatchOnInjectedScript = WebInspector.Callback.processCallback;
diff --git a/WebCore/inspector/front-end/InspectorBackendStub.js b/WebCore/inspector/front-end/InspectorBackendStub.js
index 7cfc8a1..c87cb81 100644
--- a/WebCore/inspector/front-end/InspectorBackendStub.js
+++ b/WebCore/inspector/front-end/InspectorBackendStub.js
@@ -46,6 +46,7 @@ WebInspector.InspectorBackendStub = function()
this._registerDelegate("enableResourceTracking");
this._registerDelegate("enableSearchingForNode");
this._registerDelegate("enableTimeline");
+ this._registerDelegate("getApplicationCaches");
this._registerDelegate("getChildNodes");
this._registerDelegate("getCookies");
this._registerDelegate("getDatabaseTableNames");
@@ -81,6 +82,7 @@ WebInspector.InspectorBackendStub = function()
this._registerDelegate("stopTimelineProfiler");
this._registerDelegate("storeLastActivePanel");
this._registerDelegate("takeHeapSnapshot");
+ this._registerDelegate("getProfilerLogLines");
this._registerDelegate("getAllStyles");
this._registerDelegate("getStyles");
@@ -103,6 +105,7 @@ WebInspector.InspectorBackendStub = function()
this._registerDelegate("removeBreakpoint");
this._registerDelegate("activateBreakpoints");
this._registerDelegate("deactivateBreakpoints");
+ this._registerDelegate("pause");
this._registerDelegate("resume");
this._registerDelegate("stepIntoStatement");
this._registerDelegate("stepOutOfFunction");
@@ -119,10 +122,7 @@ WebInspector.InspectorBackendStub.prototype = {
sendMessageToBackend: function()
{
var message = JSON.stringify(Array.prototype.slice.call(arguments));
- if (WebInspector._paramsObject && "page" in WebInspector._paramsObject)
- WebInspector.socket.send(message);
- else
- InspectorFrontendHost.sendMessageToBackend(message);
+ InspectorFrontendHost.sendMessageToBackend(message);
}
}
diff --git a/WebCore/inspector/front-end/ProfilesPanel.js b/WebCore/inspector/front-end/ProfilesPanel.js
index 911b1da..e5877d9 100644
--- a/WebCore/inspector/front-end/ProfilesPanel.js
+++ b/WebCore/inspector/front-end/ProfilesPanel.js
@@ -627,5 +627,3 @@ WebInspector.ProfileGroupSidebarTreeElement.prototype = {
WebInspector.ProfileGroupSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype;
-WebInspector.didGetProfileHeaders = WebInspector.Callback.processCallback;
-WebInspector.didGetProfile = WebInspector.Callback.processCallback;
diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js
index 4fda07b..9785644 100644
--- a/WebCore/inspector/front-end/ResourcesPanel.js
+++ b/WebCore/inspector/front-end/ResourcesPanel.js
@@ -891,8 +891,6 @@ WebInspector.getResourceContent = function(identifier, callback)
InspectorBackend.getResourceContent(WebInspector.Callback.wrap(callback), identifier);
}
-WebInspector.didGetResourceContent = WebInspector.Callback.processCallback;
-
WebInspector.ResourceTimeCalculator = function(startAtZero)
{
WebInspector.AbstractTimelineCalculator.call(this);
diff --git a/WebCore/inspector/front-end/ScriptView.js b/WebCore/inspector/front-end/ScriptView.js
index 597fd28..5598577 100644
--- a/WebCore/inspector/front-end/ScriptView.js
+++ b/WebCore/inspector/front-end/ScriptView.js
@@ -136,4 +136,3 @@ WebInspector.ScriptView.prototype = {
WebInspector.ScriptView.prototype.__proto__ = WebInspector.View.prototype;
-WebInspector.didGetScriptSource = WebInspector.Callback.processCallback;
diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js
index dff4853..44c1dba 100644
--- a/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/WebCore/inspector/front-end/ScriptsPanel.js
@@ -103,11 +103,11 @@ WebInspector.ScriptsPanel = function()
this.stepOutButton.appendChild(document.createElement("img"));
this.sidebarButtonsElement.appendChild(this.stepOutButton);
- this.toggleBreakpointsButton = new WebInspector.StatusBarButton("", "toggle-breakpoints");
+ this.toggleBreakpointsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Deactivate all breakpoints."), "toggle-breakpoints");
+ // Breakpoints should be activated by default, so emulate a click to toggle on.
+ this.toggleBreakpointsButton.toggled = true;
this.toggleBreakpointsButton.addEventListener("click", this.toggleBreakpointsClicked.bind(this), false);
this.sidebarButtonsElement.appendChild(this.toggleBreakpointsButton.element);
- // Breakpoints should be activated by default, so emulate a click to toggle on.
- this.toggleBreakpointsClicked();
this.debuggerStatusElement = document.createElement("div");
this.debuggerStatusElement.id = "scripts-debugger-status";
@@ -1034,4 +1034,3 @@ WebInspector.ScriptsPanel.prototype = {
WebInspector.ScriptsPanel.prototype.__proto__ = WebInspector.Panel.prototype;
-WebInspector.didEditScriptSource = WebInspector.Callback.processCallback;
diff --git a/WebCore/inspector/front-end/Settings.js b/WebCore/inspector/front-end/Settings.js
index e54acc7..c84ba79 100644
--- a/WebCore/inspector/front-end/Settings.js
+++ b/WebCore/inspector/front-end/Settings.js
@@ -43,6 +43,7 @@ var Preferences = {
debuggerAlwaysEnabled: false,
profilerAlwaysEnabled: false,
auditsPanelEnabled: true,
+ onlineDetectionEnabled: true
}
WebInspector.populateApplicationSettings = function(settingsString)
diff --git a/WebCore/inspector/front-end/StoragePanel.js b/WebCore/inspector/front-end/StoragePanel.js
index 68563de..2d17989 100644
--- a/WebCore/inspector/front-end/StoragePanel.js
+++ b/WebCore/inspector/front-end/StoragePanel.js
@@ -298,32 +298,28 @@ WebInspector.StoragePanel.prototype = {
database.getTableNames(tableNamesCallback);
},
- dataGridForResult: function(rows)
+ dataGridForResult: function(columnNames, values)
{
- if (!rows.length)
+ var numColumns = columnNames.length;
+ if (!numColumns)
return null;
var columns = {};
- var numColumns = 0;
- for (var columnIdentifier in rows[0]) {
+ for (var i = 0; i < columnNames.length; ++i) {
var column = {};
- column.width = columnIdentifier.length;
- column.title = columnIdentifier;
+ column.width = columnNames[i].length;
+ column.title = columnNames[i];
column.sortable = true;
- columns[columnIdentifier] = column;
- ++numColumns;
+ columns[columnNames[i]] = column;
}
var nodes = [];
- var length = rows.length;
- for (var i = 0; i < length; ++i) {
+ for (var i = 0; i < values.length / numColumns; ++i) {
var data = {};
-
- var row = rows[i];
- for (var columnIdentifier in row)
- data[columnIdentifier] = row[columnIdentifier];
+ for (var j = 0; j < columnNames.length; ++j)
+ data[columnNames[j]] = values[numColumns * i + j];
var node = new WebInspector.DataGridNode(data, false);
node.selectable = false;
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index 4bb30c7..4e8e633 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -526,7 +526,6 @@ WebInspector.loaded = function()
document.getElementById("close-button-left").addEventListener("click", this.close, true);
document.getElementById("close-button-right").addEventListener("click", this.close, true);
- this.extensionServer = new WebInspector.ExtensionServer();
this.extensionServer.initExtensions();
InspectorFrontendHost.loaded();
@@ -587,6 +586,11 @@ WebInspector.dispatchMessageFromBackend = function(arguments)
WebInspector.dispatch.apply(this, arguments);
}
+WebInspector.reportProtocolError = function(callId, methodName, errorText)
+{
+ WebInspector.log("InspectorBackend." + methodName + " failed with error text: '" + errorText + "'");
+ WebInspector.removeResponseCallbackEntry(callId);
+}
WebInspector.windowResize = function(event)
{
@@ -687,7 +691,7 @@ WebInspector.documentClick = function(event)
return;
}
- WebInspector.showResourcesPanel();
+ WebInspector.showPanel("resources");
}
if (WebInspector.followLinkTimeout)
@@ -1077,7 +1081,7 @@ WebInspector.elementDragEnd = function(event)
WebInspector.toggleSearchingForNode = function()
{
if (this.panels.elements) {
- this.showElementsPanel();
+ this.showPanel("elements");
this.panels.elements.toggleSearchingForNode();
}
}
@@ -1092,60 +1096,28 @@ WebInspector.showChanges = function()
this.drawer.showView(this.changes);
}
-WebInspector.showElementsPanel = function()
-{
- this.currentPanel = this.panels.elements;
-}
-
-WebInspector.showResourcesPanel = function()
-{
- this.currentPanel = this.panels.resources;
-}
-
-WebInspector.showScriptsPanel = function()
-{
- this.currentPanel = this.panels.scripts;
-}
-
-WebInspector.showTimelinePanel = function()
-{
- this.currentPanel = this.panels.timeline;
-}
-
-WebInspector.showProfilesPanel = function()
-{
- this.currentPanel = this.panels.profiles;
-}
-
-WebInspector.showStoragePanel = function()
-{
- this.currentPanel = this.panels.storage;
-}
-
-WebInspector.showConsolePanel = function()
-{
- this.currentPanel = this.panels.console;
-}
-
-WebInspector.showAuditsPanel = function()
+WebInspector.showPanel = function(panel)
{
- this.currentPanel = this.panels.audits;
+ if (!(panel in this.panels))
+ panel = "elements";
+ this.currentPanel = this.panels[panel];
}
WebInspector.selectDatabase = function(o)
{
- WebInspector.showStoragePanel();
+ WebInspector.showPanel("storage");
WebInspector.panels.storage.selectDatabase(o);
}
WebInspector.selectDOMStorage = function(o)
{
- WebInspector.showStoragePanel();
+ WebInspector.showPanel("storage");
WebInspector.panels.storage.selectDOMStorage(o);
}
-WebInspector.updateResource = function(identifier, payload)
+WebInspector.updateResource = function(payload)
{
+ var identifier = payload.id;
var resource = this.resources[identifier];
if (!resource) {
resource = new WebInspector.Resource(identifier, payload.url);
@@ -1737,7 +1709,7 @@ WebInspector.linkifyStringAsFragment = function(string)
WebInspector.showProfileForURL = function(url)
{
- WebInspector.showProfilesPanel();
+ WebInspector.showPanel("profiles");
WebInspector.panels.profiles.showProfileForURL(url);
}
@@ -1787,6 +1759,9 @@ WebInspector.completeURL = function(baseURL, href)
if (path.charAt(0) !== "/") {
var basePath = match[4] || "/";
path = basePath.substring(0, basePath.lastIndexOf("/")) + "/" + path;
+ } else if (path.length > 1 && path.charAt(1) === "/") {
+ // href starts with "//" which is a full URL with the protocol dropped (use the baseURL protocol).
+ return match[1] + ":" + path;
}
return match[1] + "://" + match[2] + (match[3] ? (":" + match[3]) : "") + path;
}
diff --git a/WebCore/inspector/front-end/utilities.js b/WebCore/inspector/front-end/utilities.js
index d248071..dd3e761 100644
--- a/WebCore/inspector/front-end/utilities.js
+++ b/WebCore/inspector/front-end/utilities.js
@@ -274,7 +274,8 @@ Element.prototype.query = function(query)
Element.prototype.removeChildren = function()
{
- this.innerHTML = "";
+ if (this.firstChild)
+ this.textContent = "";
}
Element.prototype.isInsertionCaretInside = function()