aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/readablestreamdefaultcontroller.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/readablestreamdefaultcontroller.rs')
-rw-r--r--components/script/dom/readablestreamdefaultcontroller.rs29
1 files changed, 18 insertions, 11 deletions
diff --git a/components/script/dom/readablestreamdefaultcontroller.rs b/components/script/dom/readablestreamdefaultcontroller.rs
index 66ba3d209c7..c52fb712a03 100644
--- a/components/script/dom/readablestreamdefaultcontroller.rs
+++ b/components/script/dom/readablestreamdefaultcontroller.rs
@@ -540,7 +540,7 @@ impl ReadableStreamDefaultController {
let realm = enter_realm(&*global);
let comp = InRealm::Entered(&realm);
let result = underlying_source
- .call_pull_algorithm(controller, can_gc)
+ .call_pull_algorithm(controller, &global, can_gc)
.unwrap_or_else(|| {
let promise = Promise::new(&global, can_gc);
promise.resolve_native(&(), can_gc);
@@ -563,6 +563,8 @@ impl ReadableStreamDefaultController {
/// <https://streams.spec.whatwg.org/#rs-default-controller-private-cancel>
pub(crate) fn perform_cancel_steps(
&self,
+ cx: SafeJSContext,
+ global: &GlobalScope,
reason: SafeHandleValue,
can_gc: CanGc,
) -> Rc<Promise> {
@@ -573,24 +575,21 @@ impl ReadableStreamDefaultController {
.underlying_source
.get()
.expect("Controller should have a source when the cancel steps are called into.");
- let global = self.global();
-
// Let result be the result of performing this.[[cancelAlgorithm]], passing reason.
let result = underlying_source
- .call_cancel_algorithm(reason, can_gc)
+ .call_cancel_algorithm(cx, global, reason, can_gc)
.unwrap_or_else(|| {
- let promise = Promise::new(&global, can_gc);
+ let promise = Promise::new(global, can_gc);
promise.resolve_native(&(), can_gc);
Ok(promise)
});
let promise = result.unwrap_or_else(|error| {
- let cx = GlobalScope::get_cx();
rooted!(in(*cx) let mut rval = UndefinedValue());
- // TODO: check if `self.global()` is the right globalscope.
+
error
.clone()
- .to_jsval(cx, &self.global(), rval.handle_mut(), can_gc);
- let promise = Promise::new(&global, can_gc);
+ .to_jsval(cx, global, rval.handle_mut(), can_gc);
+ let promise = Promise::new(global, can_gc);
promise.reject_native(&rval.handle(), can_gc);
promise
});
@@ -812,7 +811,7 @@ impl ReadableStreamDefaultController {
}
/// <https://streams.spec.whatwg.org/#readable-stream-default-controller-get-desired-size>
- fn get_desired_size(&self) -> Option<f64> {
+ pub(crate) fn get_desired_size(&self) -> Option<f64> {
let stream = self.stream.get()?;
// If state is "errored", return null.
@@ -832,7 +831,7 @@ impl ReadableStreamDefaultController {
}
/// <https://streams.spec.whatwg.org/#readable-stream-default-controller-can-close-or-enqueue>
- fn can_close_or_enqueue(&self) -> bool {
+ pub(crate) fn can_close_or_enqueue(&self) -> bool {
let Some(stream) = self.stream.get() else {
return false;
};
@@ -865,6 +864,14 @@ impl ReadableStreamDefaultController {
stream.error(e, can_gc);
}
+
+ /// <https://streams.spec.whatwg.org/#rs-default-controller-has-backpressure>
+ #[allow(unused)]
+ pub(crate) fn has_backpressure(&self) -> bool {
+ // If ! ReadableStreamDefaultControllerShouldCallPull(controller) is true, return false.
+ // Otherwise, return true.
+ !self.should_call_pull()
+ }
}
impl ReadableStreamDefaultControllerMethods<crate::DomTypeHolder>