mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
updated Blob constructor to use optional, fixes https://github.com/servo/servo/issues/10779
This commit is contained in:
parent
98ae238adf
commit
711c23ae39
3 changed files with 21 additions and 27 deletions
|
@ -117,29 +117,28 @@ impl Blob {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#constructorBlob
|
// https://w3c.github.io/FileAPI/#constructorBlob
|
||||||
pub fn Constructor(global: GlobalRef) -> Fallible<Root<Blob>> {
|
pub fn Constructor(global: GlobalRef,
|
||||||
Ok(Blob::new(global, Vec::new(), ""))
|
blobParts: Option<Vec<BlobOrString>>,
|
||||||
}
|
blobPropertyBag: &BlobBinding::BlobPropertyBag)
|
||||||
|
-> Fallible<Root<Blob>> {
|
||||||
// https://w3c.github.io/FileAPI/#constructorBlob
|
|
||||||
pub fn Constructor_(global: GlobalRef,
|
|
||||||
blobParts: Vec<BlobOrString>,
|
|
||||||
blobPropertyBag: &BlobBinding::BlobPropertyBag)
|
|
||||||
-> Fallible<Root<Blob>> {
|
|
||||||
|
|
||||||
// TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView
|
// TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView
|
||||||
let bytes: Vec<u8> = blobParts.iter()
|
let bytes: Vec<u8> = match blobParts {
|
||||||
.flat_map(|bPart| {
|
None => Vec::new(),
|
||||||
match bPart {
|
Some(blobs) => {
|
||||||
&BlobOrString::String(ref s) => {
|
blobs.iter().flat_map(|bPart| {
|
||||||
UTF_8.encode(s, EncoderTrap::Replace).unwrap()
|
match bPart {
|
||||||
},
|
&BlobOrString::String(ref s) => {
|
||||||
&BlobOrString::Blob(ref b) => {
|
UTF_8.encode(s, EncoderTrap::Replace).unwrap()
|
||||||
b.get_data().get_bytes().to_vec()
|
},
|
||||||
},
|
&BlobOrString::Blob(ref b) => {
|
||||||
}
|
b.get_data().get_bytes().to_vec()
|
||||||
})
|
},
|
||||||
.collect();
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
};
|
||||||
let typeString = if is_ascii_printable(&blobPropertyBag.type_) {
|
let typeString = if is_ascii_printable(&blobPropertyBag.type_) {
|
||||||
&*blobPropertyBag.type_
|
&*blobPropertyBag.type_
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-Blob
|
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-Blob
|
||||||
[Constructor,
|
[Constructor(optional sequence<(/*ArrayBuffer or ArrayBufferView or */Blob or DOMString)> blobParts,
|
||||||
Constructor(sequence<(/*ArrayBuffer or ArrayBufferView or */Blob or DOMString)> blobParts,
|
|
||||||
optional BlobPropertyBag options),
|
optional BlobPropertyBag options),
|
||||||
Exposed=Window/*,Worker*/]
|
Exposed=Window/*,Worker*/]
|
||||||
interface Blob {
|
interface Blob {
|
||||||
|
|
|
@ -46,7 +46,3 @@
|
||||||
bug: https://github.com/servo/servo/issues/10744
|
bug: https://github.com/servo/servo/issues/10744
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Blob constructor with undefined as first argument]
|
|
||||||
bug: https://github.com/servo/servo/issues/10779
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue