Modified: trunk/Source/WebInspectorUI/ChangeLog (186694 => 186695)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-07-10 23:09:59 UTC (rev 186694)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-07-10 23:31:05 UTC (rev 186695)
@@ -1,3 +1,27 @@
+2015-07-10 Devin Rousso <[email protected]>
+
+ 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):
+
2015-07-10 Timothy Hatcher <[email protected]>
Web Inspector: Storage tab should have a scope bar in the sidebar
Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js (186694 => 186695)
--- trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js 2015-07-10 23:09:59 UTC (rev 186694)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js 2015-07-10 23:31:05 UTC (rev 186695)
@@ -478,6 +478,36 @@
return WebInspector.RemoteObject.createCallArgument(this);
}
+ 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;
+ }
+
// Private
_isSymbol()
@@ -485,6 +515,11 @@
return this._type === "symbol";
}
+ _isFunction()
+ {
+ return this._type === "function";
+ }
+
_weakCollectionObjectGroup()
{
return JSON.stringify(this._objectId) + "-" + this._subtype;
@@ -564,6 +599,11 @@
}
};
+WebInspector.RemoteObject.SourceCodeLocationPromise = {
+ NoSourceFound: "remote-object-source-code-location-promise-no-source-found",
+ MissingObjectId: "remote-object-source-code-location-promise-missing-object-id"
+}
+
// FIXME: Phase out this deprecated class.
WebInspector.DeprecatedRemoteObjectProperty = class DeprecatedRemoteObjectProperty
{
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css (186694 => 186695)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css 2015-07-10 23:09:59 UTC (rev 186694)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.css 2015-07-10 23:31:05 UTC (rev 186695)
@@ -230,7 +230,10 @@
.console-message .console-message-location {
float: right;
+ font-family: -webkit-system-font, sans-serif;
+ font-size: 12px;
font-weight: normal;
+ -webkit-user-select: text;
}
.console-message .call-frame {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (186694 => 186695)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js 2015-07-10 23:09:59 UTC (rev 186694)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js 2015-07-10 23:31:05 UTC (rev 186695)
@@ -314,12 +314,30 @@
});
}
- if (!callFrame)
+ if (callFrame) {
+ var locationElement = new WebInspector.CallFrameView(callFrame);
+ locationElement.classList.add("console-message-location");
+ this._element.appendChild(locationElement);
+
return;
+ }
- var locationElement = new WebInspector.CallFrameView(callFrame);
- locationElement.classList.add("console-message-location");
- this._element.appendChild(locationElement);
+ 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));
+ }
}
_appendExtraParameters()
@@ -369,22 +387,26 @@
}
}
+ _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);
+ }
+
_appendFormattedArguments(element, parameters)
{
if (!parameters.length)
return;
- // 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;
+ for (var i = 0; i < parameters.length; ++i)
+ parameters[i] = this._createRemoteObjectIfNeeded(parameters[i]);
- if (typeof parameters[i] === "object")
- parameters[i] = WebInspector.RemoteObject.fromPayload(parameters[i]);
- else
- parameters[i] = WebInspector.RemoteObject.fromPrimitiveValue(parameters[i]);
- }
-
var builderElement = element.appendChild(document.createElement("span"));
var shouldFormatWithStringSubstitution = WebInspector.RemoteObject.type(parameters[0]) === "string" && this._message.type !== WebInspector.ConsoleMessage.MessageType.Result;
@@ -619,10 +641,15 @@
_linkifyLocation(url, lineNumber, columnNumber)
{
+ return WebInspector.linkifyLocation(url, lineNumber, columnNumber, "console-message-url");
+ }
+
+ _linkifyCallFrameLocation(url, lineNumber, columnNumber)
+ {
// ConsoleMessage stack trace line numbers are one-based.
lineNumber = lineNumber ? lineNumber - 1 : 0;
columnNumber = columnNumber ? columnNumber - 1 : 0;
- return WebInspector.linkifyLocation(url, lineNumber, columnNumber, "console-message-url");
+ return this._linkifyLocation(url, lineNumber, columnNumber);
}
_linkifyCallFrame(callFrame)
@@ -638,7 +665,7 @@
url = "" && sourceCodeLocation.sourceCode.url || "";
}
- return this._linkifyLocation(url, lineNumber, columnNumber);
+ return this._linkifyCallFrameLocation(url, lineNumber, columnNumber);
}
_userProvidedColumnNames(columnNamesArgument)