Commit graph

46790 commits

Author SHA1 Message Date
Oriol Brufau
a7699d9034 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
f48b95e2e3 style: Move size of tests to compile-time tests in the style crate
Same reasoning as the previous commit.

Differential Revision: https://phabricator.services.mozilla.com/D146104
2023-08-16 17:46:41 +02:00
Oriol Brufau
50d31686be Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
9a7e8006e1 style: Convert specified value tests to compile-time tests
These were written at a time where std::mem::size_of wasn't a `const fn` in
Rust.

Now that it is, we can make these tests live in the style crate, and the build
not to compile if they fail.

Differential Revision: https://phabricator.services.mozilla.com/D146103
2023-08-16 17:46:41 +02:00
David Shin
5f75d29aac style: Implement piecewise linear function
Differential Revision: https://phabricator.services.mozilla.com/D145256
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
a1c8d7ebb2 style: Fix layer statement rules with multiple layer names
MANUAL PUSH: Trivial orange fix CLOSED TREE.
2023-08-16 17:46:41 +02:00
Oriol Brufau
7300c12a13 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
82c5be08c8 style: Track @container condition id in style rules
Much like we track layer rules. Consolidate that "containing rule state
we pass down while building the cascade data" in a single struct that we
can easily restore.

For now, do nothing with it. I want to land this patch separately
because it touches the Rule struct and CascadeData rebuilds, which both
are performance sensitive.

Its layout shouldn't change because I also changed LayerId to be a u16
(this shouldn't matter in practice, since LayerOrder is already a u16).

Differential Revision: https://phabricator.services.mozilla.com/D145243
2023-08-16 17:46:41 +02:00
Oriol Brufau
b05552369f Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
4878422c93 style: Simplify selector flags setup even more
In my investigation for bug 1766439, I am digging into why selector
matching regressed.

It doesn't help that the selector-matching code is instantiated a
gazillion times (so there's a ton of copies of the relevant functions).

This was needed in the past because we had different ways of setting the
selector flags on elements, but I unified that recently and now we only
need to either set them or not. That is the kind of thing that
MatchingContext is really good for, so pass that instead on
MatchingContext creation.

Differential Revision: https://phabricator.services.mozilla.com/D145428
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
db53845694 style: Remove proton places tooltip code
There's nobody working on it, and tooltips should hopefully be nice
enough after recent changes (bug 1765423).

Having it enabled causes artifacts like bug 1767815 comment 3. We can
always rescue this from hg history if needed.

Differential Revision: https://phabricator.services.mozilla.com/D145621
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
68af027381 style: Implement media feature expression multi-range syntax
Differential Revision: https://phabricator.services.mozilla.com/D145231
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
f545a473ff style: Refactor media feature expression representation in preparation to support multi-range syntax
No behavior change.

Depends on D145229

Differential Revision: https://phabricator.services.mozilla.com/D145230
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
990de9ceaa style: Factor out parsing the query feature name
No behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D145229
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
d1a281ebbd style: Fix insertRule with layer statements before imports
We need to do a bit more nuanced check because @layer statements might
go before imports.

Differential Revision: https://phabricator.services.mozilla.com/D144996
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
819ebc5710 style: Introduce Optional<T> to represent optional values in the style system
cross-fade() was kinda doing this in its own way with PercentOrNone, but
since now we have more use-cases for this we should probably make this a
slightly more general solution.

I added some convenience APIs, but they're unused as of this patch so
let me know if you want them gone.

Differential Revision: https://phabricator.services.mozilla.com/D144831
2023-08-16 17:46:41 +02:00
Oriol Brufau
16cfd01823 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
1003d644aa style: Add support for parsing container-query-specific features
There are some mediaqueries-5 features that we still don't support and
explain the remaining failures in at-container-{parsing,serialization}.

Differential Revision: https://phabricator.services.mozilla.com/D144446
2023-08-16 17:46:41 +02:00
Oriol Brufau
989f8d89c4 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
679a69defb style: cleanup animation-name
Make the representation the same between Gecko and Servo code. This will
enable further clean-ups in the future.

Make serialization be correct, serializing as identifier unless it's an
invalid one (in which case we serialize as a string).

This changes our stringification behavior in the specified style, but
now it will match the computed style and be more correct over-all.

Differential Revision: https://phabricator.services.mozilla.com/D144473
2023-08-16 17:46:41 +02:00
Oriol Brufau
ca25d17626 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
453e7d03d4 style: Move some of the media query code to a more generic queries module
No behavior change, just moving and renaming files.

The code in the "queries" module will be shared between @media and
@container.

@media has some other code that container queries doesn't need like
MediaList / MediaType / etc. That remains in the media_queries module.

Differential Revision: https://phabricator.services.mozilla.com/D144435
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
3eed093e33 style: Tweak contain bitflag definition order to avoid static constructors
This has no behavior change otherwise. The STRICT definition depended on
SIZE, which was defined later. That's fine in Rust, but in C++ it causes
the initialization to be dynamic because it doesn't have the definition
of SIZE yet (ugh).

This is the fix for the regression, though the following patch turns on
constexpr support in cbindgen, which would've caught this at build-time,
and guarantees that we don't have extra static constructors.

Differential Revision: https://phabricator.services.mozilla.com/D144316
2023-08-16 17:46:41 +02:00
Boris Chiou
3b174e376e style: Add scroll() to animation-timeline for style system
scroll() is defined in the spec proposal, and there is a temporary spec:
https://drafts.csswg.org/scroll-animations-1/rewrite#scroll-notation.

The spec is still under development, so we don't drop the orignal
scroll-timeline at rule. Instead, we add a new scroll() notation to
animation-timeline, and support both syntax for now.

Differential Revision: https://phabricator.services.mozilla.com/D143417
2023-08-16 17:46:41 +02:00
Oriol Brufau
f981596622 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
8d8b5942be style: Make media feature evaluation take a computed::Context
This has no behavior change right now, but will simplify sharing code
with container queries.

Container queries will have container information in the
computed::Context (this is necessary anyways for container-based units),
so this avoids having to have different code for media and container
queries.

Differential Revision: https://phabricator.services.mozilla.com/D144152
2023-08-16 17:46:41 +02:00
Oriol Brufau
6279504ddb Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
76847f7b45 style: Move transitions and animations to nsStyleUIReset
This mostly just moves code around, to minimize potential behavior
changes. There are some cleanups that we should try to do long term
(this "have an array with n different counts" is pretty weird).

But for now this should unblock people.

The destination struct (nsStyleUIReset) was chosen mainly because it's
small and non-inherited, and it doesn't seem like a worse place than
nsStyleDisplay.

Differential Revision: https://phabricator.services.mozilla.com/D144183
2023-08-16 17:46:41 +02:00
Oriol Brufau
fdff95b9c8 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
6a6a53930e style: Simplify media query evaluation code a bit
This patch:

  * Removes generic <ident> support for media features. These were used
    for some privileged media features but are no longer used.

  * Simplifies media feature getters by shifting the responsibility of
    dealing with RangeOrOperator to the caller. This makes it easier to
    implement container-query / mediaqueries-4 syntax, and also cleans up
    the code a bunch.

There should be no change in behavior.

Differential Revision: https://phabricator.services.mozilla.com/D144051
2023-08-16 17:46:41 +02:00
David Shin
e4fb1377ac style: Implement contain: inline-size
Differential Revision: https://phabricator.services.mozilla.com/D143501
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
af52dbe028 style: Clean-up viewport unit resolution a bit
I should've caught this when reviewing the new viewport units but alas :-)

Differential Revision: https://phabricator.services.mozilla.com/D143856
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
14fb147b6c style: Fix visited handling after bug 1763750
Before bug 1763750, we unconditionally called compute_writing_mode,
which got the writing mode from the cascade mode for visited styles.

However after that bug we only do that if we apply any
writing-mode-related property.

We could just call compute_writing_mode unconditionally, but instead it
seems better to skip all that work for visited cascade and reuse the
mechanism introduced in that bug to only apply the visited-dependent
longhands.

We assert that all visited-dependent longhands are "late" longhands, so
as to also avoid applying the font group and such.

Differential Revision: https://phabricator.services.mozilla.com/D143490
2023-08-16 17:46:41 +02:00
Oriol Brufau
d868cddb09 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Nika Layzell
82af75bb94 style: Join servo style threads during shutdown
I was unable to change the BLOOM_KEY field to no longer be leaked, as the TLS
is also accessed on the main thread, which is not exited before the leak
checker shuts down.

Differential Revision: https://phabricator.services.mozilla.com/D143529
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
5bdec7a0f4 style: Implement prefers-contrast: custom and let prefers-contrast ride the trains
Differential Revision: https://phabricator.services.mozilla.com/D143198
2023-08-16 17:46:41 +02:00
Hiroyuki Ikezoe
dbeec6df35 style: Implement new *vi and *vb units
Differential Revision: https://phabricator.services.mozilla.com/D143253
2023-08-16 17:46:41 +02:00
Oriol Brufau
f62fb7e5f5 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Hiroyuki Ikezoe
129e06327a style: Implement new {small,large,dynamic} viewport units
Differential Revision: https://phabricator.services.mozilla.com/D143252
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
7c538e8147 style: Tweak cascade priority to split writing-mode and font properties
This makes the worst case for cascade performance slightly more
expensive (4 rather than three declaration walks), but my hope is that
it will make the average case faster, since the best case is now just
two walks instead of three, and writing mode properties are somewhat
rare.

This needs a test, but needs to wait until the writing-mode dependent
viewport units land (will wait to land with a test).

Differential Revision: https://phabricator.services.mozilla.com/D143261
2023-08-16 17:46:41 +02:00
Oriol Brufau
27cb7cd4f2 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
b31ea25848 style: Add basic @container rule parsing and boilerplate
For now parse a MediaFeatureCondition. That needs being made more
specific, but that is probably worth its own patch.

Differential Revision: https://phabricator.services.mozilla.com/D143192
2023-08-16 17:46:41 +02:00
Oriol Brufau
6755548267 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
90a65bcf01 style: Inherit used color-scheme from embedder <browser> elements
This allows popups and sidebars to use the chrome preferred
color-scheme.

This moves the responsibility of setting the content-preferred color
scheme to the appropriate browsers to the front-end (via tabs.css).

We still return the PreferredColorSchemeForContent() when there's no
pres context (e.g., for display:none in-process iframes). We could
potentially move a bunch of the pres-context data to the document
instead, but that should be acceptable IMO as for general web content
there's no behavior change in any case.

Differential Revision: https://phabricator.services.mozilla.com/D142578
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
80d2c8f22b style: Deduplicate TokenList values faster
Remember whether we have already de-duplicated them once and avoid doing
that again.

This is an alternative approach that doesn't add overhead to attribute
setting in the general case.

Differential Revision: https://phabricator.services.mozilla.com/D142813
2023-08-16 17:46:41 +02:00
David Shin
739d6d14ab style: Migrate <th> text-align behaviour from presentation hint to UA CSS
Differential Revision: https://phabricator.services.mozilla.com/D142494
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
0cf72d5e70 style: Remove assert that doesn't hold for text-decorations because of presentation hints
MANUAL PUSH: Orange fix CLOSED TREE
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
ec6099563e style: Implement parsing / serialization for container{,-type,-name} CSS properties
Two noteworthy details that may seem random otherwise:

 * Moving values around in nsStyleDisplay is needed so that the struct
   remains under the size limit that we have to avoid jumping allocator
   buckets.

 * All the test expectation churn is because tests depend on
   `container-type: size` parsing to run, and now they run. Tests for
   the relevant bits I implemented are passing, with the only exception
   of some `container-name-computed.html` failures which are
   https://github.com/w3c/csswg-drafts/issues/7181. Safari agrees with
   us there.

Other notes when looking at the spec and seeing how it matches the
implementation:

 * `container` syntax doesn't match spec, but matches tests and sanity:
   https://github.com/w3c/csswg-drafts/issues/7180

 * `container-type` syntax doesn't _quite_ match spec, but matches tests
   and I think it's a spec bug since the definition for the missing
   keyword is gone:
   https://github.com/w3c/csswg-drafts/issues/7179

Differential Revision: https://phabricator.services.mozilla.com/D142419
2023-08-16 17:46:41 +02:00
Oriol Brufau
ee4e09359f Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
f30837baf1 style: Allow to derive Parse/ToCss/SpecifiedValueInfo on bitflags
We keep getting this pattern of properties that have a set of joint and
disjoint flags, and copy-pasting or writing the same parsing and
serialization code in slightly different ways.

container-type is one such type, and I think we should have a single way
of dealing with this, thus implement deriving for various traits for
bitflags, with an attribute that says which flags are single vs mixed.

See docs and properties I ported. The remaining ones I left TODOs with,
they are a bit trickier but can be ported with some care.

Differential Revision: https://phabricator.services.mozilla.com/D142418
2023-08-16 17:46:41 +02:00