Commit Graph

2265 Commits

Author SHA1 Message Date
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
Jonathan Kew
800340ccc6 Bug 727831 - Use the line cursor to optimize nsBlockFrame::DoRemoveFrame, to avoid perf cliff when reflowing/modifying large blocks of text. r=layout-reviewers,emilio
This is basically Mats' line-cursor patch from 2012, updated to account for changes
in nsBlockFrame that have happened since then.

The example in https://bugzilla.mozilla.org/show_bug.cgi?id=1911451, for instance,
benefits hugely from this. Profile of resizing the textarea in the example there,
after pasting in the huge JS source:

Current mozilla-central: https://share.firefox.dev/3M6gUui
(truncated because I got tired of waiting for the reflow to finish)

With this patch applied: https://share.firefox.dev/46RMmpy
It's still janky, but only takes a second or so to reflow at each step.

Differential Revision: https://phabricator.services.mozilla.com/D219358
2024-08-22 12:55:40 +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
Daniel Holbert
56c38ff56f Bug 1909773 part 2: Create BehavesLikeStretchOnInlineAxis() utility-function as an abstraction for the '-moz-available' sizing behavior. r=emilio
This patch doesn't change behavior.

The '-moz-available' keyword is our closest equivalent to the CSS 'stretch'
keyword, *specifically* for the inline axis (since we currently nerf
'-moz-available' to behave like the initial value in the block axis). Hence, it
makes sense to say that the '-moz-available' keyword "Behaves Like Stretch On
Inline Axis".

By abstracting the existing behavior behind this helper-function, we can
start implementing the actual 'stretch' value in terms of this existing
behavior, in later patches.

Differential Revision: https://phabricator.services.mozilla.com/D217685
2024-07-25 18:18:23 +00:00
Ting-Yu Lin
c182ed4f84 Bug 1908826 - Modernize collapsing margin data structure. r=layout-reviewers,emilio
- Drop the "ns" prefix, and move the class into mozilla namespace.

- Remove unnecessary constructors and `operator=` because compiler can generate
  them automatically.

- Change `get` to `Get` to conform to the coding style.

- Misc cosmetic fix such as adding braces.

Differential Revision: https://phabricator.services.mozilla.com/D217056
2024-07-23 06:29:48 +00:00
Iulian Moraru
c3946b4ab0 Backed out changeset 07b27f0f7e21 (bug 1908826) for causing non unified build bustages on nsBlockReflowContext.h. CLOSED TREE 2024-07-23 04:55:23 +03:00
Ting-Yu Lin
16459adaa6 Bug 1908826 - Modernize collapsing margin data structure. r=layout-reviewers,emilio
- Drop the "ns" prefix, and move the class into mozilla namespace.

- Remove unnecessary constructors and `operator=` because compiler can generate
  them automatically.

- Change `get` to `Get` to conform to the coding style.

- Misc cosmetic fix such as adding braces.

Differential Revision: https://phabricator.services.mozilla.com/D217056
2024-07-22 21:06:54 +00:00
Ting-Yu Lin
54bbd58ae9 Bug 1906768 - Get floats list again after calling AppendPushedFloatChain(). r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D215995
2024-07-11 17:23:34 +00:00
Stanca Serban
ef51e7129d Backed out changeset 9a0e6453ea8f (bug 1906768) for causing android wpt failures. CLOSED TREE 2024-07-10 11:30:08 +03:00
Ting-Yu Lin
bb2d3e235c Bug 1906768 - Get floats list again after calling AppendPushedFloatChain(). r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D215995
2024-07-09 18:50:32 +00:00
Ting-Yu Lin
21d81e2fbe Bug 1905463 - Cap aspect-ratio's automatic minimum size by the maximum size. r=layout-reviewers,emilio
See https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum

The flex container and grid container have already considered max sizes clamping
when computing their sizes. Therefore, `flex-aspect-ratio-043.html`,
`flex-aspect-ratio-044.html`, and `grid-aspect-ratio-042.html` already pass on
the current Nightly without this patch.

- `flex-aspect-ratio-043.html` and `flex-aspect-ratio-044.html` are adapted from
  `flex-aspect-ratio-040.html` and `flex-aspect-ratio-041.html`.
- `grid-aspect-ratio-042.html` is adapted from `grid-aspect-ratio-039.html`.
- `fieldset-element-002.html` is adapted from `fieldset-element-001.html`.

Differential Revision: https://phabricator.services.mozilla.com/D215296
2024-07-01 21:26:25 +00:00
Ting-Yu Lin
9426229a09 Bug 1904409 - Call StartRemoveFrame() before calling ContinueRemoveFrame() in nsBlockFrame::RemoveFloat(). r=dholbert
After Bug 1903141 Part 3 [1], StartRemoveFrame() does not get called when there
is no float list. We need to make sure StartRemoveFrame() is called before
calling ContinueRemoveFrame().

[1] https://hg.mozilla.org/mozilla-central/rev/c2ba52894016007c3f5c4f21241f14d3cd7bd7a3

Differential Revision: https://phabricator.services.mozilla.com/D214775
2024-06-26 20:24:58 +00:00
Ting-Yu Lin
d52e3dc178 Bug 1903141 Part 3 - Store floats list in a frame property rather than in nsBlockFrame::mFloats. r=dholbert
On optimized builds for all desktop platforms, `nsBlockFrame` is 192 bytes, and
`mFloats` is 16 bytes. With this patch, we can reduce the size of `nsBlockFrame`
to 176 bytes, saving 8.33% memory on every `nsBlockFrame` and its derived
subclasses allocated.

On a real webpage like https://en.wikipedia.org/wiki/Firefox, `about:memory`
shows that we allocate 0.36 MB of `nsBlockFrame` consistently. After this patch,
we allocate 0.33 MB, saving approximately 30 KB (0.36 MB * 8.33%) of the memory.

Differential Revision: https://phabricator.services.mozilla.com/D214046
2024-06-19 21:50:41 +00:00
Ting-Yu Lin
d00d8eefb7 Bug 1903141 Part 1 - Simplify MaybeHasFloats() that checks pushed floats. r=dholbert
After Bug 1902542 Part 5 [1], the pushed floats list is deleted if it is empty.
Therefore, we can simplify `MaybeHasFloats()` as suggested in the XXX comment.

[1] https://hg.mozilla.org/mozilla-central/rev/52a9610fc9f2

Differential Revision: https://phabricator.services.mozilla.com/D214044
2024-06-19 21:50:40 +00:00
pstanciu
f3651823b9 Backed out 3 changesets (bug 1903141) for causing crashtest failures on nsSplittableFrame.cpp CLOSED TREE
Backed out changeset ccd18b9b52fc (bug 1903141)
Backed out changeset fbd60d2007b0 (bug 1903141)
Backed out changeset ce65f1574c68 (bug 1903141)
2024-06-19 03:15:25 +03:00
Ting-Yu Lin
94a9ed2943 Bug 1903141 Part 3 - Store floats list in a frame property rather than in nsBlockFrame::mFloats. r=dholbert
On optimized builds for all desktop platforms, `nsBlockFrame` is 192 bytes, and
`mFloats` is 16 bytes. With this patch, we can reduce the size of `nsBlockFrame`
to 176 bytes, saving 8.33% memory on every `nsBlockFrame` and its derived
subclasses allocated.

On a real webpage like https://en.wikipedia.org/wiki/Firefox, `about:memory`
shows that we allocate 0.36 MB of `nsBlockFrame` consistently. After this patch,
we allocate 0.33 MB, saving approximately 30 KB (0.36 MB * 8.33%) of the memory.

Differential Revision: https://phabricator.services.mozilla.com/D214046
2024-06-18 20:13:55 +00:00
Ting-Yu Lin
f8c82f76ac Bug 1903141 Part 1 - Simplify MaybeHasFloats() that checks pushed floats. r=dholbert
After Bug 1902542 Part 5 [1], the pushed floats list is deleted if it is empty.
Therefore, we can simplify `MaybeHasFloats()` as suggested in the XXX comment.

