mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
dom: Set "composed" flag on construction for some event types (#36239)
"Composed" flag (https://dom.spec.whatwg.org/#composed-flag) should be properly set on event construction phase from optional "EventInit" dictionary (https://dom.spec.whatwg.org/#dom-eventinit-composed). The limited set of event types (Custom/Error/Focus/Mouse) will be affected by this CL (used in WPT tests). --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are WPT shadow-dom tests which have new issues related to event "relatedTarget" property tests/wpt/tests/shadow-dom/event-composed-path-with-related-target.html tests/wpt/tests/shadow-dom/event-with-related-target.html Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This commit is contained in:
parent
7382efa209
commit
f48c3a5e2a
10 changed files with 24 additions and 21 deletions
|
@ -93,7 +93,7 @@ impl CustomEventMethods<crate::DomTypeHolder> for CustomEvent {
|
|||
type_: DOMString,
|
||||
init: RootedTraceableBox<CustomEventBinding::CustomEventInit>,
|
||||
) -> DomRoot<CustomEvent> {
|
||||
CustomEvent::new(
|
||||
let event = CustomEvent::new(
|
||||
global,
|
||||
proto,
|
||||
Atom::from(type_),
|
||||
|
@ -101,7 +101,9 @@ impl CustomEventMethods<crate::DomTypeHolder> for CustomEvent {
|
|||
init.parent.cancelable,
|
||||
init.detail.handle(),
|
||||
can_gc,
|
||||
)
|
||||
);
|
||||
event.upcast::<Event>().set_composed(init.parent.composed);
|
||||
event
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-customevent-detail
|
||||
|
|
|
@ -142,6 +142,7 @@ impl ErrorEventMethods<crate::DomTypeHolder> for ErrorEvent {
|
|||
init.error.handle(),
|
||||
can_gc,
|
||||
);
|
||||
event.upcast::<Event>().set_composed(init.parent.composed);
|
||||
Ok(event)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::event::{EventBubbles, EventCancelable};
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::uievent::UIEvent;
|
||||
use crate::dom::window::Window;
|
||||
|
@ -118,6 +118,9 @@ impl FocusEventMethods<crate::DomTypeHolder> for FocusEvent {
|
|||
init.relatedTarget.as_deref(),
|
||||
can_gc,
|
||||
);
|
||||
event
|
||||
.upcast::<Event>()
|
||||
.set_composed(init.parent.parent.composed);
|
||||
Ok(event)
|
||||
}
|
||||
|
||||
|
|
|
@ -342,6 +342,9 @@ impl MouseEventMethods<crate::DomTypeHolder> for MouseEvent {
|
|||
None,
|
||||
can_gc,
|
||||
);
|
||||
event
|
||||
.upcast::<Event>()
|
||||
.set_composed(init.parent.parent.parent.composed);
|
||||
Ok(event)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue