Merge from Chromium at DEPS revision r210036
This commit was generated by merge_to_master.py.
Change-Id: Ib2112ed87a48d7a6d9c0563ba71850716d1475ef
diff --git a/Source/core/inspector/CodeGeneratorInspector.py b/Source/core/inspector/CodeGeneratorInspector.py
index a718464..4c81796 100755
--- a/Source/core/inspector/CodeGeneratorInspector.py
+++ b/Source/core/inspector/CodeGeneratorInspector.py
@@ -226,7 +226,11 @@
@classmethod
def get_raw_validator_call_text(cls):
- return "RuntimeCastHelper::assertType<InspectorValue::Type%s>" % cls.get_validate_method_params().template_type
+ return "RuntimeCastHelper::assertType<JSONValue::Type%s>" % cls.get_validate_method_params().template_type
+
+ @staticmethod
+ def get_validate_method_params():
+ raise Exception("Abstract method")
class String(BaseType):
@staticmethod
@@ -393,7 +397,7 @@
@staticmethod
def get_c_initializer():
- return "InspectorObject::create()"
+ return "JSONObject::create()"
@staticmethod
def get_output_argument_prefix():
@@ -415,7 +419,7 @@
@staticmethod
def get_array_item_raw_c_type_text():
- return "InspectorObject"
+ return "JSONObject"
@staticmethod
def get_raw_type_model():
@@ -450,7 +454,7 @@
@staticmethod
def get_array_item_raw_c_type_text():
- return "InspectorValue"
+ return "JSONValue"
@staticmethod
def get_raw_type_model():
@@ -471,7 +475,7 @@
@staticmethod
def get_c_initializer():
- return "InspectorArray::create()"
+ return "JSONArray::create()"
@staticmethod
def get_output_argument_prefix():
@@ -493,7 +497,7 @@
@staticmethod
def get_array_item_raw_c_type_text():
- return "InspectorArray"
+ return "JSONArray"
@staticmethod
def get_raw_type_model():
@@ -690,14 +694,14 @@
cls.Int = cls.ValueType("int", False)
cls.Number = cls.ValueType("double", False)
cls.String = cls.ValueType("String", True,)
- cls.Object = cls.RefPtrBased("InspectorObject")
- cls.Array = cls.RefPtrBased("InspectorArray")
- cls.Any = cls.RefPtrBased("InspectorValue")
+ cls.Object = cls.RefPtrBased("JSONObject")
+ cls.Array = cls.RefPtrBased("JSONArray")
+ cls.Any = cls.RefPtrBased("JSONValue")
TypeModel.init_class()
-# Collection of InspectorObject class methods that are likely to be overloaded in generated class.
+# Collection of JSONObject class methods that are likely to be overloaded in generated class.
# We must explicitly import all overloaded methods or they won't be available to user.
INSPECTOR_OBJECT_SETTER_NAMES = frozenset(["setValue", "setBoolean", "setNumber", "setString", "setValue", "setObject", "setArray"])
@@ -893,14 +897,14 @@
if enum_binding_cls.need_internal_runtime_cast_:
writer.append("#if %s\n" % VALIDATOR_IFDEF_NAME)
- writer.newline(" static void assertCorrectValue(InspectorValue* value);\n")
+ writer.newline(" static void assertCorrectValue(JSONValue* value);\n")
writer.append("#endif // %s\n" % VALIDATOR_IFDEF_NAME)
validator_writer = generate_context.validator_writer
domain_fixes = DomainNameFixes.get_fixed_data(context_domain_name)
- validator_writer.newline("void %s%s::assertCorrectValue(InspectorValue* value)\n" % (helper.full_name_prefix_for_impl, enum_name))
+ validator_writer.newline("void %s%s::assertCorrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, enum_name))
validator_writer.newline("{\n")
validator_writer.newline(" WTF::String s;\n")
validator_writer.newline(" bool cast_res = value->asString(&s);\n")
@@ -1131,9 +1135,9 @@
writer.append(class_name)
writer.append(" : public ")
if is_open_type:
- writer.append("InspectorObject")
+ writer.append("JSONObject")
else:
- writer.append("InspectorObjectBase")
+ writer.append("JSONObjectBase")
writer.append(" {\n")
writer.newline("public:\n")
ad_hoc_type_writer = writer.insert_writer(" ")
@@ -1210,25 +1214,25 @@
if setter_name in INSPECTOR_OBJECT_SETTER_NAMES:
- writer.newline(" using InspectorObjectBase::%s;\n\n" % setter_name)
+ writer.newline(" using JSONObjectBase::%s;\n\n" % setter_name)
if class_binding_cls.need_user_runtime_cast_:
- writer.newline(" static PassRefPtr<%s> runtimeCast(PassRefPtr<InspectorValue> value)\n" % class_name)
+ writer.newline(" static PassRefPtr<%s> runtimeCast(PassRefPtr<JSONValue> value)\n" % class_name)
writer.newline(" {\n")
- writer.newline(" RefPtr<InspectorObject> object;\n")
+ writer.newline(" RefPtr<JSONObject> object;\n")
writer.newline(" bool castRes = value->asObject(&object);\n")
writer.newline(" ASSERT_UNUSED(castRes, castRes);\n")
writer.append("#if %s\n" % VALIDATOR_IFDEF_NAME)
writer.newline(" assertCorrectValue(object.get());\n")
writer.append("#endif // %s\n" % VALIDATOR_IFDEF_NAME)
- writer.newline(" COMPILE_ASSERT(sizeof(%s) == sizeof(InspectorObjectBase), type_cast_problem);\n" % class_name)
- writer.newline(" return static_cast<%s*>(static_cast<InspectorObjectBase*>(object.get()));\n" % class_name)
+ writer.newline(" COMPILE_ASSERT(sizeof(%s) == sizeof(JSONObjectBase), type_cast_problem);\n" % class_name)
+ writer.newline(" return static_cast<%s*>(static_cast<JSONObjectBase*>(object.get()));\n" % class_name)
writer.newline(" }\n")
writer.append("\n")
if class_binding_cls.need_internal_runtime_cast_:
writer.append("#if %s\n" % VALIDATOR_IFDEF_NAME)
- writer.newline(" static void assertCorrectValue(InspectorValue* value);\n")
+ writer.newline(" static void assertCorrectValue(JSONValue* value);\n")
writer.append("#endif // %s\n" % VALIDATOR_IFDEF_NAME)
closed_field_set = (context_domain_name + "." + class_name) not in TYPES_WITH_OPEN_FIELD_LIST_SET
@@ -1237,15 +1241,15 @@
domain_fixes = DomainNameFixes.get_fixed_data(context_domain_name)
- validator_writer.newline("void %s%s::assertCorrectValue(InspectorValue* value)\n" % (helper.full_name_prefix_for_impl, class_name))
+ validator_writer.newline("void %s%s::assertCorrectValue(JSONValue* value)\n" % (helper.full_name_prefix_for_impl, class_name))
validator_writer.newline("{\n")
- validator_writer.newline(" RefPtr<InspectorObject> object;\n")
+ validator_writer.newline(" RefPtr<JSONObject> object;\n")
validator_writer.newline(" bool castRes = value->asObject(&object);\n")
validator_writer.newline(" ASSERT_UNUSED(castRes, castRes);\n")
for prop_data in resolve_data.main_properties:
validator_writer.newline(" {\n")
it_name = "%sPos" % prop_data.p["name"]
- validator_writer.newline(" InspectorObject::iterator %s;\n" % it_name)
+ validator_writer.newline(" JSONObject::iterator %s;\n" % it_name)
validator_writer.newline(" %s = object->find(\"%s\");\n" % (it_name, prop_data.p["name"]))
validator_writer.newline(" ASSERT(%s != object->end());\n" % it_name)
validator_writer.newline(" %s(%s->value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name))
@@ -1257,7 +1261,7 @@
for prop_data in resolve_data.optional_properties:
validator_writer.newline(" {\n")
it_name = "%sPos" % prop_data.p["name"]
- validator_writer.newline(" InspectorObject::iterator %s;\n" % it_name)
+ validator_writer.newline(" JSONObject::iterator %s;\n" % it_name)
validator_writer.newline(" %s = object->find(\"%s\");\n" % (it_name, prop_data.p["name"]))
validator_writer.newline(" if (%s != object->end()) {\n" % it_name)
validator_writer.newline(" %s(%s->value.get());\n" % (prop_data.param_type_binding.get_validator_call_text(), it_name))
@@ -1368,7 +1372,7 @@
@staticmethod
def get_validator_call_text():
- return "RuntimeCastHelper::assertType<InspectorValue::TypeObject>"
+ return "RuntimeCastHelper::assertType<JSONValue::TypeObject>"
@classmethod
def get_array_item_c_type_text(cls):
@@ -1868,7 +1872,7 @@
class EventMethodStructTemplate:
@staticmethod
def append_prolog(line_list):
- line_list.append(" RefPtr<InspectorObject> paramsObject = InspectorObject::create();\n")
+ line_list.append(" RefPtr<JSONObject> paramsObject = JSONObject::create();\n")
@staticmethod
def append_epilog(line_list):
@@ -1884,7 +1888,7 @@
Generator.method_name_enum_list.append(" %s," % cmd_enum_name)
Generator.method_handler_list.append(" &InspectorBackendDispatcherImpl::%s_%s," % (domain_name, json_command_name))
- Generator.backend_method_declaration_list.append(" void %s_%s(long callId, InspectorObject* requestMessageObject);" % (domain_name, json_command_name))
+ Generator.backend_method_declaration_list.append(" void %s_%s(long callId, JSONObject* requestMessageObject);" % (domain_name, json_command_name))
ad_hoc_type_output = []
Generator.backend_agent_interface_list.append(ad_hoc_type_output)
diff --git a/Source/core/inspector/CodeGeneratorInspectorStrings.py b/Source/core/inspector/CodeGeneratorInspectorStrings.py
index 8131ff2..8759b2f 100644
--- a/Source/core/inspector/CodeGeneratorInspectorStrings.py
+++ b/Source/core/inspector/CodeGeneratorInspectorStrings.py
@@ -44,16 +44,16 @@
""")
backend_method = (
-"""void InspectorBackendDispatcherImpl::${domainName}_$methodName(long callId, InspectorObject*$requestMessageObject)
+"""void InspectorBackendDispatcherImpl::${domainName}_$methodName(long callId, JSONObject*$requestMessageObject)
{
- RefPtr<InspectorArray> protocolErrors = InspectorArray::create();
+ RefPtr<JSONArray> protocolErrors = JSONArray::create();
if (!$agentField)
protocolErrors->pushString("${domainName} handler is not available.");
$methodOutCode
$methodInCode
- RefPtr<InspectorObject> result = InspectorObject::create();
- RefPtr<InspectorValue> resultErrorData;
+ RefPtr<JSONObject> result = JSONObject::create();
+ RefPtr<JSONValue> resultErrorData;
ErrorString error;
if (!protocolErrors->length()) {
$agentField->$methodName(&error$agentCallParams);
@@ -66,7 +66,7 @@
frontend_method = ("""void InspectorFrontend::$domainName::$eventName($parameters)
{
- RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
+ RefPtr<JSONObject> jsonMessage = JSONObject::create();
jsonMessage->setString("method", "$domainName.$eventName");
$code if (m_inspectorFrontendChannel)
m_inspectorFrontendChannel->sendMessageToFrontend(jsonMessage->toJSONString());
@@ -78,8 +78,8 @@
void InspectorBackendDispatcher::$agentName::$callbackName::sendSuccess($parameters)
{
- RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
-$code sendIfActive(jsonMessage, ErrorString(), PassRefPtr<InspectorValue>());
+ RefPtr<JSONObject> jsonMessage = JSONObject::create();
+$code sendIfActive(jsonMessage, ErrorString(), PassRefPtr<JSONValue>());
}
""")
@@ -87,7 +87,7 @@
"""void InspectorBackendDispatcher::$agentName::$callbackName::sendFailure(const ErrorString& error, $parameter)
{
ASSERT(error.length());
- RefPtr<InspectorValue> errorDataValue;
+ RefPtr<JSONValue> errorDataValue;
if (error) {
errorDataValue = $argument;
}
@@ -101,9 +101,9 @@
#define InspectorFrontend_h
#include "InspectorTypeBuilder.h"
-#include "core/inspector/InspectorValues.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "core/platform/JSONValues.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -137,8 +137,8 @@
namespace WebCore {
class InspectorAgent;
-class InspectorObject;
-class InspectorArray;
+class JSONObject;
+class JSONArray;
class InspectorFrontendChannel;
typedef String ErrorString;
@@ -158,7 +158,7 @@
bool isActive();
protected:
- void sendIfActive(PassRefPtr<InspectorObject> partialMessage, const ErrorString& invocationError, PassRefPtr<InspectorValue> errorData);
+ void sendIfActive(PassRefPtr<JSONObject> partialMessage, const ErrorString& invocationError, PassRefPtr<JSONValue> errorData);
private:
void disable() { m_alreadySent = true; }
@@ -186,7 +186,7 @@
};
void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage) const;
- virtual void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage, PassRefPtr<InspectorValue> data) const = 0;
+ virtual void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage, PassRefPtr<JSONValue> data) const = 0;
virtual void dispatch(const String& message) = 0;
static bool getCommandName(const String& message, String* result);
@@ -211,12 +211,12 @@
#include "config.h"
#include "InspectorBackendDispatcher.h"
-
#include "core/inspector/InspectorAgent.h"
#include "core/inspector/InspectorFrontendChannel.h"
-#include "core/inspector/InspectorValues.h"
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include "core/inspector/JSONParser.h"
+#include "core/platform/JSONValues.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -234,10 +234,10 @@
virtual void clearFrontend() { m_inspectorFrontendChannel = 0; }
virtual void dispatch(const String& message);
- virtual void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage, PassRefPtr<InspectorValue> data) const;
+ virtual void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage, PassRefPtr<JSONValue> data) const;
using InspectorBackendDispatcher::reportProtocolError;
- void sendResponse(long callId, PassRefPtr<InspectorObject> result, const ErrorString&invocationError, PassRefPtr<InspectorValue> errorData);
+ void sendResponse(long callId, PassRefPtr<JSONObject> result, const ErrorString&invocationError, PassRefPtr<JSONValue> errorData);
bool isActive() { return m_inspectorFrontendChannel; }
$setters
@@ -248,16 +248,16 @@
$fieldDeclarations
template<typename R, typename V, typename V0>
- static R getPropertyValueImpl(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors, V0 initial_value, bool (*as_method)(InspectorValue*, V*), const char* type_name);
+ static R getPropertyValueImpl(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors, V0 initial_value, bool (*as_method)(JSONValue*, V*), const char* type_name);
- static int getInt(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors);
- static double getDouble(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors);
- static String getString(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors);
- static bool getBoolean(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors);
- static PassRefPtr<InspectorObject> getObject(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors);
- static PassRefPtr<InspectorArray> getArray(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors);
+ static int getInt(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors);
+ static double getDouble(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors);
+ static String getString(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors);
+ static bool getBoolean(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors);
+ static PassRefPtr<JSONObject> getObject(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors);
+ static PassRefPtr<JSONArray> getArray(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors);
- void sendResponse(long callId, PassRefPtr<InspectorObject> result, const char* commandName, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError, PassRefPtr<InspectorValue> errorData);
+ void sendResponse(long callId, PassRefPtr<JSONObject> result, const char* commandName, PassRefPtr<JSONArray> protocolErrors, ErrorString invocationError, PassRefPtr<JSONValue> errorData);
};
@@ -272,7 +272,7 @@
void InspectorBackendDispatcherImpl::dispatch(const String& message)
{
RefPtr<InspectorBackendDispatcher> protect = this;
- typedef void (InspectorBackendDispatcherImpl::*CallHandler)(long callId, InspectorObject* messageObject);
+ typedef void (InspectorBackendDispatcherImpl::*CallHandler)(long callId, JSONObject* messageObject);
typedef HashMap<String, CallHandler> DispatchMap;
DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );
long callId = 0;
@@ -286,19 +286,19 @@
dispatchMap.add(commandNames[i], handlers[i]);
}
- RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);
+ RefPtr<JSONValue> parsedMessage = parseJSON(message);
if (!parsedMessage) {
reportProtocolError(0, ParseError, "Message must be in JSON format");
return;
}
- RefPtr<InspectorObject> messageObject = parsedMessage->asObject();
+ RefPtr<JSONObject> messageObject = parsedMessage->asObject();
if (!messageObject) {
reportProtocolError(0, InvalidRequest, "Message must be a JSONified object");
return;
}
- RefPtr<InspectorValue> callIdValue = messageObject->get("id");
+ RefPtr<JSONValue> callIdValue = messageObject->get("id");
if (!callIdValue) {
reportProtocolError(0, InvalidRequest, "'id' property was not found");
return;
@@ -309,7 +309,7 @@
return;
}
- RefPtr<InspectorValue> methodValue = messageObject->get("method");
+ RefPtr<JSONValue> methodValue = messageObject->get("method");
if (!methodValue) {
reportProtocolError(&callId, InvalidRequest, "'method' property wasn't found");
return;
@@ -330,7 +330,7 @@
((*this).*it->value)(callId, messageObject.get());
}
-void InspectorBackendDispatcherImpl::sendResponse(long callId, PassRefPtr<InspectorObject> result, const char* commandName, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError, PassRefPtr<InspectorValue> errorData)
+void InspectorBackendDispatcherImpl::sendResponse(long callId, PassRefPtr<JSONObject> result, const char* commandName, PassRefPtr<JSONArray> protocolErrors, ErrorString invocationError, PassRefPtr<JSONValue> errorData)
{
if (protocolErrors->length()) {
String errorMessage = String::format("Some arguments of method '%s' can't be processed", commandName);
@@ -340,14 +340,14 @@
sendResponse(callId, result, invocationError, errorData);
}
-void InspectorBackendDispatcherImpl::sendResponse(long callId, PassRefPtr<InspectorObject> result, const ErrorString& invocationError, PassRefPtr<InspectorValue> errorData)
+void InspectorBackendDispatcherImpl::sendResponse(long callId, PassRefPtr<JSONObject> result, const ErrorString& invocationError, PassRefPtr<JSONValue> errorData)
{
if (invocationError.length()) {
reportProtocolError(&callId, ServerError, invocationError, errorData);
return;
}
- RefPtr<InspectorObject> responseMessage = InspectorObject::create();
+ RefPtr<JSONObject> responseMessage = JSONObject::create();
responseMessage->setObject("result", result);
responseMessage->setNumber("id", callId);
if (m_inspectorFrontendChannel)
@@ -356,10 +356,10 @@
void InspectorBackendDispatcher::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage) const
{
- reportProtocolError(callId, code, errorMessage, PassRefPtr<InspectorValue>());
+ reportProtocolError(callId, code, errorMessage, PassRefPtr<JSONValue>());
}
-void InspectorBackendDispatcherImpl::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage, PassRefPtr<InspectorValue> data) const
+void InspectorBackendDispatcherImpl::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage, PassRefPtr<JSONValue> data) const
{
DEFINE_STATIC_LOCAL(Vector<int>,s_commonErrors,);
if (!s_commonErrors.size()) {
@@ -373,24 +373,24 @@
ASSERT(code >=0);
ASSERT((unsigned)code < s_commonErrors.size());
ASSERT(s_commonErrors[code]);
- RefPtr<InspectorObject> error = InspectorObject::create();
+ RefPtr<JSONObject> error = JSONObject::create();
error->setNumber("code", s_commonErrors[code]);
error->setString("message", errorMessage);
ASSERT(error);
if (data)
error->setValue("data", data);
- RefPtr<InspectorObject> message = InspectorObject::create();
+ RefPtr<JSONObject> message = JSONObject::create();
message->setObject("error", error);
if (callId)
message->setNumber("id", *callId);
else
- message->setValue("id", InspectorValue::null());
+ message->setValue("id", JSONValue::null());
if (m_inspectorFrontendChannel)
m_inspectorFrontendChannel->sendMessageToFrontend(message->toJSONString());
}
template<typename R, typename V, typename V0>
-R InspectorBackendDispatcherImpl::getPropertyValueImpl(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors, V0 initial_value, bool (*as_method)(InspectorValue*, V*), const char* type_name)
+R InspectorBackendDispatcherImpl::getPropertyValueImpl(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors, V0 initial_value, bool (*as_method)(JSONValue*, V*), const char* type_name)
{
ASSERT(protocolErrors);
@@ -407,8 +407,8 @@
return value;
}
- InspectorObject::const_iterator end = object->end();
- InspectorObject::const_iterator valueIterator = object->find(name);
+ JSONObject::const_iterator end = object->end();
+ JSONObject::const_iterator valueIterator = object->find(name);
if (valueIterator == end) {
if (!valueFound)
@@ -425,51 +425,51 @@
}
struct AsMethodBridges {
- static bool asInt(InspectorValue* value, int* output) { return value->asNumber(output); }
- static bool asDouble(InspectorValue* value, double* output) { return value->asNumber(output); }
- static bool asString(InspectorValue* value, String* output) { return value->asString(output); }
- static bool asBoolean(InspectorValue* value, bool* output) { return value->asBoolean(output); }
- static bool asObject(InspectorValue* value, RefPtr<InspectorObject>* output) { return value->asObject(output); }
- static bool asArray(InspectorValue* value, RefPtr<InspectorArray>* output) { return value->asArray(output); }
+ static bool asInt(JSONValue* value, int* output) { return value->asNumber(output); }
+ static bool asDouble(JSONValue* value, double* output) { return value->asNumber(output); }
+ static bool asString(JSONValue* value, String* output) { return value->asString(output); }
+ static bool asBoolean(JSONValue* value, bool* output) { return value->asBoolean(output); }
+ static bool asObject(JSONValue* value, RefPtr<JSONObject>* output) { return value->asObject(output); }
+ static bool asArray(JSONValue* value, RefPtr<JSONArray>* output) { return value->asArray(output); }
};
-int InspectorBackendDispatcherImpl::getInt(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
+int InspectorBackendDispatcherImpl::getInt(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors)
{
return getPropertyValueImpl<int, int, int>(object, name, valueFound, protocolErrors, 0, AsMethodBridges::asInt, "Number");
}
-double InspectorBackendDispatcherImpl::getDouble(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
+double InspectorBackendDispatcherImpl::getDouble(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors)
{
return getPropertyValueImpl<double, double, double>(object, name, valueFound, protocolErrors, 0, AsMethodBridges::asDouble, "Number");
}
-String InspectorBackendDispatcherImpl::getString(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
+String InspectorBackendDispatcherImpl::getString(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors)
{
return getPropertyValueImpl<String, String, String>(object, name, valueFound, protocolErrors, "", AsMethodBridges::asString, "String");
}
-bool InspectorBackendDispatcherImpl::getBoolean(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
+bool InspectorBackendDispatcherImpl::getBoolean(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors)
{
return getPropertyValueImpl<bool, bool, bool>(object, name, valueFound, protocolErrors, false, AsMethodBridges::asBoolean, "Boolean");
}
-PassRefPtr<InspectorObject> InspectorBackendDispatcherImpl::getObject(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
+PassRefPtr<JSONObject> InspectorBackendDispatcherImpl::getObject(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors)
{
- return getPropertyValueImpl<PassRefPtr<InspectorObject>, RefPtr<InspectorObject>, InspectorObject*>(object, name, valueFound, protocolErrors, 0, AsMethodBridges::asObject, "Object");
+ return getPropertyValueImpl<PassRefPtr<JSONObject>, RefPtr<JSONObject>, JSONObject*>(object, name, valueFound, protocolErrors, 0, AsMethodBridges::asObject, "Object");
}
-PassRefPtr<InspectorArray> InspectorBackendDispatcherImpl::getArray(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors)
+PassRefPtr<JSONArray> InspectorBackendDispatcherImpl::getArray(JSONObject* object, const String& name, bool* valueFound, JSONArray* protocolErrors)
{
- return getPropertyValueImpl<PassRefPtr<InspectorArray>, RefPtr<InspectorArray>, InspectorArray*>(object, name, valueFound, protocolErrors, 0, AsMethodBridges::asArray, "Array");
+ return getPropertyValueImpl<PassRefPtr<JSONArray>, RefPtr<JSONArray>, JSONArray*>(object, name, valueFound, protocolErrors, 0, AsMethodBridges::asArray, "Array");
}
bool InspectorBackendDispatcher::getCommandName(const String& message, String* result)
{
- RefPtr<InspectorValue> value = InspectorValue::parseJSON(message);
+ RefPtr<JSONValue> value = parseJSON(message);
if (!value)
return false;
- RefPtr<InspectorObject> object = value->asObject();
+ RefPtr<JSONObject> object = value->asObject();
if (!object)
return false;
@@ -487,7 +487,7 @@
void InspectorBackendDispatcher::CallbackBase::sendFailure(const ErrorString& error)
{
ASSERT(error.length());
- sendIfActive(0, error, PassRefPtr<InspectorValue>());
+ sendIfActive(0, error, PassRefPtr<JSONValue>());
}
bool InspectorBackendDispatcher::CallbackBase::isActive()
@@ -495,7 +495,7 @@
return !m_alreadySent && m_backendImpl->isActive();
}
-void InspectorBackendDispatcher::CallbackBase::sendIfActive(PassRefPtr<InspectorObject> partialMessage, const ErrorString& invocationError, PassRefPtr<InspectorValue> errorData)
+void InspectorBackendDispatcher::CallbackBase::sendIfActive(PassRefPtr<JSONObject> partialMessage, const ErrorString& invocationError, PassRefPtr<JSONValue> errorData)
{
if (m_alreadySent)
return;
@@ -513,13 +513,12 @@
"""
#include "config.h"
-
#include "InspectorFrontend.h"
-#include "core/inspector/InspectorFrontendChannel.h"
-#include "core/inspector/InspectorValues.h"
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include "core/inspector/InspectorFrontendChannel.h"
+#include "core/platform/JSONValues.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -538,10 +537,9 @@
#ifndef InspectorTypeBuilder_h
#define InspectorTypeBuilder_h
-#include "core/inspector/InspectorValues.h"
-
-#include <wtf/Assertions.h>
-#include <wtf/PassRefPtr.h>
+#include "core/platform/JSONValues.h"
+#include "wtf/Assertions.h"
+#include "wtf/PassRefPtr.h"
namespace WebCore {
@@ -600,13 +598,13 @@
class RuntimeCastHelper {
public:
#if $validatorIfdefName
- template<InspectorValue::Type TYPE>
- static void assertType(InspectorValue* value)
+ template<JSONValue::Type TYPE>
+ static void assertType(JSONValue* value)
{
ASSERT(value->type() == TYPE);
}
- static void assertAny(InspectorValue*);
- static void assertInt(InspectorValue* value);
+ static void assertAny(JSONValue*);
+ static void assertInt(JSONValue* value);
#endif
};
@@ -619,13 +617,13 @@
};
template<typename T>
-class Array : public InspectorArrayBase {
+class Array : public JSONArrayBase {
private:
Array() { }
- InspectorArray* openAccessors() {
- COMPILE_ASSERT(sizeof(InspectorArray) == sizeof(Array<T>), cannot_cast);
- return static_cast<InspectorArray*>(static_cast<InspectorArrayBase*>(this));
+ JSONArray* openAccessors() {
+ COMPILE_ASSERT(sizeof(JSONArray) == sizeof(Array<T>), cannot_cast);
+ return static_cast<JSONArray*>(static_cast<JSONArrayBase*>(this));
}
public:
@@ -644,22 +642,22 @@
return adoptRef(new Array<T>());
}
- static PassRefPtr<Array<T> > runtimeCast(PassRefPtr<InspectorValue> value)
+ static PassRefPtr<Array<T> > runtimeCast(PassRefPtr<JSONValue> value)
{
- RefPtr<InspectorArray> array;
+ RefPtr<JSONArray> array;
bool castRes = value->asArray(&array);
ASSERT_UNUSED(castRes, castRes);
#if $validatorIfdefName
assertCorrectValue(array.get());
#endif // $validatorIfdefName
- COMPILE_ASSERT(sizeof(Array<T>) == sizeof(InspectorArray), type_cast_problem);
- return static_cast<Array<T>*>(static_cast<InspectorArrayBase*>(array.get()));
+ COMPILE_ASSERT(sizeof(Array<T>) == sizeof(JSONArray), type_cast_problem);
+ return static_cast<Array<T>*>(static_cast<JSONArrayBase*>(array.get()));
}
#if $validatorIfdefName
- static void assertCorrectValue(InspectorValue* value)
+ static void assertCorrectValue(JSONValue* value)
{
- RefPtr<InspectorArray> array;
+ RefPtr<JSONArray> array;
bool castRes = value->asArray(&array);
ASSERT_UNUSED(castRes, castRes);
for (unsigned i = 0; i < array->length(); i++)
@@ -670,14 +668,14 @@
};
struct StructItemTraits {
- static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorValue> value)
+ static void pushRefPtr(JSONArray* array, PassRefPtr<JSONValue> value)
{
array->pushValue(value);
}
#if $validatorIfdefName
template<typename T>
- static void assertCorrectValue(InspectorValue* value) {
+ static void assertCorrectValue(JSONValue* value) {
T::assertCorrectValue(value);
}
#endif // $validatorIfdefName
@@ -686,15 +684,15 @@
template<>
struct ArrayItemHelper<String> {
struct Traits {
- static void pushRaw(InspectorArray* array, const String& value)
+ static void pushRaw(JSONArray* array, const String& value)
{
array->pushString(value);
}
#if $validatorIfdefName
template<typename T>
- static void assertCorrectValue(InspectorValue* value) {
- RuntimeCastHelper::assertType<InspectorValue::TypeString>(value);
+ static void assertCorrectValue(JSONValue* value) {
+ RuntimeCastHelper::assertType<JSONValue::TypeString>(value);
}
#endif // $validatorIfdefName
};
@@ -703,14 +701,14 @@
template<>
struct ArrayItemHelper<int> {
struct Traits {
- static void pushRaw(InspectorArray* array, int value)
+ static void pushRaw(JSONArray* array, int value)
{
array->pushInt(value);
}
#if $validatorIfdefName
template<typename T>
- static void assertCorrectValue(InspectorValue* value) {
+ static void assertCorrectValue(JSONValue* value) {
RuntimeCastHelper::assertInt(value);
}
#endif // $validatorIfdefName
@@ -720,15 +718,15 @@
template<>
struct ArrayItemHelper<double> {
struct Traits {
- static void pushRaw(InspectorArray* array, double value)
+ static void pushRaw(JSONArray* array, double value)
{
array->pushNumber(value);
}
#if $validatorIfdefName
template<typename T>
- static void assertCorrectValue(InspectorValue* value) {
- RuntimeCastHelper::assertType<InspectorValue::TypeNumber>(value);
+ static void assertCorrectValue(JSONValue* value) {
+ RuntimeCastHelper::assertType<JSONValue::TypeNumber>(value);
}
#endif // $validatorIfdefName
};
@@ -737,31 +735,31 @@
template<>
struct ArrayItemHelper<bool> {
struct Traits {
- static void pushRaw(InspectorArray* array, bool value)
+ static void pushRaw(JSONArray* array, bool value)
{
array->pushBoolean(value);
}
#if $validatorIfdefName
template<typename T>
- static void assertCorrectValue(InspectorValue* value) {
- RuntimeCastHelper::assertType<InspectorValue::TypeBoolean>(value);
+ static void assertCorrectValue(JSONValue* value) {
+ RuntimeCastHelper::assertType<JSONValue::TypeBoolean>(value);
}
#endif // $validatorIfdefName
};
};
template<>
-struct ArrayItemHelper<InspectorValue> {
+struct ArrayItemHelper<JSONValue> {
struct Traits {
- static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorValue> value)
+ static void pushRefPtr(JSONArray* array, PassRefPtr<JSONValue> value)
{
array->pushValue(value);
}
#if $validatorIfdefName
template<typename T>
- static void assertCorrectValue(InspectorValue* value) {
+ static void assertCorrectValue(JSONValue* value) {
RuntimeCastHelper::assertAny(value);
}
#endif // $validatorIfdefName
@@ -769,34 +767,34 @@
};
template<>
-struct ArrayItemHelper<InspectorObject> {
+struct ArrayItemHelper<JSONObject> {
struct Traits {
- static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorValue> value)
+ static void pushRefPtr(JSONArray* array, PassRefPtr<JSONValue> value)
{
array->pushValue(value);
}
#if $validatorIfdefName
template<typename T>
- static void assertCorrectValue(InspectorValue* value) {
- RuntimeCastHelper::assertType<InspectorValue::TypeObject>(value);
+ static void assertCorrectValue(JSONValue* value) {
+ RuntimeCastHelper::assertType<JSONValue::TypeObject>(value);
}
#endif // $validatorIfdefName
};
};
template<>
-struct ArrayItemHelper<InspectorArray> {
+struct ArrayItemHelper<JSONArray> {
struct Traits {
- static void pushRefPtr(InspectorArray* array, PassRefPtr<InspectorArray> value)
+ static void pushRefPtr(JSONArray* array, PassRefPtr<JSONArray> value)
{
array->pushArray(value);
}
#if $validatorIfdefName
template<typename T>
- static void assertCorrectValue(InspectorValue* value) {
- RuntimeCastHelper::assertType<InspectorValue::TypeArray>(value);
+ static void assertCorrectValue(JSONValue* value) {
+ RuntimeCastHelper::assertType<JSONValue::TypeArray>(value);
}
#endif // $validatorIfdefName
};
@@ -805,14 +803,14 @@
template<typename T>
struct ArrayItemHelper<TypeBuilder::Array<T> > {
struct Traits {
- static void pushRefPtr(InspectorArray* array, PassRefPtr<TypeBuilder::Array<T> > value)
+ static void pushRefPtr(JSONArray* array, PassRefPtr<TypeBuilder::Array<T> > value)
{
array->pushValue(value);
}
#if $validatorIfdefName
template<typename S>
- static void assertCorrectValue(InspectorValue* value) {
+ static void assertCorrectValue(JSONValue* value) {
S::assertCorrectValue(value);
}
#endif // $validatorIfdefName
@@ -839,8 +837,7 @@
#include "config.h"
#include "InspectorTypeBuilder.h"
-
-#include <wtf/text/CString.h>
+#include "wtf/text/CString.h"
namespace WebCore {
@@ -859,13 +856,13 @@
#if $validatorIfdefName
-void TypeBuilder::RuntimeCastHelper::assertAny(InspectorValue*)
+void TypeBuilder::RuntimeCastHelper::assertAny(JSONValue*)
{
// No-op.
}
-void TypeBuilder::RuntimeCastHelper::assertInt(InspectorValue* value)
+void TypeBuilder::RuntimeCastHelper::assertInt(JSONValue* value)
{
double v;
bool castRes = value->asNumber(&v);
@@ -882,9 +879,9 @@
""")
param_container_access_code = """
- RefPtr<InspectorObject> paramsContainer = requestMessageObject->getObject("params");
- InspectorObject* paramsContainerPtr = paramsContainer.get();
- InspectorArray* protocolErrorsPtr = protocolErrors.get();
+ RefPtr<JSONObject> paramsContainer = requestMessageObject->getObject("params");
+ JSONObject* paramsContainerPtr = paramsContainer.get();
+ JSONArray* protocolErrorsPtr = protocolErrors.get();
"""
class_binding_builder_part_1 = (
@@ -894,14 +891,14 @@
template<int STATE>
class Builder {
private:
- RefPtr<InspectorObject> m_result;
+ RefPtr<JSONObject> m_result;
template<int STEP> Builder<STATE | STEP>& castState()
{
return *reinterpret_cast<Builder<STATE | STEP>*>(this);
}
- Builder(PassRefPtr</*%s*/InspectorObject> ptr)
+ Builder(PassRefPtr</*%s*/JSONObject> ptr)
{
COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state);
m_result = ptr;
@@ -923,7 +920,7 @@
operator RefPtr<%s>& ()
{
COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready);
- COMPILE_ASSERT(sizeof(%s) == sizeof(InspectorObject), cannot_cast);
+ COMPILE_ASSERT(sizeof(%s) == sizeof(JSONObject), cannot_cast);
return *reinterpret_cast<RefPtr<%s>*>(&m_result);
}
@@ -938,6 +935,6 @@
class_binding_builder_part_4 = (
""" static Builder<NoFieldsSet> create()
{
- return Builder<NoFieldsSet>(InspectorObject::create());
+ return Builder<NoFieldsSet>(JSONObject::create());
}
""")
diff --git a/Source/core/inspector/CodeGeneratorInstrumentation.py b/Source/core/inspector/CodeGeneratorInstrumentation.py
index 372d141..b72cb5d 100644
--- a/Source/core/inspector/CodeGeneratorInstrumentation.py
+++ b/Source/core/inspector/CodeGeneratorInstrumentation.py
@@ -277,6 +277,10 @@
else:
fast_return = ""
+ for param in self.params:
+ if "FastReturn" in param.options:
+ fast_return += "\n if (!%s)\n return %s;" % (param.name, self.default_return_value)
+
if self.accepts_cookie:
condition = "%s.isValid()" % self.params_impl[0].name
template = template_inline
diff --git a/Source/core/inspector/ConsoleMessage.cpp b/Source/core/inspector/ConsoleMessage.cpp
index fed5016..7ce1741 100644
--- a/Source/core/inspector/ConsoleMessage.cpp
+++ b/Source/core/inspector/ConsoleMessage.cpp
@@ -42,9 +42,7 @@
#include "core/inspector/ScriptArguments.h"
#include "core/inspector/ScriptCallFrame.h"
#include "core/inspector/ScriptCallStack.h"
-#include "core/page/Console.h"
#include "wtf/CurrentTime.h"
-#include "wtf/MainThread.h"
namespace WebCore {
@@ -55,6 +53,7 @@
, m_message(message)
, m_url()
, m_line(0)
+ , m_column(0)
, m_repeatCount(1)
, m_requestId(IdentifiersFactory::requestId(0))
, m_timestamp(WTF::currentTime())
@@ -62,13 +61,14 @@
autogenerateMetadata(canGenerateCallStack);
}
-ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& url, unsigned line, ScriptState* state, unsigned long requestIdentifier)
+ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& url, unsigned line, unsigned column, ScriptState* state, unsigned long requestIdentifier)
: m_source(source)
, m_type(type)
, m_level(level)
, m_message(message)
, m_url(url)
, m_line(line)
+ , m_column(column)
, m_repeatCount(1)
, m_requestId(IdentifiersFactory::requestId(requestIdentifier))
, m_timestamp(WTF::currentTime())
@@ -83,6 +83,7 @@
, m_message(message)
, m_arguments(0)
, m_line(0)
+ , m_column(0)
, m_repeatCount(1)
, m_requestId(IdentifiersFactory::requestId(requestIdentifier))
, m_timestamp(WTF::currentTime())
@@ -91,6 +92,7 @@
const ScriptCallFrame& frame = callStack->at(0);
m_url = frame.sourceURL();
m_line = frame.lineNumber();
+ m_column = frame.columnNumber();
}
m_callStack = callStack;
}
@@ -103,6 +105,7 @@
, m_arguments(arguments)
, m_url()
, m_line(0)
+ , m_column(0)
, m_repeatCount(1)
, m_requestId(IdentifiersFactory::requestId(requestIdentifier))
, m_timestamp(WTF::currentTime())
@@ -130,6 +133,7 @@
const ScriptCallFrame& frame = m_callStack->at(0);
m_url = frame.sourceURL();
m_line = frame.lineNumber();
+ m_column = frame.columnNumber();
return;
}
@@ -195,6 +199,7 @@
// FIXME: only send out type for ConsoleAPI source messages.
jsonObj->setType(messageTypeValue(m_type));
jsonObj->setLine(static_cast<int>(m_line));
+ jsonObj->setColumn(static_cast<int>(m_column));
jsonObj->setUrl(m_url);
jsonObj->setRepeatCount(static_cast<int>(m_repeatCount));
if (m_source == NetworkMessageSource && !m_requestId.isEmpty())
@@ -265,6 +270,7 @@
&& msg->m_level == m_level
&& msg->m_message == m_message
&& msg->m_line == m_line
+ && msg->m_column == m_column
&& msg->m_url == m_url
&& msg->m_requestId == m_requestId;
}
diff --git a/Source/core/inspector/ConsoleMessage.h b/Source/core/inspector/ConsoleMessage.h
index 4ea2bdd..78f4f9f 100644
--- a/Source/core/inspector/ConsoleMessage.h
+++ b/Source/core/inspector/ConsoleMessage.h
@@ -35,15 +35,13 @@
#include "bindings/v8/ScriptState.h"
#include "core/inspector/ConsoleAPITypes.h"
#include "core/page/ConsoleTypes.h"
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
namespace WebCore {
class DOMWindow;
class InjectedScriptManager;
class InspectorFrontend;
-class InspectorObject;
class ScriptArguments;
class ScriptCallFrame;
class ScriptCallStack;
@@ -53,7 +51,7 @@
WTF_MAKE_NONCOPYABLE(ConsoleMessage); WTF_MAKE_FAST_ALLOCATED;
public:
ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message);
- ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, ScriptState*, unsigned long requestIdentifier);
+ ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, unsigned column, ScriptState*, unsigned long requestIdentifier);
ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>, unsigned long requestIdentifier);
ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, ScriptState*, unsigned long requestIdentifier);
~ConsoleMessage();
@@ -83,6 +81,7 @@
RefPtr<ScriptCallStack> m_callStack;
String m_url;
unsigned m_line;
+ unsigned m_column;
unsigned m_repeatCount;
String m_requestId;
double m_timestamp;
diff --git a/Source/core/inspector/ContentSearchUtils.cpp b/Source/core/inspector/ContentSearchUtils.cpp
index 64dc152..86c79ea 100644
--- a/Source/core/inspector/ContentSearchUtils.cpp
+++ b/Source/core/inspector/ContentSearchUtils.cpp
@@ -31,7 +31,6 @@
#include "core/inspector/ContentSearchUtils.h"
#include "core/platform/text/RegularExpression.h"
-#include <wtf/StdLibExtras.h>
using namespace std;
@@ -46,45 +45,28 @@
static String createSearchRegexSource(const String& text)
{
String result;
- const UChar* characters = text.characters();
String specials(regexSpecialCharacters);
for (unsigned i = 0; i < text.length(); i++) {
- if (specials.find(characters[i]) != notFound)
+ if (specials.find(text[i]) != notFound)
result.append("\\");
- result.append(characters[i]);
+ result.append(text[i]);
}
return result;
}
-static inline size_t sizetExtractor(const size_t* value)
-{
- return *value;
-}
-
-TextPosition textPositionFromOffset(size_t offset, const Vector<size_t>& lineEndings)
-{
- const size_t* foundLineEnding = approximateBinarySearch<size_t, size_t>(lineEndings, lineEndings.size(), offset, sizetExtractor);
- size_t lineIndex = foundLineEnding - &lineEndings.at(0);
- if (offset > *foundLineEnding)
- ++lineIndex;
- size_t lineStartOffset = lineIndex > 0 ? lineEndings.at(lineIndex - 1) + 1 : 0;
- size_t column = offset - lineStartOffset;
- return TextPosition(OrdinalNumber::fromZeroBasedInt(lineIndex), OrdinalNumber::fromZeroBasedInt(column));
-}
-
static Vector<pair<int, String> > getRegularExpressionMatchesByLines(const RegularExpression* regex, const String& text)
{
Vector<pair<int, String> > result;
if (text.isEmpty())
return result;
- OwnPtr<Vector<size_t> > endings(lineEndings(text));
- size_t size = endings->size();
+ OwnPtr<Vector<unsigned> > endings(lineEndings(text));
+ unsigned size = endings->size();
unsigned start = 0;
- for (size_t lineNumber = 0; lineNumber < size; ++lineNumber) {
- size_t lineEnd = endings->at(lineNumber);
+ for (unsigned lineNumber = 0; lineNumber < size; ++lineNumber) {
+ unsigned lineEnd = endings->at(lineNumber);
String line = text.substring(start, lineEnd - start);
if (line.endsWith('\r'))
line = line.left(line.length() - 1);
@@ -98,24 +80,6 @@
return result;
}
-PassOwnPtr<Vector<size_t> > lineEndings(const String& text)
-{
- OwnPtr<Vector<size_t> > result(adoptPtr(new Vector<size_t>()));
-
- unsigned start = 0;
- while (start < text.length()) {
- size_t lineEnd = text.find('\n', start);
- if (lineEnd == notFound)
- break;
-
- result->append(lineEnd);
- start = lineEnd + 1;
- }
- result->append(text.length());
-
- return result.release();
-}
-
static PassRefPtr<TypeBuilder::Page::SearchMatch> buildObjectForSearchMatch(int lineNumber, const String& lineContent)
{
return TypeBuilder::Page::SearchMatch::create()
diff --git a/Source/core/inspector/ContentSearchUtils.h b/Source/core/inspector/ContentSearchUtils.h
index 6691d39..eb189ae 100644
--- a/Source/core/inspector/ContentSearchUtils.h
+++ b/Source/core/inspector/ContentSearchUtils.h
@@ -38,7 +38,6 @@
namespace WebCore {
-class InspectorArray;
class RegularExpression;
namespace ContentSearchUtils {
@@ -51,8 +50,6 @@
PassOwnPtr<RegularExpression> createSearchRegex(const String& query, bool caseSensitive, bool isRegex);
int countRegularExpressionMatches(const RegularExpression*, const String&);
PassRefPtr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> > searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex);
-TextPosition textPositionFromOffset(size_t offset, const Vector<size_t>& lineEndings);
-PassOwnPtr<Vector<size_t> > lineEndings(const String&);
String findSourceURL(const String& content, MagicCommentType, bool* deprecated);
String findSourceMapURL(const String& content, MagicCommentType, bool* deprecated);
diff --git a/Source/core/inspector/DOMEditor.cpp b/Source/core/inspector/DOMEditor.cpp
index 3140edd..55fc766 100644
--- a/Source/core/inspector/DOMEditor.cpp
+++ b/Source/core/inspector/DOMEditor.cpp
@@ -33,6 +33,7 @@
#include "core/inspector/DOMEditor.h"
+#include "core/dom/DOMException.h"
#include "core/dom/Element.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/Node.h"
@@ -399,10 +400,8 @@
static void populateErrorString(const ExceptionCode& ec, ErrorString* errorString)
{
- if (ec) {
- ExceptionCodeDescription description(ec);
- *errorString = description.name;
- }
+ if (ec)
+ *errorString = DOMException::getErrorName(ec);
}
bool DOMEditor::insertBefore(Node* parentNode, PassRefPtr<Node> node, Node* anchorNode, ErrorString* errorString)
diff --git a/Source/core/inspector/HeapGraphSerializer.cpp b/Source/core/inspector/HeapGraphSerializer.cpp
index 41d1824..f159e05 100644
--- a/Source/core/inspector/HeapGraphSerializer.cpp
+++ b/Source/core/inspector/HeapGraphSerializer.cpp
@@ -34,11 +34,11 @@
#include "core/inspector/HeapGraphSerializer.h"
#include "core/dom/WebCoreMemoryInstrumentation.h"
-#include <wtf/MemoryInstrumentationHashMap.h>
-#include <wtf/MemoryInstrumentationVector.h>
-#include <wtf/MemoryObjectInfo.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include "core/inspector/JSONParser.h"
+#include "wtf/MemoryInstrumentationHashMap.h"
+#include "wtf/MemoryInstrumentationVector.h"
+#include "wtf/MemoryObjectInfo.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -49,7 +49,7 @@
, m_nodeEdgesCount(0)
, m_nodes(Nodes::create())
, m_baseToRealNodeIdMap(BaseToRealNodeIdMap::create())
- , m_typeStrings(InspectorObject::create())
+ , m_typeStrings(JSONObject::create())
, m_leafCount(0)
{
ASSERT(m_client);
@@ -157,7 +157,7 @@
m_baseToRealNodeIdMap->addItem(toNodeId(real));
}
-PassRefPtr<InspectorObject> HeapGraphSerializer::finish()
+PassRefPtr<JSONObject> HeapGraphSerializer::finish()
{
addRootNode();
pushUpdate();
@@ -189,8 +189,8 @@
"]"
"}";
- RefPtr<InspectorValue> metaValue = InspectorValue::parseJSON(metaString);
- RefPtr<InspectorObject> meta;
+ RefPtr<JSONValue> metaValue = parseJSON(metaString);
+ RefPtr<JSONObject> meta;
metaValue->asObject(&meta);
ASSERT(meta);
meta->setObject("type_strings", m_typeStrings);
diff --git a/Source/core/inspector/HeapGraphSerializer.h b/Source/core/inspector/HeapGraphSerializer.h
index 6669805..e1be9f4 100644
--- a/Source/core/inspector/HeapGraphSerializer.h
+++ b/Source/core/inspector/HeapGraphSerializer.h
@@ -60,7 +60,7 @@
void reportBaseAddress(const void*, const void*);
int registerString(const char*);
- PassRefPtr<InspectorObject> finish();
+ PassRefPtr<JSONObject> finish();
void reportMemoryUsage(MemoryObjectInfo*) const;
@@ -100,7 +100,7 @@
Address2NodeId m_address2NodeIdMap;
Vector<const void*> m_roots;
- RefPtr<InspectorObject> m_typeStrings;
+ RefPtr<JSONObject> m_typeStrings;
size_t m_edgeTypes[WTF::LastMemberTypeEntry];
int m_unknownClassNameId;
diff --git a/Source/core/inspector/InjectedScript.cpp b/Source/core/inspector/InjectedScript.cpp
index 79b0980..43422c8 100644
--- a/Source/core/inspector/InjectedScript.cpp
+++ b/Source/core/inspector/InjectedScript.cpp
@@ -35,8 +35,8 @@
#include "bindings/v8/ScriptFunctionCall.h"
#include "core/inspector/InjectedScriptHost.h"
-#include "core/inspector/InspectorValues.h"
-#include <wtf/text/WTFString.h>
+#include "core/platform/JSONValues.h"
+#include "wtf/text/WTFString.h"
using WebCore::TypeBuilder::Array;
using WebCore::TypeBuilder::Debugger::CallFrame;
@@ -92,19 +92,19 @@
makeEvalCall(errorString, function, result, wasThrown);
}
-void InjectedScript::restartFrame(ErrorString* errorString, const ScriptValue& callFrames, const String& callFrameId, RefPtr<InspectorObject>* result)
+void InjectedScript::restartFrame(ErrorString* errorString, const ScriptValue& callFrames, const String& callFrameId, RefPtr<JSONObject>* result)
{
ScriptFunctionCall function(injectedScriptObject(), "restartFrame");
function.appendArgument(callFrames);
function.appendArgument(callFrameId);
- RefPtr<InspectorValue> resultValue;
+ RefPtr<JSONValue> resultValue;
makeCall(function, &resultValue);
if (resultValue) {
- if (resultValue->type() == InspectorValue::TypeString) {
+ if (resultValue->type() == JSONValue::TypeString) {
resultValue->asString(errorString);
return;
}
- if (resultValue->type() == InspectorValue::TypeObject) {
+ if (resultValue->type() == JSONValue::TypeObject) {
*result = resultValue->asObject();
return;
}
@@ -129,13 +129,13 @@
function.appendArgument(scopeNumber);
function.appendArgument(variableName);
function.appendArgument(newValueStr);
- RefPtr<InspectorValue> resultValue;
+ RefPtr<JSONValue> resultValue;
makeCall(function, &resultValue);
if (!resultValue) {
*errorString = "Internal error";
return;
}
- if (resultValue->type() == InspectorValue::TypeString) {
+ if (resultValue->type() == JSONValue::TypeString) {
resultValue->asString(errorString);
return;
}
@@ -146,9 +146,9 @@
{
ScriptFunctionCall function(injectedScriptObject(), "getFunctionDetails");
function.appendArgument(functionId);
- RefPtr<InspectorValue> resultValue;
+ RefPtr<JSONValue> resultValue;
makeCall(function, &resultValue);
- if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
+ if (!resultValue || resultValue->type() != JSONValue::TypeObject) {
if (!resultValue->asString(errorString))
*errorString = "Internal error";
return;
@@ -163,9 +163,9 @@
function.appendArgument(ownProperties);
function.appendArgument(accessorPropertiesOnly);
- RefPtr<InspectorValue> result;
+ RefPtr<JSONValue> result;
makeCall(function, &result);
- if (!result || result->type() != InspectorValue::TypeArray) {
+ if (!result || result->type() != JSONValue::TypeArray) {
*errorString = "Internal error";
return;
}
@@ -177,9 +177,9 @@
ScriptFunctionCall function(injectedScriptObject(), "getInternalProperties");
function.appendArgument(objectId);
- RefPtr<InspectorValue> result;
+ RefPtr<JSONValue> result;
makeCall(function, &result);
- if (!result || result->type() != InspectorValue::TypeArray) {
+ if (!result || result->type() != JSONValue::TypeArray) {
*errorString = "Internal error";
return;
}
@@ -207,7 +207,7 @@
{
ScriptFunctionCall function(injectedScriptObject(), "releaseObject");
function.appendArgument(objectId);
- RefPtr<InspectorValue> result;
+ RefPtr<JSONValue> result;
makeCall(function, &result);
}
@@ -219,8 +219,8 @@
bool hadException = false;
ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
- RefPtr<InspectorValue> result = callFramesValue.toInspectorValue(scriptState());
- if (result->type() == InspectorValue::TypeArray)
+ RefPtr<JSONValue> result = callFramesValue.toJSONValue(scriptState());
+ if (result->type() == JSONValue::TypeArray)
return Array<CallFrame>::runtimeCast(result);
return Array<CallFrame>::create();
}
@@ -237,7 +237,7 @@
ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException);
if (hadException)
return 0;
- RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
+ RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject();
return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
}
@@ -255,7 +255,7 @@
ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException);
if (hadException)
return 0;
- RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
+ RefPtr<JSONObject> rawResult = r.toJSONValue(scriptState())->asObject();
return TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
}
@@ -281,7 +281,7 @@
ASSERT(!hasNoValue());
ScriptFunctionCall function(injectedScriptObject(), "inspectNode");
function.appendArgument(nodeAsScriptValue(node));
- RefPtr<InspectorValue> result;
+ RefPtr<JSONValue> result;
makeCall(function, &result);
}
diff --git a/Source/core/inspector/InjectedScript.h b/Source/core/inspector/InjectedScript.h
index 2e4347b..609efd2 100644
--- a/Source/core/inspector/InjectedScript.h
+++ b/Source/core/inspector/InjectedScript.h
@@ -36,10 +36,7 @@
#include "core/inspector/InjectedScriptBase.h"
#include "core/inspector/InjectedScriptManager.h"
#include "core/inspector/ScriptArguments.h"
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
+#include "wtf/Forward.h"
namespace WebCore {
@@ -79,7 +76,7 @@
bool generatePreview,
RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
TypeBuilder::OptOutput<bool>* wasThrown);
- void restartFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<InspectorObject>* result);
+ void restartFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<JSONObject>* result);
void setVariableValue(ErrorString*, const ScriptValue& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt, int scopeNumber, const String& variableName, const String& newValueStr);
void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>* result);
void getProperties(ErrorString*, const String& objectId, bool ownProperties, bool accessorPropertiesOnly, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >* result);
diff --git a/Source/core/inspector/InjectedScriptBase.cpp b/Source/core/inspector/InjectedScriptBase.cpp
index 1ffa72f..2f246a8 100644
--- a/Source/core/inspector/InjectedScriptBase.cpp
+++ b/Source/core/inspector/InjectedScriptBase.cpp
@@ -35,8 +35,8 @@
#include "bindings/v8/ScriptFunctionCall.h"
#include "core/inspector/InspectorInstrumentation.h"
-#include "core/inspector/InspectorValues.h"
-#include <wtf/text/WTFString.h>
+#include "core/platform/JSONValues.h"
+#include "wtf/text/WTFString.h"
using WebCore::TypeBuilder::Runtime::RemoteObject;
@@ -94,10 +94,10 @@
return resultValue;
}
-void InjectedScriptBase::makeCall(ScriptFunctionCall& function, RefPtr<InspectorValue>* result)
+void InjectedScriptBase::makeCall(ScriptFunctionCall& function, RefPtr<JSONValue>* result)
{
if (hasNoValue() || !canAccessInspectedWindow()) {
- *result = InspectorValue::null();
+ *result = JSONValue::null();
return;
}
@@ -106,32 +106,33 @@
ASSERT(!hadException);
if (!hadException) {
- *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState());
+ *result = resultValue.toJSONValue(m_injectedScriptObject.scriptState());
if (!*result)
- *result = InspectorString::create(String::format("Object has too long reference chain(must not be longer than %d)", InspectorValue::maxDepth));
- } else
- *result = InspectorString::create("Exception while making a call.");
+ *result = JSONString::create(String::format("Object has too long reference chain(must not be longer than %d)", JSONValue::maxDepth));
+ } else {
+ *result = JSONString::create("Exception while making a call.");
+ }
}
void InjectedScriptBase::makeEvalCall(ErrorString* errorString, ScriptFunctionCall& function, RefPtr<TypeBuilder::Runtime::RemoteObject>* objectResult, TypeBuilder::OptOutput<bool>* wasThrown)
{
- RefPtr<InspectorValue> result;
+ RefPtr<JSONValue> result;
makeCall(function, &result);
if (!result) {
*errorString = "Internal error: result value is empty";
return;
}
- if (result->type() == InspectorValue::TypeString) {
+ if (result->type() == JSONValue::TypeString) {
result->asString(errorString);
ASSERT(errorString->length());
return;
}
- RefPtr<InspectorObject> resultPair = result->asObject();
+ RefPtr<JSONObject> resultPair = result->asObject();
if (!resultPair) {
*errorString = "Internal error: result is not an Object";
return;
}
- RefPtr<InspectorObject> resultObj = resultPair->getObject("result");
+ RefPtr<JSONObject> resultObj = resultPair->getObject("result");
bool wasThrownVal = false;
if (!resultObj || !resultPair->getBoolean("wasThrown", &wasThrownVal)) {
*errorString = "Internal error: result is not a pair of value and wasThrown flag";
diff --git a/Source/core/inspector/InjectedScriptBase.h b/Source/core/inspector/InjectedScriptBase.h
index 17b8ca3..194d022 100644
--- a/Source/core/inspector/InjectedScriptBase.h
+++ b/Source/core/inspector/InjectedScriptBase.h
@@ -33,12 +33,11 @@
#include "InspectorTypeBuilder.h"
#include "bindings/v8/ScriptObject.h"
-#include <wtf/Forward.h>
-#include <wtf/RefPtr.h>
+#include "wtf/Forward.h"
namespace WebCore {
-class InspectorValue;
+class JSONValue;
class ScriptFunctionCall;
typedef String ErrorString;
@@ -61,7 +60,7 @@
bool canAccessInspectedWindow() const;
const ScriptObject& injectedScriptObject() const;
ScriptValue callFunctionWithEvalEnabled(ScriptFunctionCall&, bool& hadException) const;
- void makeCall(ScriptFunctionCall&, RefPtr<InspectorValue>* result);
+ void makeCall(ScriptFunctionCall&, RefPtr<JSONValue>* result);
void makeEvalCall(ErrorString*, ScriptFunctionCall&, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown);
private:
diff --git a/Source/core/inspector/InjectedScriptCanvasModule.cpp b/Source/core/inspector/InjectedScriptCanvasModule.cpp
index 618fee6..ec892d4 100644
--- a/Source/core/inspector/InjectedScriptCanvasModule.cpp
+++ b/Source/core/inspector/InjectedScriptCanvasModule.cpp
@@ -29,8 +29,6 @@
*/
#include "config.h"
-
-
#include "core/inspector/InjectedScriptCanvasModule.h"
#include "InjectedScriptCanvasModuleSource.h"
@@ -43,6 +41,7 @@
using WebCore::TypeBuilder::Canvas::ResourceState;
using WebCore::TypeBuilder::Canvas::TraceLog;
using WebCore::TypeBuilder::Canvas::TraceLogId;
+using WebCore::TypeBuilder::Runtime::RemoteObject;
namespace WebCore {
@@ -89,7 +88,7 @@
void InjectedScriptCanvasModule::markFrameEnd()
{
ScriptFunctionCall function(injectedScriptObject(), "markFrameEnd");
- RefPtr<InspectorValue> resultValue;
+ RefPtr<JSONValue> resultValue;
makeCall(function, &resultValue);
ASSERT(resultValue);
}
@@ -107,9 +106,9 @@
void InjectedScriptCanvasModule::callStartCapturingFunction(const String& functionName, ErrorString* errorString, TraceLogId* traceLogId)
{
ScriptFunctionCall function(injectedScriptObject(), functionName);
- RefPtr<InspectorValue> resultValue;
+ RefPtr<JSONValue> resultValue;
makeCall(function, &resultValue);
- if (!resultValue || resultValue->type() != InspectorValue::TypeString || !resultValue->asString(traceLogId))
+ if (!resultValue || resultValue->type() != JSONValue::TypeString || !resultValue->asString(traceLogId))
*errorString = "Internal error: " + functionName;
}
@@ -142,9 +141,9 @@
function.appendArgument(*startOffset);
if (maxLength)
function.appendArgument(*maxLength);
- RefPtr<InspectorValue> resultValue;
+ RefPtr<JSONValue> resultValue;
makeCall(function, &resultValue);
- if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
+ if (!resultValue || resultValue->type() != JSONValue::TypeObject) {
if (!resultValue->asString(errorString))
*errorString = "Internal error: traceLog";
return;
@@ -157,9 +156,9 @@
ScriptFunctionCall function(injectedScriptObject(), "replayTraceLog");
function.appendArgument(traceLogId);
function.appendArgument(stepNo);
- RefPtr<InspectorValue> resultValue;
+ RefPtr<JSONValue> resultValue;
makeCall(function, &resultValue);
- if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
+ if (!resultValue || resultValue->type() != JSONValue::TypeObject) {
if (!resultValue->asString(errorString))
*errorString = "Internal error: replayTraceLog";
return;
@@ -171,9 +170,9 @@
{
ScriptFunctionCall function(injectedScriptObject(), "resourceInfo");
function.appendArgument(resourceId);
- RefPtr<InspectorValue> resultValue;
+ RefPtr<JSONValue> resultValue;
makeCall(function, &resultValue);
- if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
+ if (!resultValue || resultValue->type() != JSONValue::TypeObject) {
if (!resultValue->asString(errorString))
*errorString = "Internal error: resourceInfo";
return;
@@ -186,9 +185,9 @@
ScriptFunctionCall function(injectedScriptObject(), "resourceState");
function.appendArgument(traceLogId);
function.appendArgument(resourceId);
- RefPtr<InspectorValue> resultValue;
+ RefPtr<JSONValue> resultValue;
makeCall(function, &resultValue);
- if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
+ if (!resultValue || resultValue->type() != JSONValue::TypeObject) {
if (!resultValue->asString(errorString))
*errorString = "Internal error: resourceState";
return;
@@ -196,5 +195,29 @@
*result = ResourceState::runtimeCast(resultValue);
}
-} // namespace WebCore
+void InjectedScriptCanvasModule::evaluateTraceLogCallArgument(ErrorString* errorString, const TraceLogId& traceLogId, int callIndex, int argumentIndex, const String& objectGroup, RefPtr<RemoteObject>* result, RefPtr<ResourceState>* resourceState)
+{
+ ScriptFunctionCall function(injectedScriptObject(), "evaluateTraceLogCallArgument");
+ function.appendArgument(traceLogId);
+ function.appendArgument(callIndex);
+ function.appendArgument(argumentIndex);
+ function.appendArgument(objectGroup);
+ RefPtr<JSONValue> resultValue;
+ makeCall(function, &resultValue);
+ if (!resultValue || resultValue->type() != JSONValue::TypeObject) {
+ if (!resultValue->asString(errorString))
+ *errorString = "Internal error: evaluateTraceLogCallArgument";
+ return;
+ }
+ RefPtr<JSONObject> resultObject = resultValue->asObject();
+ RefPtr<JSONObject> remoteObject = resultObject->getObject("result");
+ if (remoteObject)
+ *result = RemoteObject::runtimeCast(remoteObject);
+ RefPtr<JSONObject> resourceStateObject = resultObject->getObject("resourceState");
+ if (resourceStateObject)
+ *resourceState = ResourceState::runtimeCast(resourceStateObject);
+ if (!remoteObject && !resourceStateObject)
+ *errorString = "Internal error: no result and no resource state";
+}
+} // namespace WebCore
diff --git a/Source/core/inspector/InjectedScriptCanvasModule.h b/Source/core/inspector/InjectedScriptCanvasModule.h
index 8999373..c34aab8 100644
--- a/Source/core/inspector/InjectedScriptCanvasModule.h
+++ b/Source/core/inspector/InjectedScriptCanvasModule.h
@@ -33,7 +33,7 @@
#include "bindings/v8/ScriptState.h"
#include "core/inspector/InjectedScriptModule.h"
-#include <wtf/text/WTFString.h>
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -61,6 +61,7 @@
void replayTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, RefPtr<TypeBuilder::Canvas::ResourceState>*);
void resourceInfo(ErrorString*, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceInfo>*);
void resourceState(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceState>*);
+ void evaluateTraceLogCallArgument(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, int, const String&, RefPtr<TypeBuilder::Runtime::RemoteObject>*, RefPtr<TypeBuilder::Canvas::ResourceState>*);
private:
ScriptObject callWrapContextFunction(const String&, const ScriptObject&);
diff --git a/Source/core/inspector/InjectedScriptCanvasModuleSource.js b/Source/core/inspector/InjectedScriptCanvasModuleSource.js
index ffc22b0..98c489e 100644
--- a/Source/core/inspector/InjectedScriptCanvasModuleSource.js
+++ b/Source/core/inspector/InjectedScriptCanvasModuleSource.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 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
@@ -29,11 +29,12 @@
*/
/**
- * @param {InjectedScriptHost} InjectedScriptHost
+ * @param {InjectedScriptHostClass} InjectedScriptHost
* @param {Window} inspectedWindow
* @param {number} injectedScriptId
+ * @param {!InjectedScript} injectedScript
*/
-(function (InjectedScriptHost, inspectedWindow, injectedScriptId) {
+(function (InjectedScriptHost, inspectedWindow, injectedScriptId, injectedScript) {
var TypeUtils = {
/**
@@ -542,6 +543,24 @@
},
/**
+ * @return {string}
+ */
+ propertyName: function()
+ {
+ console.assert(this.isPropertySetter());
+ return /** @type {string} */ (this._args[0]);
+ },
+
+ /**
+ * @return {*}
+ */
+ propertyValue: function()
+ {
+ console.assert(this.isPropertySetter());
+ return this._args[1];
+ },
+
+ /**
* @return {Array.<ReplayableResource|*>}
*/
args: function()
@@ -583,7 +602,7 @@
},
/**
- * @param {Cache} cache
+ * @param {!Cache} cache
* @return {!Call}
*/
replay: function(cache)
@@ -2663,8 +2682,8 @@
if (this._drawingMethodNames[functionName])
result.isDrawingCall = true;
} else {
- result.property = replayableCall.args()[0];
- result.value = this.formatValue(replayableCall.args()[1]);
+ result.property = replayableCall.propertyName();
+ result.value = this.formatValue(replayableCall.propertyValue());
}
return result;
},
@@ -2675,11 +2694,23 @@
*/
formatValue: function(value)
{
- if (value instanceof ReplayableResource)
- var description = value.description();
- else
- var description = "" + value;
- return { description: description };
+ if (value instanceof ReplayableResource) {
+ return {
+ description: value.description(),
+ resourceId: CallFormatter.makeStringResourceId(value.id())
+ };
+ }
+
+ var remoteObject = injectedScript.wrapObject(value, "", true, false);
+ var result = {
+ description: remoteObject.description || ("" + value),
+ type: /** @type {CanvasAgent.CallArgumentType} */ (remoteObject.type)
+ };
+ if (remoteObject.subtype)
+ result.subtype = /** @type {CanvasAgent.CallArgumentSubtype} */ (remoteObject.subtype);
+ if (remoteObject.objectId)
+ injectedScript.releaseObject(remoteObject.objectId);
+ return result;
}
}
@@ -2714,6 +2745,15 @@
}
/**
+ * @param {number} resourceId
+ * @return {CanvasAgent.ResourceId}
+ */
+CallFormatter.makeStringResourceId = function(resourceId)
+{
+ return "{\"injectedScriptId\":" + injectedScriptId + ",\"resourceId\":" + resourceId + "}";
+}
+
+/**
* @constructor
* @extends {CallFormatter}
* @param {!Object.<string, boolean>} drawingMethodNames
@@ -2761,12 +2801,12 @@
{"aname": "getBufferParameter", "enum": [0, 1]},
{"aname": "getError", "hints": ["NO_ERROR"], "returnType": "enum"},
{"aname": "getFramebufferAttachmentParameter", "enum": [0, 1, 2]},
- {"aname": "getParameter", "enum": [0], "hints": ["ZERO", "ONE"]},
+ {"aname": "getParameter", "enum": [0]},
{"aname": "getProgramParameter", "enum": [1]},
{"aname": "getRenderbufferParameter", "enum": [0, 1]},
{"aname": "getShaderParameter", "enum": [1]},
{"aname": "getShaderPrecisionFormat", "enum": [0, 1]},
- {"aname": "getTexParameter", "enum": [0, 1]},
+ {"aname": "getTexParameter", "enum": [0, 1], "returnType": "enum"},
{"aname": "getVertexAttrib", "enum": [1]},
{"aname": "getVertexAttribOffset", "enum": [1]},
{"aname": "hint", "enum": [0, 1]},
@@ -3408,7 +3448,7 @@
var stackTrace = call.stackTrace();
var callFrame = stackTrace ? stackTrace.callFrame(0) || {} : {};
var item = CallFormatter.formatCall(call);
- item.contextId = this._makeStringResourceId(contextResource.id());
+ item.contextId = CallFormatter.makeStringResourceId(contextResource.id());
item.sourceURL = callFrame.sourceURL;
item.lineNumber = callFrame.lineNumber;
item.columnNumber = callFrame.columnNumber;
@@ -3419,19 +3459,6 @@
},
/**
- * @param {*} obj
- * @return {!CanvasAgent.CallArgument}
- */
- _makeCallArgument: function(obj)
- {
- if (obj instanceof ReplayableResource)
- var description = obj.description();
- else
- var description = "" + obj;
- return { description: description };
- },
-
- /**
* @param {CanvasAgent.TraceLogId} traceLogId
* @param {number} stepNo
* @return {!CanvasAgent.ResourceState|string}
@@ -3449,7 +3476,7 @@
resource = resource.contextResource();
dataURL = resource.toDataURL();
}
- return this._makeResourceState(this._makeStringResourceId(resource.id()), traceLogId, dataURL);
+ return this._makeResourceState(CallFormatter.makeStringResourceId(resource.id()), traceLogId, dataURL);
},
/**
@@ -3506,6 +3533,46 @@
},
/**
+ * @param {CanvasAgent.TraceLogId} traceLogId
+ * @param {number} callIndex
+ * @param {number} argumentIndex
+ * @param {string} objectGroup
+ * @return {!Object|string}
+ */
+ evaluateTraceLogCallArgument: function(traceLogId, callIndex, argumentIndex, objectGroup)
+ {
+ var traceLog = this._traceLogs[traceLogId];
+ if (!traceLog)
+ return "Error: Trace log with the given ID not found.";
+
+ var replayableCall = traceLog.replayableCalls()[callIndex];
+ if (!replayableCall)
+ return "Error: No call found at index " + callIndex;
+
+ var value;
+ if (replayableCall.isPropertySetter())
+ value = replayableCall.propertyValue();
+ else if (argumentIndex === -1)
+ value = replayableCall.result();
+ else {
+ var args = replayableCall.args();
+ if (argumentIndex < 0 || argumentIndex >= args.length)
+ return "Error: No argument found at index " + argumentIndex + " for call at index " + callIndex;
+ value = args[argumentIndex];
+ }
+
+ if (value instanceof ReplayableResource) {
+ var traceLogPlayer = this._traceLogPlayers[traceLogId];
+ var resource = traceLogPlayer && traceLogPlayer.replayWorldResource(value.id());
+ var resourceState = this._makeResourceState(CallFormatter.makeStringResourceId(value.id()), traceLogId, resource ? resource.toDataURL() : "");
+ return { resourceState: resourceState };
+ }
+
+ var remoteObject = injectedScript.wrapObject(value, objectGroup, true, false);
+ return { result: remoteObject };
+ },
+
+ /**
* @return {CanvasAgent.TraceLogId}
*/
_makeTraceLogId: function()
@@ -3514,15 +3581,6 @@
},
/**
- * @param {number} resourceId
- * @return {CanvasAgent.ResourceId}
- */
- _makeStringResourceId: function(resourceId)
- {
- return "{\"injectedScriptId\":" + injectedScriptId + ",\"resourceId\":" + resourceId + "}";
- },
-
- /**
* @param {CanvasAgent.ResourceId} stringResourceId
* @param {string} description
* @return {!CanvasAgent.ResourceInfo}
diff --git a/Source/core/inspector/InjectedScriptExterns.js b/Source/core/inspector/InjectedScriptExterns.js
index 3306627..3076568 100644
--- a/Source/core/inspector/InjectedScriptExterns.js
+++ b/Source/core/inspector/InjectedScriptExterns.js
@@ -38,78 +38,76 @@
/**
* @constructor
*/
-function InjectedScriptHost() { }
-InjectedScriptHost.prototype.storageId = function(object) { }
-InjectedScriptHost.prototype.getInternalProperties = function(object) { }
+function InjectedScriptHostClass() { }
+InjectedScriptHostClass.prototype.storageId = function(object) { }
+InjectedScriptHostClass.prototype.getInternalProperties = function(object) { }
/**
* @param {Function} func
*/
-InjectedScriptHost.prototype.functionDetails = function(func) { }
+InjectedScriptHostClass.prototype.functionDetails = function(func) { }
/**
* @param {*} object
*/
-InjectedScriptHost.prototype.isHTMLAllCollection = function(object) { }
+InjectedScriptHostClass.prototype.isHTMLAllCollection = function(object) { }
/**
* @param {*} object
*/
-InjectedScriptHost.prototype.internalConstructorName = function(object) { }
+InjectedScriptHostClass.prototype.internalConstructorName = function(object) { }
/**
* @param {*} object
*/
-InjectedScriptHost.prototype.copyText = function(object) { }
-InjectedScriptHost.prototype.clearConsoleMessages = function() { }
+InjectedScriptHostClass.prototype.copyText = function(object) { }
+InjectedScriptHostClass.prototype.clearConsoleMessages = function() { }
/**
* @param {number} index
*/
-InjectedScriptHost.prototype.inspectedObject = function(index) { }
+InjectedScriptHostClass.prototype.inspectedObject = function(index) { }
/**
* @param {*} object
* @return {number}
*/
-InjectedScriptHost.prototype.objectId = function(object) { }
+InjectedScriptHostClass.prototype.objectId = function(object) { }
/**
* @param {*} object
*/
-InjectedScriptHost.prototype.releaseObjectId = function(object) { }
+InjectedScriptHostClass.prototype.releaseObjectId = function(object) { }
/**
* @param {*} object
*/
-InjectedScriptHost.prototype.databaseId = function(object) { }
+InjectedScriptHostClass.prototype.databaseId = function(object) { }
/**
* @param {*} object
* @param {Object} hints
*/
-InjectedScriptHost.prototype.inspect = function(object, hints) { }
+InjectedScriptHostClass.prototype.inspect = function(object, hints) { }
/**
* @param {*} object
*/
-InjectedScriptHost.prototype.type = function(object) { }
+InjectedScriptHostClass.prototype.type = function(object) { }
/**
* @param {*} object
*/
-InjectedScriptHost.prototype.getEventListeners = function(object) { }
+InjectedScriptHostClass.prototype.getEventListeners = function(object) { }
/**
* @param {string} expression
*/
-InjectedScriptHost.prototype.evaluate = function(expression) { }
+InjectedScriptHostClass.prototype.evaluate = function(expression) { }
/**
* @param {*} fn
*/
-InjectedScriptHost.prototype.debugFunction = function(fn) { }
+InjectedScriptHostClass.prototype.debugFunction = function(fn) { }
/**
* @param {*} fn
*/
-InjectedScriptHost.prototype.undebugFunction = function(fn) { }
+InjectedScriptHostClass.prototype.undebugFunction = function(fn) { }
/**
* @param {*} fn
*/
-InjectedScriptHost.prototype.monitorFunction = function(fn) { }
+InjectedScriptHostClass.prototype.monitorFunction = function(fn) { }
/**
* @param {*} fn
*/
-InjectedScriptHost.prototype.unmonitorFunction = function(fn) { }
-
-
+InjectedScriptHostClass.prototype.unmonitorFunction = function(fn) { }
/**
* @param {function(...)} fun
@@ -117,7 +115,14 @@
* @param {string} variableName
* @param {*} newValue
*/
-InjectedScriptHost.prototype.setFunctionVariableValue = function(fun, scopeNumber, variableName, newValue) { }
+InjectedScriptHostClass.prototype.setFunctionVariableValue = function(fun, scopeNumber, variableName, newValue) { }
+
+/** @type {!InjectedScriptHostClass} */
+var InjectedScriptHost;
+/** @type {!Window} */
+var inspectedWindow;
+/** @type {number} */
+var injectedScriptId;
/**
* @constructor
diff --git a/Source/core/inspector/InjectedScriptHost.cpp b/Source/core/inspector/InjectedScriptHost.cpp
index bafd14c..778221f 100644
--- a/Source/core/inspector/InjectedScriptHost.cpp
+++ b/Source/core/inspector/InjectedScriptHost.cpp
@@ -37,12 +37,11 @@
#include "core/inspector/InspectorDOMStorageAgent.h"
#include "core/inspector/InspectorDatabaseAgent.h"
#include "core/inspector/InspectorDebuggerAgent.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/Pasteboard.h"
#include "wtf/RefPtr.h"
-#include "wtf/StdLibExtras.h"
#include "wtf/text/StringBuilder.h"
using namespace std;
@@ -72,7 +71,7 @@
m_scriptDebugServer = 0;
}
-void InjectedScriptHost::inspectImpl(PassRefPtr<InspectorValue> object, PassRefPtr<InspectorValue> hints)
+void InjectedScriptHost::inspectImpl(PassRefPtr<JSONValue> object, PassRefPtr<JSONValue> hints)
{
if (InspectorAgent* inspectorAgent = m_instrumentingAgents ? m_instrumentingAgents->inspectorAgent() : 0) {
RefPtr<TypeBuilder::Runtime::RemoteObject> remoteObject = TypeBuilder::Runtime::RemoteObject::runtimeCast(object);
diff --git a/Source/core/inspector/InjectedScriptHost.h b/Source/core/inspector/InjectedScriptHost.h
index 01cc55c..6a3729c 100644
--- a/Source/core/inspector/InjectedScriptHost.h
+++ b/Source/core/inspector/InjectedScriptHost.h
@@ -32,16 +32,15 @@
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/ScriptWrappable.h"
-#include "core/page/ConsoleTypes.h"
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
namespace WebCore {
class Database;
class InjectedScript;
-class InspectorValue;
class InstrumentingAgents;
+class JSONValue;
class Node;
class ScriptDebugServer;
class ScriptValue;
@@ -80,7 +79,7 @@
void clearInspectedObjects();
InspectableObject* inspectedObject(unsigned int num);
- void inspectImpl(PassRefPtr<InspectorValue> objectToInspect, PassRefPtr<InspectorValue> hints);
+ void inspectImpl(PassRefPtr<JSONValue> objectToInspect, PassRefPtr<JSONValue> hints);
void getEventListenersImpl(Node*, Vector<EventListenerInfo>& listenersArray);
void clearConsoleMessages();
diff --git a/Source/core/inspector/InjectedScriptManager.cpp b/Source/core/inspector/InjectedScriptManager.cpp
index 16dd077..d7cec01 100644
--- a/Source/core/inspector/InjectedScriptManager.cpp
+++ b/Source/core/inspector/InjectedScriptManager.cpp
@@ -35,8 +35,9 @@
#include "bindings/v8/ScriptObject.h"
#include "core/inspector/InjectedScript.h"
#include "core/inspector/InjectedScriptHost.h"
-#include "core/inspector/InspectorValues.h"
-#include <wtf/PassOwnPtr.h>
+#include "core/inspector/JSONParser.h"
+#include "core/platform/JSONValues.h"
+#include "wtf/PassOwnPtr.h"
namespace WebCore {
@@ -47,7 +48,7 @@
PassOwnPtr<InjectedScriptManager> InjectedScriptManager::createForWorker()
{
- return adoptPtr(new InjectedScriptManager(&InjectedScriptManager::canAccessInspectedWorkerContext));
+ return adoptPtr(new InjectedScriptManager(&InjectedScriptManager::canAccessInspectedWorkerGlobalScope));
}
InjectedScriptManager::InjectedScriptManager(InspectedStateAccessCheck accessCheck)
@@ -96,8 +97,8 @@
InjectedScript InjectedScriptManager::injectedScriptForObjectId(const String& objectId)
{
- RefPtr<InspectorValue> parsedObjectId = InspectorValue::parseJSON(objectId);
- if (parsedObjectId && parsedObjectId->type() == InspectorValue::TypeObject) {
+ RefPtr<JSONValue> parsedObjectId = parseJSON(objectId);
+ if (parsedObjectId && parsedObjectId->type() == JSONValue::TypeObject) {
long injectedScriptId = 0;
bool success = parsedObjectId->asObject()->getNumber("injectedScriptId", &injectedScriptId);
if (success)
@@ -141,7 +142,7 @@
m_scriptStateToId.remove(scriptStatesToRemove[i]);
}
-bool InjectedScriptManager::canAccessInspectedWorkerContext(ScriptState*)
+bool InjectedScriptManager::canAccessInspectedWorkerGlobalScope(ScriptState*)
{
return true;
}
diff --git a/Source/core/inspector/InjectedScriptManager.h b/Source/core/inspector/InjectedScriptManager.h
index 07faa59..6bd5958 100644
--- a/Source/core/inspector/InjectedScriptManager.h
+++ b/Source/core/inspector/InjectedScriptManager.h
@@ -40,7 +40,6 @@
class DOMWindow;
class InjectedScript;
class InjectedScriptHost;
-class InspectorObject;
class ScriptObject;
class InjectedScriptManager {
@@ -73,7 +72,7 @@
ScriptObject createInjectedScript(const String& source, ScriptState*, int id);
static bool canAccessInspectedWindow(ScriptState*);
- static bool canAccessInspectedWorkerContext(ScriptState*);
+ static bool canAccessInspectedWorkerGlobalScope(ScriptState*);
int m_nextInjectedScriptId;
typedef HashMap<int, InjectedScript> IdToInjectedScriptMap;
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
index 5875cc7..c59c45e 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,8 +34,11 @@
*/
(function (InjectedScriptHost, inspectedWindow, injectedScriptId) {
-// Protect against Object overwritten by the user code.
-var Object = {}.constructor;
+/**
+ * Protect against Object overwritten by the user code.
+ * @suppress {duplicate}
+ */
+var Object = /** @type {function(new:Object, *=)} */ ({}.constructor);
/**
* @param {Arguments} array
@@ -407,6 +411,8 @@
continue;
} else {
// Not all bindings provide proper descriptors. Fall back to the writable, configurable property.
+ if (accessorPropertiesOnly)
+ continue;
try {
descriptor = { name: name, value: o[name], writable: false, configurable: false, enumerable: false};
if (o === object)
@@ -418,6 +424,8 @@
continue;
}
} catch (e) {
+ if (accessorPropertiesOnly)
+ continue;
var descriptor = {};
descriptor.value = e;
descriptor.wasThrown = true;
@@ -429,7 +437,7 @@
descriptors.push(descriptor);
}
if (ownProperties) {
- if (object.__proto__)
+ if (object.__proto__ && !accessorPropertiesOnly)
descriptors.push({ name: "__proto__", value: object.__proto__, writable: true, configurable: true, enumerable: false, isOwn: true});
break;
}
@@ -650,7 +658,7 @@
return "Could not find call frame with given id";
setter = callFrame.setVariableValue.bind(callFrame);
} else {
- var parsedFunctionId = this._parseObjectId(/** @type {string} */(functionObjectId));
+ var parsedFunctionId = this._parseObjectId(/** @type {string} */ (functionObjectId));
var func = this._objectForId(parsedFunctionId);
if (typeof func !== "function")
return "Cannot resolve function by id.";
@@ -744,7 +752,7 @@
inspectedWindow.console.error("Web Inspector error: A function was expected for module %s evaluation", name);
return null;
}
- var module = moduleFunction.call(inspectedWindow, InjectedScriptHost, inspectedWindow, injectedScriptId);
+ var module = moduleFunction.call(inspectedWindow, InjectedScriptHost, inspectedWindow, injectedScriptId, this);
this._modules[name] = module;
return module;
},
@@ -769,7 +777,7 @@
},
/**
- * @param {Object=} obj
+ * @param {*} obj
* @return {string?}
*/
_subtype: function(obj)
@@ -809,8 +817,6 @@
if (this.isPrimitiveValue(obj))
return null;
- obj = /** @type {Object} */ (obj);
-
// Type is object, get subtype.
var subtype = this._subtype(obj);
@@ -868,7 +874,7 @@
}
/**
- * @type {InjectedScript}
+ * @type {!InjectedScript}
* @const
*/
var injectedScript = new InjectedScript();
@@ -886,15 +892,15 @@
this.type = typeof object;
if (injectedScript.isPrimitiveValue(object) || object === null || forceValueType) {
// We don't send undefined values over JSON.
- if (typeof object !== "undefined")
+ if (this.type !== "undefined")
this.value = object;
- // Null object is object with 'null' subtype'
+ // Null object is object with 'null' subtype.
if (object === null)
this.subtype = "null";
// Provide user-friendly number values.
- if (typeof object === "number")
+ if (this.type === "number")
this.description = object + "";
return;
}
@@ -947,7 +953,7 @@
*/
_generateProtoPreview: function(object, preview, propertiesThreshold, firstLevelKeys, secondLevelKeys)
{
- var propertyNames = firstLevelKeys ? firstLevelKeys : Object.keys(/** @type {!Object} */(object));
+ var propertyNames = firstLevelKeys ? firstLevelKeys : Object.keys(/** @type {!Object} */ (object));
try {
for (var i = 0; i < propertyNames.length; ++i) {
if (!propertiesThreshold.properties || !propertiesThreshold.indexes) {
@@ -959,7 +965,7 @@
if (this.subtype === "array" && name === "length")
continue;
- var descriptor = Object.getOwnPropertyDescriptor(/** @type {!Object} */(object), name);
+ var descriptor = Object.getOwnPropertyDescriptor(/** @type {!Object} */ (object), name);
if (!("value" in descriptor) || !descriptor.enumerable) {
preview.lossless = false;
continue;
diff --git a/Source/core/inspector/InspectorAgent.cpp b/Source/core/inspector/InspectorAgent.cpp
index ee2b455..e6933cb 100644
--- a/Source/core/inspector/InspectorAgent.cpp
+++ b/Source/core/inspector/InspectorAgent.cpp
@@ -31,8 +31,6 @@
#include "config.h"
#include "core/inspector/InspectorAgent.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
#include "InspectorFrontend.h"
#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/ScriptController.h"
@@ -41,11 +39,11 @@
#include "core/inspector/InjectedScriptManager.h"
#include "core/inspector/InspectorController.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/loader/DocumentLoader.h"
#include "core/page/Frame.h"
#include "core/page/Page.h"
+#include "core/platform/JSONValues.h"
#include "weborigin/SecurityOrigin.h"
using namespace std;
@@ -162,7 +160,7 @@
m_injectedScriptForOrigin.set(origin, source);
}
-void InspectorAgent::inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints)
+void InspectorAgent::inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<JSONObject> hints)
{
if (m_state->getBoolean(InspectorAgentState::inspectorAgentEnabled) && m_frontend) {
m_frontend->inspector()->inspect(objectToInspect, hints);
diff --git a/Source/core/inspector/InspectorAgent.h b/Source/core/inspector/InspectorAgent.h
index a84d9b6..d1e56c1 100644
--- a/Source/core/inspector/InspectorAgent.h
+++ b/Source/core/inspector/InspectorAgent.h
@@ -44,8 +44,8 @@
class Frame;
class InjectedScriptManager;
class InspectorFrontend;
-class InspectorObject;
class InstrumentingAgents;
+class JSONObject;
class KURL;
class Page;
@@ -86,7 +86,7 @@
void setInjectedScriptForOrigin(const String& origin, const String& source);
- void inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints);
+ void inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<JSONObject> hints);
private:
InspectorAgent(Page*, InjectedScriptManager*, InstrumentingAgents*, InspectorCompositeState*);
@@ -102,7 +102,7 @@
InjectedScriptManager* m_injectedScriptManager;
Vector<pair<long, String> > m_pendingEvaluateTestCommands;
- pair<RefPtr<TypeBuilder::Runtime::RemoteObject>, RefPtr<InspectorObject> > m_pendingInspectData;
+ pair<RefPtr<TypeBuilder::Runtime::RemoteObject>, RefPtr<JSONObject> > m_pendingInspectData;
typedef HashMap<String, String> InjectedScriptForOriginMap;
InjectedScriptForOriginMap m_injectedScriptForOrigin;
};
diff --git a/Source/core/inspector/InspectorApplicationCacheAgent.h b/Source/core/inspector/InspectorApplicationCacheAgent.h
index 3855618..922c302 100644
--- a/Source/core/inspector/InspectorApplicationCacheAgent.h
+++ b/Source/core/inspector/InspectorApplicationCacheAgent.h
@@ -35,11 +35,8 @@
namespace WebCore {
class Frame;
-class InspectorArray;
class InspectorFrontend;
-class InspectorObject;
class InspectorPageAgent;
-class InspectorValue;
class InspectorState;
class InstrumentingAgents;
class Page;
diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp
index c4a236d..74059b5 100644
--- a/Source/core/inspector/InspectorCSSAgent.cpp
+++ b/Source/core/inspector/InspectorCSSAgent.cpp
@@ -31,7 +31,6 @@
#include "core/css/CSSImportRule.h"
#include "core/css/CSSMediaRule.h"
#include "core/css/CSSParser.h"
-#include "core/css/CSSPropertySourceData.h"
#include "core/css/CSSRule.h"
#include "core/css/CSSRuleList.h"
#include "core/css/CSSStyleRule.h"
@@ -50,23 +49,20 @@
#include "core/dom/Node.h"
#include "core/dom/NodeList.h"
#include "core/html/HTMLHeadElement.h"
-#include "core/inspector/ContentSearchUtils.h"
#include "core/inspector/InspectorDOMAgent.h"
#include "core/inspector/InspectorHistory.h"
#include "core/inspector/InspectorPageAgent.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/loader/DocumentLoader.h"
-#include "core/loader/cache/CachedResource.h"
#include "core/page/ContentSecurityPolicy.h"
+#include "core/platform/JSONValues.h"
#include "core/rendering/RenderRegion.h"
-
-#include <wtf/CurrentTime.h>
-#include <wtf/HashSet.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringConcatenate.h>
-#include <wtf/Vector.h>
+#include "wtf/CurrentTime.h"
+#include "wtf/HashSet.h"
+#include "wtf/Vector.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/StringConcatenate.h"
namespace CSSAgentState {
static const char cssAgentEnabled[] = "cssAgentEnabled";
@@ -167,7 +163,7 @@
Vector<CSSStyleSheet*>& m_result;
};
-static unsigned computePseudoClassMask(InspectorArray* pseudoClassArray)
+static unsigned computePseudoClassMask(JSONArray* pseudoClassArray)
{
DEFINE_STATIC_LOCAL(String, active, (ASCIILiteral("active")));
DEFINE_STATIC_LOCAL(String, hover, (ASCIILiteral("hover")));
@@ -178,7 +174,7 @@
unsigned result = PseudoNone;
for (size_t i = 0; i < pseudoClassArray->length(); ++i) {
- RefPtr<InspectorValue> pseudoClassValue = pseudoClassArray->get(i);
+ RefPtr<JSONValue> pseudoClassValue = pseudoClassArray->get(i);
String pseudoClass;
bool success = pseudoClassValue->asString(&pseudoClass);
if (!success)
@@ -323,6 +319,54 @@
m_timer.startOneShot(0);
}
+class ChangeRegionOversetTask {
+public:
+ ChangeRegionOversetTask(InspectorCSSAgent*);
+ void scheduleFor(NamedFlow*, int documentNodeId);
+ void unschedule(NamedFlow*);
+ void reset();
+ void onTimer(Timer<ChangeRegionOversetTask>*);
+
+private:
+ InspectorCSSAgent* m_cssAgent;
+ Timer<ChangeRegionOversetTask> m_timer;
+ HashMap<NamedFlow*, int> m_namedFlows;
+};
+
+ChangeRegionOversetTask::ChangeRegionOversetTask(InspectorCSSAgent* cssAgent)
+ : m_cssAgent(cssAgent)
+ , m_timer(this, &ChangeRegionOversetTask::onTimer)
+{
+}
+
+void ChangeRegionOversetTask::scheduleFor(NamedFlow* namedFlow, int documentNodeId)
+{
+ m_namedFlows.add(namedFlow, documentNodeId);
+
+ if (!m_timer.isActive())
+ m_timer.startOneShot(0);
+}
+
+void ChangeRegionOversetTask::unschedule(NamedFlow* namedFlow)
+{
+ m_namedFlows.remove(namedFlow);
+}
+
+void ChangeRegionOversetTask::reset()
+{
+ m_timer.stop();
+ m_namedFlows.clear();
+}
+
+void ChangeRegionOversetTask::onTimer(Timer<ChangeRegionOversetTask>*)
+{
+ // The timer is stopped on m_cssAgent destruction, so this method will never be called after m_cssAgent has been destroyed.
+ for (HashMap<NamedFlow*, int>::iterator it = m_namedFlows.begin(), end = m_namedFlows.end(); it != end; ++it)
+ m_cssAgent->regionOversetChanged(it->key, it->value);
+
+ m_namedFlows.clear();
+}
+
class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action {
WTF_MAKE_NONCOPYABLE(StyleSheetAction);
public:
@@ -608,28 +652,103 @@
return static_cast<CSSStyleRule*>(rule);
}
-template <typename CharType>
-static bool hasVendorSpecificPrefix(const CharType* string, size_t stringLength)
+template <typename CharType, size_t bufferLength>
+static size_t vendorPrefixLowerCase(const CharType* string, size_t stringLength, char (&buffer)[bufferLength])
{
- for (size_t i = 1; i < stringLength; ++i) {
- int c = string[i];
- if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z'))
- return i >= 2 && c == '-';
+ static const char lowerCaseOffset = 'a' - 'A';
+
+ if (string[0] != '-')
+ return 0;
+
+ for (size_t i = 0; i < stringLength - 1; i++) {
+ CharType c = string[i + 1];
+ if (c == '-')
+ return i;
+ if (i == bufferLength)
+ break;
+ if (c < 'A' || c > 'z')
+ break;
+ if (c >= 'a')
+ buffer[i] = c;
+ else if (c <= 'Z')
+ buffer[i] = c + lowerCaseOffset;
+ else
+ break;
}
- return false;
+ return 0;
+}
+
+template <size_t patternLength>
+static bool equals(const char* prefix, size_t prefixLength, const char (&pattern)[patternLength])
+{
+ if (prefixLength != patternLength - 1)
+ return false;
+ for (size_t i = 0; i < patternLength - 1; i++) {
+ if (prefix[i] != pattern[i])
+ return false;
+ }
+ return true;
}
static bool hasNonWebkitVendorSpecificPrefix(const CSSParserString& string)
{
+ // Known prefixes: http://wiki.csswg.org/spec/vendor-prefixes
const size_t stringLength = string.length();
- if (stringLength < 4 || string[0] != '-')
+ if (stringLength < 4)
return false;
- static const char webkitPrefix[] = "-webkit-";
- if (stringLength > 8 && string.startsWithIgnoringCase(webkitPrefix))
+ char buffer[6];
+ size_t prefixLength = string.is8Bit() ?
+ vendorPrefixLowerCase(string.characters8(), stringLength, buffer) :
+ vendorPrefixLowerCase(string.characters16(), stringLength, buffer);
+
+ if (!prefixLength || prefixLength == stringLength - 2)
return false;
- return string.is8Bit() ? hasVendorSpecificPrefix(string.characters8(), stringLength) : hasVendorSpecificPrefix(string.characters16(), stringLength);
+ switch (buffer[0]) {
+ case 'a':
+ return (prefixLength == 2 && buffer[1] == 'h') || equals(buffer + 1, prefixLength - 1, "tsc");
+ case 'e':
+ return equals(buffer + 1, prefixLength - 1, "pub");
+ case 'h':
+ return prefixLength == 2 && buffer[1] == 'p';
+ case 'i':
+ return equals(buffer + 1, prefixLength - 1, "books");
+ case 'k':
+ return equals(buffer + 1, prefixLength - 1, "html");
+ case 'm':
+ if (prefixLength == 2)
+ return buffer[1] == 's';
+ if (prefixLength == 3)
+ return (buffer[1] == 'o' && buffer[2] == 'z') || (buffer[1] == 's' || buffer[2] == 'o');
+ break;
+ case 'o':
+ return prefixLength == 1;
+ case 'p':
+ return equals(buffer + 1, prefixLength - 1, "rince");
+ case 'r':
+ return (prefixLength == 2 && buffer[1] == 'o') || equals(buffer + 1, prefixLength - 1, "im");
+ case 't':
+ return prefixLength == 2 && buffer[1] == 'c';
+ case 'w':
+ return (prefixLength == 3 && buffer[1] == 'a' && buffer[2] == 'p') || equals(buffer + 1, prefixLength - 1, "easy");
+ case 'x':
+ return prefixLength == 2 && buffer[1] == 'v';
+ }
+ return false;
+}
+
+static bool isValidPropertyName(const CSSParserString& content)
+{
+ if (content.equalIgnoringCase("animation")
+ || content.equalIgnoringCase("font-size-adjust")
+ || content.equalIgnoringCase("transform")
+ || content.equalIgnoringCase("user-select")
+ || content.equalIgnoringCase("-webkit-flex-pack")
+ || content.equalIgnoringCase("-webkit-text-size-adjust"))
+ return true;
+
+ return false;
}
// static
@@ -646,6 +765,7 @@
// The "filter" property is commonly used instead of "opacity" for IE9.
if (propertyId == CSSPropertyFilter)
return false;
+
break;
case CSSParser::InvalidPropertyValueError:
@@ -661,9 +781,29 @@
if (propertyId == CSSPropertyCursor && content.equalIgnoringCase("hand"))
return false;
- // Ignore properties like "property: value \9". This trick used in bootsrtap for IE-only properies.
- if (contentLength > 2 && content[contentLength - 2] == '\\' && content[contentLength - 1] == '9')
+ // Ignore properties like "property: value \9" (common IE hack) or "property: value \0" (IE 8 hack).
+ if (contentLength > 2 && content[contentLength - 2] == '\\' && (content[contentLength - 1] == '9' || content[contentLength - 1] == '0'))
return false;
+
+ if (contentLength > 3) {
+
+ // property: value\0/;
+ if (content[contentLength - 3] == '\\' && content[contentLength - 2] == '0' && content[contentLength - 1] == '/')
+ return false;
+
+ // property: value !ie;
+ if (content[contentLength - 3] == '!' && content[contentLength - 2] == 'i' && content[contentLength - 1] == 'e')
+ return false;
+ }
+
+ // Popular value prefixes valid in other browsers.
+ if (content.startsWithIgnoringCase("linear-gradient"))
+ return false;
+ if (content.startsWithIgnoringCase("-webkit-flexbox"))
+ return false;
+ if (propertyId == CSSPropertyUnicodeBidi && content.startsWithIgnoringCase("isolate"))
+ return false;
+
break;
case CSSParser::InvalidPropertyError:
@@ -678,10 +818,20 @@
if (content.startsWithIgnoringCase("scrollbar-"))
return false;
- // Unsupported standard property.
- if (content.equalIgnoringCase("font-size-adjust"))
+ if (isValidPropertyName(content))
return false;
+
break;
+
+ case CSSParser::InvalidRuleError:
+ // Block error reporting for @-rules for now to avoid noise.
+ if (contentLength > 4 && content[0] == '@')
+ return false;
+ return true;
+
+ case CSSParser::InvalidSelectorPseudoError:
+ if (hasNonWebkitVendorSpecificPrefix(content))
+ return false;
}
return true;
}
@@ -749,6 +899,8 @@
m_namedFlowCollectionsRequested.clear();
if (m_updateRegionLayoutTask)
m_updateRegionLayoutTask->reset();
+ if (m_changeRegionOversetTask)
+ m_changeRegionOversetTask->reset();
resetPseudoStates();
}
@@ -830,6 +982,28 @@
m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
}
+void InspectorCSSAgent::didChangeRegionOverset(Document* document, NamedFlow* namedFlow)
+{
+ int documentNodeId = documentNodeWithRequestedFlowsId(document);
+ if (!documentNodeId)
+ return;
+
+ if (!m_changeRegionOversetTask)
+ m_changeRegionOversetTask = adoptPtr(new ChangeRegionOversetTask(this));
+ m_changeRegionOversetTask->scheduleFor(namedFlow, documentNodeId);
+}
+
+void InspectorCSSAgent::regionOversetChanged(NamedFlow* namedFlow, int documentNodeId)
+{
+ if (namedFlow->flowState() == NamedFlow::FlowStateNull)
+ return;
+
+ ErrorString errorString;
+ RefPtr<NamedFlow> protector(namedFlow);
+
+ m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
+}
+
void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document, const Vector<RefPtr<StyleSheet> >& newSheets)
{
HashSet<CSSStyleSheet*> removedSheets;
@@ -1037,7 +1211,7 @@
*errorString = InspectorDOMAgent::toErrorString(ec);
}
-void InspectorCSSAgent::setStyleText(ErrorString* errorString, const RefPtr<InspectorObject>& fullStyleId, const String& text, RefPtr<TypeBuilder::CSS::CSSStyle>& result)
+void InspectorCSSAgent::setStyleText(ErrorString* errorString, const RefPtr<JSONObject>& fullStyleId, const String& text, RefPtr<TypeBuilder::CSS::CSSStyle>& result)
{
InspectorCSSId compoundId(fullStyleId);
ASSERT(!compoundId.isEmpty());
@@ -1053,7 +1227,7 @@
*errorString = InspectorDOMAgent::toErrorString(ec);
}
-void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<InspectorObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result)
+void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<JSONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result)
{
InspectorCSSId compoundId(fullStyleId);
ASSERT(!compoundId.isEmpty());
@@ -1069,7 +1243,7 @@
*errorString = InspectorDOMAgent::toErrorString(ec);
}
-void InspectorCSSAgent::toggleProperty(ErrorString* errorString, const RefPtr<InspectorObject>& fullStyleId, int propertyIndex, bool disable, RefPtr<TypeBuilder::CSS::CSSStyle>& result)
+void InspectorCSSAgent::toggleProperty(ErrorString* errorString, const RefPtr<JSONObject>& fullStyleId, int propertyIndex, bool disable, RefPtr<TypeBuilder::CSS::CSSStyle>& result)
{
InspectorCSSId compoundId(fullStyleId);
ASSERT(!compoundId.isEmpty());
@@ -1085,7 +1259,7 @@
*errorString = InspectorDOMAgent::toErrorString(ec);
}
-void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const RefPtr<InspectorObject>& fullRuleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result)
+void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const RefPtr<JSONObject>& fullRuleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result)
{
InspectorCSSId compoundId(fullRuleId);
ASSERT(!compoundId.isEmpty());
@@ -1154,7 +1328,7 @@
cssProperties = properties.release();
}
-void InspectorCSSAgent::forcePseudoState(ErrorString* errorString, int nodeId, const RefPtr<InspectorArray>& forcedPseudoClasses)
+void InspectorCSSAgent::forcePseudoState(ErrorString* errorString, int nodeId, const RefPtr<JSONArray>& forcedPseudoClasses)
{
Element* element = m_domAgent->assertElement(errorString, nodeId);
if (!element)
@@ -1216,7 +1390,6 @@
if (!sourceURL.isEmpty()) {
mediaObject->setSourceURL(sourceURL);
- mediaObject->setSourceLine(media->queries()->lastLine());
CSSRule* parentRule = media->parentRule();
if (!parentRule)
@@ -1573,7 +1746,7 @@
return 0;
// FIXME: Ugliness below.
- StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(static_cast<StyledElement*>(element)->presentationAttributeStyle());
+ StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->presentationAttributeStyle());
if (!attributeStyle)
return 0;
@@ -1591,17 +1764,17 @@
for (unsigned i = 0; i < regionList->length(); ++i) {
TypeBuilder::CSS::Region::RegionOverset::Enum regionOverset;
- switch (toElement(regionList->item(i))->renderRegion()->regionState()) {
- case RenderRegion::RegionFit:
+ switch (toElement(regionList->item(i))->renderRegion()->regionOversetState()) {
+ case RegionFit:
regionOverset = TypeBuilder::CSS::Region::RegionOverset::Fit;
break;
- case RenderRegion::RegionEmpty:
+ case RegionEmpty:
regionOverset = TypeBuilder::CSS::Region::RegionOverset::Empty;
break;
- case RenderRegion::RegionOverset:
+ case RegionOverset:
regionOverset = TypeBuilder::CSS::Region::RegionOverset::Overset;
break;
- case RenderRegion::RegionUndefined:
+ case RegionUndefined:
continue;
default:
ASSERT_NOT_REACHED();
diff --git a/Source/core/inspector/InspectorCSSAgent.h b/Source/core/inspector/InspectorCSSAgent.h
index 5eafc00..8382c1a 100644
--- a/Source/core/inspector/InspectorCSSAgent.h
+++ b/Source/core/inspector/InspectorCSSAgent.h
@@ -30,18 +30,18 @@
#include "core/inspector/InspectorBaseAgent.h"
#include "core/inspector/InspectorDOMAgent.h"
#include "core/inspector/InspectorStyleSheet.h"
-#include "core/inspector/InspectorValues.h"
#include "core/page/ContentSecurityPolicy.h"
-
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "core/platform/JSONValues.h"
+#include "wtf/HashMap.h"
+#include "wtf/HashSet.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
+class ChangeRegionOversetTask;
struct CSSParserString;
class CSSRule;
class CSSRuleList;
@@ -118,8 +118,15 @@
void mediaQueryResultChanged();
void didCreateNamedFlow(Document*, NamedFlow*);
void willRemoveNamedFlow(Document*, NamedFlow*);
- void didUpdateRegionLayout(Document*, NamedFlow*);
+
+private:
void regionLayoutUpdated(NamedFlow*, int documentNodeId);
+ void regionOversetChanged(NamedFlow*, int documentNodeId);
+
+public:
+ void didUpdateRegionLayout(Document*, NamedFlow*);
+ void didChangeRegionOverset(Document*, NamedFlow*);
+
void activeStyleSheetsUpdated(Document*, const Vector<RefPtr<StyleSheet> >& newSheets);
void frameDetachedFromParent(Frame*);
@@ -130,13 +137,13 @@
virtual void getStyleSheet(ErrorString*, const String& styleSheetId, RefPtr<TypeBuilder::CSS::CSSStyleSheetBody>& result);
virtual void getStyleSheetText(ErrorString*, const String& styleSheetId, String* result);
virtual void setStyleSheetText(ErrorString*, const String& styleSheetId, const String& text);
- virtual void setStyleText(ErrorString*, const RefPtr<InspectorObject>& styleId, const String& text, RefPtr<TypeBuilder::CSS::CSSStyle>& result);
- virtual void setPropertyText(ErrorString*, const RefPtr<InspectorObject>& styleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result);
- virtual void toggleProperty(ErrorString*, const RefPtr<InspectorObject>& styleId, int propertyIndex, bool disable, RefPtr<TypeBuilder::CSS::CSSStyle>& result);
- virtual void setRuleSelector(ErrorString*, const RefPtr<InspectorObject>& ruleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result);
+ virtual void setStyleText(ErrorString*, const RefPtr<JSONObject>& styleId, const String& text, RefPtr<TypeBuilder::CSS::CSSStyle>& result);
+ virtual void setPropertyText(ErrorString*, const RefPtr<JSONObject>& styleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result);
+ virtual void toggleProperty(ErrorString*, const RefPtr<JSONObject>& styleId, int propertyIndex, bool disable, RefPtr<TypeBuilder::CSS::CSSStyle>& result);
+ virtual void setRuleSelector(ErrorString*, const RefPtr<JSONObject>& ruleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result);
virtual void addRule(ErrorString*, int contextNodeId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result);
virtual void getSupportedCSSProperties(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSPropertyInfo> >& result);
- virtual void forcePseudoState(ErrorString*, int nodeId, const RefPtr<InspectorArray>& forcedPseudoClasses);
+ virtual void forcePseudoState(ErrorString*, int nodeId, const RefPtr<JSONArray>& forcedPseudoClasses);
virtual void getNamedFlowCollection(ErrorString*, int documentNodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> >& result);
virtual void startSelectorProfiler(ErrorString*);
@@ -207,13 +214,16 @@
NodeIdToForcedPseudoState m_nodeIdToForcedPseudoState;
HashSet<int> m_namedFlowCollectionsRequested;
OwnPtr<UpdateRegionLayoutTask> m_updateRegionLayoutTask;
+ OwnPtr<ChangeRegionOversetTask> m_changeRegionOversetTask;
int m_lastStyleSheetId;
bool m_creatingViaInspectorStyleSheet;
OwnPtr<SelectorProfile> m_currentSelectorProfile;
+ friend class ChangeRegionOversetTask;
friend class StyleSheetBinder;
+ friend class UpdateRegionLayoutTask;
};
diff --git a/Source/core/inspector/InspectorCanvasAgent.cpp b/Source/core/inspector/InspectorCanvasAgent.cpp
index eaa5314..64f6a08 100644
--- a/Source/core/inspector/InspectorCanvasAgent.cpp
+++ b/Source/core/inspector/InspectorCanvasAgent.cpp
@@ -55,6 +55,7 @@
using WebCore::TypeBuilder::Canvas::TraceLog;
using WebCore::TypeBuilder::Canvas::TraceLogId;
using WebCore::TypeBuilder::Network::FrameId;
+using WebCore::TypeBuilder::Runtime::RemoteObject;
namespace WebCore {
@@ -190,6 +191,13 @@
module.resourceState(errorString, traceLogId, resourceId, &result);
}
+void InspectorCanvasAgent::evaluateTraceLogCallArgument(ErrorString* errorString, const TraceLogId& traceLogId, int callIndex, int argumentIndex, const String* objectGroup, RefPtr<RemoteObject>& result, RefPtr<ResourceState>& resourceState)
+{
+ InjectedScriptCanvasModule module = injectedScriptCanvasModule(errorString, traceLogId);
+ if (!module.hasNoValue())
+ module.evaluateTraceLogCallArgument(errorString, traceLogId, callIndex, argumentIndex, objectGroup ? *objectGroup : String(), &result, &resourceState);
+}
+
ScriptObject InspectorCanvasAgent::wrapCanvas2DRenderingContextForInstrumentation(const ScriptObject& context)
{
ErrorString error;
diff --git a/Source/core/inspector/InspectorCanvasAgent.h b/Source/core/inspector/InspectorCanvasAgent.h
index 0d8bf0c..b5a7fe0 100644
--- a/Source/core/inspector/InspectorCanvasAgent.h
+++ b/Source/core/inspector/InspectorCanvasAgent.h
@@ -36,10 +36,9 @@
#include "InspectorTypeBuilder.h"
#include "bindings/v8/ScriptState.h"
#include "core/inspector/InspectorBaseAgent.h"
-#include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/HashMap.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -86,6 +85,7 @@
virtual void replayTraceLog(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, RefPtr<TypeBuilder::Canvas::ResourceState>&);
virtual void getResourceInfo(ErrorString*, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceInfo>&);
virtual void getResourceState(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, const TypeBuilder::Canvas::ResourceId&, RefPtr<TypeBuilder::Canvas::ResourceState>&);
+ virtual void evaluateTraceLogCallArgument(ErrorString*, const TypeBuilder::Canvas::TraceLogId&, int, int, const String*, RefPtr<TypeBuilder::Runtime::RemoteObject>&, RefPtr<TypeBuilder::Canvas::ResourceState>&);
private:
InspectorCanvasAgent(InstrumentingAgents*, InspectorCompositeState*, InspectorPageAgent*, InjectedScriptManager*);
diff --git a/Source/core/inspector/InspectorClient.h b/Source/core/inspector/InspectorClient.h
index dfcca85..6fa61c7 100644
--- a/Source/core/inspector/InspectorClient.h
+++ b/Source/core/inspector/InspectorClient.h
@@ -61,6 +61,7 @@
virtual void setShowDebugBorders(bool) { }
virtual void setShowFPSCounter(bool) { }
virtual void setContinuousPaintingEnabled(bool) { }
+ virtual void setShowScrollBottleneckRects(bool) { }
virtual void getAllocatedObjects(HashSet<const void*>&) { }
virtual void dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>&) { }
diff --git a/Source/core/inspector/InspectorConsoleAgent.cpp b/Source/core/inspector/InspectorConsoleAgent.cpp
index c09dd77..b4fcec9 100644
--- a/Source/core/inspector/InspectorConsoleAgent.cpp
+++ b/Source/core/inspector/InspectorConsoleAgent.cpp
@@ -40,17 +40,15 @@
#include "core/inspector/ScriptCallFrame.h"
#include "core/inspector/ScriptCallStack.h"
#include "core/loader/DocumentLoader.h"
-#include "core/page/Console.h"
-#include "core/page/DOMWindow.h"
#include "core/page/Frame.h"
#include "core/page/Page.h"
#include "core/platform/network/ResourceError.h"
#include "core/platform/network/ResourceResponse.h"
-#include <wtf/CurrentTime.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/CurrentTime.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -174,7 +172,7 @@
addConsoleMessage(adoptPtr(new ConsoleMessage(!isWorkerAgent(), source, type, level, message, arguments, state, requestIdentifier)));
}
-void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, ScriptState* state, unsigned long requestIdentifier)
+void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber, ScriptState* state, unsigned long requestIdentifier)
{
if (type == ClearMessageType) {
ErrorString error;
@@ -182,7 +180,7 @@
}
bool canGenerateCallStack = !isWorkerAgent() && m_frontend;
- addConsoleMessage(adoptPtr(new ConsoleMessage(canGenerateCallStack, source, type, level, message, scriptId, lineNumber, state, requestIdentifier)));
+ addConsoleMessage(adoptPtr(new ConsoleMessage(canGenerateCallStack, source, type, level, message, scriptId, lineNumber, columnNumber, state, requestIdentifier)));
}
Vector<unsigned> InspectorConsoleAgent::consoleMessageArgumentCounts()
@@ -220,7 +218,7 @@
double elapsed = monotonicallyIncreasingTime() - startTime;
String message = title + String::format(": %.3fms", elapsed * 1000);
const ScriptCallFrame& lastCaller = callStack->at(0);
- addMessageToConsole(ConsoleAPIMessageSource, TimingMessageType, DebugMessageLevel, message, lastCaller.sourceURL(), lastCaller.lineNumber());
+ addMessageToConsole(ConsoleAPIMessageSource, TimingMessageType, DebugMessageLevel, message, lastCaller.sourceURL(), lastCaller.lineNumber(), lastCaller.columnNumber());
}
void InspectorConsoleAgent::consoleCount(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
@@ -268,7 +266,7 @@
{
if (m_frontend && m_state->getBoolean(ConsoleAgentState::monitoringXHR)) {
String message = "XHR finished loading: \"" + url + "\".";
- addMessageToConsole(NetworkMessageSource, LogMessageType, DebugMessageLevel, message, sendURL, sendLineNumber, 0, requestIdentifier);
+ addMessageToConsole(NetworkMessageSource, LogMessageType, DebugMessageLevel, message, sendURL, sendLineNumber, 0, 0, requestIdentifier);
}
}
@@ -278,7 +276,7 @@
return;
if (response.httpStatusCode() >= 400) {
String message = "Failed to load resource: the server responded with a status of " + String::number(response.httpStatusCode()) + " (" + response.httpStatusText() + ')';
- addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message, response.url().string(), 0, 0, requestIdentifier);
+ addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message, response.url().string(), 0, 0, 0, requestIdentifier);
}
}
@@ -292,7 +290,7 @@
message.appendLiteral(": ");
message.append(error.localizedDescription());
}
- addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message.toString(), error.failingURL(), 0, 0, requestIdentifier);
+ addMessageToConsole(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message.toString(), error.failingURL(), 0, 0, 0, requestIdentifier);
}
void InspectorConsoleAgent::setMonitoringXHREnabled(ErrorString*, bool enabled)
diff --git a/Source/core/inspector/InspectorConsoleAgent.h b/Source/core/inspector/InspectorConsoleAgent.h
index 550d295..3d08e74 100644
--- a/Source/core/inspector/InspectorConsoleAgent.h
+++ b/Source/core/inspector/InspectorConsoleAgent.h
@@ -74,7 +74,7 @@
virtual void restore();
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, ScriptState*, PassRefPtr<ScriptArguments>, unsigned long requestIdentifier = 0);
- void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, const String& scriptId, unsigned lineNumber, ScriptState* = 0, unsigned long requestIdentifier = 0);
+ void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber = 0, ScriptState* = 0, unsigned long requestIdentifier = 0);
// FIXME: Remove once we no longer generate stacks outside of Inspector.
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>, unsigned long requestIdentifier = 0);
diff --git a/Source/core/inspector/InspectorController.cpp b/Source/core/inspector/InspectorController.cpp
index 9e59ddc..196c876 100644
--- a/Source/core/inspector/InspectorController.cpp
+++ b/Source/core/inspector/InspectorController.cpp
@@ -70,8 +70,7 @@
#include "core/inspector/PageRuntimeAgent.h"
#include "core/page/Page.h"
#include "core/platform/PlatformMouseEvent.h"
-#include <wtf/MemoryInstrumentationVector.h>
-#include <wtf/UnusedParam.h>
+#include "wtf/MemoryInstrumentationVector.h"
namespace WebCore {
@@ -112,7 +111,7 @@
inspectorClient));
m_agents.append(InspectorApplicationCacheAgent::create(m_instrumentingAgents.get(), m_state.get(), pageAgent));
- m_agents.append(InspectorResourceAgent::create(m_instrumentingAgents.get(), pageAgent, inspectorClient, m_state.get()));
+ m_agents.append(InspectorResourceAgent::create(m_instrumentingAgents.get(), pageAgent, inspectorClient, m_state.get(), m_overlay.get()));
PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::shared();
diff --git a/Source/core/inspector/InspectorCounters.h b/Source/core/inspector/InspectorCounters.h
index d619d16..893f941 100644
--- a/Source/core/inspector/InspectorCounters.h
+++ b/Source/core/inspector/InspectorCounters.h
@@ -31,11 +31,10 @@
#ifndef InspectorCounters_h
#define InspectorCounters_h
-#include <wtf/FastAllocBase.h>
-#include <wtf/UnusedParam.h>
+#include "wtf/FastAllocBase.h"
#if !ASSERT_DISABLED
-#include <wtf/MainThread.h>
+#include "wtf/MainThread.h"
#endif
namespace WebCore {
diff --git a/Source/core/inspector/InspectorDOMAgent.cpp b/Source/core/inspector/InspectorDOMAgent.cpp
index 16de128..c9a1674 100644
--- a/Source/core/inspector/InspectorDOMAgent.cpp
+++ b/Source/core/inspector/InspectorDOMAgent.cpp
@@ -37,6 +37,7 @@
#include "core/dom/Attr.h"
#include "core/dom/CharacterData.h"
#include "core/dom/ContainerNode.h"
+#include "core/dom/DOMException.h"
#include "core/dom/Document.h"
#include "core/dom/DocumentFragment.h"
#include "core/dom/DocumentType.h"
@@ -93,7 +94,7 @@
static const size_t maxTextSize = 10000;
static const UChar ellipsisUChar[] = { 0x2026, 0 };
-static Color parseColor(const RefPtr<InspectorObject>* colorObject)
+static Color parseColor(const RefPtr<JSONObject>* colorObject)
{
if (!colorObject || !(*colorObject))
return Color::transparent;
@@ -121,13 +122,13 @@
return Color(r, g, b, static_cast<int>(a * 255));
}
-static Color parseConfigColor(const String& fieldName, InspectorObject* configObject)
+static Color parseConfigColor(const String& fieldName, JSONObject* configObject)
{
- const RefPtr<InspectorObject> colorObject = configObject->getObject(fieldName);
+ const RefPtr<JSONObject> colorObject = configObject->getObject(fieldName);
return parseColor(&colorObject);
}
-static bool parseQuad(const RefPtr<InspectorArray>& quadArray, FloatQuad* quad)
+static bool parseQuad(const RefPtr<JSONArray>& quadArray, FloatQuad* quad)
{
if (!quadArray)
return false;
@@ -214,10 +215,8 @@
String InspectorDOMAgent::toErrorString(const ExceptionCode& ec)
{
- if (ec) {
- ExceptionCodeDescription description(ec);
- return description.name;
- }
+ if (ec)
+ return DOMException::getErrorName(ec);
return "";
}
@@ -994,7 +993,7 @@
break;
if (node->nodeType() == Node::ATTRIBUTE_NODE)
- node = static_cast<Attr*>(node)->ownerElement();
+ node = toAttr(node)->ownerElement();
resultCollector.add(node);
}
}
@@ -1101,7 +1100,7 @@
m_overlay->highlightNode(node, eventTarget, *m_inspectModeHighlightConfig);
}
-void InspectorDOMAgent::setSearchingForNode(ErrorString* errorString, bool enabled, InspectorObject* highlightInspectorObject)
+void InspectorDOMAgent::setSearchingForNode(ErrorString* errorString, bool enabled, JSONObject* highlightInspectorObject)
{
if (m_searchingForNode == enabled)
return;
@@ -1115,7 +1114,7 @@
hideHighlight(errorString);
}
-PassOwnPtr<HighlightConfig> InspectorDOMAgent::highlightConfigFromInspectorObject(ErrorString* errorString, InspectorObject* highlightInspectorObject)
+PassOwnPtr<HighlightConfig> InspectorDOMAgent::highlightConfigFromInspectorObject(ErrorString* errorString, JSONObject* highlightInspectorObject)
{
if (!highlightInspectorObject) {
*errorString = "Internal error: highlight configuration parameter is missing";
@@ -1138,18 +1137,18 @@
return highlightConfig.release();
}
-void InspectorDOMAgent::setInspectModeEnabled(ErrorString* errorString, bool enabled, const RefPtr<InspectorObject>* highlightConfig)
+void InspectorDOMAgent::setInspectModeEnabled(ErrorString* errorString, bool enabled, const RefPtr<JSONObject>* highlightConfig)
{
setSearchingForNode(errorString, enabled, highlightConfig ? highlightConfig->get() : 0);
}
-void InspectorDOMAgent::highlightRect(ErrorString*, int x, int y, int width, int height, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor)
+void InspectorDOMAgent::highlightRect(ErrorString*, int x, int y, int width, int height, const RefPtr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor)
{
OwnPtr<FloatQuad> quad = adoptPtr(new FloatQuad(FloatRect(x, y, width, height)));
innerHighlightQuad(quad.release(), color, outlineColor);
}
-void InspectorDOMAgent::highlightQuad(ErrorString* errorString, const RefPtr<InspectorArray>& quadArray, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor)
+void InspectorDOMAgent::highlightQuad(ErrorString* errorString, const RefPtr<JSONArray>& quadArray, const RefPtr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor)
{
OwnPtr<FloatQuad> quad = adoptPtr(new FloatQuad());
if (!parseQuad(quadArray, quad.get())) {
@@ -1159,7 +1158,7 @@
innerHighlightQuad(quad.release(), color, outlineColor);
}
-void InspectorDOMAgent::innerHighlightQuad(PassOwnPtr<FloatQuad> quad, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor)
+void InspectorDOMAgent::innerHighlightQuad(PassOwnPtr<FloatQuad> quad, const RefPtr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor)
{
OwnPtr<HighlightConfig> highlightConfig = adoptPtr(new HighlightConfig());
highlightConfig->content = parseColor(color);
@@ -1167,7 +1166,7 @@
m_overlay->highlightQuad(quad, *highlightConfig);
}
-void InspectorDOMAgent::highlightNode(ErrorString* errorString, const RefPtr<InspectorObject>& highlightInspectorObject, const int* nodeId, const String* objectId)
+void InspectorDOMAgent::highlightNode(ErrorString* errorString, const RefPtr<JSONObject>& highlightInspectorObject, const int* nodeId, const String* objectId)
{
Node* node = 0;
if (nodeId) {
@@ -1193,8 +1192,8 @@
void InspectorDOMAgent::highlightFrame(
ErrorString*,
const String& frameId,
- const RefPtr<InspectorObject>* color,
- const RefPtr<InspectorObject>* outlineColor)
+ const RefPtr<JSONObject>* color,
+ const RefPtr<JSONObject>* outlineColor)
{
Frame* frame = m_pageAgent->frameForId(frameId);
if (frame && frame->ownerElement()) {
@@ -1269,7 +1268,7 @@
element->focus();
}
-void InspectorDOMAgent::setFileInputFiles(ErrorString* errorString, int nodeId, const RefPtr<InspectorArray>& files)
+void InspectorDOMAgent::setFileInputFiles(ErrorString* errorString, int nodeId, const RefPtr<JSONArray>& files)
{
Node* node = assertNode(errorString, nodeId);
if (!node)
@@ -1280,7 +1279,7 @@
}
RefPtr<FileList> fileList = FileList::create();
- for (InspectorArray::const_iterator iter = files->begin(); iter != files->end(); ++iter) {
+ for (JSONArray::const_iterator iter = files->begin(); iter != files->end(); ++iter) {
String path;
if (!(*iter)->asString(&path)) {
*errorString = "Files must be strings";
@@ -1413,7 +1412,7 @@
value->setSystemId(docType->systemId());
value->setInternalSubset(docType->internalSubset());
} else if (node->isAttributeNode()) {
- Attr* attribute = static_cast<Attr*>(node);
+ Attr* attribute = toAttr(node);
value->setName(attribute->name());
value->setValue(attribute->value());
}
diff --git a/Source/core/inspector/InspectorDOMAgent.h b/Source/core/inspector/InspectorDOMAgent.h
index 912fdb6..a7aed5d 100644
--- a/Source/core/inspector/InspectorDOMAgent.h
+++ b/Source/core/inspector/InspectorDOMAgent.h
@@ -31,24 +31,19 @@
#define InspectorDOMAgent_h
#include "InspectorFrontend.h"
-#include "core/dom/EventTarget.h"
#include "core/inspector/InjectedScript.h"
#include "core/inspector/InjectedScriptManager.h"
#include "core/inspector/InspectorBaseAgent.h"
-#include "core/inspector/InspectorOverlay.h"
-#include "core/inspector/InspectorValues.h"
-#include "core/platform/Timer.h"
+#include "core/platform/JSONValues.h"
#include "core/rendering/RenderLayer.h"
-#include <wtf/Deque.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/ListHashSet.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/Vector.h>
+#include "wtf/HashMap.h"
+#include "wtf/HashSet.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/AtomicString.h"
namespace WebCore {
class ContainerNode;
@@ -138,23 +133,23 @@
virtual void discardSearchResults(ErrorString*, const String& searchId);
virtual void resolveNode(ErrorString*, int nodeId, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result);
virtual void getAttributes(ErrorString*, int nodeId, RefPtr<TypeBuilder::Array<String> >& result);
- virtual void setInspectModeEnabled(ErrorString*, bool enabled, const RefPtr<InspectorObject>* highlightConfig);
+ virtual void setInspectModeEnabled(ErrorString*, bool enabled, const RefPtr<JSONObject>* highlightConfig);
virtual void requestNode(ErrorString*, const String& objectId, int* nodeId);
virtual void pushNodeByPathToFrontend(ErrorString*, const String& path, int* nodeId);
virtual void pushNodeByBackendIdToFrontend(ErrorString*, BackendNodeId, int* nodeId);
virtual void releaseBackendNodeIds(ErrorString*, const String& nodeGroup);
virtual void hideHighlight(ErrorString*);
- virtual void highlightRect(ErrorString*, int x, int y, int width, int height, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor);
- virtual void highlightQuad(ErrorString*, const RefPtr<InspectorArray>& quad, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor);
- virtual void highlightNode(ErrorString*, const RefPtr<InspectorObject>& highlightConfig, const int* nodeId, const String* objectId);
- virtual void highlightFrame(ErrorString*, const String& frameId, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor);
+ virtual void highlightRect(ErrorString*, int x, int y, int width, int height, const RefPtr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor);
+ virtual void highlightQuad(ErrorString*, const RefPtr<JSONArray>& quad, const RefPtr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor);
+ virtual void highlightNode(ErrorString*, const RefPtr<JSONObject>& highlightConfig, const int* nodeId, const String* objectId);
+ virtual void highlightFrame(ErrorString*, const String& frameId, const RefPtr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor);
virtual void moveTo(ErrorString*, int nodeId, int targetNodeId, const int* anchorNodeId, int* newNodeId);
virtual void undo(ErrorString*);
virtual void redo(ErrorString*);
virtual void markUndoableState(ErrorString*);
virtual void focus(ErrorString*, int nodeId);
- virtual void setFileInputFiles(ErrorString*, int nodeId, const RefPtr<InspectorArray>& files);
+ virtual void setFileInputFiles(ErrorString*, int nodeId, const RefPtr<JSONArray>& files);
static void getEventListeners(Node*, Vector<EventListenerInfo>& listenersArray, bool includeAncestors);
@@ -212,8 +207,8 @@
private:
InspectorDOMAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorCompositeState*, InjectedScriptManager*, InspectorOverlay*, InspectorClient*);
- void setSearchingForNode(ErrorString*, bool enabled, InspectorObject* highlightConfig);
- PassOwnPtr<HighlightConfig> highlightConfigFromInspectorObject(ErrorString*, InspectorObject* highlightInspectorObject);
+ void setSearchingForNode(ErrorString*, bool enabled, JSONObject* highlightConfig);
+ PassOwnPtr<HighlightConfig> highlightConfigFromInspectorObject(ErrorString*, JSONObject* highlightInspectorObject);
// Node-related methods.
typedef HashMap<RefPtr<Node>, int> NodeToIdMap;
@@ -230,7 +225,7 @@
bool hasBreakpoint(Node*, int type);
void updateSubtreeBreakpoints(Node* root, uint32_t rootMask, bool value);
- void descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, PassRefPtr<InspectorObject> description);
+ void descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, PassRefPtr<JSONObject> description);
PassRefPtr<TypeBuilder::DOM::Node> buildObjectForNode(Node*, int depth, NodeToIdMap*);
PassRefPtr<TypeBuilder::Array<String> > buildArrayForElementAttributes(Element*);
@@ -242,7 +237,7 @@
void discardBackendBindings();
void discardFrontendBindings();
- void innerHighlightQuad(PassOwnPtr<FloatQuad>, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor);
+ void innerHighlightQuad(PassOwnPtr<FloatQuad>, const RefPtr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor);
InspectorPageAgent* m_pageAgent;
InjectedScriptManager* m_injectedScriptManager;
diff --git a/Source/core/inspector/InspectorDOMDebuggerAgent.cpp b/Source/core/inspector/InspectorDOMDebuggerAgent.cpp
index b955bb9..5d76e88 100644
--- a/Source/core/inspector/InspectorDOMDebuggerAgent.cpp
+++ b/Source/core/inspector/InspectorDOMDebuggerAgent.cpp
@@ -36,9 +36,9 @@
#include "core/inspector/InspectorDOMAgent.h"
#include "core/inspector/InspectorDebuggerAgent.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
-#include <wtf/text/WTFString.h>
+#include "core/platform/JSONValues.h"
+#include "wtf/text/WTFString.h"
namespace {
@@ -162,7 +162,7 @@
return;
}
- RefPtr<InspectorObject> eventListenerBreakpoints = m_state->getObject(DOMDebuggerAgentState::eventListenerBreakpoints);
+ RefPtr<JSONObject> eventListenerBreakpoints = m_state->getObject(DOMDebuggerAgentState::eventListenerBreakpoints);
eventListenerBreakpoints->setBoolean(eventName, true);
m_state->setObject(DOMDebuggerAgentState::eventListenerBreakpoints, eventListenerBreakpoints);
}
@@ -184,7 +184,7 @@
return;
}
- RefPtr<InspectorObject> eventListenerBreakpoints = m_state->getObject(DOMDebuggerAgentState::eventListenerBreakpoints);
+ RefPtr<JSONObject> eventListenerBreakpoints = m_state->getObject(DOMDebuggerAgentState::eventListenerBreakpoints);
eventListenerBreakpoints->remove(eventName);
m_state->setObject(DOMDebuggerAgentState::eventListenerBreakpoints, eventListenerBreakpoints);
}
@@ -192,7 +192,7 @@
void InspectorDOMDebuggerAgent::didInvalidateStyleAttr(Node* node)
{
if (hasBreakpoint(node, AttributeModified)) {
- RefPtr<InspectorObject> eventData = InspectorObject::create();
+ RefPtr<JSONObject> eventData = JSONObject::create();
descriptionForDOMEvent(node, AttributeModified, false, eventData.get());
m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
}
@@ -292,7 +292,7 @@
void InspectorDOMDebuggerAgent::willInsertDOMNode(Node* parent)
{
if (hasBreakpoint(parent, SubtreeModified)) {
- RefPtr<InspectorObject> eventData = InspectorObject::create();
+ RefPtr<JSONObject> eventData = JSONObject::create();
descriptionForDOMEvent(parent, SubtreeModified, true, eventData.get());
m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
}
@@ -302,11 +302,11 @@
{
Node* parentNode = InspectorDOMAgent::innerParentNode(node);
if (hasBreakpoint(node, NodeRemoved)) {
- RefPtr<InspectorObject> eventData = InspectorObject::create();
+ RefPtr<JSONObject> eventData = JSONObject::create();
descriptionForDOMEvent(node, NodeRemoved, false, eventData.get());
m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
} else if (parentNode && hasBreakpoint(parentNode, SubtreeModified)) {
- RefPtr<InspectorObject> eventData = InspectorObject::create();
+ RefPtr<JSONObject> eventData = JSONObject::create();
descriptionForDOMEvent(node, SubtreeModified, false, eventData.get());
m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
}
@@ -316,13 +316,13 @@
void InspectorDOMDebuggerAgent::willModifyDOMAttr(Element* element, const AtomicString&, const AtomicString&)
{
if (hasBreakpoint(element, AttributeModified)) {
- RefPtr<InspectorObject> eventData = InspectorObject::create();
+ RefPtr<JSONObject> eventData = JSONObject::create();
descriptionForDOMEvent(element, AttributeModified, false, eventData.get());
m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
}
}
-void InspectorDOMDebuggerAgent::descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, InspectorObject* description)
+void InspectorDOMDebuggerAgent::descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, JSONObject* description)
{
ASSERT(hasBreakpoint(target, breakpointType));
@@ -379,7 +379,7 @@
updateSubtreeBreakpoints(child, newRootMask, set);
}
-void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(PassRefPtr<InspectorObject> eventData, bool synchronous)
+void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(PassRefPtr<JSONObject> eventData, bool synchronous)
{
if (!eventData)
return;
@@ -389,18 +389,18 @@
m_debuggerAgent->schedulePauseOnNextStatement(InspectorFrontend::Debugger::Reason::EventListener, eventData);
}
-PassRefPtr<InspectorObject> InspectorDOMDebuggerAgent::preparePauseOnNativeEventData(bool isDOMEvent, const String& eventName)
+PassRefPtr<JSONObject> InspectorDOMDebuggerAgent::preparePauseOnNativeEventData(bool isDOMEvent, const String& eventName)
{
String fullEventName = (isDOMEvent ? listenerEventCategoryType : instrumentationEventCategoryType) + eventName;
if (m_pauseInNextEventListener)
m_pauseInNextEventListener = false;
else {
- RefPtr<InspectorObject> eventListenerBreakpoints = m_state->getObject(DOMDebuggerAgentState::eventListenerBreakpoints);
+ RefPtr<JSONObject> eventListenerBreakpoints = m_state->getObject(DOMDebuggerAgentState::eventListenerBreakpoints);
if (eventListenerBreakpoints->find(fullEventName) == eventListenerBreakpoints->end())
return 0;
}
- RefPtr<InspectorObject> eventData = InspectorObject::create();
+ RefPtr<JSONObject> eventData = JSONObject::create();
eventData->setString("eventName", fullEventName);
return eventData.release();
}
@@ -442,7 +442,7 @@
void InspectorDOMDebuggerAgent::didFireWebGLError(const String& errorName)
{
- RefPtr<InspectorObject> eventData = preparePauseOnNativeEventData(false, webglErrorFiredEventName);
+ RefPtr<JSONObject> eventData = preparePauseOnNativeEventData(false, webglErrorFiredEventName);
if (!eventData)
return;
eventData->setString("webglErrorName", errorName);
@@ -456,7 +456,7 @@
return;
}
- RefPtr<InspectorObject> xhrBreakpoints = m_state->getObject(DOMDebuggerAgentState::xhrBreakpoints);
+ RefPtr<JSONObject> xhrBreakpoints = m_state->getObject(DOMDebuggerAgentState::xhrBreakpoints);
xhrBreakpoints->setBoolean(url, true);
m_state->setObject(DOMDebuggerAgentState::xhrBreakpoints, xhrBreakpoints);
}
@@ -468,7 +468,7 @@
return;
}
- RefPtr<InspectorObject> xhrBreakpoints = m_state->getObject(DOMDebuggerAgentState::xhrBreakpoints);
+ RefPtr<JSONObject> xhrBreakpoints = m_state->getObject(DOMDebuggerAgentState::xhrBreakpoints);
xhrBreakpoints->remove(url);
m_state->setObject(DOMDebuggerAgentState::xhrBreakpoints, xhrBreakpoints);
}
@@ -479,8 +479,8 @@
if (m_state->getBoolean(DOMDebuggerAgentState::pauseOnAllXHRs))
breakpointURL = "";
else {
- RefPtr<InspectorObject> xhrBreakpoints = m_state->getObject(DOMDebuggerAgentState::xhrBreakpoints);
- for (InspectorObject::iterator it = xhrBreakpoints->begin(); it != xhrBreakpoints->end(); ++it) {
+ RefPtr<JSONObject> xhrBreakpoints = m_state->getObject(DOMDebuggerAgentState::xhrBreakpoints);
+ for (JSONObject::iterator it = xhrBreakpoints->begin(); it != xhrBreakpoints->end(); ++it) {
if (url.contains(it->key)) {
breakpointURL = it->key;
break;
@@ -491,7 +491,7 @@
if (breakpointURL.isNull())
return;
- RefPtr<InspectorObject> eventData = InspectorObject::create();
+ RefPtr<JSONObject> eventData = JSONObject::create();
eventData->setString("breakpointURL", breakpointURL);
eventData->setString("url", url);
m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::XHR, eventData.release());
diff --git a/Source/core/inspector/InspectorDOMDebuggerAgent.h b/Source/core/inspector/InspectorDOMDebuggerAgent.h
index d925081..18d3698 100644
--- a/Source/core/inspector/InspectorDOMDebuggerAgent.h
+++ b/Source/core/inspector/InspectorDOMDebuggerAgent.h
@@ -34,10 +34,9 @@
#include "core/inspector/InspectorBaseAgent.h"
#include "core/inspector/InspectorDebuggerAgent.h"
-#include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/HashMap.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -47,9 +46,9 @@
class InspectorDOMAgent;
class InspectorDebuggerAgent;
class InspectorFrontend;
-class InspectorObject;
class InspectorState;
class InstrumentingAgents;
+class JSONObject;
class Node;
typedef String ErrorString;
@@ -96,8 +95,8 @@
private:
InspectorDOMDebuggerAgent(InstrumentingAgents*, InspectorCompositeState*, InspectorDOMAgent*, InspectorDebuggerAgent*);
- void pauseOnNativeEventIfNeeded(PassRefPtr<InspectorObject> eventData, bool synchronous);
- PassRefPtr<InspectorObject> preparePauseOnNativeEventData(bool isDOMEvent, const String& eventName);
+ void pauseOnNativeEventIfNeeded(PassRefPtr<JSONObject> eventData, bool synchronous);
+ PassRefPtr<JSONObject> preparePauseOnNativeEventData(bool isDOMEvent, const String& eventName);
// InspectorDebuggerAgent::Listener implementation.
virtual void debuggerWasEnabled();
@@ -106,7 +105,7 @@
virtual void didPause();
void disable();
- void descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, InspectorObject* description);
+ void descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, JSONObject* description);
void updateSubtreeBreakpoints(Node*, uint32_t rootMask, bool set);
bool hasBreakpoint(Node*, int type);
void discardBindings();
diff --git a/Source/core/inspector/InspectorDOMStorageAgent.cpp b/Source/core/inspector/InspectorDOMStorageAgent.cpp
index 01a4545..65f4812 100644
--- a/Source/core/inspector/InspectorDOMStorageAgent.cpp
+++ b/Source/core/inspector/InspectorDOMStorageAgent.cpp
@@ -30,26 +30,24 @@
#include "config.h"
#include "core/inspector/InspectorDOMStorageAgent.h"
-#include "DOMException.h"
#include "InspectorFrontend.h"
+#include "core/dom/DOMException.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/WebCoreMemoryInstrumentation.h"
#include "core/inspector/InspectorPageAgent.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/page/DOMWindow.h"
#include "core/page/Frame.h"
#include "core/page/Page.h"
#include "core/page/PageGroup.h"
+#include "core/platform/JSONValues.h"
#include "core/storage/Storage.h"
#include "core/storage/StorageArea.h"
#include "core/storage/StorageNamespace.h"
#include "weborigin/SecurityOrigin.h"
-
-#include <wtf/MemoryInstrumentationHashMap.h>
-#include <wtf/Vector.h>
+#include "wtf/MemoryInstrumentationHashMap.h"
namespace WebCore {
@@ -76,13 +74,10 @@
, m_pageAgent(pageAgent)
, m_frontend(0)
{
- m_instrumentingAgents->setInspectorDOMStorageAgent(this);
}
InspectorDOMStorageAgent::~InspectorDOMStorageAgent()
{
- m_instrumentingAgents->setInspectorDOMStorageAgent(0);
- m_instrumentingAgents = 0;
}
void InspectorDOMStorageAgent::setFrontend(InspectorFrontend* frontend)
@@ -104,17 +99,19 @@
void InspectorDOMStorageAgent::enable(ErrorString*)
{
m_state->setBoolean(DOMStorageAgentState::domStorageAgentEnabled, true);
+ m_instrumentingAgents->setInspectorDOMStorageAgent(this);
}
void InspectorDOMStorageAgent::disable(ErrorString*)
{
+ m_instrumentingAgents->setInspectorDOMStorageAgent(0);
m_state->setBoolean(DOMStorageAgentState::domStorageAgentEnabled, false);
}
-void InspectorDOMStorageAgent::getDOMStorageItems(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > >& items)
+void InspectorDOMStorageAgent::getDOMStorageItems(ErrorString* errorString, const RefPtr<JSONObject>& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > >& items)
{
Frame* frame;
- RefPtr<StorageArea> storageArea = findStorageArea(errorString, storageId, frame);
+ OwnPtr<StorageArea> storageArea = findStorageArea(errorString, storageId, frame);
if (!storageArea)
return;
@@ -138,17 +135,15 @@
static String toErrorString(const ExceptionCode& ec)
{
- if (ec) {
- ExceptionCodeDescription description(ec);
- return description.name;
- }
+ if (ec)
+ return DOMException::getErrorName(ec);
return "";
}
-void InspectorDOMStorageAgent::setDOMStorageItem(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, const String& key, const String& value)
+void InspectorDOMStorageAgent::setDOMStorageItem(ErrorString* errorString, const RefPtr<JSONObject>& storageId, const String& key, const String& value)
{
Frame* frame;
- RefPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame);
+ OwnPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame);
if (!storageArea) {
*errorString = "Storage not found";
return;
@@ -159,10 +154,10 @@
*errorString = toErrorString(exception);
}
-void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, const String& key)
+void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString* errorString, const RefPtr<JSONObject>& storageId, const String& key)
{
Frame* frame;
- RefPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame);
+ OwnPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame);
if (!storageArea) {
*errorString = "Storage not found";
return;
@@ -209,7 +204,7 @@
m_frontend->domstorage()->domStorageItemUpdated(id, key, oldValue, newValue);
}
-PassRefPtr<StorageArea> InspectorDOMStorageAgent::findStorageArea(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, Frame*& targetFrame)
+PassOwnPtr<StorageArea> InspectorDOMStorageAgent::findStorageArea(ErrorString* errorString, const RefPtr<JSONObject>& storageId, Frame*& targetFrame)
{
String securityOrigin;
bool isLocalStorage = false;
@@ -219,21 +214,20 @@
if (!success) {
if (errorString)
*errorString = "Invalid storageId format";
- return 0;
+ return nullptr;
}
Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);
if (!frame) {
if (errorString)
*errorString = "Frame not found for the given security origin";
- return 0;
+ return nullptr;
}
targetFrame = frame;
- Page* page = m_pageAgent->page();
if (isLocalStorage)
- return page->group().localStorage()->storageArea(frame->document()->securityOrigin());
- return page->sessionStorage()->storageArea(frame->document()->securityOrigin());
+ return StorageNamespace::localStorageArea(frame->document()->securityOrigin());
+ return m_pageAgent->page()->sessionStorage()->storageArea(frame->document()->securityOrigin());
}
void InspectorDOMStorageAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
diff --git a/Source/core/inspector/InspectorDOMStorageAgent.h b/Source/core/inspector/InspectorDOMStorageAgent.h
index 3cacfba..ba2fb1c 100644
--- a/Source/core/inspector/InspectorDOMStorageAgent.h
+++ b/Source/core/inspector/InspectorDOMStorageAgent.h
@@ -31,18 +31,17 @@
#include "core/inspector/InspectorBaseAgent.h"
#include "core/storage/StorageArea.h"
-#include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
class Frame;
-class InspectorArray;
class InspectorFrontend;
class InspectorPageAgent;
class InspectorState;
class InstrumentingAgents;
+class JSONObject;
class Page;
class Storage;
class StorageArea;
@@ -63,9 +62,9 @@
// Called from the front-end.
virtual void enable(ErrorString*);
virtual void disable(ErrorString*);
- virtual void getDOMStorageItems(ErrorString*, const RefPtr<InspectorObject>& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > >& items);
- virtual void setDOMStorageItem(ErrorString*, const RefPtr<InspectorObject>& storageId, const String& key, const String& value);
- virtual void removeDOMStorageItem(ErrorString*, const RefPtr<InspectorObject>& storageId, const String& key);
+ virtual void getDOMStorageItems(ErrorString*, const RefPtr<JSONObject>& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > >& items);
+ virtual void setDOMStorageItem(ErrorString*, const RefPtr<JSONObject>& storageId, const String& key, const String& value);
+ virtual void removeDOMStorageItem(ErrorString*, const RefPtr<JSONObject>& storageId, const String& key);
// Called from the injected script.
String storageId(Storage*);
@@ -81,7 +80,7 @@
InspectorDOMStorageAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorCompositeState*);
bool isEnabled() const;
- PassRefPtr<StorageArea> findStorageArea(ErrorString*, const RefPtr<InspectorObject>&, Frame*&);
+ PassOwnPtr<StorageArea> findStorageArea(ErrorString*, const RefPtr<JSONObject>&, Frame*&);
InspectorPageAgent* m_pageAgent;
InspectorFrontend* m_frontend;
diff --git a/Source/core/inspector/InspectorDatabaseAgent.cpp b/Source/core/inspector/InspectorDatabaseAgent.cpp
index d75a3aa..2fbc619 100644
--- a/Source/core/inspector/InspectorDatabaseAgent.cpp
+++ b/Source/core/inspector/InspectorDatabaseAgent.cpp
@@ -35,11 +35,11 @@
#include "core/html/VoidCallback.h"
#include "core/inspector/InspectorDatabaseResource.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/loader/DocumentLoader.h"
#include "core/page/Frame.h"
#include "core/page/Page.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/sql/SQLValue.h"
#include "modules/webdatabase/Database.h"
#include "modules/webdatabase/SQLError.h"
@@ -89,14 +89,14 @@
for (size_t i = 0; i < columns.size(); ++i)
columnNames->addItem(columns[i]);
- RefPtr<TypeBuilder::Array<InspectorValue> > values = TypeBuilder::Array<InspectorValue>::create();
+ RefPtr<TypeBuilder::Array<JSONValue> > values = TypeBuilder::Array<JSONValue>::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->addItem(InspectorString::create(value.string())); break;
- case SQLValue::NumberValue: values->addItem(InspectorBasicValue::create(value.number())); break;
- case SQLValue::NullValue: values->addItem(InspectorValue::null()); break;
+ case SQLValue::StringValue: values->addItem(JSONString::create(value.string())); break;
+ case SQLValue::NumberValue: values->addItem(JSONBasicValue::create(value.number())); break;
+ case SQLValue::NullValue: values->addItem(JSONValue::null()); break;
}
}
m_requestCallback->sendSuccess(columnNames.release(), values.release(), 0);
diff --git a/Source/core/inspector/InspectorDatabaseAgent.h b/Source/core/inspector/InspectorDatabaseAgent.h
index 190e004..39eb8ed 100644
--- a/Source/core/inspector/InspectorDatabaseAgent.h
+++ b/Source/core/inspector/InspectorDatabaseAgent.h
@@ -40,7 +40,6 @@
class Database;
class DocumentLoader;
class Frame;
-class InspectorArray;
class InspectorDatabaseResource;
class InspectorFrontend;
class InspectorState;
diff --git a/Source/core/inspector/InspectorDebuggerAgent.cpp b/Source/core/inspector/InspectorDebuggerAgent.cpp
index 6a847c9..b3e2640 100644
--- a/Source/core/inspector/InspectorDebuggerAgent.cpp
+++ b/Source/core/inspector/InspectorDebuggerAgent.cpp
@@ -38,15 +38,15 @@
#include "core/inspector/InjectedScriptManager.h"
#include "core/inspector/InspectorPageAgent.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/inspector/ScriptArguments.h"
#include "core/inspector/ScriptCallStack.h"
#include "core/loader/cache/CachedResource.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/text/RegularExpression.h"
-#include <wtf/MemoryInstrumentationHashMap.h>
-#include <wtf/MemoryInstrumentationVector.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/MemoryInstrumentationHashMap.h"
+#include "wtf/MemoryInstrumentationVector.h"
+#include "wtf/text/WTFString.h"
using WebCore::TypeBuilder::Array;
using WebCore::TypeBuilder::Debugger::FunctionDetails;
@@ -113,7 +113,7 @@
void InspectorDebuggerAgent::disable()
{
- m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, InspectorObject::create());
+ m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, JSONObject::create());
m_state->setLong(DebuggerAgentState::pauseOnExceptionsState, ScriptDebugServer::DontPauseOnExceptions);
m_instrumentingAgents->setInspectorDebuggerAgent(0);
@@ -214,9 +214,9 @@
}
-static PassRefPtr<InspectorObject> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, bool isRegex)
+static PassRefPtr<JSONObject> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, bool isRegex)
{
- RefPtr<InspectorObject> breakpointObject = InspectorObject::create();
+ RefPtr<JSONObject> breakpointObject = JSONObject::create();
breakpointObject->setString("url", url);
breakpointObject->setNumber("lineNumber", lineNumber);
breakpointObject->setNumber("columnNumber", columnNumber);
@@ -248,7 +248,7 @@
bool isRegex = optionalURLRegex;
String breakpointId = (isRegex ? "/" + url + "/" : url) + ':' + String::number(lineNumber) + ':' + String::number(columnNumber);
- RefPtr<InspectorObject> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints);
+ RefPtr<JSONObject> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints);
if (breakpointsCookie->find(breakpointId) != breakpointsCookie->end()) {
*errorString = "Breakpoint at specified location already exists.";
return;
@@ -268,7 +268,7 @@
*outBreakpointId = breakpointId;
}
-static bool parseLocation(ErrorString* errorString, RefPtr<InspectorObject> location, String* scriptId, int* lineNumber, int* columnNumber)
+static bool parseLocation(ErrorString* errorString, PassRefPtr<JSONObject> location, String* scriptId, int* lineNumber, int* columnNumber)
{
if (!location->getString("scriptId", scriptId) || !location->getNumber("lineNumber", lineNumber)) {
// FIXME: replace with input validation.
@@ -280,7 +280,7 @@
return true;
}
-void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, const RefPtr<InspectorObject>& location, const String* const optionalCondition, TypeBuilder::Debugger::BreakpointId* outBreakpointId, RefPtr<TypeBuilder::Debugger::Location>& actualLocation)
+void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, const RefPtr<JSONObject>& location, const String* const optionalCondition, TypeBuilder::Debugger::BreakpointId* outBreakpointId, RefPtr<TypeBuilder::Debugger::Location>& actualLocation)
{
String scriptId;
int lineNumber;
@@ -306,7 +306,7 @@
void InspectorDebuggerAgent::removeBreakpoint(ErrorString*, const String& breakpointId)
{
- RefPtr<InspectorObject> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints);
+ RefPtr<JSONObject> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints);
breakpointsCookie->remove(breakpointId);
m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie);
@@ -326,7 +326,7 @@
m_breakpointIdToDebugServerBreakpointIds.remove(debugServerBreakpointIdsIterator);
}
-void InspectorDebuggerAgent::continueToLocation(ErrorString* errorString, const RefPtr<InspectorObject>& location)
+void InspectorDebuggerAgent::continueToLocation(ErrorString* errorString, const RefPtr<JSONObject>& location)
{
if (!m_continueToLocationBreakpointId.isEmpty()) {
scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId);
@@ -374,11 +374,11 @@
return location;
}
-static PassRefPtr<InspectorObject> scriptToInspectorObject(ScriptObject scriptObject)
+static PassRefPtr<JSONObject> scriptToInspectorObject(ScriptObject scriptObject)
{
if (scriptObject.hasNoValue())
return 0;
- RefPtr<InspectorValue> value = scriptObject.toInspectorValue(scriptObject.scriptState());
+ RefPtr<JSONValue> value = scriptObject.toJSONValue(scriptObject.scriptState());
if (!value)
return 0;
return value->asObject();
@@ -396,18 +396,18 @@
*error = "No script for id: " + scriptId;
}
-void InspectorDebuggerAgent::setScriptSource(ErrorString* error, const String& scriptId, const String& newContent, const bool* const preview, RefPtr<Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames, RefPtr<InspectorObject>& result)
+void InspectorDebuggerAgent::setScriptSource(ErrorString* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>& errorData, const String& scriptId, const String& newContent, const bool* const preview, RefPtr<Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames, RefPtr<JSONObject>& result)
{
bool previewOnly = preview && *preview;
ScriptObject resultObject;
- if (!scriptDebugServer().setScriptSource(scriptId, newContent, previewOnly, error, &m_currentCallStack, &resultObject))
+ if (!scriptDebugServer().setScriptSource(scriptId, newContent, previewOnly, error, errorData, &m_currentCallStack, &resultObject))
return;
newCallFrames = currentCallFrames();
- RefPtr<InspectorObject> object = scriptToInspectorObject(resultObject);
+ RefPtr<JSONObject> object = scriptToInspectorObject(resultObject);
if (object)
result = object;
}
-void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames, RefPtr<InspectorObject>& result)
+void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames, RefPtr<JSONObject>& result)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(callFrameId);
if (injectedScript.hasNoValue()) {
@@ -439,7 +439,7 @@
injectedScript.getFunctionDetails(errorString, functionId, &details);
}
-void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<InspectorObject> data)
+void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data)
{
if (m_javaScriptPauseScheduled)
return;
@@ -616,7 +616,7 @@
{
}
-void InspectorDebuggerAgent::setVariableValue(ErrorString* errorString, int scopeNumber, const String& variableName, const RefPtr<InspectorObject>& newValue, const String* callFrameId, const String* functionObjectId)
+void InspectorDebuggerAgent::setVariableValue(ErrorString* errorString, int scopeNumber, const String& variableName, const RefPtr<JSONObject>& newValue, const String* callFrameId, const String* functionObjectId)
{
InjectedScript injectedScript;
if (callFrameId) {
@@ -643,7 +643,7 @@
void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directiveText)
{
if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontPauseOnExceptions) {
- RefPtr<InspectorObject> directive = InspectorObject::create();
+ RefPtr<JSONObject> directive = JSONObject::create();
directive->setString("directiveText", directiveText);
breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directive.release());
}
@@ -666,8 +666,7 @@
bool deprecated;
String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source, ContentSearchUtils::JavaScriptMagicComment, &deprecated);
if (!sourceMapURL.isEmpty()) {
- if (deprecated)
- addConsoleMessage(NetworkMessageSource, WarningMessageLevel, "\"//@ sourceMappingURL=\" source mapping URL declaration is deprecated, \"//# sourceMappingURL=\" declaration should be used instead.", script.url);
+ // FIXME: add deprecated console message here.
return sourceMapURL;
}
@@ -692,8 +691,7 @@
if (!script.startLine && !script.startColumn) {
bool deprecated;
sourceURL = ContentSearchUtils::findSourceURL(script.source, ContentSearchUtils::JavaScriptMagicComment, &deprecated);
- if (deprecated)
- addConsoleMessage(NetworkMessageSource, WarningMessageLevel, "\"//@ sourceURL=\" source URL declaration is deprecated, \"//# sourceURL=\" declaration should be used instead.", script.url);
+ // FIXME: add deprecated console message here.
}
bool hasSourceURL = !sourceURL.isEmpty();
String scriptURL = hasSourceURL ? sourceURL : script.url;
@@ -705,9 +703,9 @@
if (scriptURL.isEmpty())
return;
- RefPtr<InspectorObject> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints);
- for (InspectorObject::iterator it = breakpointsCookie->begin(); it != breakpointsCookie->end(); ++it) {
- RefPtr<InspectorObject> breakpointObject = it->value->asObject();
+ RefPtr<JSONObject> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints);
+ for (JSONObject::iterator it = breakpointsCookie->begin(); it != breakpointsCookie->end(); ++it) {
+ RefPtr<JSONObject> breakpointObject = it->value->asObject();
bool isRegex;
breakpointObject->getBoolean("isRegex", &isRegex);
String url;
@@ -782,7 +780,7 @@
return scriptDebugServer().canBreakProgram();
}
-void InspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<InspectorObject> data)
+void InspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data)
{
m_breakReason = breakReason;
m_breakAuxData = data;
diff --git a/Source/core/inspector/InspectorDebuggerAgent.h b/Source/core/inspector/InspectorDebuggerAgent.h
index cc5664d..d34cff0 100644
--- a/Source/core/inspector/InspectorDebuggerAgent.h
+++ b/Source/core/inspector/InspectorDebuggerAgent.h
@@ -38,22 +38,19 @@
#include "core/inspector/ScriptBreakpoint.h"
#include "core/inspector/ScriptDebugListener.h"
#include "core/page/ConsoleTypes.h"
-#include <wtf/Forward.h>
-#include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/Vector.h>
+#include "wtf/Forward.h"
+#include "wtf/HashMap.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/StringHash.h"
namespace WebCore {
class InjectedScriptManager;
class InspectorFrontend;
-class InspectorArray;
-class InspectorObject;
class InspectorState;
-class InspectorValue;
class InstrumentingAgents;
+class JSONObject;
class ScriptArguments;
class ScriptCallStack;
class ScriptDebugServer;
@@ -91,13 +88,13 @@
virtual void setBreakpointsActive(ErrorString*, bool active);
virtual void setBreakpointByUrl(ErrorString*, int lineNumber, const String* optionalURL, const String* optionalURLRegex, const int* optionalColumnNumber, const String* optionalCondition, TypeBuilder::Debugger::BreakpointId*, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::Location> >& locations);
- virtual void setBreakpoint(ErrorString*, const RefPtr<InspectorObject>& location, const String* optionalCondition, TypeBuilder::Debugger::BreakpointId*, RefPtr<TypeBuilder::Debugger::Location>& actualLocation);
+ virtual void setBreakpoint(ErrorString*, const RefPtr<JSONObject>& location, const String* optionalCondition, TypeBuilder::Debugger::BreakpointId*, RefPtr<TypeBuilder::Debugger::Location>& actualLocation);
virtual void removeBreakpoint(ErrorString*, const String& breakpointId);
- virtual void continueToLocation(ErrorString*, const RefPtr<InspectorObject>& location);
+ virtual void continueToLocation(ErrorString*, const RefPtr<JSONObject>& location);
virtual void searchInContent(ErrorString*, const String& scriptId, const String& query, const bool* optionalCaseSensitive, const bool* optionalIsRegex, RefPtr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> >&);
- virtual void setScriptSource(ErrorString*, const String& scriptId, const String& newContent, const bool* preview, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames, RefPtr<InspectorObject>& result);
- virtual void restartFrame(ErrorString*, const String& callFrameId, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames, RefPtr<InspectorObject>& result);
+ virtual void setScriptSource(ErrorString*, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>&, const String& scriptId, const String& newContent, const bool* preview, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames, RefPtr<JSONObject>& result);
+ virtual void restartFrame(ErrorString*, const String& callFrameId, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames, RefPtr<JSONObject>& result);
virtual void getScriptSource(ErrorString*, const String& scriptId, String* scriptSource);
virtual void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>&);
virtual void pause(ErrorString*);
@@ -119,13 +116,13 @@
void compileScript(ErrorString*, const String& expression, const String& sourceURL, TypeBuilder::OptOutput<TypeBuilder::Debugger::ScriptId>*, TypeBuilder::OptOutput<String>* syntaxErrorMessage);
void runScript(ErrorString*, const TypeBuilder::Debugger::ScriptId&, const int* executionContextId, const String* objectGroup, const bool* doNotPauseOnExceptionsAndMuteConsole, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown);
virtual void setOverlayMessage(ErrorString*, const String*);
- virtual void setVariableValue(ErrorString*, int in_scopeNumber, const String& in_variableName, const RefPtr<InspectorObject>& in_newValue, const String* in_callFrame, const String* in_functionObjectId);
+ virtual void setVariableValue(ErrorString*, int in_scopeNumber, const String& in_variableName, const RefPtr<JSONObject>& in_newValue, const String* in_callFrame, const String* in_functionObjectId);
- void schedulePauseOnNextStatement(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<InspectorObject> data);
+ void schedulePauseOnNextStatement(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data);
void didFireTimer();
void didHandleEvent();
bool canBreakProgram();
- void breakProgram(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<InspectorObject> data);
+ void breakProgram(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data);
virtual void scriptExecutionBlockedByCSP(const String& directiveText);
class Listener {
@@ -196,7 +193,7 @@
DebugServerBreakpointToBreakpointIdAndSourceMap m_serverBreakpoints;
String m_continueToLocationBreakpointId;
InspectorFrontend::Debugger::Reason::Enum m_breakReason;
- RefPtr<InspectorObject> m_breakAuxData;
+ RefPtr<JSONObject> m_breakAuxData;
bool m_javaScriptPauseScheduled;
Listener* m_listener;
};
diff --git a/Source/core/inspector/InspectorFrontendHost.cpp b/Source/core/inspector/InspectorFrontendHost.cpp
index d23bdce..f914a14 100644
--- a/Source/core/inspector/InspectorFrontendHost.cpp
+++ b/Source/core/inspector/InspectorFrontendHost.cpp
@@ -48,7 +48,6 @@
#include "core/platform/network/ResourceResponse.h"
#include "core/rendering/RenderTheme.h"
#include "modules/filesystem/DOMFileSystem.h"
-#include <wtf/StdLibExtras.h>
using namespace std;
diff --git a/Source/core/inspector/InspectorFrontendHost.h b/Source/core/inspector/InspectorFrontendHost.h
index fb9da0c..83e9344 100644
--- a/Source/core/inspector/InspectorFrontendHost.h
+++ b/Source/core/inspector/InspectorFrontendHost.h
@@ -30,12 +30,10 @@
#define InspectorFrontendHost_h
#include "bindings/v8/ScriptWrappable.h"
-#include "core/page/ConsoleTypes.h"
-#include "core/page/ContextMenuProvider.h"
#include "core/platform/ContextMenu.h"
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/RefCounted.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
diff --git a/Source/core/inspector/InspectorIndexedDBAgent.cpp b/Source/core/inspector/InspectorIndexedDBAgent.cpp
index 31e0736..d138931 100644
--- a/Source/core/inspector/InspectorIndexedDBAgent.cpp
+++ b/Source/core/inspector/InspectorIndexedDBAgent.cpp
@@ -40,8 +40,8 @@
#include "core/inspector/InjectedScript.h"
#include "core/inspector/InspectorPageAgent.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/page/Frame.h"
+#include "core/platform/JSONValues.h"
#include "modules/indexeddb/DOMWindowIndexedDatabase.h"
#include "modules/indexeddb/IDBCursor.h"
#include "modules/indexeddb/IDBCursorWithValue.h"
@@ -320,7 +320,7 @@
RefPtr<RequestDatabaseCallback> m_requestCallback;
};
-static PassRefPtr<IDBKey> idbKeyFromInspectorObject(InspectorObject* key)
+static PassRefPtr<IDBKey> idbKeyFromInspectorObject(JSONObject* key)
{
RefPtr<IDBKey> idbKey;
@@ -350,10 +350,10 @@
idbKey = IDBKey::createDate(date);
} else if (type == array) {
IDBKey::KeyArray keyArray;
- RefPtr<InspectorArray> array = key->getArray("array");
+ RefPtr<JSONArray> array = key->getArray("array");
for (size_t i = 0; i < array->length(); ++i) {
- RefPtr<InspectorValue> value = array->get(i);
- RefPtr<InspectorObject> object;
+ RefPtr<JSONValue> value = array->get(i);
+ RefPtr<JSONObject> object;
if (!value->asObject(&object))
return 0;
keyArray.append(idbKeyFromInspectorObject(object.get()));
@@ -365,14 +365,14 @@
return idbKey.release();
}
-static PassRefPtr<IDBKeyRange> idbKeyRangeFromKeyRange(InspectorObject* keyRange)
+static PassRefPtr<IDBKeyRange> idbKeyRangeFromKeyRange(JSONObject* keyRange)
{
- RefPtr<InspectorObject> lower = keyRange->getObject("lower");
+ RefPtr<JSONObject> lower = keyRange->getObject("lower");
RefPtr<IDBKey> idbLower = lower ? idbKeyFromInspectorObject(lower.get()) : 0;
if (lower && !idbLower)
return 0;
- RefPtr<InspectorObject> upper = keyRange->getObject("upper");
+ RefPtr<JSONObject> upper = keyRange->getObject("upper");
RefPtr<IDBKey> idbUpper = upper ? idbKeyFromInspectorObject(upper.get()) : 0;
if (upper && !idbUpper)
return 0;
@@ -652,7 +652,7 @@
databaseLoader->start(idbFactory, document->securityOrigin(), databaseName);
}
-void InspectorIndexedDBAgent::requestData(ErrorString* errorString, const String& securityOrigin, const String& databaseName, const String& objectStoreName, const String& indexName, int skipCount, int pageSize, const RefPtr<InspectorObject>* keyRange, PassRefPtr<RequestDataCallback> requestCallback)
+void InspectorIndexedDBAgent::requestData(ErrorString* errorString, const String& securityOrigin, const String& databaseName, const String& objectStoreName, const String& indexName, int skipCount, int pageSize, const RefPtr<JSONObject>* keyRange, PassRefPtr<RequestDataCallback> requestCallback)
{
Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);
Document* document = assertDocument(errorString, frame);
diff --git a/Source/core/inspector/InspectorIndexedDBAgent.h b/Source/core/inspector/InspectorIndexedDBAgent.h
index 259b2a7..f008585 100644
--- a/Source/core/inspector/InspectorIndexedDBAgent.h
+++ b/Source/core/inspector/InspectorIndexedDBAgent.h
@@ -58,7 +58,7 @@
virtual void disable(ErrorString*);
virtual void requestDatabaseNames(ErrorString*, const String& securityOrigin, PassRefPtr<RequestDatabaseNamesCallback>);
virtual void requestDatabase(ErrorString*, const String& securityOrigin, const String& databaseName, PassRefPtr<RequestDatabaseCallback>);
- virtual void requestData(ErrorString*, const String& securityOrigin, const String& databaseName, const String& objectStoreName, const String& indexName, int skipCount, int pageSize, const RefPtr<InspectorObject>* keyRange, PassRefPtr<RequestDataCallback>);
+ virtual void requestData(ErrorString*, const String& securityOrigin, const String& databaseName, const String& objectStoreName, const String& indexName, int skipCount, int pageSize, const RefPtr<JSONObject>* keyRange, PassRefPtr<RequestDataCallback>);
virtual void clearObjectStore(ErrorString*, const String& in_securityOrigin, const String& in_databaseName, const String& in_objectStoreName, PassRefPtr<ClearObjectStoreCallback>);
private:
diff --git a/Source/core/inspector/InspectorInstrumentation.cpp b/Source/core/inspector/InspectorInstrumentation.cpp
index c70efe8..fc2937f 100644
--- a/Source/core/inspector/InspectorInstrumentation.cpp
+++ b/Source/core/inspector/InspectorInstrumentation.cpp
@@ -36,15 +36,13 @@
#include "core/inspector/InspectorConsoleAgent.h"
#include "core/inspector/InspectorController.h"
#include "core/inspector/InspectorDebuggerAgent.h"
-#include "core/inspector/InspectorPageAgent.h"
#include "core/inspector/InspectorProfilerAgent.h"
#include "core/inspector/InspectorResourceAgent.h"
#include "core/inspector/InspectorTimelineAgent.h"
-#include "core/inspector/InspectorWorkerAgent.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/inspector/WorkerInspectorController.h"
#include "core/loader/cache/CachedResourceInitiatorInfo.h"
-#include "core/workers/WorkerContext.h"
+#include "core/workers/WorkerGlobalScope.h"
namespace WebCore {
@@ -207,17 +205,17 @@
return instrumentingAgentsForFrame(renderer->frame());
}
-InstrumentingAgents* instrumentingAgentsForWorkerContext(WorkerContext* workerContext)
+InstrumentingAgents* instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope* workerGlobalScope)
{
- if (!workerContext)
+ if (!workerGlobalScope)
return 0;
- return instrumentationForWorkerContext(workerContext);
+ return instrumentationForWorkerGlobalScope(workerGlobalScope);
}
InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ScriptExecutionContext* context)
{
- if (context->isWorkerContext())
- return instrumentationForWorkerContext(static_cast<WorkerContext*>(context));
+ if (context->isWorkerGlobalScope())
+ return instrumentationForWorkerGlobalScope(toWorkerGlobalScope(context));
return 0;
}
@@ -252,9 +250,9 @@
return 0;
}
-InstrumentingAgents* instrumentationForWorkerContext(WorkerContext* workerContext)
+InstrumentingAgents* instrumentationForWorkerGlobalScope(WorkerGlobalScope* workerGlobalScope)
{
- if (WorkerInspectorController* controller = workerContext->workerInspectorController())
+ if (WorkerInspectorController* controller = workerGlobalScope->workerInspectorController())
return controller->m_instrumentingAgents.get();
return 0;
}
diff --git a/Source/core/inspector/InspectorInstrumentation.h b/Source/core/inspector/InspectorInstrumentation.h
index 6d05983..85421bf 100644
--- a/Source/core/inspector/InspectorInstrumentation.h
+++ b/Source/core/inspector/InspectorInstrumentation.h
@@ -31,17 +31,13 @@
#ifndef InspectorInstrumentation_h
#define InspectorInstrumentation_h
-#include "bindings/v8/ScriptState.h"
#include "bindings/v8/ScriptString.h"
-#include "core/css/CSSImportRule.h"
-#include "core/css/CSSRule.h"
#include "core/css/CSSSelector.h"
#include "core/css/CSSStyleSheet.h"
#include "core/dom/Element.h"
#include "core/dom/EventContext.h"
#include "core/dom/ScriptExecutionContext.h"
#include "core/inspector/ConsoleAPITypes.h"
-#include "core/page/ConsoleTypes.h"
#include "core/page/Frame.h"
#include "core/page/Page.h"
#include "core/platform/network/FormData.h"
@@ -51,8 +47,6 @@
#include "modules/websockets/WebSocketHandshakeRequest.h"
#include "modules/websockets/WebSocketHandshakeResponse.h"
#include "wtf/RefPtr.h"
-#include "wtf/UnusedParam.h"
-#include "wtf/Vector.h"
namespace WebCore {
@@ -95,8 +89,8 @@
class StyleRule;
class StyleSheet;
class ThreadableLoaderClient;
-class WorkerContext;
-class WorkerContextProxy;
+class WorkerGlobalScope;
+class WorkerGlobalScopeProxy;
class XMLHttpRequest;
#define FAST_RETURN_IF_NO_FRONTENDS(value) if (!hasFrontends()) return value;
@@ -144,7 +138,7 @@
InstrumentingAgents* instrumentingAgentsForRenderObject(RenderObject*);
InstrumentingAgents* instrumentingAgentsForElement(Element*);
-InstrumentingAgents* instrumentingAgentsForWorkerContext(WorkerContext*);
+InstrumentingAgents* instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope*);
InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ScriptExecutionContext*);
} // namespace InspectorInstrumentation
@@ -205,7 +199,7 @@
InstrumentingAgents* instrumentationForPage(Page*);
-InstrumentingAgents* instrumentationForWorkerContext(WorkerContext*);
+InstrumentingAgents* instrumentationForWorkerGlobalScope(WorkerGlobalScope*);
} // namespace WebCore
diff --git a/Source/core/inspector/InspectorInstrumentation.idl b/Source/core/inspector/InspectorInstrumentation.idl
index 1e8d82e..f90e47e 100644
--- a/Source/core/inspector/InspectorInstrumentation.idl
+++ b/Source/core/inspector/InspectorInstrumentation.idl
@@ -36,7 +36,7 @@
*
* The syntax for an instrumentation method is as follows:
*
-* [methodAttributes] returnValue methodName([paramAttributes] paramList)
+* [methodAttributes] returnValue methodName([paramAttr1] param1, [paramAttr2] param2, ...)
*
* Where:
* methodAttributes - optional list of method attributes.
@@ -48,8 +48,9 @@
* Attributes without "=" are the names of the agents to be invoked.
* Examples: DOM, Page, Debugger.
*
-* paramAttributes - options list of attributes controlling the parameters handling.
+* paramAttr - optional attribute controlling the parameters handling (one attribute per parameter max).
* Keep - pass first parameter (used to access the InstrumentingAgents instance) to agents.
+* FastReturn - return early from the inline method if this parameter is 0/false.
*
* returnValue: C++ return value. Only "void" and "InspectorInstrumentationCookie" are supported.
*
@@ -111,6 +112,9 @@
[CSS, Inline=FastReturn]
void didUpdateRegionLayout([Keep] Document*, NamedFlow*);
+ [CSS, Inline=FastReturn]
+ void didChangeRegionOverset([Keep] Document*, NamedFlow*);
+
[DOMDebugger, Inline=FastReturn]
void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
@@ -225,8 +229,8 @@
[CSS, Inline=FastReturn]
void didMatchRule(const InspectorInstrumentationCookie&, bool matched);
- [CSS, Inline=Custom]
- InspectorInstrumentationCookie willProcessRule(Document* document, StyleRule* rule, StyleResolver* styleResolver);
+ [CSS, Inline=FastReturn]
+ InspectorInstrumentationCookie willProcessRule(Document* document, [FastReturn] StyleRule* rule, StyleResolver* styleResolver);
[CSS, Inline=FastReturn]
void didProcessRule(const InspectorInstrumentationCookie&);
@@ -372,13 +376,13 @@
void didDispatchDOMStorageEvent(Page* page, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin);
[Worker]
- void didStartWorkerContext(ScriptExecutionContext*, WorkerContextProxy* proxy, const KURL& url);
+ void didStartWorkerGlobalScope(ScriptExecutionContext*, WorkerGlobalScopeProxy* proxy, const KURL& url);
[WorkerRuntime]
- void willEvaluateWorkerScript([Keep] WorkerContext* context, int workerThreadStartMode);
+ void willEvaluateWorkerScript([Keep] WorkerGlobalScope* context, int workerThreadStartMode);
[Worker]
- void workerContextTerminated(ScriptExecutionContext*, WorkerContextProxy* proxy);
+ void workerGlobalScopeTerminated(ScriptExecutionContext*, WorkerGlobalScopeProxy* proxy);
[Resource, Timeline]
void didCreateWebSocket([Keep] Document*, unsigned long identifier, const KURL& requestURL, const String& protocol);
@@ -430,14 +434,14 @@
void addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, ScriptState* state, PassRefPtr<ScriptArguments> arguments, unsigned long requestIdentifier = 0);
[Console]
- void addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, ScriptState* state = 0, unsigned long requestIdentifier = 0);
+ void addMessageToConsole(Page* page, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber = 0, ScriptState* state = 0, unsigned long requestIdentifier = 0);
// FIXME: Convert to ScriptArguments to match non-worker context.
// Use the same implementation as above as a similar method dispatched on Page.
- void addMessageToConsole(WorkerContext* workerContext, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier = 0);
+ void addMessageToConsole(WorkerGlobalScope* workerGlobalScope, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier = 0);
// Use the same implementation as above as a similar method dispatched on Page.
- void addMessageToConsole(WorkerContext* workerContext, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, ScriptState* state, unsigned long requestIdentifier = 0);
+ void addMessageToConsole(WorkerGlobalScope* workerGlobalScope, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber, ScriptState* state, unsigned long requestIdentifier = 0);
[Console]
void consoleCount(Page* page, ScriptState* state, PassRefPtr<ScriptArguments> arguments);
diff --git a/Source/core/inspector/InspectorInstrumentationCustomInl.h b/Source/core/inspector/InspectorInstrumentationCustomInl.h
index 8657666..4a181f6 100644
--- a/Source/core/inspector/InspectorInstrumentationCustomInl.h
+++ b/Source/core/inspector/InspectorInstrumentationCustomInl.h
@@ -37,7 +37,6 @@
bool profilerEnabledImpl(InstrumentingAgents*);
bool isDebuggerPausedImpl(InstrumentingAgents*);
-InspectorInstrumentationCookie willProcessRuleImpl(InstrumentingAgents*, StyleRule*, StyleResolver*);
bool collectingHTMLParseErrorsImpl(InstrumentingAgents*);
bool canvasAgentEnabled(ScriptExecutionContext*);
@@ -59,16 +58,6 @@
return false;
}
-inline InspectorInstrumentationCookie willProcessRule(Document* document, StyleRule* rule, StyleResolver* styleResolver)
-{
- FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
- if (!rule)
- return InspectorInstrumentationCookie();
- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
- return willProcessRuleImpl(instrumentingAgents, rule, styleResolver);
- return InspectorInstrumentationCookie();
-}
-
inline bool collectingHTMLParseErrors(Page* page)
{
FAST_RETURN_IF_NO_FRONTENDS(false);
diff --git a/Source/core/inspector/InspectorLayerTreeAgent.h b/Source/core/inspector/InspectorLayerTreeAgent.h
index cfb8765..f77c5cb 100644
--- a/Source/core/inspector/InspectorLayerTreeAgent.h
+++ b/Source/core/inspector/InspectorLayerTreeAgent.h
@@ -34,10 +34,9 @@
#include "InspectorTypeBuilder.h"
#include "core/inspector/InspectorBaseAgent.h"
#include "core/rendering/RenderLayer.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
diff --git a/Source/core/inspector/InspectorMemoryAgent.cpp b/Source/core/inspector/InspectorMemoryAgent.cpp
index 017c362..7c576db 100644
--- a/Source/core/inspector/InspectorMemoryAgent.cpp
+++ b/Source/core/inspector/InspectorMemoryAgent.cpp
@@ -40,22 +40,20 @@
#include "core/inspector/HeapGraphSerializer.h"
#include "core/inspector/InspectorClient.h"
#include "core/inspector/InspectorDOMStorageAgent.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/MemoryInstrumentationImpl.h"
#include "core/loader/cache/MemoryCache.h"
#include "core/page/Frame.h"
#include "core/page/Page.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/MemoryUsageSupport.h"
-#include <wtf/ArrayBufferView.h>
-#include <wtf/HashSet.h>
-#include <wtf/MemoryInstrumentationArrayBufferView.h>
-#include <wtf/NonCopyingSort.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/StringImpl.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/ArrayBufferView.h"
+#include "wtf/MemoryInstrumentationArrayBufferView.h"
+#include "wtf/NonCopyingSort.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/StringImpl.h"
+#include "wtf/text/WTFString.h"
// Use a type alias instead of 'using' here which would cause a conflict on Mac.
typedef WebCore::TypeBuilder::Memory::MemoryBlock InspectorMemoryBlock;
@@ -298,7 +296,7 @@
getProcessMemoryDistributionImpl(false, memoryInfo);
}
-void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, const bool* reportGraph, RefPtr<InspectorMemoryBlock>& processMemory, RefPtr<InspectorObject>& graphMetaInformation)
+void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, const bool* reportGraph, RefPtr<InspectorMemoryBlock>& processMemory, RefPtr<JSONObject>& graphMetaInformation)
{
TypeNameToSizeMap memoryInfo;
graphMetaInformation = getProcessMemoryDistributionImpl(reportGraph && *reportGraph, &memoryInfo);
@@ -339,9 +337,9 @@
}
-PassRefPtr<InspectorObject> InspectorMemoryAgent::getProcessMemoryDistributionImpl(bool reportGraph, TypeNameToSizeMap* memoryInfo)
+PassRefPtr<JSONObject> InspectorMemoryAgent::getProcessMemoryDistributionImpl(bool reportGraph, TypeNameToSizeMap* memoryInfo)
{
- RefPtr<InspectorObject> meta;
+ RefPtr<JSONObject> meta;
OwnPtr<HeapGraphSerializer> graphSerializer;
OwnPtr<FrontendWrapper> frontendWrapper;
diff --git a/Source/core/inspector/InspectorMemoryAgent.h b/Source/core/inspector/InspectorMemoryAgent.h
index 0f580c3..bc39faa 100644
--- a/Source/core/inspector/InspectorMemoryAgent.h
+++ b/Source/core/inspector/InspectorMemoryAgent.h
@@ -59,7 +59,7 @@
virtual ~InspectorMemoryAgent();
virtual void getDOMCounters(ErrorString*, int* documents, int* nodes, int* jsEventListeners);
- virtual void getProcessMemoryDistribution(ErrorString*, const bool* reportGraph, RefPtr<TypeBuilder::Memory::MemoryBlock>& out_processMemory, RefPtr<InspectorObject>& graphMetaInformation);
+ virtual void getProcessMemoryDistribution(ErrorString*, const bool* reportGraph, RefPtr<TypeBuilder::Memory::MemoryBlock>& out_processMemory, RefPtr<JSONObject>& graphMetaInformation);
virtual void reportMemoryUsage(MemoryObjectInfo*) const;
@@ -71,7 +71,7 @@
private:
InspectorMemoryAgent(InstrumentingAgents*, InspectorClient*, InspectorCompositeState*, Page*);
- PassRefPtr<InspectorObject> getProcessMemoryDistributionImpl(bool reportGraph, HashMap<String, size_t>* memoryInfo);
+ PassRefPtr<JSONObject> getProcessMemoryDistributionImpl(bool reportGraph, HashMap<String, size_t>* memoryInfo);
InspectorClient* m_inspectorClient;
Page* m_page;
diff --git a/Source/core/inspector/InspectorOverlay.cpp b/Source/core/inspector/InspectorOverlay.cpp
index 4a27580..5964d55 100644
--- a/Source/core/inspector/InspectorOverlay.cpp
+++ b/Source/core/inspector/InspectorOverlay.cpp
@@ -35,11 +35,9 @@
#include "bindings/v8/ScriptSourceCode.h"
#include "core/dom/Element.h"
#include "core/dom/Node.h"
-#include "core/dom/StyledElement.h"
#include "core/dom/WebCoreMemoryInstrumentation.h"
#include "core/inspector/InspectorClient.h"
#include "core/inspector/InspectorOverlayHost.h"
-#include "core/inspector/InspectorValues.h"
#include "core/loader/DocumentLoader.h"
#include "core/loader/EmptyClients.h"
#include "core/page/Chrome.h"
@@ -48,13 +46,13 @@
#include "core/page/FrameView.h"
#include "core/page/Page.h"
#include "core/page/Settings.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/PlatformMouseEvent.h"
-#include "core/platform/PlatformTouchEvent.h"
#include "core/platform/graphics/GraphicsContextStateSaver.h"
#include "core/rendering/RenderBoxModelObject.h"
#include "core/rendering/RenderInline.h"
#include "core/rendering/RenderObject.h"
-#include <wtf/text/StringBuilder.h>
+#include "wtf/text/StringBuilder.h"
namespace WebCore {
@@ -234,6 +232,8 @@
, m_drawViewSizeWithGrid(false)
, m_timer(this, &InspectorOverlay::onTimer)
, m_overlayHost(InspectorOverlayHost::create())
+ , m_overrides(0)
+ , m_overridesTopOffset(0)
{
}
@@ -262,12 +262,23 @@
return false;
EventHandler* eventHandler = overlayPage()->mainFrame()->eventHandler();
+ bool result;
switch (event.type()) {
- case PlatformEvent::MouseMoved: return eventHandler->mouseMoved(event);
- case PlatformEvent::MousePressed: return eventHandler->handleMousePressEvent(event);
- case PlatformEvent::MouseReleased: return eventHandler->handleMouseReleaseEvent(event);
- default: return false;
+ case PlatformEvent::MouseMoved:
+ result = eventHandler->mouseMoved(event);
+ break;
+ case PlatformEvent::MousePressed:
+ result = eventHandler->handleMousePressEvent(event);
+ break;
+ case PlatformEvent::MouseReleased:
+ result = eventHandler->handleMouseReleaseEvent(event);
+ break;
+ default:
+ return false;
}
+
+ overlayPage()->mainFrame()->document()->updateLayout();
+ return result;
}
bool InspectorOverlay::handleTouchEvent(const PlatformTouchEvent& event)
@@ -314,6 +325,25 @@
update();
}
+void InspectorOverlay::setOverride(OverrideType type, bool enabled)
+{
+ bool currentEnabled = m_overrides & type;
+ if (currentEnabled == enabled)
+ return;
+ if (enabled)
+ m_overrides |= type;
+ else
+ m_overrides &= ~type;
+ update();
+}
+
+void InspectorOverlay::setOverridesTopOffset(int offset)
+{
+ m_overridesTopOffset = offset;
+ if (m_overrides)
+ update();
+}
+
void InspectorOverlay::hideHighlight()
{
m_highlightNode.clear();
@@ -352,7 +382,7 @@
bool InspectorOverlay::isEmpty()
{
- bool hasAlwaysVisibleElements = m_highlightNode || m_eventTargetNode || m_highlightQuad || !m_size.isEmpty() || m_drawViewSize;
+ bool hasAlwaysVisibleElements = m_highlightNode || m_eventTargetNode || m_highlightQuad || m_overrides || !m_size.isEmpty() || m_drawViewSize;
bool hasInvisibleInInspectModeElements = !m_pausedInDebuggerMessage.isNull();
return !(hasAlwaysVisibleElements || (hasInvisibleInInspectModeElements && !m_inspectModeEnabled));
}
@@ -384,6 +414,7 @@
if (!m_inspectModeEnabled)
drawPausedInDebuggerMessage();
drawViewSize();
+ drawOverridesMessage();
// Position DOM elements.
overlayPage()->mainFrame()->document()->recalcStyle(Node::Force);
@@ -404,20 +435,22 @@
m_size = IntSize();
m_drawViewSize = false;
m_drawViewSizeWithGrid = false;
+ m_overrides = 0;
+ m_overridesTopOffset = 0;
update();
}
-static PassRefPtr<InspectorObject> buildObjectForPoint(const FloatPoint& point)
+static PassRefPtr<JSONObject> buildObjectForPoint(const FloatPoint& point)
{
- RefPtr<InspectorObject> object = InspectorObject::create();
+ RefPtr<JSONObject> object = JSONObject::create();
object->setNumber("x", point.x());
object->setNumber("y", point.y());
return object.release();
}
-static PassRefPtr<InspectorArray> buildArrayForQuad(const FloatQuad& quad)
+static PassRefPtr<JSONArray> buildArrayForQuad(const FloatQuad& quad)
{
- RefPtr<InspectorArray> array = InspectorArray::create();
+ RefPtr<JSONArray> array = JSONArray::create();
array->pushObject(buildObjectForPoint(quad.p1()));
array->pushObject(buildObjectForPoint(quad.p2()));
array->pushObject(buildObjectForPoint(quad.p3()));
@@ -425,10 +458,10 @@
return array.release();
}
-static PassRefPtr<InspectorObject> buildObjectForHighlight(const Highlight& highlight)
+static PassRefPtr<JSONObject> buildObjectForHighlight(const Highlight& highlight)
{
- RefPtr<InspectorObject> object = InspectorObject::create();
- RefPtr<InspectorArray> array = InspectorArray::create();
+ RefPtr<JSONObject> object = JSONObject::create();
+ RefPtr<JSONArray> array = JSONArray::create();
for (size_t i = 0; i < highlight.quads.size(); ++i)
array->pushArray(buildArrayForQuad(highlight.quads[i]));
object->setArray("quads", array.release());
@@ -442,9 +475,9 @@
return object.release();
}
-static PassRefPtr<InspectorObject> buildObjectForSize(const IntSize& size)
+static PassRefPtr<JSONObject> buildObjectForSize(const IntSize& size)
{
- RefPtr<InspectorObject> result = InspectorObject::create();
+ RefPtr<JSONObject> result = JSONObject::create();
result->setNumber("width", size.width());
result->setNumber("height", size.height());
return result.release();
@@ -467,11 +500,11 @@
buildNodeHighlight(m_eventTargetNode.get(), m_nodeHighlightConfig, &eventTargetHighlight);
highlight.quads.append(eventTargetHighlight.quads[1]); // Add border from eventTargetNode to highlight.
}
- RefPtr<InspectorObject> highlightObject = buildObjectForHighlight(highlight);
+ RefPtr<JSONObject> highlightObject = buildObjectForHighlight(highlight);
Node* node = m_highlightNode.get();
if (node->isElementNode() && m_nodeHighlightConfig.showInfo && node->renderer() && node->document()->frame()) {
- RefPtr<InspectorObject> elementInfo = InspectorObject::create();
+ RefPtr<JSONObject> elementInfo = JSONObject::create();
Element* element = toElement(node);
bool isXHTML = element->document()->isXHTMLDocument();
elementInfo->setString("tagName", isXHTML ? element->nodeName() : element->nodeName().lower());
@@ -479,7 +512,7 @@
HashSet<AtomicString> usedClassNames;
if (element->hasClass() && element->isStyledElement()) {
StringBuilder classNames;
- const SpaceSplitString& classNamesString = static_cast<StyledElement*>(element)->classNames();
+ const SpaceSplitString& classNamesString = element->classNames();
size_t classNameCount = classNamesString.size();
for (size_t i = 0; i < classNameCount; ++i) {
const AtomicString& className = classNamesString[i];
@@ -525,6 +558,14 @@
evaluateInOverlay("drawViewSize", m_drawViewSizeWithGrid ? "true" : "false");
}
+void InspectorOverlay::drawOverridesMessage()
+{
+ RefPtr<JSONObject> data = JSONObject::create();
+ data->setNumber("overrides", m_overrides);
+ data->setNumber("topOffset", m_overridesTopOffset);
+ evaluateInOverlay("drawOverridesMessage", data.release());
+}
+
Page* InspectorOverlay::overlayPage()
{
if (m_overlayPage)
@@ -562,11 +603,9 @@
frame->view()->setCanHaveScrollbars(false);
frame->view()->setTransparent(true);
ASSERT(loader->activeDocumentLoader());
- loader->activeDocumentLoader()->writer()->setMIMEType("text/html");
- loader->activeDocumentLoader()->writer()->begin();
- loader->activeDocumentLoader()->writer()->addData(reinterpret_cast<const char*>(InspectorOverlayPage_html), sizeof(InspectorOverlayPage_html));
- loader->activeDocumentLoader()->writer()->end();
-
+ DocumentWriter* writer = loader->activeDocumentLoader()->beginWriting("text/html", "UTF-8");
+ writer->addData(reinterpret_cast<const char*>(InspectorOverlayPage_html), sizeof(InspectorOverlayPage_html));
+ loader->activeDocumentLoader()->endWriting(writer);
v8::HandleScope handleScope;
v8::Handle<v8::Context> frameContext = frame->script()->currentWorldContext();
v8::Context::Scope contextScope(frameContext);
@@ -587,7 +626,7 @@
void InspectorOverlay::reset(const IntSize& viewportSize, const IntSize& frameViewFullSize, int scrollX, int scrollY)
{
- RefPtr<InspectorObject> resetData = InspectorObject::create();
+ RefPtr<JSONObject> resetData = JSONObject::create();
resetData->setNumber("pageScaleFactor", m_page->pageScaleFactor());
resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor());
resetData->setObject("viewportSize", buildObjectForSize(viewportSize));
@@ -600,15 +639,15 @@
void InspectorOverlay::evaluateInOverlay(const String& method, const String& argument)
{
- RefPtr<InspectorArray> command = InspectorArray::create();
+ RefPtr<JSONArray> command = JSONArray::create();
command->pushString(method);
command->pushString(argument);
overlayPage()->mainFrame()->script()->executeScriptInMainWorld(ScriptSourceCode("dispatch(" + command->toJSONString() + ")"));
}
-void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<InspectorValue> argument)
+void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<JSONValue> argument)
{
- RefPtr<InspectorArray> command = InspectorArray::create();
+ RefPtr<JSONArray> command = JSONArray::create();
command->pushString(method);
command->pushValue(argument);
overlayPage()->mainFrame()->script()->executeScriptInMainWorld(ScriptSourceCode("dispatch(" + command->toJSONString() + ")"));
diff --git a/Source/core/inspector/InspectorOverlay.h b/Source/core/inspector/InspectorOverlay.h
index d742dfd..574222e 100644
--- a/Source/core/inspector/InspectorOverlay.h
+++ b/Source/core/inspector/InspectorOverlay.h
@@ -47,8 +47,8 @@
class GraphicsContext;
class InspectorClient;
class InspectorOverlayHost;
-class InspectorValue;
class IntRect;
+class JSONValue;
class Node;
class Page;
class PlatformMouseEvent;
@@ -107,6 +107,15 @@
class InspectorOverlay {
WTF_MAKE_FAST_ALLOCATED;
public:
+ // This must be kept in sync with the overrideEntries array in InspectorOverlayPage.html.
+ enum OverrideType {
+ UserAgentOverride = 1,
+ DeviceMetricsOverride = 1 << 1,
+ GeolocationOverride = 1 << 2,
+ DeviceOrientationOverride = 1 << 3,
+ TouchOverride = 1 << 4,
+ CSSMediaOverride = 1 << 5
+ };
static PassOwnPtr<InspectorOverlay> create(Page* page, InspectorClient* client)
{
return adoptPtr(new InspectorOverlay(page, client));
@@ -124,6 +133,8 @@
void setPausedInDebuggerMessage(const String*);
void setInspectModeEnabled(bool);
+ void setOverride(OverrideType, bool);
+ void setOverridesTopOffset(int);
void hideHighlight();
void highlightNode(Node*, Node* eventTarget, const HighlightConfig&);
@@ -150,11 +161,12 @@
void drawQuadHighlight();
void drawPausedInDebuggerMessage();
void drawViewSize();
+ void drawOverridesMessage();
Page* overlayPage();
void reset(const IntSize& viewportSize, const IntSize& frameViewFullSize, int scrollX, int scrollY);
void evaluateInOverlay(const String& method, const String& argument);
- void evaluateInOverlay(const String& method, PassRefPtr<InspectorValue> argument);
+ void evaluateInOverlay(const String& method, PassRefPtr<JSONValue> argument);
void onTimer(Timer<InspectorOverlay>*);
Page* m_page;
@@ -173,6 +185,8 @@
bool m_drawViewSize;
bool m_drawViewSizeWithGrid;
Timer<InspectorOverlay> m_timer;
+ unsigned m_overrides;
+ int m_overridesTopOffset;
};
} // namespace WebCore
diff --git a/Source/core/inspector/InspectorOverlayHost.cpp b/Source/core/inspector/InspectorOverlayHost.cpp
index e28cf6f..830dd54 100644
--- a/Source/core/inspector/InspectorOverlayHost.cpp
+++ b/Source/core/inspector/InspectorOverlayHost.cpp
@@ -30,8 +30,6 @@
#include "InspectorOverlayHost.h"
-#include "InspectorController.h"
-
namespace WebCore {
InspectorOverlayHost::InspectorOverlayHost()
diff --git a/Source/core/inspector/InspectorOverlayPage.html b/Source/core/inspector/InspectorOverlayPage.html
index 14ce216..4d6f021 100644
--- a/Source/core/inspector/InspectorOverlayPage.html
+++ b/Source/core/inspector/InspectorOverlayPage.html
@@ -34,6 +34,10 @@
padding: 0;
}
+body.touch {
+ cursor: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAQAAAADHm0dAAABH0lEQVR4XpWTO2rDQBCG18S6gAWCoD6VFHKCCBZsN7qACgenFZn/OAZDrConMahJzmGM+oBJMfmziIUs8UMOXzHD7seyzMMwJOEDZ7r4ftEFZy5PwtvfNKIliE/Z4hVbFwmHZfRXTfWZWOEOI5iekctXINx5GqopZSdTmCOm2AmFt15lpMu9TGBOMsFe9InjXmVBzGHOMgfBR6cyJtYwF1mDYGyYEdmAmoNgZmgPcjOgjvEltEarFmaQd2hltN5cob5B6ytf/YBW//krMyIfUO99BWKiGVCbvq6+W+UFsfTd8jPQSXJGTND1MxBMViflyRe7YLK8rEuiQQ5fDRfz/o/uPD3egoIgDtJig9ZFwlGEWxASM6PVSmutaF0eh7c/zBRVQt5j3yoAAAAASUVORK5CYII=) 10 10, auto !important;
+}
+
body.platform-mac {
font-size: 11px;
font-family: Menlo, Monaco;
@@ -163,6 +167,30 @@
background-color: darkgray;
}
+#overrides-container {
+ display: inline-block;
+ padding: 0 0 10px 10px;
+ position: absolute;
+ top: 0;
+ right: 0;
+}
+
+#overrides-message > div:not(:first-child) {
+ text-indent: 8px;
+}
+
+#overrides-message {
+ display: inline-block;
+ font-size: 14px;
+ padding: 4px 6px;
+ color: red;
+ background-color: rgba(17, 17, 17, 0.843); /* Same as DebugColors::HUDBackgroundColor() */
+}
+
+#overrides-container:hover #overrides-message,
+#overrides-container.hidden #overrides-message {
+ visibility: hidden;
+}
</style>
<script>
const lightGridColor = "rgba(0,0,0,0.2)";
@@ -170,6 +198,13 @@
const transparentColor = "rgba(0, 0, 0, 0)";
const gridBackgroundColor = "rgba(255, 255, 255, 0.8)";
+// The order must correspond to that in InspectorOverlay::OverrideType.
+const overrideEntries = ["User-Agent", "Device Metrics", "Geolocation", "Device Orientation", "Touch", "Media"];
+const overrideTouchBit = 1 << 4;
+
+var overridesContainer;
+var overridesMessageElement;
+
function drawPausedInDebuggerMessage(message)
{
document.querySelector(".controls-line").style.visibility = "visible";
@@ -410,6 +445,39 @@
_drawGrid();
}
+function drawOverridesMessage(data)
+{
+ overridesContainer.style.top = data.topOffset + "px";
+ var overrides = data.overrides;
+ overridesMessageElement.textContent = "";
+ if (!overrides) {
+ overridesContainer.classList.add("hidden");
+ document.body.classList.remove("touch");
+ return;
+ }
+
+ var header = document.createElement("div");
+ header.id = "overrides-header";
+ header.textContent = "Overrides:";
+ overridesMessageElement.appendChild(header);
+
+ var maskBit = 1;
+ for (var i = 0; i < overrideEntries.length; ++i, maskBit <<= 1) {
+ if (!(overrides & maskBit))
+ continue;
+ var item = document.createElement("div");
+ item.textContent = overrideEntries[i];
+ overridesMessageElement.appendChild(item);
+ }
+
+ overridesContainer.classList.remove("hidden");
+ var hasTouch = overrides & overrideTouchBit;
+ if (hasTouch)
+ document.body.classList.add("touch");
+ else
+ document.body.classList.remove("touch");
+}
+
function reset(resetData)
{
window.viewportSize = resetData.viewportSize;
@@ -689,10 +757,31 @@
InspectorOverlayHost.stepOver();
}
+function onMouseMotion(isOverElement)
+{
+ if (!overridesMessageElement.textContent.length)
+ return;
+ if (isOverElement)
+ overridesContainer.classList.add("hidden");
+ else
+ overridesContainer.classList.remove("hidden");
+}
+
+function onFocus()
+{
+ if (overridesMessageElement.textContent.length)
+ overridesContainer.classList.remove("hidden");
+}
+
function onLoaded()
{
+ overridesContainer = document.getElementById("overrides-container");
+ overridesMessageElement = document.getElementById("overrides-message");
document.getElementById("resume-button").addEventListener("click", onResumeClick);
document.getElementById("step-over-button").addEventListener("click", onStepOverClick);
+ overridesContainer.addEventListener("mousemove", onMouseMotion.bind(this, true));
+ overridesContainer.addEventListener("mouseout", onMouseMotion.bind(this, false));
+ window.addEventListener("focus", onFocus);
}
window.addEventListener("DOMContentLoaded", onLoaded);
@@ -713,5 +802,8 @@
</div>
<div id="right-gutter"></div>
<div id="bottom-gutter"></div>
+<div id="overrides-container">
+ <div id="overrides-message"></div>
+</div>
<div id="log"></div>
</html>
diff --git a/Source/core/inspector/InspectorPageAgent.cpp b/Source/core/inspector/InspectorPageAgent.cpp
index 41bfe99..7c33d1b 100644
--- a/Source/core/inspector/InspectorPageAgent.cpp
+++ b/Source/core/inspector/InspectorPageAgent.cpp
@@ -35,7 +35,6 @@
#include "InspectorFrontend.h"
#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/ScriptController.h"
-#include "bindings/v8/ScriptObject.h"
#include "core/dom/DOMImplementation.h"
#include "core/dom/DeviceOrientationController.h"
#include "core/dom/Document.h"
@@ -49,7 +48,6 @@
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/InspectorOverlay.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/loader/CookieJar.h"
#include "core/loader/DocumentLoader.h"
@@ -68,15 +66,14 @@
#include "core/page/PageConsole.h"
#include "core/page/Settings.h"
#include "core/platform/Cookie.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/text/RegularExpression.h"
#include "modules/geolocation/GeolocationController.h"
-#include "modules/geolocation/GeolocationError.h"
#include "weborigin/SecurityOrigin.h"
#include "wtf/CurrentTime.h"
#include "wtf/ListHashSet.h"
#include "wtf/Vector.h"
#include "wtf/text/Base64.h"
-#include "wtf/text/StringBuilder.h"
#include "wtf/text/TextEncoding.h"
using namespace std;
@@ -95,6 +92,7 @@
static const char pageAgentContinuousPaintingEnabled[] = "pageAgentContinuousPaintingEnabled";
static const char pageAgentShowPaintRects[] = "pageAgentShowPaintRects";
static const char pageAgentShowDebugBorders[] = "pageAgentShowDebugBorders";
+static const char pageAgentShowScrollBottleneckRects[] = "pageAgentShowScrollBottleneckRects";
static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled";
static const char pageAgentEmulatedMedia[] = "pageAgentEmulatedMedia";
static const char showSizeOnResize[] = "showSizeOnResize";
@@ -363,6 +361,8 @@
setEmulatedMedia(0, emulatedMedia);
bool continuousPaintingEnabled = m_state->getBoolean(PageAgentState::pageAgentContinuousPaintingEnabled);
setContinuousPaintingEnabled(0, continuousPaintingEnabled);
+ bool showScrollBottleneckRects = m_state->getBoolean(PageAgentState::pageAgentShowScrollBottleneckRects);
+ setShowScrollBottleneckRects(0, showScrollBottleneckRects);
int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScreenWidthOverride));
int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScreenHeightOverride));
@@ -399,6 +399,7 @@
setShowFPSCounter(0, false);
setEmulatedMedia(0, "");
setContinuousPaintingEnabled(0, false);
+ setShowScrollBottleneckRects(0, false);
setShowViewportSizeOnResize(0, false, 0);
if (m_didForceCompositingMode)
setForceCompositingMode(0, false);
@@ -416,9 +417,9 @@
void InspectorPageAgent::addScriptToEvaluateOnLoad(ErrorString*, const String& source, String* identifier)
{
- RefPtr<InspectorObject> scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
+ RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
if (!scripts) {
- scripts = InspectorObject::create();
+ scripts = JSONObject::create();
m_state->setObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad, scripts);
}
// Assure we don't override existing ids -- m_lastScriptIdentifier could get out of sync WRT actual
@@ -434,7 +435,7 @@
void InspectorPageAgent::removeScriptToEvaluateOnLoad(ErrorString* error, const String& identifier)
{
- RefPtr<InspectorObject> scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
+ RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
if (!scripts || scripts->find(identifier) == scripts->end()) {
*error = "Script not found";
return;
@@ -711,8 +712,6 @@
{
m_state->setBoolean(PageAgentState::pageAgentShowDebugBorders, show);
m_client->setShowDebugBorders(show);
- if (mainFrame() && mainFrame()->view())
- mainFrame()->view()->invalidate();
}
void InspectorPageAgent::setShowFPSCounter(ErrorString*, bool show)
@@ -720,8 +719,7 @@
m_state->setBoolean(PageAgentState::pageAgentShowFPSCounter, show);
m_client->setShowFPSCounter(show);
- if (mainFrame() && mainFrame()->view())
- mainFrame()->view()->invalidate();
+ updateOverridesTopOffset();
}
void InspectorPageAgent::setContinuousPaintingEnabled(ErrorString*, bool enabled)
@@ -729,8 +727,13 @@
m_state->setBoolean(PageAgentState::pageAgentContinuousPaintingEnabled, enabled);
m_client->setContinuousPaintingEnabled(enabled);
- if (!enabled && mainFrame() && mainFrame()->view())
- mainFrame()->view()->invalidate();
+ updateOverridesTopOffset();
+}
+
+void InspectorPageAgent::setShowScrollBottleneckRects(ErrorString*, bool show)
+{
+ m_state->setBoolean(PageAgentState::pageAgentShowScrollBottleneckRects, show);
+ m_client->setShowScrollBottleneckRects(show);
}
void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandler::Result::Enum* status)
@@ -780,10 +783,10 @@
if (!m_frontend)
return;
- RefPtr<InspectorObject> scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
+ RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
if (scripts) {
- InspectorObject::const_iterator end = scripts->end();
- for (InspectorObject::const_iterator it = scripts->begin(); it != end; ++it) {
+ JSONObject::const_iterator end = scripts->end();
+ for (JSONObject::const_iterator it = scripts->begin(); it != end; ++it) {
String scriptText;
if (it->value->asString(&scriptText))
frame->script()->executeScript(scriptText);
@@ -804,8 +807,10 @@
setForceCompositingMode(0, true);
}
-void InspectorPageAgent::loadEventFired(Frame*)
+void InspectorPageAgent::loadEventFired(Frame* frame)
{
+ if (frame->page()->mainFrame() != frame)
+ return;
m_frontend->loadEventFired(currentTime());
}
@@ -902,7 +907,7 @@
return String();
String deprecatedHeaderSourceMapURL = resource->response().httpHeaderField(deprecatedSourceMapHttpHeader);
if (!deprecatedHeaderSourceMapURL.isEmpty()) {
- m_page->console()->addMessage(NetworkMessageSource, WarningMessageLevel, "Resource is served with deprecated header X-SourceMap, SourceMap should be used instead.", url, 0);
+ // FIXME: add deprecated console message here.
return deprecatedHeaderSourceMapURL;
}
return resource->response().httpHeaderField(sourceMapHttpHeader);
@@ -1107,6 +1112,7 @@
if (document)
document->styleResolverChanged(RecalcStyleImmediately);
InspectorInstrumentation::mediaQueryResultChanged(document);
+ m_overlay->setOverride(InspectorOverlay::DeviceMetricsOverride, width && height);
}
void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled)
@@ -1114,6 +1120,19 @@
m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled);
if (mainFrame() && mainFrame()->settings())
mainFrame()->settings()->setTouchEventEmulationEnabled(enabled);
+ m_overlay->setOverride(InspectorOverlay::TouchOverride, enabled);
+}
+
+void InspectorPageAgent::updateOverridesTopOffset()
+{
+ static const int continousPaintingGraphHeight = 92;
+ static const int fpsGraphHeight = 73;
+ int topOffset = 0;
+ if (m_state->getBoolean(PageAgentState::pageAgentContinuousPaintingEnabled))
+ topOffset = continousPaintingGraphHeight;
+ else if (m_state->getBoolean(PageAgentState::pageAgentShowFPSCounter))
+ topOffset = fpsGraphHeight;
+ m_overlay->setOverridesTopOffset(topOffset);
}
void InspectorPageAgent::setGeolocationOverride(ErrorString* error, const double* latitude, const double* longitude, const double* accuracy)
@@ -1135,6 +1154,7 @@
m_geolocationPosition.clear();
controller->positionChanged(0); // Kick location update.
+ m_overlay->setOverride(InspectorOverlay::GeolocationOverride, true);
}
void InspectorPageAgent::clearGeolocationOverride(ErrorString*)
@@ -1147,6 +1167,7 @@
GeolocationController* controller = GeolocationController::from(m_page);
if (controller && m_platformGeolocationPosition.get())
controller->positionChanged(m_platformGeolocationPosition.get());
+ m_overlay->setOverride(InspectorOverlay::GeolocationOverride, false);
}
GeolocationPosition* InspectorPageAgent::overrideGeolocationPosition(GeolocationPosition* position)
@@ -1172,11 +1193,13 @@
m_deviceOrientation = DeviceOrientationData::create(true, alpha, true, beta, true, gamma);
controller->didChangeDeviceOrientation(m_deviceOrientation.get());
+ m_overlay->setOverride(InspectorOverlay::DeviceOrientationOverride, true);
}
void InspectorPageAgent::clearDeviceOrientationOverride(ErrorString*)
{
m_deviceOrientation.clear();
+ m_overlay->setOverride(InspectorOverlay::DeviceOrientationOverride, false);
}
DeviceOrientationData* InspectorPageAgent::overrideDeviceOrientation(DeviceOrientationData* deviceOrientation)
@@ -1207,6 +1230,7 @@
document->styleResolverChanged(RecalcStyleImmediately);
document->updateLayout();
}
+ m_overlay->setOverride(InspectorOverlay::CSSMediaOverride, !media.isEmpty());
}
void InspectorPageAgent::applyEmulatedMedia(String* media)
@@ -1235,20 +1259,6 @@
mainFrame->view()->updateCompositingLayersAfterStyleChange();
}
-void InspectorPageAgent::getCompositingBordersVisible(ErrorString* error, bool* outParam)
-{
- Settings* settings = m_page->settings();
- *outParam = settings->showDebugBorders() || settings->showRepaintCounter();
-}
-
-void InspectorPageAgent::setCompositingBordersVisible(ErrorString*, bool visible)
-{
- Settings* settings = m_page->settings();
-
- settings->setShowDebugBorders(visible);
- settings->setShowRepaintCounter(visible);
-}
-
void InspectorPageAgent::captureScreenshot(ErrorString*, String*)
{
// Handled on the browser level.
diff --git a/Source/core/inspector/InspectorPageAgent.h b/Source/core/inspector/InspectorPageAgent.h
index af638d1..f73f6f9 100644
--- a/Source/core/inspector/InspectorPageAgent.h
+++ b/Source/core/inspector/InspectorPageAgent.h
@@ -36,10 +36,8 @@
#include "core/dom/DeviceOrientationData.h"
#include "core/inspector/InspectorBaseAgent.h"
#include "modules/geolocation/GeolocationPosition.h"
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/HashMap.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -106,6 +104,7 @@
virtual void setShowDebugBorders(ErrorString*, bool show);
virtual void setShowFPSCounter(ErrorString*, bool show);
virtual void setContinuousPaintingEnabled(ErrorString*, bool enabled);
+ virtual void setShowScrollBottleneckRects(ErrorString*, bool show);
virtual void getScriptExecutionStatus(ErrorString*, PageCommandHandler::Result::Enum*);
virtual void setScriptExecutionDisabled(ErrorString*, bool);
virtual void setGeolocationOverride(ErrorString*, const double*, const double*, const double*);
@@ -115,8 +114,6 @@
virtual void setTouchEmulationEnabled(ErrorString*, bool);
virtual void setEmulatedMedia(ErrorString*, const String&);
virtual void setForceCompositingMode(ErrorString*, bool force);
- virtual void getCompositingBordersVisible(ErrorString*, bool* out_param);
- virtual void setCompositingBordersVisible(ErrorString*, bool);
virtual void captureScreenshot(ErrorString*, String* data);
virtual void handleJavaScriptDialog(ErrorString*, bool accept, const String* promptText);
virtual void setShowViewportSizeOnResize(ErrorString*, bool show, const bool* showGrid);
@@ -178,6 +175,7 @@
bool deviceMetricsChanged(int width, int height, double fontScaleFactor, bool fitWindow);
void updateViewMetrics(int, int, double, bool);
void updateTouchEventEmulationInPage(bool);
+ void updateOverridesTopOffset();
static bool dataContent(const char* data, unsigned size, const String& textEncodingName, bool withBase64Encode, String* result);
diff --git a/Source/core/inspector/InspectorProfilerAgent.cpp b/Source/core/inspector/InspectorProfilerAgent.cpp
index d84ef17..dc2f7e6 100644
--- a/Source/core/inspector/InspectorProfilerAgent.cpp
+++ b/Source/core/inspector/InspectorProfilerAgent.cpp
@@ -31,26 +31,19 @@
#include "core/inspector/InspectorProfilerAgent.h"
#include "InspectorFrontend.h"
-#include "bindings/v8/PageScriptDebugServer.h"
-#include "bindings/v8/ScriptObject.h"
#include "bindings/v8/ScriptProfiler.h"
-#include "bindings/v8/WorkerScriptDebugServer.h"
#include "core/dom/WebCoreMemoryInstrumentation.h"
#include "core/inspector/ConsoleAPITypes.h"
#include "core/inspector/InjectedScript.h"
#include "core/inspector/InjectedScriptHost.h"
#include "core/inspector/InspectorConsoleAgent.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/inspector/ScriptCallStack.h"
#include "core/inspector/ScriptProfile.h"
-#include "core/page/Console.h"
#include "core/page/ConsoleTypes.h"
-#include "core/page/Page.h"
#include "wtf/CurrentTime.h"
#include "wtf/MemoryInstrumentationHashMap.h"
-#include "wtf/OwnPtr.h"
#include "wtf/text/StringConcatenate.h"
namespace WebCore {
diff --git a/Source/core/inspector/InspectorProfilerAgent.h b/Source/core/inspector/InspectorProfilerAgent.h
index 98f48ba..d30be1e 100644
--- a/Source/core/inspector/InspectorProfilerAgent.h
+++ b/Source/core/inspector/InspectorProfilerAgent.h
@@ -42,16 +42,14 @@
namespace WebCore {
class InjectedScriptManager;
-class InspectorArray;
class InspectorConsoleAgent;
class InspectorFrontend;
-class InspectorObject;
class InspectorState;
class InstrumentingAgents;
class Page;
class ScriptCallStack;
class ScriptProfile;
-class WorkerContext;
+class WorkerGlobalScope;
typedef String ErrorString;
diff --git a/Source/core/inspector/InspectorResourceAgent.cpp b/Source/core/inspector/InspectorResourceAgent.cpp
index c9ea29e..9b15d6e 100644
--- a/Source/core/inspector/InspectorResourceAgent.cpp
+++ b/Source/core/inspector/InspectorResourceAgent.cpp
@@ -34,30 +34,28 @@
#include "InspectorFrontend.h"
#include "bindings/v8/ScriptCallStackFactory.h"
#include "core/dom/Document.h"
-#include "core/dom/Event.h"
-#include "core/dom/EventListener.h"
-#include "core/dom/EventTarget.h"
-#include "core/dom/ExceptionCode.h"
#include "core/dom/ExceptionCodePlaceholder.h"
#include "core/dom/ScriptableDocumentParser.h"
#include "core/inspector/IdentifiersFactory.h"
#include "core/inspector/InspectorClient.h"
+#include "core/inspector/InspectorOverlay.h"
#include "core/inspector/InspectorPageAgent.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/inspector/NetworkResourcesData.h"
#include "core/inspector/ScriptCallStack.h"
#include "core/loader/DocumentLoader.h"
+#include "core/loader/DocumentThreadableLoader.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/ResourceLoader.h"
-#include "core/loader/UniqueIdentifier.h"
-#include "core/loader/cache/CachedRawResource.h"
+#include "core/loader/ThreadableLoader.h"
+#include "core/loader/ThreadableLoaderClient.h"
#include "core/loader/cache/CachedResource.h"
#include "core/loader/cache/CachedResourceInitiatorInfo.h"
#include "core/loader/cache/MemoryCache.h"
#include "core/page/Frame.h"
#include "core/page/Page.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/network/HTTPHeaderMap.h"
#include "core/platform/network/ResourceError.h"
#include "core/platform/network/ResourceRequest.h"
@@ -68,11 +66,8 @@
#include "modules/websockets/WebSocketHandshakeResponse.h"
#include "weborigin/KURL.h"
#include "wtf/CurrentTime.h"
-#include "wtf/HexNumber.h"
-#include "wtf/ListHashSet.h"
#include "wtf/MemoryInstrumentationHashMap.h"
#include "wtf/RefPtr.h"
-#include "wtf/text/StringBuilder.h"
typedef WebCore::InspectorBackendDispatcher::NetworkCommandHandler::LoadResourceForFrontendCallback LoadResourceForFrontendCallback;
@@ -87,47 +82,92 @@
namespace {
-class SendXHRCallback : public EventListener {
- WTF_MAKE_NONCOPYABLE(SendXHRCallback);
+static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers)
+{
+ RefPtr<JSONObject> headersObject = JSONObject::create();
+ HTTPHeaderMap::const_iterator end = headers.end();
+ for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it)
+ headersObject->setString(it->key.string(), it->value);
+ return headersObject;
+}
+
+class InspectorThreadableLoaderClient : public ThreadableLoaderClient {
+ WTF_MAKE_NONCOPYABLE(InspectorThreadableLoaderClient);
public:
- static PassRefPtr<SendXHRCallback> create(PassRefPtr<LoadResourceForFrontendCallback> callback)
+ InspectorThreadableLoaderClient(PassRefPtr<LoadResourceForFrontendCallback> callback)
+ : m_callback(callback)
+ , m_statusCode(0) { }
+
+ virtual ~InspectorThreadableLoaderClient() { }
+
+ virtual void didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
{
- return adoptRef(new SendXHRCallback(callback));
+ WTF::TextEncoding textEncoding(response.textEncodingName());
+ bool useDetector = false;
+ if (!textEncoding.isValid()) {
+ textEncoding = UTF8Encoding();
+ useDetector = true;
+ }
+ m_decoder = TextResourceDecoder::create("text/plain", textEncoding, useDetector);
+ m_statusCode = response.httpStatusCode();
+ m_responseHeaders = response.httpHeaderFields();
}
- virtual ~SendXHRCallback() { }
-
- virtual bool operator==(const EventListener& other) OVERRIDE
+ virtual void didReceiveData(const char* data, int dataLength)
{
- return this == &other;
+ if (!dataLength)
+ return;
+
+ if (dataLength == -1)
+ dataLength = strlen(data);
+
+ m_responseText = m_responseText.concatenateWith(m_decoder->decode(data, dataLength));
}
- virtual void handleEvent(ScriptExecutionContext*, Event* event) OVERRIDE
+ virtual void didFinishLoading(unsigned long /*identifier*/, double /*finishTime*/)
{
- if (!m_callback->isActive())
- return;
- if (event->type() == eventNames().errorEvent) {
- m_callback->sendFailure("Error loading resource.");
- return;
- }
- if (event->type() != eventNames().readystatechangeEvent) {
- m_callback->sendFailure("Unexpected event type.");
- return;
- }
+ if (m_decoder)
+ m_responseText = m_responseText.concatenateWith(m_decoder->flush());
+ m_callback->sendSuccess(m_statusCode, buildObjectForHeaders(m_responseHeaders), m_responseText.flattenToString());
+ dispose();
+ }
- XMLHttpRequest* xhr = static_cast<XMLHttpRequest*>(event->target());
- if (xhr->readyState() != XMLHttpRequest::DONE)
- return;
+ virtual void didFail(const ResourceError&)
+ {
+ m_callback->sendFailure("Loading resource for inspector failed");
+ dispose();
+ }
- ScriptString responseText = xhr->responseText(IGNORE_EXCEPTION);
- m_callback->sendSuccess(responseText.flattenToString());
+ virtual void didFailRedirectCheck()
+ {
+ m_callback->sendFailure("Loading resource for inspector failed redirect check");
+ dispose();
+ }
+
+ void didFailLoaderCreation()
+ {
+ m_callback->sendFailure("Couldn't create a loader");
+ dispose();
+ }
+
+ void setLoader(PassRefPtr<ThreadableLoader> loader)
+ {
+ m_loader = loader;
}
private:
- SendXHRCallback(PassRefPtr<LoadResourceForFrontendCallback> callback)
- : EventListener(EventListener::CPPEventListenerType)
- , m_callback(callback) { }
+ void dispose()
+ {
+ m_loader = 0;
+ delete this;
+ }
+
RefPtr<LoadResourceForFrontendCallback> m_callback;
+ RefPtr<ThreadableLoader> m_loader;
+ RefPtr<TextResourceDecoder> m_decoder;
+ ScriptString m_responseText;
+ int m_statusCode;
+ HTTPHeaderMap m_responseHeaders;
};
KURL urlWithoutFragment(const KURL& url)
@@ -157,15 +197,6 @@
enable();
}
-static PassRefPtr<InspectorObject> buildObjectForHeaders(const HTTPHeaderMap& headers)
-{
- RefPtr<InspectorObject> headersObject = InspectorObject::create();
- HTTPHeaderMap::const_iterator end = headers.end();
- for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it)
- headersObject->setString(it->key.string(), it->value);
- return headersObject;
-}
-
static PassRefPtr<TypeBuilder::Network::ResourceTiming> buildObjectForTiming(const ResourceLoadTiming& timing, DocumentLoader* loader)
{
return TypeBuilder::Network::ResourceTiming::create()
@@ -210,7 +241,7 @@
status = response.httpStatusCode();
statusText = response.httpStatusText();
}
- RefPtr<InspectorObject> headers;
+ RefPtr<JSONObject> headers;
if (response.resourceLoadInfo())
headers = buildObjectForHeaders(response.resourceLoadInfo()->responseHeaders);
else
@@ -267,11 +298,11 @@
String requestId = IdentifiersFactory::requestId(identifier);
m_resourcesData->resourceCreated(requestId, m_pageAgent->loaderId(loader));
- RefPtr<InspectorObject> headers = m_state->getObject(ResourceAgentState::extraRequestHeaders);
+ RefPtr<JSONObject> headers = m_state->getObject(ResourceAgentState::extraRequestHeaders);
if (headers) {
- InspectorObject::const_iterator end = headers->end();
- for (InspectorObject::const_iterator it = headers->begin(); it != end; ++it) {
+ JSONObject::const_iterator end = headers->end();
+ for (JSONObject::const_iterator it = headers->begin(); it != end; ++it) {
String value;
if (it->value->asString(&value))
request.setHTTPHeaderField(it->key, value);
@@ -362,31 +393,15 @@
finishTime = loader->timing()->monotonicTimeToPseudoWallTime(monotonicFinishTime);
String requestId = IdentifiersFactory::requestId(identifier);
- if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::DocumentResource) {
- RefPtr<SharedBuffer> buffer = loader->frameLoader()->documentLoader()->mainResourceData();
- m_resourcesData->addResourceSharedBuffer(requestId, buffer, loader->frame()->document()->inputEncoding());
- }
-
m_resourcesData->maybeDecodeDataToContent(requestId);
-
if (!finishTime)
finishTime = currentTime();
-
m_frontend->loadingFinished(requestId, finishTime);
}
void InspectorResourceAgent::didFailLoading(unsigned long identifier, DocumentLoader* loader, const ResourceError& error)
{
String requestId = IdentifiersFactory::requestId(identifier);
-
- if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::DocumentResource) {
- Frame* frame = loader ? loader->frame() : 0;
- if (frame && frame->loader()->documentLoader() && frame->document()) {
- RefPtr<SharedBuffer> buffer = frame->loader()->documentLoader()->mainResourceData();
- m_resourcesData->addResourceSharedBuffer(requestId, buffer, frame->document()->inputEncoding());
- }
- }
-
bool canceled = error.isCancellation();
m_frontend->loadingFailed(requestId, currentTime(), error.localizedDescription(), canceled ? &canceled : 0);
}
@@ -600,9 +615,10 @@
void InspectorResourceAgent::setUserAgentOverride(ErrorString*, const String& userAgent)
{
m_state->setString(ResourceAgentState::userAgentOverride, userAgent);
+ m_overlay->setOverride(InspectorOverlay::UserAgentOverride, !userAgent.isEmpty());
}
-void InspectorResourceAgent::setExtraHTTPHeaders(ErrorString*, const RefPtr<InspectorObject>& headers)
+void InspectorResourceAgent::setExtraHTTPHeaders(ErrorString*, const RefPtr<JSONObject>& headers)
{
m_state->setObject(ResourceAgentState::extraRequestHeaders, headers);
}
@@ -687,7 +703,7 @@
memoryCache()->evictResources();
}
-void InspectorResourceAgent::loadResourceForFrontend(ErrorString* errorString, const String& frameId, const String& url, PassRefPtr<LoadResourceForFrontendCallback> callback)
+void InspectorResourceAgent::loadResourceForFrontend(ErrorString* errorString, const String& frameId, const String& url, const RefPtr<JSONObject>* requestHeaders, PassRefPtr<LoadResourceForFrontendCallback> callback)
{
Frame* frame = m_pageAgent->assertFrame(errorString, frameId);
if (!frame)
@@ -699,30 +715,39 @@
return;
}
- RefPtr<XMLHttpRequest> xhr = XMLHttpRequest::create(document);
-
KURL kurl = KURL(ParsedURLString, url);
if (kurl.isLocalFile()) {
*errorString = "Can not load local file";
return;
}
- ExceptionCode ec = 0;
- xhr->open(ASCIILiteral("GET"), kurl, ec);
- if (ec) {
- *errorString = "Error opening an XMLHttpRequest";
- return;
+ ResourceRequest request(url);
+ request.setHTTPMethod("GET");
+ request.setCachePolicy(ReloadIgnoringCacheData);
+ if (requestHeaders) {
+ for (JSONObject::iterator it = (*requestHeaders)->begin(); it != (*requestHeaders)->end(); ++it) {
+ String value;
+ bool success = it->value->asString(&value);
+ if (!success) {
+ *errorString = "Request header \"" + it->key + "\" value is not a string";
+ return;
+ }
+ request.addHTTPHeaderField(it->key, value);
+ }
}
- RefPtr<SendXHRCallback> sendXHRCallback = SendXHRCallback::create(callback);
- xhr->addEventListener(eventNames().abortEvent, sendXHRCallback, false);
- xhr->addEventListener(eventNames().errorEvent, sendXHRCallback, false);
- xhr->addEventListener(eventNames().readystatechangeEvent, sendXHRCallback, false);
- xhr->sendForInspector(ec);
- if (ec) {
- *errorString = "Error sending an XMLHttpRequest";
+ ThreadableLoaderOptions options;
+ options.allowCredentials = DoNotAllowStoredCredentials;
+ options.crossOriginRequestPolicy = AllowCrossOriginRequests;
+
+ InspectorThreadableLoaderClient* inspectorThreadableLoaderClient = new InspectorThreadableLoaderClient(callback);
+ RefPtr<DocumentThreadableLoader> loader = DocumentThreadableLoader::create(document, inspectorThreadableLoaderClient, request, options);
+ if (!loader) {
+ inspectorThreadableLoaderClient->didFailLoaderCreation();
return;
}
+ loader->setDefersLoading(false);
+ inspectorThreadableLoaderClient->setLoader(loader.release());
}
void InspectorResourceAgent::didCommitLoad(Frame* frame, DocumentLoader* loader)
@@ -749,10 +774,11 @@
info.addMember(m_styleRecalculationInitiator, "styleRecalculationInitiator");
}
-InspectorResourceAgent::InspectorResourceAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorCompositeState* state)
+InspectorResourceAgent::InspectorResourceAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorCompositeState* state, InspectorOverlay* overlay)
: InspectorBaseAgent<InspectorResourceAgent>("Network", instrumentingAgents, state)
, m_pageAgent(pageAgent)
, m_client(client)
+ , m_overlay(overlay)
, m_frontend(0)
, m_resourcesData(adoptPtr(new NetworkResourcesData()))
, m_loadingXHRSynchronously(false)
diff --git a/Source/core/inspector/InspectorResourceAgent.h b/Source/core/inspector/InspectorResourceAgent.h
index 40827c6..ec3771a 100644
--- a/Source/core/inspector/InspectorResourceAgent.h
+++ b/Source/core/inspector/InspectorResourceAgent.h
@@ -35,9 +35,6 @@
#include "bindings/v8/ScriptString.h"
#include "core/inspector/InspectorBaseAgent.h"
#include "wtf/PassOwnPtr.h"
-#include "wtf/RefCounted.h"
-#include "wtf/Vector.h"
-#include "wtf/text/TextPosition.h"
#include "wtf/text/WTFString.h"
@@ -54,13 +51,13 @@
class FormData;
class Frame;
class HTTPHeaderMap;
-class InspectorArray;
class InspectorClient;
class InspectorFrontend;
-class InspectorObject;
+class InspectorOverlay;
class InspectorPageAgent;
class InspectorState;
class InstrumentingAgents;
+class JSONObject;
class KURL;
class NetworkResourcesData;
class Page;
@@ -81,9 +78,9 @@
class InspectorResourceAgent : public InspectorBaseAgent<InspectorResourceAgent>, public InspectorBackendDispatcher::NetworkCommandHandler {
public:
- static PassOwnPtr<InspectorResourceAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorCompositeState* state)
+ static PassOwnPtr<InspectorResourceAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorCompositeState* state, InspectorOverlay* overlay)
{
- return adoptPtr(new InspectorResourceAgent(instrumentingAgents, pageAgent, client, state));
+ return adoptPtr(new InspectorResourceAgent(instrumentingAgents, pageAgent, client, state, overlay));
}
virtual void setFrontend(InspectorFrontend*);
@@ -138,7 +135,7 @@
virtual void enable(ErrorString*);
virtual void disable(ErrorString*);
virtual void setUserAgentOverride(ErrorString*, const String& userAgent);
- virtual void setExtraHTTPHeaders(ErrorString*, const RefPtr<InspectorObject>&);
+ virtual void setExtraHTTPHeaders(ErrorString*, const RefPtr<JSONObject>&);
virtual void getResponseBody(ErrorString*, const String& requestId, String* content, bool* base64Encoded);
virtual void replayXHR(ErrorString*, const String& requestId);
@@ -149,17 +146,18 @@
virtual void clearBrowserCookies(ErrorString*);
virtual void setCacheDisabled(ErrorString*, bool cacheDisabled);
- virtual void loadResourceForFrontend(ErrorString*, const String& frameId, const String& url, PassRefPtr<LoadResourceForFrontendCallback>);
+ virtual void loadResourceForFrontend(ErrorString*, const String& frameId, const String& url, const RefPtr<JSONObject>* requestHeaders, PassRefPtr<LoadResourceForFrontendCallback>);
virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
private:
- InspectorResourceAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorClient*, InspectorCompositeState*);
+ InspectorResourceAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorClient*, InspectorCompositeState*, InspectorOverlay*);
void enable();
InspectorPageAgent* m_pageAgent;
InspectorClient* m_client;
+ InspectorOverlay* m_overlay;
InspectorFrontend::Network* m_frontend;
String m_userAgentOverride;
OwnPtr<NetworkResourcesData> m_resourcesData;
diff --git a/Source/core/inspector/InspectorRuntimeAgent.cpp b/Source/core/inspector/InspectorRuntimeAgent.cpp
index c042fe2..2568d13 100644
--- a/Source/core/inspector/InspectorRuntimeAgent.cpp
+++ b/Source/core/inspector/InspectorRuntimeAgent.cpp
@@ -33,8 +33,7 @@
#include "core/inspector/InjectedScript.h"
#include "core/inspector/InjectedScriptManager.h"
-#include "core/inspector/InspectorValues.h"
-#include <wtf/PassRefPtr.h>
+#include "core/platform/JSONValues.h"
#include "bindings/v8/ScriptDebugServer.h"
@@ -86,7 +85,7 @@
}
}
-void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const RefPtr<InspectorArray>* const optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
+void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const RefPtr<JSONArray>* const optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue()) {
diff --git a/Source/core/inspector/InspectorRuntimeAgent.h b/Source/core/inspector/InspectorRuntimeAgent.h
index 83ec406..8ad65c1 100644
--- a/Source/core/inspector/InspectorRuntimeAgent.h
+++ b/Source/core/inspector/InspectorRuntimeAgent.h
@@ -32,22 +32,19 @@
#define InspectorRuntimeAgent_h
-#include "bindings/v8/ScriptState.h"
#include "core/inspector/InspectorBaseAgent.h"
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
+#include "wtf/Forward.h"
+#include "wtf/Noncopyable.h"
namespace WebCore {
class InjectedScript;
class InjectedScriptManager;
-class InspectorArray;
class InspectorFrontend;
-class InspectorObject;
-class InspectorValue;
class InstrumentingAgents;
+class JSONArray;
class ScriptDebugServer;
-class WorkerContext;
+class WorkerGlobalScope;
typedef String ErrorString;
@@ -73,7 +70,7 @@
virtual void callFunctionOn(ErrorString*,
const String& objectId,
const String& expression,
- const RefPtr<InspectorArray>* optionalArguments,
+ const RefPtr<JSONArray>* optionalArguments,
const bool* doNotPauseOnExceptionsAndMuteConsole,
const bool* returnByValue,
const bool* generatePreview,
diff --git a/Source/core/inspector/InspectorState.cpp b/Source/core/inspector/InspectorState.cpp
index fc3124f..2ed6d20 100644
--- a/Source/core/inspector/InspectorState.cpp
+++ b/Source/core/inspector/InspectorState.cpp
@@ -30,11 +30,12 @@
#include "core/inspector/InspectorState.h"
#include "core/inspector/InspectorStateClient.h"
-#include <wtf/PassOwnPtr.h>
+#include "core/inspector/JSONParser.h"
+#include "wtf/PassOwnPtr.h"
namespace WebCore {
-InspectorState::InspectorState(InspectorStateUpdateListener* listener, PassRefPtr<InspectorObject> properties)
+InspectorState::InspectorState(InspectorStateUpdateListener* listener, PassRefPtr<JSONObject> properties)
: m_listener(listener)
, m_properties(properties)
{
@@ -46,12 +47,12 @@
m_listener->inspectorStateUpdated();
}
-void InspectorState::setFromCookie(PassRefPtr<InspectorObject> properties)
+void InspectorState::setFromCookie(PassRefPtr<JSONObject> properties)
{
m_properties = properties;
}
-void InspectorState::setValue(const String& propertyName, PassRefPtr<InspectorValue> value)
+void InspectorState::setValue(const String& propertyName, PassRefPtr<JSONValue> value)
{
m_properties->setValue(propertyName, value);
updateCookie();
@@ -65,7 +66,7 @@
bool InspectorState::getBoolean(const String& propertyName)
{
- InspectorObject::iterator it = m_properties->find(propertyName);
+ JSONObject::iterator it = m_properties->find(propertyName);
bool value = false;
if (it != m_properties->end())
it->value->asBoolean(&value);
@@ -74,7 +75,7 @@
String InspectorState::getString(const String& propertyName)
{
- InspectorObject::iterator it = m_properties->find(propertyName);
+ JSONObject::iterator it = m_properties->find(propertyName);
String value;
if (it != m_properties->end())
it->value->asString(&value);
@@ -83,7 +84,7 @@
long InspectorState::getLong(const String& propertyName)
{
- InspectorObject::iterator it = m_properties->find(propertyName);
+ JSONObject::iterator it = m_properties->find(propertyName);
long value = 0;
if (it != m_properties->end())
it->value->asNumber(&value);
@@ -92,18 +93,18 @@
double InspectorState::getDouble(const String& propertyName)
{
- InspectorObject::iterator it = m_properties->find(propertyName);
+ JSONObject::iterator it = m_properties->find(propertyName);
double value = 0;
if (it != m_properties->end())
it->value->asNumber(&value);
return value;
}
-PassRefPtr<InspectorObject> InspectorState::getObject(const String& propertyName)
+PassRefPtr<JSONObject> InspectorState::getObject(const String& propertyName)
{
- InspectorObject::iterator it = m_properties->find(propertyName);
+ JSONObject::iterator it = m_properties->find(propertyName);
if (it == m_properties->end()) {
- m_properties->setObject(propertyName, InspectorObject::create());
+ m_properties->setObject(propertyName, JSONObject::create());
it = m_properties->find(propertyName);
}
return it->value->asObject();
@@ -113,7 +114,7 @@
{
ASSERT(m_stateObject->find(agentName) == m_stateObject->end());
ASSERT(m_inspectorStateMap.find(agentName) == m_inspectorStateMap.end());
- RefPtr<InspectorObject> stateProperties = InspectorObject::create();
+ RefPtr<JSONObject> stateProperties = JSONObject::create();
m_stateObject->setObject(agentName, stateProperties);
OwnPtr<InspectorState> statePtr = adoptPtr(new InspectorState(this, stateProperties));
InspectorState* state = statePtr.get();
@@ -123,17 +124,17 @@
void InspectorCompositeState::loadFromCookie(const String& inspectorCompositeStateCookie)
{
- RefPtr<InspectorValue> cookie = InspectorValue::parseJSON(inspectorCompositeStateCookie);
+ RefPtr<JSONValue> cookie = parseJSON(inspectorCompositeStateCookie);
if (cookie)
m_stateObject = cookie->asObject();
if (!m_stateObject)
- m_stateObject = InspectorObject::create();
+ m_stateObject = JSONObject::create();
InspectorStateMap::iterator end = m_inspectorStateMap.end();
for (InspectorStateMap::iterator it = m_inspectorStateMap.begin(); it != end; ++it) {
- RefPtr<InspectorObject> agentStateObject = m_stateObject->getObject(it->key);
+ RefPtr<JSONObject> agentStateObject = m_stateObject->getObject(it->key);
if (!agentStateObject) {
- agentStateObject = InspectorObject::create();
+ agentStateObject = JSONObject::create();
m_stateObject->setObject(it->key, agentStateObject);
}
it->value->setFromCookie(agentStateObject);
diff --git a/Source/core/inspector/InspectorState.h b/Source/core/inspector/InspectorState.h
index 7952f2b..7fe1f50 100644
--- a/Source/core/inspector/InspectorState.h
+++ b/Source/core/inspector/InspectorState.h
@@ -32,10 +32,9 @@
#define InspectorState_h
-#include "core/inspector/InspectorValues.h"
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include "core/platform/JSONValues.h"
+#include "wtf/HashMap.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -50,7 +49,7 @@
class InspectorState {
WTF_MAKE_FAST_ALLOCATED;
public:
- InspectorState(InspectorStateUpdateListener*, PassRefPtr<InspectorObject>);
+ InspectorState(InspectorStateUpdateListener*, PassRefPtr<JSONObject>);
virtual ~InspectorState() {}
void loadFromCookie(const String& inspectorStateCookie);
@@ -62,33 +61,33 @@
String getString(const String& propertyName);
long getLong(const String& propertyName);
double getDouble(const String& propertyName);
- PassRefPtr<InspectorObject> getObject(const String& propertyName);
+ PassRefPtr<JSONObject> getObject(const String& propertyName);
- void setBoolean(const String& propertyName, bool value) { setValue(propertyName, InspectorBasicValue::create(value)); }
- void setString(const String& propertyName, const String& value) { setValue(propertyName, InspectorString::create(value)); }
- void setLong(const String& propertyName, long value) { setValue(propertyName, InspectorBasicValue::create((double)value)); }
- void setDouble(const String& propertyName, double value) { setValue(propertyName, InspectorBasicValue::create(value)); }
- void setObject(const String& propertyName, PassRefPtr<InspectorObject> value) { setValue(propertyName, value); }
+ void setBoolean(const String& propertyName, bool value) { setValue(propertyName, JSONBasicValue::create(value)); }
+ void setString(const String& propertyName, const String& value) { setValue(propertyName, JSONString::create(value)); }
+ void setLong(const String& propertyName, long value) { setValue(propertyName, JSONBasicValue::create((double)value)); }
+ void setDouble(const String& propertyName, double value) { setValue(propertyName, JSONBasicValue::create(value)); }
+ void setObject(const String& propertyName, PassRefPtr<JSONObject> value) { setValue(propertyName, value); }
void remove(const String&);
private:
void updateCookie();
- void setValue(const String& propertyName, PassRefPtr<InspectorValue>);
+ void setValue(const String& propertyName, PassRefPtr<JSONValue>);
// Gets called from InspectorCompositeState::loadFromCookie().
- void setFromCookie(PassRefPtr<InspectorObject>);
+ void setFromCookie(PassRefPtr<JSONObject>);
friend class InspectorCompositeState;
InspectorStateUpdateListener* m_listener;
- RefPtr<InspectorObject> m_properties;
+ RefPtr<JSONObject> m_properties;
};
class InspectorCompositeState : public InspectorStateUpdateListener {
public:
InspectorCompositeState(InspectorStateClient* inspectorClient)
: m_client(inspectorClient)
- , m_stateObject(InspectorObject::create())
+ , m_stateObject(JSONObject::create())
, m_isMuted(false)
{
}
@@ -107,7 +106,7 @@
virtual void inspectorStateUpdated();
InspectorStateClient* m_client;
- RefPtr<InspectorObject> m_stateObject;
+ RefPtr<JSONObject> m_stateObject;
bool m_isMuted;
InspectorStateMap m_inspectorStateMap;
};
diff --git a/Source/core/inspector/InspectorStyleSheet.cpp b/Source/core/inspector/InspectorStyleSheet.cpp
index 0d52545..e001e72 100644
--- a/Source/core/inspector/InspectorStyleSheet.cpp
+++ b/Source/core/inspector/InspectorStyleSheet.cpp
@@ -29,7 +29,6 @@
#include "HTMLNames.h"
#include "SVGNames.h"
#include "core/css/CSSHostRule.h"
-#include "core/css/CSSImportRule.h"
#include "core/css/CSSKeyframesRule.h"
#include "core/css/CSSMediaRule.h"
#include "core/css/CSSParser.h"
@@ -49,15 +48,15 @@
#include "core/inspector/ContentSearchUtils.h"
#include "core/inspector/InspectorCSSAgent.h"
#include "core/inspector/InspectorPageAgent.h"
-#include "core/inspector/InspectorValues.h"
#include "core/page/Page.h"
#include "core/page/PageConsole.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/text/RegularExpression.h"
-
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/TextPosition.h"
using WebCore::TypeBuilder::Array;
using WebCore::RuleSourceDataList;
@@ -443,12 +442,12 @@
MediaListSourceImportRule
};
-static PassRefPtr<TypeBuilder::CSS::SourceRange> buildSourceRangeObject(const SourceRange& range, Vector<size_t>* lineEndings)
+static PassRefPtr<TypeBuilder::CSS::SourceRange> buildSourceRangeObject(const SourceRange& range, Vector<unsigned>* lineEndings)
{
if (!lineEndings)
return 0;
- TextPosition start = ContentSearchUtils::textPositionFromOffset(range.start, *lineEndings);
- TextPosition end = ContentSearchUtils::textPositionFromOffset(range.end, *lineEndings);
+ TextPosition start = TextPosition::fromOffsetAndLineEndings(range.start, *lineEndings);
+ TextPosition end = TextPosition::fromOffsetAndLineEndings(range.end, *lineEndings);
RefPtr<TypeBuilder::CSS::SourceRange> result = TypeBuilder::CSS::SourceRange::create()
.setStartLine(start.m_line.zeroBasedInt())
@@ -710,7 +709,7 @@
HashSet<String> foundShorthands;
String previousPriority;
String previousStatus;
- OwnPtr<Vector<size_t> > lineEndings(m_parentStyleSheet ? m_parentStyleSheet->lineEndings() : PassOwnPtr<Vector<size_t> >());
+ OwnPtr<Vector<unsigned> > lineEndings(m_parentStyleSheet ? m_parentStyleSheet->lineEndings() : PassOwnPtr<Vector<unsigned> >());
RefPtr<CSSRuleSourceData> sourceData = extractSourceData();
unsigned ruleBodyRangeStart = sourceData ? sourceData->ruleBodyRange.start : 0;
@@ -903,14 +902,13 @@
int propertyIndex = 0;
bool isFullPrefixScanned = false;
bool lineFeedTerminated = false;
- const UChar* characters = text.characters();
while (propertyIndex < propertyCount) {
const WebCore::CSSPropertySourceData& currentProperty = sourcePropertyData->at(propertyIndex++);
bool processNextProperty = false;
int scanEnd = currentProperty.range.start;
for (int i = scanStart; i < scanEnd; ++i) {
- UChar ch = characters[i];
+ UChar ch = text[i];
bool isLineFeed = isHTMLLineBreak(ch);
if (isLineFeed) {
if (!lineFeedTerminated)
@@ -1434,8 +1432,7 @@
bool deprecated;
String commentValue = ContentSearchUtils::findSourceURL(styleSheetText, ContentSearchUtils::CSSMagicComment, &deprecated);
if (!commentValue.isEmpty()) {
- if (deprecated)
- m_pageAgent->page()->console()->addMessage(NetworkMessageSource, WarningMessageLevel, "\"/*@ sourceURL=\" source URL declaration is deprecated, \"/*# sourceURL=\" declaration should be used instead.", finalURL(), 0);
+ // FIXME: add deprecated console message here.
m_sourceURL = commentValue;
return commentValue;
}
@@ -1488,8 +1485,7 @@
bool deprecated;
String commentValue = ContentSearchUtils::findSourceMapURL(styleSheetText, ContentSearchUtils::CSSMagicComment, &deprecated);
if (!commentValue.isEmpty()) {
- if (deprecated)
- m_pageAgent->page()->console()->addMessage(NetworkMessageSource, WarningMessageLevel, "\"/*@ sourceMappingURL=\" source mapping URL declaration is deprecated, \"/*# sourceMappingURL=\" declaration should be used instead.", finalURL(), 0);
+ // FIXME: add deprecated console message here.
return commentValue;
}
}
@@ -1514,11 +1510,11 @@
return m_parsedStyleSheet->ruleSourceDataAt(ruleIndexByStyle(style));
}
-PassOwnPtr<Vector<size_t> > InspectorStyleSheet::lineEndings() const
+PassOwnPtr<Vector<unsigned> > InspectorStyleSheet::lineEndings() const
{
if (!m_parsedStyleSheet->hasText())
- return PassOwnPtr<Vector<size_t> >();
- return ContentSearchUtils::lineEndings(m_parsedStyleSheet->text());
+ return PassOwnPtr<Vector<unsigned> >();
+ return WTF::lineEndings(m_parsedStyleSheet->text());
}
unsigned InspectorStyleSheet::ruleIndexByStyle(CSSStyleDeclaration* pageStyle) const
@@ -1748,9 +1744,9 @@
return !ec;
}
-PassOwnPtr<Vector<size_t> > InspectorStyleSheetForInlineStyle::lineEndings() const
+PassOwnPtr<Vector<unsigned> > InspectorStyleSheetForInlineStyle::lineEndings() const
{
- return ContentSearchUtils::lineEndings(elementStyleText());
+ return WTF::lineEndings(elementStyleText());
}
Document* InspectorStyleSheetForInlineStyle::ownerDocument() const
diff --git a/Source/core/inspector/InspectorStyleSheet.h b/Source/core/inspector/InspectorStyleSheet.h
index 61a8d3c..9082de5 100644
--- a/Source/core/inspector/InspectorStyleSheet.h
+++ b/Source/core/inspector/InspectorStyleSheet.h
@@ -30,14 +30,12 @@
#include "core/css/CSSStyleDeclaration.h"
#include "core/dom/ExceptionCode.h"
#include "core/inspector/InspectorStyleTextEditor.h"
-#include "core/inspector/InspectorValues.h"
-
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "core/platform/JSONValues.h"
+#include "wtf/HashMap.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
class ParsedStyleSheet;
@@ -63,12 +61,12 @@
{
}
- explicit InspectorCSSId(RefPtr<InspectorObject> value)
+ explicit InspectorCSSId(PassRefPtr<JSONObject> value)
{
if (!value->getString("styleSheetId", &m_styleSheetId))
return;
- RefPtr<InspectorValue> ordinalValue = value->get("ordinal");
+ RefPtr<JSONValue> ordinalValue = value->get("ordinal");
if (!ordinalValue || !ordinalValue->asNumber(&m_ordinal))
m_styleSheetId = "";
}
@@ -223,7 +221,7 @@
// Also accessed by friend class InspectorStyle.
virtual bool setStyleText(CSSStyleDeclaration*, const String&);
- virtual PassOwnPtr<Vector<size_t> > lineEndings() const;
+ virtual PassOwnPtr<Vector<unsigned> > lineEndings() const;
private:
friend class InspectorStyle;
@@ -277,7 +275,7 @@
// Also accessed by friend class InspectorStyle.
virtual bool setStyleText(CSSStyleDeclaration*, const String&);
- virtual PassOwnPtr<Vector<size_t> > lineEndings() const;
+ virtual PassOwnPtr<Vector<unsigned> > lineEndings() const;
private:
CSSStyleDeclaration* inlineStyle() const;
diff --git a/Source/core/inspector/InspectorStyleTextEditor.cpp b/Source/core/inspector/InspectorStyleTextEditor.cpp
index f2701b2..f7044ff 100644
--- a/Source/core/inspector/InspectorStyleTextEditor.cpp
+++ b/Source/core/inspector/InspectorStyleTextEditor.cpp
@@ -68,13 +68,11 @@
if (insertLast && !insertFirstInSource) {
propertyStart = styleBodyLength;
if (propertyStart && textToSet.length()) {
- const UChar* characters = m_styleText.characters();
-
long curPos = propertyStart - 1; // The last position of style declaration, since propertyStart points past one.
- while (curPos && isHTMLSpace(characters[curPos]))
+ while (curPos && isHTMLSpace(m_styleText[curPos]))
--curPos;
if (curPos) {
- bool terminated = characters[curPos] == ';' || (characters[curPos] == '/' && characters[curPos - 1] == '*');
+ bool terminated = m_styleText[curPos] == ';' || (m_styleText[curPos] == '/' && m_styleText[curPos - 1] == '*');
if (!terminated) {
// Prepend a ";" to the property text if appending to a style declaration where
// the last property has no trailing ";".
@@ -140,7 +138,6 @@
const SourceRange& range = property.sourceData.range;
long replaceRangeStart = range.start;
long replaceRangeEnd = range.end;
- const UChar* characters = m_styleText.characters();
long newTextLength = newText.length();
String finalNewText = newText;
@@ -151,14 +148,14 @@
if (replaceRangeStart >= fullPrefixLength && m_styleText.substring(replaceRangeStart - fullPrefixLength, fullPrefixLength) == fullPrefix)
replaceRangeStart -= fullPrefixLength;
} else if (newTextLength) {
- if (isHTMLLineBreak(newText.characters()[newTextLength - 1])) {
+ if (isHTMLLineBreak(newText[newTextLength - 1])) {
// Coalesce newlines of the original and new property values (to avoid a lot of blank lines while incrementally applying property values).
bool foundNewline = false;
bool isLastNewline = false;
int i;
int textLength = m_styleText.length();
- for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline(characters[i]); ++i) {
- isLastNewline = isHTMLLineBreak(characters[i]);
+ for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline(m_styleText[i]); ++i) {
+ isLastNewline = isHTMLLineBreak(m_styleText[i]);
if (isLastNewline)
foundNewline = true;
else if (foundNewline && !isLastNewline) {
diff --git a/Source/core/inspector/InspectorStyleTextEditor.h b/Source/core/inspector/InspectorStyleTextEditor.h
index 5fdab78..f5ac0ec 100644
--- a/Source/core/inspector/InspectorStyleTextEditor.h
+++ b/Source/core/inspector/InspectorStyleTextEditor.h
@@ -25,10 +25,8 @@
#ifndef InspectorStyleTextEditor_h
#define InspectorStyleTextEditor_h
-#include "core/css/CSSPropertySourceData.h"
-
-#include <wtf/text/WTFString.h>
-#include <wtf/Vector.h>
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
diff --git a/Source/core/inspector/InspectorTimelineAgent.cpp b/Source/core/inspector/InspectorTimelineAgent.cpp
index 09db80d..0ea8f7f 100644
--- a/Source/core/inspector/InspectorTimelineAgent.cpp
+++ b/Source/core/inspector/InspectorTimelineAgent.cpp
@@ -55,7 +55,7 @@
#include "core/rendering/RenderView.h"
#include "core/xml/XMLHttpRequest.h"
-#include <wtf/CurrentTime.h>
+#include "wtf/CurrentTime.h"
namespace WebCore {
@@ -164,7 +164,7 @@
GCEvents events = m_gcEvents;
m_gcEvents.clear();
for (GCEvents::iterator i = events.begin(); i != events.end(); ++i) {
- RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(m_timeConverter.fromMonotonicallyIncreasingTime(i->startTime), m_maxCallStackDepth, TimelineRecordType::GCEvent);
+ RefPtr<JSONObject> record = TimelineRecordFactory::createGenericRecord(m_timeConverter.fromMonotonicallyIncreasingTime(i->startTime), m_maxCallStackDepth, TimelineRecordType::GCEvent);
record->setObject("data", TimelineRecordFactory::createGCEventData(i->collectedBytes));
record->setNumber("endTime", m_timeConverter.fromMonotonicallyIncreasingTime(i->endTime));
addRecordToTimeline(record.release());
@@ -294,7 +294,7 @@
void InspectorTimelineAgent::didInvalidateLayout(Frame* frame)
{
- appendRecord(InspectorObject::create(), TimelineRecordType::InvalidateLayout, true, frame);
+ appendRecord(JSONObject::create(), TimelineRecordType::InvalidateLayout, true, frame);
}
bool InspectorTimelineAgent::willLayout(Frame* frame)
@@ -333,12 +333,12 @@
void InspectorTimelineAgent::didScheduleStyleRecalculation(Document* document)
{
- appendRecord(InspectorObject::create(), TimelineRecordType::ScheduleStyleRecalculation, true, document->frame());
+ appendRecord(JSONObject::create(), TimelineRecordType::ScheduleStyleRecalculation, true, document->frame());
}
bool InspectorTimelineAgent::willRecalculateStyle(Document* document)
{
- pushCurrentRecord(InspectorObject::create(), TimelineRecordType::RecalculateStyles, true, document->frame());
+ pushCurrentRecord(JSONObject::create(), TimelineRecordType::RecalculateStyles, true, document->frame());
ASSERT(!m_styleRecalcElementCounter);
return true;
}
@@ -366,7 +366,7 @@
InstrumentationEventArguments::PageId, reinterpret_cast<unsigned long long>(frame->page()),
InstrumentationEventArguments::NodeId, idForNode(renderer->generatingNode()));
- pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Paint, true, frame, true);
+ pushCurrentRecord(JSONObject::create(), TimelineRecordType::Paint, true, frame, true);
}
void InspectorTimelineAgent::didPaint(RenderObject* renderer, GraphicsContext*, const LayoutRect& clipRect)
@@ -381,7 +381,7 @@
void InspectorTimelineAgent::willScrollLayer(Frame* frame)
{
- pushCurrentRecord(InspectorObject::create(), TimelineRecordType::ScrollLayer, false, frame);
+ pushCurrentRecord(JSONObject::create(), TimelineRecordType::ScrollLayer, false, frame);
}
void InspectorTimelineAgent::didScrollLayer()
@@ -411,7 +411,7 @@
void InspectorTimelineAgent::willComposite()
{
- pushCurrentRecord(InspectorObject::create(), TimelineRecordType::CompositeLayers, false, 0);
+ pushCurrentRecord(JSONObject::create(), TimelineRecordType::CompositeLayers, false, 0);
}
void InspectorTimelineAgent::didComposite()
@@ -604,7 +604,7 @@
void InspectorTimelineAgent::willProcessTask()
{
- pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Program, false, 0);
+ pushCurrentRecord(JSONObject::create(), TimelineRecordType::Program, false, 0);
}
void InspectorTimelineAgent::didProcessTask()
@@ -632,13 +632,13 @@
appendRecord(TimelineRecordFactory::createGenericWebSocketData(identifier), TimelineRecordType::WebSocketDestroy, true, document->frame());
}
-void InspectorTimelineAgent::addRecordToTimeline(PassRefPtr<InspectorObject> record)
+void InspectorTimelineAgent::addRecordToTimeline(PassRefPtr<JSONObject> record)
{
commitFrameRecord();
innerAddRecordToTimeline(record);
}
-void InspectorTimelineAgent::innerAddRecordToTimeline(PassRefPtr<InspectorObject> prpRecord)
+void InspectorTimelineAgent::innerAddRecordToTimeline(PassRefPtr<JSONObject> prpRecord)
{
RefPtr<TypeBuilder::Timeline::TimelineEvent> record = TypeBuilder::Timeline::TimelineEvent::runtimeCast(prpRecord);
@@ -687,7 +687,7 @@
return;
HashMap<String, size_t> map;
m_memoryAgent->getProcessMemoryDistributionMap(&map);
- RefPtr<InspectorObject> stats = InspectorObject::create();
+ RefPtr<JSONObject> stats = JSONObject::create();
for (HashMap<String, size_t>::iterator it = map.begin(); it != map.end(); ++it)
stats->setNumber(it->key, it->value);
size_t privateBytes = 0;
@@ -697,7 +697,7 @@
record->setNativeHeapStatistics(stats.release());
}
-void InspectorTimelineAgent::setFrameIdentifier(InspectorObject* record, Frame* frame)
+void InspectorTimelineAgent::setFrameIdentifier(JSONObject* record, Frame* frame)
{
if (!frame || !m_pageAgent)
return;
@@ -747,29 +747,29 @@
{
}
-void InspectorTimelineAgent::appendRecord(PassRefPtr<InspectorObject> data, const String& type, bool captureCallStack, Frame* frame)
+void InspectorTimelineAgent::appendRecord(PassRefPtr<JSONObject> data, const String& type, bool captureCallStack, Frame* frame)
{
pushGCEventRecords();
- RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(timestamp(), captureCallStack ? m_maxCallStackDepth : 0, type);
+ RefPtr<JSONObject> record = TimelineRecordFactory::createGenericRecord(timestamp(), captureCallStack ? m_maxCallStackDepth : 0, type);
record->setObject("data", data);
setFrameIdentifier(record.get(), frame);
addRecordToTimeline(record.release());
}
-void InspectorTimelineAgent::sendEvent(PassRefPtr<InspectorObject> event)
+void InspectorTimelineAgent::sendEvent(PassRefPtr<JSONObject> event)
{
// FIXME: runtimeCast is a hack. We do it because we can't build TimelineEvent directly now.
RefPtr<TypeBuilder::Timeline::TimelineEvent> recordChecked = TypeBuilder::Timeline::TimelineEvent::runtimeCast(event);
m_frontend->eventRecorded(recordChecked.release());
}
-void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data, const String& type, bool captureCallStack, Frame* frame, bool hasLowLevelDetails)
+void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<JSONObject> data, const String& type, bool captureCallStack, Frame* frame, bool hasLowLevelDetails)
{
pushGCEventRecords();
commitFrameRecord();
- RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(timestamp(), captureCallStack ? m_maxCallStackDepth : 0, type);
+ RefPtr<JSONObject> record = TimelineRecordFactory::createGenericRecord(timestamp(), captureCallStack ? m_maxCallStackDepth : 0, type);
setFrameIdentifier(record.get(), frame);
- m_recordStack.append(TimelineRecordEntry(record.release(), data, InspectorArray::create(), type, getUsedHeapSize()));
+ m_recordStack.append(TimelineRecordEntry(record.release(), data, JSONArray::create(), type, getUsedHeapSize()));
if (hasLowLevelDetails && !m_platformInstrumentationClientInstalledAtStackDepth && !PlatformInstrumentation::hasClient()) {
m_platformInstrumentationClientInstalledAtStackDepth = m_recordStack.size();
PlatformInstrumentation::setClient(this);
@@ -781,7 +781,7 @@
if (!m_pendingFrameRecord)
return;
- m_pendingFrameRecord->setObject("data", InspectorObject::create());
+ m_pendingFrameRecord->setObject("data", JSONObject::create());
innerAddRecordToTimeline(m_pendingFrameRecord.release());
}
diff --git a/Source/core/inspector/InspectorTimelineAgent.h b/Source/core/inspector/InspectorTimelineAgent.h
index 2a35c56..b589156 100644
--- a/Source/core/inspector/InspectorTimelineAgent.h
+++ b/Source/core/inspector/InspectorTimelineAgent.h
@@ -36,13 +36,13 @@
#include "bindings/v8/ScriptGCEvent.h"
#include "core/dom/EventContext.h"
#include "core/inspector/InspectorBaseAgent.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/ScriptGCEventListener.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/PlatformInstrumentation.h"
#include "core/platform/graphics/LayoutRect.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/WeakPtr.h>
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/WeakPtr.h"
namespace WebCore {
struct CachedResourceInitiatorInfo;
@@ -214,13 +214,13 @@
friend class TimelineTraceEventProcessor;
struct TimelineRecordEntry {
- TimelineRecordEntry(PassRefPtr<InspectorObject> record, PassRefPtr<InspectorObject> data, PassRefPtr<InspectorArray> children, const String& type, size_t usedHeapSizeAtStart)
+ TimelineRecordEntry(PassRefPtr<JSONObject> record, PassRefPtr<JSONObject> data, PassRefPtr<JSONArray> children, const String& type, size_t usedHeapSizeAtStart)
: record(record), data(data), children(children), type(type), usedHeapSizeAtStart(usedHeapSizeAtStart)
{
}
- RefPtr<InspectorObject> record;
- RefPtr<InspectorObject> data;
- RefPtr<InspectorArray> children;
+ RefPtr<JSONObject> record;
+ RefPtr<JSONObject> data;
+ RefPtr<JSONArray> children;
String type;
size_t usedHeapSizeAtStart;
};
@@ -229,22 +229,22 @@
void didFinishLoadingResource(unsigned long, bool didFail, double finishTime, Frame*);
- void sendEvent(PassRefPtr<InspectorObject>);
- void appendRecord(PassRefPtr<InspectorObject> data, const String& type, bool captureCallStack, Frame*);
- void pushCurrentRecord(PassRefPtr<InspectorObject>, const String& type, bool captureCallStack, Frame*, bool hasLowLevelDetails = false);
+ void sendEvent(PassRefPtr<JSONObject>);
+ void appendRecord(PassRefPtr<JSONObject> data, const String& type, bool captureCallStack, Frame*);
+ void pushCurrentRecord(PassRefPtr<JSONObject>, const String& type, bool captureCallStack, Frame*, bool hasLowLevelDetails = false);
void setDOMCounters(TypeBuilder::Timeline::TimelineEvent* record);
void setNativeHeapStatistics(TypeBuilder::Timeline::TimelineEvent* record);
- void setFrameIdentifier(InspectorObject* record, Frame*);
+ void setFrameIdentifier(JSONObject* record, Frame*);
void pushGCEventRecords();
void didCompleteCurrentRecord(const String& type);
- void setHeapSizeStatistics(InspectorObject* record);
+ void setHeapSizeStatistics(JSONObject* record);
void commitFrameRecord();
- void addRecordToTimeline(PassRefPtr<InspectorObject>);
- void innerAddRecordToTimeline(PassRefPtr<InspectorObject>);
+ void addRecordToTimeline(PassRefPtr<JSONObject>);
+ void innerAddRecordToTimeline(PassRefPtr<JSONObject>);
void clearRecordStack();
void localToPageQuad(const RenderObject& renderer, const LayoutRect&, FloatQuad*);
@@ -279,7 +279,7 @@
GCEvents m_gcEvents;
int m_maxCallStackDepth;
unsigned m_platformInstrumentationClientInstalledAtStackDepth;
- RefPtr<InspectorObject> m_pendingFrameRecord;
+ RefPtr<JSONObject> m_pendingFrameRecord;
InspectorType m_inspectorType;
InspectorClient* m_client;
WeakPtrFactory<InspectorTimelineAgent> m_weakFactory;
diff --git a/Source/core/inspector/InspectorValues.cpp b/Source/core/inspector/InspectorValues.cpp
deleted file mode 100644
index c132a98..0000000
--- a/Source/core/inspector/InspectorValues.cpp
+++ /dev/null
@@ -1,796 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "core/inspector/InspectorValues.h"
-
-#include <wtf/DecimalNumber.h>
-#include <wtf/dtoa.h>
-#include <wtf/text/StringBuilder.h>
-
-namespace WebCore {
-
-namespace {
-
-static const int stackLimit = 1000;
-
-enum Token {
- OBJECT_BEGIN,
- OBJECT_END,
- ARRAY_BEGIN,
- ARRAY_END,
- STRING,
- NUMBER,
- BOOL_TRUE,
- BOOL_FALSE,
- NULL_TOKEN,
- LIST_SEPARATOR,
- OBJECT_PAIR_SEPARATOR,
- INVALID_TOKEN,
-};
-
-const char* const nullString = "null";
-const char* const trueString = "true";
-const char* const falseString = "false";
-
-bool parseConstToken(const UChar* start, const UChar* end, const UChar** tokenEnd, const char* token)
-{
- while (start < end && *token != '\0' && *start++ == *token++) { }
- if (*token != '\0')
- return false;
- *tokenEnd = start;
- return true;
-}
-
-bool readInt(const UChar* start, const UChar* end, const UChar** tokenEnd, bool canHaveLeadingZeros)
-{
- if (start == end)
- return false;
- bool haveLeadingZero = '0' == *start;
- int length = 0;
- while (start < end && '0' <= *start && *start <= '9') {
- ++start;
- ++length;
- }
- if (!length)
- return false;
- if (!canHaveLeadingZeros && length > 1 && haveLeadingZero)
- return false;
- *tokenEnd = start;
- return true;
-}
-
-bool parseNumberToken(const UChar* start, const UChar* end, const UChar** tokenEnd)
-{
- // We just grab the number here. We validate the size in DecodeNumber.
- // According to RFC4627, a valid number is: [minus] int [frac] [exp]
- if (start == end)
- return false;
- UChar c = *start;
- if ('-' == c)
- ++start;
-
- if (!readInt(start, end, &start, false))
- return false;
- if (start == end) {
- *tokenEnd = start;
- return true;
- }
-
- // Optional fraction part
- c = *start;
- if ('.' == c) {
- ++start;
- if (!readInt(start, end, &start, true))
- return false;
- if (start == end) {
- *tokenEnd = start;
- return true;
- }
- c = *start;
- }
-
- // Optional exponent part
- if ('e' == c || 'E' == c) {
- ++start;
- if (start == end)
- return false;
- c = *start;
- if ('-' == c || '+' == c) {
- ++start;
- if (start == end)
- return false;
- }
- if (!readInt(start, end, &start, true))
- return false;
- }
-
- *tokenEnd = start;
- return true;
-}
-
-bool readHexDigits(const UChar* start, const UChar* end, const UChar** tokenEnd, int digits)
-{
- if (end - start < digits)
- return false;
- for (int i = 0; i < digits; ++i) {
- UChar c = *start++;
- if (!(('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')))
- return false;
- }
- *tokenEnd = start;
- return true;
-}
-
-bool parseStringToken(const UChar* start, const UChar* end, const UChar** tokenEnd)
-{
- while (start < end) {
- UChar c = *start++;
- if ('\\' == c) {
- c = *start++;
- // Make sure the escaped char is valid.
- switch (c) {
- case 'x':
- if (!readHexDigits(start, end, &start, 2))
- return false;
- break;
- case 'u':
- if (!readHexDigits(start, end, &start, 4))
- return false;
- break;
- case '\\':
- case '/':
- case 'b':
- case 'f':
- case 'n':
- case 'r':
- case 't':
- case 'v':
- case '"':
- break;
- default:
- return false;
- }
- } else if ('"' == c) {
- *tokenEnd = start;
- return true;
- }
- }
- return false;
-}
-
-Token parseToken(const UChar* start, const UChar* end, const UChar** tokenStart, const UChar** tokenEnd)
-{
- while (start < end && isSpaceOrNewline(*start))
- ++start;
-
- if (start == end)
- return INVALID_TOKEN;
-
- *tokenStart = start;
-
- switch (*start) {
- case 'n':
- if (parseConstToken(start, end, tokenEnd, nullString))
- return NULL_TOKEN;
- break;
- case 't':
- if (parseConstToken(start, end, tokenEnd, trueString))
- return BOOL_TRUE;
- break;
- case 'f':
- if (parseConstToken(start, end, tokenEnd, falseString))
- return BOOL_FALSE;
- break;
- case '[':
- *tokenEnd = start + 1;
- return ARRAY_BEGIN;
- case ']':
- *tokenEnd = start + 1;
- return ARRAY_END;
- case ',':
- *tokenEnd = start + 1;
- return LIST_SEPARATOR;
- case '{':
- *tokenEnd = start + 1;
- return OBJECT_BEGIN;
- case '}':
- *tokenEnd = start + 1;
- return OBJECT_END;
- case ':':
- *tokenEnd = start + 1;
- return OBJECT_PAIR_SEPARATOR;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '-':
- if (parseNumberToken(start, end, tokenEnd))
- return NUMBER;
- break;
- case '"':
- if (parseStringToken(start + 1, end, tokenEnd))
- return STRING;
- break;
- }
- return INVALID_TOKEN;
-}
-
-inline int hexToInt(UChar c)
-{
- if ('0' <= c && c <= '9')
- return c - '0';
- if ('A' <= c && c <= 'F')
- return c - 'A' + 10;
- if ('a' <= c && c <= 'f')
- return c - 'a' + 10;
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-bool decodeString(const UChar* start, const UChar* end, StringBuilder* output)
-{
- while (start < end) {
- UChar c = *start++;
- if ('\\' != c) {
- output->append(c);
- continue;
- }
- c = *start++;
- switch (c) {
- case '"':
- case '/':
- case '\\':
- break;
- case 'b':
- c = '\b';
- break;
- case 'f':
- c = '\f';
- break;
- case 'n':
- c = '\n';
- break;
- case 'r':
- c = '\r';
- break;
- case 't':
- c = '\t';
- break;
- case 'v':
- c = '\v';
- break;
- case 'x':
- c = (hexToInt(*start) << 4) +
- hexToInt(*(start + 1));
- start += 2;
- break;
- case 'u':
- c = (hexToInt(*start) << 12) +
- (hexToInt(*(start + 1)) << 8) +
- (hexToInt(*(start + 2)) << 4) +
- hexToInt(*(start + 3));
- start += 4;
- break;
- default:
- return false;
- }
- output->append(c);
- }
- return true;
-}
-
-bool decodeString(const UChar* start, const UChar* end, String* output)
-{
- if (start == end) {
- *output = "";
- return true;
- }
- if (start > end)
- return false;
- StringBuilder buffer;
- buffer.reserveCapacity(end - start);
- if (!decodeString(start, end, &buffer))
- return false;
- *output = buffer.toString();
- return true;
-}
-
-PassRefPtr<InspectorValue> buildValue(const UChar* start, const UChar* end, const UChar** valueTokenEnd, int depth)
-{
- if (depth > stackLimit)
- return 0;
-
- RefPtr<InspectorValue> result;
- const UChar* tokenStart;
- const UChar* tokenEnd;
- Token token = parseToken(start, end, &tokenStart, &tokenEnd);
- switch (token) {
- case INVALID_TOKEN:
- return 0;
- case NULL_TOKEN:
- result = InspectorValue::null();
- break;
- case BOOL_TRUE:
- result = InspectorBasicValue::create(true);
- break;
- case BOOL_FALSE:
- result = InspectorBasicValue::create(false);
- break;
- case NUMBER: {
- bool ok;
- double value = charactersToDouble(tokenStart, tokenEnd - tokenStart, &ok);
- if (!ok)
- return 0;
- result = InspectorBasicValue::create(value);
- break;
- }
- case STRING: {
- String value;
- bool ok = decodeString(tokenStart + 1, tokenEnd - 1, &value);
- if (!ok)
- return 0;
- result = InspectorString::create(value);
- break;
- }
- case ARRAY_BEGIN: {
- RefPtr<InspectorArray> array = InspectorArray::create();
- start = tokenEnd;
- token = parseToken(start, end, &tokenStart, &tokenEnd);
- while (token != ARRAY_END) {
- RefPtr<InspectorValue> arrayNode = buildValue(start, end, &tokenEnd, depth + 1);
- if (!arrayNode)
- return 0;
- array->pushValue(arrayNode);
-
- // After a list value, we expect a comma or the end of the list.
- start = tokenEnd;
- token = parseToken(start, end, &tokenStart, &tokenEnd);
- if (token == LIST_SEPARATOR) {
- start = tokenEnd;
- token = parseToken(start, end, &tokenStart, &tokenEnd);
- if (token == ARRAY_END)
- return 0;
- } else if (token != ARRAY_END) {
- // Unexpected value after list value. Bail out.
- return 0;
- }
- }
- if (token != ARRAY_END)
- return 0;
- result = array.release();
- break;
- }
- case OBJECT_BEGIN: {
- RefPtr<InspectorObject> object = InspectorObject::create();
- start = tokenEnd;
- token = parseToken(start, end, &tokenStart, &tokenEnd);
- while (token != OBJECT_END) {
- if (token != STRING)
- return 0;
- String key;
- if (!decodeString(tokenStart + 1, tokenEnd - 1, &key))
- return 0;
- start = tokenEnd;
-
- token = parseToken(start, end, &tokenStart, &tokenEnd);
- if (token != OBJECT_PAIR_SEPARATOR)
- return 0;
- start = tokenEnd;
-
- RefPtr<InspectorValue> value = buildValue(start, end, &tokenEnd, depth + 1);
- if (!value)
- return 0;
- object->setValue(key, value);
- start = tokenEnd;
-
- // After a key/value pair, we expect a comma or the end of the
- // object.
- token = parseToken(start, end, &tokenStart, &tokenEnd);
- if (token == LIST_SEPARATOR) {
- start = tokenEnd;
- token = parseToken(start, end, &tokenStart, &tokenEnd);
- if (token == OBJECT_END)
- return 0;
- } else if (token != OBJECT_END) {
- // Unexpected value after last object value. Bail out.
- return 0;
- }
- }
- if (token != OBJECT_END)
- return 0;
- result = object.release();
- break;
- }
-
- default:
- // We got a token that's not a value.
- return 0;
- }
- *valueTokenEnd = tokenEnd;
- return result.release();
-}
-
-inline bool escapeChar(UChar c, StringBuilder* dst)
-{
- switch (c) {
- case '\b': dst->append("\\b", 2); break;
- case '\f': dst->append("\\f", 2); break;
- case '\n': dst->append("\\n", 2); break;
- case '\r': dst->append("\\r", 2); break;
- case '\t': dst->append("\\t", 2); break;
- case '\\': dst->append("\\\\", 2); break;
- case '"': dst->append("\\\"", 2); break;
- default:
- return false;
- }
- return true;
-}
-
-inline void doubleQuoteString(const String& str, StringBuilder* dst)
-{
- dst->append('"');
- for (unsigned i = 0; i < str.length(); ++i) {
- UChar c = str[i];
- if (!escapeChar(c, dst)) {
- if (c < 32 || c > 126 || c == '<' || c == '>') {
- // 1. Escaping <, > to prevent script execution.
- // 2. Technically, we could also pass through c > 126 as UTF8, but this
- // is also optional. It would also be a pain to implement here.
- unsigned int symbol = static_cast<unsigned int>(c);
- String symbolCode = String::format("\\u%04X", symbol);
- dst->append(symbolCode.characters(), symbolCode.length());
- } else
- dst->append(c);
- }
- }
- dst->append('"');
-}
-
-} // anonymous namespace
-
-bool InspectorValue::asBoolean(bool*) const
-{
- return false;
-}
-
-bool InspectorValue::asNumber(double*) const
-{
- return false;
-}
-
-bool InspectorValue::asNumber(long*) const
-{
- return false;
-}
-
-bool InspectorValue::asNumber(int*) const
-{
- return false;
-}
-
-bool InspectorValue::asNumber(unsigned long*) const
-{
- return false;
-}
-
-bool InspectorValue::asNumber(unsigned int*) const
-{
- return false;
-}
-
-bool InspectorValue::asString(String*) const
-{
- return false;
-}
-
-bool InspectorValue::asValue(RefPtr<InspectorValue>* output)
-{
- *output = this;
- return true;
-}
-
-bool InspectorValue::asObject(RefPtr<InspectorObject>*)
-{
- return false;
-}
-
-bool InspectorValue::asArray(RefPtr<InspectorArray>*)
-{
- return false;
-}
-
-PassRefPtr<InspectorObject> InspectorValue::asObject()
-{
- return 0;
-}
-
-PassRefPtr<InspectorArray> InspectorValue::asArray()
-{
- return 0;
-}
-
-PassRefPtr<InspectorValue> InspectorValue::parseJSON(const String& json)
-{
- const UChar* start = json.characters();
- const UChar* end = json.characters() + json.length();
- const UChar *tokenEnd;
- RefPtr<InspectorValue> value = buildValue(start, end, &tokenEnd, 0);
- if (!value || tokenEnd != end)
- return 0;
- return value.release();
-}
-
-String InspectorValue::toJSONString() const
-{
- StringBuilder result;
- result.reserveCapacity(512);
- writeJSON(&result);
- return result.toString();
-}
-
-void InspectorValue::writeJSON(StringBuilder* output) const
-{
- ASSERT(m_type == TypeNull);
- output->append(nullString, 4);
-}
-
-bool InspectorBasicValue::asBoolean(bool* output) const
-{
- if (type() != TypeBoolean)
- return false;
- *output = m_boolValue;
- return true;
-}
-
-bool InspectorBasicValue::asNumber(double* output) const
-{
- if (type() != TypeNumber)
- return false;
- *output = m_doubleValue;
- return true;
-}
-
-bool InspectorBasicValue::asNumber(long* output) const
-{
- if (type() != TypeNumber)
- return false;
- *output = static_cast<long>(m_doubleValue);
- return true;
-}
-
-bool InspectorBasicValue::asNumber(int* output) const
-{
- if (type() != TypeNumber)
- return false;
- *output = static_cast<int>(m_doubleValue);
- return true;
-}
-
-bool InspectorBasicValue::asNumber(unsigned long* output) const
-{
- if (type() != TypeNumber)
- return false;
- *output = static_cast<unsigned long>(m_doubleValue);
- return true;
-}
-
-bool InspectorBasicValue::asNumber(unsigned int* output) const
-{
- if (type() != TypeNumber)
- return false;
- *output = static_cast<unsigned int>(m_doubleValue);
- return true;
-}
-
-void InspectorBasicValue::writeJSON(StringBuilder* output) const
-{
- ASSERT(type() == TypeBoolean || type() == TypeNumber);
- if (type() == TypeBoolean) {
- if (m_boolValue)
- output->append(trueString, 4);
- else
- output->append(falseString, 5);
- } else if (type() == TypeNumber) {
- NumberToLStringBuffer buffer;
- if (!std::isfinite(m_doubleValue)) {
- output->append(nullString, 4);
- return;
- }
- DecimalNumber decimal = m_doubleValue;
- unsigned length = 0;
- if (decimal.bufferLengthForStringDecimal() > WTF::NumberToStringBufferLength) {
- // Not enough room for decimal. Use exponential format.
- if (decimal.bufferLengthForStringExponential() > WTF::NumberToStringBufferLength) {
- // Fallback for an abnormal case if it's too little even for exponential.
- output->append("NaN", 3);
- return;
- }
- length = decimal.toStringExponential(buffer, WTF::NumberToStringBufferLength);
- } else
- length = decimal.toStringDecimal(buffer, WTF::NumberToStringBufferLength);
- output->append(buffer, length);
- }
-}
-
-bool InspectorString::asString(String* output) const
-{
- *output = m_stringValue;
- return true;
-}
-
-void InspectorString::writeJSON(StringBuilder* output) const
-{
- ASSERT(type() == TypeString);
- doubleQuoteString(m_stringValue, output);
-}
-
-InspectorObjectBase::~InspectorObjectBase()
-{
-}
-
-bool InspectorObjectBase::asObject(RefPtr<InspectorObject>* output)
-{
- COMPILE_ASSERT(sizeof(InspectorObject) == sizeof(InspectorObjectBase), cannot_cast);
- *output = static_cast<InspectorObject*>(this);
- return true;
-}
-
-PassRefPtr<InspectorObject> InspectorObjectBase::asObject()
-{
- return openAccessors();
-}
-
-InspectorObject* InspectorObjectBase::openAccessors()
-{
- COMPILE_ASSERT(sizeof(InspectorObject) == sizeof(InspectorObjectBase), cannot_cast);
- return static_cast<InspectorObject*>(this);
-}
-
-bool InspectorObjectBase::getBoolean(const String& name, bool* output) const
-{
- RefPtr<InspectorValue> value = get(name);
- if (!value)
- return false;
- return value->asBoolean(output);
-}
-
-bool InspectorObjectBase::getString(const String& name, String* output) const
-{
- RefPtr<InspectorValue> value = get(name);
- if (!value)
- return false;
- return value->asString(output);
-}
-
-PassRefPtr<InspectorObject> InspectorObjectBase::getObject(const String& name) const
-{
- PassRefPtr<InspectorValue> value = get(name);
- if (!value)
- return 0;
- return value->asObject();
-}
-
-PassRefPtr<InspectorArray> InspectorObjectBase::getArray(const String& name) const
-{
- PassRefPtr<InspectorValue> value = get(name);
- if (!value)
- return 0;
- return value->asArray();
-}
-
-PassRefPtr<InspectorValue> InspectorObjectBase::get(const String& name) const
-{
- Dictionary::const_iterator it = m_data.find(name);
- if (it == m_data.end())
- return 0;
- return it->value;
-}
-
-void InspectorObjectBase::remove(const String& name)
-{
- m_data.remove(name);
- for (size_t i = 0; i < m_order.size(); ++i) {
- if (m_order[i] == name) {
- m_order.remove(i);
- break;
- }
- }
-}
-
-void InspectorObjectBase::writeJSON(StringBuilder* output) const
-{
- output->append('{');
- for (size_t i = 0; i < m_order.size(); ++i) {
- Dictionary::const_iterator it = m_data.find(m_order[i]);
- ASSERT(it != m_data.end());
- if (i)
- output->append(',');
- doubleQuoteString(it->key, output);
- output->append(':');
- it->value->writeJSON(output);
- }
- output->append('}');
-}
-
-InspectorObjectBase::InspectorObjectBase()
- : InspectorValue(TypeObject)
- , m_data()
- , m_order()
-{
-}
-
-InspectorArrayBase::~InspectorArrayBase()
-{
-}
-
-bool InspectorArrayBase::asArray(RefPtr<InspectorArray>* output)
-{
- COMPILE_ASSERT(sizeof(InspectorArrayBase) == sizeof(InspectorArray), cannot_cast);
- *output = static_cast<InspectorArray*>(this);
- return true;
-}
-
-PassRefPtr<InspectorArray> InspectorArrayBase::asArray()
-{
- COMPILE_ASSERT(sizeof(InspectorArrayBase) == sizeof(InspectorArray), cannot_cast);
- return static_cast<InspectorArray*>(this);
-}
-
-void InspectorArrayBase::writeJSON(StringBuilder* output) const
-{
- output->append('[');
- for (Vector<RefPtr<InspectorValue> >::const_iterator it = m_data.begin(); it != m_data.end(); ++it) {
- if (it != m_data.begin())
- output->append(',');
- (*it)->writeJSON(output);
- }
- output->append(']');
-}
-
-InspectorArrayBase::InspectorArrayBase()
- : InspectorValue(TypeArray)
- , m_data()
-{
-}
-
-PassRefPtr<InspectorValue> InspectorArrayBase::get(size_t index)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size());
- return m_data[index];
-}
-
-} // namespace WebCore
diff --git a/Source/core/inspector/InspectorValues.h b/Source/core/inspector/InspectorValues.h
deleted file mode 100644
index 1f0aecb..0000000
--- a/Source/core/inspector/InspectorValues.h
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef InspectorValues_h
-#define InspectorValues_h
-
-#include <wtf/Forward.h>
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-class InspectorArray;
-class InspectorObject;
-
-class InspectorValue : public RefCounted<InspectorValue> {
-public:
- static const int maxDepth = 1000;
-
- InspectorValue() : m_type(TypeNull) { }
- virtual ~InspectorValue() { }
-
- static PassRefPtr<InspectorValue> null()
- {
- return adoptRef(new InspectorValue());
- }
-
- typedef enum {
- TypeNull = 0,
- TypeBoolean,
- TypeNumber,
- TypeString,
- TypeObject,
- TypeArray
- } Type;
-
- Type type() const { return m_type; }
-
- bool isNull() const { return m_type == TypeNull; }
-
- virtual bool asBoolean(bool* output) const;
- virtual bool asNumber(double* output) const;
- virtual bool asNumber(long* output) const;
- virtual bool asNumber(int* output) const;
- virtual bool asNumber(unsigned long* output) const;
- virtual bool asNumber(unsigned int* output) const;
- virtual bool asString(String* output) const;
- virtual bool asValue(RefPtr<InspectorValue>* output);
- virtual bool asObject(RefPtr<InspectorObject>* output);
- virtual bool asArray(RefPtr<InspectorArray>* output);
- virtual PassRefPtr<InspectorObject> asObject();
- virtual PassRefPtr<InspectorArray> asArray();
-
- static PassRefPtr<InspectorValue> parseJSON(const String& json);
-
- String toJSONString() const;
- virtual void writeJSON(StringBuilder* output) const;
-
-protected:
- explicit InspectorValue(Type type) : m_type(type) { }
-
-private:
- Type m_type;
-};
-
-class InspectorBasicValue : public InspectorValue {
-public:
-
- static PassRefPtr<InspectorBasicValue> create(bool value)
- {
- return adoptRef(new InspectorBasicValue(value));
- }
-
- static PassRefPtr<InspectorBasicValue> create(int value)
- {
- return adoptRef(new InspectorBasicValue(value));
- }
-
- static PassRefPtr<InspectorBasicValue> create(double value)
- {
- return adoptRef(new InspectorBasicValue(value));
- }
-
- virtual bool asBoolean(bool* output) const;
- virtual bool asNumber(double* output) const;
- virtual bool asNumber(long* output) const;
- virtual bool asNumber(int* output) const;
- virtual bool asNumber(unsigned long* output) const;
- virtual bool asNumber(unsigned int* output) const;
-
- virtual void writeJSON(StringBuilder* output) const;
-
-private:
- explicit InspectorBasicValue(bool value) : InspectorValue(TypeBoolean), m_boolValue(value) { }
- explicit InspectorBasicValue(int value) : InspectorValue(TypeNumber), m_doubleValue((double)value) { }
- explicit InspectorBasicValue(double value) : InspectorValue(TypeNumber), m_doubleValue(value) { }
-
- union {
- bool m_boolValue;
- double m_doubleValue;
- };
-};
-
-class InspectorString : public InspectorValue {
-public:
- static PassRefPtr<InspectorString> create(const String& value)
- {
- return adoptRef(new InspectorString(value));
- }
-
- static PassRefPtr<InspectorString> create(const char* value)
- {
- return adoptRef(new InspectorString(value));
- }
-
- virtual bool asString(String* output) const;
-
- virtual void writeJSON(StringBuilder* output) const;
-
-private:
- explicit InspectorString(const String& value) : InspectorValue(TypeString), m_stringValue(value) { }
- explicit InspectorString(const char* value) : InspectorValue(TypeString), m_stringValue(value) { }
-
- String m_stringValue;
-};
-
-class InspectorObjectBase : public InspectorValue {
-private:
- typedef HashMap<String, RefPtr<InspectorValue> > Dictionary;
-
-public:
- typedef Dictionary::iterator iterator;
- typedef Dictionary::const_iterator const_iterator;
-
- virtual PassRefPtr<InspectorObject> asObject();
- InspectorObject* openAccessors();
-
-protected:
- ~InspectorObjectBase();
-
- virtual bool asObject(RefPtr<InspectorObject>* output);
-
- void setBoolean(const String& name, bool);
- void setNumber(const String& name, double);
- void setString(const String& name, const String&);
- void setValue(const String& name, PassRefPtr<InspectorValue>);
- void setObject(const String& name, PassRefPtr<InspectorObject>);
- void setArray(const String& name, PassRefPtr<InspectorArray>);
-
- iterator find(const String& name);
- const_iterator find(const String& name) const;
- bool getBoolean(const String& name, bool* output) const;
- template<class T> bool getNumber(const String& name, T* output) const
- {
- RefPtr<InspectorValue> value = get(name);
- if (!value)
- return false;
- return value->asNumber(output);
- }
- bool getString(const String& name, String* output) const;
- PassRefPtr<InspectorObject> getObject(const String& name) const;
- PassRefPtr<InspectorArray> getArray(const String& name) const;
- PassRefPtr<InspectorValue> get(const String& name) const;
-
- void remove(const String& name);
-
- virtual void writeJSON(StringBuilder* output) const;
-
- iterator begin() { return m_data.begin(); }
- iterator end() { return m_data.end(); }
- const_iterator begin() const { return m_data.begin(); }
- const_iterator end() const { return m_data.end(); }
-
- int size() const { return m_data.size(); }
-
-protected:
- InspectorObjectBase();
-
-private:
- Dictionary m_data;
- Vector<String> m_order;
-};
-
-class InspectorObject : public InspectorObjectBase {
-public:
- static PassRefPtr<InspectorObject> create()
- {
- return adoptRef(new InspectorObject());
- }
-
- using InspectorObjectBase::asObject;
-
- using InspectorObjectBase::setBoolean;
- using InspectorObjectBase::setNumber;
- using InspectorObjectBase::setString;
- using InspectorObjectBase::setValue;
- using InspectorObjectBase::setObject;
- using InspectorObjectBase::setArray;
-
- using InspectorObjectBase::find;
- using InspectorObjectBase::getBoolean;
- using InspectorObjectBase::getNumber;
- using InspectorObjectBase::getString;
- using InspectorObjectBase::getObject;
- using InspectorObjectBase::getArray;
- using InspectorObjectBase::get;
-
- using InspectorObjectBase::remove;
-
- using InspectorObjectBase::begin;
- using InspectorObjectBase::end;
-
- using InspectorObjectBase::size;
-};
-
-
-class InspectorArrayBase : public InspectorValue {
-public:
- typedef Vector<RefPtr<InspectorValue> >::iterator iterator;
- typedef Vector<RefPtr<InspectorValue> >::const_iterator const_iterator;
-
- virtual PassRefPtr<InspectorArray> asArray();
-
- unsigned length() const { return m_data.size(); }
-
-protected:
- ~InspectorArrayBase();
-
- virtual bool asArray(RefPtr<InspectorArray>* output);
-
- void pushBoolean(bool);
- void pushInt(int);
- void pushNumber(double);
- void pushString(const String&);
- void pushValue(PassRefPtr<InspectorValue>);
- void pushObject(PassRefPtr<InspectorObject>);
- void pushArray(PassRefPtr<InspectorArray>);
-
- PassRefPtr<InspectorValue> get(size_t index);
-
- virtual void writeJSON(StringBuilder* output) const;
-
- iterator begin() { return m_data.begin(); }
- iterator end() { return m_data.end(); }
- const_iterator begin() const { return m_data.begin(); }
- const_iterator end() const { return m_data.end(); }
-
-protected:
- InspectorArrayBase();
-
-private:
- Vector<RefPtr<InspectorValue> > m_data;
-};
-
-class InspectorArray : public InspectorArrayBase {
-public:
- static PassRefPtr<InspectorArray> create()
- {
- return adoptRef(new InspectorArray());
- }
-
- using InspectorArrayBase::asArray;
-
- using InspectorArrayBase::pushBoolean;
- using InspectorArrayBase::pushInt;
- using InspectorArrayBase::pushNumber;
- using InspectorArrayBase::pushString;
- using InspectorArrayBase::pushValue;
- using InspectorArrayBase::pushObject;
- using InspectorArrayBase::pushArray;
-
- using InspectorArrayBase::get;
-
- using InspectorArrayBase::begin;
- using InspectorArrayBase::end;
-};
-
-
-inline InspectorObjectBase::iterator InspectorObjectBase::find(const String& name)
-{
- return m_data.find(name);
-}
-
-inline InspectorObjectBase::const_iterator InspectorObjectBase::find(const String& name) const
-{
- return m_data.find(name);
-}
-
-inline void InspectorObjectBase::setBoolean(const String& name, bool value)
-{
- setValue(name, InspectorBasicValue::create(value));
-}
-
-inline void InspectorObjectBase::setNumber(const String& name, double value)
-{
- setValue(name, InspectorBasicValue::create(value));
-}
-
-inline void InspectorObjectBase::setString(const String& name, const String& value)
-{
- setValue(name, InspectorString::create(value));
-}
-
-inline void InspectorObjectBase::setValue(const String& name, PassRefPtr<InspectorValue> value)
-{
- ASSERT(value);
- if (m_data.set(name, value).isNewEntry)
- m_order.append(name);
-}
-
-inline void InspectorObjectBase::setObject(const String& name, PassRefPtr<InspectorObject> value)
-{
- ASSERT(value);
- if (m_data.set(name, value).isNewEntry)
- m_order.append(name);
-}
-
-inline void InspectorObjectBase::setArray(const String& name, PassRefPtr<InspectorArray> value)
-{
- ASSERT(value);
- if (m_data.set(name, value).isNewEntry)
- m_order.append(name);
-}
-
-inline void InspectorArrayBase::pushBoolean(bool value)
-{
- m_data.append(InspectorBasicValue::create(value));
-}
-
-inline void InspectorArrayBase::pushInt(int value)
-{
- m_data.append(InspectorBasicValue::create(value));
-}
-
-inline void InspectorArrayBase::pushNumber(double value)
-{
- m_data.append(InspectorBasicValue::create(value));
-}
-
-inline void InspectorArrayBase::pushString(const String& value)
-{
- m_data.append(InspectorString::create(value));
-}
-
-inline void InspectorArrayBase::pushValue(PassRefPtr<InspectorValue> value)
-{
- ASSERT(value);
- m_data.append(value);
-}
-
-inline void InspectorArrayBase::pushObject(PassRefPtr<InspectorObject> value)
-{
- ASSERT(value);
- m_data.append(value);
-}
-
-inline void InspectorArrayBase::pushArray(PassRefPtr<InspectorArray> value)
-{
- ASSERT(value);
- m_data.append(value);
-}
-
-} // namespace WebCore
-
-#endif // !defined(InspectorValues_h)
diff --git a/Source/core/inspector/InspectorWorkerAgent.cpp b/Source/core/inspector/InspectorWorkerAgent.cpp
index e77d62e..4665d47 100644
--- a/Source/core/inspector/InspectorWorkerAgent.cpp
+++ b/Source/core/inspector/InspectorWorkerAgent.cpp
@@ -34,9 +34,10 @@
#include "InspectorFrontend.h"
#include "core/inspector/InspectorState.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/InstrumentingAgents.h"
-#include "core/workers/WorkerContextProxy.h"
+#include "core/inspector/JSONParser.h"
+#include "core/platform/JSONValues.h"
+#include "core/workers/WorkerGlobalScopeProxy.h"
#include "weborigin/KURL.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefPtr.h"
@@ -48,10 +49,10 @@
static const char autoconnectToWorkers[] = "autoconnectToWorkers";
};
-class InspectorWorkerAgent::WorkerFrontendChannel : public WorkerContextProxy::PageInspector {
+class InspectorWorkerAgent::WorkerFrontendChannel : public WorkerGlobalScopeProxy::PageInspector {
WTF_MAKE_FAST_ALLOCATED;
public:
- explicit WorkerFrontendChannel(InspectorFrontend* frontend, WorkerContextProxy* proxy)
+ explicit WorkerFrontendChannel(InspectorFrontend* frontend, WorkerGlobalScopeProxy* proxy)
: m_frontend(frontend)
, m_proxy(proxy)
, m_id(s_nextId++)
@@ -60,13 +61,13 @@
}
virtual ~WorkerFrontendChannel()
{
- disconnectFromWorkerContext();
+ disconnectFromWorkerGlobalScope();
}
int id() const { return m_id; }
- WorkerContextProxy* proxy() const { return m_proxy; }
+ WorkerGlobalScopeProxy* proxy() const { return m_proxy; }
- void connectToWorkerContext()
+ void connectToWorkerGlobalScope()
{
if (m_connected)
return;
@@ -74,7 +75,7 @@
m_proxy->connectToInspector(this);
}
- void disconnectFromWorkerContext()
+ void disconnectFromWorkerGlobalScope()
{
if (!m_connected)
return;
@@ -83,20 +84,20 @@
}
private:
- // WorkerContextProxy::PageInspector implementation
+ // WorkerGlobalScopeProxy::PageInspector implementation
virtual void dispatchMessageFromWorker(const String& message)
{
- RefPtr<InspectorValue> value = InspectorValue::parseJSON(message);
+ RefPtr<JSONValue> value = parseJSON(message);
if (!value)
return;
- RefPtr<InspectorObject> messageObject = value->asObject();
+ RefPtr<JSONObject> messageObject = value->asObject();
if (!messageObject)
return;
m_frontend->worker()->dispatchMessageFromWorker(m_id, messageObject);
}
InspectorFrontend* m_frontend;
- WorkerContextProxy* m_proxy;
+ WorkerGlobalScopeProxy* m_proxy;
int m_id;
bool m_connected;
static int s_nextId;
@@ -164,7 +165,7 @@
{
WorkerFrontendChannel* channel = m_idToChannel.get(workerId);
if (channel)
- channel->connectToWorkerContext();
+ channel->connectToWorkerGlobalScope();
else
*error = "Worker is gone";
}
@@ -173,12 +174,12 @@
{
WorkerFrontendChannel* channel = m_idToChannel.get(workerId);
if (channel)
- channel->disconnectFromWorkerContext();
+ channel->disconnectFromWorkerGlobalScope();
else
*error = "Worker is gone";
}
-void InspectorWorkerAgent::sendMessageToWorker(ErrorString* error, int workerId, const RefPtr<InspectorObject>& message)
+void InspectorWorkerAgent::sendMessageToWorker(ErrorString* error, int workerId, const RefPtr<JSONObject>& message)
{
WorkerFrontendChannel* channel = m_idToChannel.get(workerId);
if (channel)
@@ -197,14 +198,14 @@
return m_state->getBoolean(WorkerAgentState::autoconnectToWorkers);
}
-void InspectorWorkerAgent::didStartWorkerContext(WorkerContextProxy* workerContextProxy, const KURL& url)
+void InspectorWorkerAgent::didStartWorkerGlobalScope(WorkerGlobalScopeProxy* workerGlobalScopeProxy, const KURL& url)
{
- m_dedicatedWorkers.set(workerContextProxy, url.string());
+ m_dedicatedWorkers.set(workerGlobalScopeProxy, url.string());
if (m_inspectorFrontend && m_state->getBoolean(WorkerAgentState::workerInspectionEnabled))
- createWorkerFrontendChannel(workerContextProxy, url.string());
+ createWorkerFrontendChannel(workerGlobalScopeProxy, url.string());
}
-void InspectorWorkerAgent::workerContextTerminated(WorkerContextProxy* proxy)
+void InspectorWorkerAgent::workerGlobalScopeTerminated(WorkerGlobalScopeProxy* proxy)
{
m_dedicatedWorkers.remove(proxy);
for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) {
@@ -226,21 +227,21 @@
void InspectorWorkerAgent::destroyWorkerFrontendChannels()
{
for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) {
- it->value->disconnectFromWorkerContext();
+ it->value->disconnectFromWorkerGlobalScope();
delete it->value;
}
m_idToChannel.clear();
}
-void InspectorWorkerAgent::createWorkerFrontendChannel(WorkerContextProxy* workerContextProxy, const String& url)
+void InspectorWorkerAgent::createWorkerFrontendChannel(WorkerGlobalScopeProxy* workerGlobalScopeProxy, const String& url)
{
- WorkerFrontendChannel* channel = new WorkerFrontendChannel(m_inspectorFrontend, workerContextProxy);
+ WorkerFrontendChannel* channel = new WorkerFrontendChannel(m_inspectorFrontend, workerGlobalScopeProxy);
m_idToChannel.set(channel->id(), channel);
ASSERT(m_inspectorFrontend);
bool autoconnectToWorkers = m_state->getBoolean(WorkerAgentState::autoconnectToWorkers);
if (autoconnectToWorkers)
- channel->connectToWorkerContext();
+ channel->connectToWorkerGlobalScope();
m_inspectorFrontend->worker()->workerCreated(channel->id(), url, autoconnectToWorkers);
}
diff --git a/Source/core/inspector/InspectorWorkerAgent.h b/Source/core/inspector/InspectorWorkerAgent.h
index 4f53b1f..74146aa 100644
--- a/Source/core/inspector/InspectorWorkerAgent.h
+++ b/Source/core/inspector/InspectorWorkerAgent.h
@@ -37,11 +37,11 @@
namespace WebCore {
class InspectorFrontend;
-class InspectorObject;
class InspectorState;
class InstrumentingAgents;
+class JSONObject;
class KURL;
-class WorkerContextProxy;
+class WorkerGlobalScopeProxy;
typedef String ErrorString;
@@ -56,8 +56,8 @@
// Called from InspectorInstrumentation
bool shouldPauseDedicatedWorkerOnStart();
- void didStartWorkerContext(WorkerContextProxy*, const KURL&);
- void workerContextTerminated(WorkerContextProxy*);
+ void didStartWorkerGlobalScope(WorkerGlobalScopeProxy*, const KURL&);
+ void workerGlobalScopeTerminated(WorkerGlobalScopeProxy*);
// Called from InspectorBackendDispatcher
virtual void enable(ErrorString*);
@@ -65,13 +65,13 @@
virtual void canInspectWorkers(ErrorString*, bool*);
virtual void connectToWorker(ErrorString*, int workerId);
virtual void disconnectFromWorker(ErrorString*, int workerId);
- virtual void sendMessageToWorker(ErrorString*, int workerId, const RefPtr<InspectorObject>& message);
+ virtual void sendMessageToWorker(ErrorString*, int workerId, const RefPtr<JSONObject>& message);
virtual void setAutoconnectToWorkers(ErrorString*, bool value);
private:
InspectorWorkerAgent(InstrumentingAgents*, InspectorCompositeState*);
void createWorkerFrontendChannelsForExistingWorkers();
- void createWorkerFrontendChannel(WorkerContextProxy*, const String& url);
+ void createWorkerFrontendChannel(WorkerGlobalScopeProxy*, const String& url);
void destroyWorkerFrontendChannels();
InspectorFrontend* m_inspectorFrontend;
@@ -79,7 +79,7 @@
class WorkerFrontendChannel;
typedef HashMap<int, WorkerFrontendChannel*> WorkerChannels;
WorkerChannels m_idToChannel;
- typedef HashMap<WorkerContextProxy*, String> DedicatedWorkers;
+ typedef HashMap<WorkerGlobalScopeProxy*, String> DedicatedWorkers;
DedicatedWorkers m_dedicatedWorkers;
};
diff --git a/Source/core/inspector/JSONParser.cpp b/Source/core/inspector/JSONParser.cpp
new file mode 100644
index 0000000..bf364db
--- /dev/null
+++ b/Source/core/inspector/JSONParser.cpp
@@ -0,0 +1,478 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "core/inspector/JSONParser.h"
+
+#include "core/platform/JSONValues.h"
+#include "wtf/text/StringBuilder.h"
+
+namespace WebCore {
+
+namespace {
+
+const int stackLimit = 1000;
+
+enum Token {
+ ObjectBegin,
+ ObjectEnd,
+ ArrayBegin,
+ ArrayEnd,
+ StringLiteral,
+ Number,
+ BoolTrue,
+ BoolFalse,
+ NullToken,
+ ListSeparator,
+ ObjectPairSeparator,
+ InvalidToken,
+};
+
+const char* const nullString = "null";
+const char* const trueString = "true";
+const char* const falseString = "false";
+
+template<typename CharType>
+bool parseConstToken(const CharType* start, const CharType* end, const CharType** tokenEnd, const char* token)
+{
+ while (start < end && *token != '\0' && *start++ == *token++) { }
+ if (*token != '\0')
+ return false;
+ *tokenEnd = start;
+ return true;
+}
+
+template<typename CharType>
+bool readInt(const CharType* start, const CharType* end, const CharType** tokenEnd, bool canHaveLeadingZeros)
+{
+ if (start == end)
+ return false;
+ bool haveLeadingZero = '0' == *start;
+ int length = 0;
+ while (start < end && '0' <= *start && *start <= '9') {
+ ++start;
+ ++length;
+ }
+ if (!length)
+ return false;
+ if (!canHaveLeadingZeros && length > 1 && haveLeadingZero)
+ return false;
+ *tokenEnd = start;
+ return true;
+}
+
+template<typename CharType>
+bool parseNumberToken(const CharType* start, const CharType* end, const CharType** tokenEnd)
+{
+ // We just grab the number here. We validate the size in DecodeNumber.
+ // According to RFC4627, a valid number is: [minus] int [frac] [exp]
+ if (start == end)
+ return false;
+ CharType c = *start;
+ if ('-' == c)
+ ++start;
+
+ if (!readInt(start, end, &start, false))
+ return false;
+ if (start == end) {
+ *tokenEnd = start;
+ return true;
+ }
+
+ // Optional fraction part
+ c = *start;
+ if ('.' == c) {
+ ++start;
+ if (!readInt(start, end, &start, true))
+ return false;
+ if (start == end) {
+ *tokenEnd = start;
+ return true;
+ }
+ c = *start;
+ }
+
+ // Optional exponent part
+ if ('e' == c || 'E' == c) {
+ ++start;
+ if (start == end)
+ return false;
+ c = *start;
+ if ('-' == c || '+' == c) {
+ ++start;
+ if (start == end)
+ return false;
+ }
+ if (!readInt(start, end, &start, true))
+ return false;
+ }
+
+ *tokenEnd = start;
+ return true;
+}
+
+template<typename CharType>
+bool readHexDigits(const CharType* start, const CharType* end, const CharType** tokenEnd, int digits)
+{
+ if (end - start < digits)
+ return false;
+ for (int i = 0; i < digits; ++i) {
+ CharType c = *start++;
+ if (!(('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')))
+ return false;
+ }
+ *tokenEnd = start;
+ return true;
+}
+
+template<typename CharType>
+bool parseStringToken(const CharType* start, const CharType* end, const CharType** tokenEnd)
+{
+ while (start < end) {
+ CharType c = *start++;
+ if ('\\' == c) {
+ c = *start++;
+ // Make sure the escaped char is valid.
+ switch (c) {
+ case 'x':
+ if (!readHexDigits(start, end, &start, 2))
+ return false;
+ break;
+ case 'u':
+ if (!readHexDigits(start, end, &start, 4))
+ return false;
+ break;
+ case '\\':
+ case '/':
+ case 'b':
+ case 'f':
+ case 'n':
+ case 'r':
+ case 't':
+ case 'v':
+ case '"':
+ break;
+ default:
+ return false;
+ }
+ } else if ('"' == c) {
+ *tokenEnd = start;
+ return true;
+ }
+ }
+ return false;
+}
+
+template<typename CharType>
+Token parseToken(const CharType* start, const CharType* end, const CharType** tokenStart, const CharType** tokenEnd)
+{
+ while (start < end && isSpaceOrNewline(*start))
+ ++start;
+
+ if (start == end)
+ return InvalidToken;
+
+ *tokenStart = start;
+
+ switch (*start) {
+ case 'n':
+ if (parseConstToken(start, end, tokenEnd, nullString))
+ return NullToken;
+ break;
+ case 't':
+ if (parseConstToken(start, end, tokenEnd, trueString))
+ return BoolTrue;
+ break;
+ case 'f':
+ if (parseConstToken(start, end, tokenEnd, falseString))
+ return BoolFalse;
+ break;
+ case '[':
+ *tokenEnd = start + 1;
+ return ArrayBegin;
+ case ']':
+ *tokenEnd = start + 1;
+ return ArrayEnd;
+ case ',':
+ *tokenEnd = start + 1;
+ return ListSeparator;
+ case '{':
+ *tokenEnd = start + 1;
+ return ObjectBegin;
+ case '}':
+ *tokenEnd = start + 1;
+ return ObjectEnd;
+ case ':':
+ *tokenEnd = start + 1;
+ return ObjectPairSeparator;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '-':
+ if (parseNumberToken(start, end, tokenEnd))
+ return Number;
+ break;
+ case '"':
+ if (parseStringToken(start + 1, end, tokenEnd))
+ return StringLiteral;
+ break;
+ }
+ return InvalidToken;
+}
+
+template<typename CharType>
+inline int hexToInt(CharType c)
+{
+ if ('0' <= c && c <= '9')
+ return c - '0';
+ if ('A' <= c && c <= 'F')
+ return c - 'A' + 10;
+ if ('a' <= c && c <= 'f')
+ return c - 'a' + 10;
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+template<typename CharType>
+bool decodeString(const CharType* start, const CharType* end, StringBuilder* output)
+{
+ while (start < end) {
+ CharType c = *start++;
+ if ('\\' != c) {
+ output->append(c);
+ continue;
+ }
+ c = *start++;
+ switch (c) {
+ case '"':
+ case '/':
+ case '\\':
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'v':
+ c = '\v';
+ break;
+ case 'x':
+ c = (hexToInt(*start) << 4) +
+ hexToInt(*(start + 1));
+ start += 2;
+ break;
+ case 'u':
+ c = (hexToInt(*start) << 12) +
+ (hexToInt(*(start + 1)) << 8) +
+ (hexToInt(*(start + 2)) << 4) +
+ hexToInt(*(start + 3));
+ start += 4;
+ break;
+ default:
+ return false;
+ }
+ output->append(c);
+ }
+ return true;
+}
+
+template<typename CharType>
+bool decodeString(const CharType* start, const CharType* end, String* output)
+{
+ if (start == end) {
+ *output = "";
+ return true;
+ }
+ if (start > end)
+ return false;
+ StringBuilder buffer;
+ buffer.reserveCapacity(end - start);
+ if (!decodeString(start, end, &buffer))
+ return false;
+ *output = buffer.toString();
+ return true;
+}
+
+template<typename CharType>
+PassRefPtr<JSONValue> buildValue(const CharType* start, const CharType* end, const CharType** valueTokenEnd, int depth)
+{
+ if (depth > stackLimit)
+ return 0;
+
+ RefPtr<JSONValue> result;
+ const CharType* tokenStart;
+ const CharType* tokenEnd;
+ Token token = parseToken(start, end, &tokenStart, &tokenEnd);
+ switch (token) {
+ case InvalidToken:
+ return 0;
+ case NullToken:
+ result = JSONValue::null();
+ break;
+ case BoolTrue:
+ result = JSONBasicValue::create(true);
+ break;
+ case BoolFalse:
+ result = JSONBasicValue::create(false);
+ break;
+ case Number: {
+ bool ok;
+ double value = charactersToDouble(tokenStart, tokenEnd - tokenStart, &ok);
+ if (!ok)
+ return 0;
+ result = JSONBasicValue::create(value);
+ break;
+ }
+ case StringLiteral: {
+ String value;
+ bool ok = decodeString(tokenStart + 1, tokenEnd - 1, &value);
+ if (!ok)
+ return 0;
+ result = JSONString::create(value);
+ break;
+ }
+ case ArrayBegin: {
+ RefPtr<JSONArray> array = JSONArray::create();
+ start = tokenEnd;
+ token = parseToken(start, end, &tokenStart, &tokenEnd);
+ while (token != ArrayEnd) {
+ RefPtr<JSONValue> arrayNode = buildValue(start, end, &tokenEnd, depth + 1);
+ if (!arrayNode)
+ return 0;
+ array->pushValue(arrayNode);
+
+ // After a list value, we expect a comma or the end of the list.
+ start = tokenEnd;
+ token = parseToken(start, end, &tokenStart, &tokenEnd);
+ if (token == ListSeparator) {
+ start = tokenEnd;
+ token = parseToken(start, end, &tokenStart, &tokenEnd);
+ if (token == ArrayEnd)
+ return 0;
+ } else if (token != ArrayEnd) {
+ // Unexpected value after list value. Bail out.
+ return 0;
+ }
+ }
+ if (token != ArrayEnd)
+ return 0;
+ result = array.release();
+ break;
+ }
+ case ObjectBegin: {
+ RefPtr<JSONObject> object = JSONObject::create();
+ start = tokenEnd;
+ token = parseToken(start, end, &tokenStart, &tokenEnd);
+ while (token != ObjectEnd) {
+ if (token != StringLiteral)
+ return 0;
+ String key;
+ if (!decodeString(tokenStart + 1, tokenEnd - 1, &key))
+ return 0;
+ start = tokenEnd;
+
+ token = parseToken(start, end, &tokenStart, &tokenEnd);
+ if (token != ObjectPairSeparator)
+ return 0;
+ start = tokenEnd;
+
+ RefPtr<JSONValue> value = buildValue(start, end, &tokenEnd, depth + 1);
+ if (!value)
+ return 0;
+ object->setValue(key, value);
+ start = tokenEnd;
+
+ // After a key/value pair, we expect a comma or the end of the
+ // object.
+ token = parseToken(start, end, &tokenStart, &tokenEnd);
+ if (token == ListSeparator) {
+ start = tokenEnd;
+ token = parseToken(start, end, &tokenStart, &tokenEnd);
+ if (token == ObjectEnd)
+ return 0;
+ } else if (token != ObjectEnd) {
+ // Unexpected value after last object value. Bail out.
+ return 0;
+ }
+ }
+ if (token != ObjectEnd)
+ return 0;
+ result = object.release();
+ break;
+ }
+
+ default:
+ // We got a token that's not a value.
+ return 0;
+ }
+ *valueTokenEnd = tokenEnd;
+ return result.release();
+}
+
+template<typename CharType>
+PassRefPtr<JSONValue> parseJSONInternal(const CharType* start, unsigned length)
+{
+ const CharType* end = start + length;
+ const CharType *tokenEnd;
+ RefPtr<JSONValue> value = buildValue(start, end, &tokenEnd, 0);
+ if (!value || tokenEnd != end)
+ return 0;
+ return value.release();
+}
+
+} // anonymous namespace
+
+PassRefPtr<JSONValue> parseJSON(const String& json)
+{
+ if (json.isEmpty())
+ return 0;
+ if (json.is8Bit())
+ return parseJSONInternal(json.characters8(), json.length());
+ return parseJSONInternal(json.characters16(), json.length());
+}
+
+} // namespace WebCore
diff --git a/Source/core/inspector/InspectorWorkerResource.h b/Source/core/inspector/JSONParser.h
similarity index 61%
rename from Source/core/inspector/InspectorWorkerResource.h
rename to Source/core/inspector/JSONParser.h
index f8bed52..7979944 100644
--- a/Source/core/inspector/InspectorWorkerResource.h
+++ b/Source/core/inspector/JSONParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Google 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
@@ -28,39 +28,18 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef InspectorWorkerResource_h
-#define InspectorWorkerResource_h
+#ifndef JSONParser_h
+#define JSONParser_h
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#include "wtf/PassRefPtr.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
-class InspectorWorkerResource : public RefCounted<InspectorWorkerResource> {
-public:
- static PassRefPtr<InspectorWorkerResource> create(intptr_t id, const String& url, bool isSharedWorker)
- {
- return adoptRef(new InspectorWorkerResource(id, url, isSharedWorker));
- }
+class JSONValue;
- intptr_t id() const { return m_id; }
- const String& url() const { return m_url; }
- bool isSharedWorker() const { return m_isSharedWorker; }
-private:
- InspectorWorkerResource(intptr_t id, const String& url, bool isSharedWorker)
- : m_id(id)
- , m_url(url)
- , m_isSharedWorker(isSharedWorker)
- {
- }
-
- intptr_t m_id;
- String m_url;
- bool m_isSharedWorker;
-};
+PassRefPtr<JSONValue> parseJSON(const String& json);
} // namespace WebCore
-#endif // InspectorWorkerResource_h
+#endif // !defined(JSONParser_h)
diff --git a/Source/core/inspector/MemoryInstrumentationImpl.cpp b/Source/core/inspector/MemoryInstrumentationImpl.cpp
index b13bb9c..467d2f4 100644
--- a/Source/core/inspector/MemoryInstrumentationImpl.cpp
+++ b/Source/core/inspector/MemoryInstrumentationImpl.cpp
@@ -33,11 +33,11 @@
#include "core/dom/WebCoreMemoryInstrumentation.h"
#include "core/inspector/HeapGraphSerializer.h"
-#include <wtf/Assertions.h>
-#include <wtf/MemoryInstrumentationHashMap.h>
-#include <wtf/MemoryInstrumentationHashSet.h>
-#include <wtf/MemoryInstrumentationVector.h>
-#include <wtf/text/StringHash.h>
+#include "wtf/Assertions.h"
+#include "wtf/MemoryInstrumentationHashMap.h"
+#include "wtf/MemoryInstrumentationHashSet.h"
+#include "wtf/MemoryInstrumentationVector.h"
+#include "wtf/text/StringHash.h"
namespace WebCore {
diff --git a/Source/core/inspector/NetworkResourcesData.h b/Source/core/inspector/NetworkResourcesData.h
index 101b9a0..6dc84e2 100644
--- a/Source/core/inspector/NetworkResourcesData.h
+++ b/Source/core/inspector/NetworkResourcesData.h
@@ -36,7 +36,6 @@
#include "wtf/Deque.h"
#include "wtf/HashMap.h"
#include "wtf/RefCounted.h"
-#include "wtf/text/StringBuilder.h"
#include "wtf/text/WTFString.h"
diff --git a/Source/core/inspector/ScriptCallFrame.cpp b/Source/core/inspector/ScriptCallFrame.cpp
index 65daa67..42433e3 100644
--- a/Source/core/inspector/ScriptCallFrame.cpp
+++ b/Source/core/inspector/ScriptCallFrame.cpp
@@ -31,8 +31,6 @@
#include "config.h"
#include "core/inspector/ScriptCallFrame.h"
-#include <wtf/RefPtr.h>
-
namespace WebCore {
ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& scriptName, unsigned lineNumber, unsigned column)
diff --git a/Source/core/inspector/ScriptCallFrame.h b/Source/core/inspector/ScriptCallFrame.h
index 93fc006..941c549 100644
--- a/Source/core/inspector/ScriptCallFrame.h
+++ b/Source/core/inspector/ScriptCallFrame.h
@@ -38,8 +38,6 @@
namespace WebCore {
-class InspectorObject;
-
class ScriptCallFrame {
public:
ScriptCallFrame(const String& functionName, const String& scriptName, unsigned lineNumber, unsigned column = 0);
diff --git a/Source/core/inspector/ScriptCallStack.h b/Source/core/inspector/ScriptCallStack.h
index 3796fe1..ce605ea 100644
--- a/Source/core/inspector/ScriptCallStack.h
+++ b/Source/core/inspector/ScriptCallStack.h
@@ -40,8 +40,6 @@
namespace WebCore {
-class InspectorArray;
-
class ScriptCallStack : public RefCounted<ScriptCallStack> {
public:
static const size_t maxCallStackSizeToCapture = 200;
diff --git a/Source/core/inspector/ScriptProfile.cpp b/Source/core/inspector/ScriptProfile.cpp
index 2683c6a..f1f76d3 100644
--- a/Source/core/inspector/ScriptProfile.cpp
+++ b/Source/core/inspector/ScriptProfile.cpp
@@ -72,6 +72,7 @@
RefPtr<TypeBuilder::Profiler::CPUProfileNode> result = TypeBuilder::Profiler::CPUProfileNode::create()
.setFunctionName(toWebCoreString(node->GetFunctionName()))
+ .setScriptId(String::number(node->GetScriptId()))
.setUrl(toWebCoreString(node->GetScriptResourceName()))
.setLineNumber(node->GetLineNumber())
.setTotalTime(node->GetTotalTime())
diff --git a/Source/core/inspector/ScriptProfile.h b/Source/core/inspector/ScriptProfile.h
index de58931..19afeac 100644
--- a/Source/core/inspector/ScriptProfile.h
+++ b/Source/core/inspector/ScriptProfile.h
@@ -41,8 +41,6 @@
namespace WebCore {
-class InspectorObject;
-
class ScriptProfile : public RefCounted<ScriptProfile> {
public:
static PassRefPtr<ScriptProfile> create(const v8::CpuProfile* profile, double idleTime)
diff --git a/Source/core/inspector/TimelineRecordFactory.cpp b/Source/core/inspector/TimelineRecordFactory.cpp
index 3e12727..3f9afe3 100644
--- a/Source/core/inspector/TimelineRecordFactory.cpp
+++ b/Source/core/inspector/TimelineRecordFactory.cpp
@@ -33,19 +33,19 @@
#include "bindings/v8/ScriptCallStackFactory.h"
#include "core/dom/Event.h"
-#include "core/inspector/InspectorValues.h"
#include "core/inspector/ScriptCallStack.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/graphics/FloatQuad.h"
#include "core/platform/graphics/LayoutRect.h"
#include "core/platform/network/ResourceRequest.h"
#include "core/platform/network/ResourceResponse.h"
-#include <wtf/CurrentTime.h>
+#include "wtf/CurrentTime.h"
namespace WebCore {
-PassRefPtr<InspectorObject> TimelineRecordFactory::createGenericRecord(double startTime, int maxCallStackDepth, const String& type)
+PassRefPtr<JSONObject> TimelineRecordFactory::createGenericRecord(double startTime, int maxCallStackDepth, const String& type)
{
- RefPtr<InspectorObject> record = InspectorObject::create();
+ RefPtr<JSONObject> record = JSONObject::create();
record->setNumber("startTime", startTime);
if (maxCallStackDepth) {
@@ -57,110 +57,110 @@
return record.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createBackgroundRecord(double startTime, const String& threadName)
+PassRefPtr<JSONObject> TimelineRecordFactory::createBackgroundRecord(double startTime, const String& threadName)
{
- RefPtr<InspectorObject> record = InspectorObject::create();
+ RefPtr<JSONObject> record = JSONObject::create();
record->setNumber("startTime", startTime);
record->setString("thread", threadName);
return record.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createGCEventData(const size_t usedHeapSizeDelta)
+PassRefPtr<JSONObject> TimelineRecordFactory::createGCEventData(const size_t usedHeapSizeDelta)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("usedHeapSizeDelta", usedHeapSizeDelta);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createFunctionCallData(const String& scriptName, int scriptLine)
+PassRefPtr<JSONObject> TimelineRecordFactory::createFunctionCallData(const String& scriptName, int scriptLine)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("scriptName", scriptName);
data->setNumber("scriptLine", scriptLine);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createEventDispatchData(const Event& event)
+PassRefPtr<JSONObject> TimelineRecordFactory::createEventDispatchData(const Event& event)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("type", event.type().string());
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createGenericTimerData(int timerId)
+PassRefPtr<JSONObject> TimelineRecordFactory::createGenericTimerData(int timerId)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("timerId", timerId);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, int timeout, bool singleShot)
+PassRefPtr<JSONObject> TimelineRecordFactory::createTimerInstallData(int timerId, int timeout, bool singleShot)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("timerId", timerId);
data->setNumber("timeout", timeout);
data->setBoolean("singleShot", singleShot);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createXHRReadyStateChangeData(const String& url, int readyState)
+PassRefPtr<JSONObject> TimelineRecordFactory::createXHRReadyStateChangeData(const String& url, int readyState)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("url", url);
data->setNumber("readyState", readyState);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createXHRLoadData(const String& url)
+PassRefPtr<JSONObject> TimelineRecordFactory::createXHRLoadData(const String& url)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("url", url);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createEvaluateScriptData(const String& url, double lineNumber)
+PassRefPtr<JSONObject> TimelineRecordFactory::createEvaluateScriptData(const String& url, double lineNumber)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("url", url);
data->setNumber("lineNumber", lineNumber);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createTimeStampData(const String& message)
+PassRefPtr<JSONObject> TimelineRecordFactory::createTimeStampData(const String& message)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("message", message);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createScheduleResourceRequestData(const String& url)
+PassRefPtr<JSONObject> TimelineRecordFactory::createScheduleResourceRequestData(const String& url)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("url", url);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceSendRequestData(const String& requestId, const ResourceRequest& request)
+PassRefPtr<JSONObject> TimelineRecordFactory::createResourceSendRequestData(const String& requestId, const ResourceRequest& request)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("requestId", requestId);
data->setString("url", request.url().string());
data->setString("requestMethod", request.httpMethod());
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceReceiveResponseData(const String& requestId, const ResourceResponse& response)
+PassRefPtr<JSONObject> TimelineRecordFactory::createResourceReceiveResponseData(const String& requestId, const ResourceResponse& response)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("requestId", requestId);
data->setNumber("statusCode", response.httpStatusCode());
data->setString("mimeType", response.mimeType());
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceFinishData(const String& requestId, bool didFail, double finishTime)
+PassRefPtr<JSONObject> TimelineRecordFactory::createResourceFinishData(const String& requestId, bool didFail, double finishTime)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("requestId", requestId);
data->setBoolean("didFail", didFail);
if (finishTime)
@@ -168,61 +168,61 @@
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createReceiveResourceData(const String& requestId, int length)
+PassRefPtr<JSONObject> TimelineRecordFactory::createReceiveResourceData(const String& requestId, int length)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("requestId", requestId);
data->setNumber("encodedDataLength", length);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout)
+PassRefPtr<JSONObject> TimelineRecordFactory::createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("dirtyObjects", dirtyObjects);
data->setNumber("totalObjects", totalObjects);
data->setBoolean("partialLayout", partialLayout);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createDecodeImageData(const String& imageType)
+PassRefPtr<JSONObject> TimelineRecordFactory::createDecodeImageData(const String& imageType)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setString("imageType", imageType);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createResizeImageData(bool shouldCache)
+PassRefPtr<JSONObject> TimelineRecordFactory::createResizeImageData(bool shouldCache)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setBoolean("cached", shouldCache);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createMarkData(bool isMainFrame)
+PassRefPtr<JSONObject> TimelineRecordFactory::createMarkData(bool isMainFrame)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setBoolean("isMainFrame", isMainFrame);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createParseHTMLData(unsigned startLine)
+PassRefPtr<JSONObject> TimelineRecordFactory::createParseHTMLData(unsigned startLine)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("startLine", startLine);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createAnimationFrameData(int callbackId)
+PassRefPtr<JSONObject> TimelineRecordFactory::createAnimationFrameData(int callbackId)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("id", callbackId);
return data.release();
}
-static PassRefPtr<InspectorArray> createQuad(const FloatQuad& quad)
+static PassRefPtr<JSONArray> createQuad(const FloatQuad& quad)
{
- RefPtr<InspectorArray> array = InspectorArray::create();
+ RefPtr<JSONArray> array = JSONArray::create();
array->pushNumber(quad.p1().x());
array->pushNumber(quad.p1().y());
array->pushNumber(quad.p2().x());
@@ -234,29 +234,29 @@
return array.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createLayerData(long long layerRootNodeId)
+PassRefPtr<JSONObject> TimelineRecordFactory::createLayerData(long long layerRootNodeId)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
if (layerRootNodeId)
data->setNumber("layerRootNode", layerRootNodeId);
return data.release();
}
-PassRefPtr<InspectorObject> TimelineRecordFactory::createPaintData(const FloatQuad& quad, long long layerRootNodeId)
+PassRefPtr<JSONObject> TimelineRecordFactory::createPaintData(const FloatQuad& quad, long long layerRootNodeId)
{
- RefPtr<InspectorObject> data = TimelineRecordFactory::createLayerData(layerRootNodeId);
+ RefPtr<JSONObject> data = TimelineRecordFactory::createLayerData(layerRootNodeId);
data->setArray("clip", createQuad(quad));
return data.release();
}
-void TimelineRecordFactory::appendLayoutRoot(InspectorObject* data, const FloatQuad& quad, long long rootNodeId)
+void TimelineRecordFactory::appendLayoutRoot(JSONObject* data, const FloatQuad& quad, long long rootNodeId)
{
data->setArray("root", createQuad(quad));
if (rootNodeId)
data->setNumber("rootNode", rootNodeId);
}
-void TimelineRecordFactory::appendStyleRecalcDetails(InspectorObject* data, unsigned elementCount)
+void TimelineRecordFactory::appendStyleRecalcDetails(JSONObject* data, unsigned elementCount)
{
data->setNumber("elementCount", elementCount);
}
diff --git a/Source/core/inspector/TimelineRecordFactory.h b/Source/core/inspector/TimelineRecordFactory.h
index de97280..9fb244d 100644
--- a/Source/core/inspector/TimelineRecordFactory.h
+++ b/Source/core/inspector/TimelineRecordFactory.h
@@ -31,8 +31,7 @@
#ifndef TimelineRecordFactory_h
#define TimelineRecordFactory_h
-#include "core/inspector/InspectorValues.h"
-#include "core/platform/graphics/LayoutRect.h"
+#include "core/platform/JSONValues.h"
#include "weborigin/KURL.h"
#include "wtf/Forward.h"
#include "wtf/text/WTFString.h"
@@ -42,67 +41,66 @@
class Event;
class FloatQuad;
class InspectorFrontend;
- class InspectorObject;
class IntRect;
class ResourceRequest;
class ResourceResponse;
class TimelineRecordFactory {
public:
- static PassRefPtr<InspectorObject> createGenericRecord(double startTime, int maxCallStackDepth, const String& type);
- static PassRefPtr<InspectorObject> createBackgroundRecord(double startTime, const String& thread);
+ static PassRefPtr<JSONObject> createGenericRecord(double startTime, int maxCallStackDepth, const String& type);
+ static PassRefPtr<JSONObject> createBackgroundRecord(double startTime, const String& thread);
- static PassRefPtr<InspectorObject> createGCEventData(const size_t usedHeapSizeDelta);
+ static PassRefPtr<JSONObject> createGCEventData(const size_t usedHeapSizeDelta);
- static PassRefPtr<InspectorObject> createFunctionCallData(const String& scriptName, int scriptLine);
+ static PassRefPtr<JSONObject> createFunctionCallData(const String& scriptName, int scriptLine);
- static PassRefPtr<InspectorObject> createEventDispatchData(const Event&);
+ static PassRefPtr<JSONObject> createEventDispatchData(const Event&);
- static PassRefPtr<InspectorObject> createGenericTimerData(int timerId);
+ static PassRefPtr<JSONObject> createGenericTimerData(int timerId);
- static PassRefPtr<InspectorObject> createTimerInstallData(int timerId, int timeout, bool singleShot);
+ static PassRefPtr<JSONObject> createTimerInstallData(int timerId, int timeout, bool singleShot);
- static PassRefPtr<InspectorObject> createXHRReadyStateChangeData(const String& url, int readyState);
+ static PassRefPtr<JSONObject> createXHRReadyStateChangeData(const String& url, int readyState);
- static PassRefPtr<InspectorObject> createXHRLoadData(const String& url);
+ static PassRefPtr<JSONObject> createXHRLoadData(const String& url);
- static PassRefPtr<InspectorObject> createEvaluateScriptData(const String&, double lineNumber);
+ static PassRefPtr<JSONObject> createEvaluateScriptData(const String&, double lineNumber);
- static PassRefPtr<InspectorObject> createTimeStampData(const String&);
+ static PassRefPtr<JSONObject> createTimeStampData(const String&);
- static PassRefPtr<InspectorObject> createResourceSendRequestData(const String& requestId, const ResourceRequest&);
+ static PassRefPtr<JSONObject> createResourceSendRequestData(const String& requestId, const ResourceRequest&);
- static PassRefPtr<InspectorObject> createScheduleResourceRequestData(const String&);
+ static PassRefPtr<JSONObject> createScheduleResourceRequestData(const String&);
- static PassRefPtr<InspectorObject> createResourceReceiveResponseData(const String& requestId, const ResourceResponse&);
+ static PassRefPtr<JSONObject> createResourceReceiveResponseData(const String& requestId, const ResourceResponse&);
- static PassRefPtr<InspectorObject> createReceiveResourceData(const String& requestId, int length);
+ static PassRefPtr<JSONObject> createReceiveResourceData(const String& requestId, int length);
- static PassRefPtr<InspectorObject> createResourceFinishData(const String& requestId, bool didFail, double finishTime);
+ static PassRefPtr<JSONObject> createResourceFinishData(const String& requestId, bool didFail, double finishTime);
- static PassRefPtr<InspectorObject> createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout);
+ static PassRefPtr<JSONObject> createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout);
- static PassRefPtr<InspectorObject> createDecodeImageData(const String& imageType);
+ static PassRefPtr<JSONObject> createDecodeImageData(const String& imageType);
- static PassRefPtr<InspectorObject> createResizeImageData(bool shouldCache);
+ static PassRefPtr<JSONObject> createResizeImageData(bool shouldCache);
- static PassRefPtr<InspectorObject> createMarkData(bool isMainFrame);
+ static PassRefPtr<JSONObject> createMarkData(bool isMainFrame);
- static PassRefPtr<InspectorObject> createParseHTMLData(unsigned startLine);
+ static PassRefPtr<JSONObject> createParseHTMLData(unsigned startLine);
- static PassRefPtr<InspectorObject> createAnimationFrameData(int callbackId);
+ static PassRefPtr<JSONObject> createAnimationFrameData(int callbackId);
- static PassRefPtr<InspectorObject> createLayerData(long long layerRootNodeId);
+ static PassRefPtr<JSONObject> createLayerData(long long layerRootNodeId);
- static PassRefPtr<InspectorObject> createPaintData(const FloatQuad&, long long layerRootNodeId);
+ static PassRefPtr<JSONObject> createPaintData(const FloatQuad&, long long layerRootNodeId);
- static void appendLayoutRoot(InspectorObject* data, const FloatQuad&, long long rootNodeId);
+ static void appendLayoutRoot(JSONObject* data, const FloatQuad&, long long rootNodeId);
- static void appendStyleRecalcDetails(InspectorObject* data, unsigned elementCount);
+ static void appendStyleRecalcDetails(JSONObject* data, unsigned elementCount);
- static inline PassRefPtr<InspectorObject> createWebSocketCreateData(unsigned long identifier, const KURL& url, const String& protocol)
+ static inline PassRefPtr<JSONObject> createWebSocketCreateData(unsigned long identifier, const KURL& url, const String& protocol)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("identifier", identifier);
data->setString("url", url.string());
if (!protocol.isNull())
@@ -110,9 +108,9 @@
return data.release();
}
- static inline PassRefPtr<InspectorObject> createGenericWebSocketData(unsigned long identifier)
+ static inline PassRefPtr<JSONObject> createGenericWebSocketData(unsigned long identifier)
{
- RefPtr<InspectorObject> data = InspectorObject::create();
+ RefPtr<JSONObject> data = JSONObject::create();
data->setNumber("identifier", identifier);
return data.release();
}
diff --git a/Source/core/inspector/TimelineTraceEventProcessor.cpp b/Source/core/inspector/TimelineTraceEventProcessor.cpp
index 70e842f..a2323e0 100644
--- a/Source/core/inspector/TimelineTraceEventProcessor.cpp
+++ b/Source/core/inspector/TimelineTraceEventProcessor.cpp
@@ -35,10 +35,9 @@
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/TimelineRecordFactory.h"
-#include <wtf/CurrentTime.h>
-#include <wtf/MainThread.h>
-#include <wtf/ThreadSpecific.h>
-#include <wtf/Vector.h>
+#include "wtf/CurrentTime.h"
+#include "wtf/MainThread.h"
+#include "wtf/Vector.h"
namespace WebCore {
@@ -107,7 +106,7 @@
{
}
-void TimelineRecordStack::addScopedRecord(PassRefPtr<InspectorObject> record)
+void TimelineRecordStack::addScopedRecord(PassRefPtr<JSONObject> record)
{
m_stack.append(Entry(record));
}
@@ -124,7 +123,7 @@
addInstantRecord(last.record);
}
-void TimelineRecordStack::addInstantRecord(PassRefPtr<InspectorObject> record)
+void TimelineRecordStack::addInstantRecord(PassRefPtr<JSONObject> record)
{
if (m_stack.isEmpty())
send(record);
@@ -140,7 +139,7 @@
}
#endif
-void TimelineRecordStack::send(PassRefPtr<InspectorObject> record)
+void TimelineRecordStack::send(PassRefPtr<JSONObject> record)
{
InspectorTimelineAgent* timelineAgent = m_timelineAgent.get();
if (!timelineAgent)
@@ -261,7 +260,7 @@
return;
unsigned long long layerId = event.asUInt(InstrumentationEventArguments::LayerId);
ASSERT(layerId);
- RefPtr<InspectorObject> record = createRecord(event, TimelineRecordType::Rasterize);
+ RefPtr<JSONObject> record = createRecord(event, TimelineRecordType::Rasterize);
record->setObject("data", TimelineRecordFactory::createLayerData(m_layerToNodeMap.get(layerId)));
state.recordStack.addScopedRecord(record.release());
}
@@ -340,19 +339,19 @@
m_layerToNodeMap.set(m_layerId, nodeId);
InspectorTimelineAgent* timelineAgent = m_timelineAgent.get();
if (timelineAgent && paintSetupStart) {
- RefPtr<InspectorObject> paintSetupRecord = TimelineRecordFactory::createGenericRecord(paintSetupStart, 0, TimelineRecordType::PaintSetup);
+ RefPtr<JSONObject> paintSetupRecord = TimelineRecordFactory::createGenericRecord(paintSetupStart, 0, TimelineRecordType::PaintSetup);
paintSetupRecord->setNumber("endTime", m_paintSetupEnd);
paintSetupRecord->setObject("data", TimelineRecordFactory::createLayerData(nodeId));
timelineAgent->addRecordToTimeline(paintSetupRecord);
}
}
-PassRefPtr<InspectorObject> TimelineTraceEventProcessor::createRecord(const TraceEvent& event, const String& recordType, PassRefPtr<InspectorObject> data)
+PassRefPtr<JSONObject> TimelineTraceEventProcessor::createRecord(const TraceEvent& event, const String& recordType, PassRefPtr<JSONObject> data)
{
double startTime = m_timeConverter.fromMonotonicallyIncreasingTime(event.timestamp());
- RefPtr<InspectorObject> record = TimelineRecordFactory::createBackgroundRecord(startTime, String::number(event.threadIdentifier()));
+ RefPtr<JSONObject> record = TimelineRecordFactory::createBackgroundRecord(startTime, String::number(event.threadIdentifier()));
record->setString("type", recordType);
- record->setObject("data", data ? data : InspectorObject::create());
+ record->setObject("data", data ? data : JSONObject::create());
return record.release();
}
diff --git a/Source/core/inspector/TimelineTraceEventProcessor.h b/Source/core/inspector/TimelineTraceEventProcessor.h
index e2eb733..48edc09 100644
--- a/Source/core/inspector/TimelineTraceEventProcessor.h
+++ b/Source/core/inspector/TimelineTraceEventProcessor.h
@@ -33,15 +33,12 @@
#include "core/inspector/InspectorTimelineAgent.h"
-#include "core/inspector/InspectorValues.h"
-
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/Threading.h>
-#include <wtf/Vector.h>
-#include <wtf/WeakPtr.h>
+#include "core/platform/JSONValues.h"
+#include "wtf/HashMap.h"
+#include "wtf/Threading.h"
+#include "wtf/Vector.h"
+#include "wtf/WeakPtr.h"
+#include "wtf/text/WTFString.h"
namespace WebCore {
@@ -52,30 +49,30 @@
class TimelineRecordStack {
private:
struct Entry {
- Entry(PassRefPtr<InspectorObject> record)
+ Entry(PassRefPtr<JSONObject> record)
: record(record)
- , children(InspectorArray::create())
+ , children(JSONArray::create())
{
}
- RefPtr<InspectorObject> record;
- RefPtr<InspectorArray> children;
+ RefPtr<JSONObject> record;
+ RefPtr<JSONArray> children;
};
public:
TimelineRecordStack() { }
TimelineRecordStack(WeakPtr<InspectorTimelineAgent>);
- void addScopedRecord(PassRefPtr<InspectorObject> record);
+ void addScopedRecord(PassRefPtr<JSONObject> record);
void closeScopedRecord(double endTime);
- void addInstantRecord(PassRefPtr<InspectorObject> record);
+ void addInstantRecord(PassRefPtr<JSONObject> record);
#ifndef NDEBUG
bool isOpenRecordOfType(const String& type);
#endif
private:
- void send(PassRefPtr<InspectorObject>);
+ void send(PassRefPtr<JSONObject>);
WeakPtr<InspectorTimelineAgent> m_timelineAgent;
Vector<Entry> m_stack;
@@ -226,7 +223,7 @@
void leaveLayerTask(TimelineThreadState&);
void processBackgroundEvents();
- PassRefPtr<InspectorObject> createRecord(const TraceEvent&, const String& recordType, PassRefPtr<InspectorObject> data = 0);
+ PassRefPtr<JSONObject> createRecord(const TraceEvent&, const String& recordType, PassRefPtr<JSONObject> data = 0);
void registerHandler(const char* name, TraceEventPhase, TraceEventHandler);
diff --git a/Source/core/inspector/WorkerDebuggerAgent.cpp b/Source/core/inspector/WorkerDebuggerAgent.cpp
index 4e9cdd7..b30b39a 100644
--- a/Source/core/inspector/WorkerDebuggerAgent.cpp
+++ b/Source/core/inspector/WorkerDebuggerAgent.cpp
@@ -33,7 +33,7 @@
#include "core/inspector/WorkerDebuggerAgent.h"
#include "bindings/v8/ScriptDebugServer.h"
-#include "core/workers/WorkerContext.h"
+#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerThread.h"
#include <wtf/MessageQueue.h>
@@ -58,46 +58,46 @@
class RunInspectorCommandsTask : public ScriptDebugServer::Task {
public:
- RunInspectorCommandsTask(WorkerThread* thread, WorkerContext* workerContext)
+ RunInspectorCommandsTask(WorkerThread* thread, WorkerGlobalScope* workerGlobalScope)
: m_thread(thread)
- , m_workerContext(workerContext) { }
+ , m_workerGlobalScope(workerGlobalScope) { }
virtual ~RunInspectorCommandsTask() { }
virtual void run()
{
- // Process all queued debugger commands. It is safe to use m_workerContext here
+ // Process all queued debugger commands. It is safe to use m_workerGlobalScope here
// because it is alive if RunWorkerLoop is not terminated, otherwise it will
// just be ignored. WorkerThread is certainly alive if this task is being executed.
- while (MessageQueueMessageReceived == m_thread->runLoop().runInMode(m_workerContext, WorkerDebuggerAgent::debuggerTaskMode, WorkerRunLoop::DontWaitForMessage)) { }
+ while (MessageQueueMessageReceived == m_thread->runLoop().runInMode(m_workerGlobalScope, WorkerDebuggerAgent::debuggerTaskMode, WorkerRunLoop::DontWaitForMessage)) { }
}
private:
WorkerThread* m_thread;
- WorkerContext* m_workerContext;
+ WorkerGlobalScope* m_workerGlobalScope;
};
} // namespace
const char* WorkerDebuggerAgent::debuggerTaskMode = "debugger";
-PassOwnPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState, WorkerScriptDebugServer* scriptDebugServer, WorkerContext* inspectedWorkerContext, InjectedScriptManager* injectedScriptManager)
+PassOwnPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState, WorkerScriptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injectedScriptManager)
{
- return adoptPtr(new WorkerDebuggerAgent(instrumentingAgents, inspectorState, scriptDebugServer, inspectedWorkerContext, injectedScriptManager));
+ return adoptPtr(new WorkerDebuggerAgent(instrumentingAgents, inspectorState, scriptDebugServer, inspectedWorkerGlobalScope, injectedScriptManager));
}
-WorkerDebuggerAgent::WorkerDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState, WorkerScriptDebugServer* scriptDebugServer, WorkerContext* inspectedWorkerContext, InjectedScriptManager* injectedScriptManager)
+WorkerDebuggerAgent::WorkerDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState, WorkerScriptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injectedScriptManager)
: InspectorDebuggerAgent(instrumentingAgents, inspectorState, injectedScriptManager)
, m_scriptDebugServer(scriptDebugServer)
- , m_inspectedWorkerContext(inspectedWorkerContext)
+ , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope)
{
MutexLocker lock(workerDebuggerAgentsMutex());
- workerDebuggerAgents().set(inspectedWorkerContext->thread(), this);
+ workerDebuggerAgents().set(inspectedWorkerGlobalScope->thread(), this);
}
WorkerDebuggerAgent::~WorkerDebuggerAgent()
{
MutexLocker lock(workerDebuggerAgentsMutex());
- ASSERT(workerDebuggerAgents().contains(m_inspectedWorkerContext->thread()));
- workerDebuggerAgents().remove(m_inspectedWorkerContext->thread());
+ ASSERT(workerDebuggerAgents().contains(m_inspectedWorkerGlobalScope->thread()));
+ workerDebuggerAgents().remove(m_inspectedWorkerGlobalScope->thread());
}
void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* thread)
@@ -105,7 +105,7 @@
MutexLocker lock(workerDebuggerAgentsMutex());
WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread);
if (agent)
- agent->m_scriptDebugServer->interruptAndRunTask(adoptPtr(new RunInspectorCommandsTask(thread, agent->m_inspectedWorkerContext)));
+ agent->m_scriptDebugServer->interruptAndRunTask(adoptPtr(new RunInspectorCommandsTask(thread, agent->m_inspectedWorkerGlobalScope)));
}
void WorkerDebuggerAgent::startListeningScriptDebugServer()
@@ -129,7 +129,7 @@
*error = "Execution context id is not supported for workers as there is only one execution context.";
return InjectedScript();
}
- ScriptState* scriptState = scriptStateFromWorkerContext(m_inspectedWorkerContext);
+ ScriptState* scriptState = scriptStateFromWorkerGlobalScope(m_inspectedWorkerGlobalScope);
return injectedScriptManager()->injectedScriptFor(scriptState);
}
@@ -145,7 +145,7 @@
void WorkerDebuggerAgent::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL)
{
- ScriptExecutionContext* context = m_inspectedWorkerContext;
+ ScriptExecutionContext* context = m_inspectedWorkerGlobalScope;
context->addConsoleMessage(source, level, message, sourceURL, 0);
}
diff --git a/Source/core/inspector/WorkerDebuggerAgent.h b/Source/core/inspector/WorkerDebuggerAgent.h
index b766d85..f51b390 100644
--- a/Source/core/inspector/WorkerDebuggerAgent.h
+++ b/Source/core/inspector/WorkerDebuggerAgent.h
@@ -36,21 +36,21 @@
namespace WebCore {
-class WorkerContext;
+class WorkerGlobalScope;
class WorkerThread;
class WorkerDebuggerAgent : public InspectorDebuggerAgent {
WTF_MAKE_NONCOPYABLE(WorkerDebuggerAgent);
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassOwnPtr<WorkerDebuggerAgent> create(InstrumentingAgents*, InspectorCompositeState*, WorkerScriptDebugServer*, WorkerContext*, InjectedScriptManager*);
+ static PassOwnPtr<WorkerDebuggerAgent> create(InstrumentingAgents*, InspectorCompositeState*, WorkerScriptDebugServer*, WorkerGlobalScope*, InjectedScriptManager*);
virtual ~WorkerDebuggerAgent();
static const char* debuggerTaskMode;
static void interruptAndDispatchInspectorCommands(WorkerThread*);
private:
- WorkerDebuggerAgent(InstrumentingAgents*, InspectorCompositeState*, WorkerScriptDebugServer*, WorkerContext*, InjectedScriptManager*);
+ WorkerDebuggerAgent(InstrumentingAgents*, InspectorCompositeState*, WorkerScriptDebugServer*, WorkerGlobalScope*, InjectedScriptManager*);
virtual void startListeningScriptDebugServer();
virtual void stopListeningScriptDebugServer();
@@ -61,7 +61,7 @@
virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL);
WorkerScriptDebugServer* m_scriptDebugServer;
- WorkerContext* m_inspectedWorkerContext;
+ WorkerGlobalScope* m_inspectedWorkerGlobalScope;
};
} // namespace WebCore
diff --git a/Source/core/inspector/WorkerInspectorController.cpp b/Source/core/inspector/WorkerInspectorController.cpp
index cf84183..397b443 100644
--- a/Source/core/inspector/WorkerInspectorController.cpp
+++ b/Source/core/inspector/WorkerInspectorController.cpp
@@ -47,7 +47,7 @@
#include "core/inspector/WorkerConsoleAgent.h"
#include "core/inspector/WorkerDebuggerAgent.h"
#include "core/inspector/WorkerRuntimeAgent.h"
-#include "core/workers/WorkerContext.h"
+#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerReportingProxy.h"
#include "core/workers/WorkerThread.h"
#include <wtf/PassOwnPtr.h>
@@ -59,46 +59,46 @@
class PageInspectorProxy : public InspectorFrontendChannel {
WTF_MAKE_FAST_ALLOCATED;
public:
- explicit PageInspectorProxy(WorkerContext* workerContext) : m_workerContext(workerContext) { }
+ explicit PageInspectorProxy(WorkerGlobalScope* workerGlobalScope) : m_workerGlobalScope(workerGlobalScope) { }
virtual ~PageInspectorProxy() { }
private:
virtual bool sendMessageToFrontend(const String& message)
{
- m_workerContext->thread()->workerReportingProxy().postMessageToPageInspector(message);
+ m_workerGlobalScope->thread()->workerReportingProxy().postMessageToPageInspector(message);
return true;
}
- WorkerContext* m_workerContext;
+ WorkerGlobalScope* m_workerGlobalScope;
};
class WorkerStateClient : public InspectorStateClient {
WTF_MAKE_FAST_ALLOCATED;
public:
- WorkerStateClient(WorkerContext* context) : m_workerContext(context) { }
+ WorkerStateClient(WorkerGlobalScope* context) : m_workerGlobalScope(context) { }
virtual ~WorkerStateClient() { }
private:
virtual void updateInspectorStateCookie(const String& cookie)
{
- m_workerContext->thread()->workerReportingProxy().updateInspectorStateCookie(cookie);
+ m_workerGlobalScope->thread()->workerReportingProxy().updateInspectorStateCookie(cookie);
}
- WorkerContext* m_workerContext;
+ WorkerGlobalScope* m_workerGlobalScope;
};
}
-WorkerInspectorController::WorkerInspectorController(WorkerContext* workerContext)
- : m_workerContext(workerContext)
- , m_stateClient(adoptPtr(new WorkerStateClient(workerContext)))
+WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope* workerGlobalScope)
+ : m_workerGlobalScope(workerGlobalScope)
+ , m_stateClient(adoptPtr(new WorkerStateClient(workerGlobalScope)))
, m_state(adoptPtr(new InspectorCompositeState(m_stateClient.get())))
, m_instrumentingAgents(InstrumentingAgents::create())
, m_injectedScriptManager(InjectedScriptManager::createForWorker())
- , m_debugServer(adoptPtr(new WorkerScriptDebugServer(workerContext, WorkerDebuggerAgent::debuggerTaskMode)))
+ , m_debugServer(adoptPtr(new WorkerScriptDebugServer(workerGlobalScope, WorkerDebuggerAgent::debuggerTaskMode)))
{
- m_agents.append(WorkerRuntimeAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), m_debugServer.get(), workerContext));
+ m_agents.append(WorkerRuntimeAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), m_debugServer.get(), workerGlobalScope));
OwnPtr<InspectorConsoleAgent> consoleAgent = WorkerConsoleAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get());
- m_agents.append(WorkerDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), m_debugServer.get(), workerContext, m_injectedScriptManager.get()));
+ m_agents.append(WorkerDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), m_debugServer.get(), workerGlobalScope, m_injectedScriptManager.get()));
m_agents.append(InspectorProfilerAgent::create(m_instrumentingAgents.get(), consoleAgent.get(), m_state.get(), m_injectedScriptManager.get()));
m_agents.append(InspectorHeapProfilerAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get()));
@@ -118,7 +118,7 @@
{
ASSERT(!m_frontend);
m_state->unmute();
- m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerContext));
+ m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerGlobalScope));
m_frontend = adoptPtr(new InspectorFrontend(m_frontendChannel.get()));
m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.get());
m_agents.registerInDispatcher(m_backendDispatcher.get());
diff --git a/Source/core/inspector/WorkerInspectorController.h b/Source/core/inspector/WorkerInspectorController.h
index aada5b8..4c70063 100644
--- a/Source/core/inspector/WorkerInspectorController.h
+++ b/Source/core/inspector/WorkerInspectorController.h
@@ -47,14 +47,14 @@
class InspectorState;
class InspectorStateClient;
class InstrumentingAgents;
-class WorkerContext;
+class WorkerGlobalScope;
class WorkerScriptDebugServer;
class WorkerInspectorController {
WTF_MAKE_NONCOPYABLE(WorkerInspectorController);
WTF_MAKE_FAST_ALLOCATED;
public:
- WorkerInspectorController(WorkerContext*);
+ WorkerInspectorController(WorkerGlobalScope*);
~WorkerInspectorController();
bool hasFrontend() const { return m_frontend; }
@@ -65,9 +65,9 @@
void resume();
private:
- friend InstrumentingAgents* instrumentationForWorkerContext(WorkerContext*);
+ friend InstrumentingAgents* instrumentationForWorkerGlobalScope(WorkerGlobalScope*);
- WorkerContext* m_workerContext;
+ WorkerGlobalScope* m_workerGlobalScope;
OwnPtr<InspectorStateClient> m_stateClient;
OwnPtr<InspectorCompositeState> m_state;
RefPtr<InstrumentingAgents> m_instrumentingAgents;
diff --git a/Source/core/inspector/WorkerRuntimeAgent.cpp b/Source/core/inspector/WorkerRuntimeAgent.cpp
index 8ddd4b2..d3d0c3f 100644
--- a/Source/core/inspector/WorkerRuntimeAgent.cpp
+++ b/Source/core/inspector/WorkerRuntimeAgent.cpp
@@ -36,15 +36,15 @@
#include "core/inspector/InjectedScript.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/inspector/WorkerDebuggerAgent.h"
-#include "core/workers/WorkerContext.h"
+#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerRunLoop.h"
#include "core/workers/WorkerThread.h"
namespace WebCore {
-WorkerRuntimeAgent::WorkerRuntimeAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InjectedScriptManager* injectedScriptManager, ScriptDebugServer* scriptDebugServer, WorkerContext* workerContext)
+WorkerRuntimeAgent::WorkerRuntimeAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InjectedScriptManager* injectedScriptManager, ScriptDebugServer* scriptDebugServer, WorkerGlobalScope* workerGlobalScope)
: InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager, scriptDebugServer)
- , m_workerContext(workerContext)
+ , m_workerGlobalScope(workerGlobalScope)
, m_paused(false)
{
m_instrumentingAgents->setWorkerRuntimeAgent(this);
@@ -61,7 +61,7 @@
*error = "Execution context id is not supported for workers as there is only one execution context.";
return InjectedScript();
}
- ScriptState* scriptState = scriptStateFromWorkerContext(m_workerContext);
+ ScriptState* scriptState = scriptStateFromWorkerGlobalScope(m_workerGlobalScope);
return injectedScriptManager()->injectedScriptFor(scriptState);
}
@@ -80,9 +80,9 @@
m_paused = false;
}
-void WorkerRuntimeAgent::willEvaluateWorkerScript(WorkerContext* context, int workerThreadStartMode)
+void WorkerRuntimeAgent::willEvaluateWorkerScript(WorkerGlobalScope* context, int workerThreadStartMode)
{
- if (workerThreadStartMode != PauseWorkerContextOnStart)
+ if (workerThreadStartMode != PauseWorkerGlobalScopeOnStart)
return;
m_paused = true;
diff --git a/Source/core/inspector/WorkerRuntimeAgent.h b/Source/core/inspector/WorkerRuntimeAgent.h
index 5ceb747..226c135 100644
--- a/Source/core/inspector/WorkerRuntimeAgent.h
+++ b/Source/core/inspector/WorkerRuntimeAgent.h
@@ -36,11 +36,11 @@
namespace WebCore {
-class WorkerContext;
+class WorkerGlobalScope;
class WorkerRuntimeAgent : public InspectorRuntimeAgent {
public:
- static PassOwnPtr<WorkerRuntimeAgent> create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InjectedScriptManager* injectedScriptManager, ScriptDebugServer* scriptDebugServer, WorkerContext* context)
+ static PassOwnPtr<WorkerRuntimeAgent> create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InjectedScriptManager* injectedScriptManager, ScriptDebugServer* scriptDebugServer, WorkerGlobalScope* context)
{
return adoptPtr(new WorkerRuntimeAgent(instrumentingAgents, state, injectedScriptManager, scriptDebugServer, context));
}
@@ -49,14 +49,14 @@
// Protocol commands.
virtual void run(ErrorString*);
- void willEvaluateWorkerScript(WorkerContext*, int workerThreadStartMode);
+ void willEvaluateWorkerScript(WorkerGlobalScope*, int workerThreadStartMode);
private:
- WorkerRuntimeAgent(InstrumentingAgents*, InspectorCompositeState*, InjectedScriptManager*, ScriptDebugServer*, WorkerContext*);
+ WorkerRuntimeAgent(InstrumentingAgents*, InspectorCompositeState*, InjectedScriptManager*, ScriptDebugServer*, WorkerGlobalScope*);
virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId);
virtual void muteConsole();
virtual void unmuteConsole();
- WorkerContext* m_workerContext;
+ WorkerGlobalScope* m_workerGlobalScope;
bool m_paused;
};