Commit Graph

660 Commits

Author SHA1 Message Date
Daniel Holbert
10b7012c65 Bug 1870949 part 1: When synthesizing a baseline from a grid item, don't bother with central baselines if we're getting a measurement in the item's inline axis. r=TYLin
This patch only changes behavior in cases where the following conditions hold:
(a) We're asking an item for its baseline, and the item has a writing-mode
     that uses a central baseline (e.g. vertical-rl).
(b) We're asking for a baseline **in that item's inline axis**, i.e. a
    measurement in the y-axis.

In this situation, the item really only wants to use central baselines for its
own block-axis baselines, not for its inline-axis baselines.  So let's not
bother trying to generate central baselines in its inline axis.

This is documented to some extent in
https://www.w3.org/TR/css-writing-modes-4/#text-baselines, which describes
central baselines as being between the 'over' and 'under' edges (aka
'line-over' and 'line-under'), i.e. a measurement in the element's own block
axis.

This makes us pass WPT subgrid-stretch.html, because it happens to depend on
the baseline alignment of horizontal-writing-mode grids that have
vertical-writing-mode subgrids.

Differential Revision: https://phabricator.services.mozilla.com/D196932
2023-12-20 23:26:01 +00:00
Ting-Yu Lin
eba54dc01f Bug 1870983 - Remove child pos workaround when XUL is a grid item. r=dholbert
This patch reverts this patch
https://hg.mozilla.org/mozilla-central/rev/2d39de2be1ae (bug 1593060).

Note: some of the code (around `::MeasuringReflow`) has been reverted in
https://hg.mozilla.org/mozilla-central/rev/cd9c32d42c40 (Bug 1600542).

Differential Revision: https://phabricator.services.mozilla.com/D196939
2023-12-20 22:28:42 +00:00
Daniel Holbert
b3d670a2b4 Bug 1800563: Inhibit out-of-flow grid containers from being subgrids. r=TYLin
This patch does two things:

1. Extends ShouldInhibitSubgridDueToIFC to return true for out-of-flow frames,
   per spec (which makes us pass the WPT independent-formatting-context.html).
   Spec reference: https://drafts.csswg.org/css-grid-2/#subgrid-listing
   "...if the grid container [the one that's styled to be a subgrid] is
   otherwise forced to establish an independent formatting context (for
   example, due to layout containment or absolute positioning), the used value
   is the initial value, 'none', and the grid container is not a subgrid."

2. Removes some newly-dead code from ComputeSelfSubgridMasonryBits that
   provided some special handling for out-of-flow subgrids (which are now
   impossible to create, as of this change); and also remove
   WillHaveAtLeastOneTrackInAxis() whose last caller I'm removing here.

3. Renames a variable 'gridParent' to 'parentGrid' to match the spec
   terminology at https://drafts.csswg.org/css-grid-2/#parent-grid

Differential Revision: https://phabricator.services.mozilla.com/D193731
2023-12-20 02:03:04 +00:00
Daniel Holbert
e4d5b42e07 Bug 1870906 part 2: Split out a helper function to determine whether we should inhibit a grid from being a subgrid. r=TYLin
This patch doesn't change behavior; it's just refactoring out some
existing checks into a helper function.

Differential Revision: https://phabricator.services.mozilla.com/D196901
2023-12-20 02:03:03 +00:00
Daniel Holbert
d99a0d5104 Bug 1870906 part 1: Simplify ComputeSelfSubgridMasonryBits() to return early once we know we can't be a subgrid. r=TYLin,emilio
This patch doesn't change behavior.

The code that follows the new early-return is all in the service of making
changes to the return value `bits`; and all of the modifications are guarded
directly or indirectly by checks for `!inhibitSubgrid`.  So we might as well
just morph this `inhibitSubgrid` variable into an early-return and skip all of
that code entirely when it evaluates to true.

Differential Revision: https://phabricator.services.mozilla.com/D196900
2023-12-20 02:03:03 +00:00
Daniel Holbert
2c7fc34d08 Bug 1870911: Don't inadvertently clobber masonry bits just because a nested grid can't be a subgrid. r=TYLin
This ComputeSelfSubgridMasonryBits() function has some logic to determine
whether a grid is using subgrid layout (i.e. participating in a parent grid)
and also whether it's using masonry layout at all.

There's one early-return for a case where we can't be a subgrid, which
inadvertently also disregards the masonry state that we've set. It looks like
this was an oversight, since in fact we can still use masonry regardless of
whether we're allowed to be a subgrid.

Differential Revision: https://phabricator.services.mozilla.com/D196891
2023-12-19 22:38:25 +00:00
Ting-Yu Lin
1be0a3ff3c Bug 1841296 - Implement stretch for subgrids in the subgridded axis. r=dholbert
This implements https://drafts.csswg.org/css-grid/#subgrid-box-alignment

Differential Revision: https://phabricator.services.mozilla.com/D196706
2023-12-18 22:58:07 +00:00
Ting-Yu Lin
e13978de72 Bug 1350037 Part 2 - Add a helper to compute stretch for grid items. r=dholbert
The helper will be used in the next part, too.

This doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D196704
2023-12-18 22:12:43 +00:00
Ting-Yu Lin
1aad741930 Bug 1350037 Part 1 - Rename two variables storing grid item's axes. r=dholbert
Rename to make them clearer that they stores child's axes in grid container's
writing-mode. Without the "InWM" suffix, it's a bit confusing why not just use
`eLogicalAxisInline`.

Differential Revision: https://phabricator.services.mozilla.com/D196703
2023-12-18 22:12:42 +00:00
Emilio Cobos Álvarez
12644edacf Bug 1869580 - Move devtools info bit to specific frame classes. r=tnikkel,layout-reviewers
No need for them to live in nsIFrame.

Differential Revision: https://phabricator.services.mozilla.com/D196198
2023-12-13 12:48:35 +00:00
Tiaan Louw
18eb9a2e47 Bug 1609403 - Grid items with align/justify-self should participate in baseline alginment r=emilio,layout-reviewers
When a grid item is set to align itself to the baseline (first or last)
then it should participate in baseline alignment if the item's size is
not dependent on the size of the track and vice versa.

Also added a test to check for last baseline alignment in addition to
first baseline alignment on empty blocks.

Differential Revision: https://phabricator.services.mozilla.com/D157345
2023-12-07 11:49:40 +00:00
Natalia Csoregi
03a2df09bc Backed out changeset 3d0a5f6fd8b4 (bug 1609403) for causing failures on grid-self-baseline-changes-grid-area-size-002.html. CLOSED TREE 2023-12-05 01:37:51 +02:00
Tiaan Louw
9947e39000 Bug 1609403 - Grid items with align/justify-self should participate in baseline alginment r=emilio,layout-reviewers
When a grid item is set to align itself to the baseline (first or last)
then it should participate in baseline alignment if the item's size is
not dependent on the size of the track and vice versa.

Also added a test to check for last baseline alignment in addition to
first baseline alignment on empty blocks.

Differential Revision: https://phabricator.services.mozilla.com/D157345
2023-12-04 22:10:24 +00:00
Natalia Csoregi
d7b0119d62 Backed out changeset 02d58cff5d1a (bug 1609403) for causing failures on grid-self-baseline-changes-grid-area-size-002.html. CLOSED TREE 2023-12-04 23:03:05 +02:00
Tiaan Louw
02a6fa34ba Bug 1609403 - Grid items with align/justify-self should participate in baseline alginment r=emilio,layout-reviewers
When a grid item is set to align itself to the baseline (first or last)
then it should participate in baseline alignment if the item's size is
not dependent on the size of the track and vice versa.

Also added a test to check for last baseline alignment in addition to
first baseline alignment on empty blocks.

Differential Revision: https://phabricator.services.mozilla.com/D157345
2023-12-04 14:55:19 +00:00
Noemi Erli
11820ee6fc Backed out changeset 5dfc5b6d7ba4 (bug 1609403) for causing failures in grid-self-baseline-changes-grid-area-size-002.html CLOSED TREE 2023-12-04 15:02:53 +02:00
Boris Chiou
c7d7b2e722 Bug 1867789 - Use the reference to a pointer to avoid recreating a new ImplicitNamedAreas in each iteration. r=emilio
I forgot to use a reference when doing the refactoring. We should use a
reference to a pointer because we rely on the information from the previous
iteration, in the private function, `AddImplicitNamedAreasInternal()`.

Note: I don't have a test for this. This bug is from a real website:
https://www.oddbird.net/tools/, and it's not easy to reduce the
testcase, so we may need a QA to verify this by the real website.

Differential Revision: https://phabricator.services.mozilla.com/D195388
2023-12-04 12:08:47 +00:00
Tiaan Louw
5a7098b893 Bug 1609403 - Grid items with align/justify-self should participate in baseline alginment r=emilio,layout-reviewers
When a grid item is set to align itself to the baseline (first or last)
then it should participate in baseline alignment if the item's size is
not dependent on the size of the track and vice versa.

Also added a test to check for last baseline alignment in addition to
first baseline alignment on empty blocks.

Differential Revision: https://phabricator.services.mozilla.com/D157345
2023-12-04 08:32:32 +00:00
Emilio Cobos Álvarez
c27730d3df Bug 1364813 - Remove IsFrameOfType, use non-virtual checks. r=jwatt
Extend the per-frame-class bit we have to devirtualize IsLeaf to also
devirtualize IsFrameOfType. That is, move this data to FrameClasses.py.

This was done by going through all the frame classes, trying to preserve
behavior.

The only quirky thing is that I had to add two more trivial frame
classes, `nsAudioFrame` for audio elements, and
`nsFloatingFirstLetterFrame`. That's because these frame classes were
returning different answers at runtime, but they do this only on
conditions that trigger frame reconstruction (floating, and being an
audio element, respectively).

Differential Revision: https://phabricator.services.mozilla.com/D194703
2023-11-26 22:17:28 +00:00
Boris Chiou
377eb95e00 Bug 1841330 - Use CustomIdent for GridLine. r=emilio
So we can avoid calling clone() in to_css().

Differential Revision: https://phabricator.services.mozilla.com/D193838
2023-11-16 23:01:37 +00:00
Boris Chiou
71d80063af Bug 1583429 - Keep repeat() information for specified/computed value for subgrid. r=layout-reviewers,firefox-style-system-reviewers,emilio
We introduce a different rust type for `<line-name-list>` for subgrid,
which keeps `repeat()` information at computed time. At this moment,
we don't expand `repeat()`.

Also, we precompute the possible expanded list length, so we can expand
`repeat(auto-fill)` in a single iteration in nsGridContainerFrame. If we
don't have this precompution, we have to go through `<line-name-list>`
first to know how many items we have after expanding `repeat(Integer)`.

Differential Revision: https://phabricator.services.mozilla.com/D192876
2023-11-08 21:44:36 +00:00
Gregory Pappas
42ab0c6786 Bug 1851094 - Remove layout.css.grid-item-baxis-measurement.enabled pref r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D187250
2023-09-19 22:06:03 +00:00
Ting-Yu Lin
d3b5b1e844 Bug 1853090 - Add ContentISize() and ContentBSize() convenience methods to nsIFrame. r=layout-reviewers,jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D188157
2023-09-14 18:13:17 +00:00
Emilio Cobos Álvarez
0b366c953e Bug 1851787 - Plumb a DestroyContext through all functions that can destroy frames. r=dholbert
This prevents anonymous content getting destroyed at weird times
during frame destruction.

Differential Revision: https://phabricator.services.mozilla.com/D187693
2023-09-08 15:11:17 +00:00
Narcis Beleuzu
c10ba98491 Backed out changeset 69bb261fbdce (bug 1851094) for bustages on nsGridContainerFrame.cpp . CLOSED TREE 2023-09-02 05:57:52 +03:00
Gregory Pappas
b11d9e7ad2 Bug 1851094 - Remove layout.css.grid-item-baxis-measurement.enabled pref r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D187250
2023-09-02 02:19:04 +00:00
David Shin
cd09d0a351 Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-17 12:56:54 +00:00
Sandor Molnar
3faee50252 Backed out 3 changesets (bug 1809568) for causing build bustages in layout/generic/nsLineLayout.cpp CLOSED TREE
Backed out changeset 6c5bbcbafce9 (bug 1809568)
Backed out changeset b518133a5c34 (bug 1809568)
Backed out changeset 2407088e9b49 (bug 1809568)
2023-05-17 01:34:42 +03:00
David Shin
33ec2490df Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-16 20:48:18 +00:00
Sandor Molnar
146a43a1bc Backed out 3 changesets (bug 1809568) for causing node devtools failures in devtools/client/debugger/src/components/test/QuickOpenModal.spec.js CLOSED TREE
Backed out changeset 56ce741da8f5 (bug 1809568)
Backed out changeset 5a91ce4870e4 (bug 1809568)
Backed out changeset cc00422f050a (bug 1809568)
2023-05-16 22:22:31 +03:00
David Shin
970986fac9 Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-16 19:02:11 +00:00
Cristian Tuns
aa3e994c56 Backed out 3 changesets (bug 1809568) for causing build bustages on nsLineLayout.cpp CLOSED TREE
Backed out changeset e862b1560caa (bug 1809568)
Backed out changeset 0a20b91de67b (bug 1809568)
Backed out changeset 6060fc7d49d4 (bug 1809568)
2023-05-15 13:03:03 -04:00
David Shin
6f868ef403 Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-15 14:34:26 +00:00
Cosmin Sabou
44343a085c Backed out 3 changesets (bug 1809568) for causing build bustages on nsBlockFrame.cpp. CLOSED TREE
Backed out changeset eaa7fe280317 (bug 1809568)
Backed out changeset ab0f2bcb2d9b (bug 1809568)
Backed out changeset a481bf06452b (bug 1809568)
2023-05-01 21:42:14 +03:00
David Shin
65b6b0c69f Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-01 17:04:27 +00:00
Iulian Moraru
babc5faa23 Backed out 3 changesets (bug 1809568) for causing build bustages on nsLineLayout.cpp. CLOSED TREE
Backed out changeset 573dc0bd9554 (bug 1809568)
Backed out changeset b8401947aea0 (bug 1809568)
Backed out changeset 7ecabe895121 (bug 1809568)
2023-05-01 17:59:21 +03:00
David Shin
9e2157483e Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-01 13:44:43 +00:00
Andi-Bogdan Postelnicu
7ca4abd93a Bug 1277372 - Move away from "mozilla/TypeTraits.h". r=geckoview-reviewers,sergesanspaille,m_kato
std::is_pod has been deprecated in C++20, see https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0767r1.html.
This is equivalent with std::is_trivial_v && std::is_standard_layout.

Differential Revision: https://phabricator.services.mozilla.com/D174128
2023-04-17 13:50:11 +00:00
Emilio Cobos Álvarez
09eaf2464a Bug 1824957 - Remove a bunch of now completely dead XUL layout code. r=layout-reviewers,desktop-theme-reviewers,devtools-reviewers,dao,TYLin
And some related tests.

A bunch of -moz-box* properties are web exposed, so I'll file a
follow-up for hiding them.

Differential Revision: https://phabricator.services.mozilla.com/D173819
2023-03-29 21:23:55 +00:00
Emilio Cobos Álvarez
4d140ec032 Bug 1600542 - Remove no longer used nsGridContainerFrame special-case. r=layout-reviewers,tlouw
We have no more grid items being XUL boxes.

Differential Revision: https://phabricator.services.mozilla.com/D172873
2023-03-20 16:42:52 +00:00
Ting-Yu Lin
c62e69811c Bug 1819211 - Export Baseline.h under mozilla. r=emilio
It is because `Baseline` is a utility class under `namespace mozilla`.

Also change the include guard to match the coding style.
https://firefox-source-docs.mozilla.org/code-quality/coding-style/coding_style_cpp.html#header-files

Differential Revision: https://phabricator.services.mozilla.com/D171162
2023-03-01 03:50:03 +00:00
David Shin
2b6c1b9ffd Bug 1811311 - Part 3: Refactor GetNaturalBaselineBOffset to return Maybe<nscoord>. r=layout-reviewers,emilio
Changed from returning `bool` & taking an out parameter.

Differential Revision: https://phabricator.services.mozilla.com/D168998
2023-02-23 14:53:27 +00:00
David Shin
33761711d3 Bug 1811311 - Part 2: Extract SynthesizeBaselineBOffsetFrom* out of nsIFrame. r=emilio
These functions work fine as static functions, and `nsIFrame` is pretty overloaded.

Differential Revision: https://phabricator.services.mozilla.com/D167991
2023-02-23 14:53:27 +00:00
David Shin
ea283b961b Bug 1811311 - Part 1: Unite baseline-related functions in nsIFrame into one. r=emilio
Before, there existed 3 virtual functions that calculated baselines:

- `GetLogicalBaseline`
- `GetVerticalAlignBaseline`
- `GetNaturalBaselineBOffset`

Each of them had slightly different behaviours:

- `GetLogicalBaseline` would synthesize a baseline if there is no baseline.
  Others would simply return `false`.
- `GetNaturalBaselineBOffset` requires the caller to pick which of first/last
  baseline to calculate. Others pick on on their own.
- `GetNaturalBaselineBOffset`'s result can be either offset from border box
   start/end edge, depending on the caller-supplied baseline. Others always
   return offset from border box start edge.

Now:

- `GetNaturalBaselineBOffset` is the sole virtual function.
- `GetLogicalBaseline` exists to support its use, with 2 virtual helper functions:
  - `SynthesizeFallbackBaseline` to generate a baseline for elements that
    doesn't have one.
  - `GetBaselineSharingGroup` to preserve the default baseline picking behaviour.

Differential Revision: https://phabricator.services.mozilla.com/D167990
2023-02-23 14:53:26 +00:00
Brad Werth
68434f47f6 Bug 1815140 Part 1: Make Grid dom object an idempotent property of its frame. r=emilio
This ensures that repeated calls to Element::GetGridFragments will return
an array of idempotent Grid objects for each fragment. This is
accomplished by making the Grid object hold a WeakFrame back to its
originating frame, and updating a property on construction and
destruction.

Differential Revision: https://phabricator.services.mozilla.com/D169724
2023-02-23 01:07:34 +00:00
Cosmin Sabou
16ef9eba19 Backed out 3 changesets (bug 1815140) for causing wrapper related dt failures. CLOSED TREE
Backed out changeset 0380de95a301 (bug 1815140)
Backed out changeset dd7288d15da0 (bug 1815140)
Backed out changeset 7f50487ea10c (bug 1815140)
2023-02-21 07:15:20 +02:00
Brad Werth
792fde2cfe Bug 1815140 Part 1: Make Grid dom object an idempotent property of its frame. r=emilio
This ensures that repeated calls to Element::GetGridFragments will return
an array of idempotent Grid objects for each fragment. This is
accomplished by making the Grid object hold a WeakFrame back to its
originating frame, and updating a property on construction and
destruction.

Differential Revision: https://phabricator.services.mozilla.com/D169724
2023-02-21 04:06:37 +00:00
Ting-Yu Lin
1d2813cb13 Bug 1637091 - Always reflow a flex item in a fragmented context. r=dholbert
nsColumnSetFrame can reflow its last column in an unconstrained available
block-size to measure the total block-size of the content [1]. This patch adds a
helper method in ReflowInput for that.

For flex items in a fragmented context, we *cannot* skip its final reflow
because fragmentation might grow its block-size if there's any force break in
it (bug 1663079), or if it has repeated table header/footer (bug 1744363).

This patch doesn't change observable behavior for now. Before this patch, we may
skip an item's final reflow if it is in a flex container's continuation that is
in the last column with an unconstrained available block-size. As of this patch,
the item will be reflowed. This is a partial step towards fixing the above bugs
where the item's block-size may grow.

[1] https://searchfox.org/mozilla-central/rev/daf613efc5c358f3a94961d73b90472c00703838/layout/generic/nsColumnSetFrame.cpp#614-621

Differential Revision: https://phabricator.services.mozilla.com/D167207
2023-02-06 22:04:21 +00:00
Ben Freist
35bf9129f3 Bug 1805097 - [refactor] Migrate NS_STYLE_MASONRY_* defines r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D164422
2023-01-03 12:14:56 +00:00
Martin Robinson
62878408df Bug 1803377 - Rename the values of the IntrinsicDirty enum r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D163607
2022-12-02 12:27:31 +00:00