LibWeb: Mostly implement ReadableByteStreamController.[[ReleaseSteps]]

This commit is contained in:
Matthew Olsson 2023-04-08 11:49:58 -07:00 committed by Linus Groh
parent 51abecc8bc
commit bd7809cc18
Notes: sideshowbarker 2024-07-17 20:19:08 +09:00
2 changed files with 22 additions and 0 deletions

View file

@ -106,6 +106,27 @@ WebIDL::ExceptionOr<void> ReadableByteStreamController::pull_steps(NonnullRefPtr
return {};
}
// https://streams.spec.whatwg.org/#rbs-controller-private-pull
WebIDL::ExceptionOr<void> ReadableByteStreamController::release_steps()
{
auto& vm = this->vm();
// 1. If this.[[pendingPullIntos]] is not empty,
if (!m_pending_pull_intos.is_empty()) {
// 1. Let firstPendingPullInto be this.[[pendingPullIntos]][0].
auto first_pending_pull_into = m_pending_pull_intos.first();
// 2. Set firstPendingPullIntos reader type to "none".
first_pending_pull_into.reader_type = ReaderType::None;
// 3. Set this.[[pendingPullIntos]] to the list « firstPendingPullInto ».
m_pending_pull_intos.clear();
TRY_OR_THROW_OOM(vm, m_pending_pull_intos.try_append(first_pending_pull_into));
}
return {};
}
void ReadableByteStreamController::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);

View file

@ -118,6 +118,7 @@ public:
WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>> cancel_steps(JS::Value reason);
WebIDL::ExceptionOr<void> pull_steps(NonnullRefPtr<ReadRequest>);
WebIDL::ExceptionOr<void> release_steps();
private:
explicit ReadableByteStreamController(JS::Realm&);