diff options
Diffstat (limited to 'src/components/main/layout')
-rw-r--r-- | src/components/main/layout/block.rs | 6 | ||||
-rw-r--r-- | src/components/main/layout/box.rs | 24 | ||||
-rw-r--r-- | src/components/main/layout/box_builder.rs | 40 | ||||
-rw-r--r-- | src/components/main/layout/float.rs | 10 | ||||
-rw-r--r-- | src/components/main/layout/float_context.rs | 20 | ||||
-rw-r--r-- | src/components/main/layout/flow.rs | 4 | ||||
-rw-r--r-- | src/components/main/layout/inline.rs | 80 | ||||
-rw-r--r-- | src/components/main/layout/layout_task.rs | 10 | ||||
-rw-r--r-- | src/components/main/layout/text.rs | 20 | ||||
-rw-r--r-- | src/components/main/layout/util.rs | 16 |
10 files changed, 113 insertions, 117 deletions
diff --git a/src/components/main/layout/block.rs b/src/components/main/layout/block.rs index ba3b4746a63..7a852dbf117 100644 --- a/src/components/main/layout/block.rs +++ b/src/components/main/layout/block.rs @@ -360,7 +360,7 @@ impl FlowContext for BlockFlow { /// Dual boxes consume some width first, and the remainder is assigned to all child (block) /// contexts. fn assign_widths(&mut self, ctx: &mut LayoutContext) { - debug!("assign_widths_block: assigning width for flow %?", self.base.id); + debug!("assign_widths_block: assigning width for flow {}", self.base.id); if self.is_root { debug!("Setting root position"); self.base.position.origin = Au::zero_point(); @@ -433,12 +433,12 @@ impl FlowContext for BlockFlow { } fn assign_height_inorder(&mut self, ctx: &mut LayoutContext) { - debug!("assign_height_inorder: assigning height for block %?", self.base.id); + debug!("assign_height_inorder: assigning height for block {}", self.base.id); self.assign_height_block_base(ctx, true); } fn assign_height(&mut self, ctx: &mut LayoutContext) { - debug!("assign_height: assigning height for block %?", self.base.id); + debug!("assign_height: assigning height for block {}", self.base.id); // This is the only case in which a block flow can start an inorder // subtraversal. if self.is_root && self.base.num_floats > 0 { diff --git a/src/components/main/layout/box.rs b/src/components/main/layout/box.rs index 364b6c03f70..5dc426d3af0 100644 --- a/src/components/main/layout/box.rs +++ b/src/components/main/layout/box.rs @@ -310,7 +310,7 @@ impl RenderBox for ImageRenderBox { let size = self.image.mutate().ptr.get_size(); let height = Au::from_px(size.unwrap_or(Size2D(0, 0)).height); self.base.position.mutate().ptr.size.height = height; - debug!("box_height: found image height: %?", height); + debug!("box_height: found image height: {}", height); height } @@ -343,7 +343,7 @@ impl TextRenderBox { /// /// FIXME(pcwalton): This API is confusing. pub fn new(base: RenderBoxBase, run: @TextRun, range: Range) -> TextRenderBox { - debug!("Creating textbox with span: (strlen=%u, off=%u, len=%u) of textrun (%s) (len=%u)", + debug!("Creating textbox with span: (strlen={:u}, off={:u}, len={:u}) of textrun ({:s}) (len={:u})", run.char_len(), range.begin(), range.length(), @@ -422,13 +422,13 @@ impl RenderBox for TextRenderBox { let mut left_range = Range::new(self.range.begin(), 0); let mut right_range: Option<Range> = None; - debug!("split_to_width: splitting text box (strlen=%u, range=%?, avail_width=%?)", + debug!("split_to_width: splitting text box (strlen={:u}, range={}, avail_width={})", self.run.text.get().len(), self.range, max_width); for (glyphs, offset, slice_range) in self.run.iter_slices_for_range(&self.range) { - debug!("split_to_width: considering slice (offset=%?, range=%?, remain_width=%?)", + debug!("split_to_width: considering slice (offset={}, range={}, remain_width={})", offset, slice_range, remaining_width); @@ -470,7 +470,7 @@ impl RenderBox for TextRenderBox { // the right chunk. let right_range_end = self.range.end() - slice_begin; right_range = Some(Range::new(slice_begin, right_range_end)); - debug!("split_to_width: case=splitting remainder with right range=%?", + debug!("split_to_width: case=splitting remainder with right range={:?}", right_range); } } @@ -728,7 +728,7 @@ impl RenderBoxBase { pub fn font_style(&self) -> FontStyle { let my_style = self.nearest_ancestor_element().style(); - debug!("(font style) start: %?", self.nearest_ancestor_element().type_id()); + debug!("(font style) start: {:?}", self.nearest_ancestor_element().type_id()); // FIXME: Too much allocation here. let font_families = do my_style.Font.font_family.map |family| { @@ -737,10 +737,10 @@ impl RenderBoxBase { } }; let font_families = font_families.connect(", "); - debug!("(font style) font families: `%s`", font_families); + debug!("(font style) font families: `{:s}`", font_families); let font_size = my_style.Font.font_size.to_f64().unwrap() / 60.0; - debug!("(font style) font size: `%fpx`", font_size); + debug!("(font style) font size: `{:f}px`", font_size); let (italic, oblique) = match my_style.Font.font_style { font_style::normal => (false, false), @@ -948,9 +948,9 @@ impl RenderBoxUtils for @RenderBox { let base = self.base(); let box_bounds = base.position.get(); let absolute_box_bounds = box_bounds.translate(offset); - debug!("RenderBox::build_display_list at rel=%?, abs=%?: %s", + debug!("RenderBox::build_display_list at rel={}, abs={}: {:s}", box_bounds, absolute_box_bounds, self.debug_str()); - debug!("RenderBox::build_display_list: dirty=%?, offset=%?", dirty, offset); + debug!("RenderBox::build_display_list: dirty={}, offset={}", *dirty, *offset); if absolute_box_bounds.intersects(dirty) { debug!("RenderBox::build_display_list: intersected. Adding display item..."); @@ -990,7 +990,7 @@ impl RenderBoxUtils for @RenderBox { // // FIXME(pcwalton): This is a bit of an abuse of the logging infrastructure. We // should have a real `SERVO_DEBUG` system. - debug!("%?", { + debug!("{:?}", { // Compute the text box bounds and draw a border surrounding them. let debug_border = SideOffsets2D::new_all_same(Au::from_px(1)); @@ -1039,7 +1039,7 @@ impl RenderBoxUtils for @RenderBox { // FIXME(pcwalton): This is a bit of an abuse of the logging infrastructure. We // should have a real `SERVO_DEBUG` system. - debug!("%?", { + debug!("{:?}", { let debug_border = SideOffsets2D::new_all_same(Au::from_px(1)); do list.with_mut_ref |list| { diff --git a/src/components/main/layout/box_builder.rs b/src/components/main/layout/box_builder.rs index e2cff941d97..6b72794a121 100644 --- a/src/components/main/layout/box_builder.rs +++ b/src/components/main/layout/box_builder.rs @@ -70,7 +70,7 @@ impl<'self> BoxGenerator<'self> { /* Debug ids only */ fn new(flow: &'self mut FlowContext) -> BoxGenerator<'self> { - debug!("Creating box generator for flow: %s", flow.debug_str()); + debug!("Creating box generator for flow: {:s}", flow.debug_str()); BoxGenerator { flow: flow, range_stack: @mut ~[] @@ -105,12 +105,12 @@ impl<'self> BoxGenerator<'self> { ctx: &LayoutContext, node: AbstractNode<LayoutView>, builder: &mut LayoutTreeBuilder) { - debug!("BoxGenerator[f%d]: pushing node: %s", flow::base(self.flow).id, node.debug_str()); + debug!("BoxGenerator[f{:d}]: pushing node: {:s}", flow::base(self.flow).id, node.debug_str()); // TODO: remove this once UA styles work let box_type = self.decide_box_type(node); - debug!("BoxGenerator[f%d]: point a", flow::base(self.flow).id); + debug!("BoxGenerator[f{:d}]: point a", flow::base(self.flow).id); let range_stack = &mut self.range_stack; // depending on flow, make a box for this node. @@ -135,10 +135,10 @@ impl<'self> BoxGenerator<'self> { }, BlockFlowClass => { let block = self.flow.as_block(); - debug!("BoxGenerator[f%d]: point b", block.base.id); + debug!("BoxGenerator[f{:d}]: point b", block.base.id); let new_box = BoxGenerator::make_box(ctx, box_type, node, builder); - debug!("BoxGenerator[f%d]: attaching box[b%d] to block flow (node: %s)", + debug!("BoxGenerator[f{:d}]: attaching box[b{:d}] to block flow (node: {:s})", block.base.id, new_box.base().id(), node.debug_str()); @@ -148,11 +148,11 @@ impl<'self> BoxGenerator<'self> { } FloatFlowClass => { let float = self.flow.as_float(); - debug!("BoxGenerator[f%d]: point b", float.base.id); + debug!("BoxGenerator[f{:d}]: point b", float.base.id); let new_box = BoxGenerator::make_box(ctx, box_type, node, builder); - debug!("BoxGenerator[f%d]: attaching box[b%d] to float flow (node: %s)", + debug!("BoxGenerator[f{:d}]: attaching box[b{:d}] to float flow (node: {:s})", float.base.id, new_box.base().id(), node.debug_str()); @@ -160,12 +160,12 @@ impl<'self> BoxGenerator<'self> { assert!(float.box.is_none() && float.index.is_none()); float.box = Some(new_box); } - _ => warn!("push_node() not implemented for flow f%d", flow::base(self.flow).id), + _ => warn!("push_node() not implemented for flow f{:d}", flow::base(self.flow).id), } } pub fn pop_node(&mut self, ctx: &LayoutContext, node: AbstractNode<LayoutView>) { - debug!("BoxGenerator[f%d]: popping node: %s", flow::base(self.flow).id, node.debug_str()); + debug!("BoxGenerator[f{:d}]: popping node: {:s}", flow::base(self.flow).id, node.debug_str()); match self.flow.class() { InlineFlowClass => { @@ -188,12 +188,12 @@ impl<'self> BoxGenerator<'self> { warn!("node range length is zero?!") } - debug!("BoxGenerator: adding element range=%?", node_range); + debug!("BoxGenerator: adding element range={}", node_range); inline.elems.add_mapping(node, &node_range); }, BlockFlowClass => assert!(self.range_stack.len() == 0), FloatFlowClass => assert!(self.range_stack.len() == 0), - _ => warn!("pop_node() not implemented for flow %?", flow::base(self.flow).id), + _ => warn!("pop_node() not implemented for flow {:?}", flow::base(self.flow).id), } } @@ -212,7 +212,7 @@ impl<'self> BoxGenerator<'self> { } ImageRenderBoxClass => BoxGenerator::make_image_box(layout_ctx, node, base), }; - debug!("BoxGenerator: created box: %s", result.debug_str()); + debug!("BoxGenerator: created box: {:s}", result.debug_str()); result } @@ -289,7 +289,7 @@ impl LayoutTreeBuilder { mut parent_generator: BoxGenerator<'a>, mut prev_sibling_generator: Option<BoxGenerator<'a>>) -> BoxConstructResult<'a> { - debug!("Considering node: %s", cur_node.debug_str()); + debug!("Considering node: {:s}", cur_node.debug_str()); let box_gen_result = { let grandparent_gen_ref = match grandparent_generator { Some(ref mut generator) => Some(generator), @@ -304,7 +304,7 @@ impl LayoutTreeBuilder { let mut reparent = false; - debug!("result from generator_for_node: %?", &box_gen_result); + debug!("result from generator_for_node: {:?}", &box_gen_result); // Skip over nodes that don't belong in the flow tree let (this_generator, next_generator) = match box_gen_result { NoGenerator => return Normal(prev_sibling_generator), @@ -332,9 +332,9 @@ impl LayoutTreeBuilder { let mut this_generator = this_generator; - debug!("point a: %s", cur_node.debug_str()); + debug!("point a: {:s}", cur_node.debug_str()); this_generator.push_node(layout_ctx, cur_node, self); - debug!("point b: %s", cur_node.debug_str()); + debug!("point b: {:s}", cur_node.debug_str()); // recurse on child nodes. let prev_gen_cell = Cell::new(Normal(None)); @@ -571,7 +571,7 @@ impl LayoutTreeBuilder { let first_box = boxes[0]; // FIXME(pcwalton): Rust bug if first_box.is_whitespace_only() { debug!("LayoutTreeBuilder: pruning whitespace-only first \ - child flow f%d from parent f%d", + child flow f{:d} from parent f{:d}", first_inline_flow.base.id, p_id); do_remove = true; @@ -599,7 +599,7 @@ impl LayoutTreeBuilder { let last_box = boxes.last(); // FIXME(pcwalton): Rust bug if last_box.is_whitespace_only() { debug!("LayoutTreeBuilder: pruning whitespace-only last \ - child flow f%d from parent f%d", + child flow f{:d} from parent f{:d}", last_inline_flow.base.id, p_id); do_remove = true; @@ -638,7 +638,7 @@ impl LayoutTreeBuilder { pub fn construct_trees(&mut self, layout_ctx: &LayoutContext, root: AbstractNode<LayoutView>) -> Result<~FlowContext:, ()> { debug!("Constructing flow tree for DOM: "); - debug!("%?", root.dump()); + debug!("{:?}", root.dump()); let mut new_flow = self.make_flow(RootFlowType, root); { @@ -661,7 +661,7 @@ impl LayoutTreeBuilder { RootFlowType => ~BlockFlow::new_root(info) as ~FlowContext:, TableFlowType => ~TableFlow::new(info) as ~FlowContext:, }; - debug!("LayoutTreeBuilder: created flow: %s", result.debug_str()); + debug!("LayoutTreeBuilder: created flow: {:s}", result.debug_str()); result } } diff --git a/src/components/main/layout/float.rs b/src/components/main/layout/float.rs index 8aee9e4837a..47f6dd12f9b 100644 --- a/src/components/main/layout/float.rs +++ b/src/components/main/layout/float.rs @@ -137,7 +137,7 @@ impl FlowContext for FloatFlow { } fn assign_widths(&mut self, _: &mut LayoutContext) { - debug!("assign_widths_float: assigning width for flow %?", self.base.id); + debug!("assign_widths_float: assigning width for flow {}", self.base.id); // position.size.width is set by parent even though we don't know // position.origin yet. let mut remaining_width = self.base.position.size.width; @@ -174,7 +174,7 @@ impl FlowContext for FloatFlow { let width = MaybeAuto::from_style(style.Box.width, remaining_width).specified_or_default(shrink_to_fit); - debug!("assign_widths_float -- width: %?", width); + debug!("assign_widths_float -- width: {}", width); model.margin.top = margin_top; model.margin.right = margin_right; @@ -210,7 +210,7 @@ impl FlowContext for FloatFlow { } fn assign_height_inorder(&mut self, _: &mut LayoutContext) { - debug!("assign_height_inorder_float: assigning height for float %?", self.base.id); + debug!("assign_height_inorder_float: assigning height for float {}", self.base.id); // assign_height_float was already called by the traversal function // so this is well-defined @@ -250,7 +250,7 @@ impl FlowContext for FloatFlow { } fn assign_height(&mut self, ctx: &mut LayoutContext) { - debug!("assign_height_float: assigning height for float %?", self.base.id); + debug!("assign_height_float: assigning height for float {}", self.base.id); let has_inorder_children = self.base.num_floats > 0; if has_inorder_children { let mut float_ctx = FloatContext::new(self.floated_children); @@ -298,7 +298,7 @@ impl FlowContext for FloatFlow { Au::new(0)).specified_or_zero(); height = geometry::max(height, height_prop) + noncontent_height; - debug!("assign_height_float -- height: %?", height); + debug!("assign_height_float -- height: {}", height); position.size.height = height; } diff --git a/src/components/main/layout/float_context.rs b/src/components/main/layout/float_context.rs index 5786cf369ae..45e142b24b9 100644 --- a/src/components/main/layout/float_context.rs +++ b/src/components/main/layout/float_context.rs @@ -128,7 +128,7 @@ impl FloatContext { impl FloatContextBase{ fn new(num_floats: uint) -> FloatContextBase { - debug!("Creating float context of size %?", num_floats); + debug!("Creating float context of size {}", num_floats); FloatContextBase { float_data: if num_floats == 0 { None @@ -151,7 +151,7 @@ impl FloatContextBase{ match self.float_data.get_ref()[self.floats_used - 1] { None => fail!("FloatContext error: floats should never be None here"), Some(float) => { - debug!("Returning float position: %?", float.bounds.origin + self.offset); + debug!("Returning float position: {}", float.bounds.origin + self.offset); float.bounds.origin + self.offset } } @@ -168,7 +168,7 @@ impl FloatContextBase{ let top = top - self.offset.y; - debug!("available_rect: trying to find space at %?", top); + debug!("available_rect: trying to find space at {}", top); // Relevant dimensions for the right-most left float let mut max_left = Au(0) - self.offset.x; @@ -188,7 +188,7 @@ impl FloatContextBase{ Some(data) => { let float_pos = data.bounds.origin; let float_size = data.bounds.size; - debug!("float_pos: %?, float_size: %?", float_pos, float_size); + debug!("float_pos: {}, float_size: {}", float_pos, float_size); match data.f_type { FloatLeft => { if(float_pos.x + float_size.width > max_left && @@ -198,7 +198,7 @@ impl FloatContextBase{ l_top = Some(float_pos.y); l_bottom = Some(float_pos.y + float_size.height); - debug!("available_rect: collision with left float: new max_left is %?", + debug!("available_rect: collision with left float: new max_left is {}", max_left); } } @@ -209,7 +209,7 @@ impl FloatContextBase{ r_top = Some(float_pos.y); r_bottom = Some(float_pos.y + float_size.height); - debug!("available_rect: collision with right float: new min_right is %?", + debug!("available_rect: collision with right float: new min_right is {}", min_right); } } @@ -249,7 +249,7 @@ impl FloatContextBase{ fn add_float(&mut self, info: &PlacementInfo) { assert!(self.float_data.is_some()); - debug!("Floats_used: %?, Floats available: %?", + debug!("Floats_used: {}, Floats available: {}", self.floats_used, self.float_data.get_ref().len()); assert!(self.floats_used < self.float_data.get_ref().len() && @@ -263,7 +263,7 @@ impl FloatContextBase{ f_type: info.f_type }; - debug!("add_float: added float with info %?", new_info); + debug!("add_float: added float with info {:?}", new_info); let new_float = FloatData { bounds: Rect { @@ -325,13 +325,13 @@ impl FloatContextBase{ /// Given necessary info, finds the closest place a box can be positioned /// without colliding with any floats. fn place_between_floats(&self, info: &PlacementInfo) -> Rect<Au>{ - debug!("place_float: Placing float with width %? and height %?", info.width, info.height); + debug!("place_float: Placing float with width {} and height {}", info.width, info.height); // Can't go any higher than previous floats or // previous elements in the document. let mut float_y = info.ceiling; loop { let maybe_location = self.available_rect(float_y, info.height, info.max_width); - debug!("place_float: Got available rect: %? for y-pos: %?", maybe_location, float_y); + debug!("place_float: Got available rect: {:?} for y-pos: {}", maybe_location, float_y); match maybe_location { // If there are no floats blocking us, return the current location diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs index 35e06902f8f..abbc39a50d9 100644 --- a/src/components/main/layout/flow.rs +++ b/src/components/main/layout/flow.rs @@ -496,12 +496,12 @@ impl<'self> MutableFlowUtils for &'self mut FlowContext { dirty: &Rect<Au>, list: &Cell<DisplayList<E>>) -> bool { - debug!("FlowContext: building display list for f%?", base(self).id); + debug!("FlowContext: building display list for f{}", base(self).id); match self.class() { BlockFlowClass => self.as_block().build_display_list_block(builder, dirty, list), InlineFlowClass => self.as_inline().build_display_list_inline(builder, dirty, list), FloatFlowClass => self.as_float().build_display_list_float(builder, dirty, list), - _ => fail!("Tried to build_display_list_recurse of flow: %?", self), + _ => fail!("Tried to build_display_list_recurse of flow: {:?}", self), } } } diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index 037b782edf0..a15f739ba05 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -103,7 +103,7 @@ impl LineboxScanner { } fn reset_scanner(&mut self, flow: &mut InlineFlow) { - debug!("Resetting line box scanner's state for flow f%d.", flow.base.id); + debug!("Resetting line box scanner's state for flow f{:d}.", flow.base.id); self.lines = ~[]; self.new_boxes = ~[]; self.cur_y = Au::new(0); @@ -128,26 +128,26 @@ impl LineboxScanner { break } let box = flow.boxes[i]; i += 1; - debug!("LineboxScanner: Working with box from box list: b%d", box.base().id()); + debug!("LineboxScanner: Working with box from box list: b{:d}", box.base().id()); box } else { let box = self.work_list.pop_front().unwrap(); - debug!("LineboxScanner: Working with box from work list: b%d", box.base().id()); + debug!("LineboxScanner: Working with box from work list: b{:d}", box.base().id()); box }; let box_was_appended = self.try_append_to_line(cur_box, flow); if !box_was_appended { - debug!("LineboxScanner: Box wasn't appended, because line %u was full.", + debug!("LineboxScanner: Box wasn't appended, because line {:u} was full.", self.lines.len()); self.flush_current_line(); } else { - debug!("LineboxScanner: appended a box to line %u", self.lines.len()); + debug!("LineboxScanner: appended a box to line {:u}", self.lines.len()); } } if self.pending_line.range.length() > 0 { - debug!("LineboxScanner: Partially full linebox %u left at end of scanning.", + debug!("LineboxScanner: Partially full linebox {:u} left at end of scanning.", self.lines.len()); self.flush_current_line(); } @@ -158,7 +158,7 @@ impl LineboxScanner { } fn swap_out_results(&mut self, flow: &mut InlineFlow) { - debug!("LineboxScanner: Propagating scanned lines[n=%u] to inline flow f%d", + debug!("LineboxScanner: Propagating scanned lines[n={:u}] to inline flow f{:d}", self.lines.len(), flow.base.id); @@ -167,11 +167,11 @@ impl LineboxScanner { } fn flush_current_line(&mut self) { - debug!("LineboxScanner: Flushing line %u: %?", + debug!("LineboxScanner: Flushing line {:u}: {:?}", self.lines.len(), self.pending_line); // clear line and add line mapping - debug!("LineboxScanner: Saving information for flushed line %u.", self.lines.len()); + debug!("LineboxScanner: Saving information for flushed line {:u}.", self.lines.len()); self.lines.push(self.pending_line); self.cur_y = self.pending_line.bounds.origin.y + self.pending_line.bounds.size.height; self.reset_linebox(); @@ -193,10 +193,10 @@ impl LineboxScanner { /// with the line's origin) and the actual width of the first box after splitting. fn initial_line_placement(&self, first_box: @RenderBox, ceiling: Au, flow: &mut InlineFlow) -> (Rect<Au>, Au) { - debug!("LineboxScanner: Trying to place first box of line %?", self.lines.len()); + debug!("LineboxScanner: Trying to place first box of line {}", self.lines.len()); let first_box_size = first_box.base().position.get().size; - debug!("LineboxScanner: box size: %?", first_box_size); + debug!("LineboxScanner: box size: {}", first_box_size); let splitable = first_box.can_split(); let line_is_empty: bool = self.pending_line.range.length() == 0; @@ -219,7 +219,7 @@ impl LineboxScanner { let line_bounds = self.floats.place_between_floats(&info); - debug!("LineboxScanner: found position for line: %? using placement_info: %?", + debug!("LineboxScanner: found position for line: {} using placement_info: {:?}", line_bounds, info); @@ -242,7 +242,7 @@ impl LineboxScanner { // try_append_to_line. match first_box.split_to_width(line_bounds.size.width, line_is_empty) { CannotSplit(_) => { - error!("LineboxScanner: Tried to split unsplittable render box! %s", + error!("LineboxScanner: Tried to split unsplittable render box! {:s}", first_box.debug_str()); return (line_bounds, first_box_size.width); } @@ -273,7 +273,7 @@ impl LineboxScanner { info.width = actual_box_width; let new_bounds = self.floats.place_between_floats(&info); - debug!("LineboxScanner: case=new line position: %?", new_bounds); + debug!("LineboxScanner: case=new line position: {}", new_bounds); return (new_bounds, actual_box_width); } } @@ -290,8 +290,8 @@ impl LineboxScanner { self.pending_line.green_zone = line_bounds.size; } - debug!("LineboxScanner: Trying to append box to line %u (box size: %?, green zone: \ - %?): %s", + debug!("LineboxScanner: Trying to append box to line {:u} (box size: {}, green zone: \ + {}): {:s}", self.lines.len(), in_box.base().position.get().size, self.pending_line.green_zone, @@ -361,7 +361,7 @@ impl LineboxScanner { if !in_box.can_split() { // TODO(Issue #224): signal that horizontal overflow happened? if line_is_empty { - debug!("LineboxScanner: case=box can't split and line %u is empty, so \ + debug!("LineboxScanner: case=box can't split and line {:u} is empty, so \ overflowing.", self.lines.len()); self.push_box_to_line(in_box); @@ -375,7 +375,7 @@ impl LineboxScanner { match in_box.split_to_width(available_width, line_is_empty) { CannotSplit(_) => { - error!("LineboxScanner: Tried to split unsplittable render box! %s", + error!("LineboxScanner: Tried to split unsplittable render box! {:s}", in_box.debug_str()); return false; } @@ -394,7 +394,7 @@ impl LineboxScanner { } SplitDidNotFit(left, right) => { if line_is_empty { - debug!("LineboxScanner: case=split box didn't fit and line %u is empty, so overflowing and deferring remainder box.", + debug!("LineboxScanner: case=split box didn't fit and line {:u} is empty, so overflowing and deferring remainder box.", self.lines.len()); // TODO(Issue #224): signal that horizontal overflow happened? match (left, right) { @@ -425,7 +425,7 @@ impl LineboxScanner { // unconditional push fn push_box_to_line(&mut self, box: @RenderBox) { - debug!("LineboxScanner: Pushing box b%d to line %u", box.base().id(), self.lines.len()); + debug!("LineboxScanner: Pushing box b{:d} to line {:u}", box.base().id(), self.lines.len()); if self.pending_line.range.length() == 0 { assert!(self.new_boxes.len() <= (u16::max_value as uint)); @@ -492,7 +492,7 @@ impl InlineFlow { // TODO(#228): Once we form line boxes and have their cached bounds, we can be smarter and // not recurse on a line if nothing in it can intersect the dirty region. - debug!("FlowContext[%d]: building display list for %u inline boxes", + debug!("FlowContext[{:d}]: building display list for {:u} inline boxes", self.base.id, self.boxes.len()); @@ -530,24 +530,20 @@ impl FlowContext for InlineFlow { child_base.floats_in = FloatContext::new(child_base.num_floats); } - { - let this = &mut *self; + let mut min_width = Au::new(0); + let mut pref_width = Au::new(0); - let mut min_width = Au::new(0); - let mut pref_width = Au::new(0); - - for box in this.boxes.iter() { - debug!("FlowContext[%d]: measuring %s", self.base.id, box.debug_str()); - let (this_minimum_width, this_preferred_width) = - box.minimum_and_preferred_widths(); - min_width = Au::max(min_width, this_minimum_width); - pref_width = Au::max(pref_width, this_preferred_width); - } - - this.base.min_width = min_width; - this.base.pref_width = pref_width; - this.base.num_floats = num_floats; + for box in self.boxes.iter() { + debug!("FlowContext[{:d}]: measuring {:s}", self.base.id, box.debug_str()); + let (this_minimum_width, this_preferred_width) = + box.minimum_and_preferred_widths(); + min_width = Au::max(min_width, this_minimum_width); + pref_width = Au::max(pref_width, this_preferred_width); } + + self.base.min_width = min_width; + self.base.pref_width = pref_width; + self.base.num_floats = num_floats; } /// Recursively (top-down) determines the actual width of child contexts and boxes. When called @@ -558,7 +554,7 @@ impl FlowContext for InlineFlow { // TODO: Combine this with `LineboxScanner`'s walk in the box list, or put this into // `RenderBox`. - debug!("assign_widths_inline: floats_in: %?", self.base.floats_in); + debug!("assign_widths_inline: floats_in: {:?}", self.base.floats_in); { let this = &mut *self; for &box in this.boxes.iter() { @@ -588,7 +584,7 @@ impl FlowContext for InlineFlow { } fn assign_height(&mut self, _: &mut LayoutContext) { - debug!("assign_height_inline: assigning height for flow %?", self.base.id); + debug!("assign_height_inline: assigning height for flow {}", self.base.id); // Divide the boxes into lines // TODO(#226): Get the CSS `line-height` property from the containing block's style to @@ -598,7 +594,7 @@ impl FlowContext for InlineFlow { // determine its height for computing linebox height. // // TODO(pcwalton): Cache the linebox scanner? - debug!("assign_height_inline: floats_in: %?", self.base.floats_in); + debug!("assign_height_inline: floats_in: {:?}", self.base.floats_in); let scanner_floats = self.base.floats_in.clone(); let mut scanner = LineboxScanner::new(scanner_floats); @@ -729,8 +725,8 @@ impl FlowContext for InlineFlow { }, // FIXME(pcwalton): This isn't very type safe! _ => { - fail!(fmt!("Tried to assign height to unknown Box variant: %s", - cur_box.debug_str())) + fail!("Tried to assign height to unknown Box variant: {:s}", + cur_box.debug_str()) } }; let mut top_from_base = top_from_base; diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs index 046f2518ffe..a894ffc3896 100644 --- a/src/components/main/layout/layout_task.rs +++ b/src/components/main/layout/layout_task.rs @@ -330,10 +330,10 @@ impl LayoutTask { // FIXME: Bad copy! let doc_url = data.url.clone(); - debug!("layout: received layout request for: %s", doc_url.to_str()); - debug!("layout: damage is %?", data.damage); + debug!("layout: received layout request for: {:s}", doc_url.to_str()); + debug!("layout: damage is {:?}", data.damage); debug!("layout: parsed Node tree"); - debug!("%?", node.dump()); + debug!("{:?}", node.dump()); // Reset the image cache. self.local_image_cache.next_round(self.make_on_image_available_cb()); @@ -341,7 +341,7 @@ impl LayoutTask { let screen_size = Size2D(Au::from_px(data.window_size.width as int), Au::from_px(data.window_size.height as int)); let resized = self.screen_size != Some(screen_size); - debug!("resized: %?", resized); + debug!("resized: {}", resized); self.screen_size = Some(screen_size); // Create a layout context for use throughout the following passes. @@ -384,7 +384,7 @@ impl LayoutTask { layout_root.traverse_postorder(&mut ComputeDamageTraversal.clone()); debug!("layout: constructed Flow tree"); - debug!("%?", layout_root.dump()); + debug!("{:?}", layout_root.dump()); // Perform the primary layout passes over the flow tree to compute the locations of all // the boxes. diff --git a/src/components/main/layout/text.rs b/src/components/main/layout/text.rs index 77a8831d137..e18538fe44f 100644 --- a/src/components/main/layout/text.rs +++ b/src/components/main/layout/text.rs @@ -31,13 +31,13 @@ impl TextRunScanner { // FIXME: this assertion fails on wikipedia, but doesn't seem // to cause problems. // assert!(inline.boxes.len() > 0); - debug!("TextRunScanner: scanning %u boxes for text runs...", inline.boxes.len()); + debug!("TextRunScanner: scanning {:u} boxes for text runs...", inline.boxes.len()); } let mut last_whitespace = true; let mut out_boxes = ~[]; for box_i in range(0, flow.as_immutable_inline().boxes.len()) { - debug!("TextRunScanner: considering box: %u", box_i); + debug!("TextRunScanner: considering box: {:u}", box_i); if box_i > 0 && !can_coalesce_text_nodes(flow.as_immutable_inline().boxes, box_i - 1, box_i) { @@ -92,7 +92,7 @@ impl TextRunScanner { assert!(self.clump.length() > 0); - debug!("TextRunScanner: flushing boxes in range=%?", self.clump); + debug!("TextRunScanner: flushing boxes in range={}", self.clump); let is_singleton = self.clump.length() == 1; let possible_text_clump = in_boxes[self.clump.begin()]; // FIXME(pcwalton): Rust bug let is_text_clump = possible_text_clump.class() == UnscannedTextRenderBoxClass; @@ -104,7 +104,7 @@ impl TextRunScanner { fail!(~"WAT: can't coalesce non-text nodes in flush_clump_to_list()!") } (true, false) => { - debug!("TextRunScanner: pushing single non-text box in range: %?", self.clump); + debug!("TextRunScanner: pushing single non-text box in range: {}", self.clump); out_boxes.push(in_boxes[self.clump.begin()]); }, (true, true) => { @@ -126,7 +126,7 @@ impl TextRunScanner { let fontgroup = ctx.font_ctx.get_resolved_font_for_style(&font_style); let run = @fontgroup.create_textrun(transformed_text, decoration); - debug!("TextRunScanner: pushing single text box in range: %? (%?)", self.clump, text); + debug!("TextRunScanner: pushing single text box in range: {} ({})", self.clump, text); let range = Range::new(0, run.char_len()); let new_box = @TextRenderBox::new((*old_box.base()).clone(), run, range); @@ -185,12 +185,12 @@ impl TextRunScanner { }; // Make new boxes with the run and adjusted text indices. - debug!("TextRunScanner: pushing box(es) in range: %?", self.clump); + debug!("TextRunScanner: pushing box(es) in range: {}", self.clump); for i in clump.eachi() { let range = new_ranges[i - self.clump.begin()]; if range.length() == 0 { debug!("Elided an `UnscannedTextbox` because it was zero-length after \ - compression; %s", + compression; {:s}", in_boxes[i].debug_str()); continue } @@ -205,19 +205,19 @@ impl TextRunScanner { debug!("--- In boxes: ---"); for (i, box) in in_boxes.iter().enumerate() { - debug!("%u --> %s", i, box.debug_str()); + debug!("{:u} --> {:s}", i, box.debug_str()); } debug!("------------------"); debug!("--- Out boxes: ---"); for (i, box) in out_boxes.iter().enumerate() { - debug!("%u --> %s", i, box.debug_str()); + debug!("{:u} --> {:s}", i, box.debug_str()); } debug!("------------------"); debug!("--- Elem ranges: ---"); for (i, nr) in inline.elems.eachi() { - debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); () + debug!("{:u}: {} --> {:s}", i, nr.range, nr.node.debug_str()); () } debug!("--------------------"); diff --git a/src/components/main/layout/util.rs b/src/components/main/layout/util.rs index 7701aa2bd66..cf6d38ee7a0 100644 --- a/src/components/main/layout/util.rs +++ b/src/components/main/layout/util.rs @@ -51,19 +51,19 @@ impl ElementMapping { debug!("--- Old boxes: ---"); for (i, box) in old_boxes.iter().enumerate() { - debug!("%u --> %s", i, box.debug_str()); + debug!("{:u} --> {:s}", i, box.debug_str()); } debug!("------------------"); debug!("--- New boxes: ---"); for (i, box) in new_boxes.iter().enumerate() { - debug!("%u --> %s", i, box.debug_str()); + debug!("{:u} --> {:s}", i, box.debug_str()); } debug!("------------------"); debug!("--- Elem ranges before repair: ---"); for (i, nr) in entries.iter().enumerate() { - debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); + debug!("{:u}: {} --> {:s}", i, nr.range, nr.node.debug_str()); } debug!("----------------------------------"); @@ -80,17 +80,17 @@ impl ElementMapping { let mut entries_k = 0; while old_i < old_boxes.len() { - debug!("repair_for_box_changes: Considering old box %u", old_i); + debug!("repair_for_box_changes: Considering old box {:u}", old_i); // possibly push several items while entries_k < entries.len() && old_i == entries[entries_k].range.begin() { let item = WorkItem {begin_idx: new_j, entry_idx: entries_k}; - debug!("repair_for_box_changes: Push work item for elem %u: %?", entries_k, item); + debug!("repair_for_box_changes: Push work item for elem {:u}: {:?}", entries_k, item); repair_stack.push(item); entries_k += 1; } while new_j < new_boxes.len() && old_boxes[old_i].base().node != new_boxes[new_j].base().node { - debug!("repair_for_box_changes: Slide through new box %u", new_j); + debug!("repair_for_box_changes: Slide through new box {:u}", new_j); new_j += 1; } @@ -99,14 +99,14 @@ impl ElementMapping { // possibly pop several items while repair_stack.len() > 0 && old_i == entries[repair_stack.last().entry_idx].range.end() { let item = repair_stack.pop(); - debug!("repair_for_box_changes: Set range for %u to %?", + debug!("repair_for_box_changes: Set range for {:u} to {}", item.entry_idx, Range::new(item.begin_idx, new_j - item.begin_idx)); entries[item.entry_idx].range = Range::new(item.begin_idx, new_j - item.begin_idx); } } debug!("--- Elem ranges after repair: ---"); for (i, nr) in entries.iter().enumerate() { - debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); + debug!("{:u}: {} --> {:s}", i, nr.range, nr.node.debug_str()); } debug!("----------------------------------"); } |