Commit Graph

208 Commits

Author SHA1 Message Date
Jonathan Kew
5a7b4f6387 Bug 1961849 - Remove physical accessors for the ReflowInput resize flags. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D246276
2025-04-22 16:04:43 +00:00
Jonathan Kew
183c59ae36 Bug 1958022 - For cells that are orthogonal to the table structure, do a final reflow after the cell size is known, to properly align content. r=dshin
We can't get text-align right during the initial table reflow because the
inline-size within which the cell content is to be aligned is not yet known
(it'll come from the block-size we compute for the parent row).

So to deal with this, we record during tableRowFrame reflow whether any
cells with orthogonal writing mode were present; and if so, at the end of
the row reflow, we make another pass over the orthogonal cells and reflow
them to properly align their content within the computed cell size.

Differential Revision: https://phabricator.services.mozilla.com/D245615
2025-04-16 18:40:46 +00:00
Jonathan Kew
958866a401 Bug 1949064 - Improve setup of AvailableISize for orthogonal flows in ReflowInput. r=layout-reviewers,emilio
The old "orthogonal limit" in ReflowInput was a rather ad hoc mechanism created
during the early implementation of writing modes, to avoid reflowing orthogonal
flows with unconstrained inline size. The spec has since been clarified to describe
the expected behavior in more detail, and we can dispense with the orthogonal-limit
concept and instead implement the constraints called for in the spec.

With this, we pass all the css-writing-modes/available-size-* tests (as well as
fixing a couple of other testcases that are dependent on this behavior).

Differential Revision: https://phabricator.services.mozilla.com/D241117
2025-03-12 11:17:29 +00:00
David Shin
8224327ca7 Bug 1943591: Remove unused ReflowInput functions. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D235438
2025-01-24 15:46:09 +00:00
Daniel Holbert
d153465dd3 Bug 1933408 part 1: Implement layout support for 'stretch' as a block-axis size (with '-webkit-fill-available' as an alias). r=TYLin
Note that both keywords are disabled in the CSS parser for now, behind
these about:config prefs:
layout.css.stretch-size-keyword.enabled
layout.css.webkit-fill-available.enabled

Prior to this patch, we handled both keywords as pure aliases for
'-moz-available' (which has the correct 'stretch' behavior in the inline axis
but which just behaves like the initial value in the block axis).

This patch changes that so that 'stretch' and '-webkit-fill-available' will now
actually do the right thing in the block axis (if they're enabled at all, via
their aforementioned about:config prefs).

The relevant spec text here is:
https://drafts.csswg.org/css-sizing-4/#valdef-width-stretch
https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing

Differential Revision: https://phabricator.services.mozilla.com/D217688
2024-12-14 06:35:06 +00:00
Jonathan Kew
0813b3e111 Bug 1887465 - Use the containing block's writing mode to resolve logical values for CSS float and clear properties. r=layout-reviewers,emilio
And don't resolve them prematurely; the computed value should remain
logical, and only be mapped to physical sides at use time.

Differential Revision: https://phabricator.services.mozilla.com/D229998
2024-11-25 22:58:46 +00:00
Alexandru Marc
ed1511635d Backed out 2 changesets (bug 1887465) for causing build bustages @ WritingModes.h . CLOSED TREE
Backed out changeset 5203c09eceb4 (bug 1887465)
Backed out changeset 0507fcccf575 (bug 1887465)
2024-11-25 18:47:23 +02:00
Jonathan Kew
64fa9b6bb6 Bug 1887465 - Use the containing block's writing mode to resolve logical values for CSS float and clear properties. r=layout-reviewers,emilio
And don't resolve them prematurely; the computed value should remain
logical, and only be mapped to physical sides at use time.

Differential Revision: https://phabricator.services.mozilla.com/D229998
2024-11-25 14:02:26 +00:00
longsonr
a1e0dc11f4 Bug 1931617 Part 2 - Remove mentions of Algorithm.h where it's no longer used r=emilio,application-update-reviewers,bytesized
Differential Revision: https://phabricator.services.mozilla.com/D229205
2024-11-19 11:25:39 +00:00
Adi
96cdd300d5 Backed out 2 changesets (bug 1931617) for causing for causing build bustages @sVersionComparator.cpp. CLOSED TREE
Backed out changeset 7376753fb852 (bug 1931617)
Backed out changeset 4cd29d936b4b (bug 1931617)
2024-11-19 11:11:50 +02:00
longsonr
2431f88b47 Bug 1931617 Part 2 - Remove mentions of Algorithm.h where it's no longer used r=emilio,application-update-reviewers,bytesized
Differential Revision: https://phabricator.services.mozilla.com/D229205
2024-11-19 08:26:38 +00:00
Ting-Yu Lin
5e0b7df8fd Bug 1742042 Part 3 - Move StyleSizeOverrides from ReflowInput.h to LayoutStructs.h. r=dholbert
We are going to use `StyleSizeOverrides` in nsLayoutUtils.h in Part 4 that
requires a full definition of `StyleSizeOverrides`. but we don't want to include
the entire ReflowInput.h in nsLayoutUtils.h that can add unnecessary header
dependency.

We could also move it into LayoutConstants.h that has been included by
nsLayoutUtils.h, but the header is a home for layout constants. Therefore, I
create a new header for layout helper classes and structs.

Differential Revision: https://phabricator.services.mozilla.com/D222049
2024-09-13 06:52:13 +00:00
Ting-Yu Lin
b826f2c1c4 Bug 1909761 Part 6 - Delete or improve obsolete comments in layout. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D219525
2024-09-03 04:25:43 +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
73a6fa4c16 Bug 1909761 Part 6 - Delete or improve obsolete comments in layout. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D219525
2024-08-28 06:18:45 +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
dd07eb1c10 Bug 1914661 Part 2 - Remove redundant mozilla:: qualifiers in ReflowInput. r=dholbert
`ReflowInput` is already living in `mozilla` namespace.

Differential Revision: https://phabricator.services.mozilla.com/D220022
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
Ting-Yu Lin
b2ef0ad2ac Bug 1901652 Part 1 - Clean up for CalculateHypotheticalPosition. r=dholbert
Remove unused `nsPresContext` and `LayoutFrameType` parameters in
`InitAbsoluteConstraints()` and `CalculateHypotheticalPosition()` (except for
one usage in `NS_ASSERTION`).

Improve the documentation for `CalculateHypotheticalPosition()` and delete the
nearly the same documentation before its definition in ReflowInput.cpp.

In `InitAbsoluteConstraints()`, we don't need to initialize the `offsets` local
variable via `ComputedLogicalOffsets()` since this is the function computing the
offset, and we'll set the four sides of `offsets` later in the function.

Differential Revision: https://phabricator.services.mozilla.com/D213313
2024-06-18 04:43:27 +00:00
Sandor Molnar
fc33dbde1c Backed out 3 changesets (bug 1901652) for causing mochitest failures @ browser_scrollToPoint.js CLOSED TREE
Backed out changeset 24bb7e89929c (bug 1901652)
Backed out changeset 8fc6e70268be (bug 1901652)
Backed out changeset a7a4eb34e7b1 (bug 1901652)
2024-06-17 10:06:06 +03:00
Ting-Yu Lin
2c1288e5ed Bug 1901652 Part 1 - Clean up for CalculateHypotheticalPosition. r=dholbert
Remove unused `nsPresContext` and `LayoutFrameType` parameters in
`InitAbsoluteConstraints()` and `CalculateHypotheticalPosition()` (except for
one usage in `NS_ASSERTION`).

Improve the documentation for `CalculateHypotheticalPosition()` and delete the
nearly the same documentation before its definition in ReflowInput.cpp.

In `InitAbsoluteConstraints()`, we don't need to initialize the `offsets` local
variable via `ComputedLogicalOffsets()` since this is the function computing the
offset, and we'll set the four sides of `offsets` later in the function.

Differential Revision: https://phabricator.services.mozilla.com/D213313
2024-06-17 02:43:01 +00:00
Ting-Yu Lin
6549711c8d Bug 1900522 Part 6 - Remove a SizeComputationInput::ComputeISizeValue() variant. r=layout-reviewers,emilio
This removed one is just forwarding the call to nsIFrame, and used internally
within ReflowInput.

While I'm here, rename local variables `inside*` and `outside*` to make them
clearer.

Differential Revision: https://phabricator.services.mozilla.com/D212509
2024-06-04 17:54:50 +00:00
Ting-Yu Lin
664f41193d Bug 1866692 Part 2 - Remove ReplacedContainsBlock in LayoutFrameClassFlags. r=layout-reviewers,emilio
The `IsReplacedWithBlock()` method is used only in
`ShouldApplyOverflowClipping()`, which determines the overflow clip axes. Since
we've already enumerated the frame types that need overflow clipping, we can
just add more types that had `ReplacedContainsBlock` flag to the switch-cases
and remove the flag.

Differential Revision: https://phabricator.services.mozilla.com/D212199
2024-05-31 19:28:19 +00:00
Ting-Yu Lin
5cdee429ce Bug 1896516 Part 11 - Remove nsIScrollableFrame usages under layout/, widget/, and toolkit/. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D211498
2024-05-30 06:32:22 +00:00
Sebastian Hengst
bf4dfe53f8 Backed out 15 changesets (bug 1896516) for causing scrolling crashes on macOS. a=backout
Backed out changeset fd6904338812 (bug 1896516)
Backed out changeset 2977ff81a23e (bug 1896516)
Backed out changeset c8a6b0e526d6 (bug 1896516)
Backed out changeset 3c06f22da72b (bug 1896516)
Backed out changeset f63b0c4335fe (bug 1896516)
Backed out changeset 6f7ab8adfa6e (bug 1896516)
Backed out changeset 997c9249dbed (bug 1896516)
Backed out changeset c964fccd5180 (bug 1896516)
Backed out changeset 7b481b747b7a (bug 1896516)
Backed out changeset 42e1bbe0ecb6 (bug 1896516)
Backed out changeset 717dac08b607 (bug 1896516)
Backed out changeset 2f0817331dbe (bug 1896516)
Backed out changeset b765169a7a8f (bug 1896516)
Backed out changeset a2d37b98273c (bug 1896516)
Backed out changeset ea9ecb543e66 (bug 1896516)
2024-05-29 11:22:52 +02:00
Ting-Yu Lin
37e9b779f9 Bug 1896516 Part 11 - Remove nsIScrollableFrame usages under layout/, widget/, and toolkit/. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D211498
2024-05-28 04:46:20 +00:00
David Shin
e6ce1aa347 Bug 1892089: Support font-relative line-height units use in canvas via SVG filter. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D207871
2024-05-07 20:35:08 +00:00
David Shin
46a093dc96 Bug 1892089: Support font-relative line-height units in SVG. r=longsonr,emilio
Differential Revision: https://phabricator.services.mozilla.com/D207870
2024-05-07 20:35:08 +00:00
Ting-Yu Lin
125e604108 Bug 1888535 Part 2 - Remove DISPLAY_INIT_CONSTRAINTS and DISPLAY_INIT_OFFSETS. r=layout-reviewers,emilio
The two macros are only used in ReflowInput.cpp, which are to print margin,
border, padding, available sizes, and other computed sizes in ReflowInput. The
information can be replaced by adding local printf or via `rr` if there are
debug needs.

Note: `ReflowInput::DisplayInitFrameTypeEnter` and
`ReflowInput::DisplayInitFrameTypeExit` have been removed in
https://hg.mozilla.org/mozilla-central/rev/429a4d022ade

Differential Revision: https://phabricator.services.mozilla.com/D206314
2024-04-02 19:03:03 +00:00
Emilio Cobos Álvarez
f3b7608278 Bug 1740580 - Align shrink-wrap behavior of semi-replaced elements with the spec. r=dholbert,layout-reviewers
The removed reftsts test basically the opposite, and are sufficiently
covered by the WPTs that we start passing, so just remove them.

Differential Revision: https://phabricator.services.mozilla.com/D204797
2024-03-23 15:14:20 +00:00
Ting-Yu Lin
5cec51111c Bug 1877850 Part 2 - Rewrite ComputedSizeAsContainerIfConstrained() using logical coordinates, and use it in BlockReflowState. r=dholbert
This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D200238
2024-02-01 22:02:01 +00:00
Ting-Yu Lin
4f26895e18 Bug 1877850 Part 1 - Convert callers of ReflowInput physical size accessors to use logical ones. r=dholbert
ReflowInput's computed sizes and border&padding are stored in logical
coordinates, so accessing the physical version is slower [1]. This patch
converts as many callers as possible to use logical coordinates.

This patch doesn't change behavior.

[1] For example, accessing `ComputedWidth()` and `ComputedHeight()` needs two
`IsVertical()` check, but `GetPhysicalSize()` only needs one.

Differential Revision: https://phabricator.services.mozilla.com/D200237
2024-02-01 22:02:00 +00:00
Emilio Cobos Álvarez
d79ce67c15 Bug 221154 - Make overflow work on table cells. r=dholbert
Depends on D198786

Differential Revision: https://phabricator.services.mozilla.com/D197978
2024-01-23 09:45:26 +00:00
Narcis Beleuzu
600cbc7a39 Backed out 2 changesets (bug 221154) for causing crashtests. CLOSED TREE
Backed out changeset 166b593890ef (bug 221154)
Backed out changeset 274f73457318 (bug 221154)
2024-01-19 20:17:38 +02:00
Emilio Cobos Álvarez
3bab568d66 Bug 221154 - Make overflow work on table cells. r=dholbert
Depends on D198786

Differential Revision: https://phabricator.services.mozilla.com/D197978
2024-01-19 16:33:54 +00:00
Ting-Yu Lin
b91f5fbde1 Bug 1874336 Part 3 - Remove ApplyMinMaxWidth() and ApplyMinMaxHeight() in ReflowInput. r=layout-reviewers,jfkthame
The last caller of these two methods was removed in Part 2.

Differential Revision: https://phabricator.services.mozilla.com/D198353
2024-01-12 21:25:39 +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
Ting-Yu Lin
a14d059181 Bug 1867784 - Force reflow all kids in the last column balancing reflow. r=layout-reviewers,dholbert
The bug occurs because some abspos children are split, but not being reflowed
again in the last column balancing reflow where the available block-size of the
last column might be unconstrained.

This patch makes the callers utilizing `ReflowInput::ShouldReflowAllKids()`
always reflow in the last column balancing reflow to ensure the correctness of
the layout.

Note: the `mIsInLastColumnBalancingReflow` flag is inheriting from parent to
child reflow input, but it will stop at the nested `nsColumnSetFrame` because
the nested one will create its own `ReflowConfig::mIsLastBalancingReflow` and
assign that flag when creating the reflow input for the children.

Differential Revision: https://phabricator.services.mozilla.com/D195945
2023-12-10 03:16:55 +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
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
Emily McDonough
bdc0924dce Bug 1804794 - Do not allow CSS named page breaks except in specific subtrees. r=dholbert
This currently only includes block frames, grid containers, and flex
containers, and the document and pagination frames. It is possible more frames
will need to be added or more advanced checks in the future.

This adds some related tests to ignoring some subtrees, but are expected fails
until bug 1816570 is fixed.

Differential Revision: https://phabricator.services.mozilla.com/D169018
2023-02-22 23:49:51 +00:00
Butkovits Atila
b05456d143 Backed out changeset 70a0f82267f1 (bug 1804794) for causing build bustages at ReflowInput.cpp. CLOSED TREE 2023-02-22 06:48:12 +02:00
Emily McDonough
a392943602 Bug 1804794 - Do not allow CSS named page breaks except in specific subtrees. r=dholbert
This currently only includes block frames, grid containers, and flex
containers, and the document and pagination frames. It is possible more frames
will need to be added or more advanced checks in the future.

This adds some related tests to ignoring some subtrees, but are expected fails
until bug 1816570 is fixed.

Differential Revision: https://phabricator.services.mozilla.com/D169018
2023-02-22 02:29:31 +00:00
Emilio Cobos Álvarez
66ce020e08 Bug 1814626 - Expose line-height resolution to style, and use it from ToResolvedValue. r=jfkthame
For ToResolvedValue implementation purposes we wouldn't need to split
out the vertical / font / line-height arguments and we could just pass
around the ComputedStyle, but the lh unit would need that distinction,
(because computing lh on font properties should use the parent style).

Differential Revision: https://phabricator.services.mozilla.com/D168705
2023-02-14 22:36:31 +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
Ting-Yu Lin
a2a56d6bdf Bug 1804146 - Clarify why we need NS_CSS_MINMAX. r=emilio DONTBUILD
Both `std::clamp()` and `mozilla::clamped` cannot handle the case where min >
max.

Differential Revision: https://phabricator.services.mozilla.com/D163884
2022-12-06 03:08:00 +00:00
Ting-Yu Lin
7840d12cae Bug 1795196 Part 2 - Convert ComputedMin{I|B}Size() and ComputedMax{I|B}Size() that return writable references to setters. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D159353
2022-10-18 00:26:20 +00:00
Ting-Yu Lin
a86adc11f8 Bug 1795196 Part 1 - Remove ComputedISize() and ComputedBSize() that return writable references. r=emilio
Users of these two getters should use setters such as SetComputedISize() instead.

Differential Revision: https://phabricator.services.mozilla.com/D159352
2022-10-18 00:26:19 +00:00
Emilio Cobos Álvarez
6a28d88249 Bug 1793700 - Improve widget-imposed min size handling. r=TYLin,layout-reviewers,dshin
Make it work as a min-size everywhere rather than only handling it in
nsIFrame::ComputeSize.

This is more similar to what XUL code does. In particular, it makes
makes it work for elements that don't have a definite size in
ComputeSize (like flex containers).

For web-exposed widgets this only matters for <input type=color> and
<input type=range>, which are the only exposed widgets that return a
minimum size that return a minimum size. This patch makes the minimum
size honored for `<input type="color" style="height: auto">`. Add a test
for that (though we might want to change it to match other browsers).

Without this fix, min/max/close buttons on Linux are zero-height with
flex emulation, because we fail to account for their minimum
widget-imposed size.

This allows us to remove the special case in nsFlexContainerFrame too,
since that should be handled by ReflowInput correctly now.

Differential Revision: https://phabricator.services.mozilla.com/D158612
2022-10-05 19:34:03 +00:00
Emilio Cobos Álvarez
777e2aa014 Bug 1786147 - Make -webkit-line-clamp create a block container in the appropriate situations. r=dholbert
This is a hack, sorta, similar to Chromium's:

  https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/layout/layout_object.cc;l=356;drc=312b74e385e6aba98ab31fd911238c0dc16b396c

except at computed-value rather than used-value time, because it's both
simpler to reason about and prevents lying in the computed style.

This fixes the relevant test-case, and matches closer what Chromium does,
by not creating anonymous flex items for all elements inside the
line-clamp context.

The behavior change is covered by the test changes. I had to also fix a
couple pre-existing bugs that were caught by tests, now that the
line-clamped block is the -webkit-box-styled element rather than an anonymous
flex item (and thus now had padding).

Depends on D155180

Differential Revision: https://phabricator.services.mozilla.com/D155181
2022-09-07 23:57:18 +00:00