Index: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
index 8c254697333d46aecca7c3b30001764b04e7fbe5..a1860bbe4536d001a2161e2ffcbfb46152b3b468 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
@@ -121,19 +121,18 @@ WebInspector.ConsoleViewMessage.prototype = { |
}, |
/** |
- * @param {!WebInspector.ConsoleMessage} consoleMessage |
* @return {!Element} |
*/ |
- _buildTableMessage: function(consoleMessage) |
+ _buildTableMessage: function() |
{ |
var formattedMessage = createElement("span"); |
WebInspector.appendStyle(formattedMessage, "components/objectValue.css"); |
formattedMessage.className = "console-message-text source-code"; |
- var anchorElement = this._buildMessageAnchor(consoleMessage); |
+ var anchorElement = this._buildMessageAnchor(); |
if (anchorElement) |
formattedMessage.appendChild(anchorElement); |
- var table = consoleMessage.parameters && consoleMessage.parameters.length ? consoleMessage.parameters[0] : null; |
+ var table = this._message.parameters && this._message.parameters.length ? this._message.parameters[0] : null; |
if (table) |
table = this._parameterToRemoteObject(table, this._target()); |
if (!table || !table.preview) |
@@ -185,7 +184,7 @@ WebInspector.ConsoleViewMessage.prototype = { |
var formattedResult = createElement("span"); |
var tableElement = formattedResult.createChild("div", "console-message-formatted-table"); |
var dataGridContainer = tableElement.createChild("span"); |
- tableElement.appendChild(this._formatParameter(table, true, false)); |
+ tableElement.appendChild(this._formatParameter(table, true)); |
dataGridContainer.appendChild(this._dataGrid.element); |
formattedMessage.appendChild(formattedResult); |
this._dataGrid.renderInline(); |
@@ -194,12 +193,12 @@ WebInspector.ConsoleViewMessage.prototype = { |
}, |
/** |
- * @param {!WebInspector.ConsoleMessage} consoleMessage |
* @return {!Element} |
*/ |
- _buildMessage: function(consoleMessage) |
+ _buildMessage: function() |
{ |
var messageElement; |
+ var consoleMessage = this._message; |
if (consoleMessage.source === WebInspector.ConsoleMessage.MessageSource.ConsoleAPI) { |
switch (consoleMessage.type) { |
case WebInspector.ConsoleMessage.MessageType.Trace: |
@@ -256,7 +255,7 @@ WebInspector.ConsoleViewMessage.prototype = { |
WebInspector.appendStyle(formattedMessage, "components/objectValue.css"); |
formattedMessage.className = "console-message-text source-code"; |
- var anchorElement = this._buildMessageAnchor(consoleMessage); |
+ var anchorElement = this._buildMessageAnchor(); |
if (anchorElement) |
formattedMessage.appendChild(anchorElement); |
formattedMessage.appendChild(messageElement); |
@@ -274,19 +273,22 @@ WebInspector.ConsoleViewMessage.prototype = { |
}, |
/** |
- * @param {!WebInspector.ConsoleMessage} consoleMessage |
* @return {?Element} |
*/ |
- _buildMessageAnchor: function(consoleMessage) |
+ _buildMessageAnchor: function() |
{ |
var anchorElement = null; |
+ var consoleMessage = this._message; |
if (consoleMessage.source !== WebInspector.ConsoleMessage.MessageSource.Network || consoleMessage.request) { |
- if (consoleMessage.scriptId) |
- anchorElement = this._linkifyScriptId(consoleMessage.scriptId, consoleMessage.url || "", consoleMessage.line, consoleMessage.column); |
- else if (consoleMessage.stackTrace && consoleMessage.stackTrace.callFrames.length) |
- anchorElement = this._linkifyStackTraceTopFrame(consoleMessage.stackTrace); |
- else if (consoleMessage.url && consoleMessage.url !== "undefined") |
- anchorElement = this._linkifyLocation(consoleMessage.url, consoleMessage.line, consoleMessage.column); |
+ var target = consoleMessage.target(); |
+ if (target) { |
+ if (consoleMessage.scriptId) |
+ anchorElement = this._linkifier.linkifyScriptLocation(target, consoleMessage.scriptId, consoleMessage.url || "", consoleMessage.line, consoleMessage.column, "console-message-url"); |
+ else if (consoleMessage.stackTrace && consoleMessage.stackTrace.callFrames.length) |
+ anchorElement = this._linkifier.linkifyStackTraceTopFrame(target, consoleMessage.stackTrace, "console-message-url"); |
+ else if (consoleMessage.url && consoleMessage.url !== "undefined") |
+ anchorElement = this._linkifier.linkifyScriptLocation(target, null, consoleMessage.url, consoleMessage.line, consoleMessage.column, "console-message-url"); |
+ } |
} else if (consoleMessage.url) { |
var url = consoleMessage.url; |
var isExternal = !WebInspector.resourceForURL(url) && !WebInspector.networkMapping.uiSourceCodeForURLForAnyTarget(url); |
@@ -311,7 +313,7 @@ WebInspector.ConsoleViewMessage.prototype = { |
var triangleElement = toggleElement.createChild("div", "console-message-stack-trace-triangle"); |
var contentElement = toggleElement.createChild("div", "console-message-stack-trace-wrapper"); |
- var messageElement = this._buildMessage(consoleMessage); |
+ var messageElement = this._buildMessage(); |
var clickableElement = contentElement.createChild("div"); |
clickableElement.appendChild(messageElement); |
var stackTraceElement = contentElement.createChild("div"); |
@@ -349,47 +351,6 @@ WebInspector.ConsoleViewMessage.prototype = { |
}, |
/** |
- * @param {string} url |
- * @param {number} lineNumber |
- * @param {number} columnNumber |
- * @return {?Element} |
- */ |
- _linkifyLocation: function(url, lineNumber, columnNumber) |
- { |
- var target = this._target(); |
- if (!target) |
- return null; |
- return this._linkifier.linkifyScriptLocation(target, null, url, lineNumber, columnNumber, "console-message-url"); |
- }, |
- |
- /** |
- * @param {!RuntimeAgent.StackTrace} stackTrace |
- * @return {?Element} |
- */ |
- _linkifyStackTraceTopFrame: function(stackTrace) |
- { |
- var target = this._target(); |
- if (!target) |
- return null; |
- return this._linkifier.linkifyStackTraceTopFrame(target, stackTrace, "console-message-url"); |
- }, |
- |
- /** |
- * @param {string} scriptId |
- * @param {string} url |
- * @param {number} lineNumber |
- * @param {number} columnNumber |
- * @return {?Element} |
- */ |
- _linkifyScriptId: function(scriptId, url, lineNumber, columnNumber) |
- { |
- var target = this._target(); |
- if (!target) |
- return null; |
- return this._linkifier.linkifyScriptLocation(target, scriptId, url, lineNumber, columnNumber, "console-message-url"); |
- }, |
- |
- /** |
* @param {!WebInspector.RemoteObject|!Object|string} parameter |
* @param {?WebInspector.Target} target |
* @return {!WebInspector.RemoteObject} |
@@ -424,10 +385,11 @@ WebInspector.ConsoleViewMessage.prototype = { |
// There can be string log and string eval result. We distinguish between them based on message type. |
var shouldFormatMessage = WebInspector.RemoteObject.type((/** @type {!Array.<!WebInspector.RemoteObject>} **/ (parameters))[0]) === "string" && (this._message.type !== WebInspector.ConsoleMessage.MessageType.Result || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Error || this._message.level === WebInspector.ConsoleMessage.MessageLevel.RevokedError); |
+ var showUndefinedsInArrays = this._message.type === WebInspector.ConsoleMessage.MessageType.DirXML || this._message.type === WebInspector.ConsoleMessage.MessageType.Result; |
// Multiple parameters with the first being a format string. Save unused substitutions. |
if (shouldFormatMessage) { |
- var result = this._formatWithSubstitutionString(/** @type {string} **/ (parameters[0].description), parameters.slice(1), formattedResult); |
+ var result = this._formatWithSubstitutionString(/** @type {string} **/ (parameters[0].description), parameters.slice(1), formattedResult, showUndefinedsInArrays); |
parameters = result.unusedSubstitutions; |
if (parameters.length) |
formattedResult.createTextChild(" "); |
@@ -439,7 +401,7 @@ WebInspector.ConsoleViewMessage.prototype = { |
if (shouldFormatMessage && parameters[i].type === "string") |
formattedResult.appendChild(WebInspector.linkifyStringAsFragment(parameters[i].description)); |
else |
- formattedResult.appendChild(this._formatParameter(parameters[i], false, true)); |
+ formattedResult.appendChild(this._formatParameter(parameters[i], false, true, showUndefinedsInArrays)); |
if (i < parameters.length - 1) |
formattedResult.createTextChild(" "); |
} |
@@ -450,9 +412,10 @@ WebInspector.ConsoleViewMessage.prototype = { |
* @param {!WebInspector.RemoteObject} output |
* @param {boolean=} forceObjectFormat |
* @param {boolean=} includePreview |
+ * @param {boolean=} showUndefinedsInArrays |
* @return {!Element} |
*/ |
- _formatParameter: function(output, forceObjectFormat, includePreview) |
+ _formatParameter: function(output, forceObjectFormat, includePreview, showUndefinedsInArrays) |
{ |
if (output.customPreview()) |
return (new WebInspector.CustomPreviewComponent(output)).element; |
@@ -462,7 +425,7 @@ WebInspector.ConsoleViewMessage.prototype = { |
switch (type) { |
case "array": |
case "typedarray": |
- element = this._formatParameterAsArray(output); |
+ element = this._formatParameterAsArray(output, showUndefinedsInArrays); |
break; |
case "error": |
element = this._formatParameterAsError(output); |
@@ -627,14 +590,14 @@ WebInspector.ConsoleViewMessage.prototype = { |
/** |
* @param {!WebInspector.RemoteObject} array |
+ * @param {boolean=} showUndefinedsInArrays |
* @return {!Element} |
*/ |
- _formatParameterAsArray: function(array) |
+ _formatParameterAsArray: function(array, showUndefinedsInArrays) |
{ |
- var usePrintedArrayFormat = this._message.type !== WebInspector.ConsoleMessage.MessageType.DirXML && this._message.type !== WebInspector.ConsoleMessage.MessageType.Result; |
var isLongArray = array.arrayLength() > 100; |
- if (usePrintedArrayFormat || isLongArray) |
- return this._formatParameterAsObject(array, usePrintedArrayFormat || !isLongArray); |
+ if (!showUndefinedsInArrays || isLongArray) |
+ return this._formatParameterAsObject(array, !showUndefinedsInArrays || !isLongArray); |
var result = createElement("span"); |
array.getAllProperties(false, printArrayResult.bind(this)); |
return result; |
@@ -787,8 +750,9 @@ WebInspector.ConsoleViewMessage.prototype = { |
* @param {string} format |
* @param {!Array.<!WebInspector.RemoteObject>} parameters |
* @param {!Element} formattedResult |
+ * @param {boolean} showUndefinedsInArrays |
*/ |
- _formatWithSubstitutionString: function(format, parameters, formattedResult) |
+ _formatWithSubstitutionString: function(format, parameters, formattedResult, showUndefinedsInArrays) |
{ |
var formatters = {}; |
@@ -800,7 +764,7 @@ WebInspector.ConsoleViewMessage.prototype = { |
*/ |
function parameterFormatter(force, obj) |
{ |
- return this._formatParameter(obj, force, false); |
+ return this._formatParameter(obj, force, false, showUndefinedsInArrays); |
} |
function stringFormatter(obj) |
@@ -981,9 +945,9 @@ WebInspector.ConsoleViewMessage.prototype = { |
if (target && shouldIncludeTrace) |
formattedMessage = this._buildMessageWithStackTrace(consoleMessage, target, this._linkifier); |
else if (this._message.type === WebInspector.ConsoleMessage.MessageType.Table) |
- formattedMessage = this._buildTableMessage(this._message); |
+ formattedMessage = this._buildTableMessage(); |
else |
- formattedMessage = this._buildMessage(consoleMessage); |
+ formattedMessage = this._buildMessage(); |
contentElement.appendChild(formattedMessage); |
this.updateTimestamp(WebInspector.moduleSetting("consoleTimestampsEnabled").get()); |