summaryrefslogtreecommitdiffstats
path: root/WebCore/inspector/front-end/RemoteObject.js
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/inspector/front-end/RemoteObject.js')
-rw-r--r--WebCore/inspector/front-end/RemoteObject.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/WebCore/inspector/front-end/RemoteObject.js b/WebCore/inspector/front-end/RemoteObject.js
index 003d483..4d6736c 100644
--- a/WebCore/inspector/front-end/RemoteObject.js
+++ b/WebCore/inspector/front-end/RemoteObject.js
@@ -41,6 +41,11 @@ WebInspector.RemoteObject.fromPrimitiveValue = function(value)
return new WebInspector.RemoteObject(null, typeof value, value);
}
+WebInspector.RemoteObject.fromLocalObject = function(value)
+{
+ return new WebInspector.LocalJSONObject(value);
+}
+
WebInspector.RemoteObject.resolveNode = function(node, callback)
{
function mycallback(object)
@@ -136,3 +141,62 @@ WebInspector.RemoteObjectProperty = function(name, value)
this.name = name;
this.value = value;
}
+
+// The below is a wrapper around a local object that provides an interface comaptible
+// with RemoteObject, to be used by the UI code (primarily ObjectPropertiesSection).
+// Note that only JSON-compliant objects are currently supported, as there's no provision
+// for traversing prototypes, extracting class names via constuctor, handling properties
+// or functions.
+
+WebInspector.LocalJSONObject = function(value)
+{
+ this._value = value;
+}
+
+WebInspector.LocalJSONObject.prototype = {
+ get description()
+ {
+ var type = this.type;
+ switch (type) {
+ case "array":
+ return "[" + this._value.length + "]";
+ case "object":
+ return this.hasChildren ? "{...}" : "{ }";
+ default:
+ return JSON.stringify(this._value);
+ }
+ },
+
+ get type()
+ {
+ if (this._value === null)
+ return "null";
+ if (this._value instanceof Array)
+ return "array";
+ return typeof this._value;
+ },
+
+ get hasChildren()
+ {
+ return typeof this._value === "object" && this._value !== null && Object.keys(this._value).length;
+ },
+
+ getOwnProperties: function(abbreviate, callback)
+ {
+ return this.getProperties(false, abbreviate, callback);
+ },
+
+ getProperties: function(ignoreHasOwnProperty, abbreviate, callback)
+ {
+ function buildProperty(propName)
+ {
+ return new WebInspector.RemoteObjectProperty(propName, new WebInspector.LocalJSONObject(this._value[propName]));
+ }
+ callback(Object.keys(this._value).map(buildProperty.bind(this)));
+ },
+
+ isError: function()
+ {
+ return false;
+ }
+}