mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
fix unit of clientrect &
add width,height test in src/test/html/content/test_getBoundingClientRect.html
This commit is contained in:
parent
2b487ed3e9
commit
e0a04fff46
3 changed files with 24 additions and 18 deletions
|
@ -5,6 +5,7 @@
|
|||
use dom::bindings::codegen::ClientRectBinding;
|
||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::window::Window;
|
||||
use servo_util::geometry::Au;
|
||||
|
||||
pub struct ClientRect {
|
||||
reflector_: Reflector,
|
||||
|
@ -17,25 +18,26 @@ pub struct ClientRect {
|
|||
|
||||
impl ClientRect {
|
||||
pub fn new_inherited(window: @mut Window,
|
||||
top: f32, bottom: f32,
|
||||
left: f32, right: f32) -> ClientRect {
|
||||
top: Au, bottom: Au,
|
||||
left: Au, right: Au) -> ClientRect {
|
||||
ClientRect {
|
||||
top: top,
|
||||
bottom: bottom,
|
||||
left: left,
|
||||
right: right,
|
||||
top: top.to_nearest_px() as f32,
|
||||
bottom: bottom.to_nearest_px() as f32,
|
||||
left: left.to_nearest_px() as f32,
|
||||
right: right.to_nearest_px() as f32,
|
||||
reflector_: Reflector::new(),
|
||||
window: window,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(window: @mut Window,
|
||||
top: f32, bottom: f32,
|
||||
left: f32, right: f32) -> @mut ClientRect {
|
||||
top: Au, bottom: Au,
|
||||
left: Au, right: Au) -> @mut ClientRect {
|
||||
let rect = ClientRect::new_inherited(window, top, bottom, left, right);
|
||||
reflect_dom_object(@mut rect, window, ClientRectBinding::Wrap)
|
||||
}
|
||||
|
||||
|
||||
pub fn Top(&self) -> f32 {
|
||||
self.top
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue