Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Unified Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js

Issue 2449973005: DevTools: ConsoleViewMessage pass linkifier into formatting functions (Closed)
Patch Set: linkifier Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a1860bbe4536d001a2161e2ffcbfb46152b3b468..fc30e6b6aebd2e0c5d53716172ccf0f0dd4fb5da 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
@@ -184,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));
+ tableElement.appendChild(this._formatParameter(table, this._linkifier, true));
dataGridContainer.appendChild(this._dataGrid.element);
formattedMessage.appendChild(formattedResult);
this._dataGrid.renderInline();
@@ -225,7 +225,7 @@ WebInspector.ConsoleViewMessage.prototype = {
break;
default:
if (consoleMessage.parameters && consoleMessage.parameters.length === 1 && consoleMessage.parameters[0].type === "string")
- messageElement = this._tryFormatAsError(/** @type {string} */(consoleMessage.parameters[0].value));
+ messageElement = this._tryFormatAsError(/** @type {string} */(consoleMessage.parameters[0].value), this._linkifier);
var args = consoleMessage.parameters || [consoleMessage.messageText];
messageElement = messageElement || this._format(args);
}
@@ -401,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, showUndefinedsInArrays));
+ formattedResult.appendChild(this._formatParameter(parameters[i], this._linkifier, false, true, showUndefinedsInArrays));
if (i < parameters.length - 1)
formattedResult.createTextChild(" ");
}
@@ -410,12 +410,13 @@ WebInspector.ConsoleViewMessage.prototype = {
/**
* @param {!WebInspector.RemoteObject} output
+ * @param {!WebInspector.Linkifier} linkifier
* @param {boolean=} forceObjectFormat
* @param {boolean=} includePreview
* @param {boolean=} showUndefinedsInArrays
* @return {!Element}
*/
- _formatParameter: function(output, forceObjectFormat, includePreview, showUndefinedsInArrays)
+ _formatParameter: function(output, linkifier, forceObjectFormat, includePreview, showUndefinedsInArrays)
{
if (output.customPreview())
return (new WebInspector.CustomPreviewComponent(output)).element;
@@ -425,10 +426,10 @@ WebInspector.ConsoleViewMessage.prototype = {
switch (type) {
case "array":
case "typedarray":
- element = this._formatParameterAsArray(output, showUndefinedsInArrays);
+ element = this._formatParameterAsArray(output, linkifier, showUndefinedsInArrays);
break;
case "error":
- element = this._formatParameterAsError(output);
+ element = this._formatParameterAsError(output, linkifier);
break;
case "function":
case "generator":
@@ -440,10 +441,10 @@ WebInspector.ConsoleViewMessage.prototype = {
case "promise":
case "proxy":
case "set":
- element = this._formatParameterAsObject(output, includePreview);
+ element = this._formatParameterAsObject(output, linkifier, includePreview);
break;
case "node":
- element = this._formatParameterAsNode(output);
+ element = this._formatParameterAsNode(output, linkifier);
break;
case "string":
element = this._formatParameterAsString(output);
@@ -481,10 +482,11 @@ WebInspector.ConsoleViewMessage.prototype = {
/**
* @param {!WebInspector.RemoteObject} obj
+ * @param {!WebInspector.Linkifier} linkifier
* @param {boolean=} includePreview
* @return {!Element}
*/
- _formatParameterAsObject: function(obj, includePreview)
+ _formatParameterAsObject: function(obj, linkifier, includePreview)
{
var titleElement = createElement("span");
if (includePreview && obj.preview) {
@@ -497,7 +499,7 @@ WebInspector.ConsoleViewMessage.prototype = {
titleElement.createTextChild(obj.description || "");
}
- var section = new WebInspector.ObjectPropertiesSection(obj, titleElement, this._linkifier);
+ var section = new WebInspector.ObjectPropertiesSection(obj, titleElement, linkifier);
section.element.classList.add("console-view-object-properties-section");
section.enableContextMenu();
return section.element;
@@ -557,9 +559,10 @@ WebInspector.ConsoleViewMessage.prototype = {
/**
* @param {!WebInspector.RemoteObject} object
+ * @param {!WebInspector.Linkifier} linkifier
* @return {!Element}
*/
- _formatParameterAsNode: function(object)
+ _formatParameterAsNode: function(object, linkifier)
{
var result = createElement("span");
WebInspector.Renderer.renderPromise(object).then(appendRenderer.bind(this), failedToRender.bind(this));
@@ -580,7 +583,7 @@ WebInspector.ConsoleViewMessage.prototype = {
*/
function failedToRender()
{
- result.appendChild(this._formatParameterAsObject(object, false));
+ result.appendChild(this._formatParameterAsObject(object, linkifier, false));
}
},
@@ -590,14 +593,15 @@ WebInspector.ConsoleViewMessage.prototype = {
/**
* @param {!WebInspector.RemoteObject} array
+ * @param {!WebInspector.Linkifier} linkifier
* @param {boolean=} showUndefinedsInArrays
* @return {!Element}
*/
- _formatParameterAsArray: function(array, showUndefinedsInArrays)
+ _formatParameterAsArray: function(array, linkifier, showUndefinedsInArrays)
{
var isLongArray = array.arrayLength() > 100;
if (!showUndefinedsInArrays || isLongArray)
- return this._formatParameterAsObject(array, !showUndefinedsInArrays || !isLongArray);
+ return this._formatParameterAsObject(array, linkifier, !showUndefinedsInArrays || !isLongArray);
var result = createElement("span");
array.getAllProperties(false, printArrayResult.bind(this));
return result;
@@ -609,7 +613,7 @@ WebInspector.ConsoleViewMessage.prototype = {
function printArrayResult(properties)
{
if (!properties) {
- result.appendChild(this._formatParameterAsObject(array, false));
+ result.appendChild(this._formatParameterAsObject(array, linkifier, false));
return;
}
@@ -657,7 +661,7 @@ WebInspector.ConsoleViewMessage.prototype = {
titleElement.createTextChild("]");
- var section = new WebInspector.ObjectPropertiesSection(array, titleElement, this._linkifier);
+ var section = new WebInspector.ObjectPropertiesSection(array, titleElement, linkifier);
section.element.classList.add("console-view-object-properties-section");
section.enableContextMenu();
result.appendChild(section.element);
@@ -682,12 +686,13 @@ WebInspector.ConsoleViewMessage.prototype = {
/**
* @param {!WebInspector.RemoteObject} output
+ * @param {!WebInspector.Linkifier} linkifier
* @return {!Element}
*/
- _formatParameterAsError: function(output)
+ _formatParameterAsError: function(output, linkifier)
{
var result = createElement("span");
- var errorSpan = this._tryFormatAsError(output.description || "");
+ var errorSpan = this._tryFormatAsError(output.description || "", linkifier);
result.appendChild(errorSpan ? errorSpan : WebInspector.linkifyStringAsFragment(output.description || ""));
return result;
},
@@ -764,7 +769,7 @@ WebInspector.ConsoleViewMessage.prototype = {
*/
function parameterFormatter(force, obj)
{
- return this._formatParameter(obj, force, false, showUndefinedsInArrays);
+ return this._formatParameter(obj, this._linkifier, force, false, showUndefinedsInArrays);
}
function stringFormatter(obj)
@@ -1112,9 +1117,10 @@ WebInspector.ConsoleViewMessage.prototype = {
/**
* @param {string} string
+ * @param {!WebInspector.Linkifier} linkifier
* @return {?Element}
*/
- _tryFormatAsError: function(string)
+ _tryFormatAsError: function(string, linkifier)
{
/**
* @param {string} prefix
@@ -1180,7 +1186,7 @@ WebInspector.ConsoleViewMessage.prototype = {
var start = 0;
for (var i = 0; i < links.length; ++i) {
formattedResult.appendChild(WebInspector.linkifyStringAsFragment(string.substring(start, links[i].positionLeft)));
- formattedResult.appendChild(this._linkifier.linkifyScriptLocation(target, null, links[i].url, links[i].lineNumber, links[i].columnNumber));
+ formattedResult.appendChild(linkifier.linkifyScriptLocation(target, null, links[i].url, links[i].lineNumber, links[i].columnNumber));
start = links[i].positionRight;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698