Split FlowChildren in IndependentLayout and FlowLayout

The result of doing the layout of an independent formatting context
should be unconcerned with margin collapsing.
This commit is contained in:
Anthony Ramine 2019-11-26 16:21:11 +01:00 committed by Simon Sapin
parent 24b7eadfff
commit 858bc5aca6
6 changed files with 61 additions and 48 deletions

View file

@ -4,7 +4,8 @@
use crate::context::LayoutContext;
use crate::dom_traversal::{Contents, NodeExt};
use crate::flow::{BlockFormattingContext, FlowChildren};
use crate::flow::BlockFormattingContext;
use crate::fragments::Fragment;
use crate::geom::flow_relative::Vec2;
use crate::positioned::AbsolutelyPositionedFragment;
use crate::replaced::ReplacedContent;
@ -14,6 +15,7 @@ use servo_arc::Arc;
use std::convert::TryInto;
use style::context::SharedStyleContext;
use style::properties::ComputedValues;
use style::values::computed::Length;
/// https://drafts.csswg.org/css-display/#independent-formatting-context
#[derive(Debug)]
@ -22,6 +24,11 @@ pub(crate) struct IndependentFormattingContext {
contents: IndependentFormattingContextContents,
}
pub(crate) struct IndependentLayout {
pub fragments: Vec<Fragment>,
pub content_block_size: Length,
}
// Private so that code outside of this module cannot match variants.
// It should got through methods instead.
#[derive(Debug)]
@ -74,7 +81,7 @@ impl IndependentFormattingContext {
containing_block: &ContainingBlock,
tree_rank: usize,
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
) -> FlowChildren {
) -> IndependentLayout {
match self.as_replaced() {
Ok(replaced) => match *replaced {},
Err(ifc) => ifc.layout(
@ -94,7 +101,7 @@ impl<'a> NonReplacedIFC<'a> {
containing_block: &ContainingBlock,
tree_rank: usize,
absolutely_positioned_fragments: &mut Vec<AbsolutelyPositionedFragment<'a>>,
) -> FlowChildren {
) -> IndependentLayout {
match &self.0 {
NonReplacedIFCKind::Flow(bfc) => bfc.layout(
layout_context,