Skip to content

Commit

Permalink
layout: Rewrite display list building to be parallel and to handle
Browse files Browse the repository at this point in the history
overflow correctly, and opportunistically lay out blocks in parallel
even if floats are present.

This commit fixes the `inline-height-test` in Acid2 by implementing
proper overflow as well as the inline "strut".  (See CSS 2.1 § 10.8.1.)
Acid2 was accidentally being rendered properly before because tables'
descendant flows were not being laid out properly.

Display list building is now parallel and is done by bubbling up display
items and layers from parent to child. Speedups of around 60%-70% are
observed on Wikipedia with a 4-core HyperThreaded Core i7.  More
optimizations are possible; this is just a start.

To minimize the amount of data that needs to be bubbled up, as well as
to make proper handling of `overflow: hidden` clipping easier, the
`StackingContext` abstraction is now purely internal to the display
list.  That is, instead of placing items into a stacking context
directly, display items are placed into display lists alongside a
stacking level.  When a stacking context is complete, it is flattened
with the the `flatten` method, which shuffles the display items that
make up the context into their proper order while handling clipping
properly.
  • Loading branch information
pcwalton committed May 2, 2014
1 parent 1ab22d9 commit 81f5da9
Show file tree
Hide file tree
Showing 20 changed files with 1,485 additions and 1,038 deletions.
338 changes: 266 additions & 72 deletions src/components/gfx/display_list.rs

Large diffs are not rendered by default.

542 changes: 292 additions & 250 deletions src/components/main/layout/block.rs

Large diffs are not rendered by default.

444 changes: 240 additions & 204 deletions src/components/main/layout/box_.rs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/components/main/layout/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ impl<'a> FlowConstructor<'a> {
}
}

let mut inline_flow = ~InlineFlow::from_boxes((*node).clone(), boxes) as ~Flow:Share;
let mut inline_flow = ~InlineFlow::from_boxes((*node).clone(), boxes);
inline_flow.compute_minimum_ascent_and_descent(self.font_context(), &**node.style());
let mut inline_flow = inline_flow as ~Flow:Share;
TextRunScanner::new().scan_for_runs(self.font_context(), inline_flow);
inline_flow.finish(self.layout_context);

Expand Down
4 changes: 4 additions & 0 deletions src/components/main/layout/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use css::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};

use geom::rect::Rect;
use geom::size::Size2D;
use gfx::display_list::OpaqueNode;
use gfx::font_context::{FontContext, FontContextInfo};
Expand Down Expand Up @@ -87,6 +88,9 @@ pub struct LayoutContext {

/// The command line options.
pub opts: Opts,

/// The dirty rectangle, used during display list building.
pub dirty: Rect<Au>,
}

#[cfg(not(target_os="android"))]
Expand Down
52 changes: 0 additions & 52 deletions src/components/main/layout/display_list_builder.rs

This file was deleted.

1 comment on commit 81f5da9

@pcwalton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=larsbergstrom

Please sign in to comment.