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

Unified Diff: third_party/WebKit/Source/devtools/front_end/components/Linkifier.js

Issue 2644753002: DevTools: untruncate links on copy (Closed)
Patch Set: ac Created 3 years, 8 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
Index: third_party/WebKit/Source/devtools/front_end/components/Linkifier.js
diff --git a/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js b/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js
index 6184cc95d5d4eb1254e5cddb10c6985f96a1c68c..b79e1db3a896ad0bdf2fad826a9cf0c7adbff69f 100644
--- a/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js
+++ b/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js
@@ -303,10 +303,9 @@ Components.Linkifier = class {
return;
Components.Linkifier._bindUILocation(anchor, uiLocation);
- var text = uiLocation.linkText();
var info = Components.Linkifier._linkInfo(anchor);
- info.originalLinkText = text;
- text = text.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, '$1\u2026');
+ info.originalLinkText = uiLocation.linkText(true /* skipTrim */);
+ var text = info.originalLinkText.replace(/([a-f0-9]{7})[a-f0-9]{13,}/g, '$1\u2026');
if (this._maxLength)
text = text.trimMiddle(this._maxLength);
anchor.textContent = text;
@@ -419,12 +418,34 @@ Components.Linkifier = class {
}
/**
- * @param {?Element} link
- * @return {?string}
+ * @param {!Array<!Node>} nodes
+ * @return {string}
+ */
+ static originalLinkText(nodes) {
lushnikov 2017/04/11 22:59:34 let's pass a link here
luoe 2017/04/12 22:00:37 Done.
+ var text = '';
+ for (var i = 0; i < nodes.length; i++) {
+ var info = this._linkInfo(nodes[i].parentElement);
+ text += info ? info.originalLinkText : nodes[i].textContent;
+ }
+ return text;
+ }
+
+ /**
+ * @param {number} offset
+ * @param {!Node} node
+ * @return {number}
*/
- static originalLinkText(link) {
+ static selectionOffsetToOriginalOffset(offset, node) {
lushnikov 2017/04/11 22:59:34 selectionOffsetToOriginalTextOffset ?
lushnikov 2017/04/11 22:59:34 let's pass link here
luoe 2017/04/12 22:00:37 Done.
luoe 2017/04/12 22:00:37 Done.
+ var link = node.parentElement;
var info = this._linkInfo(link);
- return info ? info.originalLinkText : null;
+ var originalLinkText = info ? info.originalLinkText : null;
+ if (originalLinkText === null)
+ return offset;
+
+ var truncatedLength = originalLinkText.length - link.textContent.length;
+ if (offset > link.textContent.length >> 1)
lushnikov 2017/04/11 22:59:34 /2
luoe 2017/04/12 22:00:37 Done.
+ offset += truncatedLength;
+ return offset;
}
/**

Powered by Google App Engine
This is Rietveld 408576698