Support readAsArrayBuffer in FileReader and FileReaderSync
authorjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Oct 2010 18:23:28 +0000 (18:23 +0000)
committerjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Oct 2010 18:23:28 +0000 (18:23 +0000)
commit3dc024645d328d9d551d99037b7954815c279811
treee3debdd6855f4a9b4e1900ca79387cc415f95e5e
parentbdf8ff5ea2ec772334542bce79b41e7c8ce495ef
Support readAsArrayBuffer in FileReader and FileReaderSync
https://bugs.webkit.org/show_bug.cgi?id=47691

Reviewed by David Levin.

WebCore:

Merge the similar code in FileReader and FileReaderSync into
FileReaderLoader.

Test cases have been added to read-file-test-cases.js.

* Android.jscbindings.mk:
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/v8/custom/V8FileReaderCustom.cpp: Added.
* fileapi/FileReader.cpp:
(WebCore::FileReader::FileReader):
(WebCore::FileReader::readAsArrayBuffer):
(WebCore::FileReader::readAsBinaryString):
(WebCore::FileReader::readAsText):
(WebCore::FileReader::readAsDataURL):
(WebCore::FileReader::readInternal):
(WebCore::FileReader::doAbort):
(WebCore::FileReader::terminate):
(WebCore::FileReader::start):
(WebCore::FileReader::didStartLoading):
(WebCore::FileReader::didReceiveData):
(WebCore::FileReader::didFinishLoading):
(WebCore::FileReader::didFail):
(WebCore::FileReader::fireEvent):
(WebCore::FileReader::arrayBufferResult):
(WebCore::FileReader::stringResult):
* fileapi/FileReader.h:
(WebCore::FileReader::readType):
* fileapi/FileReader.idl:
* fileapi/FileReaderLoader.cpp: Added.
* fileapi/FileReaderLoader.h: Added.
* fileapi/FileReaderLoaderClient.h: Added.
* fileapi/FileReaderSync.cpp:
(WebCore::FileReaderSync::FileReaderSync):
(WebCore::FileReaderSync::readAsArrayBuffer):
(WebCore::FileReaderSync::readAsBinaryString):
(WebCore::FileReaderSync::readAsText):
(WebCore::FileReaderSync::readAsDataURL):
(WebCore::FileReaderSync::startLoading):
* fileapi/FileReaderSync.h:
* fileapi/FileReaderSync.idl:
* html/canvas/ArrayBuffer.cpp:
(WebCore::ArrayBuffer::create):
* html/canvas/ArrayBuffer.h:
* loader/ThreadableLoaderClient.h:

LayoutTests:

* fast/files/read-file-async-expected.txt:
* fast/files/resources/read-common.js:
(readBlobAsArrayBuffer):
(_readBlobAsArrayBufferAsync):
(_readBlobAsArrayBufferSync):
(_readBlobAsBinaryStringSync):
(_readBlobAsTextSync):
(_readBlobAsDataURLSync):
(logResult):
(loaded):
(_toString):
(_isASCIIString):
(_toHexadecimal):
(_getElementAt):
* fast/files/resources/read-file-test-cases.js:
(testReadingNonExistentFileAsArrayBuffer):
(testReadingEmptyFileAsArrayBuffer):
(testReadingUTF8EncodedFileAsArrayBuffer):
(testReadingBinaryFileAsArrayBuffer):
(testMultipleReads):
* fast/files/workers/resources/worker-read-file-sync.js:
(testMultipleReadsSync):
* fast/files/workers/worker-read-blob-sync-expected.txt:
* fast/files/workers/worker-read-file-async-expected.txt:
* fast/files/workers/worker-read-file-sync-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70904 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/files/read-file-async-expected.txt
LayoutTests/fast/files/resources/read-common.js
LayoutTests/fast/files/resources/read-file-test-cases.js
LayoutTests/fast/files/workers/resources/worker-read-file-sync.js
LayoutTests/fast/files/workers/worker-read-blob-sync-expected.txt
LayoutTests/fast/files/workers/worker-read-file-async-expected.txt
LayoutTests/fast/files/workers/worker-read-file-sync-expected.txt
WebCore/Android.jscbindings.mk
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSFileReaderCustom.cpp [new file with mode: 0644]
WebCore/bindings/v8/custom/V8FileReaderCustom.cpp
WebCore/fileapi/FileReader.cpp
WebCore/fileapi/FileReader.h
WebCore/fileapi/FileReader.idl
WebCore/fileapi/FileReaderLoader.cpp [new file with mode: 0644]
WebCore/fileapi/FileReaderLoader.h [new file with mode: 0644]
WebCore/fileapi/FileReaderLoaderClient.h [new file with mode: 0644]
WebCore/fileapi/FileReaderSync.cpp
WebCore/fileapi/FileReaderSync.h
WebCore/fileapi/FileReaderSync.idl
WebCore/html/canvas/ArrayBuffer.cpp
WebCore/html/canvas/ArrayBuffer.h
WebCore/loader/ThreadableLoaderClient.h