Index: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewport.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewport.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewport.js |
index 89ae0cb8d8aa72efdc67e9af54f02d97030c76eb..09314005f5030d3ca548bc17f724acd89f831a30 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewport.js |
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewport.js |
@@ -71,6 +71,15 @@ Console.ConsoleViewport = class { |
} |
/** |
+ * @param {!Node} node |
+ * @return {string} |
+ */ |
+ static contentTransform(node) { |
+ var originalLinkText = Components.Linkifier.originalLinkText(node.parentElement); |
+ return typeof originalLinkText === 'string' ? originalLinkText : node.textContent; |
allada
2017/03/28 01:13:08
nit: return originalLinkText === null ? node.textC
luoe
2017/03/31 21:35:21
Done.
Empty strings is a good case to consider, b
allada
2017/03/31 23:17:33
Acknowledged.
|
+ } |
+ |
+ /** |
* @return {boolean} |
*/ |
stickToBottom() { |
@@ -423,8 +432,11 @@ Console.ConsoleViewport = class { |
} |
var textLines = []; |
- for (var i = startSelection.item; i <= endSelection.item; ++i) |
- textLines.push(this._providerElement(i).element().deepTextContent()); |
+ for (var i = startSelection.item; i <= endSelection.item; ++i) { |
+ var currElement = this._providerElement(i).element(); |
+ var lineContent = currElement.childTextNodes().map(Console.ConsoleViewport.contentTransform).join(''); |
+ textLines.push(lineContent); |
+ } |
var endSelectionElement = this._providerElement(endSelection.item).element(); |
if (endSelection.node && endSelection.node.isSelfOrDescendant(endSelectionElement)) { |
@@ -456,10 +468,17 @@ Console.ConsoleViewport = class { |
offset = container.textContent.length; |
} |
} |
+ // To calculate the correct offset, this assumes that links truncate from the middle. |
+ var originalLinkText = Components.Linkifier.originalLinkText(container.parentElement); |
+ if (typeof originalLinkText === 'string') { |
+ var truncatedLength = originalLinkText.length - container.textContent.length; |
+ if (offset > container.textContent.length >> 1) |
+ offset += truncatedLength; |
+ } |
var chars = 0; |
var node = itemElement; |
while ((node = node.traverseNextTextNode(itemElement)) && !node.isSelfOrDescendant(container)) |
- chars += node.textContent.length; |
+ chars += Console.ConsoleViewport.contentTransform(node).length; |
return chars + offset; |
} |