Improve implementation of DOMRect and implement DOMRectReadOnly

Passes most tests from test-css.
This commit is contained in:
Till Schneidereit 2015-09-02 14:16:34 +02:00
parent 499a847141
commit 4c1c05fac6
11 changed files with 198 additions and 184 deletions

View file

@ -30,6 +30,7 @@ use dom::bindings::codegen::InheritTypes::{HTMLTemplateElementCast, HTMLTextArea
use dom::bindings::codegen::InheritTypes::{NodeCast, NodeTypeId, TextCast};
use dom::bindings::codegen::UnionTypes::NodeOrString;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
use dom::bindings::js::{Root, RootedReference};
use dom::bindings::utils::XMLName::InvalidXMLName;
@ -1249,9 +1250,11 @@ impl ElementMethods for Element {
let node = NodeCast::from_ref(self);
let raw_rects = node.get_content_boxes();
let rects = raw_rects.iter().map(|rect| {
DOMRect::new(win.r(),
rect.origin.y, rect.origin.y + rect.size.height,
rect.origin.x, rect.origin.x + rect.size.width)
DOMRect::new(GlobalRef::Window(win.r()),
rect.origin.x.to_f64_px(),
rect.origin.y.to_f64_px(),
rect.size.width.to_f64_px(),
rect.size.height.to_f64_px())
});
DOMRectList::new(win.r(), rects)
}
@ -1261,12 +1264,11 @@ impl ElementMethods for Element {
let win = window_from_node(self);
let node = NodeCast::from_ref(self);
let rect = node.get_bounding_content_box();
DOMRect::new(
win.r(),
rect.origin.y,
rect.origin.y + rect.size.height,
rect.origin.x,
rect.origin.x + rect.size.width)
DOMRect::new(GlobalRef::Window(win.r()),
rect.origin.x.to_f64_px(),
rect.origin.y.to_f64_px(),
rect.size.width.to_f64_px(),
rect.size.height.to_f64_px())
}
// https://drafts.csswg.org/cssom-view/#dom-element-clienttop