Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp |
| index 1c898c525dc5c9c8d5a403062637151d0d85db74..97496ffbe4a355da40dd8755ea15c8f9e8c9fd7f 100644 |
| --- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp |
| +++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp |
| @@ -729,14 +729,17 @@ void CompositeEditCommand::rebalanceWhitespaceOnTextSubstring(Text* textNode, in |
| VisiblePosition visibleDownstreamPos = createVisiblePosition(Position(textNode, downstream)); |
| String string = text.substring(upstream, length); |
| - String rebalancedString = stringWithRebalancedWhitespace(string, |
| // FIXME: Because of the problem mentioned at the top of this function, we |
| // must also use nbsps at the start/end of the string because this function |
| // doesn't get all surrounding whitespace, just the whitespace in the |
| - // current text node. |
| - isStartOfParagraph(visibleUpstreamPos) || upstream == 0, |
| - (isEndOfParagraph(visibleDownstreamPos) || (unsigned)downstream == text.length()) |
| - && !(textNode->nextSibling() && textNode->nextSibling()->isTextNode() && toText(textNode->nextSibling())->data().length() != 0)); |
| + // current text node. However, if the next sibling node is a text node |
| + // (not empty, see http://crbug.com/632300), we should use a plain space. |
| + // See http://crbug.com/310149 |
| + bool nextSiblingIsTextNode = textNode->nextSibling() && textNode->nextSibling()->isTextNode() |
|
joone
2016/07/29 19:38:25
I also added nextSiblingIsTextNode.
|
| + && toText(textNode->nextSibling())->data().length() != 0; |
| + bool shouldEmitNBSPbeforeEnd =(isEndOfParagraph(visibleDownstreamPos) || (unsigned)downstream == text.length()) && !nextSiblingIsTextNode; |
| + String rebalancedString = stringWithRebalancedWhitespace(string, |
| + isStartOfParagraph(visibleUpstreamPos) || upstream == 0, shouldEmitNBSPbeforeEnd); |
| if (string != rebalancedString) |
| replaceTextInNodePreservingMarkers(textNode, upstream, length, rebalancedString); |