Implement TextDecoder and TextEncoder
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Nov 2016 02:11:05 +0000 (02:11 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Nov 2016 02:11:05 +0000 (02:11 +0000)
commit461b1e6d0e22c6cab22d05fda6a355b9a56287f2
treeaa9d6b3daff0b5c1133d32edf200d6f27a01b0e3
parent2544f794a3f65e3f2d34d1cda9f9b337d6a7f731
Implement TextDecoder and TextEncoder
https://bugs.webkit.org/show_bug.cgi?id=163771

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

* web-platform-tests/encoding/api-basics-expected.txt:
* web-platform-tests/encoding/api-invalid-label-expected.txt:
* web-platform-tests/encoding/api-replacement-encodings-expected.txt:
* web-platform-tests/encoding/api-surrogates-utf8-expected.txt:
* web-platform-tests/encoding/idlharness-expected.txt:
* web-platform-tests/encoding/iso-2022-jp-decoder-expected.txt:
* web-platform-tests/encoding/single-byte-decoder-expected.txt:
* web-platform-tests/encoding/textdecoder-byte-order-marks-expected.txt:
* web-platform-tests/encoding/textdecoder-fatal-expected.txt:
* web-platform-tests/encoding/textdecoder-fatal-single-byte-expected.txt:
* web-platform-tests/encoding/textdecoder-fatal-streaming-expected.txt:
* web-platform-tests/encoding/textdecoder-ignorebom-expected.txt:
* web-platform-tests/encoding/textdecoder-labels-expected.txt:
* web-platform-tests/encoding/textdecoder-streaming-expected.txt:
* web-platform-tests/encoding/textdecoder-utf16-surrogates-expected.txt:
* web-platform-tests/encoding/textencoder-constructor-non-utf-expected.txt:
* web-platform-tests/encoding/textencoder-utf16-surrogates-expected.txt:

Source/WebCore:

This API is already implemented by Chrome and Firefox
as specified in https://encoding.spec.whatwg.org/

Covered by newly passing web platform tests.

* features.json:
* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* dom/TextDecoder.cpp: Added.
(WebCore::isEncodingWhitespace):
(WebCore::TextDecoder::create):
(WebCore::TextDecoder::TextDecoder):
(WebCore::TextDecoder::ignoreBOMIfNecessary):
(WebCore::TextDecoder::prependBOMIfNecessary):
(WebCore::codeUnitByteSize):
(WebCore::TextDecoder::decode):
(WebCore::TextDecoder::encoding):
* dom/TextDecoder.h: Added.
(WebCore::TextDecoder::fatal):
(WebCore::TextDecoder::ignoreBOM):
* dom/TextDecoder.idl: Added.
* dom/TextEncoder.cpp: Added.
(WebCore::TextEncoder::TextEncoder):
(WebCore::TextEncoder::encoding):
(WebCore::TextEncoder::encode):
* dom/TextEncoder.h: Added.
(WebCore::TextEncoder::create):
* dom/TextEncoder.idl: Added.

LayoutTests:

* fast/encoding/utf-8-non-ascii-expected.txt: Added.
* fast/encoding/utf-8-non-ascii.html: Added.
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:
* platform/efl/js/dom/global-constructors-attributes-expected.txt:
* platform/gtk/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt:
* platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt:
* platform/mac/js/dom/global-constructors-attributes-expected.txt:
* platform/win/js/dom/global-constructors-attributes-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208872 268f45cc-cd09-0410-ab3c-d52691b4dbfc
39 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/encoding/utf-8-non-ascii-expected.txt [new file with mode: 0644]
LayoutTests/fast/encoding/utf-8-non-ascii.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/encoding/api-basics-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/api-invalid-label-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/api-replacement-encodings-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/api-surrogates-utf8-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/idlharness-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/iso-2022-jp-decoder-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/single-byte-decoder-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textdecoder-byte-order-marks-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textdecoder-fatal-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textdecoder-fatal-single-byte-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textdecoder-fatal-streaming-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textdecoder-ignorebom-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textdecoder-labels-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textdecoder-streaming-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textdecoder-utf16-surrogates-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textencoder-constructor-non-utf-expected.txt
LayoutTests/imported/w3c/web-platform-tests/encoding/textencoder-utf16-surrogates-expected.txt
LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt
LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/TextDecoder.cpp [new file with mode: 0644]
Source/WebCore/dom/TextDecoder.h [new file with mode: 0644]
Source/WebCore/dom/TextDecoder.idl [new file with mode: 0644]
Source/WebCore/dom/TextEncoder.cpp [new file with mode: 0644]
Source/WebCore/dom/TextEncoder.h [new file with mode: 0644]
Source/WebCore/dom/TextEncoder.idl [new file with mode: 0644]
Source/WebCore/features.json