LibWeb: Use C-style function pointers for ActionsOptions callbacks

This is a bit unfortunate, but if a function provided to this struct is
overloaded, the C++ compiler cannot distinguish which overload should be
assigned to the Function object. This is explained in detail here:
https://stackoverflow.com/a/30394755

C-style function pointers do work, however, and are fine here because
we only ever assign global free functions to these members.
This commit is contained in:
Timothy Flynn 2024-11-02 21:12:52 -04:00 committed by Andreas Kling
parent 6fb8500a7a
commit dc188329df
Notes: github-actions[bot] 2024-11-03 17:08:38 +00:00

View file

@ -6,7 +6,6 @@
#pragma once
#include <AK/Function.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Time.h>
@ -118,8 +117,11 @@ struct ActionObject {
// https://w3c.github.io/webdriver/#dfn-actions-options
struct ActionsOptions {
Function<bool(JsonObject const&)> is_element_origin;
Function<ErrorOr<JS::NonnullGCPtr<DOM::Element>, WebDriver::Error>(HTML::BrowsingContext const&, StringView)> get_element_origin;
using IsElementOrigin = bool (*)(JsonValue const&);
using GetElementOrigin = ErrorOr<JS::NonnullGCPtr<DOM::Element>, WebDriver::Error> (*)(HTML::BrowsingContext const&, StringView);
IsElementOrigin is_element_origin { nullptr };
GetElementOrigin get_element_origin { nullptr };
};
using OnActionsComplete = JS::NonnullGCPtr<JS::HeapFunction<void(Web::WebDriver::Response)>>;