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

Code before:
                let mut block_level = block_level.borrow_mut();
                match &mut *block_level {
                    BlockLevelBox::Independent(independent_formatting_context) => {
                        let Display::GeneratingBox(DisplayGeneratingBox::OutsideInside {
                            inside: display_inside,
                            ..
                        }) = info.style.clone_display().into()
                        else {
                            return false;
                        };
                        if !matches!(
                            BlockLevelCreator::new_for_inflow_block_level_element(
                                &info,
                                display_inside,
                                contents(),
                                independent_formatting_context.propagated_data,
                            ),
                            BlockLevelCreator::Independent { .. }
                        ) {
                            return false;
                        }
                        independent_formatting_context.rebuild(layout_context, &info);
                        true
                    },
                    BlockLevelBox::OutOfFlowFloatBox(float_box) => {
                        if !info.style.clone_float().is_floating() || is_display_contents() {
                            return false;
                        }
                        float_box.contents.rebuild(layout_context, &info);
                        true
                    },
                    BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(positioned_box) => {
                        if !is_abspos_level() {
                            return false;
                        }
                        positioned_box
                            .borrow_mut()
                            .context
                            .rebuild(layout_context, &info);
                        true
                    },
                    _ => false,
                }
            },
            LayoutBox::InlineLevel(inline_level) => match inline_level {
                InlineItem::OutOfFlowAbsolutelyPositionedBox(positioned_box, ..) => {
                    if !is_abspos_level() {
                        return false;
                    }
                    positioned_box
                        .borrow_mut()

Review comment (suggestion):
It does feel like we could just make the `is_display_content()` check unconditional before the match, unless I'm missing something.

Code after:
            LayoutBox::BlockLevel(block_level) => {
                let mut block_level = block_level.borrow_mut();
                match &mut *block_level {
                    BlockLevelBox::Independent(independent_formatting_context) => {
                        let Display::GeneratingBox(DisplayGeneratingBox::OutsideInside {
                            inside: display_inside,
                            ..
                        }) = display.into()
                        else {
                            return false;
                        };
                        if !matches!(
                            BlockLevelCreator::new_for_inflow_block_level_element(
                                &info,
                                display_inside,
                                contents(),
                                independent_formatting_context.propagated_data,
                            ),
                            BlockLevelCreator::Independent { .. }
                        ) {
                            return false;
                        }
                        independent_formatting_context.rebuild(layout_context, &info);
                        true
                    },
                    BlockLevelBox::OutOfFlowFloatBox(float_box) => {
                        if !info.style.clone_float().is_floating() {
                            return false;
                        }
                        float_box.contents.rebuild(layout_context, &info);
                        true
                    },
                    BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(positioned_box) => {
                        if !info.style.clone_position().is_absolutely_positioned() {
                            return false;
                        }
                        positioned_box
                            .borrow_mut()
                            .context
                            .rebuild(layout_context, &info);
                        true
                    },
                    _ => false,
                }
            },
            LayoutBox::InlineLevel(inline_level) => match inline_level {
                InlineItem::OutOfFlowAbsolutelyPositionedBox(positioned_box, ..) => {
                    if !info.style.clone_position().is_absolutely_positioned() {
                        return false;
                    }
                    positioned_box