Repository: servo/servo
File: components/layout/flow/mod.rs (Rust)

Code before:
        }
        sequential_layout_state.adjoin_assign(&CollapsedMargin::new(margin.block_end));
    }

    let content_rect = LogicalRect {
        start_corner: LogicalVec2 {
            block: (pbm.padding.block_start +
                pbm.border.block_start +
                clearance.unwrap_or_else(Au::zero)),
            inline: pbm.padding.inline_start +
                pbm.border.inline_start +
                effective_margin_inline_start,
        },
        size: LogicalVec2 {
            block: block_size,
            inline: containing_block_for_children.size.inline,
        },
    };

    let mut base_fragment_info = base.base_fragment_info;

    // An anonymous block doesn't establish a containing block for its contents. Therefore,
    // if its contents depend on block constraints, its block size (which is intrinsic) also
    // depends on block constraints.
    let is_anonymous = matches!(base.style.pseudo(), Some(PseudoElement::ServoAnonymousBox));
    if depends_on_block_constraints || is_anonymous && flow_layout.depends_on_block_constraints {
        base_fragment_info
            .flags
            .insert(FragmentFlags::SIZE_DEPENDS_ON_BLOCK_CONSTRAINTS_AND_CAN_BE_CHILD_OF_FLEX_ITEM);
    }

    BoxFragment::new(
        base_fragment_info,
        style.clone(),
        flow_layout.fragments,
        content_rect.as_physical(Some(containing_block)),
        pbm.padding.to_physical(containing_block_writing_mode),
        pbm.border.to_physical(containing_block_writing_mode),
        margin.to_physical(containing_block_writing_mode),
        flow_layout.specific_layout_info,
    )
    .with_baselines(flow_layout.baselines)
    .with_block_level_layout_info(block_margins_collapsed_with_children, clearance)
}

impl IndependentFormattingContext {
    /// Lay out an in-flow block-level box that establishes an independent
    /// formatting context in its containing formatting context.
    ///
    /// - <https://drafts.csswg.org/css2/visudet.html#blockwidth>
    /// - <https://drafts.csswg.org/css2/visudet.html#block-replaced-width>

Review comment (suggestion):
```suggestion
    if depends_on_block_constraints || (is_anonymous && flow_layout.depends_on_block_constraints) {
```

Code after:
        }
        sequential_layout_state.adjoin_assign(&CollapsedMargin::new(margin.block_end));
    }

    let content_rect = LogicalRect {
        start_corner: LogicalVec2 {
            block: (pbm.padding.block_start +
                pbm.border.block_start +
                clearance.unwrap_or_else(Au::zero)),
            inline: pbm.padding.inline_start +
                pbm.border.inline_start +
                effective_margin_inline_start,
        },
        size: LogicalVec2 {
            block: block_size,
            inline: containing_block_for_children.size.inline,
        },
    };

    let mut base_fragment_info = base.base_fragment_info;

    // An anonymous block doesn't establish a containing block for its contents. Therefore,
    // if its contents depend on block constraints, its block size (which is intrinsic) also
    // depends on block constraints.
    let is_anonymous = matches!(base.style.pseudo(), Some(PseudoElement::ServoAnonymousBox));
    if depends_on_block_constraints || (is_anonymous && flow_layout.depends_on_block_constraints) {
        base_fragment_info
            .flags
            .insert(FragmentFlags::SIZE_DEPENDS_ON_BLOCK_CONSTRAINTS_AND_CAN_BE_CHILD_OF_FLEX_ITEM);
    }

    BoxFragment::new(
        base_fragment_info,
        style.clone(),
        flow_layout.fragments,
        content_rect.as_physical(Some(containing_block)),
        pbm.padding.to_physical(containing_block_writing_mode),
        pbm.border.to_physical(containing_block_writing_mode),
        margin.to_physical(containing_block_writing_mode),
        flow_layout.specific_layout_info,
    )
    .with_baselines(flow_layout.baselines)
    .with_block_level_layout_info(block_margins_collapsed_with_children, clearance)
}

impl IndependentFormattingContext {
    /// Lay out an in-flow block-level box that establishes an independent
    /// formatting context in its containing formatting context.
    ///
    /// - <https://drafts.csswg.org/css2/visudet.html#blockwidth>
    /// - <https://drafts.csswg.org/css2/visudet.html#block-replaced-width>