Commit graph

8983 commits

Author SHA1 Message Date
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
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
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
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
b6db94bdf5 Further changes required by Servo 2023-11-21 15:36:35 +01:00
Tiaan Louw
8c1c4073e2 style: Convert RGBA to AbsoluteColor for computed/animated/resolved CSS colors
Computed color values will not be in the correct format, closer to the
one specified by the author.  This also means that colors accross the
code are stored now as AbsoluteColor or StyleAbsoluteColor.  This allows
color space/gamut information to be available for use.

Some animation related test failures had to be changed, because colors
now has greater precision.  Animated a color now causes a lot more
animation updates, which was not initially expected.  See the bug for
discussion.

Differential Revision: https://phabricator.services.mozilla.com/D171021
2023-11-21 15:36:35 +01:00
Oriol Brufau
61af8fb56d
Enable new color functions from CSS Color 4 (#30752)
I will need to do most of the work anyways during the style updates,
so by enabling this it will be easier to detect mistakes.

Also, canvas colors are now parsed as <color>, precisely to support
these new features. This is according to the HTML spec:
https://html.spec.whatwg.org/multipage/infrastructure.html#parsed-as-a-css-color-value
2023-11-20 16:15:43 +00:00
Oriol Brufau
ecc6ba79b0 Further changes required by Servo 2023-11-06 09:35:57 +01:00
CanadaHonk
a8fef9d4f2 style: Serialize NaN and infinity angles as per spec
`NaN`, `infinity`, and `-infinity` angles should be specially serialized.

Also fixed a few relevant WPT tests which did not follow spec.
(see https://github.com/web-platform-tests/wpt/pull/38825)

Adjusted WPT test expectations, 40 newly pass 🎉

Differential Revision: https://phabricator.services.mozilla.com/D171658
2023-11-06 09:35:57 +01:00
Oriol Brufau
7b28572309 Further changes required by Servo 2023-11-06 09:35:57 +01:00
Boris Chiou
a41194a318 style: Make <ray-size> optional and default to 'closest-side'
Per the spec update, the new syntax is:
  `ray() = ray( <angle> && <ray-size>? && contain? )`
And for `<ray-size>`:
  "If no <ray-size> is specified it defaults to closest-side."

So `<ray-size>` is optional and we omit it if it's default value, for
serialization.

By the way, offset=* properties are supported only in Gecko, so we don't
need a servo function to check the preference.

Differential Revision: https://phabricator.services.mozilla.com/D171625
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
860a6c2fe6 style: Move legacy -moz-box collapse to its own CSS property
Make display: -moz-box's visibility: collapse handling switchable by its
own CSS property.

Longer term maybe we should switch the front-end away from visibility:
collapse altogether (there are some alternatives), but for now this will
allow to move the front-end to switch to modern `display: flex` while
keeping `visibility: collapse` work as in -moz-box.

Differential Revision: https://phabricator.services.mozilla.com/D171472
2023-11-06 09:35:57 +01:00
Oriol Brufau
34eb94c71e Further changes required by Servo 2023-11-06 09:35:57 +01:00
Em Zhan
21d1bdeb9b style: Implement CSS exponential functions
Differential Revision: https://phabricator.services.mozilla.com/D170842
2023-11-06 09:35:57 +01:00
Boris Chiou
0b20b343e6 style: Support offset-position in the style system
Also, we make it animatable but don't apply it to the motion transform and
don't run it on the compositor for now (so it works for getComputedStyle but
doesn't have rendering result).

Per spec: https://w3c.github.io/csswg-drafts/css-values/#calc-serialize,
we tweak the WPT to let calc() serialize the percentage first, and maintain
zero-valued terms, i.e. 0%. (We are doing the same thing as
offset-anchor, so it should be fine with other browsers.)

Besides, I tweak the serialization of shorthand a little bit so we match
the implementation of WebKit.

Differential Revision: https://phabricator.services.mozilla.com/D170972
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
1b40d30f88 style: Fix appearance-cssom-001.html
* Remove some legacy appearance aliases that other engines don't
    implement.

  * Allow to pass with unimplemented <compat-auto> values, since per the
    spec the idea of these is to get them removed, see
    https://github.com/w3c/csswg-drafts/issues/8506 for the ones we don't
    implement.

  * Also allow the `-moz-` prefix to be implemented, because we can't
    quite get rid of it (people use it to remove the <input type=number>
    buttons with -moz-appearance: textfield and so on), and the
    alternative is to implement a bunch of non-standard ::-webkit-
    pseudo-elements.

Differential Revision: https://phabricator.services.mozilla.com/D171243
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
9a37424dca style: Make -moz-box-layout: flex default, and clean-up CSS
Now it's on by default everywhere, so all this is not needed. No behavior
change effectively since the xul.css bits being removed effectively achieve the
same.

Differential Revision: https://phabricator.services.mozilla.com/D170944
2023-11-06 09:35:57 +01:00
Oriol Brufau
4da83f238a Further changes required by Servo 2023-11-06 09:35:57 +01:00
Tiaan Louw
1c3aafd9d2 style: Use abstract color parser
In stead of having the css parser construct a color in it's own format
and then converting it to what Gecko needs to perform operations, we now
construct a Gecko friendly color type directly.

Differential Revision: https://phabricator.services.mozilla.com/D170187
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
6e128b6512 style: Don't reject negative resolutions either
This unveils an issue with image-set() tests, which expect 0x to not
parse (inconsistently with media queries).

Fix the test, since the spec doesn't restrict the range of <resolution>
values (and more importantly, it shouldn't allow open ranges).

Differential Revision: https://phabricator.services.mozilla.com/D170762
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
d68bd45cc3 style: Don't reject negative values at parse time in media features
Clean-up some other test expectations while at it.

Differential Revision: https://phabricator.services.mozilla.com/D170677
2023-11-06 09:35:57 +01:00
CanadaHonk
4ed0f518fb style: Fix parsing nested image-set funcs as valid
Nested image-set CSS functions should fail to parse as per spec.

WPT tests (2 newly pass):
a2154e3f97/css/css-images/image-set/image-set-parsing.html (L223-L239)

Differential Revision: https://phabricator.services.mozilla.com/D170829
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
75b3bf1842 style: Layer should be an invalid media type
Differential Revision: https://phabricator.services.mozilla.com/D170676
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
fa9fa00977 style: Remove -moz-image-region support from layout
There are no users of non-auto values, so we can just simplify some code and
remove the property.

Differential Revision: https://phabricator.services.mozilla.com/D170010
2023-11-06 09:35:57 +01:00
Oriol Brufau
e0e5a22614 Further changes required by Servo 2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
1a3b32a248 style: Expose scrollbar-inline-size as a chrome-only environment variable
After the previous patches this is rather straight-forward.

Reviewed in: https://phabricator.services.mozilla.com/D168148
2023-11-06 09:35:57 +01:00
Emilio Cobos Álvarez
89e01f1df6 style: Expose chrome-only environment variables to all chrome:// documents, not just chrome-docshells
This will be necessary to make the new env var testable.

Reviewed in: https://phabricator.services.mozilla.com/D168148
2023-11-06 09:35:57 +01:00
David Shin
017ab0cb24 style: linear() easing function should not consider less than 2 linear stop arguments valid
Latest spec no longer handles `linear() == linear` and `linear(<single value>) == <single value>`.

Differential Revision: https://phabricator.services.mozilla.com/D169955
2023-11-06 09:35:57 +01:00
Oriol Brufau
d76fe81600 Further changes required by Servo 2023-11-06 09:35:57 +01:00
Fred Chasen
9d41dd1ad9 style: Add forced-color-adjust property
Adds the forced-color-adjust property and ForcedColorAdjust keywords.
Updates tweak_when_ignoring_colors to check for `none` value of that property when determining if a color adjustment in needed.
Adds a check for `none` when styling selections to make sure they can be styled in forced color modes.

Differential Revision: https://phabricator.services.mozilla.com/D169000
2023-11-06 09:35:57 +01:00