OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |