script: add PointerEvent (#34437)

* Add PointerEvent webIDL

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Implement all new methods

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Cleanup warnings

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Update wpt meta

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Update interface list

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Update manifest

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Update doc links

Signed-off-by: Wu Wayne <yuweiwu@pm.me>

---------

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>
Signed-off-by: Wu Wayne <yuweiwu@pm.me>
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2024-12-02 20:53:29 +09:00 committed by GitHub
parent 9457a40ca2
commit e061a59f03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 993 additions and 7 deletions

View file

@ -157,7 +157,53 @@ impl MouseEvent {
can_gc: CanGc,
) -> DomRoot<MouseEvent> {
let ev = MouseEvent::new_uninitialized_with_proto(window, proto, can_gc);
ev.InitMouseEvent(
ev.initialize_mouse_event(
type_,
can_bubble,
cancelable,
view,
detail,
screen_x,
screen_y,
client_x,
client_y,
ctrl_key,
alt_key,
shift_key,
meta_key,
button,
buttons,
related_target,
point_in_target,
);
ev
}
/// <https://w3c.github.io/uievents/#initialize-a-mouseevent>
#[allow(clippy::too_many_arguments)]
pub fn initialize_mouse_event(
&self,
type_: DOMString,
can_bubble: EventBubbles,
cancelable: EventCancelable,
view: Option<&Window>,
detail: i32,
screen_x: i32,
screen_y: i32,
client_x: i32,
client_y: i32,
ctrl_key: bool,
alt_key: bool,
shift_key: bool,
meta_key: bool,
button: i16,
buttons: u16,
related_target: Option<&EventTarget>,
point_in_target: Option<Point2D<f32>>,
) {
// TODO: InitMouseEvent has been deprecated. We should follow the link to create an UI
// Event instead.
self.InitMouseEvent(
type_,
bool::from(can_bubble),
bool::from(cancelable),
@ -174,12 +220,11 @@ impl MouseEvent {
button,
related_target,
);
ev.buttons.set(buttons);
ev.point_in_target.set(point_in_target);
self.buttons.set(buttons);
self.point_in_target.set(point_in_target);
// TODO: Set proper values in https://github.com/servo/servo/issues/24415
ev.page_x.set(client_x);
ev.page_y.set(client_y);
ev
self.page_x.set(client_x);
self.page_y.set(client_y);
}
pub fn point_in_target(&self) -> Option<Point2D<f32>> {