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..d65b292af55222885915a517a83c2f3eab0067c5 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewport.js |
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewport.js |
@@ -423,8 +423,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 element = this._providerElement(i).element(); |
+ var lineContent = element.childTextNodes().map(Components.Linkifier.untruncatedNodeText).join(''); |
+ textLines.push(lineContent); |
+ } |
var endSelectionElement = this._providerElement(endSelection.item).element(); |
if (endSelection.node && endSelection.node.isSelfOrDescendant(endSelectionElement)) { |
@@ -449,17 +452,29 @@ Console.ConsoleViewport = class { |
*/ |
_textOffsetInNode(itemElement, container, offset) { |
if (container.nodeType !== Node.TEXT_NODE) { |
+ // If the container is not a TextNode, we may need to convert a child offset into a character offset. |
if (offset < container.childNodes.length) { |
container = /** @type {!Node} */ (container.childNodes.item(offset)); |
offset = 0; |
} else { |
offset = container.textContent.length; |
} |
+ // Ensure that the container does not come before the first text node. |
+ if (container.textContent.length === 0 && container.nodeType !== Node.TEXT_NODE) { |
lushnikov
2017/05/01 22:52:26
this is unrelated to the patch - let's have this s
luoe
2017/05/01 23:03:49
Sounds good, I've made a separate bug with the rep
|
+ var nextTextNode = container.traverseNextTextNode(itemElement); |
+ if (nextTextNode) |
+ container = nextTextNode; |
+ } |
} |
+ |
var chars = 0; |
var node = itemElement; |
while ((node = node.traverseNextTextNode(itemElement)) && !node.isSelfOrDescendant(container)) |
- chars += node.textContent.length; |
+ chars += Components.Linkifier.untruncatedNodeText(node).length; |
+ // If the selection offset is at the end of a link's ellipsis, use the untruncated length as offset. |
+ var untruncatedContainerLength = Components.Linkifier.untruncatedNodeText(container).length; |
+ if (offset === 1 && untruncatedContainerLength > offset) |
+ offset = untruncatedContainerLength; |
return chars + offset; |
} |