934 Commits
Author SHA1 Message Date
Emilio Cobos Álvarez d3ec7a6a5f Bug 2045329 - Fix subgrid border/margin/padding computation for scrollers. r=layout-reviewers,dholbert
It used to be accounted for via the padding: inherit that was removed in
the regressing bug, but that was a bit action at a distance and was not
tested at all it seems...

Simplify the code, since this used to deal with buttons as well but
button anonymous boxes were removed a while ago.

Differential Revision: https://phabricator.services.mozilla.com/D305028
2026-06-08 22:43:31 +00:00
Emily McDonough e2a7836c9f Bug 2045144 - Remove constructor for ComputedGridLineInfo. r=layout-reviewers,dholbert
This lets callers get move semantics for any/all of the fields, as desired.

Differential Revision: https://phabricator.services.mozilla.com/D304903
2026-06-04 22:08:16 +00:00
Ting-Yu Lin 1b99f231da Bug 2041516 Part 1 - Assert fresh reflow status at the beginning of AbsoluteContainingBlock::Reflow(). r=layout-reviewers,emilio
This patch enforces the invariant for `AbsoluteContainingBlock::Reflow()` that
most of the `Reflow()` functions already have.

Differential Revision: https://phabricator.services.mozilla.com/D302429
2026-05-26 19:07:08 +00:00
Jan Varga e746e7c4eb Bug 2038239 - Introduce a dedicated type for <flex> values; r=emilio,firefox-style-system-reviewers,layout-reviewers
Introduce a dedicated type for representing <flex> values and use it instead
of relying on `#[css(dimension)]`.

This removes the last use of `#[css(dimension)]` and avoids adding special
dimension handling to the `ToTyped` derive. Supporting that annotation in
`ToTyped` would add unnecessary complexity for what is now a single use case.

Having an explicit <flex> value type makes it straightforward to add Typed OM
reification support for <flex> values in a follow-up patch.

Differential Revision: https://phabricator.services.mozilla.com/D300350
2026-05-19 11:07:15 +00:00
Emilio Cobos Álvarez 69a6da6b2f Bug 2038512 - Make line clamping happen at used value time. r=jwatt
With bug 2035572 and related this clamping becomes harder to make at
parse time.

Move the clamping at used value time.

Differential Revision: https://phabricator.services.mozilla.com/D299586
2026-05-11 02:10:12 +00:00
Daniel Holbert 8ce7475f6e Bug 2036989: Use GetOrCreateDeletableProperty to reduce manual 'new' invocations in layout code. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D298481
2026-05-06 22:29:33 +00:00
Atila Butkovits e611117715 Revert "Bug 2036989: Use GetOrCreateDeletableProperty to reduce manual 'new' invocations in layout code. r=layout-reviewers,emilio" on suspicion of causing assertion failure in browser/components/sidebar/tests/browser/browser_customize_sidebar.js.
This reverts commit 300ed0d12a.
2026-05-05 13:52:41 +00:00
Daniel Holbert 300ed0d12a Bug 2036989: Use GetOrCreateDeletableProperty to reduce manual 'new' invocations in layout code. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D298481
2026-05-05 07:58:49 +00:00
Eugeniusz Lewandowski fc8097fcc3 Bug 1650944 - Remove ReflowInput.h include from nsIFrame.h r=firefox-style-system-reviewers,layout-reviewers,emilio
Removed the Reflow Input in nsIFrame. Added includes for ReflowInput as
necessary in cpp files. Also Forward Declared nsLineLayout in 3 header
files.

Differential Revision: https://phabricator.services.mozilla.com/D298203
2026-05-04 12:06:23 +00:00
Cristian Tuns bf9631318b Revert "Bug 2017527 - Remove mCanBreakAtStart from grid fragmentainer. r=TYLin,layout-reviewers"
This reverts commit a5c2c9c018.
2026-04-27 23:44:09 +00:00
Hiroyuki Ikezoe a5c2c9c018 Bug 2017527 - Remove mCanBreakAtStart from grid fragmentainer. r=TYLin,layout-reviewers
Grid containers are not block containers, so there is never a Class C
break opportunity between a grid container and its children. Remove
mCanBreakAtStart and simplify the logic that depended on it.

Reftest changes:
- grid-fragmentation-006 and grid-fragmentation-020: With mCanBreakAtStart
  removed, the first grid row is always treated as being at the top of its
  fragment (isRowTopOfPage = true). The reference files are updated to
  reflect that the grid now stays in the first column rather than being
  pushed to the next column.
- grid-fragmentation-023 and grid-fragmentation-028: align-content:normal
  is added to bottom-fragment reference elements to correctly position grid
  items at the start of those fragments. The original references used
  align-content:space-evenly inherited from the .grid class, which placed
  items at an incorrect offset.

Differential Revision: https://phabricator.services.mozilla.com/D286199
2026-04-25 09:47:37 +00:00
Ting-Yu Lin 2f6171db5c Bug 2030432 - Fix abspos painting in wrong column when its containing block has transform. r=layout-reviewers,dshin
When a transformed absolute containing block fragments across multi-column,
abspos children could paint in the wrong column. This happened because the
abspos display item was built when its placeholder was encountered during
display list traversal, and the placeholder could end up in a different column
than where the abspos should paint.

Extend `DisplayPushedAbsoluteFrames` (now renamed to
`DisplayAbsoluteFramesNotBuiltByPlaceholder`) to also directly build abspos
frames whose placeholder lived in a different continuation subtree. Skip
building those abspos frames when they are later traversed via their
placeholders.

Differential Revision: https://phabricator.services.mozilla.com/D294312
2026-04-15 23:27:08 +00:00
agoloman 83610050c8 Revert "Bug 2030432 - Fix abspos painting in wrong column when its containing block has transform. r=layout-reviewers,dshin" for causing failures @anchor-position-multicol-fixed-001.html.
This reverts commit d7c27ff2a1.
2026-04-15 21:00:00 +00:00
Ting-Yu Lin d7c27ff2a1 Bug 2030432 - Fix abspos painting in wrong column when its containing block has transform. r=layout-reviewers,dshin
When a transformed absolute containing block fragments across multi-column,
abspos children could paint in the wrong column. This happened because the
abspos display item was built when its placeholder was encountered during
display list traversal, and the placeholder could end up in a different column
than where the abspos should paint.

Extend `DisplayPushedAbsoluteFrames` (now renamed to
`DisplayAbsoluteFramesNotBuiltByPlaceholder`) to also directly build abspos
frames whose placeholder lived in a different continuation subtree. Skip
building those abspos frames when they are later traversed via their
placeholders.

Differential Revision: https://phabricator.services.mozilla.com/D294312
2026-04-15 20:04:19 +00:00
serge-sans-paille eccc9787f4 Bug 2029001 - Remove or guard inclusion of fmt/format.h when possible r=emilio,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D291866
2026-04-04 10:59:59 +00:00
Emilio Cobos Álvarez bfa96865f3 Bug 2029039 - Add a use counter for cases where the change initial value of grid-auto-flow would change. r=fantasai
Differential Revision: https://phabricator.services.mozilla.com/D291924
2026-04-03 07:45:07 +00:00
serge-sans-paille f81328e365 Bug 2023519 - Make our codebase modernize-use-equals-default + modernize-use-equals-delete -safe wrt. clang-tidy r=sylvestre,necko-reviewers,media-playback-reviewers,profiler-reviewers,dom-storage-reviewers,layout-reviewers,dom-worker-reviewers,valentin,jesup,padenot,edenchuang,emilio
The changeset has been generated automatically through:

    ./mach static-analysis check --output ./clang-tidy-bugprone.json --format json --fix

followed by manual adjustment when needed or when the auto-fixer bailed out.

This paves the way for Bug 2023527

Differential Revision: https://phabricator.services.mozilla.com/D287941
2026-03-22 08:35:47 +00:00
Alexandru Marc 04e5f74151 Revert "Bug 2023519 - Make our codebase modernize-use-equals-default + modernize-use-equals-delete -safe wrt. clang-tidy r=sylvestre,necko-reviewers,media-playback-reviewers,profiler-reviewers,dom-storage-reviewers,layout-reviewers,dom-worker-reviewers,valentin,jesup,padenot,edenchuang,emilio"
This reverts commit a64dec2665.
2026-03-19 17:29:58 +00:00
serge-sans-paille a64dec2665 Bug 2023519 - Make our codebase modernize-use-equals-default + modernize-use-equals-delete -safe wrt. clang-tidy r=sylvestre,necko-reviewers,media-playback-reviewers,profiler-reviewers,dom-storage-reviewers,layout-reviewers,dom-worker-reviewers,valentin,jesup,padenot,edenchuang,emilio
The changeset has been generated automatically through:

    ./mach static-analysis check --output ./clang-tidy-bugprone.json --format json --fix

followed by manual adjustment when needed or when the auto-fixer bailed out.

This paves the way for Bug 2023527

Differential Revision: https://phabricator.services.mozilla.com/D287941
2026-03-18 17:25:01 +00:00
Sylvestre Ledru 55481ac4b5 Bug 2023419 - Remove Emacs/Vim modelines from layout/ r=emilio,firefox-style-system-reviewers,layout-reviewers
replaced by .editorconfig

Differential Revision: https://phabricator.services.mozilla.com/D287852
2026-03-17 12:05:43 +00:00
Emilio Cobos Álvarez 6f65f203f8 Bug 2015898 - Remove ChildListID::Fixed. r=dshin,TYLin,layout-reviewers
We already rely on one frame having at most one
absolute list, so there's no point in this distinction.

In the future, with position-visibility, we might want
to make fixed and abspos containing block effectively the same.

But one step at a time.

Differential Revision: https://phabricator.services.mozilla.com/D282681
2026-02-11 01:08:27 +00:00
Emilio Cobos Álvarez 30b7a3d89a Bug 2014922 - Untangle pseudo-element and anon box definitions. r=firefox-style-system-reviewers,xpcom-reviewers,layout-reviewers,dshin,nika
I looked at this because in bug 2014331 I need to mark more pseudos as
element-backed, and it's kinda silly the state our setup is in right
now.

This is all a somewhat historical mess, because in the old style system
pseudo-elements were just atoms, and we had that different types of atom
setup. The source of truth for these right now lives in a header macro
file, which isn't very flexible.

But now we have PseudoStyleType which represents both pseudos and anon
boxes, and is similar to the rust side PseudoElement enum.

Plus, the ::-moz-tree pseudo-elements are defined as anon boxes which
doesn't make any sense, so move them to pseudo-elements while at it.

Unify this in a similar way we treat CSS properties: Source of truth is
in pseudo_elements.toml / anon_boxes.toml, and we generate Rust and C++
as needed. This allows removing the nsStaticAtom subclass thing from
XPCOM, too.

This avoids some nasty duplication around which pseudos are pref-gated
and what not as well.

Differential Revision: https://phabricator.services.mozilla.com/D282076
2026-02-06 07:39:54 +00:00
Norisz Fay 27f4694604 Revert "Bug 2014922 - Untangle pseudo-element and anon box definitions. r=firefox-style-system-reviewers,xpcom-reviewers,layout-reviewers,dshin,nika" for causing bustage @ ElementAnimationData.h
This reverts commit c70290c619.
2026-02-06 05:34:42 +00:00
Emilio Cobos Álvarez c70290c619 Bug 2014922 - Untangle pseudo-element and anon box definitions. r=firefox-style-system-reviewers,xpcom-reviewers,layout-reviewers,dshin,nika
I looked at this because in bug 2014331 I need to mark more pseudos as
element-backed, and it's kinda silly the state our setup is in right
now.

This is all a somewhat historical mess, because in the old style system
pseudo-elements were just atoms, and we had that different types of atom
setup. The source of truth for these right now lives in a header macro
file, which isn't very flexible.

But now we have PseudoStyleType which represents both pseudos and anon
boxes, and is similar to the rust side PseudoElement enum.

Plus, the ::-moz-tree pseudo-elements are defined as anon boxes which
doesn't make any sense, so move them to pseudo-elements while at it.

Unify this in a similar way we treat CSS properties: Source of truth is
in pseudo_elements.toml / anon_boxes.toml, and we generate Rust and C++
as needed. This allows removing the nsStaticAtom subclass thing from
XPCOM, too.

This avoids some nasty duplication around which pseudos are pref-gated
and what not as well.

Differential Revision: https://phabricator.services.mozilla.com/D282076
2026-02-06 03:42:45 +00:00
Emilio Cobos Álvarez f1dea2d65d Bug 2013141 - Remove custom_consts specialness from CSS keywords. r=firefox-style-system-reviewers,layout-reviewers,dshin
Just name the things like in CSS.

Differential Revision: https://phabricator.services.mozilla.com/D281001
2026-01-30 21:12:51 +00:00
David Shin 9462427f28 Bug 2013139: Paint pushed absolute frames and after painting children. r=emilio,layout-reviewers
See discussion in
https://phabricator.services.mozilla.com/D272401#inline-1485354

We seem to rely on the timing of overflow containers display items for e.g.
Pagination.

DisplayList will be sorted by z-index, but it's a stable sort that relies on
items being added in document order.

`out-of-flow-in-multicolumn-paint-order-003.html` fails due to us not
fragmenting grid items needs fragmentation.

Differential Revision: https://phabricator.services.mozilla.com/D281028
2026-01-30 14:02:16 +00:00
Emilio Cobos Álvarez 077d88e977 Bug 2011213 - Remove FMT_STRING() usage. r=padenot
Should not be needed now that we build with C++20.

Differential Revision: https://phabricator.services.mozilla.com/D279521
2026-01-19 15:12:33 +00:00
Jonathan Kew 6f2ae8ac3d Bug 1866930 - Swap logical axes when inheriting line names in an orthogonal subgrid. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D279143
2026-01-15 15:01:01 +00:00
Sandor Molnar d839523e03 Revert "Bug 1995348 - Implement the "grid-lanes" value for the "display" property r=layout-reviewers,dholbert" for causing assertion failures @ nsCSSFrameConstructor.cpp
This reverts commit 74e86f72e2.
2026-01-02 15:22:28 +00:00
Tiaan Louw 74e86f72e2 Bug 1995348 - Implement the "grid-lanes" value for the "display" property r=layout-reviewers,dholbert
Use the "display: grid-lanes" value to conform to current usage in web
platform tests.

See: https://drafts.csswg.org/css-grid-3/#masonry-model

Differential Revision: https://phabricator.services.mozilla.com/D273845
2026-01-02 14:20:35 +00:00
Ting-Yu Lin fa7b99c25b Bug 2007602 Part 4 - Fix preparing abspos children for grid container that is a first-in-flow. r=layout-reviewers,emilio
Combining with the patches in bug 1994346, this fixes a crash when running
`testing/web-platform/tests/css/css-break/grid/grid-item-008.html` on CI with
`layout.abspos.fragmentainer-aware-positioning.enabled = true`.

Differential Revision: https://phabricator.services.mozilla.com/D277496
2026-01-01 00:21:58 +00:00
Ting-Yu Lin 9aa23feec4 Bug 2007058 Part 2 - Paint pushed abspos frames with NS_FRAME_IS_PUSHED_OUT_OF_FLOW bit in DisplayPushedAbsoluteFrames(). r=layout-reviewers,dholbert
Mark abspos next-in-flows with the `NS_FRAME_IS_PUSHED_OUT_OF_FLOW` bit, and
adjust the display item generation code accordingly.

In Bug 1994346, pushed abspos first-in-flow will get the bit as well.

Differential Revision: https://phabricator.services.mozilla.com/D277138
2025-12-19 21:05:37 +00:00
Lando 1c0f0168d4 Bug 2004596: apply code formatting via Lando
# ignore-this-changeset
2025-12-19 00:04:25 +00:00
David Shin e68d92a91a Bug 2004596: Move grid absolute reflow after grid area is added to overflow. r=layout-reviewers,layout-anchor-positioning-reviewers,emilio
Adjusted ordering:

1. In-flow reflow
2. Overflow adjustment using grid-area + grid item margin rects from step 1
3. Abspos reflow, using overflow area from step 2 as scrollable containing
   block if the abspos element in question has a default anchor.

Differential Revision: https://phabricator.services.mozilla.com/D277051
2025-12-19 00:04:07 +00:00
Emilio Cobos Álvarez 45879990e9 Bug 1725177 - Make ::backdrop a real generated content pseudo-element. r=layout-reviewers,firefox-style-system-reviewers,dshin
This allows animating ::backdrop and addresses long-standing animation
issues.

Differential Revision: https://phabricator.services.mozilla.com/D276755
2025-12-17 22:11:20 +00:00
Emilio Cobos Álvarez 36a152949e Bug 1924786 - Make position-area and default-anchor adjustments take priority over CSS grid CB. r=layout-anchor-positioning-reviewers,layout-reviewers,dshin
As per https://drafts.csswg.org/css-position/#original-cb they should
happen later. In general, multiple of these adjustments should be rarer
and browsers aren't particularly consistent. It's also unclear to me how
it affects the scrollable containing block stuff, I filed bug 2004596 to
sort that out.

Give a reasonable CB (the grid container's padding rect) down from grid
layout now that we might not use the actual grid CB.

Remove a check for fallbacks that isn't needed since part 1 of
bug 1991929.

Differential Revision: https://phabricator.services.mozilla.com/D275368
2025-12-08 05:55:45 +00:00
Norisz Fay e64ec53679 Revert "Bug 1924786 - Make position-area and default-anchor adjustments take priority over CSS grid CB. r=layout-anchor-positioning-reviewers,layout-reviewers,dshin" for causing wpt failures on align-self-default-overflow-htb-ltr-htb.html
This reverts commit bc04f15c3a.
2025-12-08 01:21:02 +00:00
Emilio Cobos Álvarez bc04f15c3a Bug 1924786 - Make position-area and default-anchor adjustments take priority over CSS grid CB. r=layout-anchor-positioning-reviewers,layout-reviewers,dshin
As per https://drafts.csswg.org/css-position/#original-cb they should
happen later. In general, multiple of these adjustments should be rarer
and browsers aren't particularly consistent. It's also unclear to me how
it affects the scrollable containing block stuff, I filed bug 2004596 to
sort that out.

Give a reasonable CB (the grid container's padding rect) down from grid
layout now that we might not use the actual grid CB.

Remove a check for fallbacks that isn't needed since part 1 of
bug 1991929.

Differential Revision: https://phabricator.services.mozilla.com/D275368
2025-12-07 18:22:42 +00:00
Jonathan Kew 1267c6b0ea Bug 2003765 - Use C++20's 'default' to implement simple comparison operators in /layout/. r=layout-reviewers,firefox-style-system-reviewers,emilio
Just cleans up the code a bit; should not change any behavior.

Differential Revision: https://phabricator.services.mozilla.com/D274907
2025-12-04 01:25:04 +00:00
Ting-Yu Lin b5aa6faa00 Bug 2001781 - Return nullptr from GetAbsoluteContainingBlock() when a frame is not an absolute container. r=dholbert,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D273941
2025-11-25 13:02:21 +00:00
Ting-Yu Lin 80e7aa39a2 Bug 1994083 - Generate display items for frames in absolute child list. r=dholbert,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D272401
2025-11-24 20:48:15 +00:00
Ting-Yu Lin 1b8e2204f5 Bug 1994083 - Allow AbsoluteContainingBlock to reflow all abspos continuations. r=dholbert
This patch consists of several parts:

- Introduce `PushedAbsolute` frame list (i.e. `mPushedAbsoluteFrames`) in
  AbsoluteContainingBlock. This list is a temporary list used during reflow,
  to store abspos frames that need to be reflowed by the delegating frame's
  next-in-flow.

- For an absolute containing block frame, ensure its continuations also have
  absolute containing block.

- Ensure that the position of abspos continuation is correct by adjusting
  border, available block-size, etc. in
  `AbsoluteContainingBlock::ReflowAbsoluteFrame()`.

- Cache `layout.abspos.fragmentainer-aware-positioning.enabled` pref at the time
  when `nsPresContext` is initialized such that the pref value is stable across
  the lifetime of `nsPresContext`. This is to ensure the frame tree structure
  hygiene.

Differential Revision: https://phabricator.services.mozilla.com/D272400
2025-11-24 20:48:12 +00:00
Cristina Horotan 8317428fcd Revert "Bug 1994083 - Add WPTs for abspos fragmentation in vertical-rl writing-mode. r=dholbert" for causing Wr failures nsFrameList::ContinueRemoveFrame related
This reverts commit 0bb89a9e15.

Revert "Bug 1994083 - Adjust existing WPT expectations. r=dholbert"

This reverts commit a716c30e8f.

Revert "Bug 1994083 - Generate display items for frames in absolute child list. r=dholbert,layout-reviewers"

This reverts commit 1da35cc35d.

Revert "Bug 1994083 - Allow AbsoluteContainingBlock to reflow all abspos continuations. r=dholbert,layout-reviewers"

This reverts commit 643eec9921.
2025-11-23 05:31:49 +00:00
Ting-Yu Lin 1da35cc35d Bug 1994083 - Generate display items for frames in absolute child list. r=dholbert,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D272401
2025-11-22 23:34:19 +00:00
Ting-Yu Lin 643eec9921 Bug 1994083 - Allow AbsoluteContainingBlock to reflow all abspos continuations. r=dholbert,layout-reviewers
This patch consists of several parts:

- Introduce `PushedAbsolute` frame list (i.e. `mPushedAbsoluteFrames`) in
  AbsoluteContainingBlock. This list is a temporary list used during reflow,
  to store abspos frames that need to be reflowed by the delegating frame's
  next-in-flow.

- For an absolute containing block frame, ensure its continuations also have
  absolute containing block.

- Ensure that the position of abspos continuation is correct by adjusting
  border, available block-size, etc. in
  `AbsoluteContainingBlock::ReflowAbsoluteFrame()`.

- The change in `nsPresContext` is to force reconstruct frame tree when flipping
  `layout.abspos.fragmentainer-aware-positioning.enabled` pref, to ensure frame
  tree structure hygiene.

Differential Revision: https://phabricator.services.mozilla.com/D272400
2025-11-22 23:34:15 +00:00
Ting-Yu Lin aef5585414 Bug 2001247 - Reduce indent level for the code that reflows abspos children in grid container. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D272398
2025-11-20 03:46:40 +00:00
Ting-Yu Lin a08fe7ba21 Bug 2000488 - Use nsStylePosition::UsedSelfAlignment() to simplify code. r=layout-reviewers,jfkthame
Note: `justif-self` and `align-self` operates on the alignment container's axis.
See https://drafts.csswg.org/css-align-3/#justify-self-property and
https://drafts.csswg.org/css-align-3/#align-self-property

Differential Revision: https://phabricator.services.mozilla.com/D272825
2025-11-19 05:23:14 +00:00
Ting-Yu Lin 62ad52e725 Bug 2000488 - Add a helper method to convert LogicalAxis from one writing mode to another. r=layout-reviewers,jfkthame
Converting a logical axis from one writing mode to another is a common operation
in layout. This helper improves readability.

This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D272824
2025-11-19 05:23:12 +00:00
Ting-Yu Lin 379011e679 Bug 2000759 - Add two convenience methods IsColMasonry() and IsRowMasonry(). r=jfkthame,layout-reviewers
We have `IsColSubgrid()` and `IsRowSubgrid()`. Masonry layout should have
similar convenience helpers.

Move `IsMasonry(LogicalAxis)` from `nsIFrame` into `nsGridContainerFrame` for
two reasons:

1. There are no external callers, and having it in grid container frame removes
   the need to assert that the caller is a grid container.
2. `IsColSubgrid()` and `IsRowSubgrid()` depend on it.

Differential Revision: https://phabricator.services.mozilla.com/D272987
2025-11-18 20:17:06 +00:00
Ting-Yu Lin 997c4612a9 Bug 2000759 - Add IsMasonry overload that take a WritingMode parameter. r=jfkthame,layout-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D272986
2025-11-18 20:17:04 +00:00