Commit graph

8346 commits

Author SHA1 Message Date
Oriol Brufau
aea14a2470 Further changes required by Servo 2023-05-19 19:06:09 +02:00
Oriol Brufau
1cc44bd065 style: Will-change should only create stacking contexts / containing blocks / etc if the property it'd change would apply
As per https://drafts.csswg.org/css-will-change/#will-change.

> If any non-initial value of a property would cause the element to
> generate a containing block for absolutely positioned elements,
> specifying that property in will-change must cause the element to
> generate a containing block for absolutely positioned elements.

But in this case the transform property wouldn't apply to the element so
there's no reason to create a stacking-context.

Differential Revision: https://phabricator.services.mozilla.com/D114121
2023-05-19 19:06:09 +02:00
Oriol Brufau
60867bbe7e style: Remove unused NS_CHANGE_COLOR_IF_SAME_AS_BG
It was introduced in bug 1024930, but it is unused since.

Differential Revision: https://phabricator.services.mozilla.com/D114389
2023-05-19 19:06:09 +02:00
Oriol Brufau
516c7a304a style: Use saturating addition for math-depth
Differential Revision: https://phabricator.services.mozilla.com/D114070
2023-05-19 19:06:08 +02:00
Oriol Brufau
43cec05c04 style: Don't allow whitespace between media query operator delim tokens
Differential Revision: https://phabricator.services.mozilla.com/D113648
2023-05-19 19:06:08 +02:00
Oriol Brufau
fb9d8ddc73 style: Make sure to consume the flusher when we hit the cascade data cache
So that sheets are properly marked as committed. The issue is that we
have this "committed" optimization, to avoid doing work if somebody adds
and removes an stylesheet without us flushing in the meantime:

  https://searchfox.org/mozilla-central/rev/f018480dfed4fc583703a5770a6db9ab9dc0fb99/servo/components/style/stylesheet_set.rs#308-319

The "committed" bit is set when we consume the flusher (in each(..)).

However when we hit the cache, before this patch, we wouldn't consume
it, which means that we may fail to do some full rebuilds even though we
need them.

Fix it by making sure we call each() in that case.

We add a test (the test would show a red square before this patch, and a
lime square with the fix).

Differential Revision: https://phabricator.services.mozilla.com/D113206
2023-05-19 19:06:08 +02:00
Oriol Brufau
90781493fc style: Make the -moz-toolbar-prefers-color-scheme a tri-state
This will allow detecting the system theme, which allows fixing some of
the blocked bugs.

Note that when using the system theme we will still match light or dark
appropriately, so this shouldn't change behavior just yet.

Differential Revision: https://phabricator.services.mozilla.com/D113516
2023-05-19 19:06:08 +02:00
Oriol Brufau
ab445a02b0 style: Implement accent-color in nsNativeBasicTheme
This is a new addition for CSS UI Level 4:

  https://drafts.csswg.org/css-ui-4/#widget-accent

I want to provide feedback on some spec issues, and thought it was a
kinda neat thing to prototype (it also makes testing contrast and such
with random GTK themes easier).

For now enable for Nightly only.

Differential Revision: https://phabricator.services.mozilla.com/D112312
2023-05-19 19:06:08 +02:00
Oriol Brufau
69fc5ca9fd style: Garbage-collect event state bits
We had about 9 gaps / unused bits. I moved the devtools ones at the end
because I think we should be able to remove them (but separate bug).

Differential Revision: https://phabricator.services.mozilla.com/D113365
2023-05-19 19:06:07 +02:00
Oriol Brufau
54965bbcb9 style: Fix whitespace handling in clamp() parsing
We should just restore the state when seeing whitespace and an unknown
token like when we do when finding any other token a few lines below.

This is not an issue for most callers (it's only an issue for clamp())
because the other callers use either `parse_comma_separated()` (for
min/max), or `parse_nested_block()` (for parens / nested calc()).

Both of those functions restrict the input in such a way that
is_exhausted returns true (a few lines above) and thus we parse
successfully.

Differential Revision: https://phabricator.services.mozilla.com/D112681
2023-05-19 19:06:07 +02:00
Oriol Brufau
d12cb17d73 style: -moz-toolbar-prefers-color-scheme for dark theme detection
This adds a new @media query -moz-toolbar-prefers-color-scheme which works like
prefers-color-scheme but is set based on the browser theme rather than the OS
theme. The background colour of the toolbar is used to determine the theme
dark/light preference. This will be used for in-content common.css pages and
other UI elements that include that stylesheet in the browser-chrome through
shadow DOM.

The end result is that about: pages, infobars, and modals will now "match" the
browser theme (just light/dark mode, not LWT theming support).

Differential Revision: https://phabricator.services.mozilla.com/D111486
2023-05-19 19:06:07 +02:00
Oriol Brufau
29bca57333 Further changes required by Servo 2023-05-19 19:05:24 +02:00
Oriol Brufau
773ddf31fe style: Support the type() function in image-set
Differential Revision: https://phabricator.services.mozilla.com/D109201
2023-05-17 02:12:40 +02:00
Oriol Brufau
7567ddd262 style: Hide -moz-outline-radius behind a pref
This property does nothing since bug 315209 got implemented.

Every single user that I checked was doing the same math by hand, so
hooray for good defaults :-)

Differential Revision: https://phabricator.services.mozilla.com/D112253
2023-05-17 02:12:40 +02:00
Oriol Brufau
90a2687545 style: Add a CSS error to the console when using non-featureless :host selectors
(which would never match by definition).

Differential Revision: https://phabricator.services.mozilla.com/D111610
2023-05-17 02:12:40 +02:00
Oriol Brufau
7425f2d922 style: Enable forced-colors in UA and chrome always
Differential Revision: https://phabricator.services.mozilla.com/D112069
2023-05-17 02:12:40 +02:00
Oriol Brufau
b5dcb5c961 Further changes required by Servo 2023-05-17 02:12:21 +02:00
Oriol Brufau
e23a8bf0ad style: Add attribute names to the bloom filter
Safari does this. This reduces the runtime in the example linked from
comment 0 quite a lot (40ms on a local opt build, from ~130ms on a
release nightly build).

I added a pref because there's a slight chance of performance
regressions on pages that do not use attribute selectors, as we're now
doing more unconditional work per element (adding the attributes to the
bloom filter). But the trade-off should be worth it, I think.

Differential Revision: https://phabricator.services.mozilla.com/D111689
2023-05-16 23:40:23 +02:00
Oriol Brufau
a7ca8022d3 style: [css-pseudo] Use 'white-space: pre' by default in ::marker
Differential Revision: https://phabricator.services.mozilla.com/D107359
2023-05-16 23:40:23 +02:00
Oriol Brufau
d8993eef7e Further changes required by Servo 2023-05-16 23:40:17 +02:00
Oriol Brufau
743f213c25 style: Move moz-control-character-visibility out of mako, and remove support for gecko_pref_controlled_initial_value
No behavior change, just cleanup. Actually seem this technically _adds_ some code even
though it's a cleanup, but that's mostly because of the wrapping of the
derive list.  The resulting code is simpler (more in-line with our usual
things, so I think it's an improvement).

Differential Revision: https://phabricator.services.mozilla.com/D111551
2023-05-16 23:17:16 +02:00
Oriol Brufau
fac547276f style: Remove various image-orientation related prefs
These shipped in 77.

Differential Revision: https://phabricator.services.mozilla.com/D111550
2023-05-16 23:16:24 +02:00
Oriol Brufau
693c2f0d27 style: Remove -moz-proton-infobars media query support
Differential Revision: https://phabricator.services.mozilla.com/D110963
2023-05-16 23:15:26 +02:00
Oriol Brufau
b40f4b6fec style: Clean up text-justify, and make distribute a parse-time alias
Since it's simpler, as discussed in the CSSWG issue.

Differential Revision: https://phabricator.services.mozilla.com/D111346
2023-05-16 23:14:19 +02:00
Oriol Brufau
bbc03a2577 style: Enable Proton Urlbar
Differential Revision: https://phabricator.services.mozilla.com/D110998
2023-05-16 23:13:14 +02:00
Oriol Brufau
7bb15f19f1 style: Remove dead prefers-color-scheme: no preference code
It was removed in bug 1643656.

Differential Revision: https://phabricator.services.mozilla.com/D111461
2023-05-16 23:12:19 +02:00
Oriol Brufau
3da3d76a08 style: Clean up NPAPI plugin fallback behavior
Similifies use of EventStates and ObjectType/FallbackType enums since most states they represented are no longer valid with the removal of NPAPI plugins.  The state machine for (unsupported) plugin elements is now much simpler but still distinguishes between HTML fallbacks, fallbacks leading to a "BROKEN" state (e.g. failing to load the image the element refers to), and fallbacks that would simply lead the element to occupy an empty region.  The last type of fallback is behind a pref "layout.use-plugin-fallback" and is disabled by default.

Simplifying the state machine allows us to clean up nsObjectLoadingContent.  We also update many of the enums which refered to plugins, which would otherwise get confusing.

Differential Revision: https://phabricator.services.mozilla.com/D107158
2023-05-16 23:03:45 +02:00
Oriol Brufau
f44a6909df style: Reduce boilerplate needed to add system-metric media features
There's no reason we can't just query LookAndFeel and we need to use
sSystemMetrics. In the past, LookAndFeel queries were not cached, but
this is no longer the case, so perf wise should be pretty equivalent.

Note that we don't need the NS_SUCCEEDED checks because the default
value from GetInt if the platform doesn't support it is 0 anyways.

Differential Revision: https://phabricator.services.mozilla.com/D110805
2023-05-16 23:02:50 +02:00
Oriol Brufau
3d9eabcccb style: Convert proton pref checks from @supports rules to media features
This means that dynamic changes will be handled correctly, we can use
StaticPrefs, etc.

Differential Revision: https://phabricator.services.mozilla.com/D110816
2023-05-16 23:01:29 +02:00
Oriol Brufau
7c26fb82b1 style: add an appearance type that forces a dropshadow on menus on Windows, and uses SetWindowRgn to clip the popup to the border radius
Differential Revision: https://phabricator.services.mozilla.com/D109833
2023-05-16 23:00:33 +02:00
Oriol Brufau
8a16ba74ec Further changes required by Servo 2023-05-16 22:58:48 +02:00
Oriol Brufau
4b973885a3 style: Add the size-adjust descriptor to the style system
Differential Revision: https://phabricator.services.mozilla.com/D110022
2023-05-16 22:58:04 +02:00
Oriol Brufau
3024516019 Further changes required by Servo 2023-05-16 22:43:09 +02:00
Oriol Brufau
4d2ccaf445 style: Use a single system font definition rather than two
Follow the pattern we use for system colors.

Differential Revision: https://phabricator.services.mozilla.com/D108822
2023-05-16 13:16:53 +02:00
Oriol Brufau
7da6d525ac Further changes required by Servo 2023-05-16 13:04:55 +02:00
Oriol Brufau
1cd257d54f style: Add ascent-, descent- and line-gap-override descriptors to the style system
Differential Revision: https://phabricator.services.mozilla.com/D109287
2023-05-16 13:04:36 +02:00
Oriol Brufau
5ef832b778 style: Convert the font-stretch descriptor to use NonNegativePercentage
Depends on D109285

Differential Revision: https://phabricator.services.mozilla.com/D109286
2023-05-16 13:04:14 +02:00
Oriol Brufau
4d4fb4b414 style: Create a NonNegativePercentage type in values:specified
Differential Revision: https://phabricator.services.mozilla.com/D109285
2023-05-16 13:03:52 +02:00
Oriol Brufau
3b2eef3d7d style: Part 2 - Add page-size attribute to nsStyleStruct and property parsing
This parsing is hidden behind the pref layout.css.page-size.enabled.

It isn't ideal that we parse this as a property, but we can't treat it as a
descriptor because of compatibility issues with other browsers. There are also
outstanding spec issues related to how descriptors like page-size are cascaded,
and whether the !important specifier is valid or not.

Differential Revision: https://phabricator.services.mozilla.com/D103958
2023-05-16 13:02:53 +02:00
Oriol Brufau
cdce0d3b34 style: Part 1 - Ignore any properties which aren't valid for a style rule when generating CSS2Properties and testing propertie
To know the valid rules for each property, we need to put this information
into the Servo prop list and add an appropriate getter to Longhand/Shorthand.

Differential Revision: https://phabricator.services.mozilla.com/D105825
2023-05-16 13:02:34 +02:00
Oriol Brufau
cbf2a91ec8 style: Remove unused -moz-default-appearance values -moz-mac-vibrancy-light/dark, and the system colors of the same name
Starting with macOS 10.14, the generic light/dark vibrancy is deprecated, and semantic vibrancy names are preferred.
If we ever need more vibrancy, we can add new values with semantic names.

Depends on D107910

Differential Revision: https://phabricator.services.mozilla.com/D108152
2023-05-16 13:02:17 +02:00
Oriol Brufau
261dcf1f6d Further changes required by Servo 2023-05-16 13:01:58 +02:00
Oriol Brufau
b0a1eaebaa style: Respect system colors in the color and background-color properties
The reason why this doesn't work is because these styles come from
datetimebox.css, which is really an author style.

We could special-case these elements, but the approach that the CSSWG resolved
on for the new forced-colors spec is to respect system colors specified by
authors, see:

https://drafts.csswg.org/css-color-adjust-1/#forced-colors-properties

So this moves us towards that, and fixes the issue nicely.

Differential Revision: https://phabricator.services.mozilla.com/D108321
2023-05-16 13:01:35 +02:00
Oriol Brufau
ed19da405f style: Invalidate a bit more aggressively when a pseudo-element matches, in order to also invalidate the cached pseudo-styles on the parent
This should probably be fine. If it becomes a perf issue somehow we can
implement the RESTYLE_PSEUDOS hint or what not.

Differential Revision: https://phabricator.services.mozilla.com/D108338
2023-05-16 13:01:18 +02:00
Oriol Brufau
1be19485bb style: Make -moz-accent-color reflect the windows accent color
And remove the windows-specific versions of this color.

Also fix the hard-coded defaults by the colors I get in the default windows
theme.

Differential Revision: https://phabricator.services.mozilla.com/D108325
2023-05-16 13:00:51 +02:00
Oriol Brufau
60e206143c Further changes required by Servo 2023-05-16 13:00:18 +02:00
Oriol Brufau
060d74ba3b style: Share CascadeData instances across ShadowRoots
This should be both a memory and speed win for pages using a lot of
Shadow DOM.

In order to make the cache properly work we need to start keying media query
results on the actual StyleSheetContents, as that's what we share on Gecko, but
that should all be fine.

Differential Revision: https://phabricator.services.mozilla.com/D107266
2023-05-16 13:00:08 +02:00
Oriol Brufau
11153c63fa style: Make the cascade data cache generic
We're going to use it both for UA sheets and for author styles in Shadow
DOM.

Differential Revision: https://phabricator.services.mozilla.com/D107265
2023-05-16 12:59:46 +02:00
Oriol Brufau
b38517757f style: Remove layout.css.ruby.position-alternate.enabled pref
Differential Revision: https://phabricator.services.mozilla.com/D114044
2023-05-16 12:59:19 +02:00
Oriol Brufau
17ae374c65 style: part 1 - Support parsing ruby-position: alternate
Differential Revision: https://phabricator.services.mozilla.com/D107382
2023-05-16 12:56:06 +02:00