Chromium Code Reviews| 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 73aedc4e179d8c807b396adce17e0a2844e34dd4..5b274653684e65029e666d3827ea4efd78514402 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
| @@ -771,9 +771,9 @@ Console.ConsoleViewMessage = class { |
| /** |
| * @param {string} format |
| * @param {!Array.<!SDK.RemoteObject>} parameters |
| - * @param {!Element} formattedResult |
| + * @param {!Node} output |
| */ |
| - _formatWithSubstitutionString(format, parameters, formattedResult) { |
| + _formatWithSubstitutionString(format, parameters, output) { |
| var formatters = {}; |
| /** |
| @@ -846,11 +846,23 @@ Console.ConsoleViewMessage = class { |
| formatters._ = bypassFormatter; |
| + // replace style formatter with empty formatter to get plain string |
| + var plainFormatters = Object.assign({}, formatters, {'c': a => ''}); |
| + var plainString = String.format(format, parameters, plainFormatters, '', (a, b) => a + b); |
|
pfeldman
2016/12/12 22:05:45
Some of these formatters format objects, so you ar
karabur
2016/12/14 17:32:50
I would like to have output linkified only if it l
|
| + |
| + var linkNode = Components.Linkifier.getLinkNode(plainString.formattedResult); |
|
pfeldman
2016/12/12 22:05:45
What if we
format("%s%s %s%s", "http", "://www.fb
karabur
2016/12/14 17:32:50
This is a good point, I didn't take into account s
|
| + if (linkNode) { |
| + linkNode.innerHTML = ''; |
|
pfeldman
2016/12/12 22:05:45
Use .textContent = instead, we never use innerHTML
karabur
2016/12/14 17:32:50
Ok.
I'm using that node as accumulator for formatt
|
| + output.appendChild(linkNode); |
| + } |
| + var linkifyInner = !linkNode; |
| + |
| function append(a, b) { |
| if (b instanceof Node) { |
| a.appendChild(b); |
| } else if (typeof b !== 'undefined') { |
| - var toAppend = Components.linkifyStringAsFragment(String(b)); |
| + var toAppend = |
| + linkifyInner ? Components.linkifyStringAsFragment(String(b)) : createTextNode(String(b).trimMiddle(150)); |
|
pfeldman
2016/12/12 22:05:45
That sounds like a strange heuristic.
What you sh
karabur
2016/12/14 17:32:50
not sure I understand.
in line 876 I will get sam
|
| if (currentStyle) { |
| var wrapper = createElement('span'); |
| wrapper.appendChild(toAppend); |
| @@ -872,8 +884,10 @@ Console.ConsoleViewMessage = class { |
| element.style[key] = currentStyle[key]; |
| } |
| + var formattedResult = linkNode || output; |
| // String.format does treat formattedResult like a Builder, result is an object. |
| - return String.format(format, parameters, formatters, formattedResult, append); |
| + var result = String.format(format, parameters, formatters, formattedResult, append); |
| + return result; |
| } |
| /** |