compositing: Fix some whitespace issues and use if let in some more

places.
This commit is contained in:
Patrick Walton 2015-04-10 10:29:26 -07:00
parent b4b3cbccf7
commit fd352323e0
2 changed files with 24 additions and 30 deletions

View file

@ -298,9 +298,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
(Msg::SetFrameTree(frame_tree, response_chan, new_constellation_chan), (Msg::SetFrameTree(frame_tree, response_chan, new_constellation_chan),
ShutdownState::NotShuttingDown) => { ShutdownState::NotShuttingDown) => {
self.set_frame_tree(&frame_tree, self.set_frame_tree(&frame_tree, response_chan, new_constellation_chan);
response_chan,
new_constellation_chan);
self.send_viewport_rects_for_all_layers(); self.send_viewport_rects_for_all_layers();
self.get_title_for_main_frame(); self.get_title_for_main_frame();
} }
@ -326,7 +324,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
(Msg::AssignPaintedBuffers(pipeline_id, epoch, replies), (Msg::AssignPaintedBuffers(pipeline_id, epoch, replies),
ShutdownState::NotShuttingDown) => { ShutdownState::NotShuttingDown) => {
for (layer_id, new_layer_buffer_set) in replies.into_iter() { for (layer_id, new_layer_buffer_set) in replies.into_iter() {
self.assign_painted_buffers(pipeline_id, layer_id, new_layer_buffer_set, epoch); self.assign_painted_buffers(pipeline_id,
layer_id,
new_layer_buffer_set,
epoch);
} }
self.remove_outstanding_paint_msg(); self.remove_outstanding_paint_msg();
} }
@ -580,7 +581,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
return root_layer; return root_layer;
} }
fn find_pipeline_root_layer(&self, pipeline_id: PipelineId) -> Option<Rc<Layer<CompositorData>>> { fn find_pipeline_root_layer(&self, pipeline_id: PipelineId)
-> Option<Rc<Layer<CompositorData>>> {
if !self.pipeline_details.contains_key(&pipeline_id) { if !self.pipeline_details.contains_key(&pipeline_id) {
panic!("Tried to create or update layer for unknown pipeline") panic!("Tried to create or update layer for unknown pipeline")
} }
@ -683,22 +685,19 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn scroll_layer_to_fragment_point_if_necessary(&mut self, fn scroll_layer_to_fragment_point_if_necessary(&mut self,
pipeline_id: PipelineId, pipeline_id: PipelineId,
layer_id: LayerId) { layer_id: LayerId) {
match self.fragment_point.take() { if let Some(point) = self.fragment_point.take() {
Some(point) => { if !self.move_layer(pipeline_id, layer_id, Point2D::from_untyped(&point)) {
if !self.move_layer(pipeline_id, layer_id, Point2D::from_untyped(&point)) { panic!("Compositor: Tried to scroll to fragment with unknown layer.");
panic!("Compositor: Tried to scroll to fragment with unknown layer.");
}
self.start_scrolling_timer_if_necessary();
} }
None => {}
self.start_scrolling_timer_if_necessary();
} }
} }
fn start_scrolling_timer_if_necessary(&mut self) { fn start_scrolling_timer_if_necessary(&mut self) {
match self.composition_request { match self.composition_request {
CompositionRequest::CompositeNow | CompositionRequest::CompositeOnScrollTimeout(_) => CompositionRequest::CompositeNow(_) |
return, CompositionRequest::CompositeOnScrollTimeout(_) => return,
CompositionRequest::NoCompositingNecessary => {} CompositionRequest::NoCompositingNecessary => {}
} }
@ -1160,19 +1159,15 @@ impl<Window: WindowMethods> IOCompositor<Window> {
origin: Point2D::zero(), origin: Point2D::zero(),
size: self.window_size.as_f32(), size: self.window_size.as_f32(),
}; };
// paint the scene.
match self.scene.root { // Paint the scene.
Some(ref layer) => { if let Some(ref layer) = self.scene.root {
match self.context { match self.context {
None => { Some(context) => rendergl::render_scene(layer.clone(), context, &self.scene),
debug!("compositor: not compositing because context not yet set up") None => {
} debug!("compositor: not compositing because context not yet set up")
Some(context) => {
rendergl::render_scene(layer.clone(), context, &self.scene);
}
} }
} }
None => {}
} }
}); });

View file

@ -218,7 +218,7 @@ impl Window {
fn scroll_window(&self, dx: f32, dy: f32) { fn scroll_window(&self, dx: f32, dy: f32) {
let mouse_pos = self.mouse_pos.get(); let mouse_pos = self.mouse_pos.get();
let event = WindowEvent::Scroll(TypedPoint2D(dx as f32, dy as f32), let event = WindowEvent::Scroll(TypedPoint2D(dx as f32, dy as f32),
TypedPoint2D(mouse_pos.x as i32, mouse_pos.y as i32)); TypedPoint2D(mouse_pos.x as i32, mouse_pos.y as i32));
self.event_queue.borrow_mut().push(event); self.event_queue.borrow_mut().push(event);
} }
@ -683,9 +683,8 @@ impl CompositorProxy for GlutinCompositorProxy {
fn send(&mut self, msg: compositor_task::Msg) { fn send(&mut self, msg: compositor_task::Msg) {
// Send a message and kick the OS event loop awake. // Send a message and kick the OS event loop awake.
self.sender.send(msg).unwrap(); self.sender.send(msg).unwrap();
match self.window_proxy { if let Some(ref window_proxy) = self.window_proxy {
Some(ref window_proxy) => window_proxy.wakeup_event_loop(), window_proxy.wakeup_event_loop()
None => {}
} }
} }
fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> { fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> {