gecko-dev/servo/ports/geckolib
Frederic Wang 138e00de8e Bug 1855629 - Handling of custom properties when enumerating getComputedStyle(). r=emilio
After bug 1840478, non-inherited custom properties using their initial
values are represented as absent from `ComputedCustomProperties` in
order to save memory. Wherever the values of such properties are
requested, it is necessary to fallback to any registered initial value.
However, this makes difficult to properly enumerate custom properties
for exposure via the `CSSStyleDeclaration.item()` API and indeed our
current implementation only exposes the properties actually present in
`ComputedCustomProperties`.

Additionally, such a representation conflicts with pre-existent
representation of guaranteed-invalid values as absent values, causing
some issues e.g. bad handling of invalid at computed-value time [1] [2].

This patch changes `ComputedCustomProperties` so that registered initial
values are always stored in the `non_inherited` map, immediately fixing
the issue with `CSSStyleDeclaration.item()` and preparing follow-up
work on guaranteed-invalid values.

To avoid excessive increase of memory usage, the `non_inherited` map
becomes ref-counted. The associated Stylist contains an up-to-date
ComputedCustomProperties with registered custom properties that have
initial values, and the `non_inherited` map can generally just be
shallow-cloned from it.

A new test `get-computed-style-enumeration.html` is added to make sure
custom properties are correctly exposed when enumerating
`CSSStyleDeclaration` as a list. A similar but more restricted version
already exists: `cssstyledeclaration-registered-custom-properties.html`.
Two test cases are also added to `determine-registration.html` in order
to cover some issue previously detected during the review of
`get_custom_property_initial_values`.

[1] https://drafts.csswg.org/css-variables-2/#invalid-at-computed-value-time
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1855946

Differential Revision: https://phabricator.services.mozilla.com/D189999
2023-10-06 12:03:16 +00:00
..
tests
Cargo.toml Bug 1852568 - Update cssparser. r=tlouw,supply-chain-reviewers 2023-09-12 16:03:44 +00:00
cbindgen.toml Bug 1854441 - Initial zoom property implementation. r=layout-reviewers,jfkthame 2023-09-28 10:58:51 +00:00
error_reporter.rs
glue.rs Bug 1855629 - Handling of custom properties when enumerating getComputedStyle(). r=emilio 2023-10-06 12:03:16 +00:00
lib.rs
stylesheet_loader.rs