mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Blobs support typed arrays now
This commit is contained in:
parent
730bd5ec80
commit
3df9492dcf
7 changed files with 19 additions and 132 deletions
|
@ -5,7 +5,7 @@
|
|||
use dom::bindings::cell::DomRefCell;
|
||||
use dom::bindings::codegen::Bindings::BlobBinding;
|
||||
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
||||
use dom::bindings::codegen::UnionTypes::BlobOrString;
|
||||
use dom::bindings::codegen::UnionTypes::ArrayBufferOrArrayBufferViewOrBlobOrString;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||
use dom::bindings::root::{Dom, DomRoot};
|
||||
|
@ -43,7 +43,7 @@ pub enum BlobImpl {
|
|||
/// relative positions of current slicing range,
|
||||
/// IMPORTANT: The depth of tree is only two, i.e. the parent Blob must be
|
||||
/// either File-based or Memory-based
|
||||
Sliced(Dom<Blob>, RelativePos),
|
||||
Sliced(Dom<Blob>, RelativePos)
|
||||
}
|
||||
|
||||
impl BlobImpl {
|
||||
|
@ -117,7 +117,7 @@ impl Blob {
|
|||
|
||||
// https://w3c.github.io/FileAPI/#constructorBlob
|
||||
pub fn Constructor(global: &GlobalScope,
|
||||
blobParts: Option<Vec<BlobOrString>>,
|
||||
blobParts: Option<Vec<ArrayBufferOrArrayBufferViewOrBlobOrString>>,
|
||||
blobPropertyBag: &BlobBinding::BlobPropertyBag)
|
||||
-> Fallible<DomRoot<Blob>> {
|
||||
// TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView
|
||||
|
@ -329,18 +329,26 @@ fn read_file(global: &GlobalScope, id: Uuid) -> Result<Vec<u8>, ()> {
|
|||
|
||||
/// Extract bytes from BlobParts, used by Blob and File constructor
|
||||
/// <https://w3c.github.io/FileAPI/#constructorBlob>
|
||||
pub fn blob_parts_to_bytes(blobparts: Vec<BlobOrString>) -> Result<Vec<u8>, ()> {
|
||||
#[allow(unsafe_code)]
|
||||
pub fn blob_parts_to_bytes(mut blobparts: Vec<ArrayBufferOrArrayBufferViewOrBlobOrString>) -> Result<Vec<u8>, ()> {
|
||||
let mut ret = vec![];
|
||||
|
||||
for blobpart in &blobparts {
|
||||
for blobpart in &mut blobparts {
|
||||
match blobpart {
|
||||
&BlobOrString::String(ref s) => {
|
||||
&mut ArrayBufferOrArrayBufferViewOrBlobOrString::String(ref s) => {
|
||||
ret.extend(s.as_bytes());
|
||||
},
|
||||
&BlobOrString::Blob(ref b) => {
|
||||
&mut ArrayBufferOrArrayBufferViewOrBlobOrString::Blob(ref b) => {
|
||||
let bytes = b.get_bytes().unwrap_or(vec![]);
|
||||
ret.extend(bytes);
|
||||
},
|
||||
&mut ArrayBufferOrArrayBufferViewOrBlobOrString::ArrayBuffer(ref mut a) => unsafe {
|
||||
let bytes = a.as_slice();
|
||||
ret.extend(bytes);
|
||||
},
|
||||
&mut ArrayBufferOrArrayBufferViewOrBlobOrString::ArrayBufferView(ref mut a) => unsafe {
|
||||
let bytes = a.as_slice();
|
||||
ret.extend(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::FileBinding;
|
||||
use dom::bindings::codegen::Bindings::FileBinding::FileMethods;
|
||||
use dom::bindings::codegen::UnionTypes::BlobOrString;
|
||||
use dom::bindings::codegen::UnionTypes::ArrayBufferOrArrayBufferViewOrBlobOrString;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
|
@ -60,7 +60,7 @@ impl File {
|
|||
|
||||
// https://w3c.github.io/FileAPI/#file-constructor
|
||||
pub fn Constructor(global: &GlobalScope,
|
||||
fileBits: Vec<BlobOrString>,
|
||||
fileBits: Vec<ArrayBufferOrArrayBufferViewOrBlobOrString>,
|
||||
filename: DOMString,
|
||||
filePropertyBag: &FileBinding::FilePropertyBag)
|
||||
-> Fallible<DomRoot<File>> {
|
||||
|
|
|
@ -22,4 +22,4 @@ dictionary BlobPropertyBag {
|
|||
DOMString type = "";
|
||||
};
|
||||
|
||||
typedef (/*ArrayBuffer or ArrayBufferView or */Blob or DOMString) BlobPart;
|
||||
typedef (ArrayBuffer or ArrayBufferView or Blob or DOMString) BlobPart;
|
||||
|
|
|
@ -4,34 +4,10 @@
|
|||
expected: FAIL
|
||||
bug: https://github.com/servo/rust-mozjs/issues/269
|
||||
|
||||
[ArrayBuffer elements of the blobParts array should be supported.]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Passing typed arrays as elements of the blobParts array should work.]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Passing a Float64Array as element of the blobParts array should work.]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Passing a FrozenArray as the blobParts array should work (FrozenArray<MessagePort>).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/7457
|
||||
|
||||
[Array with two buffers]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Array with two bufferviews]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Array with mixed types]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[options properties should be accessed in lexicographic order.]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,62 +1,2 @@
|
|||
[Blob-slice.html]
|
||||
type: testharness
|
||||
[Slicing test: slice (5,0).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (5,1).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (5,2).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (5,3).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (6,0).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (6,1).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (6,2).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (7,0).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (7,1).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (7,2).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (7,3).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (8,0).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (8,1).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (8,2).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Slicing test: slice (8,3).]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
[File-constructor.html]
|
||||
type: testharness
|
||||
[ArrayBuffer fileBits]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Typed array fileBits]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Various fileBits]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[HTMLDocument in fileBits]
|
||||
expected: FAIL
|
||||
|
||||
[Invalid bits argument: "hello"]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,26 +1,2 @@
|
|||
[Determining-Encoding.html]
|
||||
type: testharness
|
||||
[Blob Determing Encoding with encoding argument]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Blob Determing Encoding with type attribute]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Blob Determing Encoding with UTF-8 BOM]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Blob Determing Encoding without anything implying charset.]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Blob Determing Encoding with UTF-16BE BOM]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
[Blob Determing Encoding with UTF-16LE BOM]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/10911
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue