aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/htmlbodyelement.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2014-04-21 22:43:20 -0400
committerMs2ger <ms2ger@gmail.com>2014-05-27 20:43:48 +0200
commit33955f0ab20c5d7edd7f334459822816b2aa031e (patch)
tree8a6c382b12a0755b5470f099a25254f23979aea0 /src/components/script/dom/htmlbodyelement.rs
parent2d6153772cc316be229d68e4d267600da406fcd4 (diff)
downloadservo-33955f0ab20c5d7edd7f334459822816b2aa031e.tar.gz
servo-33955f0ab20c5d7edd7f334459822816b2aa031e.zip
Implement window forwarding for body event handlers.
Diffstat (limited to 'src/components/script/dom/htmlbodyelement.rs')
-rw-r--r--src/components/script/dom/htmlbodyelement.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/components/script/dom/htmlbodyelement.rs b/src/components/script/dom/htmlbodyelement.rs
index 37962f3c540..c768444126f 100644
--- a/src/components/script/dom/htmlbodyelement.rs
+++ b/src/components/script/dom/htmlbodyelement.rs
@@ -10,7 +10,9 @@ use dom::document::Document;
use dom::element::HTMLBodyElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement;
-use dom::node::{Node, ElementNodeTypeId};
+use dom::node::{Node, ElementNodeTypeId, window_from_node};
+use dom::window::WindowMethods;
+use js::jsapi::{JSContext, JSObject};
use servo_util::str::DOMString;
#[deriving(Encodable)]
@@ -50,6 +52,8 @@ pub trait HTMLBodyElementMethods {
fn SetBgColor(&self, _bg_color: DOMString) -> ErrorResult;
fn Background(&self) -> DOMString;
fn SetBackground(&self, _background: DOMString) -> ErrorResult;
+ fn GetOnunload(&self, cx: *mut JSContext) -> *mut JSObject;
+ fn SetOnunload(&mut self, cx: *mut JSContext, listener: *mut JSObject);
}
impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
@@ -100,4 +104,14 @@ impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
fn SetBackground(&self, _background: DOMString) -> ErrorResult {
Ok(())
}
+
+ fn GetOnunload(&self, cx: *mut JSContext) -> *mut JSObject {
+ let win = window_from_node(self).root();
+ win.deref().GetOnunload(cx)
+ }
+
+ fn SetOnunload(&mut self, cx: *mut JSContext, listener: *mut JSObject) {
+ let mut win = window_from_node(self).root();
+ win.SetOnunload(cx, listener)
+ }
}