diff options
author | Ms2ger <Ms2ger@gmail.com> | 2015-11-06 17:13:18 +0100 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2015-11-09 09:04:01 +0100 |
commit | e8f31f2ed7cf4be5ac578ce83851e2f7b3ef1c23 (patch) | |
tree | e2a01ca74c94c3973651b8d5a0e6f921983ec176 /components/layout/layout_task.rs | |
parent | 53da53ef53561fd5921c1ebb1baccf01f440295f (diff) | |
download | servo-e8f31f2ed7cf4be5ac578ce83851e2f7b3ef1c23.tar.gz servo-e8f31f2ed7cf4be5ac578ce83851e2f7b3ef1c23.zip |
Move root_flow from LayoutTaskData to LayoutTask.
Diffstat (limited to 'components/layout/layout_task.rs')
-rw-r--r-- | components/layout/layout_task.rs | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 91122865c91..2a189e49ce2 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -94,9 +94,6 @@ const DISPLAY_PORT_THRESHOLD_SIZE_FACTOR: i32 = 4; /// /// This needs to be protected by a mutex so we can do fast RPCs. pub struct LayoutTaskData { - /// The root of the flow tree. - pub root_flow: Option<FlowRef>, - /// The channel on which messages can be sent to the constellation. pub constellation_chan: ConstellationChan, @@ -136,14 +133,6 @@ pub struct LayoutTaskData { pub visible_rects: Arc<HashMap<LayerId, Rect<Au>, DefaultState<FnvHasher>>>, } -impl LayoutTaskData { - pub fn layout_root(&self) -> Option<FlowRef> { - self.root_flow.as_ref().map(|root_flow| { - root_flow.clone() - }) - } -} - /// Information needed by the layout task. pub struct LayoutTask { /// The ID of the pipeline that we belong to. @@ -222,6 +211,9 @@ pub struct LayoutTask { /// The number of Web fonts that have been requested but not yet loaded. outstanding_web_fonts: Arc<AtomicUsize>, + /// The root of the flow tree. + root_flow: Option<FlowRef>, + /// A mutex to allow for fast, read-only RPC of layout's internal data /// structures, while still letting the LayoutTask modify them. /// @@ -436,9 +428,9 @@ impl LayoutTask { new_animations_sender: new_animations_sender, new_animations_receiver: new_animations_receiver, outstanding_web_fonts: outstanding_web_fonts_counter, + root_flow: None, rw_data: Arc::new(Mutex::new( LayoutTaskData { - root_flow: None, constellation_chan: constellation_chan, viewport_size: Size2D::new(Au(0), Au(0)), stacking_context: None, @@ -1185,7 +1177,7 @@ impl LayoutTask { }); // Retrieve the (possibly rebuilt) root flow. - rw_data.root_flow = self.try_get_layout_root(node); + self.root_flow = self.try_get_layout_root(node); } // Send new canvas renderers to the paint task @@ -1199,7 +1191,7 @@ impl LayoutTask { &mut rw_data, &mut shared_layout_context); - if let Some(mut root_flow) = rw_data.layout_root() { + if let Some(mut root_flow) = self.root_flow.clone() { match data.query_type { ReflowQueryType::ContentBoxQuery(node) => rw_data.content_box_response = process_content_box_request(node, &mut root_flow), @@ -1294,7 +1286,7 @@ impl LayoutTask { &self.url, reflow_info.goal); - if let Some(mut root_flow) = rw_data.layout_root() { + if let Some(mut root_flow) = self.root_flow.clone() { // Perform an abbreviated style recalc that operates without access to the DOM. let animations = &*rw_data.running_animations; profile(time::ProfilerCategory::LayoutStyleRecalc, @@ -1326,7 +1318,7 @@ impl LayoutTask { reflow_info.goal); // No need to do a style recalc here. - if rw_data.root_flow.as_ref().is_none() { + if self.root_flow.is_none() { return } self.perform_post_style_recalc_layout_passes(&reflow_info, @@ -1338,7 +1330,7 @@ impl LayoutTask { data: &Reflow, rw_data: &mut LayoutTaskData, layout_context: &mut SharedLayoutContext) { - if let Some(mut root_flow) = rw_data.layout_root() { + if let Some(mut root_flow) = self.root_flow.clone() { // Kick off animations if any were triggered, expire completed ones. animation::update_animation_state(&mut *rw_data, &self.new_animations_receiver, @@ -1397,7 +1389,7 @@ impl LayoutTask { rw_data: &mut LayoutTaskData, layout_context: &mut SharedLayoutContext) { // Build the display list if necessary, and send it to the painter. - if let Some(mut root_flow) = rw_data.layout_root() { + if let Some(mut root_flow) = self.root_flow.clone() { self.compute_abs_pos_and_build_display_list(data, &mut root_flow, &mut *layout_context, |