Skip to content

Conversation

@Louciole
Copy link
Member

No description provided.

Copilot finished reviewing on behalf of Louciole November 19, 2025 15:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements border-collapse support for CSS tables along with significant refactoring of the layout system to properly handle box-sizing and spacing calculations.

Key changes:

  • Added full implementation of CSS table border-collapse algorithm with conflict resolution
  • Refactored layout functions to separate content box from border box layout with explicit UsedSpacings parameter
  • Fixed box-sizing handling to properly account for borders and padding in size calculations

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
src/vaev-engine/layout/table.cpp Implements border-collapse algorithm with harmonization logic, refactors grid access from get/set to at, adds border resolution structures
src/vaev-engine/layout/base/layout-impl.cpp Refactors layout functions to separate border box vs content box layout, adds UsedSpacings struct, fixes specified size calculations
src/vaev-engine/layout/base/layout.cpp Updates function signatures to export new layout API with border/content box separation
src/vaev-engine/layout/block.cpp Adapts block layout to use new UsedSpacings API and layoutBorderBox/layoutAndCommitBorderBox functions
src/vaev-engine/layout/flex.cpp Updates flex layout to compute and pass UsedSpacings explicitly, fixes intrinsic size calculations
src/vaev-engine/layout/inline.cpp Refactors inline atomic box layout to use new spacing API
src/vaev-engine/layout/paint.cpp Adds support for painting collapsed borders via UsedBorders mapping from table formatting context
src/vaev-engine/layout/replaced.cpp Simplifies SVG layout to use new border box layout functions
src/vaev-engine/values/borders.cpp Adds template-based _Border struct to support both specified and used border values, adds BorderEdge enum
src/vaev-engine/res/html.css Adds default table styling for box-sizing and border properties
tests/css/display/display-table.xhtml Adds comprehensive tests for border-collapse with various scenarios (colorful borders, colspan/rowspan, col/row groups), fixes box-sizing in existing tests
tests/css/display/display-flex.xhtml Adds test for flex intrinsic sizing with inline children
tests/css/display/display-block.xhtml Adds test for intrinsic sizing across tree, fixes box-sizing in inline-block test, formatting improvements
tests/css/box-model/padding.xhtml Updates expected sizes to account for box-sizing fixes
tests/css/box-model/box-sizing.xhtml Enables previously skipped content-box test
tests/css/box-model/border.xhtml Adds new test file for border-radius (has structural issue)
src/vaev-engine/driver/render.cpp Updates to use renamed layoutAndCommitRoot function
src/vaev-engine/driver/print.cpp Updates to use renamed layoutAndCommitRoot function
Comments suppressed due to low confidence (1)

src/vaev-engine/layout/base/layout-impl.cpp:216

  • The logic for handling IntrinsicSize::AUTO is inconsistent between width and height. For width (lines 161-187), intrinsic sizes are calculated and border box is added, but for height (lines 190-216), intrinsic sizes return NONE. This asymmetry should be documented or justified with a comment explaining why height treats intrinsic sizing differently.
Opt<Au> computeSpecifiedBorderBoxWidth(Tree& tree, Box& box, Size size, Vec2Au containingBlock, Au horizontalBorderBox, Opt<Au> capmin) {
    if (auto calc = size.is<CalcValue<PercentOr<Length>>>()) {
        auto specifiedWidth = resolve(tree, box, *calc, containingBlock.x);
        if (box.style->boxSizing == BoxSizing::CONTENT_BOX) {
            specifiedWidth += horizontalBorderBox;
        }
        return specifiedWidth;
    }

    if (size.is<Keywords::MinContent>()) {
        auto intrinsicSize = computeIntrinsicContentSize(tree, box, IntrinsicSize::MIN_CONTENT, capmin);
        return intrinsicSize.x + horizontalBorderBox;
    } else if (size.is<Keywords::MaxContent>()) {
        auto intrinsicSize = computeIntrinsicContentSize(tree, box, IntrinsicSize::MAX_CONTENT, capmin);
        return intrinsicSize.x + horizontalBorderBox;
    } else if (size.is<FitContent>()) {
        auto minIntrinsicSize = computeIntrinsicContentSize(tree, box, IntrinsicSize::MIN_CONTENT, capmin);
        auto maxIntrinsicSize = computeIntrinsicContentSize(tree, box, IntrinsicSize::MAX_CONTENT, capmin);
        auto stretchIntrinsicSize = computeIntrinsicContentSize(tree, box, IntrinsicSize::STRETCH_TO_FIT, capmin);

        return clamp(stretchIntrinsicSize.x, minIntrinsicSize.x, maxIntrinsicSize.x) + horizontalBorderBox;
    } else if (size.is<Keywords::Auto>()) {
        return NONE;
    } else {
        logWarn("unknown specified size: {}", size);
        return 0_au;
    }
}

Opt<Au> computeSpecifiedBorderBoxHeight(Tree& tree, Box& box, Size size, Vec2Au containingBlock, Au verticalBorderBox) {
    if (auto calc = size.is<CalcValue<PercentOr<Length>>>()) {
        auto specifiedHeight = resolve(tree, box, *calc, containingBlock.y);
        if (box.style->boxSizing == BoxSizing::CONTENT_BOX) {
            specifiedHeight += verticalBorderBox;
        }
        return specifiedHeight;
    }

    if (size.is<Keywords::MinContent>()) {
        // https://drafts.csswg.org/css-sizing-3/#valdef-width-min-content
        // for a box’s block size, unless otherwise specified, this is equivalent to its automatic size.
        return NONE;
    } else if (size.is<Keywords::MaxContent>()) {
        // https://drafts.csswg.org/css-sizing-3/#valdef-width-max-content
        // for a box’s block size, unless otherwise specified, this is equivalent to its automatic size.
        return NONE;
    } else if (size.is<FitContent>()) {
        // Since this depends on min/max content size, this is also unknown.
        return NONE;
    } else if (size.is<Keywords::Auto>()) {
        return NONE;
    } else {
        logWarn("unknown specified size: {}", size);
        return 0_au;
    }
}

@Louciole Louciole marked this pull request as ready for review November 27, 2025 13:48
Copy link
Member

@sleepy-monax sleepy-monax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inshallah R+

@sleepy-monax sleepy-monax merged commit 08b586b into main Nov 27, 2025
4 checks passed
@sleepy-monax sleepy-monax deleted the loha/p4lm-h4xx5 branch November 27, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants