Commit Graph
912 Commits
Author SHA1 Message Date
Ting-Yu Lin 9fdd977b52 Bug 1890238 Part 2 - Honor forced break values on flex items. r=dholbert
This patch stops the frame constructor from inserting nsPageBreakFrame as a flex
item, because flex container does not rely on it to do forced page break at all,
and nsPageBreakFrame can produce wrong layout result.

The majority of this patch is to honor forced break values on flex items in
nsFlexContainerFrame::ReflowChildren(). In this patch, we don't handle avoid
break values such as `break-before:avoid` and `break-after:avoid` since they are
not handled in other frame types yet.

WPTs are added in later parts.

Differential Revision: https://phabricator.services.mozilla.com/D207910
2024-05-03 20:43:35 +00:00
Ting-Yu Lin 66ffa0dacc Bug 1890238 Part 1 - Rename childReflowStatus to childStatus. r=dholbert
Flex container is the only frame type in layout using `childReflowStatus` when
naming the `nsReflowStatus` variable for child. Drop "Reflow" for brevity and
for the consistency with `childrenStatus` in `ReflowChildren()`.

Differential Revision: https://phabricator.services.mozilla.com/D207909
2024-05-03 20:43:35 +00:00
Ting-Yu Lin b54a0edb4a Bug 1748891 Part 3 - Exclude flex item's margin-box at sticky position in flex container's scrollable overflow area. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D208173
2024-04-25 23:32:47 +00:00
Ting-Yu Lin b98dad1f92 Bug 1892307 Part 3 - Remove AllLogicalSides(). r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D207907
2024-04-19 22:16:04 +00:00
Ting-Yu Lin cd60dc9642 Bug 1891866 - Clear mIsTopOfPage for flex items if their positions are not adjacent with container's content-box block-start edge. r=dholbert
This fixed some WPT with `break-inside:avoid` on flex items.

Differential Revision: https://phabricator.services.mozilla.com/D207640
2024-04-17 06:34:04 +00:00
Ting-Yu Lin ecc8d53a54 Bug 1891173 - Convert PhysicalAxis to an enum class. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D207332
2024-04-15 22:17:25 +00:00
Cjm531 abac0e51ec Bug 1885695 - Change LogicalEdge to an enum class and change its variants names. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D206265
2024-04-15 20:19:47 +00:00
Ting-Yu Lin 56c570e16f Bug 1889047 - Revise flex container log. r=dholbert
* Add `FLEX_ITEM_LOG` so that the log print starts from "Flex item". Visually,
  this better groups the operations of the same flex item together than those
  "for flex item" at the end of the sentence.
* Make `FLEX_LOGV` indent with two spaces, and change all the `FLEX_LOG` logs
  with indentation to `FLEX_LOGV`.

Differential Revision: https://phabricator.services.mozilla.com/D206319
2024-04-03 07:24:24 +00:00
Ting-Yu Lin 8a77ebbb16 Bug 1888535 Part 5 - Remove DISPLAY_REFLOW. r=layout-reviewers,emilio
It is used in `Reflow()` implementations.

Differential Revision: https://phabricator.services.mozilla.com/D206317
2024-04-02 19:03:05 +00:00
Ting-Yu Lin 319fc12b73 Bug 1888535 Part 4 - Remove DISPLAY_PREF_INLINE_SIZE and DISPLAY_MIN_INLINE_SIZE. r=layout-reviewers,emilio
The two macros are used in `GetPrefISize()` and `GetMinISize()` implementations.
After removing them, we could further simplify some implementations because we
don't need a `result` variable in many cases.

This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D206316
2024-04-02 19:03:04 +00:00
sid 568f27d168 Bug 1825386 - Converted LogicalAxis to enum class and type casted where necessary. r=TYLin
LogicalAxis is one of the Logical* enums. Converting it from enum to
enum class increases type safety. To run with the pre-existing code,
type casting was added when needed. Comments have been edited where
needed.

Differential Revision: https://phabricator.services.mozilla.com/D206108
2024-03-30 16:20:37 +00:00
Ting-Yu Lin a299dff332 Bug 1888702 Part 1 - Remove unused #includes and forward declarations for flex container frame. r=layout-reviewers,tnikkel
Remove the forward declarations because we use `mozilla::` prefix in the header.

Differential Revision: https://phabricator.services.mozilla.com/D206149
2024-03-29 23:16:46 +00:00
flowejam 9d4992fcc6 Bug 1885693: Converted LogicalSide to an enum class, and renamed variables accordingly. r=TYLin
Values were static_casted where required. Some functions in WritingModes.h were
rewritten such that bitwise operations aren't being used. Added static_casts to
avoid (debug) build errors from debugging printfs in layout/tables/nsCellMap.cpp.

Differential Revision: https://phabricator.services.mozilla.com/D205510
2024-03-26 17:55:16 +00:00
Ting-Yu Lin 367f149611 Bug 1874336 Part 1 - Use ApplyMinMaxBSize() and ApplyMinMaxISize() more. r=layout-reviewers,jfkthame
Also, add a note to `NS_CSS_MINMAX` to point to these two methods.

Differential Revision: https://phabricator.services.mozilla.com/D198351
2024-01-12 21:25:39 +00:00
Emilio Cobos Álvarez e39a7a3109 Bug 1871412 - Fix scroll container checks for automatic minimum size and grid stretching checks. r=dholbert
The spec says scroll container, so overflow: visible and clip shouldn't
be different.

Note that the spec here is pending some edits from
https://github.com/w3c/csswg-drafts/issues/7714 tho.

Differential Revision: https://phabricator.services.mozilla.com/D197052
2023-12-26 20:49:16 +00:00
Ting-Yu Lin 15e3e10812 Bug 1870103 - Disallow fragmentation-imposed block-size growth for replaced elements. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D196811
2023-12-19 16:33:58 +00:00
Ting-Yu Lin 9cf9e5292b Bug 1869722 Part 2 - Remove the special case adding ShrinkWrap flag for flex items. r=dholbert
We can pass `ComputeSizeFlag::ShrinkWrap` flag when creating the `ReflowInput`
for a flex item. It is maybe more verbose, but less of the magic flex logic
hidden in `ReflowInput`.

This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D196258
2023-12-13 22:50:36 +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
Ting-Yu Lin 709aec26cb Bug 1744363 Part 4 - Allow flex item's block-size to grow in fragmented context. r=dholbert
A flex item's block-size may grow as a result of fragmentation. If we detect its
block-size is allowed to grow, then we use 'auto' block-size in the
`StyleSizeOverrides` when creating a ReflowInput, and treat its original
block-size as the min-size (as a lower bound).

Differential Revision: https://phabricator.services.mozilla.com/D188532
2023-12-06 05:16:51 +00:00
Ting-Yu Lin a0d4cc2a3a Bug 1744363 Part 3 - Rename a local variable in nsFlexContainerFrame::ReflowChildren(). r=dholbert
Rename itemBSize to borderBoxBSize to make it clearer because we are going to
add another variable in Part 4 capturing content block-size. Drop "item" for
brevity.

Differential Revision: https://phabricator.services.mozilla.com/D188531
2023-12-06 05:16:50 +00:00
Ting-Yu Lin 4e9ac3d42b Bug 1744363 Part 2 - Make nsFlexContainerFrame::ReflowChildren() return nsReflowStatus of children. r=dholbert
This is a preparation for Part 4. We need to tell apart the children reflow
status between incomplete and overflow-incomplete.

Differential Revision: https://phabricator.services.mozilla.com/D188530
2023-12-06 05:16:50 +00:00
Ting-Yu Lin 0ee4b7ee2f Bug 1744363 Part 1 - Make nsSplittableFrame a query frame target, and add a CalcAndCacheConsumedBSize wrapper. r=dholbert
This is a preparation for Part 4 since a flex container frame needs to query a
flex item continuation's consumed block-size.

Differential Revision: https://phabricator.services.mozilla.com/D188529
2023-12-06 05:16:49 +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
Ting-Yu Lin 971f71efea Bug 1854424 - Add a LogicalMargin method returning an offset to start-sides. r=layout-reviewers,jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D188847
2023-09-22 15:39:25 +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
Ting-Yu Lin 8c2b0239be Bug 1818933 - Synthesize flex item's baseline if its inline axis is the cross axis. r=dholbert
After this patch, we'll fail four tests due to reference files written in grid
layout, and we've had bug 1609403 for grid baseline alignment.

Differential Revision: https://phabricator.services.mozilla.com/D185872
2023-08-16 05:45:53 +00:00
Ting-Yu Lin 96622420cd Bug 1812485 - Fix flex container fragmentation for reversed axes. r=dholbert
When iterating flex line and flex item in ReflowChildren(), start from the
startmost line and startmost item with respect to the flex container's
writing-mode. This is equivalent to iterate the items in visual order, which is
necessary to compute the item's position correctly, because any shift to the
startmost line or startmost item can affect later ones.

Also, change a condition in `Reflow()` to `aReflowInput.IsInFragmentedContext()`
so that the necessary data can be updated when the flex container fragment is
reflowed in the last column. Otherwise, there will be "unexpected max block
size" assertions [1] while running `layout/generic/crashtests/1666592.html`.

[1] https://searchfox.org/mozilla-central/rev/e9b8c73771d0038214c69f17c5934ba8ae049799/layout/generic/nsFloatManager.cpp#111

Differential Revision: https://phabricator.services.mozilla.com/D183193
2023-07-26 17:23:58 +00:00
Ting-Yu Lin 76e8509330 Bug 1841173 - Refactor flex container baseline computation. r=dholbert
This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D182584
2023-07-01 02:37:55 +00:00
Ting-Yu Lin 1397ac9fe1 Bug 1840796 - Consider last baseline in the startmost line when computing flex container first baseline. r=dholbert
Likewise, we should also consider first baseline in the endmost line when
computing flex container last baseline.

Fixed the XXX comment by using logical coordinates. This is necessary to pass
flex-align-baseline-flex-004.html because it tests a vertical-rl flex container.

Differential Revision: https://phabricator.services.mozilla.com/D182432
2023-06-29 22:25:47 +00:00
Ting-Yu Lin 4618d27e88 Bug 1839944 - Rename two cached baseline variables in nsFlexContainerFrame. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D181826
2023-06-23 17:40:42 +00:00
Daniel Holbert df02097140 Bug 1834663 part 3: Make FlexItems join the opposite BaselineSharingGroup on their FlexLine, if their block-flow direction is opposite to the flex container's corresponding LogicalAxis. r=TYLin
The idea behind this change is for flex items with swapped block-flow direction
to end up in swapped baseline-sharing groups on the flex container's FlexLine.

The outcome of this is that all of the baseline-aligned flex items that are
using a baseline on their left edge will be aligned together (e.g. in the
"first" group), and all of the flex items with a baseline on their right edge
will be aligned together (e.g. in the "last" group), even if they may have
varying block-flow directions (vertical-lr vs. rl) and varying `align-self`
values.

This is rooted in the idea of baseline alignment preferences being "compatible"
as defined here:
https://drafts.csswg.org/css-align-3/#compatible-baseline-alignment-preferences

This makes us start passing a bunch of WPT tests; this patch removes the
corresponding .ini files for those tests that are now passing.

Differential Revision: https://phabricator.services.mozilla.com/D181824
2023-06-23 16:20:38 +00:00
Daniel Holbert 3c372422d0 Bug 1834663 part 2: Give the FlexItem class a method to return the BaselineSharingGroup that it participates in. r=TYLin
This patch doesn't affect behavior; it's just a refactoring to prepare for the
next patch in this series.

(As of this patch, the BaselineSharingGroup is always the same as the
'align-self' baseline selection, but the next patch will change that.)

Differential Revision: https://phabricator.services.mozilla.com/D181823
2023-06-23 16:20:38 +00:00
Ting-Yu Lin 049dbbaf30 Bug 1792750 Part 3 - Fix flex container baselines with reverse axes. r=dholbert
This is the spec describing flex container baselines.
https://drafts.csswg.org/css-flexbox-1/#flex-baselines

* Separate the cache for last baseline in FlexItem. This is needed beacuse we set
  an item's first baseline via `SetAscent()` after reflowing it. Any query to last
  baseline via `ResolvedAscent(false)` will wrongly return the first baseline.

* We used to compute flex container baseline from the first item in
  ReflowChildren(). Now we consolidate all the logic computing flex container
  baseline in PopulateReflowOutput().

Differential Revision: https://phabricator.services.mozilla.com/D181604
2023-06-23 00:39:46 +00:00
Ting-Yu Lin 6eea105417 Bug 1792750 Part 2 - Pass FlexLayoutResult into PopulateReflowOutput(). r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D181603
2023-06-23 00:39:46 +00:00
Ting-Yu Lin ddd8993e20 Bug 1792750 Part 1 - Remove an obsolete comment for FlexLine::LastBaselineOffset(). r=dholbert
We've removed the ability to reverse flex container's axes internally in
bug 1639053.

Differential Revision: https://phabricator.services.mozilla.com/D181602
2023-06-23 00:39:46 +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
Ting-Yu Lin e8552970b1 Bug 1827582 - Fix flex container's reflow status when unbreakable flex items consume all content block-size in current fragment. r=dholbert
The bug occurs in `PopulateReflowOutput()` when we change the reflow status of
an auto-height flex container to "complete" because unbreakable tall flex items
have consumed all the theoretical/unfragmented content block-size. Later in
`PopulateReflowOutput()`, we'll change the reflow status [1] to "overflow
incomplete," which cause the next-in-flow to become an overflow container.

It is possible that the container's block-size will grow due to pushed items.
However, `nsSplittableFrame::CalcAndCacheConsumedBSize()` [2] doesn't consider
the overflow container's block-size, so we never correctly consume the extra
block-size growth in later fragments due to pushed items. We end up creating
infinite columns.

[1] https://searchfox.org/mozilla-central/rev/54c533e94ae786056a43231f230c7d9b0773cb80/layout/generic/nsFlexContainerFrame.cpp#5623-5626
[2] https://searchfox.org/mozilla-central/rev/54c533e94ae786056a43231f230c7d9b0773cb80/layout/generic/nsSplittableFrame.cpp#201-204

Differential Revision: https://phabricator.services.mozilla.com/D175543
2023-04-19 21:53:24 +00:00
Ting-Yu Lin 5d55a4b794 Bug 1827131 - Soften the assertion in nsFlexContainerFrame::ReflowChildren(). r=dholbert
This is derived from the original revision that gets R+ in bug 1826635.
https://phabricator.services.mozilla.com/D174993?id=702649

Differential Revision: https://phabricator.services.mozilla.com/D175024
2023-04-10 23:42:22 +00:00
Ting-Yu Lin e1ae628b96 Bug 1826635 - Don't push flex item if available block-size is unconstrained. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D174993
2023-04-09 07:54:02 +00:00
Ting-Yu Lin ccced8c673 Bug 1826635 - Fix a comment in ReflowChildren(). r=dholbert
SumOfChildrenBlockSizeProperty() was moved into PerFragmentFlexData in
Bug 1804997 Part 4 [1], and later it was renamed in Bug 1743890 Part 4 [2].

[1] https://hg.mozilla.org/mozilla-central/rev/0404d371c42f3e73b56678fe52a89f4f788ea9b5
[2] https://hg.mozilla.org/mozilla-central/rev/6064a73fc99f012a7400393bdc2ade89fbdf30f8

Differential Revision: https://phabricator.services.mozilla.com/D174992
2023-04-09 07:54:01 +00:00