<!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>[180913] 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/180913">180913</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2015-03-02 18:24:49 -0800 (Mon, 02 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Context Menu to Log a Particular Object
https://bugs.webkit.org/show_bug.cgi?id=142198

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

Add a protocol method to assign a $n index to a value. For an object
use the injected script context for that object. For a value, use
the execution context to know where to save the value.

* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::saveResult):
* inspector/InjectedScript.h:
* inspector/InjectedScriptSource.js:
* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::saveResult):
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/protocol/Debugger.json:
* inspector/protocol/Runtime.json:

Source/WebInspectorUI:

* UserInterface/Controllers/JavaScriptLogViewController.js:
(WebInspector.JavaScriptLogViewController.prototype.saveResultCallback):
(WebInspector.JavaScriptLogViewController.prototype.appendImmediateExecutionWithResult):
Add a way to show an execution and result immediately in the Log View.

* UserInterface/Views/ConsolePrompt.js:
(WebInspector.ConsolePrompt.prototype.pushHistoryItem):
(WebInspector.ConsolePrompt.prototype.commitTextOrInsertNewLine):
(WebInspector.ConsolePrompt.prototype._handleEnterKey):
(WebInspector.ConsolePrompt.prototype._commitHistoryEntry):
Add a way to append a history item to the console prompt history.

* UserInterface/Views/ObjectTreePropertyTreeElement.js:
(WebInspector.ObjectTreePropertyTreeElement.prototype):
Add a context menu item to object tree properties to log the value.

* UserInterface/Protocol/RemoteObject.js:
(WebInspector.RemoteObject.createCallArgument):
(WebInspector.RemoteObject.prototype.callFunction):
(WebInspector.RemoteObject.prototype.asCallArgument):
Simplify CallArgument creation.

