aboutsummaryrefslogtreecommitdiffstats
path: root/src/servo/layout
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-10-04 11:02:53 -0700
committerPatrick Walton <pcwalton@mimiga.net>2012-10-04 15:28:10 -0700
commit994c47d22b0a3603978d4b6dcb8ffed72e65ac9a (patch)
tree6939083c1dd3a6cf070a92214573c95cdd1f1833 /src/servo/layout
parente105f3b5571f0cbfae3fc6a96938d4d039bb660d (diff)
downloadservo-994c47d22b0a3603978d4b6dcb8ffed72e65ac9a.tar.gz
servo-994c47d22b0a3603978d4b6dcb8ffed72e65ac9a.zip
Update for language changes; remove pipe protocols.
Diffstat (limited to 'src/servo/layout')
-rw-r--r--src/servo/layout/block.rs12
-rw-r--r--src/servo/layout/box.rs18
-rw-r--r--src/servo/layout/display_list_builder.rs4
-rw-r--r--src/servo/layout/flow.rs16
-rw-r--r--src/servo/layout/inline.rs2
-rw-r--r--src/servo/layout/layout_task.rs16
-rw-r--r--src/servo/layout/traverse_parallel.rs9
7 files changed, 39 insertions, 38 deletions
diff --git a/src/servo/layout/block.rs b/src/servo/layout/block.rs
index fdbd911b4e4..8a097466e73 100644
--- a/src/servo/layout/block.rs
+++ b/src/servo/layout/block.rs
@@ -22,7 +22,7 @@ fn BlockFlowData() -> BlockFlowData {
trait BlockLayout {
pure fn starts_block_flow() -> bool;
- pure fn with_block_box(fn(&&@RenderBox) -> ()) -> ();
+ pure fn with_block_box(fn(box: &@RenderBox) -> ()) -> ();
fn bubble_widths_block(ctx: &LayoutContext);
fn assign_widths_block(ctx: &LayoutContext);
@@ -43,7 +43,7 @@ impl FlowContext : BlockLayout {
/* Get the current flow's corresponding block box, if it exists, and do something with it.
This works on both BlockFlow and RootFlow, since they are mostly the same. */
- pure fn with_block_box(cb:fn(&&@RenderBox) -> ()) -> () {
+ pure fn with_block_box(cb: fn(box: &@RenderBox) -> ()) -> () {
match self {
BlockFlow(*) => {
let mut box = self.block().box;
@@ -83,8 +83,8 @@ impl FlowContext : BlockLayout {
/* if not an anonymous block context, add in block box's widths.
these widths will not include child elements, just padding etc. */
do self.with_block_box |box| {
- min_width = min_width.add(box.get_min_width());
- pref_width = pref_width.add(box.get_pref_width());
+ min_width = min_width.add(&box.get_min_width());
+ pref_width = pref_width.add(&box.get_pref_width());
}
self.d().min_width = min_width;
@@ -110,7 +110,7 @@ impl FlowContext : BlockLayout {
do self.with_block_box |box| {
box.d().position.size.width = remaining_width;
let (left_used, right_used) = box.get_used_width();
- remaining_width = remaining_width.sub(left_used.add(right_used));
+ remaining_width = remaining_width.sub(&left_used.add(&right_used));
}
for FlowTree.each_child(@self) |child_ctx| {
@@ -127,7 +127,7 @@ impl FlowContext : BlockLayout {
for FlowTree.each_child(@self) |child_ctx| {
child_ctx.d().position.origin.y = cur_y;
- cur_y = cur_y.add(child_ctx.d().position.size.height);
+ cur_y = cur_y.add(&child_ctx.d().position.size.height);
}
self.d().position.size.height = cur_y;
diff --git a/src/servo/layout/box.rs b/src/servo/layout/box.rs
index af805b0766f..b5245769f1e 100644
--- a/src/servo/layout/box.rs
+++ b/src/servo/layout/box.rs
@@ -90,7 +90,7 @@ enum RenderBoxType {
RenderBox_Text
}
-enum RenderBox {
+pub enum RenderBox {
GenericBox(RenderBoxData),
ImageBox(RenderBoxData, ImageHolder),
TextBox(RenderBoxData, TextBoxData)
@@ -142,7 +142,7 @@ impl RenderBox {
// TODO: If image isn't available, consult 'width'.
ImageBox(_,i) => au::from_px(i.get_size().get_default(Size2D(0,0)).width),
TextBox(_,d) => d.runs.foldl(au(0), |sum, run| {
- au::max(sum, run.min_break_width())
+ au::max(*sum, run.min_break_width())
})
}
}
@@ -160,7 +160,7 @@ impl RenderBox {
// how to compute its own min and pref widths, and should
// probably cache them.
TextBox(_,d) => d.runs.foldl(au(0), |sum, run| {
- au::max(sum, run.size().width)
+ au::max(*sum, run.size().width)
})
}
}
@@ -261,7 +261,7 @@ impl RenderBox {
bounds.size.height = runs[i].size().height;
let glyph_run = make_glyph_run(&runs[i]);
list.push(~dl::Glyphs(bounds, glyph_run));
- bounds.origin.y = bounds.origin.y.add(bounds.size.height);
+ bounds.origin.y = bounds.origin.y.add(&bounds.size.height);
}
return;
@@ -301,10 +301,10 @@ trait ImageBoxMethods {
* nested CSS boxes that are nested in an otherwise inline flow
* context.
*/
-enum RenderBoxTree { RenderBoxTree }
+pub enum RenderBoxTree { RenderBoxTree }
impl RenderBoxTree : tree::ReadMethods<@RenderBox> {
- fn each_child(node: @RenderBox, f: fn(&&@RenderBox) -> bool) {
+ fn each_child(node: @RenderBox, f: fn(&&box: @RenderBox) -> bool) {
tree::each_child(self, node, f)
}
@@ -350,7 +350,7 @@ impl RenderBox : BoxedDebugMethods {
@ImageBox(*) => ~"ImageBox",
@TextBox(_,d) => {
let mut s = d.runs.foldl(~"TextBox(runs=", |s, run| {
- fmt!("%s \"%s\"", s, run.text)
+ fmt!("%s \"%s\"", *s, run.text)
});
s += ~")"; s
}
@@ -385,10 +385,10 @@ mod test {
fn flat_bounds(root: @RenderBox) -> ~[Rect<au>] {
let mut r = ~[];
for tree::each_child(RenderBoxTree, root) |c| {
- push_all(r, flat_bounds(c));
+ push_all(&mut r, flat_bounds(c));
}
- push(r, copy root.d().position);
+ push(&mut r, copy root.d().position);
return r;
}
diff --git a/src/servo/layout/display_list_builder.rs b/src/servo/layout/display_list_builder.rs
index 026eea5c4a3..53c355d2637 100644
--- a/src/servo/layout/display_list_builder.rs
+++ b/src/servo/layout/display_list_builder.rs
@@ -26,7 +26,7 @@ use vec::push;
Right now, the builder isn't used for much, but it establishes the
pattern we'll need once we support DL-based hit testing &c. */
-struct DisplayListBuilder {
+pub struct DisplayListBuilder {
ctx: &LayoutContext,
}
@@ -146,4 +146,4 @@ fn should_calculate_the_bounds_of_the_text_items() {
do list.borrow |l| { assert l[1].bounds == expected; }
}
-*/ \ No newline at end of file
+*/
diff --git a/src/servo/layout/flow.rs b/src/servo/layout/flow.rs
index 992428b628c..abab04c44e5 100644
--- a/src/servo/layout/flow.rs
+++ b/src/servo/layout/flow.rs
@@ -181,8 +181,8 @@ impl FlowContext {
_ => seed
},
InlineFlow(*) => do self.inline().boxes.foldl(seed) |acc, box| {
- if box.d().node == node { blk(acc, box) }
- else { acc }
+ if box.d().node == node { blk(*acc, *box) }
+ else { *acc }
},
_ => fail fmt!("Don't know how to iterate node's RenderBoxes for %?", self)
}
@@ -213,12 +213,12 @@ impl FlowContext {
enum FlowTree { FlowTree }
impl FlowTree : tree::ReadMethods<@FlowContext> {
- fn each_child(ctx: @FlowContext, f: fn(&&@FlowContext) -> bool) {
+ fn each_child(ctx: @FlowContext, f: fn(&&box: @FlowContext) -> bool) {
tree::each_child(self, ctx, f)
}
- fn with_tree_fields<R>(&&b: @FlowContext, f: fn(tree::Tree<@FlowContext>) -> R) -> R {
- f(b.d().tree)
+ fn with_tree_fields<R>(&&box: @FlowContext, f: fn(tree::Tree<@FlowContext>) -> R) -> R {
+ f(box.d().tree)
}
}
@@ -228,8 +228,8 @@ impl FlowTree : tree::WriteMethods<@FlowContext> {
tree::add_child(self, parent, child)
}
- fn with_tree_fields<R>(&&b: @FlowContext, f: fn(tree::Tree<@FlowContext>) -> R) -> R {
- f(b.d().tree)
+ fn with_tree_fields<R>(&&box: @FlowContext, f: fn(tree::Tree<@FlowContext>) -> R) -> R {
+ f(box.d().tree)
}
}
@@ -259,7 +259,7 @@ impl FlowContext : BoxedDebugMethods {
let repr = match *self {
InlineFlow(*) => {
let mut s = self.inline().boxes.foldl(~"InlineFlow(children=", |s, box| {
- fmt!("%s %?", s, box.d().id)
+ fmt!("%s %?", *s, box.d().id)
});
s += ~")"; s
},
diff --git a/src/servo/layout/inline.rs b/src/servo/layout/inline.rs
index 3418c866a2a..678ee2f3903 100644
--- a/src/servo/layout/inline.rs
+++ b/src/servo/layout/inline.rs
@@ -133,7 +133,7 @@ impl FlowContext : InlineLayout {
};
box.d().position.origin = Point2D(au(0), cur_y);
- cur_y = cur_y.add(au::max(line_height, box.d().position.size.height));
+ cur_y = cur_y.add(&au::max(line_height, box.d().position.size.height));
} // for boxes.each |box|
self.d().position.size.height = cur_y;
diff --git a/src/servo/layout/layout_task.rs b/src/servo/layout/layout_task.rs
index 749236cc198..d9ba3b6e7a9 100644
--- a/src/servo/layout/layout_task.rs
+++ b/src/servo/layout/layout_task.rs
@@ -30,28 +30,28 @@ use layout::traverse::*;
use comm::*;
use task::*;
-type LayoutTask = Chan<Msg>;
+pub type LayoutTask = comm::Chan<Msg>;
-enum LayoutQuery {
+pub enum LayoutQuery {
ContentBox(Node)
}
-type LayoutQueryResponse = Result<LayoutQueryResponse_, ()>;
+pub type LayoutQueryResponse = Result<LayoutQueryResponse_, ()>;
enum LayoutQueryResponse_ {
ContentSize(Size2D<int>)
}
-enum Msg {
- BuildMsg(Node, ARC<Stylesheet>, Url, Chan<Event>),
- PingMsg(Chan<content_task::PingMsg>),
- QueryMsg(LayoutQuery, Chan<LayoutQueryResponse>),
+pub enum Msg {
+ BuildMsg(Node, ARC<Stylesheet>, Url, comm::Chan<Event>),
+ PingMsg(comm::Chan<content_task::PingMsg>),
+ QueryMsg(LayoutQuery, comm::Chan<LayoutQueryResponse>),
ExitMsg
}
fn LayoutTask(render_task: RenderTask,
img_cache_task: ImageCacheTask) -> LayoutTask {
- do spawn_listener::<Msg>|from_content| {
+ do spawn_listener::<Msg> |from_content| {
Layout(render_task, img_cache_task, from_content).start();
}
}
diff --git a/src/servo/layout/traverse_parallel.rs b/src/servo/layout/traverse_parallel.rs
index faad6a04b43..57b4bde29c2 100644
--- a/src/servo/layout/traverse_parallel.rs
+++ b/src/servo/layout/traverse_parallel.rs
@@ -56,7 +56,8 @@ finish, and then applies the second function to the current box.
applied to that node's children
*/
-fn traverse_helper<T : Copy Send>(-root : @RenderBox, returned : T, -top_down : fn~(+T, @RenderBox) -> T,
+fn traverse_helper<T : Copy Send>(-root : @RenderBox, returned : T,
+ -top_down : fn~(+val: T, @RenderBox) -> T,
-bottom_up : fn~(@RenderBox)) {
let returned = top_down(returned, root);
@@ -110,7 +111,7 @@ fn nop(_box : @RenderBox) {
A wrapper to change a function that only acts on a box to one that
threasds a unit through to match travserse_helper
*/
-fn unit_wrapper(-fun : fn~(@RenderBox)) -> fn~(+(), @RenderBox) {
+fn unit_wrapper(-fun : fn~(@RenderBox)) -> fn~(+val: (), @RenderBox) {
fn~(+_u : (), box : @RenderBox) { fun(box); }
}
@@ -146,7 +147,7 @@ fn bottom_up_traversal(+root : @RenderBox, -bottom_up : fn~(@RenderBox)) {
children in parallel, and then the parent.
*/
fn extended_full_traversal<T : Copy Send>(+root : @RenderBox, first_val : T,
- -top_down : fn~(+T, @RenderBox) -> T,
+ -top_down : fn~(+val: T, @RenderBox) -> T,
-bottom_up : fn~(@RenderBox)) {
traverse_helper(root, first_val, top_down, bottom_up);
}
@@ -157,6 +158,6 @@ fn extended_full_traversal<T : Copy Send>(+root : @RenderBox, first_val : T,
function is passed to each child when they are recursed upon.
*/
fn extended_top_down_traversal<T : Copy Send>(+root : @RenderBox, first_val : T,
- -top_down : fn~(+T, @RenderBox) -> T) {
+ -top_down : fn~(+val: T, @RenderBox) -> T) {
traverse_helper(root, first_val, top_down, nop);
}