mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-05 09:06:08 +00:00
LibWeb: Implement ReadableStreamPipeTo according to spec
Our existing implementation of stream piping was extremely ad-hoc. It did nothing to handle closed/errored streams, and did not read from or write to streams in a way required by the spec. This new implementation uses a custom JS::Cell to drive the read/write loop.
This commit is contained in:
parent
4010c4643a
commit
eb0a51faf0
Notes:
github-actions[bot]
2025-04-11 16:11:49 +00:00
Author: https://github.com/trflynn89
Commit: eb0a51faf0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4311
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/shannonbooth ✅
33 changed files with 3926 additions and 85 deletions
|
@ -175,8 +175,14 @@ GC::Ref<Promise> upon_rejection(Promise const& promise, GC::Ref<ReactionSteps> s
|
|||
void mark_promise_as_handled(Promise const& promise)
|
||||
{
|
||||
// To mark as handled a Promise<T> promise, set promise.[[Promise]].[[PromiseIsHandled]] to true.
|
||||
auto promise_object = as<JS::Promise>(promise.promise().ptr());
|
||||
promise_object->set_is_handled();
|
||||
auto& promise_object = as<JS::Promise>(*promise.promise());
|
||||
promise_object.set_is_handled();
|
||||
}
|
||||
|
||||
bool is_promise_fulfilled(Promise const& promise)
|
||||
{
|
||||
auto const& promise_object = as<JS::Promise>(*promise.promise());
|
||||
return promise_object.state() == JS::Promise::State::Fulfilled;
|
||||
}
|
||||
|
||||
struct WaitForAllResults : JS::Cell {
|
||||
|
|
|
@ -29,6 +29,7 @@ GC::Ref<Promise> react_to_promise(Promise const&, GC::Ptr<ReactionSteps> on_fulf
|
|||
GC::Ref<Promise> upon_fulfillment(Promise const&, GC::Ref<ReactionSteps>);
|
||||
GC::Ref<Promise> upon_rejection(Promise const&, GC::Ref<ReactionSteps>);
|
||||
void mark_promise_as_handled(Promise const&);
|
||||
bool is_promise_fulfilled(Promise const&);
|
||||
void wait_for_all(JS::Realm&, Vector<GC::Ref<Promise>> const& promises, Function<void(Vector<JS::Value> const&)> success_steps, Function<void(JS::Value)> failure_steps);
|
||||
GC::Ref<Promise> get_promise_for_wait_for_all(JS::Realm&, Vector<GC::Ref<Promise>> const& promises);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue