[css-grid] grid padding reduces available space for abspos inside grid items
Categories
(Core :: Layout: Grid, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox67 | --- | fixed |
People
(Reporter: Oriol, Assigned: MatsPalmgren_bugz)
References
(Blocks 1 open bug)
Details
Attachments
(3 files, 3 obsolete files)
522 bytes,
text/html
|
Details | |
9.42 KB,
patch
|
dholbert
:
review+
|
Details | Diff | Splinter Review |
23.77 KB,
patch
|
dholbert
:
review+
|
Details | Diff | Splinter Review |
What steps will reproduce the problem?
- Create a CSS grid with
position: relative; grid: 100px / 100px; padding-left: 20px
- Place a grid item inside it.
- Place an abspos element inside the grid item.
- Leave the abspos in its static position, but with
grid-column: 1 / 2
- Add two floats inside the abspos, each one with
width: 50px
. Or more generally, any content with total width >80px and <=100px, but which can be broken is parts narrower than <=80px each.
What is the expected result?
The max-content width of the abspos is 50px+50px = 100px, and the grid area is 100px wide, so the abspos has enough space to grow so that the content fits in a single line.
What happens instead?
For some reason, the padding-left: 20px
of the grid only lets the abspos grow to be 80px wide, so the floats will appear in different lines.
Chromium is also affected: https://crbug.com/921722. Edge does it correctly.
Updated•6 years ago
|
Assignee | ||
Comment 1•6 years ago
|
||
Seems like a valid bug to me, both intuitively and after reading the specs:
https://drafts.csswg.org/css-align-3/#staticpos-rect
https://drafts.csswg.org/css-grid/#abspos-items
Assignee | ||
Comment 2•6 years ago
•
|
||
This seems to fix it for me. It appears we calculate the "hypothetical
position" correctly but we fail to translate it into the right coordinate
space.
Oriol, does the WPT in this patch pass in Edge?
Assignee | ||
Updated•6 years ago
|
Reporter | ||
Comment 3•6 years ago
|
||
(In reply to Mats Palmgren (:mats) from comment #2)
Oriol, does the WPT in this patch pass in Edge?
Yes, Edge passes it (after replacing the logical size properties with the physical ones).
Assignee | ||
Comment 4•6 years ago
|
||
Thanks. I'll change it to use physical sizes instead.
(The test did test different writing-modes at one point too,
so it was convenient to use logical sizes, but I decided to
treat that a separate bug since it's not specific to just
Grid layout: bug 1521988.)
Assignee | ||
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Assignee | ||
Comment 7•6 years ago
|
||
(In reply to Daniel Holbert [:dholbert] from comment #6)
Comment on attachment 9038497 [details] [diff] [review]
(We really should rename |aReflowInput|, maybe to aCBReflowInput. I stared
at this chunk, confused for a bit, not realizing it was for the CB.)
It's fairly well documented in the comments though:
https://searchfox.org/mozilla-central/rev/c035ee7d3a5cd6913e7143e1bce549ffb4a566ff/layout/generic/ReflowInput.cpp#1341
https://searchfox.org/mozilla-central/rev/c035ee7d3a5cd6913e7143e1bce549ffb4a566ff/layout/generic/ReflowInput.h#1004-1005
but yeah, renaming it would make it clearer.
Is this correct if we're in a RTL writing mode, for example?
I only intended to wallpaper the common case, tbh. We need to
rewrite this code anyway for writing-mode correctness.
Anyway, I added code to handle horizontal-tb/rtl too.
(I'll punt on the rest to bug 1521988 since it's lower priority.)
Assignee | ||
Comment 8•6 years ago
|
||
Comment 9•6 years ago
|
||
Comment 10•6 years ago
•
|
||
Comment 11•6 years ago
|
||
Comment 12•6 years ago
|
||
Following up a bit more on comment 9: I'm uneasy that we're removing some code that seems to be active in no-grids-involved scenarios, and which was added in a no-grids-involved patch [1], and we're replacing it with some grid-specific code.
This seems like it'd have side effects / regressions in some no-grids-involved abs/fixed-pos behavior, though I don't know precisely what.
(Though maybe I'd be more at ease if I had a better understanding of what the removed code was aiming to do precisely and how the new code does the same thing but better. :))
[1] https://hg.mozilla.org/mozilla-central/rev/abc416eac56f#l1.174
Assignee | ||
Comment 13•6 years ago
|
||
(In reply to Daniel Holbert [:dholbert] from comment #10)
right = aReflowInput->ComputedWidth() +
aReflowInput->ComputedPhysicalBorderPadding().right -
cb.XMost();
I think this arithmetic is wrong... I think you really want to be finding
the delta between the right edge of the padding-box and cb.XMost() (which is
a rect in the coordinate system of the padding box[1]), correct?
You're absolutely right, good catch! The tests had a right border-width
that matched the left padding so they worked, unfortunately. I've tweaked
them now so that the RTL case fails with the last patch. I also added
a couple of tests that have the grid origin at a non-zero offset from
the content edge for good measure. I suspect it might be an edge case
that we currently don't have any test for.
(In reply to Daniel Holbert [:dholbert] from comment #12)
Following up a bit more on comment 9: I'm uneasy that we're removing some code that seems to be active in no-grids-involved scenarios, and which was added in a no-grids-involved patch [1], and we're replacing it with some grid-specific code.
Right, so that code came from bug 856932 (which notably landed without
a regression test). In particular, the aContainingBlock.x/y was
the result of PresShell()->GetContentDocumentFixedPositionMargins()
which was used to offset the nsViewportFrame (for the URL bar on
Android, IIUC). That code was later removed as part of a massive
rewrite in bug 1180295, in https://hg.mozilla.org/mozilla-central/diff/258257/layout/generic/nsViewportFrame.cpp
to be precise.
However, it seems to me that the original code that made an
exception for auto/auto was simply wrong. I see no reason
a static position shouldn't also be offset from the viewport
edge. I'm only guessing of course since that code has been
removed now and there's no regression test for it.
I think I prefer to always apply it for simplicity and leave
the onus on any future hacks like that to re-introduce
the auto/auto exception if needed. Hopefully with a better
explanation of why it's needed and with a regression test
this time.
Assignee | ||
Updated•6 years ago
|
Comment 14•6 years ago
|
||
Comment 15•6 years ago
|
||
Comment 16•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/280344f386b2
https://hg.mozilla.org/mozilla-central/rev/e12caed89db3
Description
•