mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Cleanup ClientRectList binding.
This commit is contained in:
parent
f75568e939
commit
6af555ab23
2 changed files with 22 additions and 25 deletions
|
@ -3,29 +3,32 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::ClientRectListBinding;
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::clientrect::ClientRect;
|
||||
use script_task::page_from_context;
|
||||
use dom::window::Window;
|
||||
|
||||
use js::jsapi::{JSObject, JSContext};
|
||||
|
||||
pub struct ClientRectList {
|
||||
reflector_: Reflector,
|
||||
rects: ~[@mut ClientRect]
|
||||
rects: ~[@mut ClientRect],
|
||||
window: @mut Window,
|
||||
}
|
||||
|
||||
impl ClientRectList {
|
||||
pub fn new(rects: ~[@mut ClientRect], cx: *JSContext, scope: *JSObject) -> @mut ClientRectList {
|
||||
let list = @mut ClientRectList {
|
||||
pub fn new_inherited(window: @mut Window,
|
||||
rects: ~[@mut ClientRect]) -> ClientRectList {
|
||||
ClientRectList {
|
||||
reflector_: Reflector::new(),
|
||||
rects: rects
|
||||
};
|
||||
list.init_wrapper(cx, scope);
|
||||
list
|
||||
rects: rects,
|
||||
window: window,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_wrapper(@mut self, cx: *JSContext, scope: *JSObject) {
|
||||
self.wrap_object_shared(cx, scope);
|
||||
pub fn new(window: @mut Window,
|
||||
rects: ~[@mut ClientRect]) -> @mut ClientRectList {
|
||||
reflect_dom_object(@mut ClientRectList::new_inherited(window, rects),
|
||||
window, ClientRectListBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Length(&self) -> u32 {
|
||||
|
@ -55,14 +58,11 @@ impl Reflectable for ClientRectList {
|
|||
&mut self.reflector_
|
||||
}
|
||||
|
||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
||||
ClientRectListBinding::Wrap(cx, scope, self)
|
||||
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut Reflectable> {
|
||||
let page = page_from_context(cx);
|
||||
unsafe {
|
||||
Some((*page).frame.get_ref().window as @mut Reflectable)
|
||||
}
|
||||
fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut Reflectable> {
|
||||
Some(self.window as @mut Reflectable)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,24 +287,21 @@ impl Element {
|
|||
let node = abstract_self;
|
||||
assert!(node.is_element());
|
||||
let (port, chan) = comm::stream();
|
||||
let (rects, cx, scope) =
|
||||
let rects =
|
||||
match win.page.query_layout(ContentBoxesQuery(node, chan), port) {
|
||||
ContentBoxesResponse(rects) => {
|
||||
let cx = win.get_cx();
|
||||
let scope = win.reflector().get_jsobject();
|
||||
let rects = do rects.map |r| {
|
||||
do rects.map |r| {
|
||||
ClientRect::new(
|
||||
win,
|
||||
r.origin.y.to_f32().unwrap(),
|
||||
(r.origin.y + r.size.height).to_f32().unwrap(),
|
||||
r.origin.x.to_f32().unwrap(),
|
||||
(r.origin.x + r.size.width).to_f32().unwrap())
|
||||
};
|
||||
(rects, cx, scope)
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
ClientRectList::new(rects, cx, scope)
|
||||
ClientRectList::new(win, rects)
|
||||
}
|
||||
|
||||
pub fn GetBoundingClientRect(&self, abstract_self: AbstractNode<ScriptView>) -> @mut ClientRect {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue