Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Place floats in layout 2020, but don't flow text around the floats yet.
This commit puts floats behind the `layout.floats.enabled` pref, because of the
following issues and unimplemented features:

* Inline formatting contexts don't take floats into account, so text doesn't
  flow around the floats yet.

* Non-floated block formatting contexts don't take floats into account, so BFCs
  can overlap floats.

* The `clear` property is only respected on floats, not on other elements; i.e.
  regular boxes can't clear past floats yet.

* Block formatting contexts that contain floats don't expand vertically to
  contain all the floats. That is, floats can stick out the bottom of BFCs,
  contra spec.

* Floats don't respect negative margins yet.

* Floats are painted in the same order as regular content, contra spec.
  • Loading branch information
pcwalton committed Jul 27, 2020
1 parent c7bdb1b commit cba8088
Show file tree
Hide file tree
Showing 218 changed files with 658 additions and 317 deletions.
3 changes: 3 additions & 0 deletions components/config/prefs.rs
Expand Up @@ -442,6 +442,9 @@ mod gen {
flexbox: {
enabled: bool,
},
floats: {
enabled: bool,
},
#[serde(default = "default_layout_threads")]
threads: i64,
viewport: {
Expand Down
4 changes: 4 additions & 0 deletions components/layout_2020/display_list/mod.rs
Expand Up @@ -101,6 +101,10 @@ impl Fragment {
Visibility::Hidden => (),
Visibility::Collapse => (),
},
Fragment::Float(f) => {
// FIXME(pcwalton): Wrong painting order!
BuilderForBoxFragment::new(&f.box_fragment, containing_block).build(builder)
},
Fragment::AbsoluteOrFixedPositioned(_) => {},
Fragment::Anonymous(_) => {},
Fragment::Image(i) => match i.style.get_inherited_box().visibility {
Expand Down
29 changes: 27 additions & 2 deletions components/layout_2020/display_list/stacking_context.rs
Expand Up @@ -6,7 +6,7 @@ use crate::cell::ArcRefCell;
use crate::display_list::conversions::ToWebRender;
use crate::display_list::DisplayListBuilder;
use crate::fragments::{
AbsoluteOrFixedPositionedFragment, AnonymousFragment, BoxFragment, Fragment,
AbsoluteOrFixedPositionedFragment, AnonymousFragment, BoxFragment, FloatFragment, Fragment,
};
use crate::geom::PhysicalRect;
use crate::style_ext::ComputedValuesExt;
Expand Down Expand Up @@ -452,7 +452,7 @@ impl Fragment {
return;
}

// If this fragment has a transform applied that makes it take up no spae
// If this fragment has a transform applied that makes it take up no space
// then we don't need to create any stacking contexts for it.
let has_non_invertible_transform =
fragment.has_non_invertible_transform(&containing_block_info.rect.to_untyped());
Expand All @@ -467,6 +467,14 @@ impl Fragment {
stacking_context,
);
},
Fragment::Float(fragment) => {
fragment.build_stacking_context_tree(
fragment_ref,
builder,
containing_block_info,
stacking_context,
);
},
Fragment::AbsoluteOrFixedPositioned(fragment) => {
fragment.build_stacking_context_tree(
builder,
Expand Down Expand Up @@ -908,6 +916,23 @@ impl AnonymousFragment {
}
}

impl FloatFragment {
fn build_stacking_context_tree(
&self,
fragment: &ArcRefCell<Fragment>,
builder: &mut StackingContextBuilder,
containing_block_info: &ContainingBlockInfo,
stacking_context: &mut StackingContext,
) {
self.box_fragment.build_stacking_context_tree(
fragment,
builder,
containing_block_info,
stacking_context,
);
}
}

impl AbsoluteOrFixedPositionedFragment {
fn build_stacking_context_tree(
&self,
Expand Down

0 comments on commit cba8088

Please sign in to comment.