<!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>[209711] 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/209711">209711</a></dd>
<dt>Author</dt> <dd>mattbaker@apple.com</dd>
<dt>Date</dt> <dd>2016-12-12 09:24:03 -0800 (Mon, 12 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Cleanup HierarchicalPathComponent
https://bugs.webkit.org/show_bug.cgi?id=165745

Reviewed by Brian Burg.

Prefer toggle for style class names, remove single use CSS class name
constants, and back all properties by the model not the DOM.

* UserInterface/Views/HierarchicalPathComponent.js:
(WebInspector.HierarchicalPathComponent):
(WebInspector.HierarchicalPathComponent.prototype.get element):
(WebInspector.HierarchicalPathComponent.prototype.get representedObject):
(WebInspector.HierarchicalPathComponent.prototype.get minimumWidth):
(WebInspector.HierarchicalPathComponent.prototype.get forcedWidth):
(WebInspector.HierarchicalPathComponent.prototype.set forcedWidth):
(WebInspector.HierarchicalPathComponent.prototype.get hidden):
(WebInspector.HierarchicalPathComponent.prototype.set hidden):
(WebInspector.HierarchicalPathComponent.prototype.get collapsed):
(WebInspector.HierarchicalPathComponent.prototype.set collapsed):
(WebInspector.HierarchicalPathComponent.prototype.get selectorArrows):
(WebInspector.HierarchicalPathComponent.prototype.set selectorArrows):
(WebInspector.HierarchicalPathComponent.prototype.get previousSibling):
(WebInspector.HierarchicalPathComponent.prototype.set previousSibling):
(WebInspector.HierarchicalPathComponent.prototype.get nextSibling):
(WebInspector.HierarchicalPathComponent.prototype.set nextSibling):
(WebInspector.HierarchicalPathComponent.prototype._updateElementTitleAndText):
(WebInspector.HierarchicalPathComponent.prototype._updateSelectElement.createOption):
(WebInspector.HierarchicalPathComponent.prototype._updateSelectElement):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsHierarchicalPathComponentjs">trunk/Source/WebInspectorUI/UserInterface/Views/HierarchicalPathComponent.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (209710 => 209711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-12-12 17:21:27 UTC (rev 209710)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-12-12 17:24:03 UTC (rev 209711)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2016-12-12  Matt Baker  &lt;mattbaker@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Web Inspector: Cleanup HierarchicalPathComponent
+        https://bugs.webkit.org/show_bug.cgi?id=165745
+
+        Reviewed by Brian Burg.
+
+        Prefer toggle for style class names, remove single use CSS class name
+        constants, and back all properties by the model not the DOM.
+
+        * UserInterface/Views/HierarchicalPathComponent.js:
+        (WebInspector.HierarchicalPathComponent):
+        (WebInspector.HierarchicalPathComponent.prototype.get element):
+        (WebInspector.HierarchicalPathComponent.prototype.get representedObject):
+        (WebInspector.HierarchicalPathComponent.prototype.get minimumWidth):
+        (WebInspector.HierarchicalPathComponent.prototype.get forcedWidth):
+        (WebInspector.HierarchicalPathComponent.prototype.set forcedWidth):
+        (WebInspector.HierarchicalPathComponent.prototype.get hidden):
+        (WebInspector.HierarchicalPathComponent.prototype.set hidden):
+        (WebInspector.HierarchicalPathComponent.prototype.get collapsed):
+        (WebInspector.HierarchicalPathComponent.prototype.set collapsed):
+        (WebInspector.HierarchicalPathComponent.prototype.get selectorArrows):
+        (WebInspector.HierarchicalPathComponent.prototype.set selectorArrows):
+        (WebInspector.HierarchicalPathComponent.prototype.get previousSibling):
+        (WebInspector.HierarchicalPathComponent.prototype.set previousSibling):
+        (WebInspector.HierarchicalPathComponent.prototype.get nextSibling):
+        (WebInspector.HierarchicalPathComponent.prototype.set nextSibling):
+        (WebInspector.HierarchicalPathComponent.prototype._updateElementTitleAndText):
+        (WebInspector.HierarchicalPathComponent.prototype._updateSelectElement.createOption):
+        (WebInspector.HierarchicalPathComponent.prototype._updateSelectElement):
+
+2016-12-12  Matt Baker  &lt;mattbaker@apple.com&gt;
+
</ins><span class="cx">         Web Inspector: Allow keyboard navigation in Heap Snapshot data grids
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=165752
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsHierarchicalPathComponentjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HierarchicalPathComponent.js (209710 => 209711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/HierarchicalPathComponent.js        2016-12-12 17:21:27 UTC (rev 209710)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HierarchicalPathComponent.js        2016-12-12 17:24:03 UTC (rev 209711)
</span><span class="lines">@@ -37,14 +37,10 @@
</span><span class="cx">         this._element = document.createElement(&quot;div&quot;);
</span><span class="cx">         this._element.className = &quot;hierarchical-path-component&quot;;
</span><span class="cx"> 
</span><del>-        if (!(styleClassNames instanceof Array))
</del><ins>+        if (!Array.isArray(styleClassNames))
</ins><span class="cx">             styleClassNames = [styleClassNames];
</span><span class="cx"> 
</span><del>-        for (var i = 0; i &lt; styleClassNames.length; ++i) {
-            if (!styleClassNames[i])
-                continue;
-            this._element.classList.add(styleClassNames[i]);
-        }
</del><ins>+        this._element.classList.add(...styleClassNames);
</ins><span class="cx"> 
</span><span class="cx">         if (!textOnly) {
</span><span class="cx">             this._iconElement = document.createElement(&quot;img&quot;);
</span><span class="lines">@@ -51,7 +47,7 @@
</span><span class="cx">             this._iconElement.className = &quot;icon&quot;;
</span><span class="cx">             this._element.appendChild(this._iconElement);
</span><span class="cx">         } else
</span><del>-            this._element.classList.add(WebInspector.HierarchicalPathComponent.TextOnlyStyleClassName);
</del><ins>+            this._element.classList.add(&quot;text-only&quot;);
</ins><span class="cx"> 
</span><span class="cx">         this._titleElement = document.createElement(&quot;div&quot;);
</span><span class="cx">         this._titleElement.className = &quot;title&quot;;
</span><span class="lines">@@ -78,8 +74,12 @@
</span><span class="cx"> 
</span><span class="cx">         this._truncatedDisplayNameLength = 0;
</span><span class="cx"> 
</span><ins>+        this._collapsed = false;
+        this._hidden = false;
+        this._selectorArrows = false;
+
+        this.displayName = displayName;
</ins><span class="cx">         this.selectorArrows = showSelectorArrows;
</span><del>-        this.displayName = displayName;
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Public
</span><span class="lines">@@ -92,16 +92,9 @@
</span><span class="cx">         return selectedOption &amp;&amp; selectedOption._pathComponent || null;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    get element()
-    {
-        return this._element;
-    }
</del><ins>+    get element() { return this._element; }
+    get representedObject() { return this._representedObject; }
</ins><span class="cx"> 
</span><del>-    get representedObject()
-    {
-        return this._representedObject;
-    }
-
</del><span class="cx">     get displayName()
</span><span class="cx">     {
</span><span class="cx">         return this._displayName;
</span><span class="lines">@@ -137,9 +130,9 @@
</span><span class="cx"> 
</span><span class="cx">     get minimumWidth()
</span><span class="cx">     {
</span><del>-        if (this.collapsed)
</del><ins>+        if (this._collapsed)
</ins><span class="cx">             return WebInspector.HierarchicalPathComponent.MinimumWidthCollapsed;
</span><del>-        if (this.selectorArrows)
</del><ins>+        if (this._selectorArrows)
</ins><span class="cx">             return WebInspector.HierarchicalPathComponent.MinimumWidth + WebInspector.HierarchicalPathComponent.SelectorArrowsWidth;
</span><span class="cx">         return WebInspector.HierarchicalPathComponent.MinimumWidth;
</span><span class="cx">     }
</span><span class="lines">@@ -146,7 +139,7 @@
</span><span class="cx"> 
</span><span class="cx">     get forcedWidth()
</span><span class="cx">     {
</span><del>-        var maxWidth = this._element.style.getProperty(&quot;width&quot;);
</del><ins>+        let maxWidth = this._element.style.getProperty(&quot;width&quot;);
</ins><span class="cx">         if (typeof maxWidth === &quot;string&quot;)
</span><span class="cx">             return parseInt(maxWidth);
</span><span class="cx">         return null;
</span><span class="lines">@@ -155,7 +148,7 @@
</span><span class="cx">     set forcedWidth(width)
</span><span class="cx">     {
</span><span class="cx">         if (typeof width === &quot;number&quot;) {
</span><del>-            var minimumWidthForOneCharacterTruncatedTitle = WebInspector.HierarchicalPathComponent.MinimumWidthForOneCharacterTruncatedTitle;
</del><ins>+            let minimumWidthForOneCharacterTruncatedTitle = WebInspector.HierarchicalPathComponent.MinimumWidthForOneCharacterTruncatedTitle;
</ins><span class="cx">             if (this.selectorArrows)
</span><span class="cx">                 minimumWidthForOneCharacterTruncatedTitle += WebInspector.HierarchicalPathComponent.SelectorArrowsWidth;
</span><span class="cx"> 
</span><span class="lines">@@ -173,78 +166,66 @@
</span><span class="cx"> 
</span><span class="cx">     get hidden()
</span><span class="cx">     {
</span><del>-        return this._element.classList.contains(WebInspector.HierarchicalPathComponent.HiddenStyleClassName);
</del><ins>+        return this._hidden;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     set hidden(flag)
</span><span class="cx">     {
</span><del>-        if (flag)
-            this._element.classList.add(WebInspector.HierarchicalPathComponent.HiddenStyleClassName);
-        else
-            this._element.classList.remove(WebInspector.HierarchicalPathComponent.HiddenStyleClassName);
</del><ins>+        if (this._hidden === flag)
+            return;
+
+        this._hidden = flag;
+        this._element.classList.toggle(&quot;hidden&quot;, this._hidden);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     get collapsed()
</span><span class="cx">     {
</span><del>-        return this._element.classList.contains(WebInspector.HierarchicalPathComponent.CollapsedStyleClassName);
</del><ins>+        return this._collapsed;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     set collapsed(flag)
</span><span class="cx">     {
</span><del>-        if (flag)
-            this._element.classList.add(WebInspector.HierarchicalPathComponent.CollapsedStyleClassName);
-        else
-            this._element.classList.remove(WebInspector.HierarchicalPathComponent.CollapsedStyleClassName);
</del><ins>+        if (this._collapsed === flag)
+            return;
+
+        this._collapsed = flag;
+        this._element.classList.toggle(&quot;collapsed&quot;, this._collapsed);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     get selectorArrows()
</span><span class="cx">     {
</span><del>-        return this._element.classList.contains(WebInspector.HierarchicalPathComponent.ShowSelectorArrowsStyleClassName);
</del><ins>+        return this._selectorArrows;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     set selectorArrows(flag)
</span><span class="cx">     {
</span><del>-        if (flag) {
</del><ins>+        if (this._selectorArrows === flag)
+            return;
+
+        this._selectorArrows = flag;
+
+        if (this._selectorArrows) {
</ins><span class="cx">             this._selectorArrowsElement = document.createElement(&quot;img&quot;);
</span><span class="cx">             this._selectorArrowsElement.className = &quot;selector-arrows&quot;;
</span><span class="cx">             this._element.insertBefore(this._selectorArrowsElement, this._separatorElement);
</span><del>-
-            this._element.classList.add(WebInspector.HierarchicalPathComponent.ShowSelectorArrowsStyleClassName);
-        } else {
-            if (this._selectorArrowsElement) {
-                this._selectorArrowsElement.remove();
-                delete this._selectorArrowsElement;
-            }
-
-            this._element.classList.remove(WebInspector.HierarchicalPathComponent.ShowSelectorArrowsStyleClassName);
</del><ins>+        } else if (this._selectorArrowsElement) {
+            this._selectorArrowsElement.remove();
+            this._selectorArrowsElement = null;
</ins><span class="cx">         }
</span><del>-    }
</del><span class="cx"> 
</span><del>-    get previousSibling()
-    {
-        return this._previousSibling;
</del><ins>+        this._element.classList.toggle(&quot;show-selector-arrows&quot;, this._selectorArrows);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    set previousSibling(newSlibling)
-    {
-        this._previousSibling = newSlibling || null;
-    }
</del><ins>+    get previousSibling() { return this._previousSibling; }
+    set previousSibling(newSlibling) { this._previousSibling = newSlibling || null; }
+    get nextSibling() { return this._nextSibling; }
+    set nextSibling(newSlibling) { this._nextSibling = newSlibling || null; }
</ins><span class="cx"> 
</span><del>-    get nextSibling()
-    {
-        return this._nextSibling;
-    }
-
-    set nextSibling(newSlibling)
-    {
-        this._nextSibling = newSlibling || null;
-    }
-
</del><span class="cx">     // Private
</span><span class="cx"> 
</span><span class="cx">     _updateElementTitleAndText()
</span><span class="cx">     {
</span><del>-        var truncatedDisplayName = this._displayName;
</del><ins>+        let truncatedDisplayName = this._displayName;
</ins><span class="cx">         if (this._truncatedDisplayNameLength &amp;&amp; truncatedDisplayName.length &gt; this._truncatedDisplayNameLength)
</span><span class="cx">             truncatedDisplayName = truncatedDisplayName.substring(0, this._truncatedDisplayNameLength) + ellipsis;
</span><span class="cx"> 
</span><span class="lines">@@ -258,15 +239,15 @@
</span><span class="cx"> 
</span><span class="cx">         function createOption(component)
</span><span class="cx">         {
</span><del>-            var optionElement = document.createElement(&quot;option&quot;);
-            var maxPopupMenuLength = 130; // &lt;rdar://problem/13445374&gt; &lt;select&gt; with very long option has clipped text and popup menu is still very wide
</del><ins>+            let optionElement = document.createElement(&quot;option&quot;);
+            let maxPopupMenuLength = 130; // &lt;rdar://problem/13445374&gt; &lt;select&gt; with very long option has clipped text and popup menu is still very wide
</ins><span class="cx">             optionElement.textContent = component.displayName.length &lt;= maxPopupMenuLength ? component.displayName : component.displayName.substring(0, maxPopupMenuLength) + ellipsis;
</span><span class="cx">             optionElement._pathComponent = component;
</span><span class="cx">             return optionElement;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        var previousSiblingCount = 0;
-        var sibling = this.previousSibling;
</del><ins>+        let previousSiblingCount = 0;
+        let sibling = this.previousSibling;
</ins><span class="cx">         while (sibling) {
</span><span class="cx">             this._selectElement.insertBefore(createOption(sibling), this._selectElement.firstChild);
</span><span class="cx">             sibling = sibling.previousSibling;
</span><span class="lines">@@ -322,11 +303,6 @@
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-WebInspector.HierarchicalPathComponent.HiddenStyleClassName = &quot;hidden&quot;;
-WebInspector.HierarchicalPathComponent.CollapsedStyleClassName = &quot;collapsed&quot;;
-WebInspector.HierarchicalPathComponent.TextOnlyStyleClassName = &quot;text-only&quot;;
-WebInspector.HierarchicalPathComponent.ShowSelectorArrowsStyleClassName = &quot;show-selector-arrows&quot;;
-
</del><span class="cx"> WebInspector.HierarchicalPathComponent.MinimumWidth = 32;
</span><span class="cx"> WebInspector.HierarchicalPathComponent.MinimumWidthCollapsed = 24;
</span><span class="cx"> WebInspector.HierarchicalPathComponent.MinimumWidthForOneCharacterTruncatedTitle = 54;
</span></span></pre>
</div>
</div>

</body>
</html>