OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 String convertHTMLTextToInterchangeFormat(const String& in, const Text& node) | 38 String convertHTMLTextToInterchangeFormat(const String& in, const Text& node) |
39 { | 39 { |
40 // Assume all the text comes from node. | 40 // Assume all the text comes from node. |
41 if (node.renderer() && node.renderer()->style()->preserveNewline()) | 41 if (node.renderer() && node.renderer()->style()->preserveNewline()) |
42 return in; | 42 return in; |
43 | 43 |
44 const char convertedSpaceString[] = "<span class=\"" AppleConvertedSpace "\"
>\xA0</span>"; | 44 const char convertedSpaceString[] = "<span class=\"" AppleConvertedSpace "\"
>\xA0</span>"; |
45 COMPILE_ASSERT((static_cast<unsigned char>('\xA0') == noBreakSpace), Convert
edSpaceStringSpaceIsNoBreakSpace); | 45 static_assert((static_cast<unsigned char>('\xA0') == noBreakSpace), "\\xA0 s
hould be non-breaking space"); |
46 | 46 |
47 StringBuilder s; | 47 StringBuilder s; |
48 | 48 |
49 unsigned i = 0; | 49 unsigned i = 0; |
50 unsigned consumed = 0; | 50 unsigned consumed = 0; |
51 while (i < in.length()) { | 51 while (i < in.length()) { |
52 consumed = 1; | 52 consumed = 1; |
53 if (isCollapsibleWhitespace(in[i])) { | 53 if (isCollapsibleWhitespace(in[i])) { |
54 // count number of adjoining spaces | 54 // count number of adjoining spaces |
55 unsigned j = i + 1; | 55 unsigned j = i + 1; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 } else | 92 } else |
93 s.append(in[i]); | 93 s.append(in[i]); |
94 i += consumed; | 94 i += consumed; |
95 } | 95 } |
96 | 96 |
97 return s.toString(); | 97 return s.toString(); |
98 } | 98 } |
99 | 99 |
100 } // namespace blink | 100 } // namespace blink |
OLD | NEW |