[1] https://hg.mozilla.org/mozilla-central/rev/52a9610fc9f2

Differential Revision: https://phabricator.services.mozilla.com/D214044
2024-06-18 20:13:54 +00:00
Ting-Yu Lin
3fe028079a Bug 1902542 Part 5 - Delete empty pushed floats list in nsBlockFrame::RemoveFloat(). r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D213702
2024-06-14 17:13:05 +00:00
Ting-Yu Lin
b4b72988b8 Bug 1902542 Part 3 - Clean up nsBlockFrame's pushed floats handling. r=layout-reviewers,emilio
Add an "s" to PushedFloatsProperty() to match the state bit.

Rename `RemovePushedFloats()` to `StealPushedFloats()` to match other APIs that
take the ownership of a frame list.
https://searchfox.org/mozilla-central/rev/4c8627a76e2e0a9b49c2b673424da478e08715ad/layout/generic/nsContainerFrame.h#598-612

Differential Revision: https://phabricator.services.mozilla.com/D213700
2024-06-14 17:13:04 +00:00
Ting-Yu Lin
5aea04a131 Bug 1902542 Part 2 - Clean up another nsBlockFrame's state bit related to cached intrinsic. r=layout-reviewers,emilio
Remove "FRAME" for the bit for the consistency with other bits.

Differential Revision: https://phabricator.services.mozilla.com/D213699
2024-06-14 17:13:04 +00:00
Ting-Yu Lin
4be8fd1565 Bug 1902542 Part 1 - Clean up nsBlockFrame's helper and state bits related to ::marker. r=layout-reviewers,emilio
- Remove "FRAME" for nsBlockFrame state bits for the consistency with other bits.

- Use helpers instead of checking state bits if possible.

- Tweak one line documentation to use C++ comment style.

- Move `GetMarker()` to protected section because it is used only internally.

Differential Revision: https://phabricator.services.mozilla.com/D213698
2024-06-14 17:13:03 +00:00
Ting-Yu Lin
a653b7becd Bug 1899894 - Remove debug statements that require customized #define. r=layout-reviewers,emilio
The debug statements all require customized #define to enable. I don't feel it
is useful to leave code that is not compiled in the default debug build.

Differential Revision: https://phabricator.services.mozilla.com/D212192
2024-05-31 17:45:44 +00:00
Ting-Yu Lin
8d546a2fd5 Bug 1899345 Part 1 - Convert PhysicalAxes to an EnumSet<PhysicalAxis>. r=layout-reviewers,emilio
This also makes `PhysicalAxis::{Horizontal,Vertical}` more useful when we
previous needed `PhysicalAxes::{Horizontal,Vertical}`.

Differential Revision: https://phabricator.services.mozilla.com/D211941
2024-05-30 17:58:25 +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
Sebastian Hengst
18041c50bb Backed out 2 changesets (bug 1899345) for conflicting with backout of bug 1896516
Backed out changeset b96c165e9ab4 (bug 1899345)
Backed out changeset 01a540f73690 (bug 1899345)
2024-05-29 11:21:39 +02:00
Ting-Yu Lin
5644682c09 Bug 1899345 Part 1 - Convert PhysicalAxes to an EnumSet<PhysicalAxis>. r=layout-reviewers,emilio
This also makes `PhysicalAxis::{Horizontal,Vertical}` more useful when we
previous needed `PhysicalAxes::{Horizontal,Vertical}`.

