Repository: LadybirdBrowser/ladybird
File: Libraries/LibWeb/Layout/LayoutState.cpp (C++)

Code before:
        if (auto* paintable_box = as_if<Painting::PaintableBox>(paintable.ptr())) {
            transfer_box_model_metrics(paintable_box->box_model(), used_values);

            paintable_box->set_offset(used_values.offset);
            paintable_box->set_content_size(used_values.content_width(), used_values.content_height());
            if (used_values.override_borders_data().has_value())
                paintable_box->set_override_borders_data(used_values.override_borders_data().value());
            if (used_values.table_cell_coordinates().has_value())
                paintable_box->set_table_cell_coordinates(used_values.table_cell_coordinates().value());

            if (auto* paintable_with_lines = as_if<Painting::PaintableWithLines>(*paintable_box)) {
                for (size_t line_index = 0; line_index < used_values.line_boxes.size(); ++line_index) {
                    auto& line_box = used_values.line_boxes[line_index];
                    for (auto& fragment : line_box.fragments()) {
                        if (auto const* text_node = as_if<TextNode>(fragment.layout_node()))
                            text_nodes.set(const_cast<TextNode*>(text_node));
                        auto did_relocate_fragment = try_to_relocate_fragment_in_inline_node(fragment, line_index);
                        if (!did_relocate_fragment)
                            paintable_with_lines->add_fragment(fragment);
                    }
                }
            }

            if (auto* svg_graphics_paintable = as_if<Painting::SVGGraphicsPaintable>(paintable.ptr());
                svg_graphics_paintable && used_values.computed_svg_transforms().has_value())
                svg_graphics_paintable->set_computed_transforms(*used_values.computed_svg_transforms());

            if (auto* svg_path_paintable = as_if<Painting::SVGPathPaintable>(paintable.ptr());
                svg_path_paintable && used_values.computed_svg_path().has_value())
                svg_path_paintable->set_computed_path(move(*used_values.computed_svg_path()));

            if (node.display().is_grid_inside()) {
                paintable_box->set_used_values_for_grid_template_columns(used_values.grid_template_columns());
                paintable_box->set_used_values_for_grid_template_rows(used_values.grid_template_rows());
            }
        }
    }

    // Create paintables for inline nodes without fragments to make possible querying their geometry.
    for (auto& inline_node : inline_nodes) {
        if (inline_node->first_paintable())
            continue;

        auto line_paintable = inline_node->create_paintable_for_line_with_index(0);
        inline_node->add_paintable(line_paintable);
        inline_node_paintables.set(line_paintable.ptr());
        if (auto const* used_values = used_values_per_layout_node.get(*inline_node).value_or(nullptr))
            transfer_box_model_metrics(line_paintable->box_model(), *used_values);
    }

    // Resolve relative positions for regular boxes (not line box fragments):

Review comment (suggestion):
This is a bit of a nitpick, but the indentation makes this hard to read. Can you put braces around this to make it more obvious where the block starts and ends? Alternatively, it could be split it into 2 if statements.

Code after:
        if (auto* paintable_box = as_if<Painting::PaintableBox>(paintable.ptr())) {
            transfer_box_model_metrics(paintable_box->box_model(), used_values);

            paintable_box->set_offset(used_values.offset);
            paintable_box->set_content_size(used_values.content_width(), used_values.content_height());
            if (used_values.override_borders_data().has_value())
                paintable_box->set_override_borders_data(used_values.override_borders_data().value());
            if (used_values.table_cell_coordinates().has_value())
                paintable_box->set_table_cell_coordinates(used_values.table_cell_coordinates().value());

            if (auto* paintable_with_lines = as_if<Painting::PaintableWithLines>(*paintable_box)) {
                for (size_t line_index = 0; line_index < used_values.line_boxes.size(); ++line_index) {
                    auto& line_box = used_values.line_boxes[line_index];
                    for (auto& fragment : line_box.fragments()) {
                        if (auto const* text_node = as_if<TextNode>(fragment.layout_node()))
                            text_nodes.set(const_cast<TextNode*>(text_node));
                        auto did_relocate_fragment = try_to_relocate_fragment_in_inline_node(fragment, line_index);
                        if (!did_relocate_fragment)
                            paintable_with_lines->add_fragment(fragment);
                    }
                }
            }

            if (auto* svg_graphics_paintable = as_if<Painting::SVGGraphicsPaintable>(paintable.ptr());
                svg_graphics_paintable && used_values.computed_svg_transforms().has_value()) {
                svg_graphics_paintable->set_computed_transforms(*used_values.computed_svg_transforms());
            }

            if (auto* svg_path_paintable = as_if<Painting::SVGPathPaintable>(paintable.ptr());
                svg_path_paintable && used_values.computed_svg_path().has_value()) {
                svg_path_paintable->set_computed_path(move(*used_values.computed_svg_path()));
            }

            if (node.display().is_grid_inside()) {
                paintable_box->set_used_values_for_grid_template_columns(used_values.grid_template_columns());
                paintable_box->set_used_values_for_grid_template_rows(used_values.grid_template_rows());
            }
        }
    }

    // Create paintables for inline nodes without fragments to make possible querying their geometry.
    for (auto& inline_node : inline_nodes) {
        if (inline_node->first_paintable())
            continue;

        auto line_paintable = inline_node->create_paintable_for_line_with_index(0);
        inline_node->add_paintable(line_paintable);
        inline_node_paintables.set(line_paintable.ptr());
        if (auto const* used_values = used_values_per_layout_node.get(*inline_node).value_or(nullptr))
            transfer_box_model_metrics(line_paintable->box_model(), *used_values);
    }