mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
dom: Implement current window event.
This commit is contained in:
parent
19f4be38d2
commit
097a84671a
6 changed files with 63 additions and 24 deletions
|
@ -150,6 +150,23 @@ pub enum CompiledEventListener {
|
|||
}
|
||||
|
||||
impl CompiledEventListener {
|
||||
#[allow(unsafe_code)]
|
||||
pub fn associated_global(&self) -> DomRoot<GlobalScope> {
|
||||
let obj = match self {
|
||||
CompiledEventListener::Listener(listener) => listener.callback(),
|
||||
CompiledEventListener::Handler(CommonEventHandler::EventHandler(handler)) => {
|
||||
handler.callback()
|
||||
},
|
||||
CompiledEventListener::Handler(CommonEventHandler::ErrorEventHandler(handler)) => {
|
||||
handler.callback()
|
||||
},
|
||||
CompiledEventListener::Handler(CommonEventHandler::BeforeUnloadEventHandler(
|
||||
handler,
|
||||
)) => handler.callback(),
|
||||
};
|
||||
unsafe { GlobalScope::from_object(obj) }
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-event-handler-processing-algorithm
|
||||
pub fn call_or_handle_event(
|
||||
&self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue