Web Inspector: Add ObjectTreeBaseTreeElement to share functionality
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Mar 2015 19:40:07 +0000 (19:40 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Mar 2015 19:40:07 +0000 (19:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142323

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-05
Reviewed by Timothy Hatcher.

By making this change:

  - Share lots of duplicated code.
  - Array / Set / Map tree elements get context menu support

* UserInterface/Main.html:
* UserInterface/Views/ObjectTreeBaseTreeElement.js: Added.
(WebInspector.ObjectTreeBaseTreeElement):
(WebInspector.ObjectTreeBaseTreeElement.prototype.get property):
(WebInspector.ObjectTreeBaseTreeElement.prototype.get propertyPath):
(WebInspector.ObjectTreeBaseTreeElement.prototype.oncontextmenu):
(WebInspector.ObjectTreeBaseTreeElement.prototype.resolvedValue):
(WebInspector.ObjectTreeBaseTreeElement.prototype.resolvedValuePropertyPath):
(WebInspector.ObjectTreeBaseTreeElement.prototype.thisPropertyPath):
(WebInspector.ObjectTreeBaseTreeElement.prototype.hadError):
(WebInspector.ObjectTreeBaseTreeElement.prototype.propertyPathType):
(WebInspector.ObjectTreeBaseTreeElement.prototype.propertyPathString):
(WebInspector.ObjectTreeBaseTreeElement.prototype.createInteractiveGetterElement):
(WebInspector.ObjectTreeBaseTreeElement.prototype.createReadOnlyIconElement):
New file, copying most of the code from PropertyTreeElement so it can be shared.

* UserInterface/Views/ObjectTreeArrayIndexTreeElement.js:
(WebInspector.ObjectTreeArrayIndexTreeElement):
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype.invokedGetter):
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype._titleFragment):
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype.get property): Deleted.
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype._resolvedValue): Deleted.
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype._propertyPathType): Deleted.
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype._resolvedValuePropertyPath): Deleted.
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype._thisPropertyPath): Deleted.
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype._propertyPathString): Deleted.
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype._updateTitle): Deleted.
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype._createInteractiveGetterElement.): Deleted.
(WebInspector.ObjectTreeArrayIndexTreeElement.prototype._createReadOnlyIconElement): Deleted.
* UserInterface/Views/ObjectTreePropertyTreeElement.js:
(WebInspector.ObjectTreePropertyTreeElement):
(WebInspector.ObjectTreePropertyTreeElement.prototype.invokedGetter):
(WebInspector.ObjectTreePropertyTreeElement.prototype._updateHasChildren):
(WebInspector.ObjectTreePropertyTreeElement.prototype._updateTooltips):
(WebInspector.ObjectTreePropertyTreeElement.prototype._titleFragment):
(WebInspector.ObjectTreePropertyTreeElement.prototype._createTitlePrototype):
(WebInspector.ObjectTreePropertyTreeElement.prototype._createTitlePropertyStyle):
(WebInspector.ObjectTreePropertyTreeElement.prototype._createTitleAPIStyle):
(WebInspector.ObjectTreePropertyTreeElement.prototype._alwaysDisplayAsProperty):
(WebInspector.ObjectTreePropertyTreeElement.prototype._updateChildren):
(WebInspector.ObjectTreePropertyTreeElement.prototype._updateChildrenInternal):
(WebInspector.ObjectTreePropertyTreeElement.prototype._updateEntries):
(WebInspector.ObjectTreePropertyTreeElement.prototype._updateProperties):
(WebInspector.ObjectTreePropertyTreeElement.prototype.get property): Deleted.
(WebInspector.ObjectTreePropertyTreeElement.prototype.oncontextmenu): Deleted.
(WebInspector.ObjectTreePropertyTreeElement.prototype._resolvedValue): Deleted.
(WebInspector.ObjectTreePropertyTreeElement.prototype._propertyPathType): Deleted.
(WebInspector.ObjectTreePropertyTreeElement.prototype._resolvedValuePropertyPath): Deleted.
(WebInspector.ObjectTreePropertyTreeElement.prototype._thisPropertyPath): Deleted.
(WebInspector.ObjectTreePropertyTreeElement.prototype._updateTitleAndIcon): Deleted.
(WebInspector.ObjectTreePropertyTreeElement.prototype._createInteractiveGetterElement.): Deleted.
(WebInspector.ObjectTreePropertyTreeElement.prototype._createReadOnlyIconElement): Deleted.
(WebInspector.ObjectTreePropertyTreeElement.prototype): Deleted.
Subclass ObjectTreeBaseTreeElement and eliminate the code now
automatically handled by the base class.

* UserInterface/Views/ObjectTreeMapEntryTreeElement.js:
(WebInspector.ObjectTreeMapEntryTreeElement):
(WebInspector.ObjectTreeMapEntryTreeElement.prototype.resolvedValue):
(WebInspector.ObjectTreeMapEntryTreeElement.prototype._titleFragment):
(WebInspector.ObjectTreeMapEntryTreeElement.prototype._propertyPathString): Deleted.
* UserInterface/Views/ObjectTreeSetIndexTreeElement.js:
(WebInspector.ObjectTreeSetIndexTreeElement):
(WebInspector.ObjectTreeSetIndexTreeElement.prototype.resolvedValue):
(WebInspector.ObjectTreeSetIndexTreeElement.prototype._titleFragment):
(WebInspector.ObjectTreeSetIndexTreeElement.prototype._resolvedValuePropertyPath): Deleted.
Override resolved value since these are not about PropertyDescriptors.
This will make context menus work automatically.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Views/ObjectTreeArrayIndexTreeElement.js
Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Views/ObjectTreeMapEntryTreeElement.js
Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js
Source/WebInspectorUI/UserInterface/Views/ObjectTreeSetIndexTreeElement.js

