Bug 212055 - [css-grid] marginLogicalSizeForChild checks auto margins in the opposite axis for orthogonal items
Summary: [css-grid] marginLogicalSizeForChild checks auto margins in the opposite axis...
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Oriol Brufau
Keywords: InRadar
Depends on:
Reported: 2020-05-18 17:41 PDT by Oriol Brufau
Modified: 2020-05-19 17:03 PDT (History)
10 users (show)

See Also:

testcase (335 bytes, text/html)
2020-05-18 17:41 PDT, Oriol Brufau
no flags Details
Patch (17.22 KB, patch)
2020-05-19 14:06 PDT, Oriol Brufau
no flags Details | Formatted Diff | Diff
Patch (21.33 KB, patch)
2020-05-19 14:13 PDT, Oriol Brufau
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oriol Brufau 2020-05-18 17:41:31 PDT
Created attachment 399689 [details]

This function is wrong:

    LayoutUnit marginLogicalSizeForChild(const RenderGrid& grid, GridTrackSizingDirection direction, const RenderBox& child)
        if (child.needsLayout())
            return computeMarginLogicalSizeForChild(grid, direction, child);
        bool isRowAxis = flowAwareDirectionForChild(grid, child, direction) == ForColumns;
        LayoutUnit marginStart = marginStartIsAuto(child, direction) ? 0_lu : isRowAxis ? child.marginStart() : child.marginBefore();
        LayoutUnit marginEnd = marginEndIsAuto(child, direction) ? 0_lu : isRowAxis ? child.marginEnd() : child.marginAfter();
        return marginStart + marginEnd;

It uses `direction` in order to know which side to check in `marginStartIsAuto` and `marginEndIsAuto`.
But when retrieving the margin amount it uses `flowAwareDirectionForChild` instead.

In the attached testcase, there should be a green square, not a green rectangle.
Comment 1 Oriol Brufau 2020-05-19 14:06:05 PDT
Created attachment 399768 [details]
Comment 2 Oriol Brufau 2020-05-19 14:13:03 PDT
Created attachment 399769 [details]
Comment 3 Oriol Brufau 2020-05-19 14:16:14 PDT
There is still some problem here since the testcase in this bug and the new cases in grid-items-minimum-width-orthogonal-001.html still fail.

But this patch fixes grid-items-minimum-height-orthogonal-001.html, so it's an improvement.
Comment 4 Manuel Rego Casasnovas 2020-05-19 15:11:09 PDT
Comment on attachment 399769 [details]

r=me, thanks for the fix.
Comment 5 EWS 2020-05-19 16:50:30 PDT
Committed r261894: <https://trac.webkit.org/changeset/261894>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 399769 [details].
Comment 6 Radar WebKit Bug Importer 2020-05-19 16:51:12 PDT