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

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

Issue 2473633002: Add a nbsp at the the end of the text when the next text has a leading space. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/inserting/insert-space.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 863
864 String string = text.substring(upstream, length); 864 String string = text.substring(upstream, length);
865 // FIXME: Because of the problem mentioned at the top of this function, we 865 // FIXME: Because of the problem mentioned at the top of this function, we
866 // must also use nbsps at the start/end of the string because this function 866 // must also use nbsps at the start/end of the string because this function
867 // doesn't get all surrounding whitespace, just the whitespace in the 867 // doesn't get all surrounding whitespace, just the whitespace in the
868 // current text node. However, if the next sibling node is a text node 868 // current text node. However, if the next sibling node is a text node
869 // (not empty, see http://crbug.com/632300), we should use a plain space. 869 // (not empty, see http://crbug.com/632300), we should use a plain space.
870 // See http://crbug.com/310149 870 // See http://crbug.com/310149
871 const bool nextSiblingIsTextNode = 871 const bool nextSiblingIsTextNode =
872 textNode->nextSibling() && textNode->nextSibling()->isTextNode() && 872 textNode->nextSibling() && textNode->nextSibling()->isTextNode() &&
873 toText(textNode->nextSibling())->data().length(); 873 toText(textNode->nextSibling())->data().length() &&
874 toText(textNode->nextSibling())->data()[0] != ' ';
874 const bool shouldEmitNBSPbeforeEnd = 875 const bool shouldEmitNBSPbeforeEnd =
875 (isEndOfParagraphDeprecated(visibleDownstreamPos) || 876 (isEndOfParagraphDeprecated(visibleDownstreamPos) ||
876 (unsigned)downstream == text.length()) && 877 (unsigned)downstream == text.length()) &&
877 !nextSiblingIsTextNode; 878 !nextSiblingIsTextNode;
878 String rebalancedString = stringWithRebalancedWhitespace( 879 String rebalancedString = stringWithRebalancedWhitespace(
879 string, isStartOfParagraphDeprecated(visibleUpstreamPos) || !upstream, 880 string, isStartOfParagraphDeprecated(visibleUpstreamPos) || !upstream,
880 shouldEmitNBSPbeforeEnd); 881 shouldEmitNBSPbeforeEnd);
881 882
882 if (string != rebalancedString) 883 if (string != rebalancedString)
883 replaceTextInNodePreservingMarkers(textNode, upstream, length, 884 replaceTextInNodePreservingMarkers(textNode, upstream, length,
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 return node; 1996 return node;
1996 } 1997 }
1997 1998
1998 DEFINE_TRACE(CompositeEditCommand) { 1999 DEFINE_TRACE(CompositeEditCommand) {
1999 visitor->trace(m_commands); 2000 visitor->trace(m_commands);
2000 visitor->trace(m_composition); 2001 visitor->trace(m_composition);
2001 EditCommand::trace(visitor); 2002 EditCommand::trace(visitor);
2002 } 2003 }
2003 2004
2004 } // namespace blink 2005 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/inserting/insert-space.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698