index 38aa800..76ec679 100644 (file)
@@ -1,3 +1,84 @@
+2015-03-05  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Add ObjectTreeBaseTreeElement to share functionality
+        https://bugs.webkit.org/show_bug.cgi?id=142323
+
+        Reviewed by Timothy Hatcher.
+
+        By making this change:
+
+          - Share lots of duplicated code.
+          - Array / Set / Map tree elements get context menu support
+
+        * UserInterface/Main.html:
+        * UserInterface/Views/ObjectTreeBaseTreeElement.js: Added.
+        (WebInspector.ObjectTreeBaseTreeElement):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.get property):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.get propertyPath):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.oncontextmenu):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.resolvedValue):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.resolvedValuePropertyPath):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.thisPropertyPath):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.hadError):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.propertyPathType):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.propertyPathString):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.createInteractiveGetterElement):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype.createReadOnlyIconElement):
+        New file, copying most of the code from PropertyTreeElement so it can be shared.
+
+        * UserInterface/Views/ObjectTreeArrayIndexTreeElement.js:
+        (WebInspector.ObjectTreeArrayIndexTreeElement):
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype.invokedGetter):
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype._titleFragment):
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype.get property): Deleted.
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype._resolvedValue): Deleted.
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype._propertyPathType): Deleted.
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype._resolvedValuePropertyPath): Deleted.
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype._thisPropertyPath): Deleted.
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype._propertyPathString): Deleted.
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype._updateTitle): Deleted.
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype._createInteractiveGetterElement.): Deleted.
+        (WebInspector.ObjectTreeArrayIndexTreeElement.prototype._createReadOnlyIconElement): Deleted.
+        * UserInterface/Views/ObjectTreePropertyTreeElement.js:
+        (WebInspector.ObjectTreePropertyTreeElement):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype.invokedGetter):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._updateHasChildren):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._updateTooltips):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._titleFragment):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._createTitlePrototype):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._createTitlePropertyStyle):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._createTitleAPIStyle):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._alwaysDisplayAsProperty):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._updateChildren):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._updateChildrenInternal):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._updateEntries):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._updateProperties):
+        (WebInspector.ObjectTreePropertyTreeElement.prototype.get property): Deleted.
+        (WebInspector.ObjectTreePropertyTreeElement.prototype.oncontextmenu): Deleted.
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._resolvedValue): Deleted.
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._propertyPathType): Deleted.
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._resolvedValuePropertyPath): Deleted.
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._thisPropertyPath): Deleted.
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._updateTitleAndIcon): Deleted.
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._createInteractiveGetterElement.): Deleted.
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._createReadOnlyIconElement): Deleted.
+        (WebInspector.ObjectTreePropertyTreeElement.prototype): Deleted.
+        Subclass ObjectTreeBaseTreeElement and eliminate the code now
+        automatically handled by the base class.
+
+        * UserInterface/Views/ObjectTreeMapEntryTreeElement.js:
+        (WebInspector.ObjectTreeMapEntryTreeElement):
+        (WebInspector.ObjectTreeMapEntryTreeElement.prototype.resolvedValue):
+        (WebInspector.ObjectTreeMapEntryTreeElement.prototype._titleFragment):
+        (WebInspector.ObjectTreeMapEntryTreeElement.prototype._propertyPathString): Deleted.
+        * UserInterface/Views/ObjectTreeSetIndexTreeElement.js:
+        (WebInspector.ObjectTreeSetIndexTreeElement):
+        (WebInspector.ObjectTreeSetIndexTreeElement.prototype.resolvedValue):
+        (WebInspector.ObjectTreeSetIndexTreeElement.prototype._titleFragment):
+        (WebInspector.ObjectTreeSetIndexTreeElement.prototype._resolvedValuePropertyPath): Deleted.
+        Override resolved value since these are not about PropertyDescriptors.
+        This will make context menus work automatically.
+
 2015-03-04  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Improve display of previews with overflow
index 2ec409a..c321579 100644 (file)
     <script src="Views/TimelineDataGridNode.js"></script>
 
     <script src="Views/DOMDetailsSidebarPanel.js"></script>
+    <script src="Views/ObjectTreeBaseTreeElement.js"></script>
     <script src="Views/FolderizedTreeElement.js"></script>
     <script src="Views/SourceCodeTreeElement.js"></script>
     <script src="Views/StorageTreeElement.js"></script>
