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

Code before:
                callback(&independent_formatting_context.borrow().base)
            },
            InlineItem::AnonymousBlock(block_box) => callback(&block_box.borrow().base),
        }
    }

    pub(crate) fn with_base_mut<T>(&self, callback: impl FnOnce(&mut LayoutBoxBase) -> T) -> T {
        match self {
            InlineItem::StartInlineBox(inline_box) => callback(&mut inline_box.borrow_mut().base),
            InlineItem::EndInlineBox | InlineItem::TextRun(..) => {
                unreachable!("Should never have these kind of fragments attached to a DOM node")
            },
            InlineItem::OutOfFlowAbsolutelyPositionedBox(positioned_box, ..) => {
                callback(&mut positioned_box.borrow_mut().context.base)
            },
            InlineItem::OutOfFlowFloatBox(float_box) => {
                callback(&mut float_box.borrow_mut().contents.base)
            },
            InlineItem::Atomic(independent_formatting_context, ..) => {
                callback(&mut independent_formatting_context.borrow_mut().base)
            },
            InlineItem::AnonymousBlock(block_box) => callback(&mut block_box.borrow_mut().base),
        }
    }

    pub(crate) fn attached_to_tree(&self, box_: WeakLayoutBox) {
        match self {
            Self::StartInlineBox(_) | InlineItem::EndInlineBox => {
                // The parentage of inline items within an inline box is handled when the entire
                // inline formatting context is attached to the tree.
            },
            Self::TextRun(_) => {
                // Text runs can't have children, so no need to do anything.
            },
            Self::OutOfFlowAbsolutelyPositionedBox(positioned_box, ..) => {
                positioned_box.borrow().context.attached_to_tree(box_)
            },
            Self::OutOfFlowFloatBox(float_box) => {
                float_box.borrow().contents.attached_to_tree(box_)
            },
            Self::Atomic(atomic, ..) => atomic.borrow().attached_to_tree(box_),
            Self::AnonymousBlock(block_box) => block_box.borrow().contents.attached_to_tree(box_),
        }
    }

    pub(crate) fn downgrade(&self) -> WeakInlineItem {
        match self {
            Self::StartInlineBox(inline_box) => {
                WeakInlineItem::StartInlineBox(inline_box.downgrade())
            },
            Self::EndInlineBox => WeakInlineItem::EndInlineBox,

Review comment (suggestion):
```suggestion
    pub(crate) fn attached_to_tree(&self, layout_box: WeakLayoutBox) {
```

Code after:
                callback(&independent_formatting_context.borrow().base)
            },
            InlineItem::AnonymousBlock(block_box) => callback(&block_box.borrow().base),
        }
    }

    pub(crate) fn with_base_mut<T>(&self, callback: impl FnOnce(&mut LayoutBoxBase) -> T) -> T {
        match self {
            InlineItem::StartInlineBox(inline_box) => callback(&mut inline_box.borrow_mut().base),
            InlineItem::EndInlineBox | InlineItem::TextRun(..) => {
                unreachable!("Should never have these kind of fragments attached to a DOM node")
            },
            InlineItem::OutOfFlowAbsolutelyPositionedBox(positioned_box, ..) => {
                callback(&mut positioned_box.borrow_mut().context.base)
            },
            InlineItem::OutOfFlowFloatBox(float_box) => {
                callback(&mut float_box.borrow_mut().contents.base)
            },
            InlineItem::Atomic(independent_formatting_context, ..) => {
                callback(&mut independent_formatting_context.borrow_mut().base)
            },
            InlineItem::AnonymousBlock(block_box) => callback(&mut block_box.borrow_mut().base),
        }
    }

    pub(crate) fn attached_to_tree(&self, layout_box: WeakLayoutBox) {
        match self {
            Self::StartInlineBox(_) | InlineItem::EndInlineBox => {
                // The parentage of inline items within an inline box is handled when the entire
                // inline formatting context is attached to the tree.
            },
            Self::TextRun(_) => {
                // Text runs can't have children, so no need to do anything.
            },
            Self::OutOfFlowAbsolutelyPositionedBox(positioned_box, ..) => {
                positioned_box.borrow().context.attached_to_tree(layout_box)
            },
            Self::OutOfFlowFloatBox(float_box) => {
                float_box.borrow().contents.attached_to_tree(layout_box)
            },
            Self::Atomic(atomic, ..) => atomic.borrow().attached_to_tree(layout_box),
            Self::AnonymousBlock(block_box) => {
                block_box.borrow().contents.attached_to_tree(layout_box)
            },
        }
    }

    pub(crate) fn downgrade(&self) -> WeakInlineItem {
        match self {
            Self::StartInlineBox(inline_box) => {
                WeakInlineItem::StartInlineBox(inline_box.downgrade())