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

Unified Diff: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp

Issue 2196553003: Refactoring: Introduce nextSiblingIsTextNode and shouldEmitNBSPbeforeEnd variables (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add const Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingUtilities.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5a00a3132f73f1f4175663315dc366f4eae24622 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
+ const bool nextSiblingIsTextNode = textNode->nextSibling() && textNode->nextSibling()->isTextNode()
+ && toText(textNode->nextSibling())->data().length();
+ const bool shouldEmitNBSPbeforeEnd =(isEndOfParagraph(visibleDownstreamPos) || (unsigned)downstream == text.length()) && !nextSiblingIsTextNode;
+ String rebalancedString = stringWithRebalancedWhitespace(string,
+ isStartOfParagraph(visibleUpstreamPos) || !upstream, shouldEmitNBSPbeforeEnd);
if (string != rebalancedString)
replaceTextInNodePreservingMarkers(textNode, upstream, length, rebalancedString);
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingUtilities.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698