mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
retire deprecated MouseEvent::InitMouseEvent (#34538)
Signed-off-by: Jay Wang <xdddxyyyxzzz123@gmail.com> Co-authored-by: Ngo Iok Ui (Wu Yu Wei) <yuweiwu@pm.me>
This commit is contained in:
parent
4103421ba5
commit
dd2fc75b71
2 changed files with 31 additions and 20 deletions
|
@ -201,30 +201,37 @@ impl MouseEvent {
|
||||||
related_target: Option<&EventTarget>,
|
related_target: Option<&EventTarget>,
|
||||||
point_in_target: Option<Point2D<f32>>,
|
point_in_target: Option<Point2D<f32>>,
|
||||||
) {
|
) {
|
||||||
// TODO: InitMouseEvent has been deprecated. We should follow the link to create an UI
|
self.uievent.initialize_ui_event(
|
||||||
// Event instead.
|
|
||||||
self.InitMouseEvent(
|
|
||||||
type_,
|
type_,
|
||||||
bool::from(can_bubble),
|
view.map(|window| window.upcast::<EventTarget>()),
|
||||||
bool::from(cancelable),
|
can_bubble,
|
||||||
view,
|
cancelable,
|
||||||
detail,
|
|
||||||
screen_x,
|
|
||||||
screen_y,
|
|
||||||
client_x,
|
|
||||||
client_y,
|
|
||||||
ctrl_key,
|
|
||||||
alt_key,
|
|
||||||
shift_key,
|
|
||||||
meta_key,
|
|
||||||
button,
|
|
||||||
related_target,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.uievent.set_detail(detail);
|
||||||
|
|
||||||
|
self.screen_x.set(screen_x);
|
||||||
|
self.screen_y.set(screen_y);
|
||||||
|
self.client_x.set(client_x);
|
||||||
|
self.client_y.set(client_y);
|
||||||
|
self.page_x.set(self.PageX());
|
||||||
|
self.page_y.set(self.PageY());
|
||||||
|
|
||||||
|
// skip setting flags as they are absent
|
||||||
|
self.shift_key.set(shift_key);
|
||||||
|
self.ctrl_key.set(ctrl_key);
|
||||||
|
self.alt_key.set(alt_key);
|
||||||
|
self.meta_key.set(meta_key);
|
||||||
|
|
||||||
|
self.button.set(button);
|
||||||
self.buttons.set(buttons);
|
self.buttons.set(buttons);
|
||||||
|
// skip step 3: Initialize PointerLock attributes for MouseEvent with event,
|
||||||
|
// as movementX, movementY is absent
|
||||||
|
|
||||||
|
self.related_target.set(related_target);
|
||||||
|
|
||||||
|
// below is not in the spec
|
||||||
self.point_in_target.set(point_in_target);
|
self.point_in_target.set(point_in_target);
|
||||||
// TODO: Set proper values in https://github.com/servo/servo/issues/24415
|
|
||||||
self.page_x.set(client_x);
|
|
||||||
self.page_y.set(client_y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn point_in_target(&self) -> Option<Point2D<f32>> {
|
pub fn point_in_target(&self) -> Option<Point2D<f32>> {
|
||||||
|
|
|
@ -113,6 +113,10 @@ impl UIEvent {
|
||||||
}
|
}
|
||||||
self.detail.set(0_i32);
|
self.detail.set(0_i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_detail(&self, detail_: i32) {
|
||||||
|
self.detail.set(detail_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UIEventMethods<crate::DomTypeHolder> for UIEvent {
|
impl UIEventMethods<crate::DomTypeHolder> for UIEvent {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue