Commit Graph

925 Commits

Author SHA1 Message Date
Ting-Yu Lin
0a5e62e315 Bug 1909761 Part 4 - Construct a percentage basis when computing children's intrinsic inline size contributions. r=dholbert
A percentage basis is needed to resolve percentage block size when computing
children's intrinsic inline size contributions. This is necessary for a child or
descendants with a preferred aspect-ratio so that the block size can transfer
through the aspect-ratio to become an intrinsic inline size.

The change in `nsFlexContainerFrame::ComputeIntrinsicISize()` is necessary to
keep us passing
`testing/web-platform/tests/css/css-flexbox/image-nested-within-definite-column-flexbox.html`.

The change in `nsPlaceholderFrame::AddFloatToIntrinsicISizeData()` is necessary
to keep us passing
`testing/web-platform/tests/css/css-sizing/intrinsic-percent-replaced-dynamic-010.html`.

`GetISizeInfo()` in BasicTableLayoutStrategy.cpp is modified to pass table cell
frame's bsize as percentage basis. Otherwise,
`layout/reftests/bugs/522632-1.html` fails. This is our current behavior, but it
is bug 1461852.

Differential Revision: https://phabricator.services.mozilla.com/D219523
2024-09-03 04:25:42 +00:00
Ting-Yu Lin
6af05a0977 Bug 1909761 Part 2 - Create a helper struct IntrinsicSizeInput to aggregate needed data when computing intrinsic inline size. r=dholbert
This patch changes the signature to `GetMinISize()`, `GetPrefISize()`,
`IntrinsicISize` by adding a helper struct as a preparation. Then we can just
add more data such as a percentage basis to the struct without altering the
signature in the future.

When passing `IntrinsicSizeInput` struct down to another helper method, we
generally just pass the original one if the method is computing the intrinsic
size of our own or our anonymous children. If the method is computing our
children's intrinsic contribution, we'll need to create a brand new
`IntrinsicSizeInput` for our children.

Differential Revision: https://phabricator.services.mozilla.com/D219521
2024-09-03 04:25:41 +00:00
Butkovits Atila
4d06404349 Backed out 6 changesets (bug 1909761) for causing failures at test_contextmenu_rtl.xhtml. CLOSED TREE
Backed out changeset 1e9f47784a54 (bug 1909761)
Backed out changeset d2dcf159185b (bug 1909761)
Backed out changeset 3f48c106bff9 (bug 1909761)
Backed out changeset 38d1e5eda09d (bug 1909761)
Backed out changeset 8de556490289 (bug 1909761)
Backed out changeset 4e7f22f43bb4 (bug 1909761)
2024-08-28 10:44:09 +03:00
Ting-Yu Lin
3ac03672b0 Bug 1909761 Part 4 - Construct a percentage basis when computing children's intrinsic inline size contributions. r=dholbert
A percentage basis is needed to resolve percentage block size when computing
children's intrinsic inline size contributions. This is necessary for a child or
descendants with a preferred aspect-ratio so that the block size can transfer
through the aspect-ratio to become an intrinsic inline size.

The change in `nsFlexContainerFrame::ComputeIntrinsicISize()` is necessary to
keep us passing
`testing/web-platform/tests/css/css-flexbox/image-nested-within-definite-column-flexbox.html`.

The change in `nsPlaceholderFrame::AddFloatToIntrinsicISizeData()` is necessary
to keep us passing
`testing/web-platform/tests/css/css-sizing/intrinsic-percent-replaced-dynamic-010.html`.

`GetISizeInfo()` in BasicTableLayoutStrategy.cpp is modified to pass table cell
frame's bsize as percentage basis. Otherwise,
`layout/reftests/bugs/522632-1.html` fails. This is our current behavior, but it
is bug 1461852.

Differential Revision: https://phabricator.services.mozilla.com/D219523
2024-08-28 06:18:45 +00:00
Ting-Yu Lin
f0ff97db90 Bug 1909761 Part 2 - Create a helper struct IntrinsicSizeInput to aggregate needed data when computing intrinsic inline size. r=dholbert
This patch changes the signature to `GetMinISize()`, `GetPrefISize()`,
`IntrinsicISize` by adding a helper struct as a preparation. Then we can just
add more data such as a percentage basis to the struct without altering the
signature in the future.

When passing `IntrinsicSizeInput` struct down to another helper method, we
generally just pass the original one if the method is computing the intrinsic
size of our own or our anonymous children. If the method is computing our
children's intrinsic contribution, we'll need to create a brand new
`IntrinsicSizeInput` for our children.

Differential Revision: https://phabricator.services.mozilla.com/D219521
2024-08-28 06:18:44 +00:00
Ting-Yu Lin
a024d0e616 Bug 1914661 Part 3 - Add ReflowInput::SetBResizeForPercentages(). r=dholbert
We have `SetBResize()`, so it would be useful to add a method to set
`mIsBResizeForPercentages` flag for consistency.

Differential Revision: https://phabricator.services.mozilla.com/D220023
2024-08-23 19:52:50 +00:00
Ting-Yu Lin
cac8ac479b Bug 1914661 Part 1 - Rename NS_CSS_MINMAX, and move it into mozilla namespace. r=dholbert
`NS_CSS_MINMAX` looks like a macro, but it is a function. Let's name it like a
function.

Differential Revision: https://phabricator.services.mozilla.com/D220021
2024-08-23 19:52:49 +00:00
Emilio Cobos Álvarez
a012cd6770 Bug 1906475 - Improve scroll{Width,Height} implementation for overflow: visible frames. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D218782
2024-08-15 15:02:00 +00:00
Ting-Yu Lin
2969a5e0cb Bug 1909995 Part 2 - Add IntrinsicISize() as a helper to implement GetMinISize() and GetPrefISize(). r=layout-reviewers,emilio
Most frame types have identical or very similar implementation for GetMinISize()
and GetPrefISize(), and many of them already have `IntrinsicISize()` to unify
the implementation. This patch introduces nsIFrame::IntrinsicISize() so that
derived classes only need to override one method.

`nsBlockFrame`, `ColumnSetWrapperFrame`, and `nsColumnSetFrame` are the only
three classes where their `GetMinISize()` and `GetPrefISize()` have significant
differences. Therefore, we rename `GetMinISize()` and `GetPrefISize()` to
`MinISize()` and `PrefISize`, respectively, and use them as helpers to implement
their `IntrinsicISize()`.

This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D217790
2024-07-26 20:54:56 +00:00
Ting-Yu Lin
38f5786fbe Bug 1906792 Part 3 - Move ContainIntrinsicISize() calls into IntrinsicISize() helper for flex and grid container. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D216000
2024-07-09 18:49:33 +00:00
Brad Werth
f67e91d1f1 Bug 1901233: Make CreateFlexLineAndFlexItemInfo account for subtrees with only anonymous boxes. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D213086
2024-06-10 23:17:43 +00:00
Ting-Yu Lin
5aff62d126 Bug 1610044 - Fill the hole in FlexLine by reordering members. r=dholbert
On Android, there is a 4 byte hole between `mTotalItemMBP` and
`mTotalOuterHypotheticalMainSize`. See
https://searchfox.org/mozilla-central/query/default?q=field-layout%3A%27nsFlexContainerFrame%3A%3AFlexLine%27

By moving `mTotalOuterHypotheticalMainSize` to the beginning of the class, we
can make `FlexLine` more compact on Android. The size remains the same on other
platforms, with or without this change.

Differential Revision: https://phabricator.services.mozilla.com/D212866
2024-06-06 23:05:19 +00:00
Ting-Yu Lin
9f961819ce Bug 1900522 Part 2 - Swap the arguments of StyleRect::Get() that gets T from logical side. r=layout-reviewers,emilio
This patch move `WritingMode` to the second argument, for the consistency with
the design of its own APIs like `StyleRect::Start(LogicalAxis, WritingMode)`,
and logical classes such as `LogicalMargin::Side(LogicalSide, WritingMode)`.

Differential Revision: https://phabricator.services.mozilla.com/D212505
2024-06-04 17:54:48 +00:00
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