mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Update WebIDL::invoke_callback()
to follow the latest spec
`WebIDL::invoke_callback()` now takes an `exception_behavior` parameter, which can be set to `report` to report an exception before returning. Setting `exception_behavior` to `rethrow` retains the previous behavior.
This commit is contained in:
parent
07635d4554
commit
1f57df34f1
Notes:
github-actions[bot]
2024-12-19 15:26:54 +00:00
Author: https://github.com/tcl3
Commit: 1f57df34f1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2739
Reviewed-by: https://github.com/shannonbooth
2 changed files with 83 additions and 14 deletions
|
@ -39,18 +39,31 @@ JS::Completion call_user_object_operation(WebIDL::CallbackType& callback, String
|
|||
return call_user_object_operation(callback, operation_name, move(this_argument), move(arguments_list));
|
||||
}
|
||||
|
||||
enum class ExceptionBehavior {
|
||||
NotSpecified,
|
||||
Report,
|
||||
Rethrow,
|
||||
};
|
||||
|
||||
JS::Completion invoke_callback(WebIDL::CallbackType& callback, Optional<JS::Value> this_argument, ExceptionBehavior exception_behavior, GC::MarkedVector<JS::Value> args);
|
||||
JS::Completion invoke_callback(WebIDL::CallbackType& callback, Optional<JS::Value> this_argument, GC::MarkedVector<JS::Value> args);
|
||||
|
||||
// https://webidl.spec.whatwg.org/#invoke-a-callback-function
|
||||
template<typename... Args>
|
||||
JS::Completion invoke_callback(WebIDL::CallbackType& callback, Optional<JS::Value> this_argument, Args&&... args)
|
||||
JS::Completion invoke_callback(WebIDL::CallbackType& callback, Optional<JS::Value> this_argument, ExceptionBehavior exception_behavior, Args&&... args)
|
||||
{
|
||||
auto& function_object = callback.callback;
|
||||
|
||||
GC::MarkedVector<JS::Value> arguments_list { function_object->heap() };
|
||||
(arguments_list.append(forward<Args>(args)), ...);
|
||||
|
||||
return invoke_callback(callback, move(this_argument), move(arguments_list));
|
||||
return invoke_callback(callback, move(this_argument), exception_behavior, move(arguments_list));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
JS::Completion invoke_callback(WebIDL::CallbackType& callback, Optional<JS::Value> this_argument, Args&&... args)
|
||||
{
|
||||
return invoke_callback(callback, move(this_argument), ExceptionBehavior::NotSpecified, forward<Args>(args)...);
|
||||
}
|
||||
|
||||
JS::Completion construct(WebIDL::CallbackType& callback, GC::MarkedVector<JS::Value> args);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue