mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:27:35 +00:00
LibWeb: Move CallbackType from Bindings/ to WebIDL/
Let's stop putting generic types and AOs from the Web IDL spec into the Bindings namespace and directory in LibWeb, and instead follow our usual naming rules of 'directory = namespace = spec name'. The IDL namespace is already used by LibIDL, so Web::WebIDL seems like a good choice.
This commit is contained in:
parent
dc44effd44
commit
4f73851afc
43 changed files with 168 additions and 165 deletions
|
@ -57,12 +57,12 @@ void AbortSignal::signal_abort(JS::Value reason)
|
|||
dispatch_event(*Event::create(global_object(), HTML::EventNames::abort));
|
||||
}
|
||||
|
||||
void AbortSignal::set_onabort(Bindings::CallbackType* event_handler)
|
||||
void AbortSignal::set_onabort(WebIDL::CallbackType* event_handler)
|
||||
{
|
||||
set_event_handler_attribute(HTML::EventNames::abort, event_handler);
|
||||
}
|
||||
|
||||
Bindings::CallbackType* AbortSignal::onabort()
|
||||
WebIDL::CallbackType* AbortSignal::onabort()
|
||||
{
|
||||
return event_handler_attribute(HTML::EventNames::abort);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ public:
|
|||
|
||||
void signal_abort(JS::Value reason);
|
||||
|
||||
void set_onabort(Bindings::CallbackType*);
|
||||
Bindings::CallbackType* onabort();
|
||||
void set_onabort(WebIDL::CallbackType*);
|
||||
WebIDL::CallbackType* onabort();
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-abortsignal-reason
|
||||
JS::Value reason() const { return m_abort_reason; }
|
||||
|
|
|
@ -299,7 +299,7 @@ static EventTarget* determine_target_of_event_handler(EventTarget& event_target,
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:event-handler-idl-attributes-2
|
||||
Bindings::CallbackType* EventTarget::event_handler_attribute(FlyString const& name)
|
||||
WebIDL::CallbackType* EventTarget::event_handler_attribute(FlyString const& name)
|
||||
{
|
||||
// 1. Let eventTarget be the result of determining the target of an event handler given this object and name.
|
||||
auto target = determine_target_of_event_handler(*this, name);
|
||||
|
@ -313,7 +313,7 @@ Bindings::CallbackType* EventTarget::event_handler_attribute(FlyString const& na
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler
|
||||
Bindings::CallbackType* EventTarget::get_current_value_of_event_handler(FlyString const& name)
|
||||
WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(FlyString const& name)
|
||||
{
|
||||
// 1. Let handlerMap be eventTarget's event handler map. (NOTE: Not necessary)
|
||||
|
||||
|
@ -464,16 +464,16 @@ Bindings::CallbackType* EventTarget::get_current_value_of_event_handler(FlyStrin
|
|||
function->set_script_or_module({});
|
||||
|
||||
// 12. Set eventHandler's value to the result of creating a Web IDL EventHandler callback function object whose object reference is function and whose callback context is settings object.
|
||||
event_handler->value = realm.heap().allocate_without_realm<Bindings::CallbackType>(*function, settings_object);
|
||||
event_handler->value = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*function, settings_object);
|
||||
}
|
||||
|
||||
// 4. Return eventHandler's value.
|
||||
VERIFY(event_handler->value.has<Bindings::CallbackType*>());
|
||||
return *event_handler->value.get_pointer<Bindings::CallbackType*>();
|
||||
VERIFY(event_handler->value.has<WebIDL::CallbackType*>());
|
||||
return *event_handler->value.get_pointer<WebIDL::CallbackType*>();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:event-handler-idl-attributes-3
|
||||
void EventTarget::set_event_handler_attribute(FlyString const& name, Bindings::CallbackType* value)
|
||||
void EventTarget::set_event_handler_attribute(FlyString const& name, WebIDL::CallbackType* value)
|
||||
{
|
||||
// 1. Let eventTarget be the result of determining the target of an event handler given this object and name.
|
||||
auto event_target = determine_target_of_event_handler(*this, name);
|
||||
|
@ -556,7 +556,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
|
|||
0, "", &realm);
|
||||
|
||||
// NOTE: As per the spec, the callback context is arbitrary.
|
||||
auto* callback = realm.heap().allocate_without_realm<Bindings::CallbackType>(*callback_function, verify_cast<HTML::EnvironmentSettingsObject>(*realm.host_defined()));
|
||||
auto* callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_function, verify_cast<HTML::EnvironmentSettingsObject>(*realm.host_defined()));
|
||||
|
||||
// 5. Let listener be a new event listener whose type is the event handler event type corresponding to eventHandler and callback is callback.
|
||||
auto* listener = realm.heap().allocate_without_realm<DOMEventListener>();
|
||||
|
|
|
@ -51,8 +51,8 @@ public:
|
|||
virtual void legacy_cancelled_activation_behavior() { }
|
||||
virtual void legacy_cancelled_activation_behavior_was_not_called() { }
|
||||
|
||||
Bindings::CallbackType* event_handler_attribute(FlyString const& name);
|
||||
void set_event_handler_attribute(FlyString const& name, Bindings::CallbackType*);
|
||||
WebIDL::CallbackType* event_handler_attribute(FlyString const& name);
|
||||
void set_event_handler_attribute(FlyString const& name, WebIDL::CallbackType*);
|
||||
|
||||
protected:
|
||||
explicit EventTarget(JS::Realm&);
|
||||
|
@ -68,7 +68,7 @@ private:
|
|||
// Spec Note: The order of the entries of event handler map could be arbitrary. It is not observable through any algorithms that operate on the map.
|
||||
HashMap<FlyString, JS::GCPtr<HTML::EventHandler>> m_event_handler_map;
|
||||
|
||||
Bindings::CallbackType* get_current_value_of_event_handler(FlyString const& name);
|
||||
WebIDL::CallbackType* get_current_value_of_event_handler(FlyString const& name);
|
||||
void activate_event_handler(FlyString const& name, HTML::EventHandler& event_handler);
|
||||
void deactivate_event_handler(FlyString const& name);
|
||||
JS::ThrowCompletionOr<void> process_event_handler_for_event(FlyString const& name, Event& event);
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
JS::NonnullGCPtr<IDLEventListener> IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr<Bindings::CallbackType> callback)
|
||||
JS::NonnullGCPtr<IDLEventListener> IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)
|
||||
{
|
||||
return *realm.heap().allocate<IDLEventListener>(realm, realm, move(callback));
|
||||
}
|
||||
|
||||
IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr<Bindings::CallbackType> callback)
|
||||
IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)
|
||||
: JS::Object(*realm.intrinsics().object_prototype())
|
||||
, m_callback(move(callback))
|
||||
{
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/Bindings/CallbackType.h>
|
||||
#include <LibWeb/DOM/AbortSignal.h>
|
||||
#include <LibWeb/WebIDL/CallbackType.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -28,17 +28,17 @@ class IDLEventListener final : public JS::Object {
|
|||
JS_OBJECT(IDLEventListener, JS::Object);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<IDLEventListener> create(JS::Realm&, JS::NonnullGCPtr<Bindings::CallbackType>);
|
||||
IDLEventListener(JS::Realm&, JS::NonnullGCPtr<Bindings::CallbackType>);
|
||||
static JS::NonnullGCPtr<IDLEventListener> create(JS::Realm&, JS::NonnullGCPtr<WebIDL::CallbackType>);
|
||||
IDLEventListener(JS::Realm&, JS::NonnullGCPtr<WebIDL::CallbackType>);
|
||||
|
||||
virtual ~IDLEventListener() = default;
|
||||
|
||||
Bindings::CallbackType& callback() { return *m_callback; }
|
||||
WebIDL::CallbackType& callback() { return *m_callback; }
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<Bindings::CallbackType> m_callback;
|
||||
JS::NonnullGCPtr<WebIDL::CallbackType> m_callback;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
JS::NonnullGCPtr<MutationObserver> MutationObserver::create_with_global_object(HTML::Window& window, JS::GCPtr<Bindings::CallbackType> callback)
|
||||
JS::NonnullGCPtr<MutationObserver> MutationObserver::create_with_global_object(HTML::Window& window, JS::GCPtr<WebIDL::CallbackType> callback)
|
||||
{
|
||||
return *window.heap().allocate<MutationObserver>(window.realm(), window, callback);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver
|
||||
MutationObserver::MutationObserver(HTML::Window& window, JS::GCPtr<Bindings::CallbackType> callback)
|
||||
MutationObserver::MutationObserver(HTML::Window& window, JS::GCPtr<WebIDL::CallbackType> callback)
|
||||
: PlatformObject(window.realm())
|
||||
, m_callback(move(callback))
|
||||
{
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/Bindings/CallbackType.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/DOM/MutationRecord.h>
|
||||
#include <LibWeb/WebIDL/CallbackType.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -32,7 +32,7 @@ class MutationObserver final : public Bindings::PlatformObject {
|
|||
WEB_PLATFORM_OBJECT(MutationObserver, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<MutationObserver> create_with_global_object(HTML::Window&, JS::GCPtr<Bindings::CallbackType>);
|
||||
static JS::NonnullGCPtr<MutationObserver> create_with_global_object(HTML::Window&, JS::GCPtr<WebIDL::CallbackType>);
|
||||
virtual ~MutationObserver() override;
|
||||
|
||||
ExceptionOr<void> observe(Node& target, MutationObserverInit options = {});
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
Vector<WeakPtr<Node>>& node_list() { return m_node_list; }
|
||||
Vector<WeakPtr<Node>> const& node_list() const { return m_node_list; }
|
||||
|
||||
Bindings::CallbackType& callback() { return *m_callback; }
|
||||
WebIDL::CallbackType& callback() { return *m_callback; }
|
||||
|
||||
void enqueue_record(Badge<Node>, JS::NonnullGCPtr<MutationRecord> mutation_record)
|
||||
{
|
||||
|
@ -50,12 +50,12 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
MutationObserver(HTML::Window&, JS::GCPtr<Bindings::CallbackType>);
|
||||
MutationObserver(HTML::Window&, JS::GCPtr<WebIDL::CallbackType>);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-mo-callback
|
||||
JS::GCPtr<Bindings::CallbackType> m_callback;
|
||||
JS::GCPtr<WebIDL::CallbackType> m_callback;
|
||||
|
||||
// https://dom.spec.whatwg.org/#mutationobserver-node-list
|
||||
// NOTE: These are weak, per https://dom.spec.whatwg.org/#garbage-collection
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
JS::NonnullGCPtr<NodeFilter> NodeFilter::create(JS::Realm& realm, Bindings::CallbackType& callback)
|
||||
JS::NonnullGCPtr<NodeFilter> NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback)
|
||||
{
|
||||
return *realm.heap().allocate<NodeFilter>(realm, realm, callback);
|
||||
}
|
||||
|
||||
NodeFilter::NodeFilter(JS::Realm& realm, Bindings::CallbackType& callback)
|
||||
NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback)
|
||||
: PlatformObject(*realm.intrinsics().object_prototype())
|
||||
, m_callback(callback)
|
||||
{
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/CallbackType.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/WebIDL/CallbackType.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -15,11 +15,11 @@ class NodeFilter final : public Bindings::PlatformObject {
|
|||
WEB_PLATFORM_OBJECT(NodeFilter, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<NodeFilter> create(JS::Realm&, Bindings::CallbackType&);
|
||||
static JS::NonnullGCPtr<NodeFilter> create(JS::Realm&, WebIDL::CallbackType&);
|
||||
|
||||
virtual ~NodeFilter() = default;
|
||||
|
||||
Bindings::CallbackType& callback() { return m_callback; }
|
||||
WebIDL::CallbackType& callback() { return m_callback; }
|
||||
|
||||
enum Result {
|
||||
FILTER_ACCEPT = 1,
|
||||
|
@ -28,11 +28,11 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
NodeFilter(JS::Realm&, Bindings::CallbackType&);
|
||||
NodeFilter(JS::Realm&, WebIDL::CallbackType&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
Bindings::CallbackType& m_callback;
|
||||
WebIDL::CallbackType& m_callback;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue