diff options
author | Ms2ger <Ms2ger@gmail.com> | 2015-11-06 13:13:23 +0100 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2015-11-09 09:03:51 +0100 |
commit | b8d8505463fcb82a3017057ef1fc50f378090b5f (patch) | |
tree | 9b3db6b7c1eedf815320d4047205228c2a1e51e4 /components/layout/layout_task.rs | |
parent | ff0acccc061c0894e40bbda4b318bc7ab8615367 (diff) | |
download | servo-b8d8505463fcb82a3017057ef1fc50f378090b5f.tar.gz servo-b8d8505463fcb82a3017057ef1fc50f378090b5f.zip |
Disentangle the message handling from the receiver selection in LayoutTask::handle_request.
This ensures no fields of the LayoutTask are borrowed when calling repaint or
handle_request_helper, which I'll need later.
Diffstat (limited to 'components/layout/layout_task.rs')
-rw-r--r-- | components/layout/layout_task.rs | 84 |
1 files changed, 51 insertions, 33 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index a7a39233cc9..c36a45b8a7d 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -466,49 +466,67 @@ impl LayoutTask { fn handle_request<'a>(&'a self, possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) -> bool { - let port_from_script = &self.port; - let port_from_pipeline = &self.pipeline_port; - let port_from_image_cache = &self.image_cache_receiver; - let port_from_font_cache = &self.font_cache_receiver; - select! { - msg = port_from_pipeline.recv() => { - match msg.unwrap() { - LayoutControlMsg::SetVisibleRects(new_visible_rects) => { - self.handle_request_helper(Msg::SetVisibleRects(new_visible_rects), - possibly_locked_rw_data) - } - LayoutControlMsg::TickAnimations => { - self.handle_request_helper(Msg::TickAnimations, possibly_locked_rw_data) - } - LayoutControlMsg::GetCurrentEpoch(sender) => { - self.handle_request_helper(Msg::GetCurrentEpoch(sender), - possibly_locked_rw_data) - } - LayoutControlMsg::GetWebFontLoadState(sender) => { - self.handle_request_helper(Msg::GetWebFontLoadState(sender), - possibly_locked_rw_data) - } - LayoutControlMsg::ExitNow => { - self.handle_request_helper(Msg::ExitNow, - possibly_locked_rw_data) - } + enum Request { + FromPipeline(LayoutControlMsg), + FromScript(Msg), + FromImageCache, + FromFontCache, + } + + let request = { + let port_from_script = &self.port; + let port_from_pipeline = &self.pipeline_port; + let port_from_image_cache = &self.image_cache_receiver; + let port_from_font_cache = &self.font_cache_receiver; + select! { + msg = port_from_pipeline.recv() => { + Request::FromPipeline(msg.unwrap()) + }, + msg = port_from_script.recv() => { + Request::FromScript(msg.unwrap()) + }, + msg = port_from_image_cache.recv() => { + msg.unwrap(); + Request::FromImageCache + }, + msg = port_from_font_cache.recv() => { + msg.unwrap(); + Request::FromFontCache } + } + }; + + match request { + Request::FromPipeline(LayoutControlMsg::SetVisibleRects(new_visible_rects)) => { + self.handle_request_helper(Msg::SetVisibleRects(new_visible_rects), + possibly_locked_rw_data) + }, + Request::FromPipeline(LayoutControlMsg::TickAnimations) => { + self.handle_request_helper(Msg::TickAnimations, possibly_locked_rw_data) + }, + Request::FromPipeline(LayoutControlMsg::GetCurrentEpoch(sender)) => { + self.handle_request_helper(Msg::GetCurrentEpoch(sender), possibly_locked_rw_data) }, - msg = port_from_script.recv() => { - self.handle_request_helper(msg.unwrap(), possibly_locked_rw_data) + Request::FromPipeline(LayoutControlMsg::GetWebFontLoadState(sender)) => { + self.handle_request_helper(Msg::GetWebFontLoadState(sender), + possibly_locked_rw_data) }, - msg = port_from_image_cache.recv() => { - msg.unwrap(); + Request::FromPipeline(LayoutControlMsg::ExitNow) => { + self.handle_request_helper(Msg::ExitNow, possibly_locked_rw_data) + }, + Request::FromScript(msg) => { + self.handle_request_helper(msg, possibly_locked_rw_data) + }, + Request::FromImageCache => { self.repaint(possibly_locked_rw_data) }, - msg = port_from_font_cache.recv() => { - msg.unwrap(); + Request::FromFontCache => { let rw_data = self.lock_rw_data(possibly_locked_rw_data); rw_data.outstanding_web_fonts.fetch_sub(1, Ordering::SeqCst); font_context::invalidate_font_caches(); self.script_chan.send(ConstellationControlMsg::WebFontLoaded(self.id)).unwrap(); true - } + }, } } |