Title: [228836] branches/safari-605-branch

Diff

Modified: branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog (228835 => 228836)


--- branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog	2018-02-20 22:29:56 UTC (rev 228835)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog	2018-02-20 22:30:01 UTC (rev 228836)
@@ -1,3 +1,20 @@
+2018-02-20  Jason Marcell  <jmarc...@apple.com>
+
+        Cherry-pick r228594. rdar://problem/37697671
+
+    2018-02-16  Daniel Bates  <daba...@apple.com>
+
+            Remove dead code for UTF-32
+            https://bugs.webkit.org/show_bug.cgi?id=182900
+            <rdar://problem/37238717>
+
+            Reviewed by Alexey Proskuryakov.
+
+            Update expected results now that all sub-tests pass.
+
+            * web-platform-tests/encoding/unsupported-encodings-expected.txt:
+            * web-platform-tests/encoding/utf-32-expected.txt:
+
 2018-02-12  Jason Marcell  <jmarc...@apple.com>
 
         Cherry-pick r228326. rdar://problem/37460483

Modified: branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/encoding/unsupported-encodings-expected.txt (228835 => 228836)


--- branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/encoding/unsupported-encodings-expected.txt	2018-02-20 22:29:56 UTC (rev 228835)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/encoding/unsupported-encodings-expected.txt	2018-02-20 22:30:01 UTC (rev 228836)
@@ -1,16 +1,16 @@
 
 PASS UTF-7 should not be supported 
 PASS utf-7 should not be supported 
-FAIL UTF-32 with BOM should decode as UTF-16LE assert_equals: Decoding with UTF-32 expected "U+0000/U+0041/U+0000/U+0042/U+0000" but got "U+0041/U+0000/U+0000/U+0000/U+0042/U+0000/U+0000/U+0000"
+PASS UTF-32 with BOM should decode as UTF-16LE 
 PASS UTF-32 with no BOM should decode as windows-1252 
-FAIL utf-32 with BOM should decode as UTF-16LE assert_equals: Decoding with utf-32 expected "U+0000/U+0041/U+0000/U+0042/U+0000" but got "U+0041/U+0000/U+0000/U+0000/U+0042/U+0000/U+0000/U+0000"
+PASS utf-32 with BOM should decode as UTF-16LE 
 PASS utf-32 with no BOM should decode as windows-1252 
-FAIL UTF-32LE with BOM should decode as UTF-16LE assert_equals: Decoding with UTF-32LE expected "U+0000/U+0041/U+0000/U+0042/U+0000" but got "U+0041/U+0000/U+0000/U+0000/U+0042/U+0000/U+0000/U+0000"
+PASS UTF-32LE with BOM should decode as UTF-16LE 
 PASS UTF-32LE with no BOM should decode as windows-1252 
-FAIL utf-32le with BOM should decode as UTF-16LE assert_equals: Decoding with utf-32le expected "U+0000/U+0041/U+0000/U+0042/U+0000" but got "U+0041/U+0000/U+0000/U+0000/U+0042/U+0000/U+0000/U+0000"
+PASS utf-32le with BOM should decode as UTF-16LE 
 PASS utf-32le with no BOM should decode as windows-1252 
 PASS UTF-32be with no BOM should decode as windows-1252 
-FAIL UTF-32be with BOM should decode as windows-1252 assert_equals: Decoding with UTF-32be expected "U+0000/U+0000/U+00FE/U+00FF/U+0000/U+0000/U+0000/U+0041/U+0000/U+0000/U+0000/U+0042" but got "U+0000/U+0000/U+0000/U+0041/U+0000/U+0000/U+0000/U+0042"
+PASS UTF-32be with BOM should decode as windows-1252 
 PASS utf-32be with no BOM should decode as windows-1252 
-FAIL utf-32be with BOM should decode as windows-1252 assert_equals: Decoding with utf-32be expected "U+0000/U+0000/U+00FE/U+00FF/U+0000/U+0000/U+0000/U+0041/U+0000/U+0000/U+0000/U+0042" but got "U+0000/U+0000/U+0000/U+0041/U+0000/U+0000/U+0000/U+0042"
+PASS utf-32be with BOM should decode as windows-1252 
 

Modified: branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/encoding/utf-32-expected.txt (228835 => 228836)


--- branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/encoding/utf-32-expected.txt	2018-02-20 22:29:56 UTC (rev 228835)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/encoding/utf-32-expected.txt	2018-02-20 22:30:01 UTC (rev 228836)
@@ -3,8 +3,8 @@
 PASS Expect resources/utf-32-big-endian-bom.xml to parse as windows-1252 
 PASS Expect resources/utf-32-big-endian-nobom.html to parse as windows-1252 
 PASS Expect resources/utf-32-big-endian-nobom.xml to parse as windows-1252 
