diff options
author | gterzian <2792687+gterzian@users.noreply.github.com> | 2024-07-11 18:35:33 +0800 |
---|---|---|
committer | gterzian <2792687+gterzian@users.noreply.github.com> | 2024-07-11 18:35:33 +0800 |
commit | d26d95b41901980282a6fc3d4ef3186cb2349562 (patch) | |
tree | 6ca181a08c0c98dfb86b297a72e2cbd6508d6906 | |
parent | 200a2ad8d2cfb0a048da19d480df4ec1da44c3e7 (diff) | |
download | servo-d26d95b41901980282a6fc3d4ef3186cb2349562.tar.gz servo-d26d95b41901980282a6fc3d4ef3186cb2349562.zip |
add default controller init in stream constructor
-rw-r--r-- | components/script/dom/readablestream.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/components/script/dom/readablestream.rs b/components/script/dom/readablestream.rs index ca07a89d3d1..a3ccb02a43c 100644 --- a/components/script/dom/readablestream.rs +++ b/components/script/dom/readablestream.rs @@ -93,7 +93,7 @@ impl ReadableStream { /// <https://streams.spec.whatwg.org/#rs-constructor> pub fn Constructor( cx: SafeJSContext, - _global: &GlobalScope, + global: &GlobalScope, _proto: Option<SafeHandleObject>, underlying_source: Option<*mut JSObject>, _strategy: &QueuingStrategy, @@ -101,7 +101,7 @@ impl ReadableStream { // Step 1 rooted!(in(*cx) let underlying_source_obj = underlying_source.unwrap_or(ptr::null_mut())); // Step 2 - let _underlying_source_dict = if !underlying_source_obj.is_null() { + let underlying_source_dict = if !underlying_source_obj.is_null() { rooted!(in(*cx) let obj_val = ObjectValue(underlying_source_obj.get())); match JsUnderlyingSource::new(cx, obj_val.handle()) { Ok(ConversionResult::Success(val)) => val, @@ -115,8 +115,20 @@ impl ReadableStream { } else { JsUnderlyingSource::empty() }; - // TODO - Err(Error::NotFound) + + let controller = if underlying_source_dict.type_.is_some() { + // TODO: byte controller. + todo!() + } else { + ReadableStreamDefaultController::new( + global, + UnderlyingSourceType::Js(underlying_source_dict), + ) + }; + Ok(ReadableStream::new( + global, + Controller::ReadableStreamDefaultController(controller), + )) } #[allow(crown::unrooted_must_root)] |