aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/main/layout/inline.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/main/layout/inline.rs')
-rw-r--r--src/components/main/layout/inline.rs40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs
index 9d8f5cfbb4f..3886695c4d3 100644
--- a/src/components/main/layout/inline.rs
+++ b/src/components/main/layout/inline.rs
@@ -105,7 +105,7 @@ impl LineboxScanner {
self.pending_line.green_zone = Size2D(Au(0), Au(0))
}
- pub fn scan_for_lines(&mut self, ctx: &LayoutContext) {
+ pub fn scan_for_lines(&mut self) {
self.reset_scanner();
{ // FIXME: manually control borrow length
@@ -127,7 +127,7 @@ impl LineboxScanner {
box
};
- let box_was_appended = self.try_append_to_line(ctx, cur_box);
+ let box_was_appended = self.try_append_to_line(cur_box);
if !box_was_appended {
debug!("LineboxScanner: Box wasn't appended, because line %u was full.",
self.lines.len());
@@ -222,7 +222,7 @@ impl LineboxScanner {
/// Computes the position of a line that has only the provided RenderBox.
/// Returns: the bounding rect of the line's green zone (whose origin coincides
/// with the line's origin) and the actual width of the first box after splitting.
- fn initial_line_placement (&self, ctx: &LayoutContext, first_box: RenderBox, ceiling: Au) -> (Rect<Au>, Au) {
+ fn initial_line_placement (&self, first_box: RenderBox, ceiling: Au) -> (Rect<Au>, Au) {
debug!("LineboxScanner: Trying to place first box of line %?", self.lines.len());
debug!("LineboxScanner: box size: %?", first_box.position().size);
let splitable = first_box.can_split();
@@ -266,7 +266,7 @@ impl LineboxScanner {
// FIXME(eatkinson): calling split_to_width here seems excessive and expensive.
// We should find a better abstraction or merge it with the call in
// try_append_to_line.
- match first_box.split_to_width(ctx, line_bounds.size.width, line_is_empty) {
+ match first_box.split_to_width(line_bounds.size.width, line_is_empty) {
CannotSplit(_) => {
error!("LineboxScanner: Tried to split unsplittable render box! %s",
first_box.debug_str());
@@ -279,7 +279,7 @@ impl LineboxScanner {
(Some(l_box), Some(_)) => l_box.position().size.width,
(Some(l_box), None) => l_box.position().size.width,
(None, Some(r_box)) => r_box.position().size.width,
- (None, None) => fail!("This cas makes no sense.")
+ (None, None) => fail!("This case makes no sense.")
};
return (line_bounds, actual_box_width);
}
@@ -293,7 +293,7 @@ impl LineboxScanner {
(Some(l_box), Some(_)) => l_box.position().size.width,
(Some(l_box), None) => l_box.position().size.width,
(None, Some(r_box)) => r_box.position().size.width,
- (None, None) => fail!("This cas makes no sense.")
+ (None, None) => fail!("This case makes no sense.")
};
info.width = actual_box_width;
@@ -307,11 +307,11 @@ impl LineboxScanner {
}
/// Returns false only if we should break the line.
- fn try_append_to_line(&mut self, ctx: &LayoutContext, in_box: RenderBox) -> bool {
+ fn try_append_to_line(&mut self, in_box: RenderBox) -> bool {
let line_is_empty: bool = self.pending_line.range.length() == 0;
if line_is_empty {
- let (line_bounds, _) = self.initial_line_placement(ctx, in_box, self.cur_y);
+ let (line_bounds, _) = self.initial_line_placement(in_box, self.cur_y);
self.pending_line.bounds.origin = line_bounds.origin;
self.pending_line.green_zone = line_bounds.size;
}
@@ -348,7 +348,7 @@ impl LineboxScanner {
// First predict where the next line is going to be
let this_line_y = self.pending_line.bounds.origin.y;
- let (next_line, first_box_width) = self.initial_line_placement(ctx, in_box, this_line_y);
+ let (next_line, first_box_width) = self.initial_line_placement(in_box, this_line_y);
let next_green_zone = next_line.size;
let new_width = self.pending_line.bounds.size.width + first_box_width;
@@ -396,7 +396,7 @@ impl LineboxScanner {
} else {
let available_width = green_zone.width - self.pending_line.bounds.size.width;
- match in_box.split_to_width(ctx, available_width, line_is_empty) {
+ match in_box.split_to_width(available_width, line_is_empty) {
CannotSplit(_) => {
error!("LineboxScanner: Tried to split unsplittable render box! %s",
in_box.debug_str());
@@ -542,7 +542,7 @@ impl InlineFlowData {
/// Recursively (top-down) determines the actual width of child contexts and boxes. When called
/// on this context, the context has had its width set by the parent context.
- pub fn assign_widths_inline(@mut self, _: &mut LayoutContext) {
+ pub fn assign_widths_inline(@mut self, _: &LayoutContext) {
// Initialize content box widths if they haven't been initialized already.
//
// TODO: Combine this with `LineboxScanner`'s walk in the box list, or put this into
@@ -574,6 +574,7 @@ impl InlineFlowData {
for InlineFlow(self).each_child |kid| {
do kid.with_mut_base |base| {
base.position.size.width = self.common.position.size.width;
+ base.is_inorder = self.common.is_inorder;
}
}
// There are no child contexts, so stop here.
@@ -585,11 +586,16 @@ impl InlineFlowData {
// 'inline-block' box that created this flow before recursing.
}
- pub fn assign_height_inline(@mut self, ctx: &mut LayoutContext) {
-
+ pub fn assign_height_inorder_inline(@mut self, ctx: &mut LayoutContext) {
for InlineFlow(self).each_child |kid| {
- kid.assign_height(ctx);
+ kid.assign_height_inorder(ctx);
}
+ self.assign_height_inline(ctx);
+ }
+
+ pub fn assign_height_inline(@mut self, _: &LayoutContext) {
+
+ debug!("assign_height_inline: assigning height for flow %?", self.common.id);
// Divide the boxes into lines
// TODO(#226): Get the CSS `line-height` property from the containing block's style to
@@ -598,7 +604,7 @@ impl InlineFlowData {
// TODO(#226): Get the CSS `line-height` property from each non-replaced inline element to
// determine its height for computing linebox height.
let mut scanner = LineboxScanner::new(InlineFlow(self), self.common.floats_in.clone());
- scanner.scan_for_lines(ctx);
+ scanner.scan_for_lines();
// Now, go through each line and lay out the boxes inside
for self.lines.iter().advance |line| {
@@ -765,7 +771,9 @@ impl InlineFlowData {
// TODO(#225): Should `inline-block` elements have flows as children of the inline flow or
// should the flow be nested inside the box somehow?
- true
+
+ // For now, don't traverse the subtree rooted here
+ false
}
}