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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 * @param {!Element} anchor 296 * @param {!Element} anchor
297 * @param {!Bindings.LiveLocation} liveLocation 297 * @param {!Bindings.LiveLocation} liveLocation
298 */ 298 */
299 _updateAnchor(anchor, liveLocation) { 299 _updateAnchor(anchor, liveLocation) {
300 Components.Linkifier._unbindUILocation(anchor); 300 Components.Linkifier._unbindUILocation(anchor);
301 var uiLocation = liveLocation.uiLocation(); 301 var uiLocation = liveLocation.uiLocation();
302 if (!uiLocation) 302 if (!uiLocation)
303 return; 303 return;
304 304
305 Components.Linkifier._bindUILocation(anchor, uiLocation); 305 Components.Linkifier._bindUILocation(anchor, uiLocation);
306 var text = uiLocation.linkText(); 306 var originalLinkText = uiLocation.linkText(true /* skipTrim */);
307 var info = Components.Linkifier._linkInfo(anchor); 307 var text = originalLinkText.replace(/([a-f0-9]{7})[a-f0-9]{13,}/g, '$1\u2026 ');
308 info.originalLinkText = text;
309 text = text.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, '$1\u2026');
310 if (this._maxLength) 308 if (this._maxLength)
311 text = text.trimMiddle(this._maxLength); 309 text = text.trimMiddle(this._maxLength);
312 anchor.textContent = text; 310 anchor.removeChildren();
311 anchor.appendChild(Components.DOMPresentationUtils.createTruncatedTextNode(t ext, originalLinkText));
313 312
314 var titleText = uiLocation.uiSourceCode.url(); 313 var titleText = uiLocation.uiSourceCode.url();
315 if (typeof uiLocation.lineNumber === 'number') 314 if (typeof uiLocation.lineNumber === 'number')
316 titleText += ':' + (uiLocation.lineNumber + 1); 315 titleText += ':' + (uiLocation.lineNumber + 1);
317 anchor.title = titleText; 316 anchor.title = titleText;
318 anchor.classList.toggle('webkit-html-blackbox-link', liveLocation.isBlackbox ed()); 317 anchor.classList.toggle('webkit-html-blackbox-link', liveLocation.isBlackbox ed());
319 Components.Linkifier._updateLinkDecorations(anchor); 318 Components.Linkifier._updateLinkDecorations(anchor);
320 } 319 }
321 320
322 /** 321 /**
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 * @param {boolean=} preventClick 388 * @param {boolean=} preventClick
390 * @returns{!Element} 389 * @returns{!Element}
391 */ 390 */
392 static _createLink(text, className, maxLength, title, href, preventClick) { 391 static _createLink(text, className, maxLength, title, href, preventClick) {
393 var link = createElementWithClass('span', className); 392 var link = createElementWithClass('span', className);
394 link.classList.add('devtools-link'); 393 link.classList.add('devtools-link');
395 if (title) 394 if (title)
396 link.title = title; 395 link.title = title;
397 if (href) 396 if (href)
398 link.href = href; 397 link.href = href;
399 link.textContent = text;
400 if (maxLength) 398 if (maxLength)
401 link.textContent = link.textContent.trimMiddle(maxLength); 399 link.appendChild(Components.DOMPresentationUtils.createTruncatedTextNode(t ext.trimMiddle(maxLength), text));
400 else
401 link.textContent = text;
402 link[Components.Linkifier._infoSymbol] = { 402 link[Components.Linkifier._infoSymbol] = {
403 icon: null, 403 icon: null,
404 enableDecorator: false, 404 enableDecorator: false,
405 uiLocation: null, 405 uiLocation: null,
406 liveLocation: null, 406 liveLocation: null,
407 url: href || null, 407 url: href || null,
408 lineNumber: null, 408 lineNumber: null,
409 columnNumber: null, 409 columnNumber: null,
410 revealable: null, 410 revealable: null,
411 fallback: null, 411 fallback: null
412 originalLinkText: text
413 }; 412 };
414 if (!preventClick) 413 if (!preventClick)
415 link.addEventListener('click', Components.Linkifier._handleClick, false); 414 link.addEventListener('click', Components.Linkifier._handleClick, false);
416 else 415 else
417 link.classList.add('devtools-link-prevent-click'); 416 link.classList.add('devtools-link-prevent-click');
418 return link; 417 return link;
419 } 418 }
420 419
421 /** 420 /**
422 * @param {?Element} link 421 * @param {?Element} link
423 * @return {?string}
424 */
425 static originalLinkText(link) {
426 var info = this._linkInfo(link);
427 return info ? info.originalLinkText : null;
428 }
429
430 /**
431 * @param {?Element} link
432 * @return {?Components._LinkInfo} 422 * @return {?Components._LinkInfo}
433 */ 423 */
434 static _linkInfo(link) { 424 static _linkInfo(link) {
435 return /** @type {?Components._LinkInfo} */ (link ? link[Components.Linkifie r._infoSymbol] || null : null); 425 return /** @type {?Components._LinkInfo} */ (link ? link[Components.Linkifie r._infoSymbol] || null : null);
436 } 426 }
437 427
438 /** 428 /**
439 * @param {!Event} event 429 * @param {!Event} event
440 */ 430 */
441 static _handleClick(event) { 431 static _handleClick(event) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 /** 543 /**
554 * @typedef {{ 544 * @typedef {{
555 * icon: ?UI.Icon, 545 * icon: ?UI.Icon,
556 * enableDecorator: boolean, 546 * enableDecorator: boolean,
557 * uiLocation: ?Workspace.UILocation, 547 * uiLocation: ?Workspace.UILocation,
558 * liveLocation: ?Bindings.LiveLocation, 548 * liveLocation: ?Bindings.LiveLocation,
559 * url: ?string, 549 * url: ?string,
560 * lineNumber: ?number, 550 * lineNumber: ?number,
561 * columnNumber: ?number, 551 * columnNumber: ?number,
562 * revealable: ?Object, 552 * revealable: ?Object,
563 * fallback: ?Element, 553 * fallback: ?Element
564 * originalLinkText: string
565 * }} 554 * }}
566 */ 555 */
567 Components._LinkInfo; 556 Components._LinkInfo;
568 557
569 /** 558 /**
570 * The maximum length before strings are considered too long for finding URLs. 559 * The maximum length before strings are considered too long for finding URLs.
571 * @const 560 * @const
572 * @type {number} 561 * @type {number}
573 */ 562 */
574 Components.Linkifier.MaxLengthToIgnoreLinkifier = 10000; 563 Components.Linkifier.MaxLengthToIgnoreLinkifier = 10000;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 contextMenu.appendSeparator(); 769 contextMenu.appendSeparator();
781 contextMenu.appendItem(Common.UIString('Save'), save.bind(null, false)); 770 contextMenu.appendItem(Common.UIString('Save'), save.bind(null, false));
782 771
783 if (contentProvider instanceof Workspace.UISourceCode) { 772 if (contentProvider instanceof Workspace.UISourceCode) {
784 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvider ); 773 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvider );
785 if (!uiSourceCode.project().canSetFileContent()) 774 if (!uiSourceCode.project().canSetFileContent())
786 contextMenu.appendItem(Common.UIString.capitalize('Save ^as...'), save.b ind(null, true)); 775 contextMenu.appendItem(Common.UIString.capitalize('Save ^as...'), save.b ind(null, true));
787 } 776 }
788 } 777 }
789 }; 778 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698