Commit Graph

775 Commits

Author SHA1 Message Date
Emily McDonough
eab92e0de5 Bug 1963204 - Remove unnecessary use of eContentBasedAutoMinSize in ResolveIntrinsicSizeForNonSpanningItems r=layout-grid-reviewers,dholbert
After recent changes, this is totally unnecessary and can simply be removed.

Differential Revision: https://phabricator.services.mozilla.com/D247020
2025-04-29 16:39:19 +00:00
Ting-Yu Lin
c4432f819e Bug 1961424 - Store CachedBAxisMeasurement's key verbatim instead of hashing them. r=emilio
Instead of bit-packing grid area inline size and baseline padding into a hash,
store them as separate fields to avoid key collisions.

I failed to craft a testcase to cover this change alone. However, with the new
behavior introduced in bug 1944423 (with
`layout.css.grid-multi-pass-track-sizing.enabled` enabled), these WPTs will fail
without this patch.

- css/css-grid/layout-algorithm/grid-fit-content-percentage.html
- css/css-grid/layout-algorithm/grid-container-percentage-001.html

Differential Revision: https://phabricator.services.mozilla.com/D246465
2025-04-28 18:49:20 +00:00
Ting-Yu Lin
25bed1b6a4 Bug 1961428 Part 2 - Move nsGridContainerFrame::CachedBAxisMeasurement to cpp file. r=layout-reviewers,dholbert
The grid item cache is an internal implementation detail that does not need to
be exposed in the header. This patch moves `CachedBAxisMeasurement` to the cpp
file, similar to where `nsFlexContainerFrame::CachedBAxisMeasurement` lives.
This change also reduces compile time when modifying the cache code.

Since `CachedBAxisMeasurement` is now hidden, we add a helper
`MarkCachedGridMeasurementsDirty` to remove `CachedBAxisMeasurement::Prop()` in
`nsIFrame::MarkIntrinsicISizesDirty()`.

Differential Revision: https://phabricator.services.mozilla.com/D246060
2025-04-19 01:05:17 +00:00
Ting-Yu Lin
54025f3acc Bug 1481876 - Compute grid row sizes a second time to resolve percentage row sizes. r=dholbert
This is based on Mats Palmgren's patch in
https://hg.mozilla.org/try/rev/bf21485b5a5157dc361b46da7ba32d0ce52acf4c

Note that we don't have test coverage for subgrid in rows with percentage sizes.
Filed Bug 1951477 for future work.

Differential Revision: https://phabricator.services.mozilla.com/D242973
2025-04-14 04:29:34 +00:00
Emily McDonough
947b68bf40 Bug 1946177 Part 1 - Rename eApplyAutoMinSize and apply the flag before any other intrinsic sizing operations. r=TYLin
This check is based on the exact definition in the spec, and ideally would
be a superset of the cases where it is currently applied.

This also updates some test expectations. It seems that perhaps
layout/reftests/css-grid/grid-flex-min-sizing-001.html isn't so useful, as
the tests and refs are almost identical now. The layout reftest changes
reflect behavior in other browsers, and appear more correct after examination.
As noted in the past, these tests depend on known incorrect behavior to begin
with.

This difference was not caught by the WPT, and a test case will be added to
WPT in the next part of this bug.

This re-breaks table-grid-item-dynamic-004.html which was fixed by
bug 1916849, however I believe this was fixed on accident in that bug. It
doesn't seem that those changes should have fixed that test, and likely it was
the slightly different handling of this flag that caused it to "work".

Differential Revision: https://phabricator.services.mozilla.com/D244447
2025-04-10 23:31:18 +00:00
Ting-Yu Lin
6d8318a0e0 Bug 1957240 - Extract two nsGridContainerFrame::Reflow() helper methods to compute sizes. r=layout-grid-reviewers,dholbert
This patch is a preparation for bug 1481876.

This patch also adds more comments based on the suggestions in [1] to clarify
the computation of content block-size (the old `trackSizingBSize`).

[1] https://phabricator.services.mozilla.com/D242973#inline-1344090

Differential Revision: https://phabricator.services.mozilla.com/D243600
2025-04-08 04:23:51 +00:00
David Shin
c291c3a105 Bug 1958914: Treat AnchorResolved-using types as instantiations, not subtypes. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D244658
2025-04-08 02:29:19 +00:00
David Shin
85c922b0dd Bug 1923959: Resolve anchor for (max) sizes. r=firefox-style-system-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D240864
2025-04-08 02:29:18 +00:00
David Shin
40e6a5c66e Bug 1923959: Resolve anchor for margins. r=firefox-style-system-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D240863
2025-04-08 02:29:18 +00:00
Emily McDonough
02d43f8837 Bug 1955109 Part 1 - Do not allow grid flex tracks to grow during intrinsic sizing of the grid container itself r=layout-grid-reviewers,dholbert
Add a test which is specifically failed before this patch (with the pref
enabled) but is fixed by the patch. This specific case seems to not be tested
in isolation by WPT.

This fixes the major issue we found with bug 1938619, and enables the pref
layout.css.grid-flex-spanning-items-intrinsic-sizing.enabled in nightly-only.

Differential Revision: https://phabricator.services.mozilla.com/D243030
2025-03-26 21:19:24 +00:00
Ting-Yu Lin
b39996855e Bug 1956370 - Rename bSize in nsGridContainerFrame::Reflow(). r=layout-grid-reviewers,AlaskanEmily
In `nsGridContainerFrame::Reflow()`, we are computing the content-box block-size
for the grid container. This patch renames the variable `bSize` to improve
clarity.

The only modification other than the rename is removing the `nscoord`
declaration within `if (aReflowInput.ShouldApplyAutomaticMinimumOnBlockAxis())`
since we've already declared `contentBSize`.

Differential Revision: https://phabricator.services.mozilla.com/D242972
2025-03-25 23:12:03 +00:00
Ting-Yu Lin
e28e919db0 Bug 1951834 Part 2 - Simplify if-else branch in nsGridContainerFrame::Reflow(). r=layout-reviewers,emilio
This patch does not change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D240719
2025-03-08 06:48:20 +00:00
Ting-Yu Lin
ed5bc38c51 Bug 1951834 Part 1 - Use IsColSubgrid() and IsRowSubgrid() more. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D240718
2025-03-08 06:48:20 +00:00
Ting-Yu Lin
3193eee06e Bug 1951861 Part 1 - Adjust flexible track sizes in grid-max-sizing-flex-006.html to make the row sizes align with a quarter of a pixel. r=dholbert
The motivation of this patch is that this test would fail after we fix
bug 1481876, and it already fails in Chrome and Safari, which is worth fixing
now.

This patch maintains the intent of the sub-test that validates fractional `fr`
units. However, the flex factor sum, which used to be less than one, now becomes
greater than one. Therefore, I have distilled this sub-test into a web-platform
test in the next part to exercise the code path and the behavior described in
spec 12.7.1.2 [1].

[1] https://drafts.csswg.org/css-grid-2/#algo-find-fr-size

Differential Revision: https://phabricator.services.mozilla.com/D240553
2025-03-06 22:37:33 +00:00
David Shin
4dc4e2d920 Bug 1942715: Part 4 - Switch to using a more transparent wrapper. r=firefox-style-system-reviewers,emilio
Don't have to write more one-off wrappers for size and margin.
It does cost having to copy fallback values, but that may
not be a huge tradeoff.

Differential Revision: https://phabricator.services.mozilla.com/D237097
2025-02-12 01:31:30 +00:00
Butkovits Atila
e51ff081c6 Backed out 6 changesets (bug 1942715) for causing build bustages. CLOSED TREE
Backed out changeset 1433202bd2f3 (bug 1942715)
Backed out changeset d9ce2be09cd0 (bug 1942715)
Backed out changeset 9789581a42a3 (bug 1942715)
Backed out changeset 9a18f1aca5d5 (bug 1942715)
Backed out changeset 46bd0cb031f4 (bug 1942715)
Backed out changeset 73fec8bae045 (bug 1942715)
2025-02-12 01:45:46 +02:00
David Shin
c536f3deb5 Bug 1942715: Part 4 - Switch to using a more transparent wrapper. r=firefox-style-system-reviewers,emilio
Don't have to write more one-off wrappers for size and margin.
It does cost having to copy fallback values, but that may
not be a huge tradeoff.

Differential Revision: https://phabricator.services.mozilla.com/D237097
2025-02-11 21:06:24 +00:00
Butkovits Atila
fd3125f8e5 Backed out 6 changesets (bug 1942715) for causing build bustages. CLOSED TREE
Backed out changeset 7c5cfe6bbaeb (bug 1942715)
Backed out changeset cc5530b02046 (bug 1942715)
Backed out changeset 5a534f455cc3 (bug 1942715)
Backed out changeset ecdd7307c9f1 (bug 1942715)
Backed out changeset 05a62c484807 (bug 1942715)
Backed out changeset a9825ee69550 (bug 1942715)
2025-02-11 22:17:26 +02:00
Ting-Yu Lin
255996f76b Bug 1947356 Part 2 - Rewrite trackSizingBSize initialization to improve readability. r=layout-grid-reviewers,tlouw
Also, improve the comment since other non-auto values of `block-size` could also
resolve to unconstrained block size.

Differential Revision: https://phabricator.services.mozilla.com/D237674
2025-02-11 18:31:22 +00:00
Ting-Yu Lin
9d8ffd594e Bug 1947356 Part 1 - Remove two local variables that are used only once in nsGridContainerFrame::Reflow(). r=tlouw
Specifically, `computedSize` and `containSize` are both used only once. I don't
feel we should bother creating them.

Differential Revision: https://phabricator.services.mozilla.com/D237673
2025-02-11 18:31:21 +00:00
David Shin
96712d3db0 Bug 1942715: Part 4 - Switch to using a more transparent wrapper. r=firefox-style-system-reviewers,emilio
Don't have to write more one-off wrappers for size and margin.
It does cost having to copy fallback values, but that may
not be a huge tradeoff.

Differential Revision: https://phabricator.services.mozilla.com/D237097
2025-02-11 18:19:56 +00:00
Daniel Holbert
5b16a6571d Bug 1946530: Introduce a utility function to convert a LogicalPoint to a different WritingMode, interpreting it as the origin of some rect. r=jfkthame,TYLin
This patch shouldn't change behavior; it's just refactoring a particular
pattern into a helper method.

Differential Revision: https://phabricator.services.mozilla.com/D237249
2025-02-07 20:45:11 +00:00
David Shin
61d5b05704 Bug 1945944: Add flag to dump frame tree with only deterministic information for diffing. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D236797
2025-02-06 15:34:27 +00:00
Emily McDonough
94bbab1b23 Bug 1946236 - Update a bug link for implementing the grid sizing algorithm r=layout-grid-reviewers,TYLin DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D236955
2025-02-05 23:06:58 +00:00
Ting-Yu Lin
42256d68d1 Bug 1945003 Part 3 - Rename remaining GridReflowInput variables. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D236291
2025-02-01 01:03:38 +00:00
Ting-Yu Lin
fd748fc6b3 Bug 1945003 Part 2 - Rename GridReflowInput parameters from aState to aGridRI. r=dholbert
Bug 1277129 renamed `GridReflowState` to `GridReflowInput`, hence the renaming
of these parameters. This change also helps distinguish these variables from
`GridItemInfo::mState` and `TrackSize::mState`.

Differential Revision: https://phabricator.services.mozilla.com/D236290
2025-02-01 01:03:38 +00:00
Ting-Yu Lin
50e1488176 Bug 1945003 Part 1 - Convert typedef to using in nsGridContainerFrame.cpp. r=dholbert
Also, sort the existing `using` declarations.

Differential Revision: https://phabricator.services.mozilla.com/D236289
2025-02-01 01:03:37 +00:00
Ting-Yu Lin
fe32255255 Bug 1930672 - Resolve percentage sizes when computing auto repeat grid tracks. r=layout-grid-reviewers,tlouw
Differential Revision: https://phabricator.services.mozilla.com/D229379
2025-01-29 05:02:42 +00:00
Ting-Yu Lin
e2666b9103 Bug 1936854 - Disregard inline-size property when computing grid intrinsic inline size with auto repeat tracks. r=layout-grid-reviewers,dholbert
`RepeatTrackSizingInput::InitFromStyle()` is called in
`nsGridContainerFrame::ComputeIntrinsicISize()`. When we compute a frame's
intrinsic inline size, its inline-size property should not affect the result.

Differential Revision: https://phabricator.services.mozilla.com/D235879
2025-01-29 05:02:42 +00:00
Emily McDonough
87603e55fc Bug 1938619 - Add a pref (disabled by default) to enable intrinsic sizing of flexible grid tracks based on grid items that span multiple tracks. r=layout-grid-reviewers,dholbert
The pref layout.css.grid-flex-spanning-items-intrinsic-sizing.enabled is
expected to be removed once these regressions are fixed. This should be a good
compromise between maintaining the code from bug 1916849, and avoiding
breakage/extra backouts.

