Commit Graph

787 Commits

Author SHA1 Message Date
iulian moraru
7e041e382a Revert "Bug 1968081 - Calculate percentage basis upfront when finding intrinsic sizes of grid items r=layout-grid-reviewers,dholbert" for causing mass build bustages on nsGridContainerFrame.cpp.
This reverts commit a9167bd9d5.
2025-05-23 23:24:43 +00:00
Emily McDonough
a9167bd9d5 Bug 1968081 - Calculate percentage basis upfront when finding intrinsic sizes of grid items r=layout-grid-reviewers,dholbert
Differential Revision: https://phabricator.services.mozilla.com/D250834
2025-05-23 22:56:54 +00:00
Emily McDonough
9b27cb817b Bug 1968326 - Always initialize masonryAxisGap in nsGridContainerFrame::ReflowRowsInFragmentainer to avoid warnings with GCC r=layout-reviewers,dholbert
Differential Revision: https://phabricator.services.mozilla.com/D251043
2025-05-23 22:56:28 +00:00
Tiaan Louw
61e2c788e5 Bug 1947817 - Calculate grid item baselines from the correct under/over side. r=layout-grid-reviewers,dholbert
The side used to calculate the baseline offset should use the correct
under/over side according to the writing modes of the container and the
item.

Differential Revision: https://phabricator.services.mozilla.com/D240317
2025-05-21 21:07:22 +00:00
Tiaan Louw
0710a5fce2 Bug 1908320 - Orthogonal items should also participate in baseline alignment r=layout-reviewers,emilio
All items in an alignment context should be checked for baseline
alignment.  Items that turn out to be orthogonal to the alignment
context should synthesize a baseline.

Differential Revision: https://phabricator.services.mozilla.com/D216793
2025-05-21 21:07:18 +00:00
Emily McDonough
918aea565d Bug 1963485 Part 2 - Rematerialize selectors for choosing tracks in grid intrinsic sizing code rather than passing the selector directly. r=layout-grid-reviewers,tlouw
This change makes most places in grid intrinsic sizing code specify operations
by sizing phase and sizing constraint, rather than using the sizing function
types directly. This should help with readability and debugging, as the
intended operation rather than the selector bits are used now.

Differential Revision: https://phabricator.services.mozilla.com/D249697
2025-05-20 22:35:11 +00:00
Emily McDonough
50e26ea3e7 Bug 1963485 Part 1 - Move selector/track size bits into a function that makes it clear which phase the selectors are for r=layout-grid-reviewers,tlouw
Differential Revision: https://phabricator.services.mozilla.com/D249695
2025-05-20 22:35:08 +00:00
Ting-Yu Lin
fd0d317872 Bug 1967360 - Improve nsGridContainerFrame::Tracks::Dump(). r=dholbert
This patch changes the following:

- Print baseline, gap, and content-box sizes in app units. If they are "unknown" or
  "unconstrained", print a string accordingly.
- Use fmt library [1] because it can print `std::string` directly.

[1] https://firefox-source-docs.mozilla.org/xpcom/fmt-in-gecko.html

Differential Revision: https://phabricator.services.mozilla.com/D250104
2025-05-20 21:50:56 +00:00
Ting-Yu Lin
a3b707e1ce Bug 1965081 - Ensure CachedBAxisMeasurement is valid before accessing it. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D248534
2025-05-10 02:09:32 +00:00
Emily McDonough
f4e3c4ba50 Bug 1964510 - Remove unnecessary pre-checks from ShouldApplyAutoMinSize r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D247832
2025-05-08 01:20:53 +00:00
Emily McDonough
481f0b2e8a Bug 1951828 - Change grid intrinsic sizing functions to use TrackSizingStep and TrackSizingPhase as regular parameters instead of template parameters r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D247845
2025-05-07 01:50:19 +00:00
Ting-Yu Lin
46b8529e34 Bug 1944423 Part 1 - Resolve grid row sizes when computing grid container's intrinsic inline-size. r=dholbert
The idea behind this patch is to allow grid items with percent-valued
block-sizes to resolve against definite grid rows and then transfer that
resolved block-size as their inline contribution to the grid container's
intrinsic inline-size.

Differential Revision: https://phabricator.services.mozilla.com/D246466
2025-05-05 11:54:41 +00:00
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