aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/clientrect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script/dom/clientrect.rs')
-rw-r--r--src/components/script/dom/clientrect.rs34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/components/script/dom/clientrect.rs b/src/components/script/dom/clientrect.rs
index 3d84944dfaa..316269bfc56 100644
--- a/src/components/script/dom/clientrect.rs
+++ b/src/components/script/dom/clientrect.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::BindingDeclarations::ClientRectBinding;
-use dom::bindings::js::JS;
+use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::window::Window;
use servo_util::geometry::Au;
@@ -19,7 +19,7 @@ pub struct ClientRect {
}
impl ClientRect {
- pub fn new_inherited(window: JS<Window>,
+ pub fn new_inherited(window: &JSRef<Window>,
top: Au, bottom: Au,
left: Au, right: Au) -> ClientRect {
ClientRect {
@@ -28,39 +28,49 @@ impl ClientRect {
left: left.to_nearest_px() as f32,
right: right.to_nearest_px() as f32,
reflector_: Reflector::new(),
- window: window,
+ window: window.unrooted(),
}
}
- pub fn new(window: &JS<Window>,
+ pub fn new(window: &JSRef<Window>,
top: Au, bottom: Au,
- left: Au, right: Au) -> JS<ClientRect> {
- let rect = ClientRect::new_inherited(window.clone(), top, bottom, left, right);
+ left: Au, right: Au) -> Temporary<ClientRect> {
+ let rect = ClientRect::new_inherited(window, top, bottom, left, right);
reflect_dom_object(~rect, window, ClientRectBinding::Wrap)
}
+}
+pub trait ClientRectMethods {
+ fn Top(&self) -> f32;
+ fn Bottom(&self) -> f32;
+ fn Left(&self) -> f32;
+ fn Right(&self) -> f32;
+ fn Width(&self) -> f32;
+ fn Height(&self) -> f32;
+}
- pub fn Top(&self) -> f32 {
+impl<'a> ClientRectMethods for JSRef<'a, ClientRect> {
+ fn Top(&self) -> f32 {
self.top
}
- pub fn Bottom(&self) -> f32 {
+ fn Bottom(&self) -> f32 {
self.bottom
}
- pub fn Left(&self) -> f32 {
+ fn Left(&self) -> f32 {
self.left
}
- pub fn Right(&self) -> f32 {
+ fn Right(&self) -> f32 {
self.right
}
- pub fn Width(&self) -> f32 {
+ fn Width(&self) -> f32 {
(self.right - self.left).abs()
}
- pub fn Height(&self) -> f32 {
+ fn Height(&self) -> f32 {
(self.bottom - self.top).abs()
}
}