mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:48:12 +00:00
LibWeb: Remove no-op impl() methods from the WEB_PLATFORM_OBJECT macro
These are leftovers from when wrapper objects still had an internal implementation, which is no longer the case.
This commit is contained in:
parent
2cab2a8e8f
commit
6055b0e850
14 changed files with 28 additions and 39 deletions
|
@ -337,7 +337,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (!@js_name@@js_suffix@.is_object() || !is<@parameter.type.name@>(@js_name@@js_suffix@.as_object()))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");
|
||||
|
||||
auto& @cpp_name@ = static_cast<@parameter.type.name@&>(@js_name@@js_suffix@.as_object()).impl();
|
||||
auto& @cpp_name@ = static_cast<@parameter.type.name@&>(@js_name@@js_suffix@.as_object());
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
|
@ -346,7 +346,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (!@js_name@@js_suffix@.is_object() || !is<@parameter.type.name@>(@js_name@@js_suffix@.as_object()))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");
|
||||
|
||||
@cpp_name@ = static_cast<@parameter.type.name@&>(@js_name@@js_suffix@.as_object()).impl();
|
||||
@cpp_name@ = static_cast<@parameter.type.name@&>(@js_name@@js_suffix@.as_object());
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (!@js_name@@js_suffix@.is_object() || !is<@parameter.type.name@>(@js_name@@js_suffix@.as_object()))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");
|
||||
|
||||
@cpp_name@ = &static_cast<@parameter.type.name@&>(@js_name@@js_suffix@.as_object()).impl();
|
||||
@cpp_name@ = &static_cast<@parameter.type.name@&>(@js_name@@js_suffix@.as_object());
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
@ -2567,7 +2567,7 @@ static JS::ThrowCompletionOr<@fully_qualified_name@*> impl_from(JS::VM& vm)
|
|||
if (interface.name == "EventTarget") {
|
||||
generator.append(R"~~~(
|
||||
if (is<HTML::Window>(this_object)) {
|
||||
return &static_cast<HTML::Window*>(this_object)->impl();
|
||||
return static_cast<HTML::Window*>(this_object);
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
@ -2576,7 +2576,7 @@ static JS::ThrowCompletionOr<@fully_qualified_name@*> impl_from(JS::VM& vm)
|
|||
if (!is<@fully_qualified_name@>(this_object))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@fully_qualified_name@");
|
||||
|
||||
return &static_cast<@fully_qualified_name@*>(this_object)->impl();
|
||||
return static_cast<@fully_qualified_name@*>(this_object);
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
@ -2869,7 +2869,7 @@ static JS::ThrowCompletionOr<@fully_qualified_name@*> impl_from(JS::VM& vm)
|
|||
auto* this_object = TRY(vm.this_value().to_object(vm));
|
||||
if (!is<@fully_qualified_name@>(this_object))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@fully_qualified_name@");
|
||||
return &static_cast<@fully_qualified_name@*>(this_object)->impl();
|
||||
return static_cast<@fully_qualified_name@*>(this_object);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::next)
|
||||
|
|
|
@ -40,7 +40,7 @@ JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&)
|
|||
|
||||
// 1. Let document be the current global object's associated Document.
|
||||
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
|
||||
auto& document = window.impl().associated_document();
|
||||
auto& document = window.associated_document();
|
||||
|
||||
// 2. Let audio be the result of creating an element given document, audio, and the HTML namespace.
|
||||
auto audio = DOM::create_element(document, HTML::TagNames::audio, Namespace::HTML);
|
||||
|
|
|
@ -108,12 +108,12 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_setter)
|
|||
|
||||
// 2. Parse the given value relative to the entry settings object. If that failed, throw a TypeError exception.
|
||||
auto new_href = TRY(vm.argument(0).to_string(vm));
|
||||
auto href_url = window.impl().associated_document().parse_url(new_href);
|
||||
auto href_url = window.associated_document().parse_url(new_href);
|
||||
if (!href_url.is_valid())
|
||||
return vm.throw_completion<JS::URIError>(String::formatted("Invalid URL '{}'", new_href));
|
||||
|
||||
// 3. Location-object navigate given the resulting URL record.
|
||||
window.impl().did_set_location_href({}, href_url);
|
||||
window.did_set_location_href({}, href_url);
|
||||
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::port_getter)
|
|||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
|
||||
window.impl().did_call_location_reload({});
|
||||
window.did_call_location_reload({});
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::replace)
|
|||
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
|
||||
auto url = TRY(vm.argument(0).to_string(vm));
|
||||
// FIXME: This needs spec compliance work.
|
||||
window.impl().did_call_location_replace({}, move(url));
|
||||
window.did_call_location_replace({}, move(url));
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,15 +14,7 @@
|
|||
namespace Web::Bindings {
|
||||
|
||||
#define WEB_PLATFORM_OBJECT(class_, base_class) \
|
||||
JS_OBJECT(class_, base_class) \
|
||||
auto& impl() \
|
||||
{ \
|
||||
return *this; \
|
||||
} \
|
||||
auto const& impl() const \
|
||||
{ \
|
||||
return *this; \
|
||||
}
|
||||
JS_OBJECT(class_, base_class)
|
||||
|
||||
#define WRAPPER_HACK(class_, namespace_) \
|
||||
namespace Web::Bindings { \
|
||||
|
|
|
@ -151,7 +151,7 @@ JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const
|
|||
// 1. Let W be the value of the [[Window]] internal slot of this.
|
||||
|
||||
// 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object.
|
||||
HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<HTML::Window>(HTML::current_global_object()).impl().browsing_context(), *m_window->browsing_context(), property_key, HTML::current_settings_object());
|
||||
HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<HTML::Window>(HTML::current_global_object()).browsing_context(), *m_window->browsing_context(), property_key, HTML::current_settings_object());
|
||||
|
||||
// 3. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver).
|
||||
// NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method.
|
||||
|
@ -171,7 +171,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_set(JS::PropertyKey const& pro
|
|||
// 1. Let W be the value of the [[Window]] internal slot of this.
|
||||
|
||||
// 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object.
|
||||
HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<HTML::Window>(HTML::current_global_object()).browsing_context(), *m_window->impl().browsing_context(), property_key, HTML::current_settings_object());
|
||||
HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<HTML::Window>(HTML::current_global_object()).browsing_context(), *m_window->browsing_context(), property_key, HTML::current_settings_object());
|
||||
|
||||
// 3. If IsPlatformObjectSameOrigin(W) is true, then:
|
||||
if (is_platform_object_same_origin(*m_window)) {
|
||||
|
|
|
@ -353,7 +353,7 @@ JS::ThrowCompletionOr<bool> CSSStyleDeclaration::internal_set(JS::PropertyKey co
|
|||
|
||||
auto css_text = TRY(value.to_string(vm()));
|
||||
|
||||
impl().set_property(property_id, css_text);
|
||||
set_property(property_id, css_text);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,15 +91,14 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<JS::Handle<DOM::DOMEvent
|
|||
|
||||
// 8. If global is a Window object, then:
|
||||
if (is<HTML::Window>(global)) {
|
||||
auto& bindings_window_global = verify_cast<HTML::Window>(global);
|
||||
auto& window_impl = bindings_window_global.impl();
|
||||
auto& window = verify_cast<HTML::Window>(global);
|
||||
|
||||
// 1. Set currentEvent to global’s current event.
|
||||
current_event = window_impl.current_event();
|
||||
current_event = window.current_event();
|
||||
|
||||
// 2. If invocationTargetInShadowTree is false, then set global’s current event to event.
|
||||
if (!invocation_target_in_shadow_tree)
|
||||
window_impl.set_current_event(&event);
|
||||
window.set_current_event(&event);
|
||||
}
|
||||
|
||||
// 9. If listener’s passive is true, then set event’s in passive listener flag.
|
||||
|
@ -125,9 +124,8 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<JS::Handle<DOM::DOMEvent
|
|||
|
||||
// 12. If global is a Window object, then set global’s current event to currentEvent.
|
||||
if (is<HTML::Window>(global)) {
|
||||
auto& bindings_window_global = verify_cast<HTML::Window>(global);
|
||||
auto& window_impl = bindings_window_global.impl();
|
||||
window_impl.set_current_event(current_event);
|
||||
auto& window = verify_cast<HTML::Window>(global);
|
||||
window.set_current_event(current_event);
|
||||
}
|
||||
|
||||
// 13. If event’s stop immediate propagation flag is set, then return found.
|
||||
|
|
|
@ -548,8 +548,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
|
|||
// The argument must be an object and it must be an Event.
|
||||
auto event_wrapper_argument = vm.argument(0);
|
||||
VERIFY(event_wrapper_argument.is_object());
|
||||
auto& event_wrapper = verify_cast<DOM::Event>(event_wrapper_argument.as_object());
|
||||
auto& event = event_wrapper.impl();
|
||||
auto& event = verify_cast<DOM::Event>(event_wrapper_argument.as_object());
|
||||
|
||||
TRY(event_target->process_event_handler_for_event(name, event));
|
||||
return JS::js_undefined();
|
||||
|
|
|
@ -43,7 +43,7 @@ JS::NonnullGCPtr<Range> Range::create(Node& start_container, u32 start_offset, N
|
|||
|
||||
JS::NonnullGCPtr<Range> Range::create_with_global_object(HTML::Window& window)
|
||||
{
|
||||
return Range::create(window.impl());
|
||||
return Range::create(window);
|
||||
}
|
||||
|
||||
Range::Range(Document& document)
|
||||
|
|
|
@ -247,7 +247,7 @@ void queue_global_task(HTML::Task::Source source, JS::Object& global_object, Fun
|
|||
DOM::Document* document { nullptr };
|
||||
if (is<HTML::Window>(global_object)) {
|
||||
auto& window_object = verify_cast<HTML::Window>(global_object);
|
||||
document = &window_object.impl().associated_document();
|
||||
document = &window_object.associated_document();
|
||||
}
|
||||
|
||||
// 3. Queue a task given source, event loop, document, and steps.
|
||||
|
|
|
@ -844,7 +844,7 @@ void Window::initialize(JS::Realm& realm)
|
|||
|
||||
HTML::Origin Window::origin() const
|
||||
{
|
||||
return impl().associated_document().origin();
|
||||
return associated_document().origin();
|
||||
}
|
||||
|
||||
// https://webidl.spec.whatwg.org/#platform-object-setprototypeof
|
||||
|
@ -870,7 +870,7 @@ static JS::ThrowCompletionOr<HTML::Window*> impl_from(JS::VM& vm)
|
|||
|
||||
if (!is<Window>(*this_object))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Window");
|
||||
return &static_cast<Window*>(this_object)->impl();
|
||||
return static_cast<Window*>(this_object);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::alert)
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
static DOM::ExceptionOr<JS::NonnullGCPtr<Worker>> create(FlyString const& script_url, WorkerOptions const options, DOM::Document& document);
|
||||
static DOM::ExceptionOr<JS::NonnullGCPtr<Worker>> create_with_global_object(HTML::Window& window, FlyString const& script_url, WorkerOptions const options)
|
||||
{
|
||||
return Worker::create(script_url, options, window.impl().associated_document());
|
||||
return Worker::create(script_url, options, window.associated_document());
|
||||
}
|
||||
|
||||
DOM::ExceptionOr<void> terminate();
|
||||
|
|
|
@ -58,7 +58,7 @@ DOM::ExceptionOr<JS::NonnullGCPtr<WebSocket>> WebSocket::create_with_global_obje
|
|||
return DOM::SyntaxError::create(window, "Presence of URL fragment is invalid");
|
||||
// 5. If `protocols` is a string, set `protocols` to a sequence consisting of just that string
|
||||
// 6. If any of the values in `protocols` occur more than once or otherwise fail to match the requirements, throw SyntaxError
|
||||
return JS::NonnullGCPtr(*window.heap().allocate<WebSocket>(window.realm(), window.impl(), url_record));
|
||||
return JS::NonnullGCPtr(*window.heap().allocate<WebSocket>(window.realm(), window, url_record));
|
||||
}
|
||||
|
||||
WebSocket::WebSocket(HTML::Window& window, AK::URL& url)
|
||||
|
|
|
@ -100,7 +100,7 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalObject::inspected_node_getter)
|
|||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "ConsoleGlobalObject");
|
||||
|
||||
auto console_global_object = static_cast<ConsoleGlobalObject*>(this_object);
|
||||
auto& window = console_global_object->m_window_object->impl();
|
||||
auto& window = *console_global_object->m_window_object;
|
||||
auto* inspected_node = window.associated_document().inspected_node();
|
||||
if (!inspected_node)
|
||||
return JS::js_undefined();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue