summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Olsson <matthewcolsson@gmail.com>2023-04-08 11:49:58 -0700
committerLinus Groh <mail@linusgroh.de>2023-04-14 13:03:34 +0200
commitbd7809cc1825e8836410b8ee4f9187e61d1a2508 (patch)
tree92192e2312b66663d6087f798431723df3a20d7b
parent51abecc8bc747090064f8d85eef8a0eb100c2904 (diff)
downloadserenity-bd7809cc1825e8836410b8ee4f9187e61d1a2508.zip
LibWeb: Mostly implement ReadableByteStreamController.[[ReleaseSteps]]
-rw-r--r--Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp21
-rw-r--r--Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp b/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp
index 1bca783d7a..56b0d19e8c 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp
+++ b/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.cpp
@@ -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 firstPendingPullInto’s 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);
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h b/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h
index a55905249f..ca16d3190a 100644
--- a/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h
+++ b/Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.h
@@ -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&);