mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #7623 - aidanhs:aphs-atomise-forwarded-events, r=nox
Match forwarded events as atoms, fixes #7495 Hopefully I understood the issue correctly... <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7623) <!-- Reviewable:end -->
This commit is contained in:
commit
4935323ebf
1 changed files with 9 additions and 11 deletions
|
@ -140,20 +140,18 @@ impl VirtualMethods for HTMLBodyElement {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(name, AttributeMutation::Set(_)) if name.starts_with("on") => {
|
(name, AttributeMutation::Set(_)) if name.starts_with("on") => {
|
||||||
static FORWARDED_EVENTS: &'static [&'static str] =
|
|
||||||
&["onfocus", "onload", "onscroll", "onafterprint", "onbeforeprint",
|
|
||||||
"onbeforeunload", "onhashchange", "onlanguagechange", "onmessage",
|
|
||||||
"onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate",
|
|
||||||
"onstorage", "onresize", "onunload", "onerror"];
|
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let (cx, url, reflector) = (window.get_cx(),
|
let (cx, url, reflector) = (window.get_cx(),
|
||||||
window.get_url(),
|
window.get_url(),
|
||||||
window.reflector().get_jsobject());
|
window.reflector().get_jsobject());
|
||||||
let evtarget =
|
let evtarget = match name {
|
||||||
if FORWARDED_EVENTS.iter().any(|&event| &**name == event) {
|
&atom!(onfocus) | &atom!(onload) | &atom!(onscroll) | &atom!(onafterprint) |
|
||||||
EventTargetCast::from_ref(window.r())
|
&atom!(onbeforeprint) | &atom!(onbeforeunload) | &atom!(onhashchange) |
|
||||||
} else {
|
&atom!(onlanguagechange) | &atom!(onmessage) | &atom!(onoffline) | &atom!(ononline) |
|
||||||
EventTargetCast::from_ref(self)
|
&atom!(onpagehide) | &atom!(onpageshow) | &atom!(onpopstate) | &atom!(onstorage) |
|
||||||
|
&atom!(onresize) | &atom!(onunload) | &atom!(onerror)
|
||||||
|
=> EventTargetCast::from_ref(window.r()), // forwarded event
|
||||||
|
_ => EventTargetCast::from_ref(self),
|
||||||
};
|
};
|
||||||
evtarget.set_event_handler_uncompiled(cx, url, reflector,
|
evtarget.set_event_handler_uncompiled(cx, url, reflector,
|
||||||
&name[2..],
|
&name[2..],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue