• jianli@chromium.org's avatar
    Support readAsArrayBuffer in FileReader and FileReaderSync · a8c47de0
    jianli@chromium.org authored
    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: http://svn.webkit.org/repository/webkit/trunk@70904 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    a8c47de0
CMakeLists.txt 68 KB