Commit graph

47158 commits

Author SHA1 Message Date
Oriol Brufau
9ce567d7fe Further changes required by Servo 2023-11-21 15:36:35 +01:00
CanadaHonk
1ac62a4ce8 style: Implement supports() syntax for @import rules
Implemented supports conditions using supports() in @import rules as per
CSS Cascading and Inheritance Level 4.

Locked behind new pref, layout.css.import-supports.enabled,
only enabled in nightlies in this patch.

Also added new WPT tests for @import supports() generally.

Spec: https://drafts.csswg.org/css-cascade-4/#conditional-import
WPT tests: https://wpt.fyi/results/css/css-cascade/import-conditions.html

Differential Revision: https://phabricator.services.mozilla.com/D172622
2023-11-21 15:36:35 +01:00
Oriol Brufau
b844a4e992 Further changes required by Servo 2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
0709e13446 style: Allow to use ThinVec/nsTArray in the style crate
This allows to clean-up the previous patches by using a single ThinVec
(which stores length / capacity along with the allocation).

Differential Revision: https://phabricator.services.mozilla.com/D175029
2023-11-21 15:36:35 +01:00
Jonathan Kew
a2df8f7ea5 style: Accept a comma-separated list of language codes in the :lang() pseudo
This is the other extension to the :lang() pseudo-class in  Selectors-4.
(Also supported in Safari.)

Depends on D174999

Differential Revision: https://phabricator.services.mozilla.com/D175000
2023-11-21 15:36:35 +01:00
CanadaHonk
13e2d10474 style: Implement inverted-colors media feature
Implemented the inverted-colors media feature from Media Queries Level 5
for all platforms.
Spec: https://drafts.csswg.org/mediaqueries-5/#inverted

Platform specific implementations:
- Windows: Checks system color filter setting, and if it is inverted
  (note: Windows does not live update due to having to read a reg key)
- Mac: Checks dedicated inverted accessibility system setting
- Android: Checks dedicated inverted system setting
- Linux: No GTK API exposes anything like it so always none

Locked behind new pref `layout.css.inverted-colors.enabled`,
always off by default for now.

Also added new WPT tests (none previously).

Other browsers:
- WebKit: shipped since Safari 9.1 (Jan 2017)
- Blink: no signal

Test page: https://goose.icu/inverted-colors

Differential Revision: https://phabricator.services.mozilla.com/D173201
2023-11-21 15:36:35 +01:00
Zach Hoffman
dcfef6cdbb style: Remove MatchingContext mutability FIXME that no longer applies
Differential Revision: https://phabricator.services.mozilla.com/D175028
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
5dd35ac6cd style: Simplify NAC setup
Make all UA widgets also NAC.

Keep the UA widget flag but break at anonymous subtree boundaries, so
that only nodes inside the UA widget directly (and not NAC from those)
get the flag.

This is important because two callers depend on this difference:

  * The style system, since we still want to match content rules from
    stylesheets in the UA widget. We also match user rules, which is a
    bit sketchy, but that was the previous behavior, will file a
    follow-up for that.

  * The reflector code, since we want the scope for UA widgets to not
    include the NAC nodes inside that UA widget. nsINode::IsInUAWidget
    got it wrong.

After this patch, ChromeOnlyAccess is equivalent to
IsInNativeAnonymousSubtree, so we should probably unify the naming.
That's left for a follow-up patch because I don't have a strong
preference.

Differential Revision: https://phabricator.services.mozilla.com/D174310
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
0917ee3f9b style: Fix some spec links
Trivial, comment-only

Differential Revision: https://phabricator.services.mozilla.com/D174474
2023-11-21 15:36:35 +01:00
Mike Hommey
38faddd687 style: Update bindgen to 0.64
Differential Revision: https://phabricator.services.mozilla.com/D174054
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
0748fd9582 style: Remove a bunch of now completely dead XUL layout code
And some related tests.

A bunch of -moz-box* properties are web exposed, so I'll file a
follow-up for hiding them.

Differential Revision: https://phabricator.services.mozilla.com/D173819
2023-11-21 15:36:35 +01:00
CanadaHonk
46a569ef45 style: Implement scripting media feature
Implemented the scripting media feature.

Not locked behind a pref as it does not do anything new or particularly
give new data which could be used for fingerprinting (see <noscript>,
etc).

Also added new WPT tests (none previously). Not supported in any other
browsers yet.

Test page: https://goose.icu/media-scripting

Differential Revision: https://phabricator.services.mozilla.com/D172995
2023-11-21 15:36:35 +01:00
CanadaHonk
d2217be803 style: CSS comp funcs should handle NaN contagiously
If NaN is given as any input to CSS comp funcs (min/max/clamp), it
should return NaN. Does not cover simplification (see Bug 1820412).

Adjusted WPT test expectations, 18 newly pass. 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171659
2023-11-21 15:36:35 +01:00
Boris Chiou
191c7cdb78 style: Remove layout.css.d-property.enabled
This feature was shipped in Fx97, and it seems we don't need this pref
anymore.

Differential Revision: https://phabricator.services.mozilla.com/D173591
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
78c1c53ccd style: Restyle pseudo-elements as well on part attribute changes
Refactor a bit the code to unify how we deal with this conditional
restyling (we had similar code for
MustCascadeChildrenIfInheritResetStyle).

Differential Revision: https://phabricator.services.mozilla.com/D172890
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
398df68d38 style: Minor clean ups on top of the previous patch
Remove now dead Mul implementations. Use Self rather than the whole type
to shrink a bit the code.

Differential Revision: https://phabricator.services.mozilla.com/D173143
2023-11-21 15:36:35 +01:00
Tiaan Louw
241e6e256f style: Refactor mul_by fn into map fn
Refactor the mul_by function on leafs into a more generic map function
that can be used for more operations like abs, signum and mul.

Differential Revision: https://phabricator.services.mozilla.com/D172936
2023-11-21 15:36:35 +01:00
Boris Chiou
a5f696b90d style: Use auto as the initial value for view-timeline-inset
Per the proposal in https://github.com/w3c/csswg-drafts/issues/7747,
we change view-timeline-inset to have an initial value of auto.

Differential Revision: https://phabricator.services.mozilla.com/D173487
2023-11-21 15:36:35 +01:00
Cathie Chen
6db3b1158c style: Update UA stylesheet for popover
Differential Revision: https://phabricator.services.mozilla.com/D172700
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
4d62fec376 style: Reuse declaration block with SVG presentation attributes
Ideally we'd only update the attributes that actually changed. That's a
bit more work I can try to look into, but this and bug 1823686 should
improve things here.

Differential Revision: https://phabricator.services.mozilla.com/D173162
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
7d12331626 style: Optimize [id=foo] as #foo in querySelector/All
This page seems to rely on this optimization being present. Optimizing
it is straight-forward. Why do they do that instead of using the #foo
syntax? Who knows.

Differential Revision: https://phabricator.services.mozilla.com/D173148
2023-11-21 15:36:35 +01:00
Zach Hoffman
536b3d603b style: Check that the lowercase attribute is different before trying to track it
Differential Revision: https://phabricator.services.mozilla.com/D173112
2023-11-21 15:36:35 +01:00
Oriol Brufau
4804e8dd94 Further changes required by Servo 2023-11-21 15:36:35 +01:00
Tiaan Louw
f3402e6144 style: Color interpolation takes none keyword into account
Now that the none keyword is available, we can take it into account when
interpolating colors following the rules from the spec here:

https://drafts.csswg.org/css-color-4/#interpolation-missing

Differential Revision: https://phabricator.services.mozilla.com/D172666
2023-11-21 15:36:35 +01:00
Oriol Brufau
11414d0c94 Further changes required by Servo 2023-11-21 15:36:35 +01:00
Tiaan Louw
fb4501c5b4 style: Allow 'none' keyword in color components
Make use of the new changes in the cssparser that allows 'none' keywords
in color components where allowed.  We store the none values as 0.0 (as
per the spec) and mark the components with the flags. This way we don't
have to check anything on the components before doing calculations.

As this is the last part intended to be released for the new [color-4]
changes, I've also enabled the changes on nightly.

Differential Revision: https://phabricator.services.mozilla.com/D170208
2023-11-21 15:36:35 +01:00
David Shin
3756e3b027 style: :has relative selector matching, with no caching/filtering
Differential Revision: https://phabricator.services.mozilla.com/D172019
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
a68766197f style: Add (unused for now) parsing for support conditions in @import
You can use this as:

  input.try_parse(SupportsCondition::parse_for_import).ok()

Or so.

Differential Revision: https://phabricator.services.mozilla.com/D172668
2023-11-21 15:36:35 +01:00
Oriol Brufau
3914ff627e Further changes required by Servo 2023-11-21 15:36:35 +01:00
Zach Hoffman
356e886d26 style: Record attribute dependencies within the selector list of :nth-child(... of <selector list>)
There are separate filters for IDs, classes, attribute local names, and
element state.

Also, we invalidate siblings of elements matched against the selector
list of :nth-child(... of <selector list>) by marking matched elements
with NODE_HAS_SLOW_SELECTOR_NTH_OF.

The only remaining invalidation case invalidation case is
`:nth-child(An+B of :has())` (bug 1818155), which should not block
shipping `layout.css.nth-child-of.enabled`, because :has(...) is still
being implemented (bug 418039).

Depends on D172352

Differential Revision: https://phabricator.services.mozilla.com/D171936
2023-11-21 15:36:35 +01:00
Oriol Brufau
c7f8845665 Further changes required by Servo 2023-11-21 15:36:35 +01:00
Zach Hoffman
744b21e72a style: Apply selector flags to the shadow root
Because restyle events cannot be posted for non-element nodes like the
shadow root, a child's siblings are restyled directly if its parent has
NODE_HAS_SLOW_SELECTOR or NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS but that
parent is the shadow root.

Drive-by, but braces were also added to some single-line "if" statements
in RestyleManager.

Differential Revision: https://phabricator.services.mozilla.com/D172352
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
11a04d9d93 style: Support rendering content: <gradient> images
We implemented support for list-style-image anyways.

Differential Revision: https://phabricator.services.mozilla.com/D172343
2023-11-21 15:36:35 +01:00
CanadaHonk
0e5eca1f00 style: Implement prefers-reduced-transparency media query
Implemented the prefers-reduced-transparency media query for all
platforms.

Windows and Mac have specific settings which are used, others (Android
and Linux/GTK) have it enabled if prefers-reduced-motion is also enabled
as there is no dedicated setting to check.

Locked behind new pref `layout.css.prefers-reduced-transparency.enabled`,
off by default always for now.

Also added new WPT tests (none previously).

Demo video: https://goose.icu/firefox_prt.mp4
Test page: https://goose.icu/prefers-reduced-transparency

Differential Revision: https://phabricator.services.mozilla.com/D172424
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
9509f84bc0 style: Simplify/remove a couple other length operations
Differential Revision: https://phabricator.services.mozilla.com/D172430
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
52f1a680d5 style: Fix a couple minor issues with the previous patch
Having unused imports and undocumented functions trigger warnings that
don't build in automation.

Differential Revision: https://phabricator.services.mozilla.com/D172429
2023-11-21 15:36:35 +01:00
CanadaHonk
571f8a8dd5 style: Serialize NaN and infinity lengths
Lengths using NaN and infinity are now serialized properly with some
improvements to computed values as well.

Also added a few minor new relevant WPT tests.
35 WPT tests newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D172183
2023-11-21 15:36:35 +01:00
CanadaHonk
2dad1f0fd7 style: Infinity angles should degenerate compute to 0
Also adjusted WPT tests to always expect deg like similar past changes.

WPT tests: https://github.com/web-platform-tests/wpt/blob/master/css/css-values/calc-infinity-nan-computed.html#L57-L71

Differential Revision: https://phabricator.services.mozilla.com/D172401
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
23d6ecfc57 style: Rustfmt recent changes to calc.rs
Differential Revision: https://phabricator.services.mozilla.com/D172339
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
2c986f0005 style: Add resolution support to calc()
Differential Revision: https://phabricator.services.mozilla.com/D172338
2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
76e8eeda72 style: Make image-set without valid images render nothing
Differential Revision: https://phabricator.services.mozilla.com/D172341
2023-11-21 15:36:35 +01:00
Boris Chiou
29105eeb49 style: Re-define CoordPair struct
Redefine/Rename the fields in CoordPair to align the data members of gfx::Point.

Differential Revision: https://phabricator.services.mozilla.com/D5903
2023-11-21 15:36:35 +01:00
Ziran Sun
29a9f0da46 style: Add popover attribute and part of basic popover functionality
Starts to add part of the basic functionality for popover. Including
[1] :open & :closed CSS pseudo class
[2] showPopover(), hidePopover() and togglePopover() interfaces. Much of the
functionality is still to-do.
[3] PopoverData interface

Differential Revision: https://phabricator.services.mozilla.com/D171719
2023-11-21 15:36:35 +01:00
CanadaHonk
3ded7ff273 style: Parse and serialize NaN and infinity times correctly
Times like NaN and infinity are now parsed and serialized correctly.

Rewrote time to use `calc_clamping_mode` instead of `was_calc` to
stop some parse-time clamping which broke these values.

Adjusted WPT test expectations, 19 newly pass 🎉

Also added a new WPT test to cover a missing edge case:
`calc(1<unit> * NaN)` -> `calc(NaN * 1<canonical_unit>)`

The very similar angle tests do this already for angle's units.

Differential Revision: https://phabricator.services.mozilla.com/D171911
2023-11-21 15:36:35 +01:00
Oriol Brufau
9a6b46aebd Further changes required by Servo 2023-11-21 15:36:35 +01:00
Boris Chiou
3390b77281 style: Create timeline objects when mutating scroll-timeline property
And so we can lookup the timeline from TimelineCollection.

Differential Revision: https://phabricator.services.mozilla.com/D169273
2023-11-21 15:36:35 +01:00
Oriol Brufau
532d769e27 Further changes required by Servo 2023-11-21 15:36:35 +01:00
Emilio Cobos Álvarez
cfb7a9a108 style: Be consistent for which URIs we expose chrome rules
Differential Revision: https://phabricator.services.mozilla.com/D171640
2023-11-21 15:36:35 +01:00
Oriol Brufau
664e44385e Further changes required by Servo 2023-11-21 15:36:35 +01:00
David Shin
f7b29ac432 style: Parsing for relative selectors in :has()
Differential Revision: https://phabricator.services.mozilla.com/D171358
2023-11-21 15:36:35 +01:00