<!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>[193001] branches/safari-601-branch/Source/WebInspectorUI</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/193001">193001</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2015-12-03 10:29:28 -0800 (Thu, 03 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/186695">r186695</a>. rdar://problem/23221163</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601branchSourceWebInspectorUIChangeLog">branches/safari-601-branch/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceProtocolRemoteObjectjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceViewsConsoleMessageViewcss">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceViewsConsoleMessageViewjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601branchSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193000 => 193001)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog        2015-12-03 17:57:13 UTC (rev 193000)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog        2015-12-03 18:29:28 UTC (rev 193001)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-12-01 Timothy Hatcher <timothy@apple.com>
+
+ Merge r186695. rdar://problem/23221163
+
+ 2015-07-10 Devin Rousso <drousso@apple.com>
+
+ Web Inspector: Add source links to functions logged in the console
+ https://bugs.webkit.org/show_bug.cgi?id=146377
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Protocol/RemoteObject.js:
+ (WebInspector.RemoteObject.prototype.findFunctionSourceCodeLocation):
+ Returns a promise that contains the sourceCodeLocation if the object represents a function and has an objectId.
+ (WebInspector.RemoteObject.prototype._isFunction):
+ * UserInterface/Views/ConsoleMessageView.css:
+ (.console-message .console-message-location):
+ Added specified values for font sizing and family to ensure that all location links have the same styling.
+ * UserInterface/Views/ConsoleMessageView.js:
+ (WebInspector.ConsoleMessageView):
+ Now creates a link to the source code of the entered text if the message is of the type "result".
+ (WebInspector.ConsoleMessageView.prototype._appendLocationLink):
+ (WebInspector.ConsoleMessageView.prototype._createRemoteObjectIfNeeded):
+ (WebInspector.ConsoleMessageView.prototype._appendFormattedArguments):
+ (WebInspector.ConsoleMessageView.prototype._linkifyLocation):
+ (WebInspector.ConsoleMessageView.prototype._linkifyCallFrameLocation):
+ (WebInspector.ConsoleMessageView.prototype._linkifyCallFrame):
+
</ins><span class="cx"> 2015-11-17 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r192172.
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceProtocolRemoteObjectjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js (193000 => 193001)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js        2015-12-03 17:57:13 UTC (rev 193000)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js        2015-12-03 18:29:28 UTC (rev 193001)
</span><span class="lines">@@ -478,6 +478,36 @@
</span><span class="cx"> return WebInspector.RemoteObject.createCallArgument(this);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ findFunctionSourceCodeLocation()
+ {
+ var result = new WebInspector.WrappedPromise;
+
+ if (!this._isFunction() || !this._objectId) {
+ result.resolve(WebInspector.RemoteObject.SourceCodeLocationPromise.MissingObjectId);
+ return result.promise;
+ }
+
+ DebuggerAgent.getFunctionDetails(this._objectId, function(error, response) {
+ if (error) {
+ result.reject(error);
+ return;
+ }
+
+ var location = response.location;
+ var sourceCode = WebInspector.debuggerManager.scriptForIdentifier(location.scriptId);
+
+ if (!sourceCode || sourceCode.url.startsWith("__WebInspector")) {
+ result.resolve(WebInspector.RemoteObject.SourceCodeLocationPromise.NoSourceFound);
+ return;
+ }
+
+ var sourceCodeLocation = sourceCode.createSourceCodeLocation(location.lineNumber, location.columnNumber || 0);
+ result.resolve(sourceCodeLocation);
+ });
+
+ return result.promise;
+ }
+
</ins><span class="cx"> // Private
</span><span class="cx">
</span><span class="cx"> _isSymbol()
</span><span class="lines">@@ -485,6 +515,11 @@
</span><span class="cx"> return this._type === "symbol";
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ _isFunction()
+ {
+ return this._type === "function";
+ }
+
</ins><span class="cx"> _weakCollectionObjectGroup()
</span><span class="cx"> {
</span><span class="cx"> return JSON.stringify(this._objectId) + "-" + this._subtype;
</span><span class="lines">@@ -564,6 +599,11 @@
</span><span class="cx"> }
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+WebInspector.RemoteObject.SourceCodeLocationPromise = {
+ NoSourceFound: "remote-object-source-code-location-promise-no-source-found",
+ MissingObjectId: "remote-object-source-code-location-promise-missing-object-id"
+}
+
</ins><span class="cx"> // FIXME: Phase out this deprecated class.
</span><span class="cx"> WebInspector.DeprecatedRemoteObjectProperty = class DeprecatedRemoteObjectProperty
</span><span class="cx"> {
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceViewsConsoleMessageViewcss"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css (193000 => 193001)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css        2015-12-03 17:57:13 UTC (rev 193000)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css        2015-12-03 18:29:28 UTC (rev 193001)
</span><span class="lines">@@ -230,7 +230,10 @@
</span><span class="cx">
</span><span class="cx"> .console-message .console-message-location {
</span><span class="cx"> float: right;
</span><ins>+ font-family: -webkit-system-font, sans-serif;
+ font-size: 12px;
</ins><span class="cx"> font-weight: normal;
</span><ins>+ -webkit-user-select: text;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> .console-message .call-frame {
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceViewsConsoleMessageViewjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (193000 => 193001)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js        2015-12-03 17:57:13 UTC (rev 193000)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js        2015-12-03 18:29:28 UTC (rev 193001)
</span><span class="lines">@@ -318,12 +318,30 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!callFrame)
</del><ins>+ if (callFrame) {
+ var locationElement = new WebInspector.CallFrameView(callFrame);
+ locationElement.classList.add("console-message-location");
+ this._element.appendChild(locationElement);
+
</ins><span class="cx"> return;
</span><ins>+ }
</ins><span class="cx">
</span><del>- var locationElement = new WebInspector.CallFrameView(callFrame);
- locationElement.classList.add("console-message-location");
- this._element.appendChild(locationElement);
</del><ins>+ if (this._message.parameters.length === 1) {
+ var parameter = this._createRemoteObjectIfNeeded(this._message.parameters[0]);
+
+ parameter.findFunctionSourceCodeLocation().then(function(result) {
+ if (result === WebInspector.RemoteObject.SourceCodeLocationPromise.NoSourceFound || result === WebInspector.RemoteObject.SourceCodeLocationPromise.MissingObjectId)
+ return;
+
+ var link = this._linkifyLocation(result.sourceCode.url, result.lineNumber, result.columnNumber);
+ link.classList.add("console-message-location");
+
+ if (this._element.hasChildNodes())
+ this._element.insertBefore(link, this._element.firstChild);
+ else
+ this._element.appendChild(link);
+ }.bind(this));
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _appendExtraParameters()
</span><span class="lines">@@ -373,22 +391,26 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ _createRemoteObjectIfNeeded(parameter)
+ {
+ // FIXME: Only pass RemoteObjects here so we can avoid this work.
+ if (parameter instanceof WebInspector.RemoteObject)
+ return parameter;
+
+ if (typeof parameter === "object")
+ return WebInspector.RemoteObject.fromPayload(parameter);
+
+ return WebInspector.RemoteObject.fromPrimitiveValue(parameter);
+ }
+
</ins><span class="cx"> _appendFormattedArguments(element, parameters)
</span><span class="cx"> {
</span><span class="cx"> if (!parameters.length)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- // FIXME: Only pass RemoteObjects here so we can avoid this work.
- for (var i = 0; i < parameters.length; ++i) {
- if (parameters[i] instanceof WebInspector.RemoteObject)
- continue;
</del><ins>+ for (var i = 0; i < parameters.length; ++i)
+ parameters[i] = this._createRemoteObjectIfNeeded(parameters[i]);
</ins><span class="cx">
</span><del>- if (typeof parameters[i] === "object")
- parameters[i] = WebInspector.RemoteObject.fromPayload(parameters[i]);
- else
- parameters[i] = WebInspector.RemoteObject.fromPrimitiveValue(parameters[i]);
- }
-
</del><span class="cx"> var builderElement = element.appendChild(document.createElement("span"));
</span><span class="cx"> var shouldFormatWithStringSubstitution = WebInspector.RemoteObject.type(parameters[0]) === "string" && this._message.type !== WebInspector.ConsoleMessage.MessageType.Result;
</span><span class="cx">
</span><span class="lines">@@ -623,10 +645,15 @@
</span><span class="cx">
</span><span class="cx"> _linkifyLocation(url, lineNumber, columnNumber)
</span><span class="cx"> {
</span><ins>+ return WebInspector.linkifyLocation(url, lineNumber, columnNumber, "console-message-url");
+ }
+
+ _linkifyCallFrameLocation(url, lineNumber, columnNumber)
+ {
</ins><span class="cx"> // ConsoleMessage stack trace line numbers are one-based.
</span><span class="cx"> lineNumber = lineNumber ? lineNumber - 1 : 0;
</span><span class="cx"> columnNumber = columnNumber ? columnNumber - 1 : 0;
</span><del>- return WebInspector.linkifyLocation(url, lineNumber, columnNumber, "console-message-url");
</del><ins>+ return this._linkifyLocation(url, lineNumber, columnNumber);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _linkifyCallFrame(callFrame)
</span><span class="lines">@@ -642,7 +669,7 @@
</span><span class="cx"> url = sourceCodeLocation.sourceCode && sourceCodeLocation.sourceCode.url || "";
</span><span class="cx"> }
</span><span class="cx">
</span><del>- return this._linkifyLocation(url, lineNumber, columnNumber);
</del><ins>+ return this._linkifyCallFrameLocation(url, lineNumber, columnNumber);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _userProvidedColumnNames(columnNamesArgument)
</span></span></pre>
</div>
</div>
</body>
</html>