Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 722 downstream++; | 722 downstream++; |
| 723 | 723 |
| 724 int length = downstream - upstream; | 724 int length = downstream - upstream; |
| 725 if (!length) | 725 if (!length) |
| 726 return; | 726 return; |
| 727 | 727 |
| 728 VisiblePosition visibleUpstreamPos = createVisiblePosition(Position(textNode , upstream)); | 728 VisiblePosition visibleUpstreamPos = createVisiblePosition(Position(textNode , upstream)); |
| 729 VisiblePosition visibleDownstreamPos = createVisiblePosition(Position(textNo de, downstream)); | 729 VisiblePosition visibleDownstreamPos = createVisiblePosition(Position(textNo de, downstream)); |
| 730 | 730 |
| 731 String string = text.substring(upstream, length); | 731 String string = text.substring(upstream, length); |
| 732 String rebalancedString = stringWithRebalancedWhitespace(string, | |
| 733 // FIXME: Because of the problem mentioned at the top of this function, we | 732 // FIXME: Because of the problem mentioned at the top of this function, we |
| 734 // must also use nbsps at the start/end of the string because this function | 733 // must also use nbsps at the start/end of the string because this function |
| 735 // doesn't get all surrounding whitespace, just the whitespace in the | 734 // doesn't get all surrounding whitespace, just the whitespace in the |
| 736 // current text node. | 735 // current text node. However, if the next sibling node is a text node |
| 737 isStartOfParagraph(visibleUpstreamPos) || upstream == 0, | 736 // (not empty, see http://crbug.com/632300), we should use a plain space. |
| 738 (isEndOfParagraph(visibleDownstreamPos) || (unsigned)downstream == text. length()) | 737 // See http://crbug.com/310149 |
| 739 && !(textNode->nextSibling() && textNode->nextSibling()->isTextNode() && toText(textNode->nextSibling())->data().length() != 0)); | 738 bool nextSiblingIsTextNode = textNode->nextSibling() && textNode->nextSiblin g()->isTextNode() |
|
joone
2016/07/29 19:38:25
I also added nextSiblingIsTextNode.
| |
| 739 && toText(textNode->nextSibling())->data().length() != 0; | |
| 740 bool shouldEmitNBSPbeforeEnd =(isEndOfParagraph(visibleDownstreamPos) || (un signed)downstream == text.length()) && !nextSiblingIsTextNode; | |
| 741 String rebalancedString = stringWithRebalancedWhitespace(string, | |
| 742 isStartOfParagraph(visibleUpstreamPos) || upstream == 0, shouldEmitNBSPb eforeEnd); | |
| 740 | 743 |
| 741 if (string != rebalancedString) | 744 if (string != rebalancedString) |
| 742 replaceTextInNodePreservingMarkers(textNode, upstream, length, rebalance dString); | 745 replaceTextInNodePreservingMarkers(textNode, upstream, length, rebalance dString); |
| 743 } | 746 } |
| 744 | 747 |
| 745 void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio n) | 748 void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio n) |
| 746 { | 749 { |
| 747 if (!isRichlyEditablePosition(position)) | 750 if (!isRichlyEditablePosition(position)) |
| 748 return; | 751 return; |
| 749 Node* node = position.anchorNode(); | 752 Node* node = position.anchorNode(); |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1644 } | 1647 } |
| 1645 | 1648 |
| 1646 DEFINE_TRACE(CompositeEditCommand) | 1649 DEFINE_TRACE(CompositeEditCommand) |
| 1647 { | 1650 { |
| 1648 visitor->trace(m_commands); | 1651 visitor->trace(m_commands); |
| 1649 visitor->trace(m_composition); | 1652 visitor->trace(m_composition); |
| 1650 EditCommand::trace(visitor); | 1653 EditCommand::trace(visitor); |
| 1651 } | 1654 } |
| 1652 | 1655 |
| 1653 } // namespace blink | 1656 } // namespace blink |
| OLD | NEW |