mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Implement RootedVec<T>
This commit is contained in:
parent
4cf76d65ba
commit
e8a1e9eabb
5 changed files with 168 additions and 27 deletions
|
@ -6,6 +6,7 @@ use dom::bindings::codegen::Bindings::DOMRectListBinding;
|
|||
use dom::bindings::codegen::Bindings::DOMRectListBinding::DOMRectListMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, JSRef, Temporary};
|
||||
use dom::bindings::trace::RootedVec;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::domrect::DOMRect;
|
||||
use dom::window::Window;
|
||||
|
@ -19,17 +20,16 @@ pub struct DOMRectList {
|
|||
|
||||
impl DOMRectList {
|
||||
fn new_inherited(window: JSRef<Window>,
|
||||
rects: Vec<JSRef<DOMRect>>) -> DOMRectList {
|
||||
let rects = rects.iter().map(|rect| JS::from_rooted(*rect)).collect();
|
||||
rects: &RootedVec<JS<DOMRect>>) -> DOMRectList {
|
||||
DOMRectList {
|
||||
reflector_: Reflector::new(),
|
||||
rects: rects,
|
||||
rects: (**rects).clone(),
|
||||
window: JS::from_rooted(window),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(window: JSRef<Window>,
|
||||
rects: Vec<JSRef<DOMRect>>) -> Temporary<DOMRectList> {
|
||||
rects: &RootedVec<JS<DOMRect>>) -> Temporary<DOMRectList> {
|
||||
reflect_dom_object(box DOMRectList::new_inherited(window, rects),
|
||||
GlobalRef::Window(window), DOMRectListBinding::Wrap)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue