mirror of
https://github.com/servo/servo.git
synced 2025-09-18 19:08:22 +01:00
Set composed flag for TouchEvent
(#39138)
Following the definition of `TouchEvent` in https://w3c.github.io/touch-events/#list-of-touchevent-types, all `TouchEvent` should have its `composed` flag set to be able to propagate past a shadow root layer. Part of #35997 Testing: Would require a testdriver. Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
This commit is contained in:
parent
8f4ced66d7
commit
b1ab72e589
2 changed files with 20 additions and 2 deletions
|
@ -44,7 +44,7 @@ use crate::dom::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::root::MutNullableDom;
|
use crate::dom::bindings::root::MutNullableDom;
|
||||||
use crate::dom::clipboardevent::ClipboardEventType;
|
use crate::dom::clipboardevent::ClipboardEventType;
|
||||||
use crate::dom::document::{FireMouseEventType, FocusInitiator, TouchEventResult};
|
use crate::dom::document::{FireMouseEventType, FocusInitiator, TouchEventResult};
|
||||||
use crate::dom::event::{EventBubbles, EventCancelable, EventDefault};
|
use crate::dom::event::{EventBubbles, EventCancelable, EventComposed, EventDefault};
|
||||||
use crate::dom::gamepad::gamepad::{Gamepad, contains_user_gesture};
|
use crate::dom::gamepad::gamepad::{Gamepad, contains_user_gesture};
|
||||||
use crate::dom::gamepad::gamepadevent::GamepadEventType;
|
use crate::dom::gamepad::gamepadevent::GamepadEventType;
|
||||||
use crate::dom::inputevent::HitTestResult;
|
use crate::dom::inputevent::HitTestResult;
|
||||||
|
@ -870,6 +870,7 @@ impl DocumentEventHandler {
|
||||||
DOMString::from(event_name),
|
DOMString::from(event_name),
|
||||||
EventBubbles::Bubbles,
|
EventBubbles::Bubbles,
|
||||||
EventCancelable::from(event.is_cancelable()),
|
EventCancelable::from(event.is_cancelable()),
|
||||||
|
EventComposed::Composed,
|
||||||
Some(window),
|
Some(window),
|
||||||
0i32,
|
0i32,
|
||||||
&touches,
|
&touches,
|
||||||
|
|
|
@ -12,21 +12,36 @@ use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||||
use crate::dom::bindings::root::{DomRoot, MutDom};
|
use crate::dom::bindings::root::{DomRoot, MutDom};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::event::{EventBubbles, EventCancelable};
|
use crate::dom::event::{Event, EventBubbles, EventCancelable, EventComposed};
|
||||||
use crate::dom::touchlist::TouchList;
|
use crate::dom::touchlist::TouchList;
|
||||||
use crate::dom::uievent::UIEvent;
|
use crate::dom::uievent::UIEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
|
/// <https://w3c.github.io/touch-events/#dom-touchevent>
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub(crate) struct TouchEvent {
|
pub(crate) struct TouchEvent {
|
||||||
uievent: UIEvent,
|
uievent: UIEvent,
|
||||||
|
|
||||||
|
/// <https://w3c.github.io/touch-events/#dom-touchevent-touches>
|
||||||
touches: MutDom<TouchList>,
|
touches: MutDom<TouchList>,
|
||||||
|
|
||||||
|
/// <https://w3c.github.io/touch-events/#dom-touchevent-targettouches>
|
||||||
target_touches: MutDom<TouchList>,
|
target_touches: MutDom<TouchList>,
|
||||||
|
|
||||||
|
/// <https://w3c.github.io/touch-events/#dom-touchevent-changedtouches>
|
||||||
changed_touches: MutDom<TouchList>,
|
changed_touches: MutDom<TouchList>,
|
||||||
|
|
||||||
|
/// <https://w3c.github.io/touch-events/#dom-touchevent-altkey>
|
||||||
alt_key: Cell<bool>,
|
alt_key: Cell<bool>,
|
||||||
|
|
||||||
|
/// <https://w3c.github.io/touch-events/#dom-touchevent-metakey>
|
||||||
meta_key: Cell<bool>,
|
meta_key: Cell<bool>,
|
||||||
|
|
||||||
|
/// <https://w3c.github.io/touch-events/#dom-touchevent-ctrlkey>
|
||||||
ctrl_key: Cell<bool>,
|
ctrl_key: Cell<bool>,
|
||||||
|
|
||||||
|
/// <https://w3c.github.io/touch-events/#dom-touchevent-shiftkey>
|
||||||
shift_key: Cell<bool>,
|
shift_key: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +87,7 @@ impl TouchEvent {
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
can_bubble: EventBubbles,
|
can_bubble: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
|
composed: EventComposed,
|
||||||
view: Option<&Window>,
|
view: Option<&Window>,
|
||||||
detail: i32,
|
detail: i32,
|
||||||
touches: &TouchList,
|
touches: &TouchList,
|
||||||
|
@ -92,6 +108,7 @@ impl TouchEvent {
|
||||||
view,
|
view,
|
||||||
detail,
|
detail,
|
||||||
);
|
);
|
||||||
|
ev.upcast::<Event>().set_composed(bool::from(composed));
|
||||||
ev.ctrl_key.set(ctrl_key);
|
ev.ctrl_key.set(ctrl_key);
|
||||||
ev.alt_key.set(alt_key);
|
ev.alt_key.set(alt_key);
|
||||||
ev.shift_key.set(shift_key);
|
ev.shift_key.set(shift_key);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue