mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibWeb: Move IDLAbstractOperations from Bindings/ to WebIDL/
This commit is contained in:
parent
4f73851afc
commit
6480faacb6
Notes:
sideshowbarker
2024-07-17 07:08:37 +09:00
Author: https://github.com/linusg
Commit: 6480faacb6
Pull-request: https://github.com/SerenityOS/serenity/pull/15345
Reviewed-by: https://github.com/awesomekling ✅
13 changed files with 28 additions and 28 deletions
|
@ -11,7 +11,6 @@
|
|||
#include <LibJS/Runtime/FinalizationRegistry.h>
|
||||
#include <LibJS/Runtime/NativeFunction.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/Bindings/LocationObject.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Bindings/WindowProxy.h>
|
||||
|
@ -22,6 +21,7 @@
|
|||
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
|
@ -380,7 +380,7 @@ void queue_mutation_observer_microtask(DOM::Document& document)
|
|||
MUST(wrapped_records->create_data_property(property_index, record.ptr()));
|
||||
}
|
||||
|
||||
auto result = IDL::invoke_callback(callback, mutation_observer.ptr(), wrapped_records, mutation_observer.ptr());
|
||||
auto result = WebIDL::invoke_callback(callback, mutation_observer.ptr(), wrapped_records, mutation_observer.ptr());
|
||||
if (result.is_abrupt())
|
||||
HTML::report_exception(result);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ include(libweb_generators)
|
|||
set(SOURCES
|
||||
Bindings/AudioConstructor.cpp
|
||||
Bindings/CSSNamespace.cpp
|
||||
Bindings/IDLAbstractOperations.cpp
|
||||
Bindings/IDLOverloadResolution.cpp
|
||||
Bindings/ImageConstructor.cpp
|
||||
Bindings/LegacyPlatformObject.cpp
|
||||
|
@ -412,6 +411,7 @@ set(SOURCES
|
|||
WebGL/WebGLContextEvent.cpp
|
||||
WebGL/WebGLRenderingContext.cpp
|
||||
WebGL/WebGLRenderingContextBase.cpp
|
||||
WebIDL/AbstractOperations.cpp
|
||||
WebIDL/CallbackType.cpp
|
||||
WebSockets/WebSocket.cpp
|
||||
XHR/EventNames.cpp
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
#include <LibCrypto/Hash/HashManager.h>
|
||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||
#include <LibJS/Runtime/Promise.h>
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::Crypto {
|
||||
|
||||
|
@ -35,7 +35,7 @@ JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object
|
|||
// 1. Let algorithm be the algorithm parameter passed to the digest() method.
|
||||
|
||||
// 2. Let data be the result of getting a copy of the bytes held by the data parameter passed to the digest() method.
|
||||
auto data_buffer_or_error = Bindings::IDL::get_buffer_source_copy(*data.cell());
|
||||
auto data_buffer_or_error = WebIDL::get_buffer_source_copy(*data.cell());
|
||||
if (data_buffer_or_error.is_error()) {
|
||||
auto error = DOM::OperationError::create(global_object(), "Failed to copy bytes from ArrayBuffer");
|
||||
auto* promise = JS::Promise::create(realm);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <AK/TypeCasts.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/DOM/AbortSignal.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
@ -21,6 +20,7 @@
|
|||
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/UIEvents/MouseEvent.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -109,7 +109,7 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<JS::Handle<DOM::DOMEvent
|
|||
// FIXME: These should be wrapped for us in call_user_object_operation, but it currently doesn't do that.
|
||||
auto* this_value = event.current_target().ptr();
|
||||
auto* wrapped_event = &event;
|
||||
auto result = Bindings::IDL::call_user_object_operation(callback, "handleEvent", this_value, wrapped_event);
|
||||
auto result = WebIDL::call_user_object_operation(callback, "handleEvent", this_value, wrapped_event);
|
||||
|
||||
// If this throws an exception, then:
|
||||
if (result.is_error()) {
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include <LibJS/Runtime/ObjectEnvironment.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/EventTargetPrototype.h>
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/DOM/AbortSignal.h>
|
||||
#include <LibWeb/DOM/DOMEventListener.h>
|
||||
|
@ -32,6 +31,7 @@
|
|||
#include <LibWeb/HTML/HTMLFrameSetElement.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/UIEvents/EventNames.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -635,7 +635,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
// calls directly into the callback without considering things such as proxies, it is a waste. However, if it observable, then we must reuse the this_value that was given to the callback.
|
||||
auto* this_value = error_event.current_target().ptr();
|
||||
|
||||
return_value_or_error = Bindings::IDL::invoke_callback(*callback, this_value, wrapped_message, wrapped_filename, wrapped_lineno, wrapped_colno, error_event.error());
|
||||
return_value_or_error = WebIDL::invoke_callback(*callback, this_value, wrapped_message, wrapped_filename, wrapped_lineno, wrapped_colno, error_event.error());
|
||||
} else {
|
||||
// -> Otherwise
|
||||
// Invoke callback with one argument, the value of which is the Event object event, with the callback this value set to event's currentTarget. Let return value be the callback's return value. [WEBIDL]
|
||||
|
@ -646,7 +646,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
// FIXME: The comments about this in the special_error_event_handling path also apply here.
|
||||
auto* this_value = event.current_target().ptr();
|
||||
|
||||
return_value_or_error = Bindings::IDL::invoke_callback(*callback, this_value, wrapped_event);
|
||||
return_value_or_error = WebIDL::invoke_callback(*callback, this_value, wrapped_event);
|
||||
}
|
||||
|
||||
// If an exception gets thrown by the callback, end these steps and allow the exception to propagate. (It will propagate to the DOM event dispatch logic, which will then report the exception.)
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/NodeIterator.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -148,7 +148,7 @@ JS::ThrowCompletionOr<NodeFilter::Result> NodeIterator::filter(Node& node)
|
|||
|
||||
// 6. Let result be the return value of call a user object’s operation with traverser’s filter, "acceptNode", and « node ».
|
||||
// If this throws an exception, then unset traverser’s active flag and rethrow the exception.
|
||||
auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, &node);
|
||||
auto result = WebIDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, &node);
|
||||
if (result.is_abrupt()) {
|
||||
m_active = false;
|
||||
return result;
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/NodeFilter.h>
|
||||
#include <LibWeb/DOM/TreeWalker.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -249,7 +249,7 @@ JS::ThrowCompletionOr<NodeFilter::Result> TreeWalker::filter(Node& node)
|
|||
|
||||
// 6. Let result be the return value of call a user object’s operation with traverser’s filter, "acceptNode", and « node ».
|
||||
// If this throws an exception, then unset traverser’s active flag and rethrow the exception.
|
||||
auto result = Bindings::IDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, &node);
|
||||
auto result = WebIDL::call_user_object_operation(m_filter->callback(), "acceptNode", {}, &node);
|
||||
if (result.is_abrupt()) {
|
||||
m_active = false;
|
||||
return result;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibJS/Runtime/TypedArray.h>
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/Encoding/TextDecoder.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::Encoding {
|
||||
|
||||
|
@ -39,7 +39,7 @@ DOM::ExceptionOr<String> TextDecoder::decode(JS::Handle<JS::Object> const& input
|
|||
{
|
||||
// FIXME: Implement the streaming stuff.
|
||||
|
||||
auto data_buffer_or_error = Bindings::IDL::get_buffer_source_copy(*input.cell());
|
||||
auto data_buffer_or_error = WebIDL::get_buffer_source_copy(*input.cell());
|
||||
if (data_buffer_or_error.is_error())
|
||||
return DOM::OperationError::create(global_object(), "Failed to copy bytes from ArrayBuffer");
|
||||
auto& data_buffer = data_buffer_or_error.value();
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/Fetch/BodyInit.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/URL/URLSearchParams.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::Fetch {
|
||||
|
||||
|
@ -51,7 +51,7 @@ DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, Bo
|
|||
},
|
||||
[&](JS::Handle<JS::Object> const& buffer_source) -> DOM::ExceptionOr<void> {
|
||||
// Set source to a copy of the bytes held by object.
|
||||
source = TRY_OR_RETURN_OOM(window, Bindings::IDL::get_buffer_source_copy(*buffer_source.cell()));
|
||||
source = TRY_OR_RETURN_OOM(window, WebIDL::get_buffer_source_copy(*buffer_source.cell()));
|
||||
return {};
|
||||
},
|
||||
[&](JS::Handle<URL::URLSearchParams> const& url_search_params) -> DOM::ExceptionOr<void> {
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#include <AK/StdLibExtras.h>
|
||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||
#include <LibWeb/Bindings/BlobPrototype.h>
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/FileAPI/Blob.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::FileAPI {
|
||||
|
||||
|
@ -90,7 +90,7 @@ ErrorOr<ByteBuffer> process_blob_parts(Vector<BlobPart> const& blob_parts, Optio
|
|||
},
|
||||
// 2. If element is a BufferSource, get a copy of the bytes held by the buffer source, and append those bytes to bytes.
|
||||
[&](JS::Handle<JS::Object> const& buffer_source) -> ErrorOr<void> {
|
||||
auto data_buffer = TRY(Bindings::IDL::get_buffer_source_copy(*buffer_source.cell()));
|
||||
auto data_buffer = TRY(WebIDL::get_buffer_source_copy(*buffer_source.cell()));
|
||||
return bytes.try_append(data_buffer.bytes());
|
||||
},
|
||||
// 3. If element is a Blob, append the bytes it represents to bytes.
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <LibWeb/Bindings/EventTargetConstructor.h>
|
||||
#include <LibWeb/Bindings/EventTargetPrototype.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/Bindings/LocationObject.h>
|
||||
#include <LibWeb/Bindings/NavigatorObject.h>
|
||||
#include <LibWeb/Bindings/Replaceable.h>
|
||||
|
@ -50,6 +49,7 @@
|
|||
#include <LibWeb/RequestIdleCallback/IdleDeadline.h>
|
||||
#include <LibWeb/Selection/Selection.h>
|
||||
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -214,7 +214,7 @@ i32 Window::run_timer_initialization_steps(TimerHandler handler, i32 timeout, JS
|
|||
handler.visit(
|
||||
// 2. If handler is a Function, then invoke handler given arguments with the callback this value set to thisArg. If this throws an exception, catch it, and report the exception.
|
||||
[&](JS::Handle<WebIDL::CallbackType> callback) {
|
||||
if (auto result = Bindings::IDL::invoke_callback(*callback, window.ptr(), arguments); result.is_error())
|
||||
if (auto result = WebIDL::invoke_callback(*callback, window.ptr(), arguments); result.is_error())
|
||||
HTML::report_exception(result);
|
||||
},
|
||||
// 3. Otherwise:
|
||||
|
@ -281,7 +281,7 @@ i32 Window::request_animation_frame_impl(WebIDL::CallbackType& js_callback)
|
|||
{
|
||||
return m_animation_frame_callback_driver.add([this, js_callback = JS::make_handle(js_callback)](auto) mutable {
|
||||
// 3. Invoke callback, passing now as the only argument,
|
||||
auto result = Bindings::IDL::invoke_callback(*js_callback, {}, JS::Value(performance().now()));
|
||||
auto result = WebIDL::invoke_callback(*js_callback, {}, JS::Value(performance().now()));
|
||||
|
||||
// and if an exception is thrown, report the exception.
|
||||
if (result.is_error())
|
||||
|
@ -510,7 +510,7 @@ void Window::queue_microtask_impl(WebIDL::CallbackType& callback)
|
|||
{
|
||||
// The queueMicrotask(callback) method must queue a microtask to invoke callback,
|
||||
HTML::queue_a_microtask(&associated_document(), [&callback]() mutable {
|
||||
auto result = Bindings::IDL::invoke_callback(callback, {});
|
||||
auto result = WebIDL::invoke_callback(callback, {});
|
||||
// and if callback throws an exception, report the exception.
|
||||
if (result.is_error())
|
||||
HTML::report_exception(result);
|
||||
|
@ -696,7 +696,7 @@ u32 Window::request_idle_callback_impl(WebIDL::CallbackType& callback)
|
|||
auto handle = window.m_idle_callback_identifier;
|
||||
// 4. Push callback to the end of window's list of idle request callbacks, associated with handle.
|
||||
auto handler = [callback = JS::make_handle(callback)](JS::NonnullGCPtr<RequestIdleCallback::IdleDeadline> deadline) -> JS::Completion {
|
||||
return Bindings::IDL::invoke_callback(const_cast<WebIDL::CallbackType&>(*callback), {}, deadline.ptr());
|
||||
return WebIDL::invoke_callback(const_cast<WebIDL::CallbackType&>(*callback), {}, deadline.ptr());
|
||||
};
|
||||
window.m_idle_request_callbacks.append(adopt_ref(*new IdleCallback(move(handler), handle)));
|
||||
// 5. Return handle and then continue running this algorithm asynchronously.
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include <LibJS/Runtime/DataView.h>
|
||||
#include <LibJS/Runtime/PropertyKey.h>
|
||||
#include <LibJS/Runtime/TypedArray.h>
|
||||
#include <LibWeb/Bindings/IDLAbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::Bindings::IDL {
|
||||
namespace Web::WebIDL {
|
||||
|
||||
// https://webidl.spec.whatwg.org/#dfn-get-buffer-source-copy
|
||||
ErrorOr<ByteBuffer> get_buffer_source_copy(JS::Object const& buffer_source)
|
|
@ -14,7 +14,7 @@
|
|||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/WebIDL/CallbackType.h>
|
||||
|
||||
namespace Web::Bindings::IDL {
|
||||
namespace Web::WebIDL {
|
||||
|
||||
ErrorOr<ByteBuffer> get_buffer_source_copy(JS::Object const& buffer_source);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue