Commit graph

25592 commits

Author SHA1 Message Date
Martin Robinson
459a7d26aa
Simplify layout of absolutes with static insets
Absolutes with static insets need to be laid out at their ancestor
containing blocks, but their position is dependent on their parent's
layout. The static layout position is passed up the tree during hoisting
and ancestors each add their own offset to the position until it is
relative to the containing block that contains the absolute.

This is currently done with a closure and a fairly tricky "tree rank"
numbering system that needs to be threaded through the entire layout.
This change replaces that system.

Every time a child is laid out we create a positioning context to hold
any absolute children (this can be optimized away at a later time). At
each of these moments, we call a method to aggregate offsets to the
static insets of hoisted absolutes. This makes the logic easier to
follow and will also allow implementing this behavior for inline-blocks,
which was impossible with the old system.
2023-06-20 11:44:25 +02:00
Oriol Brufau
4ec6dd1783 Handle floats in BlockContainer::inline_content_sizes
Typically, block-level contents are stacked vertically, so this was just
taking the maximum size among all contents. However, floats can be
stacked horizontally, so we need to sum their sizes.
2023-06-19 16:02:35 +02:00
bors-servo
47fb54fc54
Auto merge of #29883 - Loirooriol:float-inline-size, r=mrobinson
Implement BlockLevelBox::inline_content_sizes for floats

This improves #29874, but `BlockContainer::inline_content_sizes` will still need more changes in order to correctly handle sequences of floats.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2023-06-16 20:03:36 +02:00
bors-servo
0b310e6e6a
Auto merge of #29880 - mrobinson:fix-float-stacking-context-order, r=Loirooriol
Don't pass float stacking containers up to parent stacking contexts

Don't pass up float stacking containers to parent stacking contexts

Instead of passing up stacking containers created by floated content,
keep them in their original parent stacking containers. This is in in
line with specification text for stacking containers:

> To paint a stacking container, given a box root and a canvas canvas:
>
>   1.  Paint a stacking context given root and canvas, treating root as
>       if it created a new stacking context, but omitting any positioned
>       descendants or descendants that actually create a stacking context
>       (letting the parent stacking context paint them, instead).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2023-06-16 17:11:58 +02:00
Martin Robinson
ae3c22aa88
Don't pass up float stacking containers to parent stacking contexts
Instead of passing up stacking containers created by floated content,
keep them in their original parent stacking containers. This is in in
line with specification text for stacking containers:

> To paint a stacking container, given a box root and a canvas canvas:
>
>   1.  Paint a stacking context given root and canvas, treating root as
>       if it created a new stacking context, but omitting any positioned
>       descendants or descendants that actually create a stacking context
>       (letting the parent stacking context paint them, instead).
2023-06-16 17:11:00 +02:00
Oriol Brufau
66c4eee082 Implement BlockLevelBox::inline_content_sizes for floats
This improves #29874, but BlockContainer::inline_content_sizes will still
need more changes in order to correctly handle sequences of floats.
2023-06-16 15:46:35 +02:00
bors-servo
a068816113
Auto merge of #29876 - mrobinson:update-float-docs, r=mrego
Layout 2020: Fix issues with float implementation documentation

Fix some rustdoc comments which won't process properly unless they start with three '/' characters. In addition, improve the name of a function and add some missing documentation.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because they do not change behavior.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2023-06-15 15:02:06 +02:00
Martin Robinson
3b3dc4adbe
Layout 2020: Fix issues with float implementation documentation
Fix some rustdoc comments which won't process properly unless they start
with three '/' characters. In addition, improve the name of a function
and add some missing documentation.
2023-06-14 17:09:56 +02:00
Oriol Brufau
bc634be84a Avoid assert failure when using @import 2023-06-14 15:58:00 +02:00
Martin Robinson
ae819d690e
Layout 2020: Remove the floats preference
Enable floats always. It doesn't make sense to have this preference as
it's a basic feature of an experimental layout engine.
2023-06-13 19:30:54 +02:00
bors-servo
9260683b5f
Auto merge of #29848 - Loirooriol:sync, r=mrobinson
Backport several style changes from Gecko (4)

<!-- Please describe your changes on the following line: -->
This continues https://github.com/servo/servo/pull/29816.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2023-06-12 12:11:30 +02:00
bors-servo
1d69e7b234
Auto merge of #29859 - mrobinson:float-negative-block-margin, r=Loirooriol
Layout 2020: Properly handle negative margins in floats

If a float has negative block margins, it should be pushed upward, but shouldn't affect the positioning of any floats that came before it. It should lower the ceiling though when it still has some non-negative block contribution. In order to implement this behavior, we should only place the float considering its non-negative block length contribution. If the float is pushed up completely past it's "natural" position, it should be placed like a float with zero block size.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2023-06-12 09:33:48 +02:00
Martin Robinson
bc58bb080f Layout 2020: Properly handle negative block margins in floats
If a float has negative block margins, it should be pushed upward, but
shouldn't affect the positioning of any floats that came before it. It
should lower the ceiling though when it still has some non-negative
block contribution. In order to implement this behavior, we should only
place the float considering its non-negative block length contribution. If
the float is pushed up completely past it's "natural" position, it
should be placed like a float with zero block size.
2023-06-11 11:47:56 +02:00
bors-servo
7d9839acc8
Auto merge of #29863 - nicoburns:fix-infinite-loop-when-shrinking, r=Loirooriol
Fix infinite loop in flexbox algorithm

Only apply step 5c of "resolve flexible lengths" if sum of scaled flexible shrink factors > 0
Probably fixes #29852 (but speculative as I can't get mach to run).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
2023-06-10 16:54:24 +02:00
Emilio Cobos Álvarez
e03261c433 style: Remove some no longer used use statements
MANUAL PUSH: Bustage fix CLOSED TREE
2023-06-09 11:18:08 +02:00
Emilio Cobos Álvarez
01fb804320 style: Use atomic ops to read / write node flags from stylo
The flags stylo cares about reading and writing potentially at the same
time are disjoint, so there's no need for any strong memory ordering.

Differential Revision: https://phabricator.services.mozilla.com/D141829
2023-06-09 11:18:08 +02:00
Emilio Cobos Álvarez
ece2a74709 style: Put overflow: -moz-hidden-unscrollable behind a pref on Nightly
Differential Revision: https://phabricator.services.mozilla.com/D141759
2023-06-09 11:18:08 +02:00
Emilio Cobos Álvarez
32dd0b27e4 style: Honor background-color: transparent in forced colors mode
See comment as for why, and linked bugs, in particular:

  https://bugzilla.mozilla.org/show_bug.cgi?id=1755713#c16

And the following screenshot for example.

Differential Revision: https://phabricator.services.mozilla.com/D141514
2023-06-09 11:18:08 +02:00
Martin Robinson
eb96b29af0 style: Add support for parsing the content-visibility property from the CSS Contain specification
Add initial parsing support for the CSS `content-visibility` attribute.
Currently these parsed values have no effect.

Differential Revision: https://phabricator.services.mozilla.com/D140834
2023-06-09 11:18:07 +02:00
Emilio Cobos Álvarez
8016c434b0 style: Reuse inherited custom properties if they didn't change after resolution
This should be cheap and gives us a lot of memory savings for the page
on the bug, by deduplicating the inherited properties between parent and
children.

WebKit implements a similar optimization.

Differential Revision: https://phabricator.services.mozilla.com/D140826
2023-06-09 11:18:07 +02:00
Emilio Cobos Álvarez
da81d71ffa style: Make custom-property substitution only traverse variables which could have references
If a name is not in self.seen, it means we've inherited it from our
parent. That in turn means that it can't have any variable reference
(because we inherit the computed variables) and we can skip the work of
traversing it, as we'd hit the early-return in traverse() anyways.

This doesn't fix the memory usage issue of the page on the bug, which
has a giant list of properties on the root and then a custom property
specified on all elements, but should significantly reduce the time we
spend iterating over custom properties for all those elements.

Differential Revision: https://phabricator.services.mozilla.com/D140825
2023-06-09 11:18:07 +02:00
Emilio Cobos Álvarez
b798336f81 style: Generalize moz-os-version into moz-platform
Allow differentiating non-windows platforms on it.

Differential Revision: https://phabricator.services.mozilla.com/D138431
2023-06-09 11:18:07 +02:00
Oriol Brufau
e2901169c8 Further changes required by Servo 2023-06-09 11:18:07 +02:00
Emilio Cobos Álvarez
2a67752418 style: Style system and plumbing for mix-blend-mode: plus-lighter
Differential Revision: https://phabricator.services.mozilla.com/D137951
2023-06-09 11:18:07 +02:00
Mike Hommey
d3aeba6bd3 style: Use the mozbuild crate in servo
Differential Revision: https://phabricator.services.mozilla.com/D136562
2023-06-09 11:18:06 +02:00
Mike Hommey
d32c5ed85f style: Remove MOZ_DIST
As mentioned in bug 1747354, the location of the dist directory is
relied to be $topobjdir/dist, so just use that consistently rather
than getting it from a separate variable for rust build scripts.

Differential Revision: https://phabricator.services.mozilla.com/D136556
2023-06-09 11:18:06 +02:00
Oriol Brufau
54878595b3 Further changes required by Servo 2023-06-09 11:18:06 +02:00
Emily McDonough
199f54342c style: Add style_traits::ToCss for AtomIdent
Differential Revision: https://phabricator.services.mozilla.com/D136290
2023-06-09 11:18:06 +02:00
Oriol Brufau
f39ab4ffc1 Further changes required by Servo 2023-06-09 11:18:06 +02:00
Emily McDonough
01c6eb3556 style: Implement basic @page-rule selector parsing
This does not support any of the pseudo page types.

Differential Revision: https://phabricator.services.mozilla.com/D131532
2023-06-09 11:18:05 +02:00
Oriol Brufau
e4bb1df878 Upgrade darling to 0.13.1
Based on https://phabricator.services.mozilla.com/D136568
2023-06-09 11:17:48 +02:00
Emilio Cobos Álvarez
0307500c3d style: Choose tabpanel background based on content preferred color-scheme
If the theme is dark but user prefers light pages, the background of the
tabpanel should arguably be light, since it can be seen across some
navigations.

Expose a -moz-content-prefers-color-scheme media query to chrome pages
so that our UI can correctly query it (and remove the unused -moz-proton
atom while at it).

Differential Revision: https://phabricator.services.mozilla.com/D136437
2023-06-09 10:22:26 +02:00
Emilio Cobos Álvarez
df6b6ba675 style: Apply line-height to ::marker
Differential Revision: https://phabricator.services.mozilla.com/D136313
2023-06-09 10:22:26 +02:00
Oriol Brufau
01549f0389 Further changes required by Servo 2023-06-09 10:22:26 +02:00
Emilio Cobos Álvarez
080b3f8d1a style: Avoid generating InterpolateMatrix operations if there are no size dependencies
The issue here is that we end up with a transition between mismatched
transform lists that ends up generating an InterpolateMatrix {}
operation. So far so good, but we end up interpolating that a lot of
times and generating an unboundedly-deep operation list.

This implementas an optimization that flattens them to a single matrix
when possible (when there's no dependencies on the containing box).

This is similar to:

  https://chromium.googlesource.com/chromium/src.git/+/2b89cc4df436e672ef9cf940d1c0dc73fef82a4a

We fix the to_pixel_length() behavior for LenghtPercentage to be
correct (and update callers to preserve behavior).

Differential Revision: https://phabricator.services.mozilla.com/D134784
2023-06-09 10:22:26 +02:00
Emilio Cobos Álvarez
6cb3b7e254 style: Remove touch-action pref
It's been enabled by default since ~forever.

Differential Revision: https://phabricator.services.mozilla.com/D134935
2023-06-09 10:22:26 +02:00
Emilio Cobos Álvarez
f0524611c4 style: Rename StyleMathMLMathVariant -> StyleMathVariant
MANUAL PUSH: Trivial rename.
2023-06-09 10:22:25 +02:00
Neia Finch
e44bedbcda style: Replace MathML font constants with enum
Differential Revision: https://phabricator.services.mozilla.com/D134802
2023-06-09 10:22:25 +02:00
Emilio Cobos Álvarez
01e43a8488 style: Make color-adjust an alias of print-color-adjust as per spec
Differential Revision: https://phabricator.services.mozilla.com/D134779
2023-06-09 10:22:25 +02:00
Emilio Cobos Álvarez
fcc55f2156 style: Shrink maps if needed after stylist rebuilds
Hashbrown grows a lot sometimes making us waste a lot of memory. Shrink
some of these maps after CascadeData rebuild / stylesheet collection
invalidation.

Differential Revision: https://phabricator.services.mozilla.com/D134716
2023-06-09 10:22:25 +02:00
Emilio Cobos Álvarez
5b62f66f6e style: Remove ThinBoxedSlice
The only remaining consumers are ::-moz-tree pseudo-elements (we used to
use ThinBoxedSlice for other data structures in the past).

Those are not particularly performance sensitive so I think just
double-boxing is fine. In the future, if we wanted to avoid the double
indirection, we could probably use the "thin" crate
(https://docs.rs/thin) or similar, which stores the length of the slice
along with the allocation, making the pointer thin in all
configurations, much like "ThinArc" does:

  https://searchfox.org/mozilla-central/rev/1ce2eea39442190a71a1f8f650d098f286bf4a01/servo/components/servo_arc/lib.rs#891

In practice though, I don't think it's particularly worth it for this
specific case.

Differential Revision: https://phabricator.services.mozilla.com/D134672
2023-06-09 10:22:25 +02:00
Emilio Cobos Álvarez
fc4d185079 style: Use ThreadPool::scope_fifo in style
It does the same, but it saves an indentation level:

  https://searchfox.org/mozilla-central/rev/a11b63915bd7810a03635d733123448ab5bfcad3/third_party/rust/rayon-core/src/thread_pool/mod.rs#217

Differential Revision: https://phabricator.services.mozilla.com/D134321
2023-06-09 10:22:25 +02:00
Emilio Cobos Álvarez
d0475b75d4 style: Remove hwba since it's not a thing (hwb function supports alpha)
Partially backs out the previous patch.

Differential Revision: https://phabricator.services.mozilla.com/D134256
2023-06-09 10:22:24 +02:00
Emilio Cobos Álvarez
4229ace432 style: Add hwb/a to devtools autocomplete lists
The changes to the devtools directory were written automatically via ./mach devtools-css-db

Differential Revision: https://phabricator.services.mozilla.com/D134197
2023-06-09 10:22:24 +02:00
Emilio Cobos Álvarez
2b6fce1e57 style: Remove servo/components/{hashglobe,fallible} in favor of try_reserve
Differential Revision: https://phabricator.services.mozilla.com/D134194
2023-06-09 10:22:24 +02:00
Oriol Brufau
07d1bd560b Further changes required by Servo 2023-06-09 10:22:24 +02:00
Emilio Cobos Álvarez
454a9777b3 style: Deal with layers and at-rules
Differential Revision: https://phabricator.services.mozilla.com/D134010
2023-06-09 10:22:24 +02:00
Jonathan Kew
da29cade57 style: Add CSS support for the hyphenate-character property
Differential Revision: https://phabricator.services.mozilla.com/D133889
2023-06-09 10:22:23 +02:00
Emilio Cobos Álvarez
9e7b8e9202 style: Don't draw window decorations when painting headerbar on wayland
This is a better fix for the double decorations than clipping them using
CSS.

Differential Revision: https://phabricator.services.mozilla.com/D133871
2023-06-09 10:22:23 +02:00
Oriol Brufau
98b49f8023 Further changes required by Servo 2023-06-09 10:22:23 +02:00