auto merge of #2022 : lpy/servo/issue2019, r=jdm

see #2019
This commit is contained in:
bors-servo 2014-04-01 15:31:50 -04:00
commit e3bf08ea53
3 changed files with 24 additions and 40 deletions

View file

@ -571,19 +571,15 @@ impl Element {
let node: JS<Node> = NodeCast::from(abstract_self); let node: JS<Node> = NodeCast::from(abstract_self);
let (port, chan) = Chan::new(); let (port, chan) = Chan::new();
let addr = node.to_trusted_node_address(); let addr = node.to_trusted_node_address();
let rects = let ContentBoxesResponse(rects) = win.get().page().query_layout(ContentBoxesQuery(addr, chan), port);
match win.get().page().query_layout(ContentBoxesQuery(addr, chan), port) { let rects = rects.map(|r| {
ContentBoxesResponse(rects) => {
rects.map(|r| {
ClientRect::new( ClientRect::new(
win, win,
r.origin.y, r.origin.y,
r.origin.y + r.size.height, r.origin.y + r.size.height,
r.origin.x, r.origin.x,
r.origin.x + r.size.width) r.origin.x + r.size.width)
}) });
},
};
ClientRectList::new(win, rects) ClientRectList::new(win, rects)
} }
@ -595,8 +591,7 @@ impl Element {
let node: JS<Node> = NodeCast::from(abstract_self); let node: JS<Node> = NodeCast::from(abstract_self);
let (port, chan) = Chan::new(); let (port, chan) = Chan::new();
let addr = node.to_trusted_node_address(); let addr = node.to_trusted_node_address();
match win.get().page().query_layout(ContentBoxQuery(addr, chan), port) { let ContentBoxResponse(rect) = win.get().page().query_layout(ContentBoxQuery(addr, chan), port);
ContentBoxResponse(rect) => {
ClientRect::new( ClientRect::new(
win, win,
rect.origin.y, rect.origin.y,
@ -604,8 +599,6 @@ impl Element {
rect.origin.x, rect.origin.x,
rect.origin.x + rect.size.width) rect.origin.x + rect.size.width)
} }
}
}
pub fn GetInnerHTML(&self, abstract_self: &JS<Element>) -> Fallible<DOMString> { pub fn GetInnerHTML(&self, abstract_self: &JS<Element>) -> Fallible<DOMString> {
//XXX TODO: XML case //XXX TODO: XML case

View file

@ -140,12 +140,9 @@ impl HTMLImageElement {
let page = window.get().page(); let page = window.get().page();
let (port, chan) = Chan::new(); let (port, chan) = Chan::new();
let addr = node.to_trusted_node_address(); let addr = node.to_trusted_node_address();
match page.query_layout(ContentBoxQuery(addr, chan), port) { let ContentBoxResponse(rect) = page.query_layout(ContentBoxQuery(addr, chan), port);
ContentBoxResponse(rect) => {
to_px(rect.size.width) as u32 to_px(rect.size.width) as u32
} }
}
}
pub fn SetWidth(&mut self, abstract_self: &JS<HTMLImageElement>, width: u32) -> ErrorResult { pub fn SetWidth(&mut self, abstract_self: &JS<HTMLImageElement>, width: u32) -> ErrorResult {
let mut elem: JS<Element> = ElementCast::from(abstract_self); let mut elem: JS<Element> = ElementCast::from(abstract_self);
@ -159,12 +156,9 @@ impl HTMLImageElement {
let (port, chan) = Chan::new(); let (port, chan) = Chan::new();
let this_node: JS<Node> = NodeCast::from(abstract_self); let this_node: JS<Node> = NodeCast::from(abstract_self);
let addr = this_node.to_trusted_node_address(); let addr = this_node.to_trusted_node_address();
match page.query_layout(ContentBoxQuery(addr, chan), port) { let ContentBoxResponse(rect) = page.query_layout(ContentBoxQuery(addr, chan), port);
ContentBoxResponse(rect) => {
to_px(rect.size.height) as u32 to_px(rect.size.height) as u32
} }
}
}
pub fn SetHeight(&mut self, abstract_self: &JS<HTMLImageElement>, height: u32) -> ErrorResult { pub fn SetHeight(&mut self, abstract_self: &JS<HTMLImageElement>, height: u32) -> ErrorResult {
let mut elem: JS<Element> = ElementCast::from(abstract_self); let mut elem: JS<Element> = ElementCast::from(abstract_self);

View file

@ -929,14 +929,11 @@ impl ScriptTask {
fn scroll_fragment_point(&self, pipeline_id: PipelineId, page: &Page, node: JS<Element>) { fn scroll_fragment_point(&self, pipeline_id: PipelineId, page: &Page, node: JS<Element>) {
let (port, chan) = Chan::new(); let (port, chan) = Chan::new();
let node: JS<Node> = NodeCast::from(&node); let node: JS<Node> = NodeCast::from(&node);
match page.query_layout(ContentBoxQuery(node.to_trusted_node_address(), chan), port) { let ContentBoxResponse(rect) = page.query_layout(ContentBoxQuery(node.to_trusted_node_address(), chan), port);
ContentBoxResponse(rect) => {
let point = Point2D(to_frac_px(rect.origin.x).to_f32().unwrap(), let point = Point2D(to_frac_px(rect.origin.x).to_f32().unwrap(),
to_frac_px(rect.origin.y).to_f32().unwrap()); to_frac_px(rect.origin.y).to_f32().unwrap());
self.compositor.scroll_fragment_point(pipeline_id, point); self.compositor.scroll_fragment_point(pipeline_id, point);
} }
}
}
/// This is the main entry point for receiving and dispatching DOM events. /// This is the main entry point for receiving and dispatching DOM events.
/// ///