Skip to content

Commit

Permalink
Bug 1840478 - Handle inherits flag and initial value for custom prope…
Browse files Browse the repository at this point in the history
…rties. r=emilio,zrhoffman

The CSS Properties and Values API allows to register CSS properties that
can be either inherited or non-inherited, and which can also have
initial values specified [1].

In [2], the representation of computed value for custom properties was
changed to a pair of CustomPropertiesMaps: one map which is ref-counted
(for properties unregistered or registered as inherited) and one which
is not (for properties registered as non-inherited). The latter map
is currently always None (i.e. all custom properties are handled as
inherited) and several parts of the code assume this condition holds.

This patch instead ensures that values for custom properties on a node
are properly placed in the inherit or non_inherit map according to the
inherits flag. Initial values for registered properties are taken
into account and missing implementations of functions assuming
non_inherited==None is completed.

In order to minimize the size of the maps, absent values for
non-inherited properties are interpreted as initial values during var
substitution or retrieval of computed values (for non-inherited
properties). This is used for `unset` and `initial` keywords while
a copy of the parent's value is used for `inherit`.

Last but not least, `CustomPropertiesBuilder` tries to perform lazy
copy of the inherited style, postponing actual deep clone when
necessary or falling back to a shallow copy when possible [3].
This is generalized a bit when the document contains custom properties
registered as non-inherited and current optimizations are preserved as
is for pages containing only non-registered custom properties. This
could be further improved later [4].

[1] https://drafts.css-houdini.org/css-properties-values-api-1/
[2] https://hg.mozilla.org/mozilla-central/rev/8a7d9524a1b9
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=1840478
[4] https://bugzilla.mozilla.org/show_bug.cgi?id=1855887

Differential Revision: https://phabricator.services.mozilla.com/D188812

UltraBlame original commit: 6453cd78e4f187bc198e83900dd9937c3cc6d0fc
  • Loading branch information
marco-c committed Sep 30, 2023
1 parent 15e7df6 commit 6b8e0e0
Show file tree
Hide file tree
Showing 45 changed files with 2,927 additions and 2,198 deletions.
11 changes: 11 additions & 0 deletions layout/style/nsComputedDOMStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2911,6 +2911,17 @@ CSS_CUSTOM_NAME_PREFIX_LENGTH
Servo_GetCustomPropertyValue
(
mComputedStyle
mPresShell
-
>
StyleSet
(
)
-
>
RawData
(
)
&
name
&
Expand Down
Loading

0 comments on commit 6b8e0e0

Please sign in to comment.