dom: Add missing event handlers

Adding:
* global event handlers,
* window event handlers,
* document and element handlers,
* and support for BeforeUnloadEvent.

Signed-off-by: Piotr Stankiewicz <bionicrift@gmail.com>
This commit is contained in:
Piotr Stankiewicz 2016-05-15 23:47:15 +01:00
parent 4590fe230f
commit d1af39c114
21 changed files with 373 additions and 861 deletions

View file

@ -4,7 +4,7 @@
use cssparser::RGBA;
use dom::attr::{Attr, AttrValue};
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::EventHandlerBinding::{EventHandlerNonNull, OnBeforeUnloadEventHandlerNonNull};
use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::{self, HTMLBodyElementMethods};
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::inheritance::Castable;
@ -17,7 +17,6 @@ use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use msg::constellation_msg::ConstellationChan;
use script_traits::ScriptMsg as ConstellationMsg;
use std::rc::Rc;
use string_cache::Atom;
use time;
use url::Url;
@ -71,31 +70,14 @@ impl HTMLBodyElementMethods for HTMLBodyElement {
// https://html.spec.whatwg.org/multipage/#dom-body-text
make_legacy_color_setter!(SetText, "text");
// https://html.spec.whatwg.org/multipage/#the-body-element
fn GetOnunload(&self) -> Option<Rc<EventHandlerNonNull>> {
window_from_node(self).GetOnunload()
}
// https://html.spec.whatwg.org/multipage/#the-body-element
fn SetOnunload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
window_from_node(self).SetOnunload(listener)
}
// https://html.spec.whatwg.org/multipage/#the-body-element
fn GetOnstorage(&self) -> Option<Rc<EventHandlerNonNull>> {
window_from_node(self).GetOnstorage()
}
// https://html.spec.whatwg.org/multipage/#the-body-element
fn SetOnstorage(&self, listener: Option<Rc<EventHandlerNonNull>>) {
window_from_node(self).SetOnstorage(listener)
}
// https://html.spec.whatwg.org/multipage/#dom-body-background
make_getter!(Background, "background");
// https://html.spec.whatwg.org/multipage/#dom-body-background
make_url_setter!(SetBackground, "background");
// https://html.spec.whatwg.org/multipage/#windoweventhandlers
window_event_handlers!(ForwardToWindow);
}
pub trait HTMLBodyElementLayoutHelpers {