<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[180624] trunk/Source/WebInspectorUI</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/180624">180624</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-02-25 07:03:48 -0800 (Wed, 25 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: Improve PropertyPath display strings for getters / values
https://bugs.webkit.org/show_bug.cgi?id=142008
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-02-25
Reviewed by Timothy Hatcher.
* UserInterface/Base/Utilities.js:
(doubleQuotedString):
Helper to double quote a string and escape double quotes with-in it.
* UserInterface/Models/PropertyPath.js:
(WebInspector.PropertyPath.prototype.get reducedPath):
Compute the path eliminating unnecessary __proto__s. Note we don't
property handle the case where a .__proto__.x is override earlier
by a .x, but that case is rare.
(WebInspector.PropertyPath.prototype.displayPath):
Helper for choosing fullPath or reducedPath display strings.
(WebInspector.PropertyPath.prototype.appendPropertyName):
(WebInspector.PropertyPath.prototype.appendGetterPropertyName):
(WebInspector.PropertyPath.prototype.appendSetterPropertyName):
(WebInspector.PropertyPath.prototype.appendPropertyDescriptor):
When appending a descriptor, specify if it is for a getter/setter or value.
For getters / setters the actual function can be directly fetched via
__lookupGetter__/__lookupSetter__. Continue to use the property name for values.
* UserInterface/Views/FormattedValue.js:
(WebInspector.FormattedValue.createElementForTypesAndValue):
* UserInterface/Views/ObjectTreePropertyTreeElement.js:
(WebInspector.ObjectTreePropertyTreeElement.prototype._propertyPathType):
(WebInspector.ObjectTreePropertyTreeElement.prototype._resolvedValuePropertyPath):
(WebInspector.ObjectTreePropertyTreeElement.prototype._thisPropertyPath):
(WebInspector.ObjectTreePropertyTreeElement.prototype):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceBaseUtilitiesjs">trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsPropertyPathjs">trunk/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsFormattedValuejs">trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsObjectTreePropertyTreeElementjs">trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (180623 => 180624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2015-02-25 10:53:57 UTC (rev 180623)
+++ trunk/Source/WebInspectorUI/ChangeLog        2015-02-25 15:03:48 UTC (rev 180624)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2015-02-25 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Improve PropertyPath display strings for getters / values
+ https://bugs.webkit.org/show_bug.cgi?id=142008
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Base/Utilities.js:
+ (doubleQuotedString):
+ Helper to double quote a string and escape double quotes with-in it.
+
+ * UserInterface/Models/PropertyPath.js:
+ (WebInspector.PropertyPath.prototype.get reducedPath):
+ Compute the path eliminating unnecessary __proto__s. Note we don't
+ property handle the case where a .__proto__.x is override earlier
+ by a .x, but that case is rare.
+
+ (WebInspector.PropertyPath.prototype.displayPath):
+ Helper for choosing fullPath or reducedPath display strings.
+
+ (WebInspector.PropertyPath.prototype.appendPropertyName):
+ (WebInspector.PropertyPath.prototype.appendGetterPropertyName):
+ (WebInspector.PropertyPath.prototype.appendSetterPropertyName):
+ (WebInspector.PropertyPath.prototype.appendPropertyDescriptor):
+ When appending a descriptor, specify if it is for a getter/setter or value.
+ For getters / setters the actual function can be directly fetched via
+ __lookupGetter__/__lookupSetter__. Continue to use the property name for values.
+
+ * UserInterface/Views/FormattedValue.js:
+ (WebInspector.FormattedValue.createElementForTypesAndValue):
+
+ * UserInterface/Views/ObjectTreePropertyTreeElement.js:
+ (WebInspector.ObjectTreePropertyTreeElement.prototype._propertyPathType):
+ (WebInspector.ObjectTreePropertyTreeElement.prototype._resolvedValuePropertyPath):
+ (WebInspector.ObjectTreePropertyTreeElement.prototype._thisPropertyPath):
+ (WebInspector.ObjectTreePropertyTreeElement.prototype):
+
</ins><span class="cx"> 2015-02-24 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Eliminate console-formatted-* class names in favor of formatted-*
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceBaseUtilitiesjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (180623 => 180624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js        2015-02-25 10:53:57 UTC (rev 180623)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js        2015-02-25 15:03:48 UTC (rev 180624)
</span><span class="lines">@@ -1031,6 +1031,11 @@
</span><span class="cx"> return str.endsWith("{\n [native code]\n}");
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+function doubleQuotedString(str)
+{
+ return "\"" + str.replace(/"/g, "\\\"") + "\"";
+}
+
</ins><span class="cx"> function clamp(min, value, max)
</span><span class="cx"> {
</span><span class="cx"> return Math.min(Math.max(min, value), max);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsPropertyPathjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js (180623 => 180624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js        2015-02-25 10:53:57 UTC (rev 180623)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js        2015-02-25 15:03:48 UTC (rev 180624)
</span><span class="lines">@@ -50,6 +50,12 @@
</span><span class="cx"> GetterPropertyName: "@getter",
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+WebInspector.PropertyPath.Type = {
+ Value: "value",
+ Getter: "getter",
+ Setter: "setter",
+};
+
</ins><span class="cx"> WebInspector.PropertyPath.prototype = {
</span><span class="cx"> constructor: WebInspector.PropertyPath,
</span><span class="cx"> __proto__: WebInspector.Object.prototype,
</span><span class="lines">@@ -107,6 +113,35 @@
</span><span class="cx"> return components.join("");
</span><span class="cx"> },
</span><span class="cx">
</span><ins>+ get reducedPath()
+ {
+ // The display path for a value should not include __proto__.
+ // The path for "foo.__proto__.bar.__proto__.x" is better shown as "foo.bar.x".
+ // FIXME: We should keep __proto__ if this property was overridden.
+ var components = [];
+
+ var p = this;
+
+ // Include trailing __proto__s.
+ for (; p && p.isPrototype; p = p.parent)
+ components.push(p.pathComponent);
+
+ // Skip other __proto__s.
+ for (; p && p.pathComponent; p = p.parent) {
+ if (p.isPrototype)
+ continue;
+ components.push(p.pathComponent);
+ }
+
+ components.reverse();
+ return components.join("");
+ },
+
+ displayPath: function(type)
+ {
+ return type === WebInspector.PropertyPath.Type.Value ? this.reducedPath : this.fullPath;
+ },
+
</ins><span class="cx"> isRoot: function()
</span><span class="cx"> {
</span><span class="cx"> return !this._parent;
</span><span class="lines">@@ -131,7 +166,7 @@
</span><span class="cx"> appendPropertyName: function(object, propertyName)
</span><span class="cx"> {
</span><span class="cx"> var isPrototype = propertyName === "__proto__";
</span><del>- var component = this._canPropertyNameBeDotAccess(propertyName) ? "." + propertyName : "[\"" + propertyName.replace(/"/, "\\\"") + "\"]";
</del><ins>+ var component = this._canPropertyNameBeDotAccess(propertyName) ? "." + propertyName : "[" + doubleQuotedString(propertyName) + "]";
</ins><span class="cx"> return new WebInspector.PropertyPath(object, component, this, isPrototype);
</span><span class="cx"> },
</span><span class="cx">
</span><span class="lines">@@ -147,6 +182,18 @@
</span><span class="cx"> return new WebInspector.PropertyPath(object, component, this);
</span><span class="cx"> },
</span><span class="cx">
</span><ins>+ appendGetterPropertyName: function(object, propertyName)
+ {
+ var component = ".__lookupGetter__(" + doubleQuotedString(propertyName) + ")";
+ return new WebInspector.PropertyPath(object, component, this);
+ },
+
+ appendSetterPropertyName: function(object, propertyName)
+ {
+ var component = ".__lookupSetter__(" + doubleQuotedString(propertyName) + ")";
+ return new WebInspector.PropertyPath(object, component, this);
+ },
+
</ins><span class="cx"> appendArrayIndex: function(object, indexString)
</span><span class="cx"> {
</span><span class="cx"> var component = "[" + indexString + "]";
</span><span class="lines">@@ -159,11 +206,18 @@
</span><span class="cx"> return new WebInspector.PropertyPath(object, component, this);
</span><span class="cx"> },
</span><span class="cx">
</span><del>- appendPropertyDescriptor: function(object, descriptor)
</del><ins>+ appendPropertyDescriptor: function(object, descriptor, type)
</ins><span class="cx"> {
</span><span class="cx"> if (descriptor.isInternalProperty)
</span><span class="cx"> return this.appendInternalPropertyName(object, descriptor.name);
</span><span class="cx">
</span><ins>+ if (type === WebInspector.PropertyPath.Type.Getter)
+ return this.appendGetterPropertyName(object, descriptor.name);
+ if (type === WebInspector.PropertyPath.Type.Setter)
+ return this.appendSetterPropertyName(object, descriptor.name);
+
+ console.assert(type === WebInspector.PropertyPath.Type.Value);
+
</ins><span class="cx"> // FIXME: We don't yet have Symbol descriptors.
</span><span class="cx">
</span><span class="cx"> if (this._object.subtype === "array" && !isNaN(parseInt(descriptor.name)))
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsFormattedValuejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js (180623 => 180624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js        2015-02-25 10:53:57 UTC (rev 180623)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js        2015-02-25 15:03:48 UTC (rev 180624)
</span><span class="lines">@@ -82,7 +82,7 @@
</span><span class="cx">
</span><span class="cx"> // String: quoted and replace newlines as nice unicode symbols.
</span><span class="cx"> if (type === "string") {
</span><del>- span.textContent = "\"" + displayString.replace(/\n/g, "\u21B5").replace(/"/g, "\\\"") + "\"";
</del><ins>+ span.textContent = doubleQuotedString(displayString.replace(/\n/g, "\u21B5"));
</ins><span class="cx"> return span;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsObjectTreePropertyTreeElementjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js (180623 => 180624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js        2015-02-25 10:53:57 UTC (rev 180623)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js        2015-02-25 15:03:48 UTC (rev 180624)
</span><span class="lines">@@ -101,23 +101,31 @@
</span><span class="cx"> return null;
</span><span class="cx"> },
</span><span class="cx">
</span><ins>+ _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;
+ },
+
</ins><span class="cx"> _resolvedValuePropertyPath: function()
</span><span class="cx"> {
</span><del>- // FIXME: We could make a better path here.
- // If this getter was not overridden, then <this._propertyPath.lastNonPrototypeObject>[<this._property.name>] is a valid path.
- // However, we cannot easily determine from here if this getter was overridden or not.
</del><span class="cx"> if (this._getterValue)
</span><del>- return new WebInspector.PropertyPath(this._getterValue, WebInspector.PropertyPath.SpecialPathComponent.GetterPropertyName);
</del><ins>+ return this._propertyPath.appendPropertyDescriptor(this._getterValue, this._property, WebInspector.PropertyPath.Type.Value);
</ins><span class="cx">
</span><span class="cx"> if (this._property.hasValue())
</span><del>- return this._propertyPath.appendPropertyDescriptor(this._property.value, this._property);
</del><ins>+ return this._propertyPath.appendPropertyDescriptor(this._property.value, this._property, WebInspector.PropertyPath.Type.Value);
</ins><span class="cx">
</span><span class="cx"> return null;
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> _thisPropertyPath: function()
</span><span class="cx"> {
</span><del>- return this._propertyPath.appendPropertyDescriptor(null, this._property);
</del><ins>+ return this._propertyPath.appendPropertyDescriptor(null, this._property, this._propertyPathType());
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> _updateHasChildren: function()
</span><span class="lines">@@ -374,7 +382,7 @@
</span><span class="cx"> if (propertyPath.isFullPathImpossible())
</span><span class="cx"> return WebInspector.UIString("Unable to determine path to property from root");
</span><span class="cx">
</span><del>- return propertyPath.fullPath;
</del><ins>+ return propertyPath.displayPath(this._propertyPathType());
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> _updateChildren: function()
</span></span></pre>
</div>
</div>
</body>
</html>