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