Forráskód Böngészése

LibWeb: Use ArrayBufferView in ReadableStreamBYOBRequest

Shannon Booth 1 éve
szülő
commit
a9a3dcd952

+ 3 - 1
Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.cpp

@@ -1,18 +1,20 @@
 /*
 /*
  * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
  * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
+ * Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
  *
  *
  * SPDX-License-Identifier: BSD-2-Clause
  * SPDX-License-Identifier: BSD-2-Clause
  */
  */
 
 
 #include <LibWeb/Streams/ReadableByteStreamController.h>
 #include <LibWeb/Streams/ReadableByteStreamController.h>
 #include <LibWeb/Streams/ReadableStreamBYOBRequest.h>
 #include <LibWeb/Streams/ReadableStreamBYOBRequest.h>
+#include <LibWeb/WebIDL/Buffers.h>
 
 
 namespace Web::Streams {
 namespace Web::Streams {
 
 
 JS_DEFINE_ALLOCATOR(ReadableStreamBYOBRequest);
 JS_DEFINE_ALLOCATOR(ReadableStreamBYOBRequest);
 
 
 // https://streams.spec.whatwg.org/#rs-byob-request-view
 // https://streams.spec.whatwg.org/#rs-byob-request-view
-JS::GCPtr<JS::TypedArrayBase> ReadableStreamBYOBRequest::view()
+JS::GCPtr<WebIDL::ArrayBufferView> ReadableStreamBYOBRequest::view()
 {
 {
     // 1. Return this.[[view]].
     // 1. Return this.[[view]].
     return m_view;
     return m_view;

+ 4 - 3
Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.h

@@ -1,5 +1,6 @@
 /*
 /*
  * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
  * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
+ * Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
  *
  *
  * SPDX-License-Identifier: BSD-2-Clause
  * SPDX-License-Identifier: BSD-2-Clause
  */
  */
@@ -21,11 +22,11 @@ class ReadableStreamBYOBRequest : public Bindings::PlatformObject {
 public:
 public:
     virtual ~ReadableStreamBYOBRequest() override = default;
     virtual ~ReadableStreamBYOBRequest() override = default;
 
 
-    JS::GCPtr<JS::TypedArrayBase> view();
+    JS::GCPtr<WebIDL::ArrayBufferView> view();
 
 
     void set_controller(JS::GCPtr<ReadableByteStreamController> value) { m_controller = value; }
     void set_controller(JS::GCPtr<ReadableByteStreamController> value) { m_controller = value; }
 
 
-    void set_view(JS::GCPtr<JS::TypedArrayBase> value) { m_view = value; }
+    void set_view(JS::GCPtr<WebIDL::ArrayBufferView> value) { m_view = value; }
 
 
 private:
 private:
     explicit ReadableStreamBYOBRequest(JS::Realm&);
     explicit ReadableStreamBYOBRequest(JS::Realm&);
@@ -38,7 +39,7 @@ private:
 
 
     // https://streams.spec.whatwg.org/#readablestreambyobrequest-view
     // https://streams.spec.whatwg.org/#readablestreambyobrequest-view
     // A typed array representing the destination region to which the controller can write generated data, or null after the BYOB request has been invalidated.
     // A typed array representing the destination region to which the controller can write generated data, or null after the BYOB request has been invalidated.
-    JS::GCPtr<JS::TypedArrayBase> m_view;
+    JS::GCPtr<WebIDL::ArrayBufferView> m_view;
 };
 };
 
 
 }
 }

+ 1 - 2
Userland/Libraries/LibWeb/Streams/ReadableStreamBYOBRequest.idl

@@ -1,8 +1,7 @@
 // https://streams.spec.whatwg.org/#readablestreambyobrequest
 // https://streams.spec.whatwg.org/#readablestreambyobrequest
 [Exposed=*]
 [Exposed=*]
 interface ReadableStreamBYOBRequest {
 interface ReadableStreamBYOBRequest {
-    // FIXME: This should be an ArrayBufferView
-    readonly attribute any view;
+    readonly attribute ArrayBufferView? view;
 
 
     // FIXME: undefined respond([EnforceRange] unsigned long long bytesWritten);
     // FIXME: undefined respond([EnforceRange] unsigned long long bytesWritten);
     // FIXME: undefined respondWithNewView(ArrayBufferView view);
     // FIXME: undefined respondWithNewView(ArrayBufferView view);