style: Cache substituted values from shorthand properties during the cascade.

This brings the time down to 1.6ms from 4.8ms on the test-case in the
bug. This should be improvable too, but I think this is a nice
improvement for regular styling as well.

Differential Revision: https://phabricator.services.mozilla.com/D105187
This commit is contained in:
Emilio Cobos Álvarez 2021-02-17 00:21:36 +00:00
parent 1b18b06186
commit b0d05d1a5d
4 changed files with 96 additions and 54 deletions

View file

@ -367,6 +367,7 @@ impl AnimationValue {
}
},
PropertyDeclaration::WithVariables(ref declaration) => {
let mut cache = Default::default();
let substituted = {
let custom_properties =
extra_custom_properties.or_else(|| context.style().custom_properties());
@ -376,6 +377,7 @@ impl AnimationValue {
custom_properties,
context.quirks_mode,
context.device(),
&mut cache,
)
};
return AnimationValue::from_declaration(