mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Get rid of match statements in layout queries in script_task
This commit is contained in:
parent
ac5a634082
commit
d4d6fcb5f0
2 changed files with 8 additions and 17 deletions
|
@ -140,11 +140,8 @@ 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 {
|
||||||
|
@ -159,11 +156,8 @@ 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 {
|
||||||
|
|
|
@ -929,13 +929,10 @@ 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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue