Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 | 440 |
| 441 return textLines.join('\n'); | 441 return textLines.join('\n'); |
| 442 } | 442 } |
| 443 | 443 |
| 444 /** | 444 /** |
| 445 * @param {!Element} itemElement | 445 * @param {!Element} itemElement |
| 446 * @param {!Node} container | 446 * @param {!Node} container |
| 447 * @param {number} offset | 447 * @param {number} offset |
| 448 * @return {number} | 448 * @return {number} |
| 449 */ | 449 */ |
| 450 _textOffsetInNode(itemElement, container, offset) { | 450 _textOffsetInNode(itemElement, container, offset) { |
|
einbinder
2017/05/03 01:07:48
These names are confusing because the itemElement
luoe
2017/05/03 02:58:39
Done.
| |
| 451 // If the container is not a TextNode, we may need to convert a child offset into a character offset. | |
| 451 if (container.nodeType !== Node.TEXT_NODE) { | 452 if (container.nodeType !== Node.TEXT_NODE) { |
| 452 if (offset < container.childNodes.length) { | 453 if (offset < container.childNodes.length) { |
| 453 container = /** @type {!Node} */ (container.childNodes.item(offset)); | 454 container = /** @type {!Node} */ (container.childNodes.item(offset)); |
| 454 offset = 0; | 455 offset = 0; |
| 455 } else { | 456 } else { |
| 456 offset = container.textContent.length; | 457 offset = container.textContent.length; |
| 457 } | 458 } |
| 458 } | 459 } |
| 460 // This method traverses TextNodes until the container is reached. This fail s if the container is before the first | |
| 461 // TextNode. We can move the container to the next TextNode to avoid this ca se, which may happen if a text selection | |
| 462 // ends on an expand triangle icon. | |
| 463 if (container.textContent.length === 0 && container.nodeType !== Node.TEXT_N ODE) { | |
|
einbinder
2017/05/03 01:07:48
!container.textContent.length? I don't like the id
luoe
2017/05/03 02:58:39
Done.
| |
| 464 var nextTextNode = container.traverseNextTextNode(itemElement); | |
| 465 if (nextTextNode) | |
| 466 container = nextTextNode; | |
|
einbinder
2017/05/03 01:07:48
This works, but it feels uncomfortable to not have
luoe
2017/05/03 02:58:39
I can see that it seems strange at first on first
einbinder
2017/05/03 05:15:23
I guess its fine the way it was.
| |
| 467 } | |
| 459 | 468 |
| 460 var chars = 0; | 469 var chars = 0; |
| 461 var node = itemElement; | 470 var node = itemElement; |
| 462 while ((node = node.traverseNextTextNode(itemElement)) && !node.isSelfOrDesc endant(container)) | 471 while ((node = node.traverseNextTextNode(itemElement)) && !node.isSelfOrDesc endant(container)) |
| 463 chars += Components.Linkifier.untruncatedNodeText(node).length; | 472 chars += Components.Linkifier.untruncatedNodeText(node).length; |
| 464 // If the selection offset is at the end of a link's ellipsis, use the untru ncated length as offset. | 473 // If the selection offset is at the end of a link's ellipsis, use the untru ncated length as offset. |
| 465 var untruncatedContainerLength = Components.Linkifier.untruncatedNodeText(co ntainer).length; | 474 var untruncatedContainerLength = Components.Linkifier.untruncatedNodeText(co ntainer).length; |
| 466 if (offset === 1 && untruncatedContainerLength > offset) | 475 if (offset === 1 && untruncatedContainerLength > offset) |
| 467 offset = untruncatedContainerLength; | 476 offset = untruncatedContainerLength; |
| 468 return chars + offset; | 477 return chars + offset; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 Console.ConsoleViewportElement.prototype = { | 610 Console.ConsoleViewportElement.prototype = { |
| 602 willHide() {}, | 611 willHide() {}, |
| 603 | 612 |
| 604 wasShown() {}, | 613 wasShown() {}, |
| 605 | 614 |
| 606 /** | 615 /** |
| 607 * @return {!Element} | 616 * @return {!Element} |
| 608 */ | 617 */ |
| 609 element() {}, | 618 element() {}, |
| 610 }; | 619 }; |
| OLD | NEW |