style: Use only Origin during the cascade, rather than CascadeLevel.

The micro-benchmark `style-attr-1.html` regressed slightly with my patch, after
the CascadeLevel size increase.

This benchmark is meant to test for the "changing the style attribute doesn't
cause selector-matching" optimization (which, mind you, keeps working).

But in the process it creates 10k rules which form a perfect path in the rule
tree and that we put into a SmallVec during the cascade, and the benchmark
spends most of the time pushing to that SmallVec and iterating the declarations
(as there's only one property to apply).

So we could argue that the regression is minor and is not what the benchark is
supposed to be testing, but given I did the digging... :)

My patch made CascadeLevel bigger, which means that we create a somewhat bigger
vector in this case. Thankfully it also removed the dependency in the
CascadeLevel, so we can stop using that and use just Origin which is one byte to
revert the perf regression.

Differential Revision: https://phabricator.services.mozilla.com/D53181
This commit is contained in:
Emilio Cobos Álvarez 2019-11-17 23:28:39 +00:00
parent 45c64a7224
commit 425025c230
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
3 changed files with 26 additions and 23 deletions

View file

@ -16,8 +16,8 @@ use crate::properties::animated_properties::AnimatedProperty;
use crate::properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection;
use crate::properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState;
use crate::properties::{self, CascadeMode, ComputedValues, LonghandId};
use crate::rule_tree::CascadeLevel;
use crate::stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
use crate::stylesheets::Origin;
use crate::timer::Timer;
use crate::values::computed::box_::TransitionProperty;
use crate::values::computed::Time;
@ -491,7 +491,7 @@ where
guard
.normal_declaration_iter()
.filter(|declaration| declaration.is_animatable())
.map(|decl| (decl, CascadeLevel::Animations))
.map(|decl| (decl, Origin::Author))
};
// This currently ignores visited styles, which seems acceptable,