mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
integrate readablestream with fetch and blob
This commit is contained in:
parent
0281acea95
commit
bd5796c90b
74 changed files with 2219 additions and 899 deletions
|
@ -14,14 +14,18 @@ use crate::dom::bindings::str::DOMString;
|
|||
use crate::dom::bindings::structuredclone::StructuredDataHolder;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::promise::Promise;
|
||||
use crate::dom::readablestream::ReadableStream;
|
||||
use crate::realms::{AlreadyInRealm, InRealm};
|
||||
use crate::script_runtime::JSContext;
|
||||
use dom_struct::dom_struct;
|
||||
use encoding_rs::UTF_8;
|
||||
use js::jsapi::JSObject;
|
||||
use msg::constellation_msg::{BlobId, BlobIndex, PipelineNamespaceId};
|
||||
use net_traits::filemanager_thread::RelativePos;
|
||||
use script_traits::serializable::BlobImpl;
|
||||
use std::collections::HashMap;
|
||||
use std::num::NonZeroU32;
|
||||
use std::ptr::NonNull;
|
||||
use std::rc::Rc;
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -34,13 +38,7 @@ pub struct Blob {
|
|||
|
||||
impl Blob {
|
||||
pub fn new(global: &GlobalScope, blob_impl: BlobImpl) -> DomRoot<Blob> {
|
||||
let dom_blob = reflect_dom_object(
|
||||
Box::new(Blob {
|
||||
reflector_: Reflector::new(),
|
||||
blob_id: blob_impl.blob_id(),
|
||||
}),
|
||||
global,
|
||||
);
|
||||
let dom_blob = reflect_dom_object(Box::new(Blob::new_inherited(&blob_impl)), global);
|
||||
global.track_blob(&dom_blob, blob_impl);
|
||||
dom_blob
|
||||
}
|
||||
|
@ -89,6 +87,11 @@ impl Blob {
|
|||
pub fn get_blob_url_id(&self) -> Uuid {
|
||||
self.global().get_blob_url_id(&self.blob_id)
|
||||
}
|
||||
|
||||
/// <https://w3c.github.io/FileAPI/#blob-get-stream>
|
||||
pub fn get_stream(&self) -> DomRoot<ReadableStream> {
|
||||
self.global().get_blob_stream(&self.blob_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl Serializable for Blob {
|
||||
|
@ -213,6 +216,11 @@ impl BlobMethods for Blob {
|
|||
DOMString::from(self.type_string())
|
||||
}
|
||||
|
||||
// <https://w3c.github.io/FileAPI/#blob-get-stream>
|
||||
fn Stream(&self, _cx: JSContext) -> NonNull<JSObject> {
|
||||
self.get_stream().get_js_stream()
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#slice-method-algo
|
||||
fn Slice(
|
||||
&self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue