mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibWeb: Add a couple ad-hoc BufferSource AOs
These helpers will be used by CompressionStream/DecompressionStream.
This commit is contained in:
parent
35ba7c7e00
commit
c0da3e356a
Notes:
github-actions[bot]
2024-11-17 22:22:07 +00:00
Author: https://github.com/trflynn89
Commit: c0da3e356a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2370
2 changed files with 23 additions and 0 deletions
|
@ -23,6 +23,27 @@
|
||||||
|
|
||||||
namespace Web::WebIDL {
|
namespace Web::WebIDL {
|
||||||
|
|
||||||
|
bool is_buffer_source_type(JS::Value value)
|
||||||
|
{
|
||||||
|
if (!value.is_object())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto const& object = value.as_object();
|
||||||
|
return is<JS::TypedArrayBase>(object) || is<JS::DataView>(object) || is<JS::ArrayBuffer>(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
GC::Ptr<JS::ArrayBuffer> underlying_buffer_source(JS::Object& buffer_source)
|
||||||
|
{
|
||||||
|
if (is<JS::TypedArrayBase>(buffer_source))
|
||||||
|
return static_cast<JS::TypedArrayBase&>(buffer_source).viewed_array_buffer();
|
||||||
|
if (is<JS::DataView>(buffer_source))
|
||||||
|
return static_cast<JS::DataView&>(buffer_source).viewed_array_buffer();
|
||||||
|
if (is<JS::ArrayBuffer>(buffer_source))
|
||||||
|
return static_cast<JS::ArrayBuffer&>(buffer_source);
|
||||||
|
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
// https://webidl.spec.whatwg.org/#dfn-get-buffer-source-copy
|
// https://webidl.spec.whatwg.org/#dfn-get-buffer-source-copy
|
||||||
ErrorOr<ByteBuffer> get_buffer_source_copy(JS::Object const& buffer_source)
|
ErrorOr<ByteBuffer> get_buffer_source_copy(JS::Object const& buffer_source)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
namespace Web::WebIDL {
|
namespace Web::WebIDL {
|
||||||
|
|
||||||
|
bool is_buffer_source_type(JS::Value);
|
||||||
|
GC::Ptr<JS::ArrayBuffer> underlying_buffer_source(JS::Object& buffer_source);
|
||||||
ErrorOr<ByteBuffer> get_buffer_source_copy(JS::Object const& buffer_source);
|
ErrorOr<ByteBuffer> get_buffer_source_copy(JS::Object const& buffer_source);
|
||||||
|
|
||||||
JS::Completion call_user_object_operation(WebIDL::CallbackType& callback, String const& operation_name, Optional<JS::Value> this_argument, GC::MarkedVector<JS::Value> args);
|
JS::Completion call_user_object_operation(WebIDL::CallbackType& callback, String const& operation_name, Optional<JS::Value> this_argument, GC::MarkedVector<JS::Value> args);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue