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

Code before:
    /// position relative to the top of the line.
    fn calculate_block_start(&self, line_metrics: &LineMetrics) -> Au {
        match self.fragment.borrow().style().clone_baseline_shift() {
            BaselineShift::Keyword(BaselineShiftKeyword::Top) => Au::zero(),
            BaselineShift::Keyword(BaselineShiftKeyword::Center) => {
                (line_metrics.block_size - self.size.block).scale_by(0.5)
            },
            BaselineShift::Keyword(BaselineShiftKeyword::Bottom) => {
                line_metrics.block_size - self.size.block
            },

            // This covers all baseline-relative vertical alignment.
            _ => {
                let baseline = line_metrics.baseline_block_offset + self.baseline_offset_in_parent;
                baseline - self.baseline_offset_in_item
            },
        }
    }
}

pub(super) struct AbsolutelyPositionedLineItem {
    pub absolutely_positioned_box: ArcRefCell<AbsolutelyPositionedBox>,
    /// Whether the line would be phantom if it were to end before the abspos.
    /// This is used when computign the static position (in the block axis) of
    /// an abspos whose original display had a block outer display type.
    pub line_of_preceding_contents_would_be_phantom: bool,
}

pub(super) struct FloatLineItem {
    pub fragment: ArcRefCell<BoxFragment>,
    /// Whether or not this float Fragment has been placed yet. Fragments that
    /// do not fit on a line need to be placed after the hypothetical block start
    /// of the next line.
    pub needs_placement: bool,
}

/// Sort a mutable slice by the given indices array in place, reording the slice so that final
/// value of `slice[x]` is `slice[indices[x]]`.
fn sort_by_indices_in_place<T>(data: &mut [T], mut indices: Vec<usize>) {
    for idx in 0..data.len() {
        if indices[idx] == idx {
            continue;
        }

        let mut current_idx = idx;
        loop {
            let target_idx = indices[current_idx];
            indices[current_idx] = current_idx;
            if indices[target_idx] == target_idx {
                break;
            }

Review comment (suggestion):
```suggestion
    pub preceding_line_content_would_produce_phantom_line: bool,
```

Code after:
    /// position relative to the top of the line.
    fn calculate_block_start(&self, line_metrics: &LineMetrics) -> Au {
        match self.fragment.borrow().style().clone_baseline_shift() {
            BaselineShift::Keyword(BaselineShiftKeyword::Top) => Au::zero(),
            BaselineShift::Keyword(BaselineShiftKeyword::Center) => {
                (line_metrics.block_size - self.size.block).scale_by(0.5)
            },
            BaselineShift::Keyword(BaselineShiftKeyword::Bottom) => {
                line_metrics.block_size - self.size.block
            },

            // This covers all baseline-relative vertical alignment.
            _ => {
                let baseline = line_metrics.baseline_block_offset + self.baseline_offset_in_parent;
                baseline - self.baseline_offset_in_item
            },
        }
    }
}

pub(super) struct AbsolutelyPositionedLineItem {
    pub absolutely_positioned_box: ArcRefCell<AbsolutelyPositionedBox>,
    /// Whether the line would be phantom if it were to end before the abspos.
    /// This is used when computing the static position (in the block axis) of
    /// an abspos whose original display had a block outer display type.
    pub preceding_line_content_would_produce_phantom_line: bool,
}

pub(super) struct FloatLineItem {
    pub fragment: ArcRefCell<BoxFragment>,
    /// Whether or not this float Fragment has been placed yet. Fragments that
    /// do not fit on a line need to be placed after the hypothetical block start
    /// of the next line.
    pub needs_placement: bool,
}

/// Sort a mutable slice by the given indices array in place, reording the slice so that final
/// value of `slice[x]` is `slice[indices[x]]`.
fn sort_by_indices_in_place<T>(data: &mut [T], mut indices: Vec<usize>) {
    for idx in 0..data.len() {
        if indices[idx] == idx {
            continue;
        }

        let mut current_idx = idx;
        loop {
            let target_idx = indices[current_idx];
            indices[current_idx] = current_idx;
            if indices[target_idx] == target_idx {
                break;
            }