OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "DocumentFragment.h" | 29 #include "DocumentFragment.h" |
30 #include "KURL.h" | 30 #include "KURL.h" |
31 #include "TextEncoding.h" | 31 #include "TextEncoding.h" |
32 #include "markup.h" | 32 #include "markup.h" |
33 #include <shlobj.h> | 33 #include <shlobj.h> |
34 #include <shlwapi.h> | 34 #include <shlwapi.h> |
35 #include <wininet.h> // for INTERNET_MAX_URL_LENGTH | 35 #include <wininet.h> // for INTERNET_MAX_URL_LENGTH |
36 #include <wtf/StringExtras.h> | 36 #include <wtf/StringExtras.h> |
37 #include <wtf/text/CString.h> | 37 #include <wtf/text/CString.h> |
| 38 #include <wtf/text/StringBuilder.h> |
38 #include <wtf/text/WTFString.h> | 39 #include <wtf/text/WTFString.h> |
39 | 40 |
40 #if USE(CF) | 41 #if USE(CF) |
41 #include <CoreFoundation/CoreFoundation.h> | 42 #include <CoreFoundation/CoreFoundation.h> |
42 #include <wtf/RetainPtr.h> | 43 #include <wtf/RetainPtr.h> |
43 #endif | 44 #endif |
44 | 45 |
45 namespace WebCore { | 46 namespace WebCore { |
46 | 47 |
47 #if USE(CF) | 48 #if USE(CF) |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 293 |
293 #undef MAX_DIGITS | 294 #undef MAX_DIGITS |
294 #undef MAKE_NUMBER_FORMAT_1 | 295 #undef MAKE_NUMBER_FORMAT_1 |
295 #undef MAKE_NUMBER_FORMAT_2 | 296 #undef MAKE_NUMBER_FORMAT_2 |
296 #undef NUMBER_FORMAT | 297 #undef NUMBER_FORMAT |
297 } | 298 } |
298 | 299 |
299 void replaceNewlinesWithWindowsStyleNewlines(String& str) | 300 void replaceNewlinesWithWindowsStyleNewlines(String& str) |
300 { | 301 { |
301 DEFINE_STATIC_LOCAL(String, windowsNewline, ("\r\n")); | 302 DEFINE_STATIC_LOCAL(String, windowsNewline, ("\r\n")); |
302 const static unsigned windowsNewlineLength = windowsNewline.length(); | 303 StringBuilder result; |
303 | 304 for (unsigned index = 0; index < str.length(); ++index) { |
304 unsigned index = 0; | 305 if (str[index] != '\n' || (index > 0 && str[index - 1] == '\r')) |
305 unsigned strLength = str.length(); | 306 result.append(str[index]); |
306 while (index < strLength) { | 307 else |
307 if (str[index] != '\n' || (index > 0 && str[index - 1] == '\r')) { | 308 result.append(windowsNewline); |
308 ++index; | |
309 continue; | |
310 } | |
311 str.replace(index, 1, windowsNewline); | |
312 strLength = str.length(); | |
313 index += windowsNewlineLength; | |
314 } | 309 } |
| 310 str = result.toString(); |
315 } | 311 } |
316 | 312 |
317 void replaceNBSPWithSpace(String& str) | 313 void replaceNBSPWithSpace(String& str) |
318 { | 314 { |
319 static const UChar NonBreakingSpaceCharacter = 0xA0; | 315 static const UChar NonBreakingSpaceCharacter = 0xA0; |
320 static const UChar SpaceCharacter = ' '; | 316 static const UChar SpaceCharacter = ' '; |
321 str.replace(NonBreakingSpaceCharacter, SpaceCharacter); | 317 str.replace(NonBreakingSpaceCharacter, SpaceCharacter); |
322 } | 318 } |
323 | 319 |
324 FORMATETC* urlWFormat() | 320 FORMATETC* urlWFormat() |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 void setClipboardData(IDataObject* dataObject, UINT format, const Vector<String>
& dataStrings) | 832 void setClipboardData(IDataObject* dataObject, UINT format, const Vector<String>
& dataStrings) |
837 { | 833 { |
838 const ClipboardFormatMap& formatMap = getClipboardMap(); | 834 const ClipboardFormatMap& formatMap = getClipboardMap(); |
839 ClipboardFormatMap::const_iterator found = formatMap.find(format); | 835 ClipboardFormatMap::const_iterator found = formatMap.find(format); |
840 if (found == formatMap.end()) | 836 if (found == formatMap.end()) |
841 return; | 837 return; |
842 found->second->setString(dataObject, found->second->format, dataStrings); | 838 found->second->setString(dataObject, found->second->format, dataStrings); |
843 } | 839 } |
844 | 840 |
845 } // namespace WebCore | 841 } // namespace WebCore |
OLD | NEW |