Move generation from LayoutTaskData to LayoutTask.

This commit is contained in:
Ms2ger 2015-11-06 14:58:24 +01:00
parent 880fb9be0b
commit bdfa5fe804

View file

@ -110,10 +110,6 @@ pub struct LayoutTaskData {
/// Performs CSS selector matching and style resolution.
pub stylist: Box<Stylist>,
/// Starts at zero, and increased by one every time a layout completes.
/// This can be used to easily check for invalid stale data.
pub generation: u32,
/// A queued response for the union of the content boxes of a node.
pub content_box_response: Rect<Au>,
@ -222,6 +218,10 @@ pub struct LayoutTask {
/// The workers that we use for parallel operation.
parallel_traversal: Option<WorkQueue<SharedLayoutContext, WorkQueueData>>,
/// Starts at zero, and increased by one every time a layout completes.
/// This can be used to easily check for invalid stale data.
generation: u32,
/// A mutex to allow for fast, read-only RPC of layout's internal data
/// structures, while still letting the LayoutTask modify them.
///
@ -432,6 +432,7 @@ impl LayoutTask {
canvas_layers_receiver: canvas_layers_receiver,
canvas_layers_sender: canvas_layers_sender,
parallel_traversal: parallel_traversal,
generation: 0,
rw_data: Arc::new(Mutex::new(
LayoutTaskData {
root_flow: None,
@ -439,7 +440,6 @@ impl LayoutTask {
viewport_size: Size2D::new(Au(0), Au(0)),
stacking_context: None,
stylist: stylist,
generation: 0,
content_box_response: Rect::zero(),
content_boxes_response: Vec::new(),
client_rect_response: Rect::zero(),
@ -485,7 +485,7 @@ impl LayoutTask {
stylist: StylistWrapper(&*rw_data.stylist),
url: (*url).clone(),
visible_rects: rw_data.visible_rects.clone(),
generation: rw_data.generation,
generation: self.generation,
new_animations_sender: Mutex::new(rw_data.new_animations_sender.clone()),
goal: goal,
running_animations: rw_data.running_animations.clone(),
@ -1410,7 +1410,7 @@ impl LayoutTask {
root_flow.dump();
}
rw_data.generation += 1;
self.generation += 1;
}
}