Auto merge of #11255 - s-baldrick:11158, r=ConnorGBrewster

11158 - add event handlers

Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data:
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy --faster` does not report any errors
- [X] These changes fix #11158 (github issue number if applicable).

Either:
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ____

Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11255)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-05-20 21:26:41 -07:00
commit 5fc511a40e
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;
@ -16,7 +16,6 @@ use dom::htmlelement::HTMLElement;
use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use script_traits::ScriptMsg as ConstellationMsg;
use std::rc::Rc;
use string_cache::Atom;
use time;
use url::Url;
@ -70,31 +69,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 {