mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Fix WebIDL overload resolution with platform object arguments
We now check if an argument value is a platform object that implements the relevant IDL interface when resolving overloads. This makes passing a Path2D object to CanvasRenderingContext2D.fill() actually choose the Path2D overload. :^)
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 03:50:53 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9d4e0ba442 Pull-request: https://github.com/SerenityOS/serenity/pull/16249 Reviewed-by: https://github.com/AnthonyIacono Reviewed-by: https://github.com/AtkinsSJ ✅
@@ -159,10 +159,15 @@ JS::ThrowCompletionOr<ResolvedOverload> resolve_overload(JS::VM& vm, IDL::Effect
|
||||
// - a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types
|
||||
// then remove from S all other entries.
|
||||
else if (value.is_object() && is<Bindings::PlatformObject>(value.as_object())
|
||||
&& has_overload_with_argument_type_or_subtype_matching(overloads, i, [](IDL::Type const& type) {
|
||||
// FIXME: - an interface type that V implements
|
||||
&& has_overload_with_argument_type_or_subtype_matching(overloads, i, [value](IDL::Type const& type) {
|
||||
// - an interface type that V implements
|
||||
if (static_cast<Bindings::PlatformObject const&>(value.as_object()).implements_interface(type.name()))
|
||||
return true;
|
||||
|
||||
// - object
|
||||
if (type.is_object())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
})) {
|
||||
overloads.remove_all_other_entries();
|
||||
|
||||
Reference in New Issue
Block a user