Skip to content

Commit

Permalink
layout_2020: Paint hoisted positioned fragments in tree order
Browse files Browse the repository at this point in the history
Instead of painting hoisted position fragments in the order to which
they are hoisted, paint them in tree order and properly incorporate them
into the stacking context.

We do this by creating a placeholder fragment in the original tree position
of hoisted fragments. The ghost fragment contains an atomic id which
links back to the hoisted fragment in the containing block.

While building the stacking context, we keep track of containing blocks
and their children. When encountering a placeholder fragment we look at
the containing block's hoisted children in order to properly paint the
hoisted fragment.

One notable design modification in this change is that hoisted fragments
no longer need an AnonymousFragment as their parent. Instead they are
now direct children of the fragment that establishes their containing block.
  • Loading branch information
mrobinson committed Mar 11, 2020
1 parent e3c91f7 commit c3b1c92
Show file tree
Hide file tree
Showing 41 changed files with 382 additions and 159 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions components/layout_2020/Cargo.toml
Expand Up @@ -25,6 +25,7 @@ gfx_traits = {path = "../gfx_traits"}
html5ever = "0.25"
ipc-channel = "0.14"
libc = "0.2"
log = "0.4"
msg = {path = "../msg"}
mitochondria = "1.1.2"
net_traits = {path = "../net_traits"}
Expand Down
17 changes: 1 addition & 16 deletions components/layout_2020/display_list/mod.rs
Expand Up @@ -40,9 +40,6 @@ pub struct DisplayListBuilder<'a> {
/// The current SpatialId and ClipId information for this `DisplayListBuilder`.
current_space_and_clip: wr::SpaceAndClipInfo,

/// The id of the nearest ancestor reference frame for this `DisplayListBuilder`.
nearest_reference_frame: wr::SpatialId,

pub context: &'a LayoutContext<'a>,
pub wr: wr::DisplayListBuilder,

Expand All @@ -61,7 +58,6 @@ impl<'a> DisplayListBuilder<'a> {
) -> Self {
Self {
current_space_and_clip: wr::SpaceAndClipInfo::root_scroll(pipeline_id),
nearest_reference_frame: wr::SpatialId::root_reference_frame(pipeline_id),
is_contentful: false,
context,
wr: wr::DisplayListBuilder::new(pipeline_id, viewport_size),
Expand All @@ -72,18 +68,6 @@ impl<'a> DisplayListBuilder<'a> {
// TODO(gw): Make use of the WR backface visibility functionality.
wr::CommonItemProperties::new(clip_rect, self.current_space_and_clip)
}

fn clipping_and_scrolling_scope<R>(&mut self, f: impl FnOnce(&mut Self) -> R) -> R {
let previous_space_and_clip = self.current_space_and_clip;
let previous_nearest_reference_frame = self.nearest_reference_frame;

let result = f(self);

self.current_space_and_clip = previous_space_and_clip;
self.nearest_reference_frame = previous_nearest_reference_frame;

result
}
}

impl Fragment {
Expand All @@ -94,6 +78,7 @@ impl Fragment {
) {
match self {
Fragment::Box(b) => BuilderForBoxFragment::new(b, containing_block).build(builder),
Fragment::AbsoluteOrFixedPositioned(_) => {},
Fragment::Anonymous(_) => {},
Fragment::Text(t) => {
builder.is_contentful = true;
Expand Down

0 comments on commit c3b1c92

Please sign in to comment.