mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #11768 - achals:blob-string, r=Ms2ger
Update Blob::{new, new_inherited} to take Strings <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11762. <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because no logic changes, only interface changes. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11768) <!-- Reviewable:end -->
This commit is contained in:
commit
9208b8e214
5 changed files with 13 additions and 14 deletions
|
@ -17,7 +17,6 @@ use ipc_channel::ipc;
|
|||
use net_traits::filemanager_thread::{FileManagerThreadMsg, SelectedFileId};
|
||||
use num_traits::ToPrimitive;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
use std::cmp::{max, min};
|
||||
use std::sync::Arc;
|
||||
|
@ -127,16 +126,16 @@ pub struct Blob {
|
|||
}
|
||||
|
||||
impl Blob {
|
||||
pub fn new(global: GlobalRef, blob_impl: BlobImpl, typeString: &str) -> Root<Blob> {
|
||||
pub fn new(global: GlobalRef, blob_impl: BlobImpl, typeString: String) -> Root<Blob> {
|
||||
let boxed_blob = box Blob::new_inherited(blob_impl, typeString);
|
||||
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn new_inherited(blob_impl: BlobImpl, typeString: &str) -> Blob {
|
||||
pub fn new_inherited(blob_impl: BlobImpl, typeString: String) -> Blob {
|
||||
Blob {
|
||||
reflector_: Reflector::new(),
|
||||
blob_impl: blob_impl,
|
||||
typeString: typeString.to_owned(),
|
||||
typeString: typeString,
|
||||
isClosed_: Cell::new(false),
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +155,7 @@ impl Blob {
|
|||
};
|
||||
|
||||
let slice = DataSlice::from_bytes(bytes);
|
||||
Ok(Blob::new(global, BlobImpl::new_from_slice(slice), &blobPropertyBag.get_typestring()))
|
||||
Ok(Blob::new(global, BlobImpl::new_from_slice(slice), blobPropertyBag.get_typestring()))
|
||||
}
|
||||
|
||||
/// Get a slice to inner data, this might incur synchronous read and caching
|
||||
|
@ -252,7 +251,7 @@ impl BlobMethods for Blob {
|
|||
let global = self.global();
|
||||
let bytes = self.get_slice_or_empty().bytes.clone();
|
||||
let slice = DataSlice::new(bytes, start, end);
|
||||
Blob::new(global.r(), BlobImpl::new_from_slice(slice), &relativeContentType)
|
||||
Blob::new(global.r(), BlobImpl::new_from_slice(slice), relativeContentType.into())
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#dfn-isClosed
|
||||
|
|
|
@ -26,7 +26,7 @@ impl File {
|
|||
fn new_inherited(blob_impl: BlobImpl, name: DOMString,
|
||||
modified: Option<i64>, typeString: &str) -> File {
|
||||
File {
|
||||
blob: Blob::new_inherited(blob_impl, typeString),
|
||||
blob: Blob::new_inherited(blob_impl, typeString.to_owned()),
|
||||
name: name,
|
||||
// https://w3c.github.io/FileAPI/#dfn-lastModified
|
||||
modified: match modified {
|
||||
|
|
|
@ -101,7 +101,7 @@ impl TestBindingMethods for TestBinding {
|
|||
fn EnumAttribute(&self) -> TestEnum { TestEnum::_empty }
|
||||
fn SetEnumAttribute(&self, _: TestEnum) {}
|
||||
fn InterfaceAttribute(&self) -> Root<Blob> {
|
||||
Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), "")
|
||||
Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), "".to_owned())
|
||||
}
|
||||
fn SetInterfaceAttribute(&self, _: &Blob) {}
|
||||
fn UnionAttribute(&self) -> HTMLElementOrLong { HTMLElementOrLong::Long(0) }
|
||||
|
@ -179,7 +179,7 @@ impl TestBindingMethods for TestBinding {
|
|||
fn SetAttr_to_automatically_rename(&self, _: DOMString) {}
|
||||
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
|
||||
fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> {
|
||||
Some(Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), ""))
|
||||
Some(Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), "".to_owned()))
|
||||
}
|
||||
fn SetInterfaceAttributeNullable(&self, _: Option<&Blob>) {}
|
||||
fn GetInterfaceAttributeWeak(&self) -> Option<Root<URL>> {
|
||||
|
@ -230,7 +230,7 @@ impl TestBindingMethods for TestBinding {
|
|||
fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) }
|
||||
fn ReceiveEnum(&self) -> TestEnum { TestEnum::_empty }
|
||||
fn ReceiveInterface(&self) -> Root<Blob> {
|
||||
Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), "")
|
||||
Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), "".to_owned())
|
||||
}
|
||||
fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||
fn ReceiveObject(&self, _: *mut JSContext) -> *mut JSObject { panic!() }
|
||||
|
@ -247,7 +247,7 @@ impl TestBindingMethods for TestBinding {
|
|||
}
|
||||
fn ReceiveSequence(&self) -> Vec<i32> { vec![1] }
|
||||
fn ReceiveInterfaceSequence(&self) -> Vec<Root<Blob>> {
|
||||
vec![Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), "")]
|
||||
vec![Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), "".to_owned())]
|
||||
}
|
||||
|
||||
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
|
||||
|
@ -268,7 +268,7 @@ impl TestBindingMethods for TestBinding {
|
|||
fn ReceiveNullableByteString(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
|
||||
fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
|
||||
fn ReceiveNullableInterface(&self) -> Option<Root<Blob>> {
|
||||
Some(Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), ""))
|
||||
Some(Blob::new(self.global().r(), BlobImpl::new_from_empty_slice(), "".to_owned()))
|
||||
}
|
||||
fn ReceiveNullableObject(&self, _: *mut JSContext) -> *mut JSObject { ptr::null_mut() }
|
||||
fn ReceiveNullableUnion(&self) -> Option<HTMLElementOrLong> {
|
||||
|
|
|
@ -592,7 +592,7 @@ impl Runnable for MessageReceivedTask {
|
|||
match ws.binary_type.get() {
|
||||
BinaryType::Blob => {
|
||||
let slice = DataSlice::from_bytes(data);
|
||||
let blob = Blob::new(global.r(), BlobImpl::new_from_slice(slice), "");
|
||||
let blob = Blob::new(global.r(), BlobImpl::new_from_slice(slice), "".to_owned());
|
||||
blob.to_jsval(cx, message.handle_mut());
|
||||
}
|
||||
BinaryType::Arraybuffer => {
|
||||
|
|
|
@ -1111,7 +1111,7 @@ impl XMLHttpRequest {
|
|||
|
||||
// Step 3, 4
|
||||
let slice = DataSlice::from_bytes(self.response.borrow().to_vec());
|
||||
let blob = Blob::new(self.global().r(), BlobImpl::new_from_slice(slice), &mime);
|
||||
let blob = Blob::new(self.global().r(), BlobImpl::new_from_slice(slice), mime);
|
||||
self.response_blob.set(Some(blob.r()));
|
||||
blob
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue