Disable applicable declarations cache for elements with a style attribute.

The cache is never effective in this case since a style attribute
adds to the set of applicable declarations.

This also avoid avoids the cache giving out-dated (incorrect) results
when `PropertyDeclarationBlock` becomes mutable in a later commit.
This is sufficient for now since CSSOM is only implemented for
`Element.style`. When StyleRule mutation is added,
some additional mechanism (such as evicting the cache) will be needed.
This commit is contained in:
Simon Sapin 2016-10-04 15:01:44 +02:00
parent aeb3efda1f
commit d4f704cad2

View file

@ -502,7 +502,13 @@ trait PrivateMatchMethods: TNode {
-> Arc<ComputedValues>
where Ctx: StyleContext<'a>
{
let mut cacheable = true;
// Dont cache applicable declarations for elements with a style attribute.
// Since the style attribute contributes to that set, no other element would have the same set
// and the cache would not be effective anyway.
// This also works around the test failures at
// https://github.com/servo/servo/pull/13459#issuecomment-250717584
let has_style_attribute = self.as_element().map_or(false, |e| e.style_attribute().is_some());
let mut cacheable = !has_style_attribute;
let shared_context = context.shared_context();
if animate_properties {
cacheable = !self.update_animations_for_cascade(shared_context,