Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8687)

Unified Diff: chrome/tools/test/reference_build/chrome_linux/resources/inspector/ObjectPropertiesSection.js

Issue 177049: On Linux, move the passing of filedescriptors to a dedicated socketpair(). (Closed)
Patch Set: Removed *.d files from reference build Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/tools/test/reference_build/chrome_linux/resources/inspector/ObjectPropertiesSection.js
diff --git a/chrome/tools/test/reference_build/chrome_linux/resources/inspector/ObjectPropertiesSection.js b/chrome/tools/test/reference_build/chrome_linux/resources/inspector/ObjectPropertiesSection.js
index ab6ac5567a3cc7b610aa0e5dbde33ba97e273b08..63073bd62da62df022e12869b8cc5a8be398948e 100644
--- a/chrome/tools/test/reference_build/chrome_linux/resources/inspector/ObjectPropertiesSection.js
+++ b/chrome/tools/test/reference_build/chrome_linux/resources/inspector/ObjectPropertiesSection.js
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2009 Joseph Pecoraro
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,15 +26,6 @@
WebInspector.ObjectPropertiesSection = function(object, title, subtitle, emptyPlaceholder, ignoreHasOwnProperty, extraProperties, treeElementConstructor)
{
- if (!title) {
- title = Object.describe(object);
- if (title.match(/Prototype$/)) {
- title = title.replace(/Prototype$/, "");
- if (!subtitle)
- subtitle = WebInspector.UIString("Prototype");
- }
- }
-
this.emptyPlaceholder = (emptyPlaceholder || WebInspector.UIString("No Properties"));
this.object = object;
this.ignoreHasOwnProperty = ignoreHasOwnProperty;
@@ -52,70 +44,103 @@ WebInspector.ObjectPropertiesSection.prototype = {
update: function()
{
- var properties = [];
- for (var prop in this.object)
- properties.push(prop);
+ var self = this;
+ var callback = function(properties) {
+ if (!properties)
+ return;
+ self._update(properties);
+ };
+ InspectorController.getProperties(this.object, this.ignoreHasOwnProperty, callback);
+ },
+
+ _update: function(properties)
+ {
if (this.extraProperties)
- for (var prop in this.extraProperties)
- properties.push(prop);
- properties.sort();
+ for (var i = 0; i < this.extraProperties.length; ++i)
+ properties.push(this.extraProperties[i]);
+ properties.sort(this._displaySort);
this.propertiesTreeOutline.removeChildren();
- for (var i = 0; i < properties.length; ++i) {
- var object = this.object;
- var propertyName = properties[i];
- if (this.extraProperties && propertyName in this.extraProperties)
- object = this.extraProperties;
- if (propertyName === "__treeElementIdentifier")
- continue;
- if (!this.ignoreHasOwnProperty && "hasOwnProperty" in object && !object.hasOwnProperty(propertyName))
- continue;
- this.propertiesTreeOutline.appendChild(new this.treeElementConstructor(object, propertyName));
- }
+ for (var i = 0; i < properties.length; ++i)
+ this.propertiesTreeOutline.appendChild(new this.treeElementConstructor(properties[i]));
if (!this.propertiesTreeOutline.children.length) {
var title = "<div class=\"info\">" + this.emptyPlaceholder + "</div>";
var infoElement = new TreeElement(title, null, false);
this.propertiesTreeOutline.appendChild(infoElement);
}
+ },
+
+ _displaySort: function(propertyA, propertyB) {
+ var a = propertyA.name;
+ var b = propertyB.name;
+
+ // if used elsewhere make sure to
+ // - convert a and b to strings (not needed here, properties are all strings)
+ // - check if a == b (not needed here, no two properties can be the same)
+
+ var diff = 0;
+ var chunk = /^\d+|^\D+/;
+ var chunka, chunkb, anum, bnum;
+ while (diff === 0) {
+ if (!a && b)
+ return -1;
+ if (!b && a)
+ return 1;
+ chunka = a.match(chunk)[0];
+ chunkb = b.match(chunk)[0];
+ anum = !isNaN(chunka);
+ bnum = !isNaN(chunkb);
+ if (anum && !bnum)
+ return -1;
+ if (bnum && !anum)
+ return 1;
+ if (anum && bnum) {
+ diff = chunka - chunkb;
+ if (diff === 0 && chunka.length !== chunkb.length) {
+ if (!+chunka && !+chunkb) // chunks are strings of all 0s (special case)
+ return chunka.length - chunkb.length;
+ else
+ return chunkb.length - chunka.length;
+ }
+ } else if (chunka !== chunkb)
+ return (chunka < chunkb) ? -1 : 1;
+ a = a.substring(chunka.length);
+ b = b.substring(chunkb.length);
+ }
+ return diff;
}
}
WebInspector.ObjectPropertiesSection.prototype.__proto__ = WebInspector.PropertiesSection.prototype;
-WebInspector.ObjectPropertyTreeElement = function(parentObject, propertyName)
+WebInspector.ObjectPropertyTreeElement = function(property)
{
- this.parentObject = parentObject;
- this.propertyName = propertyName;
+ this.property = property;
// Pass an empty title, the title gets made later in onattach.
TreeElement.call(this, "", null, false);
}
WebInspector.ObjectPropertyTreeElement.prototype = {
- safePropertyValue: function(object, propertyName)
- {
- if (object["__lookupGetter__"] && object.__lookupGetter__(propertyName))
- return;
- return object[propertyName];
- },
-
onpopulate: function()
{
if (this.children.length && !this.shouldRefreshChildren)
return;
- this.removeChildren();
+ var self = this;
+ var callback = function(properties) {
+ self.removeChildren();
+ if (!properties)
+ return;
- var childObject = this.safePropertyValue(this.parentObject, this.propertyName);
- var properties = Object.sortedProperties(childObject);
- for (var i = 0; i < properties.length; ++i) {
- var propertyName = properties[i];
- if (propertyName === "__treeElementIdentifier")
- continue;
- this.appendChild(new this.treeOutline.section.treeElementConstructor(childObject, propertyName));
- }
+ properties.sort(self._displaySort);
+ for (var i = 0; i < properties.length; ++i) {
+ self.appendChild(new self.treeOutline.section.treeElementConstructor(properties[i]));
+ }
+ };
+ InspectorController.getProperties(this.property.value, false, callback);
},
ondblclick: function(element, event)
@@ -130,41 +155,22 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
update: function()
{
- var childObject = this.safePropertyValue(this.parentObject, this.propertyName);
- var isGetter = ("__lookupGetter__" in this.parentObject && this.parentObject.__lookupGetter__(this.propertyName));
-
var nameElement = document.createElement("span");
nameElement.className = "name";
- nameElement.textContent = this.propertyName;
+ nameElement.textContent = this.property.name;
this.valueElement = document.createElement("span");
this.valueElement.className = "value";
- if (!isGetter) {
- this.valueElement.textContent = Object.describe(childObject, true);
- } else {
- // FIXME: this should show something like "getter" (bug 16734).
- this.valueElement.textContent = "\u2014"; // em dash
- this.valueElement.addStyleClass("dimmed");
- }
+ this.valueElement.textContent = this.property.value.description;
+ if (this.property.isGetter)
+ this.valueElement.addStyleClass("dimmed");
this.listItemElement.removeChildren();
this.listItemElement.appendChild(nameElement);
this.listItemElement.appendChild(document.createTextNode(": "));
this.listItemElement.appendChild(this.valueElement);
-
- var hasSubProperties = false;
- var type = typeof childObject;
- if (childObject && (type === "object" || type === "function")) {
- for (subPropertyName in childObject) {
- if (subPropertyName === "__treeElementIdentifier")
- continue;
- hasSubProperties = true;
- break;
- }
- }
-
- this.hasChildren = hasSubProperties;
+ this.hasChildren = this.property.value.hasChildren;
},
updateSiblings: function()
@@ -214,62 +220,27 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
this.editingEnded(context);
},
- evaluateExpression: function(expression)
- {
- // Evaluate in the currently selected call frame if the debugger is paused.
- // Otherwise evaluate in against the inspected window.
- if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused && this.treeOutline.section.editInSelectedCallFrameWhenPaused)
- return WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression, false);
- return InspectorController.inspectedWindow().eval(expression);
- },
-
applyExpression: function(expression, updateInterface)
{
- var expressionLength = expression.trimWhitespace().length;
-
- if (!expressionLength) {
- // The user deleted everything, so try to delete the property.
- delete this.parentObject[this.propertyName];
-
- if (updateInterface) {
- if (this.propertyName in this.parentObject) {
- // The property was not deleted, so update.
- this.update();
- } else {
- // The property was deleted, so remove this tree element.
- this.parent.removeChild(this);
- }
- }
+ expression = expression.trimWhitespace();
+ var expressionLength = expression.length;
+ var self = this;
+ var callback = function(success) {
+ if (!updateInterface)
+ return;
- return;
- }
+ if (!success)
+ self.update();
- try {
- // Surround the expression in parenthesis so the result of the eval is the result
- // of the whole expression not the last potential sub-expression.
- var result = this.evaluateExpression("(" + expression + ")");
-
- // Store the result in the property.
- this.parentObject[this.propertyName] = result;
- } catch(e) {
- try {
- // Try to update as a string
- var result = this.evaluateExpression("\"" + expression.escapeCharacters("\"") + "\"");
-
- // Store the result in the property.
- this.parentObject[this.propertyName] = result;
- } catch(e) {
- // The expression failed so don't change the value. So just update and return.
- if (updateInterface)
- this.update();
- return;
+ if (!expressionLength) {
+ // The property was deleted, so remove this tree element.
+ self.parent.removeChild(this);
+ } else {
+ // Call updateSiblings since their value might be based on the value that just changed.
+ self.updateSiblings();
}
- }
-
- if (updateInterface) {
- // Call updateSiblings since their value might be based on the value that just changed.
- this.updateSiblings();
- }
+ };
+ InspectorController.setPropertyValue(this.property.parentObjectProxy, this.property.name, expression.trimWhitespace(), callback);
}
}

Powered by Google App Engine
This is Rietveld 408576698