Diff
Modified: trunk/Source/WTF/ChangeLog (222770 => 222771)
--- trunk/Source/WTF/ChangeLog 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WTF/ChangeLog 2017-10-03 06:42:22 UTC (rev 222771)
@@ -1,3 +1,18 @@
+2017-10-02 Myles C. Maxfield <[email protected]>
+
+ Move LineEnding.{h,cpp} from WebCore/platform/text to wtf/text
+ https://bugs.webkit.org/show_bug.cgi?id=176575
+
+ Reviewed by Alex Christensen.
+
+ As part of the PAL effort, we're trying to move everything out of WebCore/platform, one-by-one.
+ These LineEnding files belong in WTF.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/text/LineEnding.cpp: Renamed from Source/WebCore/platform/text/LineEnding.cpp.
+ (WTF::normalizeLineEndingsToCRLF):
+ * wtf/text/LineEnding.h: Renamed from Source/WebCore/platform/text/LineEnding.h.
+
2017-10-02 Geoffrey Garen <[email protected]>
WeakPtr should have a move constructor
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (222770 => 222771)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2017-10-03 06:42:22 UTC (rev 222771)
@@ -134,6 +134,7 @@
ADF2CE671E39F106006889DB /* MemoryFootprintCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADF2CE651E39F106006889DB /* MemoryFootprintCocoa.cpp */; };
C2BCFC401F61D13000C9222C /* Language.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2BCFC3E1F61D13000C9222C /* Language.cpp */; };
C2BCFC421F61D61600C9222C /* LanguageCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2BCFC411F61D61600C9222C /* LanguageCF.cpp */; };
+ C2BCFC551F621F3F00C9222C /* LineEnding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2BCFC531F621F3F00C9222C /* LineEnding.cpp */; };
CD5497AC15857D0300B5BC30 /* MediaTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5497AA15857D0300B5BC30 /* MediaTime.cpp */; };
DCEE22011CEA7551000C2396 /* BlockObjCExceptions.mm in Sources */ = {isa = PBXBuildFile; fileRef = DCEE21FD1CEA7551000C2396 /* BlockObjCExceptions.mm */; };
E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */; };
@@ -553,6 +554,8 @@
C2BCFC3E1F61D13000C9222C /* Language.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Language.cpp; sourceTree = "<group>"; };
C2BCFC3F1F61D13000C9222C /* Language.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Language.h; sourceTree = "<group>"; };
C2BCFC411F61D61600C9222C /* LanguageCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LanguageCF.cpp; sourceTree = "<group>"; };
+ C2BCFC531F621F3F00C9222C /* LineEnding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineEnding.cpp; sourceTree = "<group>"; };
+ C2BCFC541F621F3F00C9222C /* LineEnding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineEnding.h; sourceTree = "<group>"; };
C4F8A93619C65EB400B2B15D /* Stopwatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Stopwatch.h; sourceTree = "<group>"; };
C8F597CA2A57417FBAB92FD6 /* RandomDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RandomDevice.cpp; sourceTree = "<group>"; };
CD5497AA15857D0300B5BC30 /* MediaTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTime.cpp; sourceTree = "<group>"; };
@@ -1090,6 +1093,8 @@
26147B0815DDCCDC00DDB907 /* IntegerToStringConversion.h */,
93AC91A718942FC400244939 /* LChar.h */,
1C181C811D30797C00F5FA16 /* LineBreakIteratorPoolICU.h */,
+ C2BCFC531F621F3F00C9222C /* LineEnding.cpp */,
+ C2BCFC541F621F3F00C9222C /* LineEnding.h */,
14E785E71DFB330100209BD1 /* OrdinalNumber.h */,
A8A47323151A825B004123FF /* StringBuffer.h */,
A8A47324151A825B004123FF /* StringBuilder.cpp */,
@@ -1372,6 +1377,7 @@
A8A473D8151A825B004123FF /* HashTable.cpp in Sources */,
C2BCFC401F61D13000C9222C /* Language.cpp in Sources */,
C2BCFC421F61D61600C9222C /* LanguageCF.cpp in Sources */,
+ C2BCFC551F621F3F00C9222C /* LineEnding.cpp in Sources */,
0FE1646A1B6FFC9600400E7C /* Lock.cpp in Sources */,
0F60F32F1DFCBD1B00416D6C /* LockedPrintStream.cpp in Sources */,
53534F2A1EC0E10E00141B2F /* MachExceptions.defs in Sources */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (222770 => 222771)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2017-10-03 06:42:22 UTC (rev 222771)
@@ -178,6 +178,7 @@
text/CString.h
text/IntegerToStringConversion.h
text/LChar.h
+ text/LineEnding.h
text/LineBreakIteratorPoolICU.h
text/StringBuffer.h
text/StringCommon.h
@@ -287,6 +288,7 @@
text/AtomicStringTable.cpp
text/Base64.cpp
text/CString.cpp
+ text/LineEnding.cpp
text/StringBuilder.cpp
text/StringBuilderJSON.cpp
text/StringImpl.cpp
Copied: trunk/Source/WTF/wtf/text/LineEnding.cpp (from rev 222770, trunk/Source/WebCore/platform/text/LineEnding.cpp) (0 => 222771)
--- trunk/Source/WTF/wtf/text/LineEnding.cpp (rev 0)
+++ trunk/Source/WTF/wtf/text/LineEnding.cpp 2017-10-03 06:42:22 UTC (rev 222771)
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2005, 2006, 2008, 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LineEnding.h"
+
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+namespace {
+
+class OutputBuffer {
+public:
+ virtual uint8_t* allocate(size_t) = 0;
+ virtual void copy(const CString&) = 0;
+ virtual ~OutputBuffer() { }
+};
+
+class CStringBuffer : public OutputBuffer {
+public:
+ CStringBuffer(CString& buffer)
+ : m_buffer(buffer)
+ {
+ }
+ virtual ~CStringBuffer() { }
+
+ uint8_t* allocate(size_t size) override
+ {
+ char* ptr;
+ m_buffer = CString::newUninitialized(size, ptr);
+ return reinterpret_cast<uint8_t*>(ptr);
+ }
+
+ void copy(const CString& source) override
+ {
+ m_buffer = source;
+ }
+
+ const CString& buffer() const { return m_buffer; }
+
+private:
+ CString m_buffer;
+};
+
+#if OS(WINDOWS)
+class VectorCharAppendBuffer : public OutputBuffer {
+public:
+ VectorCharAppendBuffer(Vector<uint8_t>& buffer)
+ : m_buffer(buffer)
+ {
+ }
+ virtual ~VectorCharAppendBuffer() { }
+
+ uint8_t* allocate(size_t size) override
+ {
+ size_t oldSize = m_buffer.size();
+ m_buffer.grow(oldSize + size);
+ return m_buffer.data() + oldSize;
+ }
+
+ void copy(const CString& source) override
+ {
+ m_buffer.append(source.data(), source.length());
+ }
+
+private:
+ Vector<uint8_t>& m_buffer;
+};
+#endif
+
+void internalNormalizeLineEndingsToCRLF(const CString& from, OutputBuffer& buffer)
+{
+ if (!from.length())
+ return;
+ // Compute the new length.
+ size_t newLen = 0;
+ const char* p = from.data();
+ while (p < from.data() + from.length()) {
+ char c = *p++;
+ if (c == '\r') {
+ // Safe to look ahead because of trailing '\0'.
+ if (*p != '\n') {
+ // Turn CR into CRLF.
+ newLen += 2;
+ }
+ } else if (c == '\n') {
+ // Turn LF into CRLF.
+ newLen += 2;
+ } else {
+ // Leave other characters alone.
+ newLen += 1;
+ }
+ }
+ if (newLen < from.length())
+ return;
+
+ if (newLen == from.length()) {
+ buffer.copy(from);
+ return;
+ }
+
+ p = from.data();
+ uint8_t* q = buffer.allocate(newLen);
+
+ // Make a copy of the string.
+ while (p < from.data() + from.length()) {
+ char c = *p++;
+ if (c == '\r') {
+ // Safe to look ahead because of trailing '\0'.
+ if (*p != '\n') {
+ // Turn CR into CRLF.
+ *q++ = '\r';
+ *q++ = '\n';
+ }
+ } else if (c == '\n') {
+ // Turn LF into CRLF.
+ *q++ = '\r';
+ *q++ = '\n';
+ } else {
+ // Leave other characters alone.
+ *q++ = c;
+ }
+ }
+}
+
+};
+
+namespace WTF {
+
+// Normalize all line-endings to CR or LF.
+static void normalizeToCROrLF(const CString& from, Vector<uint8_t>& result, bool toCR)
+{
+ // Compute the new length.
+ size_t newLen = 0;
+ bool needFix = false;
+ const char* p = from.data();
+ char fromEndingChar = toCR ? '\n' : '\r';
+ char toEndingChar = toCR ? '\r' : '\n';
+ while (p < from.data() + from.length()) {
+ char c = *p++;
+ if (c == '\r' && *p == '\n') {
+ // Turn CRLF into CR or LF.
+ p++;
+ needFix = true;
+ } else if (c == fromEndingChar) {
+ // Turn CR/LF into LF/CR.
+ needFix = true;
+ }
+ newLen += 1;
+ }
+
+ // Grow the result buffer.
+ p = from.data();
+ size_t oldResultSize = result.size();
+ result.grow(oldResultSize + newLen);
+ uint8_t* q = result.data() + oldResultSize;
+
+ // If no need to fix the string, just copy the string over.
+ if (!needFix) {
+ memcpy(q, p, from.length());
+ return;
+ }
+
+ // Make a copy of the string.
+ while (p < from.data() + from.length()) {
+ char c = *p++;
+ if (c == '\r' && *p == '\n') {
+ // Turn CRLF or CR into CR or LF.
+ p++;
+ *q++ = toEndingChar;
+ } else if (c == fromEndingChar) {
+ // Turn CR/LF into LF/CR.
+ *q++ = toEndingChar;
+ } else {
+ // Leave other characters alone.
+ *q++ = c;
+ }
+ }
+}
+
+CString normalizeLineEndingsToCRLF(const CString& from)
+{
+ CString result;
+ ::CStringBuffer buffer(result);
+ internalNormalizeLineEndingsToCRLF(from, buffer);
+ return buffer.buffer();
+}
+
+void normalizeAndAppendLineEndingsToNative(const CString& from, Vector<uint8_t>& result)
+{
+#if OS(WINDOWS)
+ VectorCharAppendBuffer buffer(result);
+ internalNormalizeLineEndingsToCRLF(from, buffer);
+#else
+ normalizeToCROrLF(from, result, false);
+#endif
+}
+
+} // namespace WTF
Copied: trunk/Source/WTF/wtf/text/LineEnding.h (from rev 222770, trunk/Source/WebCore/platform/text/LineEnding.h) (0 => 222771)
--- trunk/Source/WTF/wtf/text/LineEnding.h (rev 0)
+++ trunk/Source/WTF/wtf/text/LineEnding.h 2017-10-03 06:42:22 UTC (rev 222771)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2005, 2006, 2008, 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Forward.h>
+#include <wtf/Vector.h>
+
+namespace WTF {
+
+// Normalize all line-endings in the given string to CRLF.
+WTF_EXPORT CString normalizeLineEndingsToCRLF(const CString& from);
+
+// Normalize all line-endings in the given string to the native line-endings and append the result to the given buffer.
+// (Normalize to CRLF on Windows and normalize to LF on all other platforms.)
+WTF_EXPORT void normalizeAndAppendLineEndingsToNative(const CString& from, Vector<uint8_t>& result);
+
+} // namespace WTF
+
+using WTF::normalizeLineEndingsToCRLF;
+using WTF::normalizeAndAppendLineEndingsToNative;
Property changes: trunk/Source/WTF/wtf/text/LineEnding.h
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Author Date Id Rev URL
\ No newline at end of property
Modified: trunk/Source/WebCore/CMakeLists.txt (222770 => 222771)
--- trunk/Source/WebCore/CMakeLists.txt 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-10-03 06:42:22 UTC (rev 222771)
@@ -2612,7 +2612,6 @@
platform/text/BidiContext.cpp
platform/text/DateTimeFormat.cpp
- platform/text/LineEnding.cpp
platform/text/LocaleToScriptMappingDefault.cpp
platform/text/PlatformLocale.cpp
platform/text/QuotedPrintable.cpp
Modified: trunk/Source/WebCore/ChangeLog (222770 => 222771)
--- trunk/Source/WebCore/ChangeLog 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WebCore/ChangeLog 2017-10-03 06:42:22 UTC (rev 222771)
@@ -1,3 +1,16 @@
+2017-10-02 Myles C. Maxfield <[email protected]>
+
+ Move LineEnding.{h,cpp} from WebCore/platform/text to wtf/text
+ https://bugs.webkit.org/show_bug.cgi?id=176575
+
+ Reviewed by Alex Christensen.
+
+ No new tests because there is no behavior change.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * fileapi/BlobBuilder.cpp:
+ * html/FormDataList.cpp:
+
2017-10-02 Joseph Pecoraro <[email protected]>
Web Inspector: Rename methods ending in *Json() as *JSON()
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (222770 => 222771)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-03 06:42:22 UTC (rev 222771)
@@ -3762,8 +3762,6 @@
8931DE5B14C44C44000DC9D2 /* JSBlobCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */; };
898785F4122E1EAC003AABDA /* JSFileReaderSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 898785F2122E1EAC003AABDA /* JSFileReaderSync.cpp */; };
898785F5122E1EAC003AABDA /* JSFileReaderSync.h in Headers */ = {isa = PBXBuildFile; fileRef = 898785F3122E1EAC003AABDA /* JSFileReaderSync.h */; };
- 89B5EAA111E8003D00F2367E /* LineEnding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 89B5EA9F11E8003D00F2367E /* LineEnding.cpp */; };
- 89B5EAA211E8003D00F2367E /* LineEnding.h in Headers */ = {isa = PBXBuildFile; fileRef = 89B5EAA011E8003D00F2367E /* LineEnding.h */; settings = {ATTRIBUTES = (Private, ); }; };
89F60B11157F686E0075E157 /* DOMWindowQuota.h in Headers */ = {isa = PBXBuildFile; fileRef = 89F60B0A157F686D0075E157 /* DOMWindowQuota.h */; };
89F60CDA15809D760075E157 /* JSStorageInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 89F60CD215809D760075E157 /* JSStorageInfo.h */; };
8A12E35D11FA33280025836A /* LoadTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A12E35C11FA33280025836A /* LoadTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -12136,8 +12134,6 @@
8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBlobCustom.cpp; sourceTree = "<group>"; };
898785F2122E1EAC003AABDA /* JSFileReaderSync.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFileReaderSync.cpp; sourceTree = "<group>"; };
898785F3122E1EAC003AABDA /* JSFileReaderSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFileReaderSync.h; sourceTree = "<group>"; };
- 89B5EA9F11E8003D00F2367E /* LineEnding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineEnding.cpp; sourceTree = "<group>"; };
- 89B5EAA011E8003D00F2367E /* LineEnding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineEnding.h; sourceTree = "<group>"; };
89F60B0A157F686D0075E157 /* DOMWindowQuota.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindowQuota.h; sourceTree = "<group>"; };
89F60CD215809D760075E157 /* JSStorageInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStorageInfo.h; sourceTree = "<group>"; };
89FD58D816EEDBD400E183F0 /* NavigatorStorageQuota.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorStorageQuota.h; sourceTree = "<group>"; };
@@ -23982,8 +23978,6 @@
CECCFC3A141973D5002A0AC1 /* DecodeEscapeSequences.h */,
7CCB11D81F81B22000849AFD /* FontRenderingMode.h */,
375CD231119D43C800A2A859 /* Hyphenation.h */,
- 89B5EA9F11E8003D00F2367E /* LineEnding.cpp */,
- 89B5EAA011E8003D00F2367E /* LineEnding.h */,
7633A72413D8B33A008501B6 /* LocaleToScriptMapping.h */,
7633A72513D8B33A008501B6 /* LocaleToScriptMappingDefault.cpp */,
F544F78615CFB2A800AF33A8 /* PlatformLocale.cpp */,
@@ -29229,7 +29223,6 @@
84730D911248F0B300D3A9C9 /* LightSource.h in Headers */,
B22279650D00BF220071B782 /* LinearGradientAttributes.h in Headers */,
AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */,
- 89B5EAA211E8003D00F2367E /* LineEnding.h in Headers */,
FFEFAB2A18380DA000514534 /* LineLayoutState.h in Headers */,
FFDBC047183D27B700407109 /* LineWidth.h in Headers */,
CBA9DC0B1DF44DF40005675C /* LinkHeader.h in Headers */,
@@ -33313,7 +33306,6 @@
417612B11E3A994000C3D81D /* LibWebRTCPeerConnectionBackend.cpp in Sources */,
41A1B00E1E526579007F3769 /* LibWebRTCProvider.cpp in Sources */,
FFB698CC1833EE0D00158A31 /* LineBreaker.cpp in Sources */,
- 89B5EAA111E8003D00F2367E /* LineEnding.cpp in Sources */,
FFB698CF183402BB00158A31 /* LineInfo.cpp in Sources */,
FFDBC048183D27B700407109 /* LineWidth.cpp in Sources */,
CBA9DC0A1DF44DF10005675C /* LinkHeader.cpp in Sources */,
Modified: trunk/Source/WebCore/fileapi/BlobBuilder.cpp (222770 => 222771)
--- trunk/Source/WebCore/fileapi/BlobBuilder.cpp 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WebCore/fileapi/BlobBuilder.cpp 2017-10-03 06:42:22 UTC (rev 222771)
@@ -32,11 +32,11 @@
#include "BlobBuilder.h"
#include "Blob.h"
-#include "LineEnding.h"
#include "TextEncoding.h"
#include <runtime/ArrayBuffer.h>
#include <runtime/ArrayBufferView.h>
#include <wtf/text/CString.h>
+#include <wtf/text/LineEnding.h>
namespace WebCore {
@@ -73,7 +73,7 @@
CString utf8Text = UTF8Encoding().encode(text, EntitiesForUnencodables);
if (m_endings == BlobLineEndings::Native)
- normalizeLineEndingsToNative(utf8Text, m_appendableData);
+ normalizeAndAppendLineEndingsToNative(utf8Text, m_appendableData);
else {
ASSERT(m_endings == BlobLineEndings::Transparent);
m_appendableData.append(utf8Text.data(), utf8Text.length());
Modified: trunk/Source/WebCore/platform/network/FormData.cpp (222770 => 222771)
--- trunk/Source/WebCore/platform/network/FormData.cpp 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WebCore/platform/network/FormData.cpp 2017-10-03 06:42:22 UTC (rev 222771)
@@ -31,10 +31,10 @@
#include "File.h"
#include "FileSystem.h"
#include "FormDataBuilder.h"
-#include "LineEnding.h"
#include "Page.h"
#include "TextEncoding.h"
#include "ThreadableBlobRegistry.h"
+#include <wtf/text/LineEnding.h>
namespace WebCore {
Deleted: trunk/Source/WebCore/platform/text/LineEnding.cpp (222770 => 222771)
--- trunk/Source/WebCore/platform/text/LineEnding.cpp 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WebCore/platform/text/LineEnding.cpp 2017-10-03 06:42:22 UTC (rev 222771)
@@ -1,227 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "LineEnding.h"
-
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-
-namespace {
-
-class OutputBuffer {
-public:
- virtual uint8_t* allocate(size_t size) = 0;
- virtual void copy(const CString&) = 0;
- virtual ~OutputBuffer() { }
-};
-
-class CStringBuffer : public OutputBuffer {
-public:
- CStringBuffer(CString& buffer)
- : m_buffer(buffer)
- {
- }
- virtual ~CStringBuffer() { }
-
- uint8_t* allocate(size_t size) override
- {
- char* ptr;
- m_buffer = CString::newUninitialized(size, ptr);
- return reinterpret_cast<uint8_t*>(ptr);
- }
-
- void copy(const CString& source) override
- {
- m_buffer = source;
- }
-
- const CString& buffer() const { return m_buffer; }
-
-private:
- CString m_buffer;
-};
-
-#if OS(WINDOWS)
-class VectorCharAppendBuffer : public OutputBuffer {
-public:
- VectorCharAppendBuffer(Vector<uint8_t>& buffer)
- : m_buffer(buffer)
- {
- }
- virtual ~VectorCharAppendBuffer() { }
-
- uint8_t* allocate(size_t size) override
- {
- size_t oldSize = m_buffer.size();
- m_buffer.grow(oldSize + size);
- return m_buffer.data() + oldSize;
- }
-
- void copy(const CString& source) override
- {
- m_buffer.append(source.data(), source.length());
- }
-
-private:
- Vector<uint8_t>& m_buffer;
-};
-#endif
-
-void internalNormalizeLineEndingsToCRLF(const CString& from, OutputBuffer& buffer)
-{
- if (!from.length())
- return;
- // Compute the new length.
- size_t newLen = 0;
- const char* p = from.data();
- while (p < from.data() + from.length()) {
- char c = *p++;
- if (c == '\r') {
- // Safe to look ahead because of trailing '\0'.
- if (*p != '\n') {
- // Turn CR into CRLF.
- newLen += 2;
- }
- } else if (c == '\n') {
- // Turn LF into CRLF.
- newLen += 2;
- } else {
- // Leave other characters alone.
- newLen += 1;
- }
- }
- if (newLen < from.length())
- return;
-
- if (newLen == from.length()) {
- buffer.copy(from);
- return;
- }
-
- p = from.data();
- uint8_t* q = buffer.allocate(newLen);
-
- // Make a copy of the string.
- while (p < from.data() + from.length()) {
- char c = *p++;
- if (c == '\r') {
- // Safe to look ahead because of trailing '\0'.
- if (*p != '\n') {
- // Turn CR into CRLF.
- *q++ = '\r';
- *q++ = '\n';
- }
- } else if (c == '\n') {
- // Turn LF into CRLF.
- *q++ = '\r';
- *q++ = '\n';
- } else {
- // Leave other characters alone.
- *q++ = c;
- }
- }
-}
-
-};
-
-namespace WebCore {
-
-// Normalize all line-endings to CR or LF.
-static void normalizeToCROrLF(const CString& from, Vector<uint8_t>& result, bool toCR)
-{
- // Compute the new length.
- size_t newLen = 0;
- bool needFix = false;
- const char* p = from.data();
- char fromEndingChar = toCR ? '\n' : '\r';
- char toEndingChar = toCR ? '\r' : '\n';
- while (p < from.data() + from.length()) {
- char c = *p++;
- if (c == '\r' && *p == '\n') {
- // Turn CRLF into CR or LF.
- p++;
- needFix = true;
- } else if (c == fromEndingChar) {
- // Turn CR/LF into LF/CR.
- needFix = true;
- }
- newLen += 1;
- }
-
- // Grow the result buffer.
- p = from.data();
- size_t oldResultSize = result.size();
- result.grow(oldResultSize + newLen);
- uint8_t* q = result.data() + oldResultSize;
-
- // If no need to fix the string, just copy the string over.
- if (!needFix) {
- memcpy(q, p, from.length());
- return;
- }
-
- // Make a copy of the string.
- while (p < from.data() + from.length()) {
- char c = *p++;
- if (c == '\r' && *p == '\n') {
- // Turn CRLF or CR into CR or LF.
- p++;
- *q++ = toEndingChar;
- } else if (c == fromEndingChar) {
- // Turn CR/LF into LF/CR.
- *q++ = toEndingChar;
- } else {
- // Leave other characters alone.
- *q++ = c;
- }
- }
-}
-
-CString normalizeLineEndingsToCRLF(const CString& from)
-{
- CString result;
- CStringBuffer buffer(result);
- internalNormalizeLineEndingsToCRLF(from, buffer);
- return buffer.buffer();
-}
-
-void normalizeLineEndingsToNative(const CString& from, Vector<uint8_t>& result)
-{
-#if OS(WINDOWS)
- VectorCharAppendBuffer buffer(result);
- internalNormalizeLineEndingsToCRLF(from, buffer);
-#else
- normalizeToCROrLF(from, result, false);
-#endif
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/platform/text/LineEnding.h (222770 => 222771)
--- trunk/Source/WebCore/platform/text/LineEnding.h 2017-10-03 06:36:56 UTC (rev 222770)
+++ trunk/Source/WebCore/platform/text/LineEnding.h 2017-10-03 06:42:22 UTC (rev 222771)
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LineEnding_h
-#define LineEnding_h
-
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-// Normalize all line-endings in the given string to CRLF.
-CString normalizeLineEndingsToCRLF(const CString& from);
-
-// Normalize all line-endings in the given string to the native line-endings and append the result to the given buffer.
-// (Normalize to CRLF on Windows and normalize to LF on all other platforms.)
-void normalizeLineEndingsToNative(const CString& from, Vector<uint8_t>& result);
-
-} // namespace WebCore
-
-#endif // LineEnding_h