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

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, 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 currElement = this._providerElement(i).element();
428 var lineContent = Components.Linkifier.originalLinkText(currElement.childT extNodes());
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 }
459 var chars = 0;
460 var node = itemElement; 462 var node = itemElement;
463 var nodes = [];
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 nodes.push(node);
463 return chars + offset; 466 var charsBeforeContainer = Components.Linkifier.originalLinkText(nodes).leng th;
467 var offsetInContainer = Components.Linkifier.selectionOffsetToOriginalOffset (offset, container);
468 return charsBeforeContainer + offsetInContainer;
464 } 469 }
465 470
466 /** 471 /**
467 * @param {!Event} event 472 * @param {!Event} event
468 */ 473 */
469 _onScroll(event) { 474 _onScroll(event) {
470 this.refresh(); 475 this.refresh();
471 } 476 }
472 477
473 /** 478 /**
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 Console.ConsoleViewportElement.prototype = { 603 Console.ConsoleViewportElement.prototype = {
599 willHide() {}, 604 willHide() {},
600 605
601 wasShown() {}, 606 wasShown() {},
602 607
603 /** 608 /**
604 * @return {!Element} 609 * @return {!Element}
605 */ 610 */
606 element() {}, 611 element() {},
607 }; 612 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698