aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/main/layout/layout_task.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-11-08 22:45:40 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-11-08 22:45:40 -0800
commit6ff7b4a6a67ba31ceb36f7a16e00e4e3a09aa1ea (patch)
tree8f2d654ce86da21a3792079728aa5eba112e3a51 /src/components/main/layout/layout_task.rs
parentbdc7e984eb73298e13f917aefdd0c34e9ae34d03 (diff)
downloadservo-6ff7b4a6a67ba31ceb36f7a16e00e4e3a09aa1ea.tar.gz
servo-6ff7b4a6a67ba31ceb36f7a16e00e4e3a09aa1ea.zip
Use `Any` for the layout data.
Breaks the dependency between `gfx` and `script`, which is nice.
Diffstat (limited to 'src/components/main/layout/layout_task.rs')
-rw-r--r--src/components/main/layout/layout_task.rs107
1 files changed, 54 insertions, 53 deletions
diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs
index 819cfffcf72..14f9235ad9c 100644
--- a/src/components/main/layout/layout_task.rs
+++ b/src/components/main/layout/layout_task.rs
@@ -15,10 +15,11 @@ use layout::flow::{FlowContext, ImmutableFlowUtils, MutableFlowUtils, PreorderFl
use layout::flow::{PostorderFlowTraversal};
use layout::flow;
use layout::incremental::{RestyleDamage, BubbleWidths};
+use layout::util::LayoutDataAccess;
use std::cast::transmute;
use std::cell::Cell;
-use std::comm::{Port};
+use std::comm::Port;
use std::task;
use extra::arc::{Arc, RWArc};
use geom::point::Point2D;
@@ -419,22 +420,23 @@ impl LayoutTask {
transmute(display_list.get().list[i].base().extra)
};
- do node.write_layout_data |layout_data| {
- layout_data.boxes.display_list = Some(display_list.clone());
-
- if layout_data.boxes.range.is_none() {
- debug!("Creating initial range for node");
- layout_data.boxes.range = Some(Range::new(i,1));
- } else {
- debug!("Appending item to range");
- unsafe {
- let old_node: AbstractNode<()> = transmute(node);
- assert!(old_node == display_list.get().list[i-1].base().extra,
- "Non-contiguous arrangement of display items");
- }
-
- layout_data.boxes.range.unwrap().extend_by(1);
+ // FIXME(pcwalton): Why are we cloning the display list here?!
+ let layout_data = node.layout_data();
+ let boxes = layout_data.boxes.mutate();
+ boxes.ptr.display_list = Some(display_list.clone());
+
+ if boxes.ptr.range.is_none() {
+ debug!("Creating initial range for node");
+ boxes.ptr.range = Some(Range::new(i,1));
+ } else {
+ debug!("Appending item to range");
+ unsafe {
+ let old_node: AbstractNode<()> = transmute(node);
+ assert!(old_node == display_list.get().list[i-1].base().extra,
+ "Non-contiguous arrangement of display items");
}
+
+ boxes.ptr.range.unwrap().extend_by(1);
}
}
@@ -469,34 +471,35 @@ impl LayoutTask {
};
fn box_for_node(node: AbstractNode<LayoutView>) -> Option<Rect<Au>> {
- do node.read_layout_data |layout_data| {
- match (layout_data.boxes.display_list.clone(), layout_data.boxes.range) {
- (Some(display_list), Some(range)) => {
- let mut rect: Option<Rect<Au>> = None;
- for i in range.eachi() {
- rect = match rect {
- Some(acc) => {
- Some(acc.union(&display_list.get().list[i].bounds()))
- }
- None => Some(display_list.get().list[i].bounds())
+ // FIXME(pcwalton): Why are we cloning the display list here?!
+ let boxes = node.layout_data().boxes.borrow();
+ let boxes = boxes.ptr;
+ match (boxes.display_list.clone(), boxes.range) {
+ (Some(display_list), Some(range)) => {
+ let mut rect: Option<Rect<Au>> = None;
+ for i in range.eachi() {
+ rect = match rect {
+ Some(acc) => {
+ Some(acc.union(&display_list.get().list[i].bounds()))
}
+ None => Some(display_list.get().list[i].bounds())
}
- rect
}
- _ => {
- let mut acc: Option<Rect<Au>> = None;
- for child in node.children() {
- let rect = box_for_node(child);
- match rect {
- None => continue,
- Some(rect) => acc = match acc {
- Some(acc) => Some(acc.union(&rect)),
- None => Some(rect)
- }
+ rect
+ }
+ _ => {
+ let mut acc: Option<Rect<Au>> = None;
+ for child in node.children() {
+ let rect = box_for_node(child);
+ match rect {
+ None => continue,
+ Some(rect) => acc = match acc {
+ Some(acc) => Some(acc.union(&rect)),
+ None => Some(rect)
}
}
- acc
}
+ acc
}
}
}
@@ -511,25 +514,23 @@ impl LayoutTask {
transmute(node)
};
- fn boxes_for_node(node: AbstractNode<LayoutView>,
- boxes: ~[Rect<Au>]) -> ~[Rect<Au>] {
- let boxes = Cell::new(boxes);
- do node.read_layout_data |layout_data| {
- let mut boxes = boxes.take();
- match (layout_data.boxes.display_list.clone(), layout_data.boxes.range) {
- (Some(display_list), Some(range)) => {
- for i in range.eachi() {
- boxes.push(display_list.get().list[i].bounds());
- }
+ fn boxes_for_node(node: AbstractNode<LayoutView>, mut box_accumulator: ~[Rect<Au>])
+ -> ~[Rect<Au>] {
+ let boxes = node.layout_data().boxes.borrow();
+ let boxes = boxes.ptr;
+ match (boxes.display_list.clone(), boxes.range) {
+ (Some(display_list), Some(range)) => {
+ for i in range.eachi() {
+ box_accumulator.push(display_list.get().list[i].bounds());
}
- _ => {
- for child in node.children() {
- boxes = boxes_for_node(child, boxes);
- }
+ }
+ _ => {
+ for child in node.children() {
+ box_accumulator = boxes_for_node(child, box_accumulator);
}
}
- boxes
}
+ box_accumulator
}
let mut boxes = ~[];