mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-24 19:28:48 +00:00
LibWeb: Use WindowProxy instead of Window in UI Events IDL
I believe this is an error in the UI Events spec, and it should be
updated to match the HTML spec (which uses WindowProxy everywhere).
This fixes a bunch of issues already covered by existing WPT tests.
Spec bug: https://github.com/w3c/uievents/issues/388
Note that WebKit has been using WindowProxy instead of Window in
UI Events IDL since 2018:
816158b4aa
This commit is contained in:
parent
5bcba896c2
commit
3e8c8b185e
Notes:
github-actions[bot]
2024-11-17 23:00:48 +00:00
Author: https://github.com/awesomekling
Commit: 3e8c8b185e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2406
20 changed files with 32 additions and 32 deletions
|
@ -37,7 +37,7 @@ void CompositionEvent::initialize(JS::Realm& realm)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/uievents/#dom-compositionevent-initcompositionevent
|
||||
void CompositionEvent::init_composition_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& data)
|
||||
void CompositionEvent::init_composition_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, String const& data)
|
||||
{
|
||||
// Initializes attributes of a CompositionEvent object. This method has the same behavior as UIEvent.initUIEvent().
|
||||
// The value of detail remains undefined.
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
// https://w3c.github.io/uievents/#dom-compositionevent-data
|
||||
String data() const { return m_data; }
|
||||
|
||||
void init_composition_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& data);
|
||||
void init_composition_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, String const& data);
|
||||
|
||||
private:
|
||||
CompositionEvent(JS::Realm&, FlyString const& event_name, CompositionEventInit const&);
|
||||
|
|
|
@ -8,7 +8,7 @@ interface CompositionEvent : UIEvent {
|
|||
|
||||
// https://w3c.github.io/uievents/#dom-compositionevent-initcompositionevent
|
||||
// FIXME: The spec uses WindowProxy rather than Window (see https://github.com/w3c/uievents/pull/379).
|
||||
undefined initCompositionEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional Window? viewArg = null, optional DOMString dataArg = "");
|
||||
undefined initCompositionEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional WindowProxy? viewArg = null, optional DOMString dataArg = "");
|
||||
};
|
||||
|
||||
// https://w3c.github.io/uievents/#dictdef-compositioneventinit
|
||||
|
|
|
@ -730,7 +730,7 @@ bool KeyboardEvent::get_modifier_state(String const& key_arg) const
|
|||
}
|
||||
|
||||
// https://w3c.github.io/uievents/#dom-keyboardevent-initkeyboardevent
|
||||
void KeyboardEvent::init_keyboard_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& key, WebIDL::UnsignedLong location, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key)
|
||||
void KeyboardEvent::init_keyboard_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, String const& key, WebIDL::UnsignedLong location, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key)
|
||||
{
|
||||
// Initializes attributes of a KeyboardEvent object. This method has the same behavior as UIEvent.initUIEvent().
|
||||
// The value of detail remains undefined.
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
virtual u32 which() const override { return m_key_code; }
|
||||
|
||||
void init_keyboard_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& key, WebIDL::UnsignedLong location, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key);
|
||||
void init_keyboard_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, String const& key, WebIDL::UnsignedLong location, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key);
|
||||
|
||||
private:
|
||||
KeyboardEvent(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& event_init);
|
||||
|
|
|
@ -30,7 +30,7 @@ interface KeyboardEvent : UIEvent {
|
|||
boolean getModifierState(DOMString keyArg);
|
||||
|
||||
// https://w3c.github.io/uievents/#dom-keyboardevent-initkeyboardevent
|
||||
undefined initKeyboardEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional Window? viewArg = null, optional DOMString keyArg = "", optional unsigned long locationArg = 0, optional boolean ctrlKey = false, optional boolean altKey = false, optional boolean shiftKey = false, optional boolean metaKey = false);
|
||||
undefined initKeyboardEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional WindowProxy? viewArg = null, optional DOMString keyArg = "", optional unsigned long locationArg = 0, optional boolean ctrlKey = false, optional boolean altKey = false, optional boolean shiftKey = false, optional boolean metaKey = false);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ bool MouseEvent::get_modifier_state(String const& key_arg) const
|
|||
}
|
||||
|
||||
// https://w3c.github.io/uievents/#dom-mouseevent-initmouseevent
|
||||
void MouseEvent::init_mouse_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, WebIDL::Long detail, WebIDL::Long screen_x, WebIDL::Long screen_y, WebIDL::Long client_x, WebIDL::Long client_y, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key, WebIDL::Short button, DOM::EventTarget* related_target)
|
||||
void MouseEvent::init_mouse_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, WebIDL::Long detail, WebIDL::Long screen_x, WebIDL::Long screen_y, WebIDL::Long client_x, WebIDL::Long client_y, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key, WebIDL::Short button, DOM::EventTarget* related_target)
|
||||
{
|
||||
// Initializes attributes of a MouseEvent object. This method has the same behavior as UIEvent.initUIEvent().
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
virtual u32 which() const override { return m_button + 1; }
|
||||
|
||||
void init_mouse_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, WebIDL::Long detail, WebIDL::Long screen_x, WebIDL::Long screen_y, WebIDL::Long client_x, WebIDL::Long client_y, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key, WebIDL::Short button, DOM::EventTarget* related_target);
|
||||
void init_mouse_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, WebIDL::Long detail, WebIDL::Long screen_x, WebIDL::Long screen_y, WebIDL::Long client_x, WebIDL::Long client_y, bool ctrl_key, bool alt_key, bool shift_key, bool meta_key, WebIDL::Short button, DOM::EventTarget* related_target);
|
||||
|
||||
protected:
|
||||
MouseEvent(JS::Realm&, FlyString const& event_name, MouseEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y);
|
||||
|
|
|
@ -34,7 +34,7 @@ interface MouseEvent : UIEvent {
|
|||
boolean getModifierState(DOMString keyArg);
|
||||
|
||||
// https://w3c.github.io/uievents/#dom-mouseevent-initmouseevent
|
||||
undefined initMouseEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional Window? viewArg = null, optional long detailArg = 0, optional long screenXArg = 0, optional long screenYArg = 0, optional long clientXArg = 0, optional long clientYArg = 0, optional boolean ctrlKeyArg = false, optional boolean altKeyArg = false, optional boolean shiftKeyArg = false, optional boolean metaKeyArg = false, optional short buttonArg = 0, optional EventTarget? relatedTargetArg = null);
|
||||
undefined initMouseEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional WindowProxy? viewArg = null, optional long detailArg = 0, optional long screenXArg = 0, optional long screenYArg = 0, optional long clientXArg = 0, optional long clientYArg = 0, optional boolean ctrlKeyArg = false, optional boolean altKeyArg = false, optional boolean shiftKeyArg = false, optional boolean metaKeyArg = false, optional short buttonArg = 0, optional EventTarget? relatedTargetArg = null);
|
||||
};
|
||||
|
||||
// https://w3c.github.io/uievents/#idl-mouseeventinit
|
||||
|
|
|
@ -31,7 +31,7 @@ void TextEvent::initialize(JS::Realm& realm)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/uievents/#dom-textevent-inittextevent
|
||||
void TextEvent::init_text_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& data)
|
||||
void TextEvent::init_text_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, String const& data)
|
||||
{
|
||||
// Initializes attributes of a TextEvent object. This method has the same behavior as UIEvent.initUIEvent().
|
||||
// The value of detail remains undefined.
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
// https://w3c.github.io/uievents/#dom-textevent-data
|
||||
String data() const { return m_data; }
|
||||
|
||||
void init_text_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, String const& data);
|
||||
void init_text_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, String const& data);
|
||||
|
||||
private:
|
||||
TextEvent(JS::Realm&, FlyString const& event_name);
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
[Exposed=Window]
|
||||
interface TextEvent : UIEvent {
|
||||
readonly attribute DOMString data;
|
||||
undefined initTextEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional Window? view = null, optional DOMString data = "undefined");
|
||||
undefined initTextEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional WindowProxy? view = null, optional DOMString data = "undefined");
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/UIEventPrototype.h>
|
||||
#include <LibWeb/HTML/WindowProxy.h>
|
||||
#include <LibWeb/UIEvents/UIEvent.h>
|
||||
|
||||
namespace Web::UIEvents {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace Web::UIEvents {
|
||||
|
||||
struct UIEventInit : public DOM::EventInit {
|
||||
GC::Ptr<HTML::Window> view;
|
||||
GC::Ptr<HTML::WindowProxy> view;
|
||||
int detail { 0 };
|
||||
};
|
||||
|
||||
|
@ -27,11 +27,11 @@ public:
|
|||
|
||||
virtual ~UIEvent() override;
|
||||
|
||||
HTML::Window const* view() const { return m_view.ptr(); }
|
||||
GC::Ptr<HTML::WindowProxy> const view() const { return m_view; }
|
||||
int detail() const { return m_detail; }
|
||||
virtual u32 which() const { return 0; }
|
||||
|
||||
void init_ui_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, int detail)
|
||||
void init_ui_event(String const& type, bool bubbles, bool cancelable, GC::Ptr<HTML::WindowProxy> view, int detail)
|
||||
{
|
||||
// Initializes attributes of an UIEvent object. This method has the same behavior as initEvent().
|
||||
|
||||
|
@ -54,7 +54,7 @@ protected:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
GC::Ptr<HTML::Window> m_view;
|
||||
GC::Ptr<HTML::WindowProxy> m_view;
|
||||
int m_detail { 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
[Exposed=Window]
|
||||
interface UIEvent : Event {
|
||||
constructor(DOMString type, optional UIEventInit eventInitDict = {});
|
||||
readonly attribute Window? view;
|
||||
readonly attribute WindowProxy? view;
|
||||
readonly attribute long detail;
|
||||
|
||||
// Obsolete
|
||||
[ImplementedAs=init_ui_event] undefined initUIEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional Window? viewArg = null, optional long detailArg = 0);
|
||||
[ImplementedAs=init_ui_event] undefined initUIEvent(DOMString typeArg, optional boolean bubblesArg = false, optional boolean cancelableArg = false, optional WindowProxy? viewArg = null, optional long detailArg = 0);
|
||||
readonly attribute unsigned long which;
|
||||
};
|
||||
|
||||
// https://w3c.github.io/uievents/#idl-uieventinit
|
||||
dictionary UIEventInit : EventInit {
|
||||
Window? view = null;
|
||||
WindowProxy? view = null;
|
||||
long detail = 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue