Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / components / ObjectPropertiesSection.js
index 444f203..c42805a 100644 (file)
@@ -114,8 +114,7 @@ WebInspector.ObjectPropertiesSection.prototype = {
         this.propertiesForTest = properties;
 
         if (!this.propertiesTreeOutline.children.length) {
-            var title = document.createElement("div");
-            title.className = "info";
+            var title = document.createElementWithClass("div", "info");
             title.textContent = this.emptyPlaceholder;
             var infoElement = new TreeElement(title, null, false);
             this.propertiesTreeOutline.appendChild(infoElement);
@@ -189,12 +188,12 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
 
     update: function()
     {
-        this.nameElement = document.createElement("span");
-        this.nameElement.className = "name";
+        this.nameElement = document.createElementWithClass("span", "name");
         var name = this.property.name;
         if (/^\s|\s$|^$|\n/.test(name))
-            name = "\"" + name.replace(/\n/g, "\u21B5") + "\"";
-        this.nameElement.textContent = name;
+            this.nameElement.createTextChildren("\"", name.replace(/\n/g, "\u21B5"), "\"");
+        else
+            this.nameElement.textContent = name;
         if (!this.property.enumerable)
             this.nameElement.classList.add("dimmed");
         if (this.property.isAccessorProperty())
@@ -202,39 +201,48 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
         if (this.property.symbol)
             this.nameElement.addEventListener("contextmenu", this._contextMenuFired.bind(this, this.property.symbol), false);
 
-        var separatorElement = document.createElement("span");
-        separatorElement.className = "separator";
+        var separatorElement = document.createElementWithClass("span", "separator");
         separatorElement.textContent = ": ";
 
         if (this.property.value) {
-            this.valueElement = document.createElement("span");
-            this.valueElement.className = "value";
+            this.valueElement = document.createElementWithClass("span", "value");
+            var type = this.property.value.type;
+            var subtype = this.property.value.subtype;
             var description = this.property.value.description;
+            var prefix;
             var valueText;
+            var suffix;
             if (this.property.wasThrown) {
-                valueText = "[Exception: " + description + "]";
-            } else if (this.property.value.type === "string" && typeof description === "string") {
+                prefix = "[Exception: ";
+                valueText = description;
+                suffix = "]";
+            } else if (type === "string" && typeof description === "string") {
                 // Render \n as a nice unicode cr symbol.
-                valueText = "\"" + description.replace(/\n/g, "\u21B5") + "\"";
+                prefix = "\"";
+                valueText = description.replace(/\n/g, "\u21B5");
+                suffix = "\"";
                 this.valueElement._originalTextContent = "\"" + description + "\"";
-            } else if (this.property.value.type === "function" && typeof description === "string") {
-                valueText = /.*/.exec(description)[0].replace(/ +$/g, "");
+            } else if (type === "function" && typeof description === "string") {
+                // Render function description until the first \n.
+                valueText = /.*/.exec(description)[0].replace(/\s+$/g, "");
                 this.valueElement._originalTextContent = description;
-            } else if (this.property.value.type !== "object" || this.property.value.subtype !== "node") {
+            } else if (type !== "object" || subtype !== "node") {
                 valueText = description;
             }
             this.valueElement.setTextContentTruncatedIfNeeded(valueText || "");
+            if (prefix)
+                this.valueElement.insertBefore(document.createTextNode(prefix), this.valueElement.firstChild);
+            if (suffix)
+                this.valueElement.createTextChild(suffix);
 
             if (this.property.wasThrown)
                 this.valueElement.classList.add("error");
-            if (this.property.value.subtype)
-                this.valueElement.classList.add("console-formatted-" + this.property.value.subtype);
-            else if (this.property.value.type)
-                this.valueElement.classList.add("console-formatted-" + this.property.value.type);
+            if (subtype || type)
+                this.valueElement.classList.add("console-formatted-" + (subtype || type));
 
             this.valueElement.addEventListener("contextmenu", this._contextMenuFired.bind(this, this.property.value), false);
-            if (this.property.value.type === "object" && this.property.value.subtype === "node" && this.property.value.description) {
-                WebInspector.DOMPresentationUtils.createSpansForNodeTitle(this.valueElement, this.property.value.description);
+            if (type === "object" && subtype === "node" && description) {
+                WebInspector.DOMPresentationUtils.createSpansForNodeTitle(this.valueElement, description);
                 this.valueElement.addEventListener("mousemove", this._mouseMove.bind(this, this.property.value), false);
                 this.valueElement.addEventListener("mouseout", this._mouseOut.bind(this, this.property.value), false);
             } else {
@@ -248,16 +256,13 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
             if (this.property.getter) {
                 this.valueElement = WebInspector.ObjectPropertyTreeElement.createRemoteObjectAccessorPropertySpan(this.property.parentObject, [this.property.name], this._onInvokeGetterClick.bind(this));
             } else {
-                this.valueElement = document.createElement("span");
-                this.valueElement.className = "console-formatted-undefined";
+                this.valueElement = document.createElementWithClass("span", "console-formatted-undefined");
                 this.valueElement.textContent = WebInspector.UIString("<unreadable>");
                 this.valueElement.title = WebInspector.UIString("No property getter");
             }
         }
 
-        this.listItemElement.appendChild(this.nameElement);
-        this.listItemElement.appendChild(separatorElement);
-        this.listItemElement.appendChild(this.valueElement);
+        this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement);
     },
 
     _contextMenuFired: function(value, event)
@@ -405,11 +410,12 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
      */
     applyExpression: function(expression)
     {
+        var property = WebInspector.RemoteObject.toCallArgument(this.property.symbol || this.property.name);
         expression = expression.trim();
         if (expression)
-            this.property.parentObject.setPropertyValue(this.property.name, expression, callback.bind(this));
+            this.property.parentObject.setPropertyValue(property, expression, callback.bind(this));
         else
-            this.property.parentObject.deleteProperty(this.property.name, callback.bind(this));
+            this.property.parentObject.deleteProperty(property, callback.bind(this));
 
         /**
          * @param {?Protocol.Error} error
@@ -616,7 +622,7 @@ WebInspector.FunctionScopeMainTreeElement.prototype = {
             return;
 
         /**
-         * @param {?DebuggerAgent.FunctionDetails} response
+         * @param {?WebInspector.DebuggerModel.FunctionDetails} response
          * @this {WebInspector.FunctionScopeMainTreeElement}
          */
         function didGetDetails(response)