mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01:00
LibWeb: Make eventInitDict GamepadEvent constructor parameter optional
This differs from the specification but matches the behavior of existing implementations.
This commit is contained in:
parent
5df91dc761
commit
9c204f36ec
|
|
@ -20,7 +20,7 @@ WebIDL::ExceptionOr<GC::Ref<GamepadEvent>> GamepadEvent::construct_impl(JS::Real
|
|||
|
||||
GamepadEvent::GamepadEvent(JS::Realm& realm, FlyString const& event_name, GamepadEventInit const& event_init)
|
||||
: DOM::Event(realm, event_name, event_init)
|
||||
, m_gamepad(*event_init.gamepad)
|
||||
, m_gamepad(event_init.gamepad.has_value() ? event_init.gamepad->ptr() : nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
namespace Web::Gamepad {
|
||||
|
||||
struct GamepadEventInit : public DOM::EventInit {
|
||||
GC::Root<Gamepad> gamepad;
|
||||
Optional<GC::Root<Gamepad>> gamepad;
|
||||
};
|
||||
|
||||
class GamepadEvent final : public DOM::Event {
|
||||
|
|
@ -19,18 +19,18 @@ class GamepadEvent final : public DOM::Event {
|
|||
GC_DECLARE_ALLOCATOR(GamepadEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<GamepadEvent>> construct_impl(JS::Realm&, FlyString const& event_name, GamepadEventInit const&);
|
||||
[[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<GamepadEvent>> construct_impl(JS::Realm&, FlyString const& event_name, GamepadEventInit const& = {});
|
||||
|
||||
virtual ~GamepadEvent() override;
|
||||
|
||||
GC::Ref<Gamepad> gamepad() const { return m_gamepad; }
|
||||
GC::Ptr<Gamepad> gamepad() const { return m_gamepad; }
|
||||
|
||||
private:
|
||||
GamepadEvent(JS::Realm&, FlyString const& event_name, GamepadEventInit const& event_init);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
GC::Ref<Gamepad> m_gamepad;
|
||||
GC::Ptr<Gamepad> m_gamepad;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,15 @@
|
|||
// https://w3c.github.io/gamepad/#dom-gamepadevent
|
||||
[Exposed=Window]
|
||||
interface GamepadEvent : Event {
|
||||
constructor(DOMString type, GamepadEventInit eventInitDict);
|
||||
[SameObject] readonly attribute Gamepad gamepad;
|
||||
// eventInitDict is not marked as optional in the specification, but existing implementations treat it as optional.
|
||||
// See: https://github.com/w3c/gamepad/pull/217
|
||||
constructor(DOMString type, optional GamepadEventInit eventInitDict = {});
|
||||
[SameObject] readonly attribute Gamepad? gamepad;
|
||||
};
|
||||
|
||||
// https://w3c.github.io/gamepad/#dom-gamepadeventinit
|
||||
dictionary GamepadEventInit : EventInit {
|
||||
required Gamepad gamepad;
|
||||
// This is marked as required in the specification, but existing implementations treat it as optional.
|
||||
// See: https://github.com/w3c/gamepad/pull/217
|
||||
Gamepad? gamepad = null;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ Harness status: OK
|
|||
|
||||
Found 1 tests
|
||||
|
||||
1 Fail
|
||||
Fail Constructed GamepadEvent timestamp should be high resolution and have the same time origin as performance.now()
|
||||
1 Pass
|
||||
Pass Constructed GamepadEvent timestamp should be high resolution and have the same time origin as performance.now()
|
||||
|
|
@ -2,8 +2,8 @@ Harness status: OK
|
|||
|
||||
Found 85 tests
|
||||
|
||||
81 Pass
|
||||
4 Fail
|
||||
83 Pass
|
||||
2 Fail
|
||||
Pass idl_test setup
|
||||
Pass idl_test validation
|
||||
Pass Partial interface Navigator: original interface defined
|
||||
|
|
@ -72,15 +72,15 @@ Pass GamepadHapticActuator interface: attribute effects
|
|||
Pass GamepadHapticActuator interface: operation playEffect(GamepadHapticEffectType, optional GamepadEffectParameters)
|
||||
Pass GamepadHapticActuator interface: operation reset()
|
||||
Pass GamepadEvent interface: existence and properties of interface object
|
||||
Pass GamepadEvent interface object length
|
||||
Fail GamepadEvent interface object length
|
||||
Pass GamepadEvent interface object name
|
||||
Pass GamepadEvent interface: existence and properties of interface prototype object
|
||||
Pass GamepadEvent interface: existence and properties of interface prototype object's "constructor" property
|
||||
Pass GamepadEvent interface: existence and properties of interface prototype object's @@unscopables property
|
||||
Pass GamepadEvent interface: attribute gamepad
|
||||
Fail GamepadEvent must be primary interface of new GamepadEvent("gamepad")
|
||||
Fail Stringification of new GamepadEvent("gamepad")
|
||||
Fail GamepadEvent interface: new GamepadEvent("gamepad") must inherit property "gamepad" with the proper type
|
||||
Pass GamepadEvent must be primary interface of new GamepadEvent("gamepad")
|
||||
Pass Stringification of new GamepadEvent("gamepad")
|
||||
Pass GamepadEvent interface: new GamepadEvent("gamepad") must inherit property "gamepad" with the proper type
|
||||
Pass HTMLBodyElement interface: attribute ongamepadconnected
|
||||
Pass HTMLBodyElement interface: attribute ongamepaddisconnected
|
||||
Pass Window interface: attribute ongamepadconnected
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user