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

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

Issue 2196553003: Refactoring: Introduce nextSiblingIsTextNode and shouldEmitNBSPbeforeEnd variables (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 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 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 965
966 bool previousCharacterWasSpace = false; 966 bool previousCharacterWasSpace = false;
967 for (size_t i = 0; i < length; i++) { 967 for (size_t i = 0; i < length; i++) {
968 UChar c = string[i]; 968 UChar c = string[i];
969 if (!isWhitespace(c)) { 969 if (!isWhitespace(c)) {
970 rebalancedString.append(c); 970 rebalancedString.append(c);
971 previousCharacterWasSpace = false; 971 previousCharacterWasSpace = false;
972 continue; 972 continue;
973 } 973 }
974 974
975 // We need to ensure there is no next sibling text node. See http://crbu g.com/310149
976 if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i + 1 == length && shouldEmitNBSPbeforeEnd)) { 975 if (previousCharacterWasSpace || (!i && startIsStartOfParagraph) || (i + 1 == length && shouldEmitNBSPbeforeEnd)) {
977 rebalancedString.append(noBreakSpaceCharacter); 976 rebalancedString.append(noBreakSpaceCharacter);
978 previousCharacterWasSpace = false; 977 previousCharacterWasSpace = false;
979 } else { 978 } else {
980 rebalancedString.append(' '); 979 rebalancedString.append(' ');
981 previousCharacterWasSpace = true; 980 previousCharacterWasSpace = true;
982 } 981 }
983 } 982 }
984 983
985 DCHECK_EQ(rebalancedString.length(), length); 984 DCHECK_EQ(rebalancedString.length(), length);
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 return InputType::DeleteWordBackward; 1942 return InputType::DeleteWordBackward;
1944 if (granularity == LineBoundary) 1943 if (granularity == LineBoundary)
1945 return InputType::DeleteLineBackward; 1944 return InputType::DeleteLineBackward;
1946 return InputType::DeleteContentBackward; 1945 return InputType::DeleteContentBackward;
1947 default: 1946 default:
1948 return InputType::None; 1947 return InputType::None;
1949 } 1948 }
1950 } 1949 }
1951 1950
1952 } // namespace blink 1951 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698