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

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

Issue 2644753002: DevTools: untruncate links on copy (Closed)
Patch Set: reset tests with zero width space 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) 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.origin alNodeText).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 14 matching lines...) Expand all
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 }
459 var chars = 0; 462 var chars = 0;
460 var node = itemElement; 463 var node = itemElement;
461 while ((node = node.traverseNextTextNode(itemElement)) && !node.isSelfOrDesc endant(container)) 464 while ((node = node.traverseNextTextNode(itemElement)) && !node.isSelfOrDesc endant(container))
462 chars += node.textContent.length; 465 chars += Components.Linkifier.originalNodeText(node).length;
463 return chars + offset; 466 return chars + Components.Linkifier.selectionOffsetToOriginalTextOffset(cont ainer, offset);
464 } 467 }
465 468
466 /** 469 /**
467 * @param {!Event} event 470 * @param {!Event} event
468 */ 471 */
469 _onScroll(event) { 472 _onScroll(event) {
470 this.refresh(); 473 this.refresh();
471 } 474 }
472 475
473 /** 476 /**
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 Console.ConsoleViewportElement.prototype = { 601 Console.ConsoleViewportElement.prototype = {
599 willHide() {}, 602 willHide() {},
600 603
601 wasShown() {}, 604 wasShown() {},
602 605
603 /** 606 /**
604 * @return {!Element} 607 * @return {!Element}
605 */ 608 */
606 element() {}, 609 element() {},
607 }; 610 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698