mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibWeb: Stop using Bindings::wrap() in a bunch of places
wrap() is now basically a no-op so we should stop using it everywhere and eventually remove it. This patch removes uses of wrap() in non-generated code.
This commit is contained in:
parent
45425de849
commit
9176a0de99
7 changed files with 32 additions and 56 deletions
|
@ -441,22 +441,16 @@ Bindings::CallbackType* EventTarget::get_current_value_of_event_handler(FlyStrin
|
|||
|
||||
// 3. If eventHandler is an element's event handler, then set scope to NewObjectEnvironment(document, true, scope).
|
||||
// (Otherwise, eventHandler is a Window object's event handler.)
|
||||
if (is<Element>(this)) {
|
||||
auto* wrapped_document = Bindings::wrap(realm, *document);
|
||||
scope = JS::new_object_environment(*wrapped_document, true, scope);
|
||||
}
|
||||
if (is<Element>(this))
|
||||
scope = JS::new_object_environment(*document, true, scope);
|
||||
|
||||
// 4. If form owner is not null, then set scope to NewObjectEnvironment(form owner, true, scope).
|
||||
if (form_owner) {
|
||||
auto* wrapped_form_owner = Bindings::wrap(realm, *form_owner);
|
||||
scope = JS::new_object_environment(*wrapped_form_owner, true, scope);
|
||||
}
|
||||
if (form_owner)
|
||||
scope = JS::new_object_environment(*form_owner, true, scope);
|
||||
|
||||
// 5. If element is not null, then set scope to NewObjectEnvironment(element, true, scope).
|
||||
if (element) {
|
||||
auto* wrapped_element = Bindings::wrap(realm, *element);
|
||||
scope = JS::new_object_environment(*wrapped_element, true, scope);
|
||||
}
|
||||
if (element)
|
||||
scope = JS::new_object_environment(*element, true, scope);
|
||||
|
||||
// 6. Return scope. (NOTE: Not necessary)
|
||||
|
||||
|
@ -625,18 +619,14 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
// 4. Process the Event object event as follows:
|
||||
JS::Completion return_value_or_error;
|
||||
|
||||
// Needed for wrapping.
|
||||
auto* callback_object = &callback->callback;
|
||||
auto& realm = callback_object->shape().realm();
|
||||
|
||||
if (special_error_event_handling) {
|
||||
// -> If special error event handling is true
|
||||
// Invoke callback with five arguments, the first one having the value of event's message attribute, the second having the value of event's filename attribute, the third having the value of event's lineno attribute,
|
||||
// the fourth having the value of event's colno attribute, the fifth having the value of event's error attribute, and with the callback this value set to event's currentTarget.
|
||||
// Let return value be the callback's return value. [WEBIDL]
|
||||
auto& error_event = verify_cast<HTML::ErrorEvent>(event);
|
||||
auto* wrapped_message = JS::js_string(callback_object->heap(), error_event.message());
|
||||
auto* wrapped_filename = JS::js_string(callback_object->heap(), error_event.filename());
|
||||
auto* wrapped_message = JS::js_string(vm(), error_event.message());
|
||||
auto* wrapped_filename = JS::js_string(vm(), error_event.filename());
|
||||
auto wrapped_lineno = JS::Value(error_event.lineno());
|
||||
auto wrapped_colno = JS::Value(error_event.colno());
|
||||
|
||||
|
@ -645,7 +635,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
// NOTE: current_target is always non-null here, as the event dispatcher takes care to make sure it's non-null (and uses it as the this value for the callback!)
|
||||
// FIXME: This is rewrapping the this value of the callback defined in activate_event_handler. While I don't think this is observable as the event dispatcher
|
||||
// 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 = Bindings::wrap(realm, *error_event.current_target());
|
||||
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());
|
||||
} else {
|
||||
|
@ -653,10 +643,10 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
|
|||
// 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]
|
||||
|
||||
// FIXME: This has the same rewrapping issue as this_value.
|
||||
auto* wrapped_event = Bindings::wrap(realm, event);
|
||||
auto* wrapped_event = &event;
|
||||
|
||||
// FIXME: The comments about this in the special_error_event_handling path also apply here.
|
||||
auto* this_value = Bindings::wrap(realm, *event.current_target());
|
||||
auto* this_value = event.current_target().ptr();
|
||||
|
||||
return_value_or_error = Bindings::IDL::invoke_callback(*callback, this_value, wrapped_event);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue