Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / components / ObjectPropertiesSection.js
index c42805a..69c0932 100644 (file)
@@ -37,7 +37,7 @@
  */
 WebInspector.ObjectPropertiesSection = function(object, title, subtitle, emptyPlaceholder, ignoreHasOwnProperty, extraProperties, treeElementConstructor)
 {
-    this.emptyPlaceholder = (emptyPlaceholder || WebInspector.UIString("No Properties"));
+    this._emptyPlaceholder = emptyPlaceholder;
     this.object = object;
     this.ignoreHasOwnProperty = ignoreHasOwnProperty;
     this.extraProperties = extraProperties;
@@ -109,16 +109,9 @@ WebInspector.ObjectPropertiesSection.prototype = {
         WebInspector.ObjectPropertyTreeElement.populateWithProperties(this.propertiesTreeOutline,
             properties, internalProperties,
             rootTreeElementConstructor, rootPropertyComparer,
-            this.skipProto, this.object);
+            this.skipProto, this.object, this._emptyPlaceholder);
 
         this.propertiesForTest = properties;
-
-        if (!this.propertiesTreeOutline.children.length) {
-            var title = document.createElementWithClass("div", "info");
-            title.textContent = this.emptyPlaceholder;
-            var infoElement = new TreeElement(title, null, false);
-            this.propertiesTreeOutline.appendChild(infoElement);
-        }
     },
 
     __proto__: WebInspector.PropertiesSection.prototype
@@ -484,8 +477,9 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
 /**
  * @param {!TreeElement} treeElement
  * @param {!WebInspector.RemoteObject} value
+ * @param {string=} emptyPlaceholder
  */
-WebInspector.ObjectPropertyTreeElement.populate = function(treeElement, value) {
+WebInspector.ObjectPropertyTreeElement.populate = function(treeElement, value, emptyPlaceholder) {
     if (treeElement.children.length && !treeElement.shouldRefreshChildren)
         return;
 
@@ -504,12 +498,9 @@ WebInspector.ObjectPropertyTreeElement.populate = function(treeElement, value) {
         treeElement.removeChildren();
         if (!properties)
             return;
-        if (!internalProperties)
-            internalProperties = [];
-
         WebInspector.ObjectPropertyTreeElement.populateWithProperties(treeElement, properties, internalProperties,
             treeElement.treeOutline.section.treeElementConstructor, WebInspector.ObjectPropertiesSection.CompareProperties,
-            treeElement.treeOutline.section.skipProto, value);
+            treeElement.treeOutline.section.skipProto, value, emptyPlaceholder);
     }
 
     WebInspector.RemoteObject.loadFromObjectPerProto(value, callback);
@@ -523,8 +514,9 @@ WebInspector.ObjectPropertyTreeElement.populate = function(treeElement, value) {
  * @param {function (!WebInspector.RemoteObjectProperty, !WebInspector.RemoteObjectProperty): number} comparator
  * @param {boolean} skipProto
  * @param {?WebInspector.RemoteObject} value
+ * @param {?string=} emptyPlaceholder
  */
-WebInspector.ObjectPropertyTreeElement.populateWithProperties = function(treeElement, properties, internalProperties, treeElementConstructor, comparator, skipProto, value) {
+WebInspector.ObjectPropertyTreeElement.populateWithProperties = function(treeElement, properties, internalProperties, treeElementConstructor, comparator, skipProto, value, emptyPlaceholder) {
     properties.sort(comparator);
 
     for (var i = 0; i < properties.length; ++i) {
@@ -570,16 +562,34 @@ WebInspector.ObjectPropertyTreeElement.populateWithProperties = function(treeEle
         if (!hasTargetFunction)
             treeElement.appendChild(new WebInspector.FunctionScopeMainTreeElement(value));
     }
+    if (value && value.type === "object" && (value.subtype === "map" || value.subtype === "set"))
+        treeElement.appendChild(new WebInspector.CollectionEntriesMainTreeElement(value));
     if (internalProperties) {
         for (var i = 0; i < internalProperties.length; i++) {
             internalProperties[i].parentObject = value;
             treeElement.appendChild(new treeElementConstructor(internalProperties[i]));
         }
     }
+
+    WebInspector.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded(treeElement, emptyPlaceholder);
 }
 
 /**
- * @param {!WebInspector.RemoteObject} object
+ * @param {!TreeElement|!TreeOutline} treeElement
+ * @param {?string=} emptyPlaceholder
+ */
+WebInspector.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded = function(treeElement, emptyPlaceholder)
+{
+    if (treeElement.children.length)
+        return;
+    var title = document.createElementWithClass("div", "info");
+    title.textContent = emptyPlaceholder || WebInspector.UIString("No Properties");
+    var infoElement = new TreeElement(title, null, false);
+    treeElement.appendChild(infoElement);
+}
+
+/**
+ * @param {?WebInspector.RemoteObject} object
  * @param {!Array.<string>} propertyPath
  * @param {function(?WebInspector.RemoteObject, boolean=)} callback
  * @return {!Element}
@@ -587,8 +597,11 @@ WebInspector.ObjectPropertyTreeElement.populateWithProperties = function(treeEle
 WebInspector.ObjectPropertyTreeElement.createRemoteObjectAccessorPropertySpan = function(object, propertyPath, callback)
 {
     var rootElement = document.createElement("span");
-    var element = rootElement.createChild("span", "properties-calculate-value-button");
+    var element = rootElement.createChild("span");
     element.textContent = WebInspector.UIString("(...)");
+    if (!object)
+        return rootElement;
+    element.classList.add("properties-calculate-value-button");
     element.title = WebInspector.UIString("Invoke property getter");
     element.addEventListener("click", onInvokeGetterClick, false);
 
@@ -631,9 +644,7 @@ WebInspector.FunctionScopeMainTreeElement.prototype = {
                 return;
             this.removeChildren();
 
-            var scopeChain = response.scopeChain;
-            if (!scopeChain)
-                return;
+            var scopeChain = response.scopeChain || [];
             for (var i = 0; i < scopeChain.length; ++i) {
                 var scope = scopeChain[i];
                 var title = null;
@@ -676,11 +687,14 @@ WebInspector.FunctionScopeMainTreeElement.prototype = {
                 } else {
                     var scopeRef = new WebInspector.ScopeRef(i, undefined, this._remoteObject.objectId);
                     var remoteObject = runtimeModel.createScopeRemoteObject(scope.object, scopeRef);
-                    var scopeTreeElement = new WebInspector.ScopeTreeElement(title, null, remoteObject);
+                    var scopeTreeElement = new WebInspector.ScopeTreeElement(title, remoteObject);
                     this.appendChild(scopeTreeElement);
                 }
             }
+
+            WebInspector.ObjectPropertyTreeElement._appendEmptyPlaceholderIfNeeded(this, WebInspector.UIString("No Scopes"));
         }
+
         this._remoteObject.functionDetails(didGetDetails.bind(this));
     },
 
@@ -690,13 +704,64 @@ WebInspector.FunctionScopeMainTreeElement.prototype = {
 /**
  * @constructor
  * @extends {TreeElement}
+ * @param {!WebInspector.RemoteObject} remoteObject
+ */
+WebInspector.CollectionEntriesMainTreeElement = function(remoteObject)
+{
+    TreeElement.call(this, "<entries>", null, false);
+    this.toggleOnClick = true;
+    this.selectable = false;
+    this._remoteObject = remoteObject;
+    this.hasChildren = true;
+}
+
+WebInspector.CollectionEntriesMainTreeElement.prototype = {
+    onpopulate: function()
+    {
+        if (this.children.length && !this.shouldRefreshChildren)
+            return;
+
+        /**
+         * @param {?Array.<!DebuggerAgent.CollectionEntry>} entries
+         * @this {WebInspector.CollectionEntriesMainTreeElement}
+         */
+        function didGetCollectionEntries(entries)
+        {
+            if (!entries)
+                return;
+            this.removeChildren();
+
+            var entriesLocalObject = [];
+            var runtimeModel = this._remoteObject.target().runtimeModel;
+            for (var i = 0; i < entries.length; ++i) {
+                var entry = entries[i];
+                if (entry.key) {
+                    entriesLocalObject.push(new WebInspector.MapEntryLocalJSONObject({
+                        key: runtimeModel.createRemoteObject(entry.key),
+                        value: runtimeModel.createRemoteObject(entry.value)
+                    }));
+                } else {
+                    entriesLocalObject.push(runtimeModel.createRemoteObject(entry.value));
+                }
+            }
+            WebInspector.ObjectPropertyTreeElement.populate(this, WebInspector.RemoteObject.fromLocalObject(entriesLocalObject), WebInspector.UIString("No Entries"));
+            this.title = "<entries>[" + entriesLocalObject.length + "]";
+        }
+
+        this._remoteObject.collectionEntries(didGetCollectionEntries.bind(this));
+    },
+
+    __proto__: TreeElement.prototype
+}
+
+/**
+ * @constructor
+ * @extends {TreeElement}
  * @param {string} title
- * @param {?string} subtitle
  * @param {!WebInspector.RemoteObject} remoteObject
  */
-WebInspector.ScopeTreeElement = function(title, subtitle, remoteObject)
+WebInspector.ScopeTreeElement = function(title, remoteObject)
 {
-    // TODO: use subtitle parameter.
     TreeElement.call(this, title, null, false);
     this.toggleOnClick = true;
     this.selectable = false;
@@ -724,6 +789,8 @@ WebInspector.ScopeTreeElement.prototype = {
 WebInspector.ArrayGroupingTreeElement = function(object, fromIndex, toIndex, propertyCount)
 {
     TreeElement.call(this, String.sprintf("[%d \u2026 %d]", fromIndex, toIndex), undefined, true);
+    this.toggleOnClick = true;
+    this.selectable = false;
     this._fromIndex = fromIndex;
     this._toIndex = toIndex;
     this._object = object;