Differential Revision: https://phabricator.services.mozilla.com/D211941
2024-05-29 05:10:38 +00:00
Stanca Serban
60109eeb45 Backed out 2 changesets (bug 1899345) for causing android build bustages in ScrollContainerFrame.cpp. CLOSED TREE
Backed out changeset ccb2ccbef46e (bug 1899345)
Backed out changeset 6f66d112b450 (bug 1899345)
2024-05-29 03:49:38 +03:00
Ting-Yu Lin
940c33226a Bug 1899345 Part 1 - Convert PhysicalAxes to an EnumSet<PhysicalAxis>. r=layout-reviewers,emilio
This also makes `PhysicalAxis::{Horizontal,Vertical}` more useful when we
previous needed `PhysicalAxes::{Horizontal,Vertical}`.

Differential Revision: https://phabricator.services.mozilla.com/D211941
2024-05-29 00:17:58 +00: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
Emilio Cobos Álvarez
6320be3e20 Bug 1897361 - Share counter-style / list-style-type representation between Servo and Gecko. r=jwatt
It's not clear to me what is going on there or what caused it. I suspect
it might be:

  https://searchfox.org/mozilla-central/rev/1f46481d6c16f27c989e72b898fd1fddce9f445f/servo/components/style/gecko/values.rs#69

Which is the only potential from_raw_parts caller there. But hard to say
without a regression range.

However I've been wanting to get rid of that code for a while, and
this is a good opportunity for that.

The WithCounterStyleNameOrSymbols stuff isn't super pretty, but it has
only two callers, and something more complicated might require further
refactoring.

Differential Revision: https://phabricator.services.mozilla.com/D210814
2024-05-19 21:24:16 +00:00
Cristian Tuns
fbb56a1610 Backed out changeset dffe004546c6 (bug 1897361) for causing reftest failures in /list-1.html CLOSED TREE 2024-05-19 17:09:47 -04:00
Emilio Cobos Álvarez
ebdae8c849 Bug 1897361 - Share counter-style / list-style-type representation between Servo and Gecko. r=jwatt
It's not clear to me what is going on there or what caused it. I suspect
it might be:

  https://searchfox.org/mozilla-central/rev/1f46481d6c16f27c989e72b898fd1fddce9f445f/servo/components/style/gecko/values.rs#69

Which is the only potential from_raw_parts caller there. But hard to say
without a regression range.

However I've been wanting to get rid of that code for a while, and
this is a good opportunity for that.

The WithCounterStyleNameOrSymbols stuff isn't super pretty, but it has
only two callers, and something more complicated might require further
refactoring.

Differential Revision: https://phabricator.services.mozilla.com/D210814
2024-05-19 19:42:38 +00:00
Emilio Cobos Álvarez
2d27ab6066 Bug 1874079 - Don't mark a line dirty for clearance if we haven't found any floats. r=dshin
Differential Revision: https://phabricator.services.mozilla.com/D209651
2024-05-17 14:48:24 +00:00
Emilio Cobos Álvarez
28bdfc0fba Bug 1281158 - Parse alternative text for the content property. r=dshin
This doesn't yet expose it to a11y but that will be done by the a11y
folks, since this blocks some of the a11y interop test-cases.

Modify the tests to not hit the network, and make -moz-alt-content not
exposed to content (we only need it for UA stylesheets).

Differential Revision: https://phabricator.services.mozilla.com/D209690
2024-05-08 16:06:47 +00:00
Emilio Cobos Álvarez
cf7adb676e Bug 1891210 - Make line-clamp on blocks work in chrome contexts. r=dholbert
This flag is tested separately, I don't think this deserves its own
test, probably...

Differential Revision: https://phabricator.services.mozilla.com/D207342
2024-04-15 18:07:51 +00:00
Jonathan Kew
07c2128661 Bug 1888449 - Ensure that attempting to balance lines doesn't alter the block-size of the result. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D206680
2024-04-07 22:37:42 +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
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
34e73c6bbd Bug 1839994 Part 2 - Rename (Has|Set)ForcedLineBreakBefore to (Has|Set)FloatClearTypeBefore. r=dholbert
This is the option b) in bug 1839994 comment 0.