* UserInterface/Controllers/RuntimeManager.js:
(WebInspector.RuntimeManager.prototype.mycallback):
(WebInspector.RuntimeManager.prototype.saveResult):
Wrap RuntimeAgent.saveResult. If supported, run the backend command
and fetch a saved result index from the backend for the given value.

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Base/Main.js:
(WebInspector.contentLoaded):
* UserInterface/Views/LogContentView.js:
(WebInspector.LogContentView.prototype.get logViewController):
Misc.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorInjectedScriptcpp">trunk/Source/JavaScriptCore/inspector/InjectedScript.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorInjectedScripth">trunk/Source/JavaScriptCore/inspector/InjectedScript.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorInjectedScriptSourcejs">trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectoragentsInspectorRuntimeAgentcpp">trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectoragentsInspectorRuntimeAgenth">trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorprotocolDebuggerjson">trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorprotocolRuntimejson">trunk/Source/JavaScriptCore/inspector/protocol/Runtime.json</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs">trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceBaseMainjs">trunk/Source/WebInspectorUI/UserInterface/Base/Main.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersJavaScriptLogViewControllerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersRuntimeManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProtocolRemoteObjectjs">trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsConsolePromptjs">trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsLogContentViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.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="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-03-02  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Context Menu to Log a Particular Object
+        https://bugs.webkit.org/show_bug.cgi?id=142198
+
+        Reviewed by Timothy Hatcher.
+
+        Add a protocol method to assign a $n index to a value. For an object
+        use the injected script context for that object. For a value, use
+        the execution context to know where to save the value.
+
+        * inspector/InjectedScript.cpp:
+        (Inspector::InjectedScript::saveResult):
+        * inspector/InjectedScript.h:
+        * inspector/InjectedScriptSource.js:
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::saveResult):
+        * inspector/agents/InspectorRuntimeAgent.h:
+        * inspector/protocol/Debugger.json:
+        * inspector/protocol/Runtime.json:
+
</ins><span class="cx"> 2015-03-02  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         SpeculativeJIT::emitAllocateArguments() should be a bit faster, and shouldn't do destructor initialization
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorInjectedScriptcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/InjectedScript.cpp (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/InjectedScript.cpp        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/JavaScriptCore/inspector/InjectedScript.cpp        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -177,6 +177,23 @@
</span><span class="cx">     *entries = BindingTraits&lt;Array&lt;Protocol::Runtime::CollectionEntry&gt;&gt;::runtimeCast(WTF::move(result));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void InjectedScript::saveResult(ErrorString&amp; errorString, const String&amp; callArgumentJSON, Inspector::Protocol::OptOutput&lt;int&gt;* savedResultIndex)
+{
+    Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral(&quot;saveResult&quot;), inspectorEnvironment()-&gt;functionCallHandler());
+    function.appendArgument(callArgumentJSON);
+
+    RefPtr&lt;InspectorValue&gt; result;
+    makeCall(function, &amp;result);
+    if (!result || result-&gt;type() != InspectorValue::Type::Integer) {
+        errorString = ASCIILiteral(&quot;Internal error&quot;);
+        return;
+    }
+
+    int savedResultIndexInt = 0;
+    if (result-&gt;asInteger(savedResultIndexInt) &amp;&amp; savedResultIndexInt &gt; 0)
+        *savedResultIndex = savedResultIndexInt;
+}
+
</ins><span class="cx"> Ref&lt;Array&lt;Inspector::Protocol::Debugger::CallFrame&gt;&gt; InjectedScript::wrapCallFrames(const Deprecated::ScriptValue&amp; callFrames)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!hasNoValue());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorInjectedScripth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/InjectedScript.h (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/InjectedScript.h        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/JavaScriptCore/inspector/InjectedScript.h        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx">     void getDisplayableProperties(ErrorString&amp;, const String&amp; objectId, bool generatePreview, RefPtr&lt;Protocol::Array&lt;Protocol::Runtime::PropertyDescriptor&gt;&gt;* result);
</span><span class="cx">     void getInternalProperties(ErrorString&amp;, const String&amp; objectId, bool generatePreview, RefPtr&lt;Protocol::Array&lt;Protocol::Runtime::InternalPropertyDescriptor&gt;&gt;* result);
</span><span class="cx">     void getCollectionEntries(ErrorString&amp;, const String&amp; objectId, const String&amp; objectGroup, int startIndex, int numberToFetch, RefPtr&lt;Protocol::Array&lt;Protocol::Runtime::CollectionEntry&gt;&gt;* entries);
</span><ins>+    void saveResult(ErrorString&amp;, const String&amp; callArgumentJSON, Inspector::Protocol::OptOutput&lt;int&gt;* savedResultIndex);
</ins><span class="cx"> 
</span><span class="cx">     Ref&lt;Protocol::Array&lt;Protocol::Debugger::CallFrame&gt;&gt; wrapCallFrames(const Deprecated::ScriptValue&amp;);
</span><span class="cx">     RefPtr&lt;Protocol::Runtime::RemoteObject&gt; wrapObject(const Deprecated::ScriptValue&amp;, const String&amp; groupName, bool generatePreview = false) const;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorInjectedScriptSourcejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -295,6 +295,19 @@
</span><span class="cx">         });
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    saveResult: function(callArgumentJSON)
+    {
+        this._savedResultIndex = 0;
+
+        try {
+            var callArgument = InjectedScriptHost.evaluate(&quot;(&quot; + callArgumentJSON + &quot;)&quot;);
+            var value = this._resolveCallArgument(callArgument);
+            this._saveResult(value);
+        } catch (e) {}
+
+        return this._savedResultIndex;
+    },
+
</ins><span class="cx">     getFunctionDetails: function(functionId)
</span><span class="cx">     {
</span><span class="cx">         var parsedFunctionId = this._parseObjectId(functionId);
</span><span class="lines">@@ -367,8 +380,12 @@
</span><span class="cx">         }
</span><span class="cx">     },
</span><span class="cx"> 
</span><del>-    _resolveCallArgument: function(callArgumentJson) {
-        var objectId = callArgumentJson.objectId;
</del><ins>+    _resolveCallArgument: function(callArgumentJSON)
+    {
+        if (&quot;value&quot; in callArgumentJSON)
+            return callArgumentJSON.value;
+
+        var objectId = callArgumentJSON.objectId;
</ins><span class="cx">         if (objectId) {
</span><span class="cx">             var parsedArgId = this._parseObjectId(objectId);
</span><span class="cx">             if (!parsedArgId || parsedArgId[&quot;injectedScriptId&quot;] !== injectedScriptId)
</span><span class="lines">@@ -379,15 +396,15 @@
</span><span class="cx">                 throw &quot;Could not find object with given id&quot;;
</span><span class="cx"> 
</span><span class="cx">             return resolvedArg;
</span><del>-        } else if (&quot;value&quot; in callArgumentJson)
-            return callArgumentJson.value;
</del><ins>+        }
+
</ins><span class="cx">         return undefined;
</span><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, saveResult)
</span><span class="cx">     {
</span><span class="cx">         try {
</span><del>-            this._savedResultIndex = undefined;
</del><ins>+            this._savedResultIndex = 0;
</ins><span class="cx"> 
</span><span class="cx">             var returnObject = {
</span><span class="cx">                 wasThrown: false,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectoragentsInspectorRuntimeAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -210,6 +210,26 @@
</span><span class="cx">     injectedScript.getCollectionEntries(errorString, objectId, objectGroup ? *objectGroup : String(), start, fetch, &amp;entries);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void InspectorRuntimeAgent::saveResult(ErrorString&amp; errorString, const RefPtr&lt;Inspector::InspectorObject&gt;&amp;&amp; callArgument, const int* executionContextId, Inspector::Protocol::OptOutput&lt;int&gt;* savedResultIndex)
+{
+    InjectedScript injectedScript;
+
+    String objectId;
+    if (callArgument-&gt;getString(ASCIILiteral(&quot;objectId&quot;), objectId)) {
+        injectedScript = m_injectedScriptManager-&gt;injectedScriptForObjectId(objectId);
+        if (injectedScript.hasNoValue()) {
+            errorString = ASCIILiteral(&quot;Inspected frame has gone&quot;);
+            return;
+        }
+    } else {
+        injectedScript = injectedScriptForEval(errorString, executionContextId);
+        if (injectedScript.hasNoValue())
+            return;
+    }
+
+    injectedScript.saveResult(errorString, callArgument-&gt;toJSONString(), savedResultIndex);
+}
+
</ins><span class="cx"> void InspectorRuntimeAgent::releaseObject(ErrorString&amp;, const String&amp; objectId)
</span><span class="cx"> {
</span><span class="cx">     InjectedScript injectedScript = m_injectedScriptManager-&gt;injectedScriptForObjectId(objectId);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectoragentsInspectorRuntimeAgenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx">     virtual void getProperties(ErrorString&amp;, const String&amp; objectId, const bool* ownProperties, const bool* generatePreview, RefPtr&lt;Inspector::Protocol::Array&lt;Inspector::Protocol::Runtime::PropertyDescriptor&gt;&gt;&amp; result, RefPtr&lt;Inspector::Protocol::Array&lt;Inspector::Protocol::Runtime::InternalPropertyDescriptor&gt;&gt;&amp; internalProperties) override final;
</span><span class="cx">     virtual void getDisplayableProperties(ErrorString&amp;, const String&amp; objectId, const bool* generatePreview, RefPtr&lt;Inspector::Protocol::Array&lt;Inspector::Protocol::Runtime::PropertyDescriptor&gt;&gt;&amp; result, RefPtr&lt;Inspector::Protocol::Array&lt;Inspector::Protocol::Runtime::InternalPropertyDescriptor&gt;&gt;&amp; internalProperties) override final;
</span><span class="cx">     virtual void getCollectionEntries(ErrorString&amp;, const String&amp; objectId, const String* objectGroup, const int* startIndex, const int* numberToFetch, RefPtr&lt;Inspector::Protocol::Array&lt;Inspector::Protocol::Runtime::CollectionEntry&gt;&gt;&amp; entries) override final;
</span><ins>+    virtual void saveResult(ErrorString&amp;, const RefPtr&lt;Inspector::InspectorObject&gt;&amp;&amp; callArgument, const int* executionContextId, Inspector::Protocol::OptOutput&lt;int&gt;* savedResultIndex) override final;
</ins><span class="cx">     virtual void releaseObjectGroup(ErrorString&amp;, const String&amp; objectGroup) override final;
</span><span class="cx">     virtual void run(ErrorString&amp;) override;
</span><span class="cx">     virtual void getRuntimeTypesForVariablesAtOffsets(ErrorString&amp;, const RefPtr&lt;Inspector::InspectorArray&gt;&amp;&amp; locations, RefPtr&lt;Inspector::Protocol::Array&lt;Inspector::Protocol::Runtime::TypeDescription&gt;&gt;&amp;) override;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolDebuggerjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -230,7 +230,7 @@
</span><span class="cx">             &quot;returns&quot;: [
</span><span class="cx">                 { &quot;name&quot;: &quot;details&quot;, &quot;$ref&quot;: &quot;FunctionDetails&quot;, &quot;description&quot;: &quot;Information about the function.&quot; }
</span><span class="cx">             ],
</span><del>-            &quot;description&quot;: &quot;Returns detailed informtation on given function.&quot;
</del><ins>+            &quot;description&quot;: &quot;Returns detailed information on given function.&quot;
</ins><span class="cx">         },
</span><span class="cx">         {
</span><span class="cx">             &quot;name&quot;: &quot;setPauseOnExceptions&quot;,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolRuntimejson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/Runtime.json (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/Runtime.json        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/JavaScriptCore/inspector/protocol/Runtime.json        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -274,6 +274,17 @@
</span><span class="cx">             ]
</span><span class="cx">         },
</span><span class="cx">         {
</span><ins>+            &quot;name&quot;: &quot;saveResult&quot;,
+            &quot;parameters&quot;: [
+                { &quot;name&quot;: &quot;value&quot;, &quot;$ref&quot;: &quot;CallArgument&quot;, &quot;description&quot;: &quot;Id or value of the object to save.&quot; },
+                { &quot;name&quot;: &quot;contextId&quot;, &quot;optional&quot;: true, &quot;$ref&quot;: &quot;ExecutionContextId&quot;, &quot;description&quot;: &quot;Unique id of the execution context. To specify in which execution context script evaluation should be performed. If not provided, determine from the CallArgument's objectId.&quot; }
+            ],
+            &quot;returns&quot;: [
+                { &quot;name&quot;: &quot;savedResultIndex&quot;, &quot;type&quot;: &quot;integer&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;If the value was saved, this is the $n index that can be used to access the value.&quot; }
+            ],
+            &quot;description&quot;: &quot;Assign a saved result index to this value.&quot;
+        },
+        {
</ins><span class="cx">             &quot;name&quot;: &quot;releaseObject&quot;,
</span><span class="cx">             &quot;parameters&quot;: [
</span><span class="cx">                 { &quot;name&quot;: &quot;objectId&quot;, &quot;$ref&quot;: &quot;RemoteObjectId&quot;, &quot;description&quot;: &quot;Identifier of the object to release.&quot; }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/WebInspectorUI/ChangeLog        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -1,5 +1,47 @@
</span><span class="cx"> 2015-03-02  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Web Inspector: Context Menu to Log a Particular Object
+        https://bugs.webkit.org/show_bug.cgi?id=142198
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Controllers/JavaScriptLogViewController.js:
+        (WebInspector.JavaScriptLogViewController.prototype.saveResultCallback):
+        (WebInspector.JavaScriptLogViewController.prototype.appendImmediateExecutionWithResult):
+        Add a way to show an execution and result immediately in the Log View.
+
+        * UserInterface/Views/ConsolePrompt.js:
+        (WebInspector.ConsolePrompt.prototype.pushHistoryItem):
+        (WebInspector.ConsolePrompt.prototype.commitTextOrInsertNewLine):
+        (WebInspector.ConsolePrompt.prototype._handleEnterKey):
+        (WebInspector.ConsolePrompt.prototype._commitHistoryEntry):
+        Add a way to append a history item to the console prompt history.
+
+        * UserInterface/Views/ObjectTreePropertyTreeElement.js:
+        (WebInspector.ObjectTreePropertyTreeElement.prototype):
+        Add a context menu item to object tree properties to log the value.
+
+        * UserInterface/Protocol/RemoteObject.js:
+        (WebInspector.RemoteObject.createCallArgument):
+        (WebInspector.RemoteObject.prototype.callFunction):
+        (WebInspector.RemoteObject.prototype.asCallArgument):
+        Simplify CallArgument creation.
+
+        * UserInterface/Controllers/RuntimeManager.js:
+        (WebInspector.RuntimeManager.prototype.mycallback):
+        (WebInspector.RuntimeManager.prototype.saveResult):
+        Wrap RuntimeAgent.saveResult. If supported, run the backend command
+        and fetch a saved result index from the backend for the given value.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        * UserInterface/Base/Main.js:
+        (WebInspector.contentLoaded):
+        * UserInterface/Views/LogContentView.js:
+        (WebInspector.LogContentView.prototype.get logViewController):
+        Misc.
+
+2015-03-02  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
</ins><span class="cx">         Web Inspector: Add Context Menus to Object Tree properties
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=142125
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -286,6 +286,7 @@
</span><span class="cx"> localizedStrings[&quot;Located at %s&quot;] = &quot;Located at %s&quot;;
</span><span class="cx"> localizedStrings[&quot;Location&quot;] = &quot;Location&quot;;
</span><span class="cx"> localizedStrings[&quot;Log Message&quot;] = &quot;Log Message&quot;;
</span><ins>+localizedStrings[&quot;Log Value&quot;] = &quot;Log Value&quot;;
</ins><span class="cx"> localizedStrings[&quot;Log: &quot;] = &quot;Log: &quot;;
</span><span class="cx"> localizedStrings[&quot;Logs&quot;] = &quot;Logs&quot;;
</span><span class="cx"> localizedStrings[&quot;MIME Type&quot;] = &quot;MIME Type&quot;;
</span><span class="lines">@@ -402,6 +403,7 @@
</span><span class="cx"> localizedStrings[&quot;Selected&quot;] = &quot;Selected&quot;;
</span><span class="cx"> localizedStrings[&quot;Selected Item&quot;] = &quot;Selected Item&quot;;
</span><span class="cx"> localizedStrings[&quot;Selected Items&quot;] = &quot;Selected Items&quot;;
</span><ins>+localizedStrings[&quot;Selected Value&quot;] = &quot;Selected Value&quot;;
</ins><span class="cx"> localizedStrings[&quot;Self Time&quot;] = &quot;Self Time&quot;;
</span><span class="cx"> localizedStrings[&quot;Semantic Issue&quot;] = &quot;Semantic Issue&quot;;
</span><span class="cx"> localizedStrings[&quot;Session&quot;] = &quot;Session&quot;;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceBaseMainjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -227,6 +227,7 @@
</span><span class="cx">     this._consoleRepresentedObject = new WebInspector.LogObject;
</span><span class="cx">     this._consoleTreeElement = new WebInspector.LogTreeElement(this._consoleRepresentedObject);
</span><span class="cx">     this.consoleContentView = WebInspector.contentBrowser.contentViewForRepresentedObject(this._consoleRepresentedObject);
</span><ins>+    this.consoleLogViewController = this.consoleContentView.logViewController;
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: The sidebars should be flipped in RTL languages.
</span><span class="cx">     this.leftSidebar = this.navigationSidebar = new WebInspector.Sidebar(document.getElementById(&quot;navigation-sidebar&quot;), WebInspector.Sidebar.Sides.Left);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersJavaScriptLogViewControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -130,6 +130,22 @@
</span><span class="cx">         consoleGroup.element.scrollIntoView();
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    appendImmediateExecutionWithResult: function(text, result)
+    {
+        console.assert(result instanceof WebInspector.RemoteObject);
+
+        var commandMessage = new WebInspector.ConsoleCommand(text);
+        this._appendConsoleMessage(commandMessage, true);
+
+        function saveResultCallback(savedResultIndex)
+        {
+            var commandResultMessage = new WebInspector.ConsoleCommandResult(result, false, commandMessage, savedResultIndex);
+            this._appendConsoleMessage(commandResultMessage, true);
+        }
+
+        WebInspector.runtimeManager.saveResult(result, saveResultCallback.bind(this));
+    },
+
</ins><span class="cx">     appendConsoleMessage: function(consoleMessage)
</span><span class="cx">     {
</span><span class="cx">         // Clone the message since there might be multiple clients using the message,
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersRuntimeManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -79,6 +79,26 @@
</span><span class="cx">         RuntimeAgent.evaluate.invoke({expression: expression, objectGroup: objectGroup, includeCommandLineAPI: includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole: doNotPauseOnExceptionsAndMuteConsole, contextId: contextId, frameId: contextId, returnByValue: returnByValue, generatePreview: generatePreview, saveResult: saveResult}, evalCallback.bind(this));
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    saveResult: function(remoteObject, callback)
+    {
+        console.assert(remoteObject instanceof WebInspector.RemoteObject);
+
+        if (!RuntimeAgent.saveResult) {
+            callback(undefined);
+            return;
+        }
+
+        function mycallback(error, savedResultIndex)
+        {
+            callback(savedResultIndex);
+        }
+
+        if (remoteObject.objectId)
+            RuntimeAgent.saveResult(remoteObject.asCallArgument(), mycallback);
+        else
+            RuntimeAgent.saveResult(remoteObject.asCallArgument(), WebInspector.quickConsole.executionContextIdentifier, mycallback);
+    },
+
</ins><span class="cx">     getPropertiesForRemoteObject: function(objectId, callback)
</span><span class="cx">     {
</span><span class="cx">         RuntimeAgent.getProperties(objectId, function(error, result) {
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProtocolRemoteObjectjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -82,6 +82,17 @@
</span><span class="cx">     return new WebInspector.RemoteObject(payload.objectId, payload.type, payload.subtype, payload.value, payload.description, payload.preview);
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+WebInspector.RemoteObject.createCallArgument = function(valueOrObject)
+{
+    if (valueOrObject instanceof WebInspector.RemoteObject) {
+        if (valueOrObject.objectId)
+            return {objectId: valueOrObject.objectId};
+        return {value: valueOrObject.value};
+    }
+
+    return {value: valueOrObject};
+};
+
</ins><span class="cx"> WebInspector.RemoteObject.resolveNode = function(node, objectGroup, callback)
</span><span class="cx"> {
</span><span class="cx">     DOMAgent.resolveNode(node.id, objectGroup, function(error, object) {
</span><span class="lines">@@ -413,16 +424,8 @@
</span><span class="cx">             callback(error, result, wasThrown);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (args) {
-            args = args.map(function(arg) {
-                if (arg instanceof WebInspector.RemoteObject) {
-                    if (arg.objectId)
-                        return {objectId: arg.objectId};
-                    return {value: arg.value};
-                }
-                return {value: arg};
-            });
-        }
</del><ins>+        if (args)
+            args = args.map(WebInspector.RemoteObject.createCallArgument);
</ins><span class="cx"> 
</span><span class="cx">         RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, undefined, generatePreview, mycallback);
</span><span class="cx">     },
</span><span class="lines">@@ -492,6 +495,11 @@
</span><span class="cx">         return parseInt(matches[1], 10);
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    asCallArgument: function()
+    {
+        return WebInspector.RemoteObject.createCallArgument(this);
+    },
+
</ins><span class="cx">     // Private
</span><span class="cx"> 
</span><span class="cx">     _weakCollectionObjectGroup: function()
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsConsolePromptjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -140,6 +140,11 @@
</span><span class="cx">         this._completionController.updateCompletions(completions, implicitSuffix);
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    pushHistoryItem: function(text)
+    {
+        this._commitHistoryEntry({text: text});
+    },
+
</ins><span class="cx">     // Protected
</span><span class="cx"> 
</span><span class="cx">     completionControllerCompletionsNeeded: function(completionController, prefix, defaultCompletions, base, suffix, forced)
</span><span class="lines">@@ -239,24 +244,8 @@
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            var historyEntry = this._historyEntryForCurrentText();
</del><ins>+            this._commitHistoryEntry(this._historyEntryForCurrentText());
</ins><span class="cx"> 
</span><del>-            // Replace the previous entry if it does not have text or if the text is the same.
-            if (this._history[1] &amp;&amp; (!this._history[1].text || this._history[1].text === historyEntry.text)) {
-                this._history[1] = historyEntry;
-                this._history[0] = {};
-            } else {
-                // Replace the first history entry and push a new empty one.
-                this._history[0] = historyEntry;
-                this._history.unshift({});
-
-                // Trim the history length if needed.
-                if (this._history.length &gt; WebInspector.ConsolePrompt.MaximumHistorySize)
-                    this._history = this._history.slice(0, WebInspector.ConsolePrompt.MaximumHistorySize);
-            }
-
-            this._historyIndex = 0;
-
</del><span class="cx">             this._codeMirror.setValue(&quot;&quot;);
</span><span class="cx">             this._codeMirror.clearHistory();
</span><span class="cx"> 
</span><span class="lines">@@ -275,6 +264,25 @@
</span><span class="cx">         commitTextOrInsertNewLine.call(this, true);
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    _commitHistoryEntry: function(historyEntry)
+    {
+        // Replace the previous entry if it does not have text or if the text is the same.
+        if (this._history[1] &amp;&amp; (!this._history[1].text || this._history[1].text === historyEntry.text)) {
+            this._history[1] = historyEntry;
+            this._history[0] = {};
+        } else {
+            // Replace the first history entry and push a new empty one.
+            this._history[0] = historyEntry;
+            this._history.unshift({});
+
+            // Trim the history length if needed.
+            if (this._history.length &gt; WebInspector.ConsolePrompt.MaximumHistorySize)
+                this._history = this._history.slice(0, WebInspector.ConsolePrompt.MaximumHistorySize);
+        }
+
+        this._historyIndex = 0;
+    },
+
</ins><span class="cx">     _handleCommandEnterKey: function(codeMirror)
</span><span class="cx">     {
</span><span class="cx">         this._handleEnterKey(codeMirror, true);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsLogContentViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -125,6 +125,11 @@
</span><span class="cx">         return this._scopeBar;
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    get logViewController()
+    {
+        return this._logViewController;
+    },
+
</ins><span class="cx">     updateLayout: function()
</span><span class="cx">     {
</span><span class="cx">         WebInspector.ContentView.prototype.updateLayout.call(this);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsObjectTreePropertyTreeElementjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js (180912 => 180913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js        2015-03-03 01:37:12 UTC (rev 180912)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js        2015-03-03 02:24:49 UTC (rev 180913)
</span><span class="lines">@@ -473,6 +473,22 @@
</span><span class="cx">         }
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    _logValue: function(value)
+    {
+        var resolvedValue = value || this._resolvedValue();
+        if (!resolvedValue)
+            return;
+
+        var propertyPath = this._resolvedValuePropertyPath();
+        var isImpossible = propertyPath.isFullPathImpossible();
+        var text = isImpossible ? WebInspector.UIString(&quot;Selected Value&quot;) : propertyPath.displayPath(this._propertyPathType());
+
+        if (!isImpossible)
+            WebInspector.quickConsole.prompt.pushHistoryItem(text);
+
+        WebInspector.consoleLogViewController.appendImmediateExecutionWithResult(text, resolvedValue);
+    },
+
</ins><span class="cx">     _contextMenuHandler: function(event)
</span><span class="cx">     {
</span><span class="cx">         var resolvedValue = this._resolvedValue();
</span><span class="lines">@@ -480,6 +496,7 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         var contextMenu = new WebInspector.ContextMenu(event);
</span><ins>+        contextMenu.appendItem(WebInspector.UIString(&quot;Log Value&quot;), this._logValue.bind(this));
</ins><span class="cx"> 
</span><span class="cx">         var propertyPath = this._resolvedValuePropertyPath();
</span><span class="cx">         if (propertyPath &amp;&amp; !propertyPath.isFullPathImpossible()) {
</span></span></pre>
</div>
</div>

</body>
</html>