2010-08-12 Pavel Feldman <pfeldman@chromium.org>
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Aug 2010 06:31:41 +0000 (06:31 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Aug 2010 06:31:41 +0000 (06:31 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: Make getPrototypes return objects, not names.
        https://bugs.webkit.org/show_bug.cgi?id=43934

        * inspector/front-end/InjectedScript.js:
        (injectedScriptConstructor):
        (injectedScriptConstructor.):
        * inspector/front-end/PropertiesSidebarPane.js:
        (WebInspector.PropertiesSidebarPane.prototype.update.callback):
        * inspector/front-end/inspector.js:
        (WebInspector.log):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@65300 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/inspector/front-end/ConsoleView.js
WebCore/inspector/front-end/InjectedScript.js
WebCore/inspector/front-end/PropertiesSidebarPane.js
WebCore/inspector/front-end/RemoteObject.js
WebCore/inspector/front-end/inspector.js

index 43a0b18..54ac14e 100644 (file)
@@ -1,3 +1,18 @@
+2010-08-12  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: Make getPrototypes return objects, not names.
+        https://bugs.webkit.org/show_bug.cgi?id=43934
+
+        * inspector/front-end/InjectedScript.js:
+        (injectedScriptConstructor):
+        (injectedScriptConstructor.):
+        * inspector/front-end/PropertiesSidebarPane.js:
+        (WebInspector.PropertiesSidebarPane.prototype.update.callback):
+        * inspector/front-end/inspector.js:
+        (WebInspector.log):
+
 2010-08-12  James Robinson  <jamesr@chromium.org>
 
         Unreviewed, rolling out r65284 and r65288.  Broke chromium compile.
index ca4fe04..155f441 100644 (file)
@@ -589,7 +589,7 @@ WebInspector.ConsoleView.prototype = {
             elem.appendChild(treeOutline.element);
         }
 
-        InjectedScriptAccess.get(object.objectId.injectedScriptId).pushNodeToFrontend(object.objectId, printNode);
+        object.pushNodeToFrontend(printNode);
     },
 
     _formatarray: function(arr, elem)
index b6ad173..c4f3afb 100644 (file)
@@ -59,7 +59,7 @@ InjectedScript.wrapObject = function(object, objectGroupName)
                 InjectedScript.objectGroups[objectGroupName] = group;
             }
             group.push(id);
-            objectId = new InjectedScript.RemoteObjectId("jsobject", id);
+            objectId = new InjectedScript.RemoteObjectId(InjectedScript.RemoteObjectId.Type.JsObject, id);
         }
         return InjectedScript.RemoteObject.fromObject(object, objectId);
     } catch (e) {
@@ -100,13 +100,14 @@ InjectedScript.getPrototypes = function(nodeId)
         return false;
 
     var result = [];
-    for (var prototype = node; prototype; prototype = prototype.__proto__) {
-        var title = InjectedScript._describe(prototype, true);
-        if (title.match(/Prototype$/)) {
-            title = title.replace(/Prototype$/, "");
-        }
-        result.push(title);
-    }
+    var prototype = node;
+    var prototypeId = new InjectedScript.RemoteObjectId(InjectedScript.RemoteObjectId.Type.Node, nodeId);
+    do {
+        result.push(InjectedScript.RemoteObject.fromObject(prototype, prototypeId));
+        prototype = prototype.__proto__;
+        prototypeId = InjectedScript.RemoteObjectId.deriveProperty(prototypeId, "__proto__");
+    } while (prototype)
+
     return result;
 }
 
@@ -131,9 +132,7 @@ InjectedScript.getProperties = function(objectId, ignoreHasOwnProperty, abbrevia
         if (!isGetter) {
             try {
                 var childObject = object[propertyName];
-                var path = objectId.path ? objectId.path.slice() : [];
-                path.push(propertyName);
-                var childObjectId = new InjectedScript.RemoteObjectId(objectId.type, objectId.value, path);
+                var childObjectId = InjectedScript.RemoteObjectId.deriveProperty(objectId, propertyName);
                 var childObjectProxy = new InjectedScript.RemoteObject.fromObject(childObject, childObjectId, abbreviate);
                 property.value = childObjectProxy;
             } catch(e) {
@@ -346,11 +345,11 @@ InjectedScript._objectForId = function(objectId)
     // - strings point to console objects cached in InspectorController for lazy evaluation upon them
     // - objects contain complex ids and are currently used for scoped objects
     var object;
-    if (objectId.type === "node")
+    if (objectId.type === InjectedScript.RemoteObjectId.Type.Node)
         object = InjectedScript._nodeForId(objectId.value);
-    else if (objectId.type === "jsobject")
+    else if (objectId.type === InjectedScript.RemoteObjectId.Type.JsObject)
         object = InjectedScript.unwrapObject(objectId.value);
-    else if (objectId.type === "scopeObject") {
+    else if (objectId.type === InjectedScript.RemoteObjectId.Type.ScopeObject) {
         var callFrame = InjectedScript._callFrameForId(objectId.value.callFrame);
         if (objectId.thisObject)
             object = callFrame.thisObject;
@@ -385,6 +384,19 @@ InjectedScript.RemoteObjectId = function(type, value, path)
     this.path = path || [];
 }
 
+InjectedScript.RemoteObjectId.Type = {
+    Node: "node",
+    JsObject: "jsObject",
+    ScopeObject: "scopeObject"
+}
+
+InjectedScript.RemoteObjectId.deriveProperty = function(objectId, propertyName)
+{
+    var path = objectId.path.slice() || [];
+    path.push(propertyName);
+    return new InjectedScript.RemoteObjectId(objectId.type, objectId.value, path);
+}
+
 InjectedScript.RemoteObject = function(objectId, type, description, hasChildren)
 {
     this.objectId = objectId;
@@ -444,14 +456,14 @@ InjectedScript.CallFrameProxy.prototype = {
         for (var i = 0; i < scopeChain.length; i++) {
             var scopeType = callFrame.scopeType(i);
             var scopeObject = scopeChain[i];
-            var scopeObjectId = new InjectedScript.RemoteObjectId("scopeObject", { callFrame: this.id, chainIndex: i });
+            var scopeObjectId = new InjectedScript.RemoteObjectId(InjectedScript.RemoteObjectId.Type.ScopeObject, { callFrame: this.id, chainIndex: i });
             var scopeObjectProxy = InjectedScript.RemoteObject.fromObject(scopeObject, scopeObjectId, true);
 
             switch(scopeType) {
                 case LOCAL_SCOPE: {
                     foundLocalScope = true;
                     scopeObjectProxy.isLocal = true;
-                    var thisObjectId = new InjectedScript.RemoteObjectId("scopeObject", { callFrame: this.id, thisObject: true });
+                    var thisObjectId = new InjectedScript.RemoteObjectId(InjectedScript.RemoteObjectId.Type.ScopeObject, { callFrame: this.id, thisObject: true });
                     scopeObjectProxy.thisObject = InjectedScript.RemoteObject.fromObject(callFrame.thisObject, thisObjectId, true);
                     break;
                 }
index d64881c..9baaf98 100644 (file)
@@ -48,14 +48,15 @@ WebInspector.PropertiesSidebarPane.prototype = {
             body.removeChildren();
             self.sections = [];
 
-            var path = [];
             // Get array of prototype user-friendly names.
             for (var i = 0; i < prototypes.length; ++i) {
-                var prototype = new WebInspector.RemoteObject.fromNode(node, path.slice());
-                var section = new WebInspector.ObjectPropertiesSection(prototype, prototypes[i], WebInspector.UIString("Prototype"));
+                var prototype = WebInspector.RemoteObject.fromPayload(prototypes[i]);
+                var title = prototype.description;
+                if (title.match(/Prototype$/))
+                    title = title.replace(/Prototype$/, "");
+                var section = new WebInspector.ObjectPropertiesSection(prototype, title, WebInspector.UIString("Prototype"));
                 self.sections.push(section);
                 body.appendChild(section.element);
-                path.push("__proto__");
             }
         };
         InjectedScriptAccess.get(-node.id).getPrototypes(node.id, callback);
index 6b21677..d6e19f2 100644 (file)
@@ -146,6 +146,11 @@ WebInspector.RemoteObject.prototype = {
             return;
         }
         InjectedScriptAccess.get(this._objectId.injectedScriptId).setPropertyValue(this._objectId, name, value, callback);
+    },
+
+    pushNodeToFrontend: function(callback)
+    {
+        InjectedScriptAccess.get(this._objectId.injectedScriptId).pushNodeToFrontend(this._objectId, callback);
     }
 }
 
index 6816d23..e73df01 100644 (file)
@@ -1467,6 +1467,12 @@ WebInspector.log = function(message, messageLevel)
     // remember 'this' for setInterval() callback
     var self = this;
 
+    // return indication if we can actually log a message
+    function isLogAvailable()
+    {
+        return WebInspector.ConsoleMessage && WebInspector.ObjectProxy && self.console;
+    }
+
     // flush the queue of pending messages
     function flushQueue()
     {