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

Code before:
    // `BlockContainer::construct` parallelize their construction.
    fn compute_inline_content_sizes(
        &self,
        layout_context: &LayoutContext,
        constraint_space: &ConstraintSpace,
    ) -> InlineContentSizesResult {
        ContentSizesComputation::compute(self, layout_context, constraint_space)
    }
}

/// A struct which takes care of computing [`ContentSizes`] for an [`InlineFormattingContext`].
struct ContentSizesComputation<'layout_data> {
    layout_context: &'layout_data LayoutContext<'layout_data>,
    constraint_space: &'layout_data ConstraintSpace<'layout_data>,
    paragraph: ContentSizes,
    current_line: ContentSizes,
    /// Size for whitespace pending to be added to this line.
    pending_whitespace: ContentSizes,
    /// The size of the not yet cleared floats on the inline-start side of the containing block.
    uncleared_start_floats: ContentSizes,
    /// The size of the already cleared floats on the inline-start side of the containing block.
    cleared_start_floats: ContentSizes,
    /// The size of the not yet cleared floats on the inline-end side of the containing block.
    uncleared_end_floats: ContentSizes,
    /// The size of the already cleared floats on the inline-end side of the containing block.
    cleared_end_floats: ContentSizes,
    /// Whether or not the current line has seen any content (excluding collapsed whitespace),
    /// when sizing under a min-content constraint.
    had_content_yet_for_min_content: bool,
    /// Whether or not the current line has seen any content (excluding collapsed whitespace),
    /// when sizing under a max-content constraint.
    had_content_yet_for_max_content: bool,
    /// Stack of ending padding, margin, and border to add to the length
    /// when an inline box finishes.
    ending_inline_pbm_stack: Vec<Au>,
    depends_on_block_constraints: bool,
}

impl<'layout_data> ContentSizesComputation<'layout_data> {
    fn traverse(
        mut self,
        inline_formatting_context: &InlineFormattingContext,
    ) -> InlineContentSizesResult {
        self.add_inline_size(
            inline_formatting_context.inline_start_for_first_line(self.constraint_space.into()),
        );
        for inline_item in inline_formatting_context.inline_items.iter() {
            self.process_item(&inline_item.borrow(), inline_formatting_context);
        }
        self.forced_line_break();
        self.clear_floats(Clear::Both);

Review comment (suggestion):
A small point but these could be `LogicalSides1D`:


```suggestion
    /// The size of the not yet cleared floats in the inline axis of the containing block.
    uncleared_floats: LogicalSides1D<ContentSizes>,
    /// The size of the already cleared floatsin the inline axis of the containing block.
    cleared_floats: LogicalSides1D<ContentSizes>,
```

Code after:
    // `BlockContainer::construct` parallelize their construction.
    fn compute_inline_content_sizes(
        &self,
        layout_context: &LayoutContext,
        constraint_space: &ConstraintSpace,
    ) -> InlineContentSizesResult {
        ContentSizesComputation::compute(self, layout_context, constraint_space)
    }
}

/// A struct which takes care of computing [`ContentSizes`] for an [`InlineFormattingContext`].
struct ContentSizesComputation<'layout_data> {
    layout_context: &'layout_data LayoutContext<'layout_data>,
    constraint_space: &'layout_data ConstraintSpace<'layout_data>,
    paragraph: ContentSizes,
    current_line: ContentSizes,
    /// Size for whitespace pending to be added to this line.
    pending_whitespace: ContentSizes,
    /// The size of the not yet cleared floats in the inline axis of the containing block.
    uncleared_floats: LogicalSides1D<ContentSizes>,
    /// The size of the already cleared floats in the inline axis of the containing block.
    cleared_floats: LogicalSides1D<ContentSizes>,
    /// Whether or not the current line has seen any content (excluding collapsed whitespace),
    /// when sizing under a min-content constraint.
    had_content_yet_for_min_content: bool,
    /// Whether or not the current line has seen any content (excluding collapsed whitespace),
    /// when sizing under a max-content constraint.
    had_content_yet_for_max_content: bool,
    /// Stack of ending padding, margin, and border to add to the length
    /// when an inline box finishes.
    ending_inline_pbm_stack: Vec<Au>,
    depends_on_block_constraints: bool,
}

impl<'layout_data> ContentSizesComputation<'layout_data> {
    fn traverse(
        mut self,
        inline_formatting_context: &InlineFormattingContext,
    ) -> InlineContentSizesResult {
        self.add_inline_size(
            inline_formatting_context.inline_start_for_first_line(self.constraint_space.into()),
        );
        for inline_item in inline_formatting_context.inline_items.iter() {
            self.process_item(&inline_item.borrow(), inline_formatting_context);
        }
        self.forced_line_break();
        self.clear_floats(Clear::Both);

        InlineContentSizesResult {
            sizes: self
                .paragraph