<!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>[179635] trunk/Source</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/179635">179635</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-02-04 14:27:19 -0800 (Wed, 04 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: console.table with columnName filter for non-existent property should still show column
https://bugs.webkit.org/show_bug.cgi?id=141066

Patch by Joseph Pecoraro &lt;pecoraro@apple.com&gt; on 2015-02-04
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
When a user provides a second argument, e.g. console.table(..., columnNames),
then pass that second argument to the frontend.

* inspector/InjectedScriptSource.js:
Add a FIXME about the old, unused path now.

Source/WebInspectorUI:

* UserInterface/Views/ConsoleMessageImpl.js:
(WebInspector.ConsoleMessageImpl.prototype._appendPropertyPreviews):
(WebInspector.ConsoleMessageImpl.prototype._userProvidedColumnNames):
(WebInspector.ConsoleMessageImpl.prototype._formatParameterAsTable):
If a second argument was provided to console.table, try to extract a list
of string names to use for the object properties. Output a table with
the provided column names, in the specified order. Also, use this
opportunity to mark missing properties with an em dash.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorConsoleMessagecpp">trunk/Source/JavaScriptCore/inspector/ConsoleMessage.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorInjectedScriptSourcejs">trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsConsoleMessageImpljs">trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (179634 => 179635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-02-04 22:25:02 UTC (rev 179634)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-02-04 22:27:19 UTC (rev 179635)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-02-04  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: console.table with columnName filter for non-existent property should still show column
+        https://bugs.webkit.org/show_bug.cgi?id=141066
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/ConsoleMessage.cpp:
+        (Inspector::ConsoleMessage::addToFrontend):
+        When a user provides a second argument, e.g. console.table(..., columnNames),
+        then pass that second argument to the frontend.
+
+        * inspector/InjectedScriptSource.js:
+        Add a FIXME about the old, unused path now.
+
</ins><span class="cx"> 2015-02-04  Saam Barati  &lt;saambarati1@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         TypeSet can use 1 byte instead of 4 bytes for its m_seenTypes member variable
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorConsoleMessagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/ConsoleMessage.cpp (179634 => 179635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/ConsoleMessage.cpp        2015-02-04 22:25:02 UTC (rev 179634)
+++ trunk/Source/JavaScriptCore/inspector/ConsoleMessage.cpp        2015-02-04 22:27:19 UTC (rev 179635)
</span><span class="lines">@@ -208,6 +208,8 @@
</span><span class="cx">                     return;
</span><span class="cx">                 }
</span><span class="cx">                 jsonArgs-&gt;addItem(inspectorValue.copyRef());
</span><ins>+                if (m_arguments-&gt;argumentCount() &gt; 1)
+                    jsonArgs-&gt;addItem(injectedScript.wrapObject(columns, ASCIILiteral(&quot;console&quot;), true));
</ins><span class="cx">             } else {
</span><span class="cx">                 for (unsigned i = 0; i &lt; m_arguments-&gt;argumentCount(); ++i) {
</span><span class="cx">                     RefPtr&lt;Inspector::Protocol::Runtime::RemoteObject&gt; inspectorValue = injectedScript.wrapObject(m_arguments-&gt;argumentAt(i), ASCIILiteral(&quot;console&quot;), generatePreview);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorInjectedScriptSourcejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js (179634 => 179635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js        2015-02-04 22:25:02 UTC (rev 179634)
+++ trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js        2015-02-04 22:27:19 UTC (rev 179635)
</span><span class="lines">@@ -102,6 +102,10 @@
</span><span class="cx">         if (!canAccessInspectedGlobalObject)
</span><span class="cx">             return this._fallbackWrapper(table);
</span><span class="cx"> 
</span><ins>+        // FIXME: Currently columns are ignored. Instead, the frontend filters all
+        // properties based on the provided column names and in the provided order.
+        // Should we filter here too?
+
</ins><span class="cx">         var columnNames = null;
</span><span class="cx">         if (typeof columns === &quot;string&quot;)
</span><span class="cx">             columns = [columns];
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (179634 => 179635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2015-02-04 22:25:02 UTC (rev 179634)
+++ trunk/Source/WebInspectorUI/ChangeLog        2015-02-04 22:27:19 UTC (rev 179635)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-02-04  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: console.table with columnName filter for non-existent property should still show column
+        https://bugs.webkit.org/show_bug.cgi?id=141066
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/ConsoleMessageImpl.js:
+        (WebInspector.ConsoleMessageImpl.prototype._appendPropertyPreviews):
+        (WebInspector.ConsoleMessageImpl.prototype._userProvidedColumnNames):
+        (WebInspector.ConsoleMessageImpl.prototype._formatParameterAsTable):
+        If a second argument was provided to console.table, try to extract a list
+        of string names to use for the object properties. Output a table with
+        the provided column names, in the specified order. Also, use this
+        opportunity to mark missing properties with an em dash.
+
</ins><span class="cx"> 2015-02-02  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: CSS Autocompletion: Autodetect many color supporting properties
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsConsoleMessageImpljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js (179634 => 179635)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js        2015-02-04 22:25:02 UTC (rev 179634)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js        2015-02-04 22:27:19 UTC (rev 179635)
</span><span class="lines">@@ -372,7 +372,7 @@
</span><span class="cx"> 
</span><span class="cx">             if (i &gt; 0)
</span><span class="cx">                 element.appendChild(document.createTextNode(&quot;, &quot;));
</span><del>-    
</del><ins>+
</ins><span class="cx">             if (!isArray || property.name != i) {
</span><span class="cx">                 element.createChild(&quot;span&quot;, &quot;name&quot;).textContent = property.name;
</span><span class="cx">                 element.appendChild(document.createTextNode(&quot;: &quot;));
</span><span class="lines">@@ -447,6 +447,31 @@
</span><span class="cx">         arr.getOwnProperties(this._printArray.bind(this, arr, elem));
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    _userProvidedColumnNames: function(columnNamesArgument)
+    {
+        if (!columnNamesArgument)
+            return null;
+
+        var remoteObject = WebInspector.RemoteObject.fromPayload(columnNamesArgument);
+
+        // Single primitive argument.
+        if (remoteObject.type === &quot;string&quot; || remoteObject.type === &quot;number&quot;)
+            return [String(columnNamesArgument.value)];
+
+        // Ignore everything that is not an array with property previews.
+        if (remoteObject.type !== &quot;object&quot; || remoteObject.subtype !== &quot;array&quot; || !remoteObject.preview || !remoteObject.preview.properties)
+            return null;
+
+        // Array. Look into the preview and get string values.
+        var extractedColumnNames = [];
+        for (var propertyPreview of remoteObject.preview.properties) {
+            if (propertyPreview.type === &quot;string&quot; || propertyPreview.type === &quot;number&quot;)
+                extractedColumnNames.push(String(propertyPreview.value));
+        }
+
+        return extractedColumnNames.length ? extractedColumnNames : null;
+    },
+
</ins><span class="cx">     _formatParameterAsTable: function(parameters)
</span><span class="cx">     {
</span><span class="cx">         var element = document.createElement(&quot;span&quot;);
</span><span class="lines">@@ -458,7 +483,15 @@
</span><span class="cx">         var columnNames = [];
</span><span class="cx">         var flatValues = [];
</span><span class="cx">         var preview = table.preview;
</span><ins>+        var userProvidedColumnNames = false;
</ins><span class="cx"> 
</span><ins>+        // User provided columnNames.
+        var extractedColumnNames = this._userProvidedColumnNames(parameters[1]);
+        if (extractedColumnNames) {
+            userProvidedColumnNames = true;
+            columnNames = extractedColumnNames;
+        }
+
</ins><span class="cx">         // Check first for valuePreviews in the properties meaning this was an array of objects.
</span><span class="cx">         for (var i = 0; i &lt; preview.properties.length; ++i) {
</span><span class="cx">             var rowProperty = preview.properties[i];
</span><span class="lines">@@ -472,7 +505,7 @@
</span><span class="cx">                 var cellProperty = rowPreview.properties[j];
</span><span class="cx">                 var columnRendered = columnNames.contains(cellProperty.name);
</span><span class="cx">                 if (!columnRendered) {
</span><del>-                    if (columnNames.length === maxColumnsToRender)
</del><ins>+                    if (userProvidedColumnNames || columnNames.length === maxColumnsToRender)
</ins><span class="cx">                         continue;
</span><span class="cx">                     columnRendered = true;
</span><span class="cx">                     columnNames.push(cellProperty.name);
</span><span class="lines">@@ -485,13 +518,19 @@
</span><span class="cx"> 
</span><span class="cx">         // If there were valuePreviews, convert to a flat list.
</span><span class="cx">         if (rows.length) {
</span><ins>+            const emDash = &quot;\u2014&quot;;
</ins><span class="cx">             columnNames.unshift(WebInspector.UIString(&quot;(Index)&quot;));
</span><span class="cx">             for (var i = 0; i &lt; rows.length; ++i) {
</span><span class="cx">                 var rowName = rows[i][0];
</span><span class="cx">                 var rowValue = rows[i][1];
</span><span class="cx">                 flatValues.push(rowName);
</span><del>-                for (var j = 1; j &lt; columnNames.length; ++j)
-                    flatValues.push(rowValue[columnNames[j]]);
</del><ins>+                for (var j = 1; j &lt; columnNames.length; ++j) {
+                    var columnName = columnNames[j];
+                    if (!(columnName in rowValue))
+                        flatValues.push(emDash);
+                    else
+                        flatValues.push(rowValue[columnName]);
+                }
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>