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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewport.js

Issue 2644753002: DevTools: untruncate links on copy (Closed)
Patch Set: ac Created 3 years, 7 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 var endSelection = null; 416 var endSelection = null;
417 if (this._selectionIsBackward) { 417 if (this._selectionIsBackward) {
418 startSelection = this._headSelection; 418 startSelection = this._headSelection;
419 endSelection = this._anchorSelection; 419 endSelection = this._anchorSelection;
420 } else { 420 } else {
421 startSelection = this._anchorSelection; 421 startSelection = this._anchorSelection;
422 endSelection = this._headSelection; 422 endSelection = this._headSelection;
423 } 423 }
424 424
425 var textLines = []; 425 var textLines = [];
426 for (var i = startSelection.item; i <= endSelection.item; ++i) 426 for (var i = startSelection.item; i <= endSelection.item; ++i) {
427 textLines.push(this._providerElement(i).element().deepTextContent()); 427 var element = this._providerElement(i).element();
428 var lineContent = element.childTextNodes().map(Components.Linkifier.untrun catedNodeText).join('');
429 textLines.push(lineContent);
430 }
428 431
429 var endSelectionElement = this._providerElement(endSelection.item).element() ; 432 var endSelectionElement = this._providerElement(endSelection.item).element() ;
430 if (endSelection.node && endSelection.node.isSelfOrDescendant(endSelectionEl ement)) { 433 if (endSelection.node && endSelection.node.isSelfOrDescendant(endSelectionEl ement)) {
431 var itemTextOffset = this._textOffsetInNode(endSelectionElement, endSelect ion.node, endSelection.offset); 434 var itemTextOffset = this._textOffsetInNode(endSelectionElement, endSelect ion.node, endSelection.offset);
432 textLines[textLines.length - 1] = textLines.peekLast().substring(0, itemTe xtOffset); 435 textLines[textLines.length - 1] = textLines.peekLast().substring(0, itemTe xtOffset);
433 } 436 }
434 437
435 var startSelectionElement = this._providerElement(startSelection.item).eleme nt(); 438 var startSelectionElement = this._providerElement(startSelection.item).eleme nt();
436 if (startSelection.node && startSelection.node.isSelfOrDescendant(startSelec tionElement)) { 439 if (startSelection.node && startSelection.node.isSelfOrDescendant(startSelec tionElement)) {
437 var itemTextOffset = this._textOffsetInNode(startSelectionElement, startSe lection.node, startSelection.offset); 440 var itemTextOffset = this._textOffsetInNode(startSelectionElement, startSe lection.node, startSelection.offset);
(...skipping 11 matching lines...) Expand all
449 */ 452 */
450 _textOffsetInNode(itemElement, container, offset) { 453 _textOffsetInNode(itemElement, container, offset) {
451 if (container.nodeType !== Node.TEXT_NODE) { 454 if (container.nodeType !== Node.TEXT_NODE) {
452 if (offset < container.childNodes.length) { 455 if (offset < container.childNodes.length) {
453 container = /** @type {!Node} */ (container.childNodes.item(offset)); 456 container = /** @type {!Node} */ (container.childNodes.item(offset));
454 offset = 0; 457 offset = 0;
455 } else { 458 } else {
456 offset = container.textContent.length; 459 offset = container.textContent.length;
457 } 460 }
458 } 461 }
462
459 var chars = 0; 463 var chars = 0;
460 var node = itemElement; 464 var node = itemElement;
461 while ((node = node.traverseNextTextNode(itemElement)) && !node.isSelfOrDesc endant(container)) 465 while ((node = node.traverseNextTextNode(itemElement)) && !node.isSelfOrDesc endant(container))
462 chars += node.textContent.length; 466 chars += Components.Linkifier.untruncatedNodeText(node).length;
467 // If the selection offset is at the end of a link's ellipsis, use the untru ncated length as offset.
468 var untruncatedContainerLength = Components.Linkifier.untruncatedNodeText(co ntainer).length;
469 if (offset === 1 && untruncatedContainerLength > offset)
470 offset = untruncatedContainerLength;
463 return chars + offset; 471 return chars + offset;
464 } 472 }
465 473
466 /** 474 /**
467 * @param {!Event} event 475 * @param {!Event} event
468 */ 476 */
469 _onScroll(event) { 477 _onScroll(event) {
470 this.refresh(); 478 this.refresh();
471 } 479 }
472 480
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 Console.ConsoleViewportElement.prototype = { 606 Console.ConsoleViewportElement.prototype = {
599 willHide() {}, 607 willHide() {},
600 608
601 wasShown() {}, 609 wasShown() {},
602 610
603 /** 611 /**
604 * @return {!Element} 612 * @return {!Element}
605 */ 613 */
606 element() {}, 614 element() {},
607 }; 615 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698