Differential Revision: https://phabricator.services.mozilla.com/D205020
2024-03-20 17:05:42 +00:00
Emilio Cobos Álvarez
ef150776cf Bug 1874823 - Remove NS_BLOCK_STATIC_BFC and NS_BLOCK_CLIP_PAGINATED_OVERFLOW. r=fredw
Put all the "is this block a BFC" logic in nsBlockFrame.cpp.

The CLIP_PAGINATED_OVERFLOW flag is also redundant, it can just be "has
non-propagated overflow styles" check in ShouldApplyOverflowClipping(),
and frees another bit.

Shouldn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D203590
2024-03-07 16:36:56 +00:00
Emilio Cobos Álvarez
2eaac42210 Bug 1882709 - Backplate only if there is visible text on the line. r=morgan
Depends on D203252

Differential Revision: https://phabricator.services.mozilla.com/D203253
2024-03-01 23:18:33 +00:00
Emilio Cobos Álvarez
d653c75106 Bug 1362907 - Fix a couple crashtests.
<select> doesn't allow first-line, which was causing some non-fatal
asserts.

The annotated crashtest overflows a bSize but it gets handled safely by
nsLineLayout.

MANUAL PUSH: Trivial orange fix CLOSED TREE
2024-02-29 14:16:40 +01:00
Emilio Cobos Álvarez
14c69b2672 Bug 1362907 - Make select use nsHTMLButtonControlFrame for layout. r=jfkthame,dholbert
This simplifies our combobox code a bit more:

 * Reflow() is only needed to compute the label isize.
 * Frame construction uses a setup more similar to <input type=file> to
   get the right frame tree, removing a bunch of special code.
 * Lots of special code removed all over the place.

Differential Revision: https://phabricator.services.mozilla.com/D203010
2024-02-29 11:15:52 +00:00
fantasai
5879e8247d Bug 1684236 - Implement 'align-content' on block containers. r=layout-reviewers,jfkthame
This is Fantasai's original patch, massively simplified:

 * We now can switch whether we're a BFC dynamically (bug 1765615), which
   simplifies the patch quite a lot.

 * I removed some changes that were specific to pagination but were untested.
   I left them as D202814, just in case we need some of those in the future.

All in all this makes the patch much more manageable.

Co-authored-by: Emilio Cobos Álvarez <emilio@crisal.io>

Differential Revision: https://phabricator.services.mozilla.com/D181858
2024-02-27 16:32:02 +00:00
Emily McDonough
d8944d6766 Bug 1865172 Part 1 - Always store a page name value when a breakpoint is first found during block reflow. r=dholbert
This happens in a similar location to where we find a breakpoint caused by a
change in page name. However, if the breakpoint was caused by something else,
we still need to compute this value so that the next page being constructed
will have the correct page name.

This also "fixes" the WPT /css/printing/page-name-007-print.html, which passed
before this patch just because our previous logic would continue using the last
page value in those cases, which coincidentally matched what was expected.

Part 2 will include a test that specifically detects this discrepency.

Differential Revision: https://phabricator.services.mozilla.com/D196895
2024-02-24 04:05:45 +00:00
Stanca Serban
f3138fcd27 Backed out 2 changesets (bug 1865172) for causing wpt failures in page-name-unnamed-trailing-001-print.html.
Backed out changeset fc1f91bbfd85 (bug 1865172)
Backed out changeset 17019e03e97c (bug 1865172)
2024-02-24 01:53:19 +02:00
Emily McDonough
fee7314f2a Bug 1865172 Part 1 - Always store a page name value when a breakpoint is first found during block reflow. r=dholbert
This happens in a similar location to where we find a breakpoint caused by a
change in page name. However, if the breakpoint was caused by something else,
we still need to compute this value so that the next page being constructed
will have the correct page name.

This also "fixes" the WPT /css/printing/page-name-007-print.html, which passed
before this patch just because our previous logic would continue using the last
page value in those cases, which coincidentally matched what was expected.

Part 2 will include a test that specifically detects this discrepency.

Differential Revision: https://phabricator.services.mozilla.com/D196895
2024-02-23 22:34:37 +00:00