Differential Revision: https://phabricator.services.mozilla.com/D235089
2025-01-24 06:30:03 +00:00
David Shin
3d615cb7f6 Bug 1923763: Part 5 - Replace inset evaluations with anchor-resolved inset evaluations. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D231259
2025-01-21 15:11:25 +00:00
Stanca Serban
4a35296e0c Backed out 7 changesets (bug 1923763) for causing build bustages in nsStyleStruct.cpp. CLOSED TREE
Backed out changeset d55070e64ced (bug 1923763)
Backed out changeset a92a0bc6047f (bug 1923763)
Backed out changeset 2203e2c5268e (bug 1923763)
Backed out changeset 0cc5e744c01a (bug 1923763)
Backed out changeset d2139afa933b (bug 1923763)
Backed out changeset 93e59980eac1 (bug 1923763)
Backed out changeset 8018734b5491 (bug 1923763)
2025-01-21 11:10:22 +02:00
David Shin
6b9f17e7ff Bug 1923763: Part 5 - Replace inset evaluations with anchor-resolved inset evaluations. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D231259
2025-01-20 23:54:50 +00:00
Ting-Yu Lin
75c9013d4c Bug 1878371 - Fix overflow alignment for distributed alignment values for grid. r=layout-grid-reviewers,dholbert
Per the CSS Align specification, 'space-between', 'space-around', and
'space-evenly' should use a "safe" fallback alignment when overflow occurs. This
patch implements that behavior, renames the function for clarity, and removes
unused parameters.

Differential Revision: https://phabricator.services.mozilla.com/D234755
2025-01-19 22:01:47 +00:00
Emily McDonough
fe2ef59f06 Bug 1941643 - Simplify a lambda in SubgridComputeMarginBorderPadding r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D234208
2025-01-15 00:04:26 +00:00
Emily McDonough
f8475ff189 Bug 1916849 - Implement intrinsic sizing for spanning grid items with flex tracks. r=tlouw,dholbert
This has a couple unfortunate parts to its implementation. In particular, the
adjustment to ShouldApplyAutoMinSize are difficult to explain other than that
function doesn't actually calculate if the minimum contribution of an item is
content-based, but rather checks if the caller should also call MinSize or not.

Part of this calculation includes checking the min-size-auto of the item, but
some are just matching checks for special cases in MinSize.

This could be optimized, and should definitely be refactored to simplify how
all of this is computed.

This still doesn't quite correctly handle all cases for items spanning flex
tracks and tracks with a definite length, but that case is already not handled
correctly so this won't introduce any regressions for that case unless the
expected result is that such an item will have an intrinsic size of zero. In
that case, simply not calculating anything would accidentally be the correct
value, and this new calculation may or may not produce that result.

Differential Revision: https://phabricator.services.mozilla.com/D230829
2024-12-19 23:55:10 +00:00
Ting-Yu Lin
0db103d4b6 Bug 1936276 - Revert Bug 1930672 to fix the overlapping icons on beta.destinyitemmanager.com. r=layout-reviewers,dholbert
This reverts commit https://hg.mozilla.org/mozilla-central/rev/4f3dfc147a61
after resolving the code conflict with Bug 1933101 Part 2
https://hg.mozilla.org/mozilla-central/rev/03da611d9c58

Differential Revision: https://phabricator.services.mozilla.com/D231879
2024-12-12 17:05:46 +00:00
Emily McDonough
9cc098f109 Bug 1936412 - Make comment for ShouldApplyAutoMinSize more correct, rename MinSize to MinContribution. r=tlouw
Differential Revision: https://phabricator.services.mozilla.com/D231748
2024-12-11 17:45:42 +00:00
Emily McDonough
bab7612ef0 Bug 1933803 - Remove explicitly stored per-span data from nsGridContainerFrame::Tracks::ResolveIntrinsicSize r=dholbert
Whether not this is actually useful to store separately is debatable.
While we will need to iterate spans to recalculate this in step 3, we
already need to iterate the tracks multiple times for step 3 so this
doesn't affect the complexity of the operation and this iteration is
relatively cheap.

This data was stored in an auto-array. This means that we only allocate
when the max span is large, but this means we either would do a larger
allocation before, or do more iterations now. At least now, we don't
allocate a big array for a single span, and the complexity of the
iteration is linear in the dimensions of the number of total spans and
the number of tracks in all spans combined, multiplied together. This
is the same complexity of each call to GrowSizeForSpanningItems, and so
is already the complexity of step 3 as a whole.

Differential Revision: https://phabricator.services.mozilla.com/D230438
2024-12-02 20:04:30 +00:00
Ting-Yu Lin
82948d6d24 Bug 1933101 Part 3 - Simplify MinSize() in nsGridContainerFrame.cpp. r=layout-reviewers,emilio
This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D230065
2024-11-25 16:38:54 +00:00
Ting-Yu Lin
d83ba680ad Bug 1933101 Part 2 - Add BehavesLikeInitialValue() to StyleSize and StyleMaxSize. r=layout-reviewers,emilio
Ideally, `BehavesLikeInitialValue()` should be defined via
`IMPL_BEHAVES_LIKE_SIZE_METHODS` macro in ServoStyleConstsInlines.h. However, it
accepts `LogicalAxis`, which is defined in `WritingModes.h`. Therefore, we have
to implement it in `WritingModes.h`.

Differential Revision: https://phabricator.services.mozilla.com/D230064
2024-11-25 16:38:53 +00:00
Ting-Yu Lin
e6851290c7 Bug 1933101 Part 1 - Use StyleSize::Size() instead of ISize() and BSize() separately. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D230063
2024-11-25 16:38:53 +00:00
Emilio Cobos Álvarez
a5184c1852 Bug 1926015 - Percentage-basis aware intrinsic cache. r=TYLin,dholbert
This avoids returning wrong intrinsic values with different calls into
intrinsic size computation, which is wrong by definition.

We shouldn't be wallpapering over it by clearing intrinsic sizes
mid-layout as the original patch was doing.

Differential Revision: https://phabricator.services.mozilla.com/D229621
2024-11-21 19:55:31 +00:00
Adi
b34823b0fe Backed out 5 changesets (bug 1926015) for causing crashtest failures @1730506.html. CLOSED TREE
Backed out changeset 7df628ab162c (bug 1926015)
Backed out changeset a3524c96da73 (bug 1926015)
Backed out changeset cfbf0fa7bf8d (bug 1926015)
Backed out changeset 2c2f56268bd7 (bug 1926015)
Backed out changeset 55175ed82058 (bug 1926015)
2024-11-21 21:28:08 +02:00
Emilio Cobos Álvarez
2e6b4fa1dc Bug 1926015 - Percentage-basis aware intrinsic cache. r=TYLin,dholbert
This avoids returning wrong intrinsic values with different calls into
intrinsic size computation, which is wrong by definition.

We shouldn't be wallpapering over it by clearing intrinsic sizes
mid-layout as the original patch was doing.

Differential Revision: https://phabricator.services.mozilla.com/D229621
2024-11-21 17:04:14 +00:00
Ting-Yu Lin
863bab3170 Bug 1930672 - Resolve percentage sizes when computing auto repeat grid tracks. r=layout-grid-reviewers,tlouw
Differential Revision: https://phabricator.services.mozilla.com/D229379
2024-11-20 00:22:57 +00:00
Emily McDonough
68b6971878 Bug 1931594 - Do not apply auto min size for grid items that span multiple tracks if any of those tracks are flexible. r=layout-grid-reviewers,tlouw
This currently does not actually affect anything, as we do not do intrinsic
sizing for grid items that span multiple tracks if any of those tracks are
flexible anyway.
This is in preparation to do intrinsic sizing for those items in Bug 1916849.

Differential Revision: https://phabricator.services.mozilla.com/D229189
2024-11-19 02:04:31 +00:00
Ting-Yu Lin
1ab1d9fab1 Bug 1931478 - Replace mozilla::Clamp with std::clamp in nsGridContainerFrame.cpp. r=layout-reviewers,emilio
`std::clamp()` requires `min <= max`. In
`RepeatTrackSizingInput::InitFromStyle()`, it computes `max` as
`max = std::max(min, resolved-max-value)` in
https://searchfox.org/mozilla-central/rev/4e69784010d271c0fce0927442e4f8e66ffe645b/layout/generic/nsGridContainerFrame.cpp#326-337

Therefore, the `max` value is never less than `min`, satisfying `min <= max`
when calling `std::clamp` to compute `size`. Hence, this patch doesn't change
behavior.

Differential Revision: https://phabricator.services.mozilla.com/D229098
2024-11-15 20:53:26 +00:00
David Shin
ee160a66f7 Bug 1920160: Part 4 - Move CSSAlignmentForAbsPosChild to nsContainerFrame. r=jwatt,firefox-style-system-reviewers,emilio
Absolutely positioned elements can be aligned, so it no longer
is grid-specific.

Differential Revision: https://phabricator.services.mozilla.com/D226530
2024-11-07 16:33:41 +00:00
longsonr
843d861ed7 Bug 1929338 - convert more mozilla:clamped to std:clamp r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D228069
2024-11-05 18:52:41 +00:00