Move root_flow from LayoutTaskData to LayoutTask.

This commit is contained in:
Ms2ger 2015-11-06 17:13:18 +01:00
parent 53da53ef53
commit e8f31f2ed7

View file

@ -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. /// This needs to be protected by a mutex so we can do fast RPCs.
pub struct LayoutTaskData { 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. /// The channel on which messages can be sent to the constellation.
pub constellation_chan: ConstellationChan, pub constellation_chan: ConstellationChan,
@ -136,14 +133,6 @@ pub struct LayoutTaskData {
pub visible_rects: Arc<HashMap<LayerId, Rect<Au>, DefaultState<FnvHasher>>>, 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. /// Information needed by the layout task.
pub struct LayoutTask { pub struct LayoutTask {
/// The ID of the pipeline that we belong to. /// 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. /// The number of Web fonts that have been requested but not yet loaded.
outstanding_web_fonts: Arc<AtomicUsize>, 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 /// A mutex to allow for fast, read-only RPC of layout's internal data
/// structures, while still letting the LayoutTask modify them. /// structures, while still letting the LayoutTask modify them.
/// ///
@ -436,9 +428,9 @@ impl LayoutTask {
new_animations_sender: new_animations_sender, new_animations_sender: new_animations_sender,
new_animations_receiver: new_animations_receiver, new_animations_receiver: new_animations_receiver,
outstanding_web_fonts: outstanding_web_fonts_counter, outstanding_web_fonts: outstanding_web_fonts_counter,
root_flow: None,
rw_data: Arc::new(Mutex::new( rw_data: Arc::new(Mutex::new(
LayoutTaskData { LayoutTaskData {
root_flow: None,
constellation_chan: constellation_chan, constellation_chan: constellation_chan,
viewport_size: Size2D::new(Au(0), Au(0)), viewport_size: Size2D::new(Au(0), Au(0)),
stacking_context: None, stacking_context: None,
@ -1185,7 +1177,7 @@ impl LayoutTask {
}); });
// Retrieve the (possibly rebuilt) root flow. // 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 // Send new canvas renderers to the paint task
@ -1199,7 +1191,7 @@ impl LayoutTask {
&mut rw_data, &mut rw_data,
&mut shared_layout_context); &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 { match data.query_type {
ReflowQueryType::ContentBoxQuery(node) => ReflowQueryType::ContentBoxQuery(node) =>
rw_data.content_box_response = process_content_box_request(node, &mut root_flow), rw_data.content_box_response = process_content_box_request(node, &mut root_flow),
@ -1294,7 +1286,7 @@ impl LayoutTask {
&self.url, &self.url,
reflow_info.goal); 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. // Perform an abbreviated style recalc that operates without access to the DOM.
let animations = &*rw_data.running_animations; let animations = &*rw_data.running_animations;
profile(time::ProfilerCategory::LayoutStyleRecalc, profile(time::ProfilerCategory::LayoutStyleRecalc,
@ -1326,7 +1318,7 @@ impl LayoutTask {
reflow_info.goal); reflow_info.goal);
// No need to do a style recalc here. // No need to do a style recalc here.
if rw_data.root_flow.as_ref().is_none() { if self.root_flow.is_none() {
return return
} }
self.perform_post_style_recalc_layout_passes(&reflow_info, self.perform_post_style_recalc_layout_passes(&reflow_info,
@ -1338,7 +1330,7 @@ impl LayoutTask {
data: &Reflow, data: &Reflow,
rw_data: &mut LayoutTaskData, rw_data: &mut LayoutTaskData,
layout_context: &mut SharedLayoutContext) { 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. // Kick off animations if any were triggered, expire completed ones.
animation::update_animation_state(&mut *rw_data, animation::update_animation_state(&mut *rw_data,
&self.new_animations_receiver, &self.new_animations_receiver,
@ -1397,7 +1389,7 @@ impl LayoutTask {
rw_data: &mut LayoutTaskData, rw_data: &mut LayoutTaskData,
layout_context: &mut SharedLayoutContext) { layout_context: &mut SharedLayoutContext) {
// Build the display list if necessary, and send it to the painter. // 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, self.compute_abs_pos_and_build_display_list(data,
&mut root_flow, &mut root_flow,
&mut *layout_context, &mut *layout_context,