index 0a58baa..accb1d7 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-// FIXME: This should share more code with ObjectTreePropertyTreeElement. (getters, resolved values, context menus)
-
 WebInspector.ObjectTreeArrayIndexTreeElement = function(property, propertyPath)
 {
-    console.assert(property instanceof WebInspector.PropertyDescriptor);
-    console.assert(propertyPath instanceof WebInspector.PropertyPath);
     console.assert(property.isIndexProperty(), "ArrayIndexTreeElement expects numeric property names");
 
-    this._property = property;
-    this._propertyPath = propertyPath;
-
-    var classNames = ["object-tree-property", "object-tree-array-index"];
-    if (!this._property.hasValue())
-        classNames.push("accessor");
+    WebInspector.ObjectTreeBaseTreeElement.call(this, property, propertyPath, property);
 
-    WebInspector.GeneralTreeElement.call(this, classNames, this._titleFragment(), null, this._property, false);
+    this.mainTitle = this._titleFragment();
+    this.addClassName("object-tree-property");
+    this.addClassName("object-tree-array-index");
 
-    this.small = true;
-    this.toggleOnClick = false;
-    this.selectable = false;
-    this.tooltipHandledSeparately = true;
-    this.hasChildren = false;
+    if (!this.property.hasValue())
+        this.addClassName("accessor");
 };
 
 WebInspector.ObjectTreeArrayIndexTreeElement.prototype = {
     constructor: WebInspector.ObjectTreeArrayIndexTreeElement,
-    __proto__: WebInspector.GeneralTreeElement.prototype,
-
-    // Public
-
-    get property()
-    {
-        return this._property;
-    },
-
-    // Private
-
-    _resolvedValue: function()
-    {
-        if (this._getterValue)
-            return this._getterValue;
-        if (this._property.hasValue())
-            return this._property.value;
-        return null;
-    },
+    __proto__: WebInspector.ObjectTreeBaseTreeElement.prototype,
 
-    _propertyPathType: function()
-    {
-        if (this._getterValue || this._property.hasValue())
-            return WebInspector.PropertyPath.Type.Value;
-        if (this._property.hasGetter())
-            return WebInspector.PropertyPath.Type.Getter;
-        if (this._property.hasSetter())
-            return WebInspector.PropertyPath.Type.Setter;
-        return WebInspector.PropertyPath.Type.Value;
-    },
+    // Protected
 
-    _resolvedValuePropertyPath: function()
-    {
-        if (this._getterValue)
-            return this._propertyPath.appendPropertyDescriptor(this._getterValue, this._property, WebInspector.PropertyPath.Type.Value);
-        if (this._property.hasValue())
-            return this._propertyPath.appendPropertyDescriptor(this._property.value, this._property, WebInspector.PropertyPath.Type.Value);
-        return null;
-    },
-
-    _thisPropertyPath: function()
-    {
-        return this._propertyPath.appendPropertyDescriptor(null, this._property, this._propertyPathType());
-    },
-
-    _propertyPathString: function(propertyPath)
-    {
-        if (propertyPath.isFullPathImpossible())
-            return WebInspector.UIString("Unable to determine path to property from root");
-
-        return propertyPath.displayPath(this._propertyPathType());
-    },
-
-    _updateTitle: function()
+    invokedGetter: function()
     {
         this.mainTitle = this._titleFragment();
 
-        if (this._getterValue)
-            this.removeClassName("accessor");
-
-        this._updateHasChildren();
+        this.removeClassName("accessor");
     },
 
+    // Private
+
     _titleFragment: function()
     {
         var container = document.createDocumentFragment();
@@ -119,56 +59,28 @@ WebInspector.ObjectTreeArrayIndexTreeElement.prototype = {
         // Array index name.
         var nameElement = container.appendChild(document.createElement("span"));
         nameElement.className = "index-name";
-        nameElement.textContent = this._property.name;
-        nameElement.title = this._propertyPathString(this._thisPropertyPath());
+        nameElement.textContent = this.property.name;
+        nameElement.title = this.propertyPathString(this.thisPropertyPath());
 
         // Value.
         var valueElement = container.appendChild(document.createElement("span"));
         valueElement.className = "index-value";
 
-        var resolvedValue = this._resolvedValue();
+        var resolvedValue = this.resolvedValue();
         if (resolvedValue)
-            valueElement.appendChild(WebInspector.FormattedValue.createObjectTreeOrFormattedValueForRemoteObject(resolvedValue, this._resolvedValuePropertyPath()));
+            valueElement.appendChild(WebInspector.FormattedValue.createObjectTreeOrFormattedValueForRemoteObject(resolvedValue, this.resolvedValuePropertyPath()));
         else {
-            if (this._property.hasGetter())
-                container.appendChild(this._createInteractiveGetterElement());
-            if (!this._property.hasSetter())
-                container.appendChild(this._createReadOnlyIconElement());
+            if (this.property.hasGetter())
+                container.appendChild(this.createInteractiveGetterElement());
+            if (!this.property.hasSetter())
+                container.appendChild(this.createReadOnlyIconElement());
             // FIXME: What if just a setter?
         }
 
         valueElement.classList.add("value");
-        if (this._property.wasThrown || this._getterHadError)
+        if (this.hadError())
             valueElement.classList.add("error");
 
         return container;
-    },
-
-    _createInteractiveGetterElement: function()
-    {
-        var getterElement = document.createElement("img");
-        getterElement.className = "getter";
-        getterElement.title = WebInspector.UIString("Invoke getter");
-
-        getterElement.addEventListener("click", function(event) {
-            event.stopPropagation();
-            var lastNonPrototypeObject = this._propertyPath.lastNonPrototypeObject;
-            var getterObject = this._property.get;
-            lastNonPrototypeObject.invokeGetter(getterObject, function(error, result, wasThrown) {
-                this._getterHadError = !!(error || wasThrown);
-                this._getterValue = result;
-                this._updateTitle();
-            }.bind(this));
-        }.bind(this));
-
-        return getterElement;
-    },
-
-    _createReadOnlyIconElement: function()
-    {
-        var readOnlyElement = document.createElement("img");
-        readOnlyElement.className = "read-only";
-        readOnlyElement.title = WebInspector.UIString("Read only");
-        return readOnlyElement;
-    },
+    }
 };