-FAIL Expect resources/utf-32-little-endian-bom.html to parse as UTF-16LE assert_equals: expected "UTF-16LE" but got "windows-1252"
-FAIL Expect resources/utf-32-little-endian-bom.xml to parse as UTF-16LE assert_equals: expected "UTF-16LE" but got "windows-1252"
+PASS Expect resources/utf-32-little-endian-bom.html to parse as UTF-16LE 
+PASS Expect resources/utf-32-little-endian-bom.xml to parse as UTF-16LE 
 PASS Expect resources/utf-32-little-endian-nobom.html to parse as windows-1252 
 PASS Expect resources/utf-32-little-endian-nobom.xml to parse as windows-1252 
 

Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (228835 => 228836)


--- branches/safari-605-branch/Source/WebCore/ChangeLog	2018-02-20 22:29:56 UTC (rev 228835)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog	2018-02-20 22:30:01 UTC (rev 228836)
@@ -1,5 +1,31 @@
 2018-02-20  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r228594. rdar://problem/37697671
+
+    2018-02-16  Daniel Bates  <daba...@apple.com>
+
+            Remove dead code for UTF-32
+            https://bugs.webkit.org/show_bug.cgi?id=182900
+            <rdar://problem/37238717>
+
+            Reviewed by Alexey Proskuryakov.
+
+            The UTF-32 encodings were removed from the text codec registry in r224747. So,
+            we no longer need code to encode or decode these variants.
+
+            * dom/TextDecoder.cpp:
+            (WebCore::codeUnitByteSize):
+            * loader/TextResourceDecoder.cpp:
+            (WebCore::TextResourceDecoder::checkForBOM):
+            (WebCore::TextResourceDecoder::checkForHeadCharset):
+            * platform/text/TextEncoding.cpp:
+            (WebCore::TextEncoding::isNonByteBasedEncoding const):
+            (WebCore::UTF32BigEndianEncoding): Deleted.
+            (WebCore::UTF32LittleEndianEncoding): Deleted.
+            * platform/text/TextEncoding.h:
+
+2018-02-20  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r228586. rdar://problem/37697673
 
     2018-02-16  Chris Dumez  <cdu...@apple.com>

Modified: branches/safari-605-branch/Source/WebCore/dom/TextDecoder.cpp (228835 => 228836)


--- branches/safari-605-branch/Source/WebCore/dom/TextDecoder.cpp	2018-02-20 22:29:56 UTC (rev 228835)
+++ branches/safari-605-branch/Source/WebCore/dom/TextDecoder.cpp	2018-02-20 22:30:01 UTC (rev 228836)
@@ -87,11 +87,7 @@
 
 static size_t codeUnitByteSize(const TextEncoding& encoding)
 {
-    if (encoding.isByteBasedEncoding())
-        return 1;
-    if (encoding == UTF32BigEndianEncoding() || encoding == UTF32LittleEndianEncoding())
-        return 4;
-    return 2;
+    return encoding.isByteBasedEncoding() ? 1 : 2;
 }
 
 ExceptionOr<String> TextDecoder::decode(std::optional<BufferSource::VariantType> input, DecodeOptions options)

Modified: branches/safari-605-branch/Source/WebCore/loader/TextResourceDecoder.cpp (228835 => 228836)


--- branches/safari-605-branch/Source/WebCore/loader/TextResourceDecoder.cpp	2018-02-20 22:29:56 UTC (rev 228835)
+++ branches/safari-605-branch/Source/WebCore/loader/TextResourceDecoder.cpp	2018-02-20 22:30:01 UTC (rev 228836)
@@ -401,8 +401,10 @@
 
 size_t TextResourceDecoder::checkForBOM(const char* data, size_t len)
 {
-    // Check for UTF-16/32 or UTF-8 BOM mark at the beginning, which is a sure sign of a Unicode encoding.
+    // Check for UTF-16 or UTF-8 BOM mark at the beginning, which is a sure sign of a Unicode encoding.
     // We let it override even a user-chosen encoding.
+    const size_t maximumBOMLength = 3;
+
     ASSERT(!m_checkedForBOM);
 
     size_t lengthOfBOM = 0;
@@ -416,31 +418,26 @@
     unsigned char c1 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0;
     unsigned char c2 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0;
     unsigned char c3 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0;
-    unsigned char c4 = buf2Len ? (--buf2Len, *buf2++) : 0;
 
     // Check for the BOM.
     if (c1 == 0xFF && c2 == 0xFE) {
-        if (c3 != 0 || c4 != 0) {
-            setEncoding(UTF16LittleEndianEncoding(), AutoDetectedEncoding);
-            lengthOfBOM = 2;
-        } else {
-            setEncoding(UTF32LittleEndianEncoding(), AutoDetectedEncoding);
-            lengthOfBOM = 4;
-        }
+        ASSERT(UTF16LittleEndianEncoding().isValid());
+        setEncoding(UTF16LittleEndianEncoding(), AutoDetectedEncoding);
+        lengthOfBOM = 2;
+    } else if (c1 == 0xFE && c2 == 0xFF) {
+        ASSERT(UTF16BigEndianEncoding().isValid());
+        setEncoding(UTF16BigEndianEncoding(), AutoDetectedEncoding);
+        lengthOfBOM = 2;
     } else if (c1 == 0xEF && c2 == 0xBB && c3 == 0xBF) {
+        ASSERT(UTF8Encoding().isValid());
         setEncoding(UTF8Encoding(), AutoDetectedEncoding);
         lengthOfBOM = 3;
-    } else if (c1 == 0xFE && c2 == 0xFF) {
-        setEncoding(UTF16BigEndianEncoding(), AutoDetectedEncoding);
-        lengthOfBOM = 2;
-    } else if (c1 == 0 && c2 == 0 && c3 == 0xFE && c4 == 0xFF) {
-        setEncoding(UTF32BigEndianEncoding(), AutoDetectedEncoding);
-        lengthOfBOM = 4;
     }
 
-    if (lengthOfBOM || bufferLength + len >= 4)
+    if (lengthOfBOM || bufferLength + len >= maximumBOMLength)
         m_checkedForBOM = true;
 
+    ASSERT(lengthOfBOM <= maximumBOMLength);
     return lengthOfBOM;
 }
 
@@ -533,12 +530,6 @@
     } else if (bytesEqual(ptr, 0, '<', 0, '?', 0, 'x')) {
         setEncoding(UTF16BigEndianEncoding(), AutoDetectedEncoding);
         return true;
-    } else if (bytesEqual(ptr, '<', 0, 0, 0, '?', 0, 0, 0)) {
-        setEncoding(UTF32LittleEndianEncoding(), AutoDetectedEncoding);
-        return true;
-    } else if (bytesEqual(ptr, 0, 0, 0, '<', 0, 0, 0, '?')) {
-        setEncoding(UTF32BigEndianEncoding(), AutoDetectedEncoding);
-        return true;
     }
 
     // The HTTP-EQUIV meta has no effect on XHTML.

Modified: branches/safari-605-branch/Source/WebCore/platform/text/TextEncoding.cpp (228835 => 228836)


--- branches/safari-605-branch/Source/WebCore/platform/text/TextEncoding.cpp	2018-02-20 22:29:56 UTC (rev 228835)
+++ branches/safari-605-branch/Source/WebCore/platform/text/TextEncoding.cpp	2018-02-20 22:30:01 UTC (rev 228836)
@@ -145,15 +145,7 @@
 
 bool TextEncoding::isNonByteBasedEncoding() const
 {
-    if (noExtendedTextEncodingNameUsed()) {
-        return *this == UTF16LittleEndianEncoding()
-            || *this == UTF16BigEndianEncoding();
-    }
-
-    return *this == UTF16LittleEndianEncoding()
-        || *this == UTF16BigEndianEncoding()
-        || *this == UTF32BigEndianEncoding()
-        || *this == UTF32LittleEndianEncoding();
+    return *this == UTF16LittleEndianEncoding() || *this == UTF16BigEndianEncoding();
 }
 
 bool TextEncoding::isUTF7Encoding() const
@@ -207,18 +199,6 @@
     return globalUTF16LittleEndianEncoding;
 }
 
-const TextEncoding& UTF32BigEndianEncoding()
-{
-    static TextEncoding globalUTF32BigEndianEncoding("UTF-32BE");
-    return globalUTF32BigEndianEncoding;
-}
-
-const TextEncoding& UTF32LittleEndianEncoding()
-{
-    static TextEncoding globalUTF32LittleEndianEncoding("UTF-32LE");
-    return globalUTF32LittleEndianEncoding;
-}
-
 const TextEncoding& UTF8Encoding()
 {
     static TextEncoding globalUTF8Encoding("UTF-8");

Modified: branches/safari-605-branch/Source/WebCore/platform/text/TextEncoding.h (228835 => 228836)


--- branches/safari-605-branch/Source/WebCore/platform/text/TextEncoding.h	2018-02-20 22:29:56 UTC (rev 228835)
+++ branches/safari-605-branch/Source/WebCore/platform/text/TextEncoding.h	2018-02-20 22:30:01 UTC (rev 228836)
@@ -67,8 +67,6 @@
 const TextEncoding& Latin1Encoding();
 const TextEncoding& UTF16BigEndianEncoding();
 const TextEncoding& UTF16LittleEndianEncoding();
-const TextEncoding& UTF32BigEndianEncoding();
-const TextEncoding& UTF32LittleEndianEncoding();
 WEBCORE_EXPORT const TextEncoding& UTF8Encoding();
 WEBCORE_EXPORT const TextEncoding& WindowsLatin1Encoding();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to