2021-09-26 14:53:28 +01:00
|
|
|
/*
|
2023-03-29 23:41:19 +01:00
|
|
|
* Copyright (c) 2021-2023, Luke Wilde <lukew@serenityos.org>
|
2022-08-16 20:33:17 +01:00
|
|
|
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
2023-12-27 21:00:56 +13:00
|
|
|
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
|
2021-09-26 14:53:28 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-12-13 22:07:04 +00:00
|
|
|
#include <AK/Forward.h>
|
2025-04-15 20:56:03 -04:00
|
|
|
#include <LibGC/Ptr.h>
|
2025-04-25 13:47:08 -04:00
|
|
|
#include <LibGC/RootVector.h>
|
2021-09-26 14:53:28 +01:00
|
|
|
#include <LibJS/Forward.h>
|
2025-07-19 19:35:33 -07:00
|
|
|
#include <LibWeb/Export.h>
|
2025-04-15 20:56:03 -04:00
|
|
|
#include <LibWeb/Forward.h>
|
2021-09-26 14:53:28 +01:00
|
|
|
|
2022-09-24 16:14:37 +01:00
|
|
|
namespace Web::WebIDL {
|
2021-09-26 14:53:28 +01:00
|
|
|
|
2024-11-15 14:47:27 -05:00
|
|
|
bool is_buffer_source_type(JS::Value);
|
|
|
|
GC::Ptr<JS::ArrayBuffer> underlying_buffer_source(JS::Object& buffer_source);
|
2025-07-19 19:35:33 -07:00
|
|
|
WEB_API ErrorOr<ByteBuffer> get_buffer_source_copy(JS::Object const& buffer_source);
|
2021-09-26 14:53:28 +01:00
|
|
|
|
2025-08-02 19:27:29 -04:00
|
|
|
JS::Completion call_user_object_operation(CallbackType& callback, Utf16FlyString const& operation_name, Optional<JS::Value> this_argument, ReadonlySpan<JS::Value> args);
|
2024-11-21 16:58:44 +00:00
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
WEB_API JS::ThrowCompletionOr<String> to_string(JS::VM&, JS::Value);
|
|
|
|
WEB_API JS::ThrowCompletionOr<Utf16String> to_utf16_string(JS::VM&, JS::Value);
|
|
|
|
WEB_API JS::ThrowCompletionOr<String> to_usv_string(JS::VM&, JS::Value);
|
2025-07-25 15:56:36 -04:00
|
|
|
JS::ThrowCompletionOr<Utf16String> to_utf16_usv_string(JS::VM&, JS::Value);
|
2024-11-21 16:58:44 +00:00
|
|
|
JS::ThrowCompletionOr<String> to_byte_string(JS::VM&, JS::Value);
|
2021-10-14 18:03:08 +01:00
|
|
|
|
2024-12-03 22:18:02 +00:00
|
|
|
enum class ExceptionBehavior {
|
|
|
|
NotSpecified,
|
|
|
|
Report,
|
|
|
|
Rethrow,
|
|
|
|
};
|
2025-07-19 19:35:33 -07:00
|
|
|
WEB_API JS::Completion invoke_callback(CallbackType& callback, Optional<JS::Value> this_argument, ExceptionBehavior exception_behavior, ReadonlySpan<JS::Value> args);
|
|
|
|
WEB_API JS::Completion invoke_callback(CallbackType& callback, Optional<JS::Value> this_argument, ReadonlySpan<JS::Value> args);
|
2024-12-03 22:18:02 +00:00
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
WEB_API GC::Ref<Promise> invoke_promise_callback(CallbackType& callback, Optional<JS::Value> this_argument, ReadonlySpan<JS::Value> args);
|
2021-10-14 18:03:08 +01:00
|
|
|
|
2025-06-09 15:48:26 +01:00
|
|
|
JS::Completion construct(CallbackType& callable, ReadonlySpan<JS::Value> args);
|
2023-03-29 23:41:19 +01:00
|
|
|
|
2023-12-27 21:00:56 +13:00
|
|
|
// https://webidl.spec.whatwg.org/#abstract-opdef-integerpart
|
|
|
|
double integer_part(double n);
|
|
|
|
|
|
|
|
enum class EnforceRange {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class Clamp {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
|
|
|
|
// https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
|
|
|
|
template<Integral T>
|
|
|
|
JS::ThrowCompletionOr<T> convert_to_int(JS::VM& vm, JS::Value, EnforceRange enforce_range = EnforceRange::No, Clamp clamp = Clamp::No);
|
|
|
|
|
2025-04-25 13:47:08 -04:00
|
|
|
bool lists_contain_same_elements(GC::Ptr<JS::Array> array, Optional<GC::RootVector<GC::Ref<DOM::Element>>> const& elements);
|
|
|
|
|
2021-09-26 14:53:28 +01:00
|
|
|
}
|