diff --git a/Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js b/Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js
new file mode 100644 (file)
index 0000000..0e5300e
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.ObjectTreeBaseTreeElement = function(representedObject, propertyPath, property)
+{
+    console.assert(representedObject);
+    console.assert(propertyPath instanceof WebInspector.PropertyPath);
+    console.assert(!property || property instanceof WebInspector.PropertyDescriptor);
+
+    this._property = property;
+    this._propertyPath = propertyPath;
+
+    WebInspector.GeneralTreeElement.call(this, null, null, null, representedObject, false);
+
+    this.small = true;
+    this.toggleOnClick = true;
+    this.selectable = false;
+    this.tooltipHandledSeparately = true;
+};
+
+WebInspector.ObjectTreeBaseTreeElement.prototype = {
+    constructor: WebInspector.ObjectTreeBaseTreeElement,
+    __proto__: WebInspector.GeneralTreeElement.prototype,
+
+    // Public
+
+    get property()
+    {
+        return this._property;
+    },
+
+    get propertyPath()
+    {
+        return this._propertyPath;
+    },
+
+    // Protected
+
+    oncontextmenu: function(event)
+    {
+        this._contextMenuHandler(event);
+    },
+
+    resolvedValue: function()
+    {
+        console.assert(this._property);
+        if (this._getterValue)
+            return this._getterValue;
+        if (this._property.hasValue())
+            return this._property.value;
+        return null;
+    },
+
+    resolvedValuePropertyPath: function()
+    {
+        console.assert(this._property);
+        if (this._getterValue)
+            return this._propertyPath.appendPropertyDescriptor(this._getterValue, this._property, WebInspector.PropertyPath.Type.Value);
+        if (this._property.hasValue())
+            return this._propertyPath.appendPropertyDescriptor(this._property.value, this._property, WebInspector.PropertyPath.Type.Value);
+        return null;
+    },
+
+    thisPropertyPath: function()
+    {
+        console.assert(this._property);
+        return this._propertyPath.appendPropertyDescriptor(null, this._property, this.propertyPathType());
+    },
+
+    hadError: function()
+    {
+        console.assert(this._property);
+        return this._property.wasThrown || this._getterHadError;
+    },
+
+    propertyPathType: function()
+    {
+        console.assert(this._property);
+        if (this._getterValue || this._property.hasValue())
+            return WebInspector.PropertyPath.Type.Value;
+        if (this._property.hasGetter())
+            return WebInspector.PropertyPath.Type.Getter;
+        if (this._property.hasSetter())
+            return WebInspector.PropertyPath.Type.Setter;
+        return WebInspector.PropertyPath.Type.Value;
+    },
+
+    propertyPathString: function(propertyPath)
+    {
+        if (propertyPath.isFullPathImpossible())
+            return WebInspector.UIString("Unable to determine path to property from root");
+
+        return propertyPath.displayPath(this.propertyPathType());
+    },
+
+    createInteractiveGetterElement: function()
+    {
+        var getterElement = document.createElement("img");
+        getterElement.className = "getter";
+        getterElement.title = WebInspector.UIString("Invoke getter");
+
+        getterElement.addEventListener("click", function(event) {
+            event.stopPropagation();
+            var lastNonPrototypeObject = this._propertyPath.lastNonPrototypeObject;
+            var getterObject = this._property.get;
+            lastNonPrototypeObject.invokeGetter(getterObject, function(error, result, wasThrown) {
+                this._getterHadError = !!(error || wasThrown);
+                this._getterValue = result;
+                if (this.invokedGetter && typeof this.invokedGetter === "function")
+                    this.invokedGetter();
+            }.bind(this));
+        }.bind(this));
+
+        return getterElement;
+    },
+
+    createReadOnlyIconElement: function()
+    {
+        var readOnlyElement = document.createElement("img");
+        readOnlyElement.className = "read-only";
+        readOnlyElement.title = WebInspector.UIString("Read only");
+        return readOnlyElement;
+    },
+
+    // Private
+
+    _logValue: function(value)
+    {
+        var resolvedValue = value || this.resolvedValue();
+        if (!resolvedValue)
+            return;
+
+        var propertyPath = this.resolvedValuePropertyPath();
+        var isImpossible = propertyPath.isFullPathImpossible();
+        var text = isImpossible ? WebInspector.UIString("Selected Value") : propertyPath.displayPath(this.propertyPathType());
+
+        if (!isImpossible)
+            WebInspector.quickConsole.prompt.pushHistoryItem(text);
+
+        WebInspector.consoleLogViewController.appendImmediateExecutionWithResult(text, resolvedValue);
+    },
+
+    _contextMenuHandler: function(event)
+    {
+        var resolvedValue = this.resolvedValue();
+        if (!resolvedValue)
+            return;
+
+        var contextMenu = new WebInspector.ContextMenu(event);
+        contextMenu.appendItem(WebInspector.UIString("Log Value"), this._logValue.bind(this));
+
+        var propertyPath = this.resolvedValuePropertyPath();
+        if (propertyPath && !propertyPath.isFullPathImpossible()) {
+            contextMenu.appendItem(WebInspector.UIString("Copy Path to Property"), function() {
+                InspectorFrontendHost.copyText(propertyPath.displayPath(WebInspector.PropertyPath.Type.Value));
+            }.bind(this));
+        }
+
+        contextMenu.appendSeparator();
+
+        this._appendMenusItemsForObject(contextMenu, resolvedValue);
+
+        if (!contextMenu.isEmpty())
+            contextMenu.show();
+    },
+
+    _appendMenusItemsForObject: function(contextMenu, resolvedValue)
+    {
+        if (resolvedValue.type === "function") {
+            // FIXME: We should better handle bound functions.
+            if (!isFunctionStringNativeCode(resolvedValue.description)) {
+                contextMenu.appendItem(WebInspector.UIString("Jump to Definition"), function() {
+                    DebuggerAgent.getFunctionDetails(resolvedValue.objectId, function(error, response) {
+                        if (error)
+                            return;
+
+                        var location = response.location;
+                        var sourceCode = WebInspector.debuggerManager.scriptForIdentifier(location.scriptId);
+                        if (!sourceCode)
+                            return;
+
+                        var sourceCodeLocation = sourceCode.createSourceCodeLocation(location.lineNumber, location.columnNumber || 0);
+                        WebInspector.resourceSidebarPanel.showSourceCodeLocation(sourceCodeLocation);
+                    });
+                });
+            }
+            return;
+        }
+
+        if (resolvedValue.subtype === "node") {
+            contextMenu.appendItem(WebInspector.UIString("Reveal in DOM Tree"), function() {
+                resolvedValue.pushNodeToFrontend(function(nodeId) {
+                    WebInspector.domTreeManager.inspectElement(nodeId);
+                });
+            });
+            return;
+        }
+    }
+};
index 640bdeb..e8e3cf9 100644 (file)
 WebInspector.ObjectTreeMapEntryTreeElement = function(object, propertyPath)
 {
     console.assert(object instanceof WebInspector.RemoteObject);
-    console.assert(propertyPath instanceof WebInspector.PropertyPath);
 
     this._object = object;
-    this._propertyPath = propertyPath;
 
     // Treat the same as an array-index just with different strings and widths.
-    WebInspector.GeneralTreeElement.call(this, ["object-tree-array-index", "object-tree-map-entry"], this._titleFragment(), null, this._object, false);
+    WebInspector.ObjectTreeBaseTreeElement.call(this, this._object, propertyPath);
 
-    this.small = true;
-    this.toggleOnClick = false;
-    this.selectable = false;
-    this.tooltipHandledSeparately = true;
-    this.hasChildren = false;
+    this.mainTitle = this._titleFragment();
+    this.addClassName("object-tree-array-index");
+    this.addClassName("object-tree-map-entry");
 };
 
 WebInspector.ObjectTreeMapEntryTreeElement.prototype = {
     constructor: WebInspector.ObjectTreeMapEntryTreeElement,
-    __proto__: WebInspector.GeneralTreeElement.prototype,
+    __proto__: WebInspector.ObjectTreeBaseTreeElement.prototype,
 
     // Public
 
@@ -52,16 +48,15 @@ WebInspector.ObjectTreeMapEntryTreeElement.prototype = {
         return this._object;
     },
 
-    // Private
+    // Protected
 
-    _propertyPathString: function(propertyPath)
+    resolvedValue: function()
     {
-        if (propertyPath.isFullPathImpossible())
-            return WebInspector.UIString("Unable to determine path to property from root");
-
-        return propertyPath.displayPath(WebInspector.PropertyPath.Type.Value);
+        return this._object;
     },
 
+    // Private
+
     _titleFragment: function()
     {
         var container = document.createDocumentFragment();
@@ -72,7 +67,7 @@ WebInspector.ObjectTreeMapEntryTreeElement.prototype = {
         var nameElement = container.appendChild(document.createElement("span"));
         nameElement.className = "index-name";
         nameElement.textContent = this.displayPropertyName();
-        nameElement.title = this._propertyPathString(propertyPath);
+        nameElement.title = this.propertyPathString(propertyPath);
 
         // Value.
         var valueElement = container.appendChild(document.createElement("span"));
@@ -88,7 +83,7 @@ WebInspector.ObjectTreeMapKeyTreeElement = function(object, propertyPath)
 {
     WebInspector.ObjectTreeMapEntryTreeElement.call(this, object, propertyPath);
     this.addClassName("key");
-}
+};
 
 WebInspector.ObjectTreeMapKeyTreeElement.prototype = {
     constructor: WebInspector.ObjectTreeMapKeyTreeElement,
@@ -113,7 +108,7 @@ WebInspector.ObjectTreeMapValueTreeElement = function(object, propertyPath, key)
     this._key = key;
     WebInspector.ObjectTreeMapEntryTreeElement.call(this, object, propertyPath);
     this.addClassName("value");
-}
+};
 
 WebInspector.ObjectTreeMapValueTreeElement.prototype = {
     constructor: WebInspector.ObjectTreeMapValueTreeElement,
index 98fffee..5f4b2c6 100644 (file)
 
 WebInspector.ObjectTreePropertyTreeElement = function(property, propertyPath, mode, prototypeName)
 {
-    console.assert(property instanceof WebInspector.PropertyDescriptor);
-    console.assert(propertyPath instanceof WebInspector.PropertyPath);
-
-    this._property = property;
     this._mode = mode || WebInspector.ObjectTreeView.Mode.Properties;
-    this._propertyPath = propertyPath;
     this._prototypeName = prototypeName;
 
-    var classNames = ["object-tree-property"];
+    WebInspector.ObjectTreeBaseTreeElement.call(this, property, propertyPath, property);
 
-    if (this._property.hasValue()) {
-        classNames.push(this._property.value.type);
-        if (this._property.value.subtype)
-            classNames.push(this._property.value.subtype);
-    } else
-        classNames.push("accessor");
+    this.mainTitle = this._titleFragment();
+    this.addClassName("object-tree-property");
 
-    if (this._property.wasThrown)
-        classNames.push("had-error");
+    if (this.property.hasValue()) {
+        this.addClassName(this.property.value.type);
+        if (this.property.value.subtype)
+            this.addClassName(this.property.value.subtype);
+    } else
+        this.addClassName("accessor");
 
-    if (this._property.name === "__proto__")
-        classNames.push("prototype-property");
+    if (this.property.wasThrown)
+        this.addClassName("had-error");
+    if (this.property.name === "__proto__")
+        this.addClassName("prototype-property");
 
-    WebInspector.GeneralTreeElement.call(this, classNames, this._titleFragment(), null, this._property, false);
     this._updateTooltips();
     this._updateHasChildren();
-
-    this.small = true;
-    this.toggleOnClick = true;
-    this.selectable = false;
-    this.tooltipHandledSeparately = true;
 };
 
 WebInspector.ObjectTreePropertyTreeElement.prototype = {
     constructor: WebInspector.ObjectTreePropertyTreeElement,
-    __proto__: WebInspector.GeneralTreeElement.prototype,
-
-    // Public
-
-    get property()
-    {
-        return this._property;
-    },
+    __proto__: WebInspector.ObjectTreeBaseTreeElement.prototype,
 
     // Protected
 
@@ -88,92 +72,52 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
             this._previewView.showPreview();
     },
 
-    oncontextmenu: function(event)
-    {
-        this._contextMenuHandler(event);
-    },
-
-    // Private
-
-    _resolvedValue: function()
+    invokedGetter: function()
     {
-        if (this._getterValue)
-            return this._getterValue;
-        if (this._property.hasValue())
-            return this._property.value;
-        return null;
-    },
+        this.mainTitle = this._titleFragment();
 
-    _propertyPathType: function()
-    {
-        if (this._getterValue || this._property.hasValue())
-            return WebInspector.PropertyPath.Type.Value;
-        if (this._property.hasGetter())
-            return WebInspector.PropertyPath.Type.Getter;
-        if (this._property.hasSetter())
-            return WebInspector.PropertyPath.Type.Setter;
-        return WebInspector.PropertyPath.Type.Value;
-    },
+        var resolvedValue = this.resolvedValue();
+        this.addClassName(resolvedValue.type);
+        if (resolvedValue.subtype)
+            this.addClassName(resolvedValue.subtype);
+        if (this.hadError())
+            this.addClassName("had-error");
+        this.removeClassName("accessor");
 
-    _resolvedValuePropertyPath: function()
-    {
-        if (this._getterValue)
-            return this._propertyPath.appendPropertyDescriptor(this._getterValue, this._property, WebInspector.PropertyPath.Type.Value);
-        if (this._property.hasValue())
-            return this._propertyPath.appendPropertyDescriptor(this._property.value, this._property, WebInspector.PropertyPath.Type.Value);
-        return null;
+        this._updateHasChildren();
     },
 
-    _thisPropertyPath: function()
-    {
-        return this._propertyPath.appendPropertyDescriptor(null, this._property, this._propertyPathType());
-    },
+    // Private
 
     _updateHasChildren: function()
     {
-        var resolvedValue = this._resolvedValue();
+        var resolvedValue = this.resolvedValue();
         var valueHasChildren = (resolvedValue && resolvedValue.hasChildren);
-        var wasThrown = this._property.wasThrown || this._getterHadError;
+        var wasThrown = this.hadError();
 
         if (this._mode === WebInspector.ObjectTreeView.Mode.Properties)
             this.hasChildren = !wasThrown && valueHasChildren;
         else
-            this.hasChildren = !wasThrown && valueHasChildren && (this._property.name === "__proto__" || this._alwaysDisplayAsProperty());
+            this.hasChildren = !wasThrown && valueHasChildren && (this.property.name === "__proto__" || this._alwaysDisplayAsProperty());
     },
 
     _updateTooltips: function()
     {
         var attributes = [];
 
-        if (this._property.configurable)
+        if (this.property.configurable)
             attributes.push("configurable");
-        if (this._property.enumerable)
+        if (this.property.enumerable)
             attributes.push("enumerable");
-        if (this._property.writable)
+        if (this.property.writable)
             attributes.push("writable");
 
         this.iconElement.title = attributes.join(" ");
     },
 
-    _updateTitleAndIcon: function()
-    {
-        this.mainTitle = this._titleFragment();
-
-        if (this._getterValue) {
-            this.addClassName(this._getterValue.type);
-            if (this._getterValue.subtype)
-                this.addClassName(this._getterValue.subtype);
-            if (this._getterHadError)
-                this.addClassName("had-error");
-            this.removeClassName("accessor");
-        }
-
-        this._updateHasChildren();
-    },
-
     _titleFragment: function()
     {
-        if (this._property.name === "__proto__")
+        if (this.property.name === "__proto__")
             return this._createTitlePrototype();
 
         if (this._mode === WebInspector.ObjectTreeView.Mode.Properties)
@@ -184,13 +128,13 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
 
     _createTitlePrototype: function()
     {
-        console.assert(this._property.hasValue());
-        console.assert(this._property.name === "__proto__");
+        console.assert(this.property.hasValue());
+        console.assert(this.property.name === "__proto__");
 
         var nameElement = document.createElement("span");
         nameElement.className = "prototype-name";
-        nameElement.textContent = WebInspector.UIString("%s Prototype").format(this._sanitizedPrototypeString(this._property.value));
-        nameElement.title = this._propertyPathString(this._thisPropertyPath());
+        nameElement.textContent = WebInspector.UIString("%s Prototype").format(this._sanitizedPrototypeString(this.property.value));
+        nameElement.title = this.propertyPathString(this.thisPropertyPath());
         return nameElement;
     },
 
@@ -201,42 +145,40 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
         // Property name.
         var nameElement = document.createElement("span");
         nameElement.className = "property-name";
-        nameElement.textContent = this._property.name + ": ";
-        nameElement.title = this._propertyPathString(this._thisPropertyPath());
+        nameElement.textContent = this.property.name + ": ";
+        nameElement.title = this.propertyPathString(this.thisPropertyPath());
 
         // Property attributes.
         if (this._mode === WebInspector.ObjectTreeView.Mode.Properties) {
-            if (!this._property.enumerable)
+            if (!this.property.enumerable)
                 nameElement.classList.add("not-enumerable");
         }
 
         // Value / Getter Value / Getter.
         var valueOrGetterElement;
-        var resolvedValue = this._resolvedValue();
+        var resolvedValue = this.resolvedValue();
         if (resolvedValue) {
             if (resolvedValue.preview) {
                 this._previewView = new WebInspector.ObjectPreviewView(resolvedValue.preview);
                 valueOrGetterElement = this._previewView.element;
             } else {
-                valueOrGetterElement = WebInspector.FormattedValue.createElementForRemoteObject(resolvedValue, this._property.wasThrown || this._getterHadError);
+                valueOrGetterElement = WebInspector.FormattedValue.createElementForRemoteObject(resolvedValue, this.hadError());
 
                 // Special case a function property string.
                 if (resolvedValue.type === "function")
                     valueOrGetterElement.textContent = this._functionPropertyString();
             }
-
-            // FIXME: Option+Click for Value.
         } else {
             valueOrGetterElement = document.createElement("span");
-            if (this._property.hasGetter())
-                valueOrGetterElement.appendChild(this._createInteractiveGetterElement());
-            if (!this._property.hasSetter())
-                valueOrGetterElement.appendChild(this._createReadOnlyIconElement());
+            if (this.property.hasGetter())
+                valueOrGetterElement.appendChild(this.createInteractiveGetterElement());
+            if (!this.property.hasSetter())
+                valueOrGetterElement.appendChild(this.createReadOnlyIconElement());
             // FIXME: What if just a setter?
         }
 
         valueOrGetterElement.classList.add("value");
-        if (this._property.wasThrown || this._getterHadError)
+        if (this.hadError())
             valueOrGetterElement.classList.add("error");
 
         container.appendChild(nameElement);
@@ -250,12 +192,9 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
         if (this._alwaysDisplayAsProperty())
             return this._createTitlePropertyStyle();
 
-        // Fetched getter values should already have been shown as properties.
-        console.assert(!this._getterValue);
-
         // No API to display.
-        var isFunction = this._property.hasValue() && this._property.value.type === "function";
-        if (!isFunction && !this._property.hasGetter() && !this._property.hasSetter())
+        var isFunction = this.property.hasValue() && this.property.value.type === "function";
+        if (!isFunction && !this.property.hasGetter() && !this.property.hasSetter())
             return null;
 
         var container = document.createDocumentFragment();
@@ -263,8 +202,8 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
         // Function / Getter / Setter.
         var nameElement = document.createElement("span");
         nameElement.className = "property-name";
-        nameElement.textContent = this._property.name;
-        nameElement.title = this._propertyPathString(this._thisPropertyPath());
+        nameElement.textContent = this.property.name;
+        nameElement.title = this.propertyPathString(this.thisPropertyPath());
         container.appendChild(nameElement);
 
         if (isFunction) {
@@ -273,52 +212,24 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
             paramElement.textContent = this._functionParameterString();
             container.appendChild(paramElement);
         } else {
-            if (this._property.hasGetter())
-                container.appendChild(this._createInteractiveGetterElement());
-            if (!this._property.hasSetter())
-                container.appendChild(this._createReadOnlyIconElement());
+            if (this.property.hasGetter())
+                container.appendChild(this.createInteractiveGetterElement());
+            if (!this.property.hasSetter())
+                container.appendChild(this.createReadOnlyIconElement());
             // FIXME: What if just a setter?
         }
 
         return container;
     },
 
-    _createInteractiveGetterElement: function()
-    {
-        var getterElement = document.createElement("img");
-        getterElement.className = "getter";
-        getterElement.title = WebInspector.UIString("Invoke getter");
-
-        getterElement.addEventListener("click", function(event) {
-            event.stopPropagation();
-            var lastNonPrototypeObject = this._propertyPath.lastNonPrototypeObject;
-            var getterObject = this._property.get;
-            lastNonPrototypeObject.invokeGetter(getterObject, function(error, result, wasThrown) {
-                this._getterHadError = !!(error || wasThrown);
-                this._getterValue = result;
-                this._updateTitleAndIcon();
-            }.bind(this));
-        }.bind(this));
-
-        return getterElement;
-    },
-
-    _createReadOnlyIconElement: function()
-    {
-        var readOnlyElement = document.createElement("img");
-        readOnlyElement.className = "read-only";
-        readOnlyElement.title = WebInspector.UIString("Read only");
-        return readOnlyElement;
-    },
-
     _alwaysDisplayAsProperty: function()
     {
         // Constructor, though a function, is often better treated as an expandable object.
-        if (this._property.name === "constructor")
+        if (this.property.name === "constructor")
             return true;
 
         // Non-function objects are often better treated as properties.
-        if (this._property.hasValue() && this._property.value.type !== "function")
+        if (this.property.hasValue() && this.property.value.type !== "function")
             return true;
 
         // Fetched getter value.
@@ -335,7 +246,7 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
 
     _functionParameterString: function()
     {
-        var resolvedValue = this._resolvedValue();
+        var resolvedValue = this.resolvedValue();
         console.assert(resolvedValue.type === "function");
 
         // For Native methods, the toString is poor. We try to provide good function parameter strings.
@@ -378,23 +289,15 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
         return value.description.replace(/Prototype$/, "");
     },
 
-    _propertyPathString: function(propertyPath)
-    {
-        if (propertyPath.isFullPathImpossible())
-            return WebInspector.UIString("Unable to determine path to property from root");
-
-        return propertyPath.displayPath(this._propertyPathType());
-    },
-
     _updateChildren: function()
     {
         if (this.children.length && !this.shouldRefreshChildren)
             return;
 
-        var resolvedValue = this._resolvedValue();
+        var resolvedValue = this.resolvedValue();
         if (resolvedValue.isCollectionType() && this._mode === WebInspector.ObjectTreeView.Mode.Properties)
             resolvedValue.getCollectionEntries(0, 100, this._updateChildrenInternal.bind(this, this._updateEntries, this._mode));
-        else if (this._property.name === "__proto__")
+        else if (this.property.name === "__proto__")
             resolvedValue.getOwnPropertyDescriptors(this._updateChildrenInternal.bind(this, this._updateProperties, WebInspector.ObjectTreeView.Mode.API));
         else
             resolvedValue.getDisplayablePropertyDescriptors(this._updateChildrenInternal.bind(this, this._updateProperties, this._mode));
@@ -410,7 +313,7 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
             return;
         }
 
-        handler.call(this, list, this._resolvedValuePropertyPath(), mode);
+        handler.call(this, list, this.resolvedValuePropertyPath(), mode);
     },
 
     _updateEntries: function(entries, propertyPath, mode)
@@ -429,7 +332,7 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
         }
 
         // Show the prototype so users can see the API.
-        var resolvedValue = this._resolvedValue();
+        var resolvedValue = this.resolvedValue();
         resolvedValue.getOwnPropertyDescriptor("__proto__", function(propertyDescriptor) {
             if (propertyDescriptor)
                 this.appendChild(new WebInspector.ObjectTreePropertyTreeElement(propertyDescriptor, propertyPath, mode));
@@ -440,13 +343,13 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
     {
         properties.sort(WebInspector.ObjectTreeView.ComparePropertyDescriptors);
 
-        var resolvedValue = this._resolvedValue();
+        var resolvedValue = this.resolvedValue();
         var isArray = resolvedValue.isArray();
         var isPropertyMode = mode === WebInspector.ObjectTreeView.Mode.Properties || this._getterValue;
         var isAPI = mode === WebInspector.ObjectTreeView.Mode.API;
 
         var prototypeName = undefined;
-        if (this._property.name === "__proto__") {
+        if (this.property.name === "__proto__") {
             if (resolvedValue.description)
                 prototypeName = this._sanitizedPrototypeString(resolvedValue);
         }
@@ -471,78 +374,5 @@ WebInspector.ObjectTreePropertyTreeElement.prototype = {
             var emptyMessageElement = WebInspector.ObjectTreeView.emptyMessageElement(WebInspector.UIString("No Properties."));
             this.appendChild(new TreeElement(emptyMessageElement, null, false));
         }
-    },
-
-    _logValue: function(value)
-    {
-        var resolvedValue = value || this._resolvedValue();
-        if (!resolvedValue)
-            return;
-
-        var propertyPath = this._resolvedValuePropertyPath();
-        var isImpossible = propertyPath.isFullPathImpossible();
-        var text = isImpossible ? WebInspector.UIString("Selected Value") : propertyPath.displayPath(this._propertyPathType());
-
-        if (!isImpossible)
-            WebInspector.quickConsole.prompt.pushHistoryItem(text);
-
-        WebInspector.consoleLogViewController.appendImmediateExecutionWithResult(text, resolvedValue);
-    },
-
-    _contextMenuHandler: function(event)
-    {
-        var resolvedValue = this._resolvedValue();
-        if (!resolvedValue)
-            return;
-
-        var contextMenu = new WebInspector.ContextMenu(event);
-        contextMenu.appendItem(WebInspector.UIString("Log Value"), this._logValue.bind(this));
-
-        var propertyPath = this._resolvedValuePropertyPath();
-        if (propertyPath && !propertyPath.isFullPathImpossible()) {
-            contextMenu.appendItem(WebInspector.UIString("Copy Path to Property"), function() {
-                InspectorFrontendHost.copyText(propertyPath.displayPath(WebInspector.PropertyPath.Type.Value));
-            }.bind(this));
-        }
-
-        contextMenu.appendSeparator();
-
-        this._appendMenusItemsForObject(contextMenu, resolvedValue);
-
-        if (!contextMenu.isEmpty())
-            contextMenu.show();
-    },
-
-    _appendMenusItemsForObject: function(contextMenu, resolvedValue)
-    {
-        if (resolvedValue.type === "function") {
-            // FIXME: We should better handle bound functions.
-            if (!isFunctionStringNativeCode(resolvedValue.description)) {
-                contextMenu.appendItem(WebInspector.UIString("Jump to Definition"), function() {
-                    DebuggerAgent.getFunctionDetails(resolvedValue.objectId, function(error, response) {
-                        if (error)
-                            return;
-
-                        var location = response.location;
-                        var sourceCode = WebInspector.debuggerManager.scriptForIdentifier(location.scriptId);
-                        if (!sourceCode)
-                            return;
-
-                        var sourceCodeLocation = sourceCode.createSourceCodeLocation(location.lineNumber, location.columnNumber || 0);
-                        WebInspector.resourceSidebarPanel.showSourceCodeLocation(sourceCodeLocation);
-                    });
-                });
-            }
-            return;
-        }
-
-        if (resolvedValue.subtype === "node") {
-            contextMenu.appendItem(WebInspector.UIString("Reveal in DOM Tree"), function() {
-                resolvedValue.pushNodeToFrontend(function(nodeId) {
-                    WebInspector.domTreeManager.inspectElement(nodeId);
-                });
-            });
-            return;
-        }
     }
 };
index 324c747..d9a8575 100644 (file)
@@ -28,21 +28,17 @@ WebInspector.ObjectTreeSetIndexTreeElement = function(object, propertyPath)
     console.assert(object instanceof WebInspector.RemoteObject);
 
     this._object = object;
-    this._propertyPath = propertyPath;
 
-    // Treat the same as an array-index just with a different character.
-    WebInspector.GeneralTreeElement.call(this, ["object-tree-array-index"], this._titleFragment(), null, this._object, false);
+    // Treat the same as an array-index just with different strings and widths.
+    WebInspector.ObjectTreeBaseTreeElement.call(this, this._object, propertyPath);
 
-    this.small = true;
-    this.toggleOnClick = false;
-    this.selectable = false;
-    this.tooltipHandledSeparately = true;
-    this.hasChildren = false;
+    this.mainTitle = this._titleFragment();
+    this.addClassName("object-tree-array-index");
 };
 
 WebInspector.ObjectTreeSetIndexTreeElement.prototype = {
     constructor: WebInspector.ObjectTreeSetIndexTreeElement,
-    __proto__: WebInspector.GeneralTreeElement.prototype,
+    __proto__: WebInspector.ObjectTreeBaseTreeElement.prototype,
 
     // Public
 
@@ -51,17 +47,21 @@ WebInspector.ObjectTreeSetIndexTreeElement.prototype = {
         return this._object;
     },
 
-    // Private
+    // Protected
 
-    _resolvedValuePropertyPath: function()
+    resolvedValue: function()
     {
-        return this._propertyPath.appendSetIndex(this._object);
+        return this._object;
     },
 
+    // Private
+
     _titleFragment: function()
     {
         var container = document.createDocumentFragment();
 
+        var propertyPath = this.propertyPath.appendSetIndex(this._object);
+
         // Set bullet.
         var nameElement = container.appendChild(document.createElement("span"));
         nameElement.className = "index-name";
@@ -71,7 +71,7 @@ WebInspector.ObjectTreeSetIndexTreeElement.prototype = {
         // Value.
         var valueElement = container.appendChild(document.createElement("span"));
         valueElement.className = "index-value";
-        valueElement.appendChild(WebInspector.FormattedValue.createObjectTreeOrFormattedValueForRemoteObject(this._object, this._resolvedValuePropertyPath()));
+        valueElement.appendChild(WebInspector.FormattedValue.createObjectTreeOrFormattedValueForRemoteObject(this._object, propertyPath));
 
         return container;
     }