<!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 <pecoraro@apple.com>
+
+ 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 <fpizlo@apple.com>
</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<Array<Protocol::Runtime::CollectionEntry>>::runtimeCast(WTF::move(result));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void InjectedScript::saveResult(ErrorString& errorString, const String& callArgumentJSON, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+{
+ Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("saveResult"), inspectorEnvironment()->functionCallHandler());
+ function.appendArgument(callArgumentJSON);
+
+ RefPtr<InspectorValue> result;
+ makeCall(function, &result);
+ if (!result || result->type() != InspectorValue::Type::Integer) {
+ errorString = ASCIILiteral("Internal error");
+ return;
+ }
+
+ int savedResultIndexInt = 0;
+ if (result->asInteger(savedResultIndexInt) && savedResultIndexInt > 0)
+ *savedResultIndex = savedResultIndexInt;
+}
+
</ins><span class="cx"> Ref<Array<Inspector::Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& 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&, const String& objectId, bool generatePreview, RefPtr<Protocol::Array<Protocol::Runtime::PropertyDescriptor>>* result);
</span><span class="cx"> void getInternalProperties(ErrorString&, const String& objectId, bool generatePreview, RefPtr<Protocol::Array<Protocol::Runtime::InternalPropertyDescriptor>>* result);
</span><span class="cx"> void getCollectionEntries(ErrorString&, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<Protocol::Array<Protocol::Runtime::CollectionEntry>>* entries);
</span><ins>+ void saveResult(ErrorString&, const String& callArgumentJSON, Inspector::Protocol::OptOutput<int>* savedResultIndex);
</ins><span class="cx">
</span><span class="cx"> Ref<Protocol::Array<Protocol::Debugger::CallFrame>> wrapCallFrames(const Deprecated::ScriptValue&);
</span><span class="cx"> RefPtr<Protocol::Runtime::RemoteObject> wrapObject(const Deprecated::ScriptValue&, const String& 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("(" + callArgumentJSON + ")");
+ 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 ("value" 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["injectedScriptId"] !== injectedScriptId)
</span><span class="lines">@@ -379,15 +396,15 @@
</span><span class="cx"> throw "Could not find object with given id";
</span><span class="cx">
</span><span class="cx"> return resolvedArg;
</span><del>- } else if ("value" 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, &entries);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void InspectorRuntimeAgent::saveResult(ErrorString& errorString, const RefPtr<Inspector::InspectorObject>&& callArgument, const int* executionContextId, Inspector::Protocol::OptOutput<int>* savedResultIndex)
+{
+ InjectedScript injectedScript;
+
+ String objectId;
+ if (callArgument->getString(ASCIILiteral("objectId"), objectId)) {
+ injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
+ if (injectedScript.hasNoValue()) {
+ errorString = ASCIILiteral("Inspected frame has gone");
+ return;
+ }
+ } else {
+ injectedScript = injectedScriptForEval(errorString, executionContextId);
+ if (injectedScript.hasNoValue())
+ return;
+ }
+
+ injectedScript.saveResult(errorString, callArgument->toJSONString(), savedResultIndex);
+}
+
</ins><span class="cx"> void InspectorRuntimeAgent::releaseObject(ErrorString&, const String& objectId)
</span><span class="cx"> {
</span><span class="cx"> InjectedScript injectedScript = m_injectedScriptManager->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&, const String& objectId, const bool* ownProperties, const bool* generatePreview, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties) override final;
</span><span class="cx"> virtual void getDisplayableProperties(ErrorString&, const String& objectId, const bool* generatePreview, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties) override final;
</span><span class="cx"> virtual void getCollectionEntries(ErrorString&, const String& objectId, const String* objectGroup, const int* startIndex, const int* numberToFetch, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::CollectionEntry>>& entries) override final;
</span><ins>+ virtual void saveResult(ErrorString&, const RefPtr<Inspector::InspectorObject>&& callArgument, const int* executionContextId, Inspector::Protocol::OptOutput<int>* savedResultIndex) override final;
</ins><span class="cx"> virtual void releaseObjectGroup(ErrorString&, const String& objectGroup) override final;
</span><span class="cx"> virtual void run(ErrorString&) override;
</span><span class="cx"> virtual void getRuntimeTypesForVariablesAtOffsets(ErrorString&, const RefPtr<Inspector::InspectorArray>&& locations, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::TypeDescription>>&) 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"> "returns": [
</span><span class="cx"> { "name": "details", "$ref": "FunctionDetails", "description": "Information about the function." }
</span><span class="cx"> ],
</span><del>- "description": "Returns detailed informtation on given function."
</del><ins>+ "description": "Returns detailed information on given function."
</ins><span class="cx"> },
</span><span class="cx"> {
</span><span class="cx"> "name": "setPauseOnExceptions",
</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>+ "name": "saveResult",
+ "parameters": [
+ { "name": "value", "$ref": "CallArgument", "description": "Id or value of the object to save." },
+ { "name": "contextId", "optional": true, "$ref": "ExecutionContextId", "description": "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." }
+ ],
+ "returns": [
+ { "name": "savedResultIndex", "type": "integer", "optional": true, "description": "If the value was saved, this is the $n index that can be used to access the value." }
+ ],
+ "description": "Assign a saved result index to this value."
+ },
+ {
</ins><span class="cx"> "name": "releaseObject",
</span><span class="cx"> "parameters": [
</span><span class="cx"> { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to release." }
</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 <pecoraro@apple.com>
</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 <pecoraro@apple.com>
+
</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["Located at %s"] = "Located at %s";
</span><span class="cx"> localizedStrings["Location"] = "Location";
</span><span class="cx"> localizedStrings["Log Message"] = "Log Message";
</span><ins>+localizedStrings["Log Value"] = "Log Value";
</ins><span class="cx"> localizedStrings["Log: "] = "Log: ";
</span><span class="cx"> localizedStrings["Logs"] = "Logs";
</span><span class="cx"> localizedStrings["MIME Type"] = "MIME Type";
</span><span class="lines">@@ -402,6 +403,7 @@
</span><span class="cx"> localizedStrings["Selected"] = "Selected";
</span><span class="cx"> localizedStrings["Selected Item"] = "Selected Item";
</span><span class="cx"> localizedStrings["Selected Items"] = "Selected Items";
</span><ins>+localizedStrings["Selected Value"] = "Selected Value";
</ins><span class="cx"> localizedStrings["Self Time"] = "Self Time";
</span><span class="cx"> localizedStrings["Semantic Issue"] = "Semantic Issue";
</span><span class="cx"> localizedStrings["Session"] = "Session";
</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("navigation-sidebar"), 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] && (!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 > WebInspector.ConsolePrompt.MaximumHistorySize)
- this._history = this._history.slice(0, WebInspector.ConsolePrompt.MaximumHistorySize);
- }
-
- this._historyIndex = 0;
-
</del><span class="cx"> this._codeMirror.setValue("");
</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] && (!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 > 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("Selected Value") : 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("Log Value"), this._logValue.bind(this));
</ins><span class="cx">
</span><span class="cx"> var propertyPath = this._resolvedValuePropertyPath();
</span><span class="cx"> if (propertyPath && !propertyPath.isFullPathImpossible()) {
</span></span></pre>
</div>
</div>
</body>
</html>