[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
jianli at chromium.org
jianli at chromium.org
Wed Dec 22 14:56:43 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 9e91d0382e737ae0580be6ac2afe98b6e2ccbcd4
Author: jianli at chromium.org <jianli at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Oct 25 20:45:07 2010 +0000
Support appending an ArrayBuffer object in BlobBuilder
https://bugs.webkit.org/show_bug.cgi?id=47701
Reviewed by David Levin.
WebCore:
Test cases have been added to read-blob-test-cases.js.
* fileapi/BlobBuilder.cpp:
(WebCore::BlobBuilder::getBuffer):
(WebCore::BlobBuilder::append): Removed bool return values since they
weren't used.
* fileapi/BlobBuilder.h:
* fileapi/BlobBuilder.idl:
LayoutTests:
* fast/files/read-blob-async-expected.txt:
* fast/files/resources/read-blob-test-cases.js:
(testReadingSingleArrayBufferBlob):
(testReadingSlicedArrayBufferBlob):
(testReadingMultipleArrayBufferBlob):
(testReadingHybridBlob):
(testReadingSlicedHybridBlob):
(testReadingTripleSlicedHybridBlob):
* fast/files/workers/worker-read-blob-async-expected.txt:
* fast/files/workers/worker-read-blob-sync-expected.txt:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70488 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 667f9d9..b894ff7 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2010-10-25 Jian Li <jianli at chromium.org>
+
+ Reviewed by David Levin.
+
+ Support appending an ArrayBuffer object in BlobBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=47701
+
+ * fast/files/read-blob-async-expected.txt:
+ * fast/files/resources/read-blob-test-cases.js:
+ (testReadingSingleArrayBufferBlob):
+ (testReadingSlicedArrayBufferBlob):
+ (testReadingMultipleArrayBufferBlob):
+ (testReadingHybridBlob):
+ (testReadingSlicedHybridBlob):
+ (testReadingTripleSlicedHybridBlob):
+ * fast/files/workers/worker-read-blob-async-expected.txt:
+ * fast/files/workers/worker-read-blob-sync-expected.txt:
+
2010-10-25 Sam Weinig <sam at webkit.org>
Rubber-stamped by Jon Honeycutt.
diff --git a/LayoutTests/fast/files/read-blob-async-expected.txt b/LayoutTests/fast/files/read-blob-async-expected.txt
index 099b1be..94c291d 100644
--- a/LayoutTests/fast/files/read-blob-async-expected.txt
+++ b/LayoutTests/fast/files/read-blob-async-expected.txt
@@ -74,6 +74,15 @@ readyState: 2
result size: 29
result: data:type/foo;base64,Rmlyc3Q=
Received loadend event
+Test reading a blob containing single ArrayBuffer
+readyState: 0
+Received loadstart event
+readyState: 1
+Received load event
+readyState: 2
+result size: 9
+result: 0x0 0x1 0x2 0x80 0x81 0x82 0xfd 0xfe 0xff
+Received loadend event
Test reading a blob containing sliced file
readyState: 0
Received loadstart event
@@ -92,6 +101,15 @@ readyState: 2
result size: 4
result: irst
Received loadend event
+Test reading a blob containing sliced ArrayBuffer
+readyState: 0
+Received loadstart event
+readyState: 1
+Received load event
+readyState: 2
+result size: 8
+result: 0x1 0x2 0x80 0x81 0x82 0xfd 0xfe 0xff
+Received loadend event
Test reading a blob containing multiple files
readyState: 0
Received loadstart event
@@ -110,14 +128,23 @@ readyState: 2
result size: 16
result: FirstSecondThird
Received loadend event
+Test reading a blob containing multiple ArrayBuffer
+readyState: 0
+Received loadstart event
+readyState: 1
+Received load event
+readyState: 2
+result size: 9
+result: 0x0 0x1 0x2 0x80 0x81 0x82 0xfd 0xfe 0xff
+Received loadend event
Test reading a hybrid blob
readyState: 0
Received loadstart event
readyState: 1
Received load event
readyState: 2
-result size: 35
-result: FirstHelloSecondWonderfulWorldThird
+result size: 38
+result: FirstHelloSecondWonderfulWorldThird012
Received loadend event
Test reading a sliced hybrid blob
readyState: 0
@@ -135,7 +162,7 @@ readyState: 1
Received load event
readyState: 2
result size: 30
-result: ondWonderfulWorldThirdFooloSec
+result: ondWonderfulWorldThird012Foolo
Received loadend event
DONE
diff --git a/LayoutTests/fast/files/resources/read-blob-test-cases.js b/LayoutTests/fast/files/resources/read-blob-test-cases.js
index a579eaa..22bf048 100644
--- a/LayoutTests/fast/files/resources/read-blob-test-cases.js
+++ b/LayoutTests/fast/files/resources/read-blob-test-cases.js
@@ -8,10 +8,13 @@ var testCases = [
"testReadingSingleTextBlob",
"testReadingSingleTextBlobAsDataURL",
"testReadingSingleTextBlobAsDataURL2",
+ "testReadingSingleArrayBufferBlob",
"testReadingSlicedFileBlob",
"testReadingSlicedTextBlob",
+ "testReadingSlicedArrayBufferBlob",
"testReadingMultipleFileBlob",
"testReadingMultipleTextBlob",
+ "testReadingMultipleArrayBufferBlob",
"testReadingHybridBlob",
"testReadingSlicedHybridBlob",
"testReadingTripleSlicedHybridBlob",
@@ -91,6 +94,14 @@ function testReadingSingleTextBlobAsDataURL2(testFiles)
readBlobAsDataURL(testFiles, blob);
}
+function testReadingSingleArrayBufferBlob(testFiles)
+{
+ log("Test reading a blob containing single ArrayBuffer");
+ var array = new Uint8Array([0, 1, 2, 128, 129, 130, 253, 254, 255]);
+ var blob = buildBlob([array.buffer]);
+ readBlobAsBinaryString(testFiles, blob);
+}
+
function testReadingSlicedFileBlob(testFiles)
{
log("Test reading a blob containing sliced file");
@@ -106,6 +117,15 @@ function testReadingSlicedTextBlob(testFiles)
readBlobAsBinaryString(testFiles, blob);
}
+function testReadingSlicedArrayBufferBlob(testFiles)
+{
+ log("Test reading a blob containing sliced ArrayBuffer");
+ var array = new Uint8Array([0, 1, 2, 128, 129, 130, 253, 254, 255]);
+ var blob = buildBlob([array.buffer])
+ blob = blob.slice(1, 10);
+ readBlobAsBinaryString(testFiles, blob);
+}
+
function testReadingMultipleFileBlob(testFiles)
{
log("Test reading a blob containing multiple files");
@@ -120,17 +140,29 @@ function testReadingMultipleTextBlob(testFiles)
readBlobAsBinaryString(testFiles, blob);
}
+function testReadingMultipleArrayBufferBlob(testFiles)
+{
+ log("Test reading a blob containing multiple ArrayBuffer");
+ var array1 = new Uint8Array([0, 1, 2]);
+ var array2 = new Uint8Array([128, 129, 130]);
+ var array3 = new Uint8Array([253, 254, 255]);
+ var blob = buildBlob([array1.buffer, array2.buffer, array3.buffer]);
+ readBlobAsBinaryString(testFiles, blob);
+}
+
function testReadingHybridBlob(testFiles)
{
log("Test reading a hybrid blob");
- var blob = buildBlob(['First', testFiles['file1'], 'Second', testFiles['file2'], testFiles['file3'], 'Third']);
+ var array = new Uint8Array([48, 49, 50]);
+ var blob = buildBlob(['First', testFiles['file1'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array.buffer]);
readBlobAsBinaryString(testFiles, blob);
}
function testReadingSlicedHybridBlob(testFiles)
{
log("Test reading a sliced hybrid blob");
- var blob = buildBlob(['First', testFiles['file1'], 'Second', testFiles['file2'], testFiles['file3'], 'Third']);
+ var array = new Uint8Array([48, 49, 50]);
+ var blob = buildBlob(['First', testFiles['file1'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array.buffer]);
var blob = blob.slice(7, 12);
readBlobAsBinaryString(testFiles, blob);
}
@@ -139,7 +171,8 @@ function testReadingTripleSlicedHybridBlob(testFiles)
{
log("Test reading a triple-sliced hybrid blob");
var builder = new BlobBuilder();
- var blob = buildBlob(['First', testFiles['file1'].slice(1, 10), testFiles['empty-file'], 'Second', testFiles['file2'], testFiles['file3'], 'Third'], undefined, builder);
+ var array = new Uint8Array([48, 49, 50]);
+ var blob = buildBlob(['First', testFiles['file1'].slice(1, 10), testFiles['empty-file'], 'Second', testFiles['file2'], testFiles['file3'], 'Third', array.buffer], undefined, builder);
var blob = blob.slice(7, 12);
var blob2 = buildBlob(['Foo', blob, 'Bar'], undefined, builder);
var blob2 = blob2.slice(12, 30);
diff --git a/LayoutTests/fast/files/workers/worker-read-blob-async-expected.txt b/LayoutTests/fast/files/workers/worker-read-blob-async-expected.txt
index 689e7b2..db6579a 100644
--- a/LayoutTests/fast/files/workers/worker-read-blob-async-expected.txt
+++ b/LayoutTests/fast/files/workers/worker-read-blob-async-expected.txt
@@ -75,6 +75,15 @@ readyState: 2
result size: 29
result: data:type/foo;base64,Rmlyc3Q=
Received loadend event
+Test reading a blob containing single ArrayBuffer
+readyState: 0
+Received loadstart event
+readyState: 1
+Received load event
+readyState: 2
+result size: 9
+result: 0x0 0x1 0x2 0x80 0x81 0x82 0xfd 0xfe 0xff
+Received loadend event
Test reading a blob containing sliced file
readyState: 0
Received loadstart event
@@ -93,6 +102,15 @@ readyState: 2
result size: 4
result: irst
Received loadend event
+Test reading a blob containing sliced ArrayBuffer
+readyState: 0
+Received loadstart event
+readyState: 1
+Received load event
+readyState: 2
+result size: 8
+result: 0x1 0x2 0x80 0x81 0x82 0xfd 0xfe 0xff
+Received loadend event
Test reading a blob containing multiple files
readyState: 0
Received loadstart event
@@ -111,14 +129,23 @@ readyState: 2
result size: 16
result: FirstSecondThird
Received loadend event
+Test reading a blob containing multiple ArrayBuffer
+readyState: 0
+Received loadstart event
+readyState: 1
+Received load event
+readyState: 2
+result size: 9
+result: 0x0 0x1 0x2 0x80 0x81 0x82 0xfd 0xfe 0xff
+Received loadend event
Test reading a hybrid blob
readyState: 0
Received loadstart event
readyState: 1
Received load event
readyState: 2
-result size: 35
-result: FirstHelloSecondWonderfulWorldThird
+result size: 38
+result: FirstHelloSecondWonderfulWorldThird012
Received loadend event
Test reading a sliced hybrid blob
readyState: 0
@@ -136,7 +163,7 @@ readyState: 1
Received load event
readyState: 2
result size: 30
-result: ondWonderfulWorldThirdFooloSec
+result: ondWonderfulWorldThird012Foolo
Received loadend event
DONE
diff --git a/LayoutTests/fast/files/workers/worker-read-blob-sync-expected.txt b/LayoutTests/fast/files/workers/worker-read-blob-sync-expected.txt
index f0ec0f1..2ce59b2 100644
--- a/LayoutTests/fast/files/workers/worker-read-blob-sync-expected.txt
+++ b/LayoutTests/fast/files/workers/worker-read-blob-sync-expected.txt
@@ -18,19 +18,25 @@ Test reading a blob containing single text as data URL
data:base64,Rmlyc3Q=
Test reading a blob containing single text as data URL (optional content type provided)
data:type/foo;base64,Rmlyc3Q=
+Test reading a blob containing single ArrayBuffer
+0x0 0x1 0x2 0x80 0x81 0x82 0xfd 0xfe 0xff
Test reading a blob containing sliced file
onder
Test reading a blob containing sliced text
irst
+Test reading a blob containing sliced ArrayBuffer
+0x1 0x2 0x80 0x81 0x82 0xfd 0xfe 0xff
Test reading a blob containing multiple files
HelloWonderfulWorld
Test reading a blob containing multiple texts
FirstSecondThird
+Test reading a blob containing multiple ArrayBuffer
+0x0 0x1 0x2 0x80 0x81 0x82 0xfd 0xfe 0xff
Test reading a hybrid blob
-FirstHelloSecondWonderfulWorldThird
+FirstHelloSecondWonderfulWorldThird012
Test reading a sliced hybrid blob
lloSecondWon
Test reading a triple-sliced hybrid blob
-ondWonderfulWorldThirdFooloSec
+ondWonderfulWorldThird012Foolo
DONE
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d74a525..c29a99b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2010-10-25 Jian Li <jianli at chromium.org>
+
+ Reviewed by David Levin.
+
+ Support appending an ArrayBuffer object in BlobBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=47701
+
+ Test cases have been added to read-blob-test-cases.js.
+
+ * fileapi/BlobBuilder.cpp:
+ (WebCore::BlobBuilder::getBuffer):
+ (WebCore::BlobBuilder::append): Removed bool return values since they
+ weren't used.
+ * fileapi/BlobBuilder.h:
+ * fileapi/BlobBuilder.idl:
+
2010-10-25 No'am Rosenthal <noam.rosenthal at nokia.com>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebCore/fileapi/BlobBuilder.cpp b/WebCore/fileapi/BlobBuilder.cpp
index 69443a5..9406899 100644
--- a/WebCore/fileapi/BlobBuilder.cpp
+++ b/WebCore/fileapi/BlobBuilder.cpp
@@ -32,12 +32,16 @@
#include "BlobBuilder.h"
+#include "ArrayBuffer.h"
#include "Blob.h"
#include "ExceptionCode.h"
#include "File.h"
#include "LineEnding.h"
#include "TextEncoding.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/Vector.h>
#include <wtf/text/AtomicString.h>
+#include <wtf/text/CString.h>
namespace WebCore {
@@ -46,46 +50,57 @@ BlobBuilder::BlobBuilder()
{
}
-bool BlobBuilder::append(const String& text, const String& endingType, ExceptionCode& ec)
+Vector<char>& BlobBuilder::getBuffer()
+{
+ // If the last item is not a data item, create one. Otherwise, we simply append the new string to the last data item.
+ if (m_items.isEmpty() || m_items[m_items.size() - 1].type != BlobDataItem::Data)
+ m_items.append(BlobDataItem(RawData::create()));
+
+ return *m_items[m_items.size() - 1].data->mutableData();
+}
+
+void BlobBuilder::append(const String& text, const String& endingType, ExceptionCode& ec)
{
bool isEndingTypeTransparent = endingType == "transparent";
bool isEndingTypeNative = endingType == "native";
if (!endingType.isEmpty() && !isEndingTypeTransparent && !isEndingTypeNative) {
ec = SYNTAX_ERR;
- return 0;
+ return;
}
CString utf8Text = UTF8Encoding().encode(text.characters(), text.length(), EntitiesForUnencodables);
- // If the last item is not a data item, create one. Otherwise, we simply append the new string to the last data item.
- if (m_items.isEmpty() || m_items[m_items.size() - 1].type != BlobDataItem::Data)
- m_items.append(BlobDataItem(RawData::create()));
-
- if (!utf8Text.isNull()) {
- Vector<char>& buffer = *m_items[m_items.size() - 1].data->mutableData();
- size_t oldSize = buffer.size();
+ Vector<char>& buffer = getBuffer();
+ size_t oldSize = buffer.size();
- if (isEndingTypeNative)
- normalizeLineEndingsToNative(utf8Text, buffer);
- else
- buffer.append(utf8Text.data(), utf8Text.length());
- m_size += buffer.size() - oldSize;
- }
+ if (isEndingTypeNative)
+ normalizeLineEndingsToNative(utf8Text, buffer);
+ else
+ buffer.append(utf8Text.data(), utf8Text.length());
+ m_size += buffer.size() - oldSize;
+}
- return true;
+void BlobBuilder::append(const String& text, ExceptionCode& ec)
+{
+ append(text, String(), ec);
}
-bool BlobBuilder::append(const String& text, ExceptionCode& ec)
+#if ENABLE(BLOB)
+void BlobBuilder::append(ArrayBuffer* arrayBuffer)
{
- return append(text, String(), ec);
+ Vector<char>& buffer = getBuffer();
+ size_t oldSize = buffer.size();
+ buffer.append(static_cast<const char*>(arrayBuffer->data()), arrayBuffer->byteLength());
+ m_size += buffer.size() - oldSize;
}
+#endif
-bool BlobBuilder::append(PassRefPtr<Blob> blob)
+void BlobBuilder::append(Blob* blob)
{
if (blob->isFile()) {
// If the blob is file that is not snapshoted, capture the snapshot now.
// FIXME: This involves synchronous file operation. We need to figure out how to make it asynchronous.
- File* file = static_cast<File*>(blob.get());
+ File* file = static_cast<File*>(blob);
long long snapshotSize;
double snapshotModificationTime;
file->captureSnapshot(snapshotSize, snapshotModificationTime);
@@ -97,7 +112,6 @@ bool BlobBuilder::append(PassRefPtr<Blob> blob)
m_size += blobSize;
m_items.append(BlobDataItem(blob->url(), 0, blobSize));
}
- return true;
}
PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType)
diff --git a/WebCore/fileapi/BlobBuilder.h b/WebCore/fileapi/BlobBuilder.h
index a981e31..db46591 100644
--- a/WebCore/fileapi/BlobBuilder.h
+++ b/WebCore/fileapi/BlobBuilder.h
@@ -32,14 +32,12 @@
#define BlobBuilder_h
#include "BlobData.h"
-#include "PlatformString.h"
-#include <wtf/PassRefPtr.h>
+#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-#include <wtf/text/CString.h>
namespace WebCore {
+class ArrayBuffer;
class Blob;
class TextEncoding;
@@ -49,15 +47,20 @@ class BlobBuilder : public RefCounted<BlobBuilder> {
public:
static PassRefPtr<BlobBuilder> create() { return adoptRef(new BlobBuilder()); }
- bool append(PassRefPtr<Blob>);
- bool append(const String& text, ExceptionCode&);
- bool append(const String& text, const String& ending, ExceptionCode&);
+ void append(Blob*);
+ void append(const String& text, ExceptionCode&);
+ void append(const String& text, const String& ending, ExceptionCode&);
+#if ENABLE(BLOB)
+ void append(ArrayBuffer*);
+#endif
PassRefPtr<Blob> getBlob(const String& contentType = String());
private:
BlobBuilder();
+ Vector<char>& getBuffer();
+
long long m_size;
BlobDataItemList m_items;
};
diff --git a/WebCore/fileapi/BlobBuilder.idl b/WebCore/fileapi/BlobBuilder.idl
index 0da9314..8f5049f 100644
--- a/WebCore/fileapi/BlobBuilder.idl
+++ b/WebCore/fileapi/BlobBuilder.idl
@@ -38,6 +38,9 @@ module html {
Blob getBlob(in [Optional, ConvertUndefinedOrNullToNullString] DOMString contentType);
#endif
void append(in Blob blob);
+#if defined(ENABLE_BLOB) && ENABLE_BLOB
+ void append(in ArrayBuffer arrayBuffer);
+#endif
void append(in DOMString value, in [Optional, ConvertUndefinedOrNullToNullString] DOMString endings) raises (DOMException);
};
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list