Commit graph

1794 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
bb5de5833c style: Improve LookAndFeel color caching
To be honest, I'm a bit baffled that bug 1773795 caused a performance
regression, but I think it's because the standins codepath is not really
cached, so system colors that are "spoofed" always go through the
massive switch, which could potentially be expensive.

To fix, this, rejigger a bit the caches so that we key on both
color-scheme and use-standins. Also, while at it, make the set of colors
we spoof a single bitflag check, rather than relying on the compiler to
do something potentially smart with it.

I had to shuffle the order of colors around so that the expression to
initialize the bitfield is constexpr (doesn't go over 1 << 64), but
other than that this patch should be relatively straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D150100
2023-10-02 14:37:19 +00:00
Oriol Brufau
34c3767560 Further changes required by Servo 2023-10-02 14:37:19 +00:00
David Shin
5d528ec8be style: Use Rust's ComputedTimingFunction for IPDL
Differential Revision: https://phabricator.services.mozilla.com/D149663
2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
a19674a5a7 style: Use style interpolation code for gradients
This ensures they're clamped on Animated -> sRGB conversion, and in the
future we'll have to implement different color spaces so we'll need to
use it anyways.

Differential Revision: https://phabricator.services.mozilla.com/D149792
2023-10-02 14:37:19 +00:00
Martin Robinson
64febfbe9a style: Implement CSS 'contain: style'
Add an implementation of CSS `contain: style`. This introduces two new
data structures, the ContainStyleScope and ContainStyleScopeManager.

ContainStyleScope manages one `contain: style` "world" which has its own
counter and quote lists. The contents of these lists depend on their
parent scopes, but are not affected by their children.
ContainStyleScopeManager manages a tree of scopes starting at a root
scope which is outside of any `contain: style` element.

Scopes are stored in a hash table that is keyed off of the nsIContent
which establishes the `contain: style` scope. When modifying quote or
content lists, the ContainStyleScopeManager is responsible for finding
the appropriate `contain: style` scope to modify.

Perhaps the most complex part of this is that counters and quotes have
read access to the state of counters and quotes that are in ancestor
`contain: style` scopes. In the case of counters, USE nodes that are at
the beginning of counter lists might have a counter scope that starts in
an ancestor `contain: style` scope. When nsCounterNode::SetScope() is
called, the code may look upward in the `contain: style` scope tree to
find the start of the counter scope. In the case of quotes, the first
node in the quote list must look for the state of quotes in ancestor
`contain: style` scopes.

Differential Revision: https://phabricator.services.mozilla.com/D149508
2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
ad68880627 style: Implement AccentColor/AccentColorText and remove -moz-prefixed version of the color
As per https://github.com/w3c/csswg-drafts/issues/7347.

Mostly renaming, doesn't change behavior other than exposing the new
color keywords (tested in wpt).

Differential Revision: https://phabricator.services.mozilla.com/D149876
2023-10-02 14:37:19 +00:00
David Shin
ca6ad97159 style: Refactor function parsing branches for specified::easing::TimingFunction
Differential Revision: https://phabricator.services.mozilla.com/D149756
2023-10-02 14:37:19 +00:00
Oriol Brufau
3d02b4ef90 Further changes required by Servo 2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
34373c2ac8 style: Check for allowed colors recursively in forced-colors mode
Differential Revision: https://phabricator.services.mozilla.com/D149733
2023-10-02 14:37:19 +00:00
Mike Hommey
fb95cb7993 style: Update stylo to itertools:0.10, itoa:1.0 and toml:0.5
Differential Revision: https://phabricator.services.mozilla.com/D149454
2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
5de65d9f2c style: Make viewport-relative units zoomable via "zoom text only"
They're not font relative, so it we probably want them to be zoomed.

Differential Revision: https://phabricator.services.mozilla.com/D148796
2023-10-02 14:37:19 +00:00
Boris Chiou
82d7f2154d style: Hook named scroll timelines to animation-timeline
Basically, animation-timeline could be
1. auto
2. none
3. <timeline-name>

We extend the <timeline-name> to cover both @scroll-timeline rule and
scroll-timeline-name property. We check @scroll-timeline rule first. If
it doesn't exist, we check scroll-timeline-name of the element itself,
the previous silbings, and their ancestors.

Differential Revision: https://phabricator.services.mozilla.com/D146358
2023-10-02 14:37:19 +00:00
Boris Chiou
0c709f714b style: Support scroll-timeline-axis longhand in style system
Implement "scroll-timeline-axis: block | inline | vertical | horizontal".

Differential Revision: https://phabricator.services.mozilla.com/D146019
2023-10-02 14:37:19 +00:00
Boris Chiou
8d8594ef86 style: Support scroll-timeline-name longhand in style system
Implement "scroll-timeline-name: none | <custom-ident>".

Differential Revision: https://phabricator.services.mozilla.com/D146018
2023-10-02 14:37:19 +00:00
Oriol Brufau
105050d46d Further changes required by Servo 2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
dcafbde256 style: Move fixed-point font types to Rust
Now that cbindgen and rust support const generics, it seems more simple.

This centralizes all the relevant font constants etc in rust and avoids
conversions when going from rust to C++ and vice versa.

Differential Revision: https://phabricator.services.mozilla.com/D148847
2023-10-02 14:37:19 +00:00
David Shin
949fd0e172 style: Add parsing for linear easing function and gate it behind pref
Differential Revision: https://phabricator.services.mozilla.com/D146839
2023-10-02 14:37:19 +00:00
David Shin
b31be826c4 style: Hook up linear easing calculation for servo and expose it to C++
Differential Revision: https://phabricator.services.mozilla.com/D146838
2023-10-02 14:37:19 +00:00
David Shin
6326a384a8 style: Rust side plumbing work for linear easing function
Add LinearFunction to TimingFunction. Because the linear function is a
variable list of linear stops, the enum is no longer Copyable.

Differential Revision: https://phabricator.services.mozilla.com/D146837
2023-10-02 14:37:19 +00:00
Emilio Cobos Álvarez
b6e8088e8e style: Use ColorMix for interpolated colors in the computed style rather than ComplexColorRatios
This among other things preserves the right color-space when
interpolating currentColor.

Differential Revision: https://phabricator.services.mozilla.com/D147512
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
c0ecfde11c style: Remove some dead vibrancy code
Drive-by cleanup.

Differential Revision: https://phabricator.services.mozilla.com/D147698
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
6ae56890b3 style: Improve Percentage -> LengthPercentage conversion
This doesn't change behavior because we only use them for images that
have no clamping.

Depends on D147008

Differential Revision: https://phabricator.services.mozilla.com/D147511
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
079fce37d2 style: Do hue interpolations in degrees rather than radians. r=barret
This gives us a bit more precision.

Differential Revision: https://phabricator.services.mozilla.com/D147007
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
bc1845a8f8 style: Fix hue adjustment to match the spec
The value to sum is tau, not pi. This was caught by some tests, see
https://drafts.csswg.org/css-color/#shorter

Differential Revision: https://phabricator.services.mozilla.com/D147006
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
1e5079ca00 style: Fix color-mix() percentage normalization
Differential Revision: https://phabricator.services.mozilla.com/D147005
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
6fc4355dc2 style: Implement more color-mix() color-spaces
We had code to convert between these and the latest draft supports them so...

Differential Revision: https://phabricator.services.mozilla.com/D147004
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
95e9898db4 style: Make the color interpolation code more generic
It's really piece-wise premultiplied interpolation, with a special-case
for hue, so centralize the implementation.

Differential Revision: https://phabricator.services.mozilla.com/D147003
2023-08-16 17:46:41 +02:00
Oriol Brufau
0fc3267d2e Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
f4ede10441 style: Update color-mix() syntax to match the current spec
Test expectation updates for this in the latest patch of the bug.

Differential Revision: https://phabricator.services.mozilla.com/D147002
2023-08-16 17:46:41 +02:00
Hiroyuki Ikezoe
3723a7b18d style: Parse scroll-snap-stop style and propagate it to APZ side
Depends on D146147

Differential Revision: https://phabricator.services.mozilla.com/D145850
2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
8c3553226b style: Ensure options in listbox selects are not stacking contexts by default
We could have a different property or something but this seems
reasonable as well probably.

Differential Revision: https://phabricator.services.mozilla.com/D146994
2023-08-16 17:46:41 +02:00
Oriol Brufau
9605ed7c74 Further changes required by Servo 2023-08-16 17:46:41 +02:00
Emilio Cobos Álvarez
bbf10a43b8 style: More container queries plumbing
Provide container information in computed::Context and use it to resolve
the container queries.

This still fails a lot of tests because we are not ensuring that layout
is up-to-date when we style the container descendants, but that's
expected.

Differential Revision: https://phabricator.services.mozilla.com/D146478
2023-08-16 17:46:41 +02:00
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
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
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
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
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
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
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
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
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
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
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