diff --git a/src/components/main/css/matching.rs b/src/components/main/css/matching.rs index 2c3db7894a5..3b883a315fa 100644 --- a/src/components/main/css/matching.rs +++ b/src/components/main/css/matching.rs @@ -131,7 +131,7 @@ impl<'a> Hash for ApplicableDeclarationsCacheQuery<'a> { static APPLICABLE_DECLARATIONS_CACHE_SIZE: uint = 32; pub struct ApplicableDeclarationsCache { - pub cache: SimpleHashCache>, + cache: SimpleHashCache>, } impl ApplicableDeclarationsCache { @@ -149,7 +149,7 @@ impl ApplicableDeclarationsCache { } fn insert(&mut self, declarations: &[MatchedProperty], style: Arc) { - drop(self.cache.insert(ApplicableDeclarationsCacheEntry::new(declarations), style)) + self.cache.insert(ApplicableDeclarationsCacheEntry::new(declarations), style) } } @@ -340,12 +340,11 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> { let cacheable; match parent_style { Some(ref parent_style) => { - let cached_computed_values; let cache_entry = applicable_declarations_cache.find(applicable_declarations); - match cache_entry { - None => cached_computed_values = None, - Some(ref style) => cached_computed_values = Some(&**style), - } + let cached_computed_values = match cache_entry { + None => None, + Some(ref style) => Some(&**style), + }; let (the_style, is_cacheable) = cascade(applicable_declarations, shareable, Some(&***parent_style), diff --git a/src/components/style/properties.rs.mako b/src/components/style/properties.rs.mako index fdd98a5ef08..bbd4d53a887 100644 --- a/src/components/style/properties.rs.mako +++ b/src/components/style/properties.rs.mako @@ -1653,10 +1653,10 @@ fn cascade_with_cached_declarations(applicable_declarations: &[MatchedProperty], for declaration in sub_list.declarations.iter() { match *declaration { % for style_struct in STYLE_STRUCTS: - % if style_struct.inherited: - % for property in style_struct.longhands: - % if property.derived_from is None: - ${property.camel_case}Declaration(ref declared_value) => { + % for property in style_struct.longhands: + % if property.derived_from is None: + ${property.camel_case}Declaration(ref declared_value) => { + % if style_struct.inherited: if seen.get_${property.ident}() { continue } @@ -1681,28 +1681,32 @@ fn cascade_with_cached_declarations(applicable_declarations: &[MatchedProperty], }; style_${style_struct.ident}.make_unique_experimental() .${property.ident} = computed_value; + % endif - % if property.name in DERIVED_LONGHANDS: - % for derived in DERIVED_LONGHANDS[property.name]: - style_${derived.style_struct.ident} - .make_unique_experimental() - .${derived.ident} = - longhands::${derived.ident} - ::derive_from_${property.ident}( - computed_value, - context); - % endfor + % if property.name in DERIVED_LONGHANDS: + % if not style_struct.inherited: + // Use the cached value. + let computed_value = style_${style_struct.ident} + .${property.ident}.clone(); % endif - } - % else: - ${property.camel_case}Declaration(_) => { - // Do not allow stylesheets to set derived properties. - } - % endif - % endfor - % endif + % for derived in DERIVED_LONGHANDS[property.name]: + style_${derived.style_struct.ident} + .make_unique_experimental() + .${derived.ident} = + longhands::${derived.ident} + ::derive_from_${property.ident}( + computed_value, + context); + % endfor + % endif + } + % else: + ${property.camel_case}Declaration(_) => { + // Do not allow stylesheets to set derived properties. + } + % endif + % endfor % endfor - _ => {} } } } diff --git a/src/components/util/cache.rs b/src/components/util/cache.rs index 043d0c2b0d7..768b015bc44 100644 --- a/src/components/util/cache.rs +++ b/src/components/util/cache.rs @@ -216,7 +216,7 @@ impl SimpleHashCache { impl Cache for SimpleHashCache { fn insert(&mut self, key: K, value: V) { let bucket_index = self.bucket_for_key(&key); - *self.entries.get_mut(bucket_index) = Some((key, value)) + *self.entries.get_mut(bucket_index) = Some((key, value)); } fn find(&mut self, key: &K) -> Option { diff --git a/src/test/ref/basic.list b/src/test/ref/basic.list index 408ef854596..fe430010bd1 100644 --- a/src/test/ref/basic.list +++ b/src/test/ref/basic.list @@ -18,6 +18,7 @@ == border_style_none_a.html border_style_none_b.html == borders_a.html borders_b.html == acid1_a.html acid1_b.html +== text_decoration_cached.html text_decoration_cached_ref.html # text_decoration_propagation_a.html text_decoration_propagation_b.html # inline_text_align_a.html inline_text_align_b.html == font_size_em.html font_size_em_ref.html diff --git a/src/test/ref/text_decoration_cached.html b/src/test/ref/text_decoration_cached.html new file mode 100644 index 00000000000..effd1359fe0 --- /dev/null +++ b/src/test/ref/text_decoration_cached.html @@ -0,0 +1,14 @@ + + + + + text-decoration cache test + + + + test + test + + diff --git a/src/test/ref/text_decoration_cached_ref.html b/src/test/ref/text_decoration_cached_ref.html new file mode 100644 index 00000000000..04a222264c3 --- /dev/null +++ b/src/test/ref/text_decoration_cached_ref.html @@ -0,0 +1,14 @@ + + + + + text-decoration cache reference + + + + test + test + +