diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 2babb8664a73..c31b8f9ea8fb 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -211,6 +211,7 @@ impl<'ln> GeckoNode<'ln> { /// WARNING: This logic is duplicated in Gecko's FlattenedTreeParentIsParent. /// Make sure to mirror any modifications in both places. + #[inline] fn flattened_tree_parent_is_parent(&self) -> bool { use gecko_bindings::structs::*; let flags = self.flags(); @@ -236,6 +237,7 @@ impl<'ln> GeckoNode<'ln> { true } + #[inline] fn flattened_tree_parent(&self) -> Option { let fast_path = self.flattened_tree_parent_is_parent(); debug_assert!(fast_path == unsafe { bindings::Gecko_FlattenedTreeParentIsParent(self.0) }); @@ -246,6 +248,7 @@ impl<'ln> GeckoNode<'ln> { } } + #[inline] fn contains_non_whitespace_content(&self) -> bool { unsafe { Gecko_IsSignificantChild(self.0, true, false) } } diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index d26557d5c1bf..f27c2c357ca9 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -91,7 +91,7 @@ pub struct DeclarationImportanceIterator<'a> { } impl<'a> DeclarationImportanceIterator<'a> { - /// Constructor + /// Constructor. pub fn new(declarations: &'a [PropertyDeclaration], important: &'a SmallBitVec) -> Self { DeclarationImportanceIterator { iter: declarations.iter().zip(important.iter()), @@ -102,17 +102,20 @@ impl<'a> DeclarationImportanceIterator<'a> { impl<'a> Iterator for DeclarationImportanceIterator<'a> { type Item = (&'a PropertyDeclaration, Importance); + #[inline] fn next(&mut self) -> Option { self.iter.next().map(|(decl, important)| (decl, if important { Importance::Important } else { Importance::Normal })) } + #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } impl<'a> DoubleEndedIterator for DeclarationImportanceIterator<'a> { + #[inline(always)] fn next_back(&mut self) -> Option { self.iter.next_back().map(|(decl, important)| (decl, if important { Importance::Important } else { Importance::Normal })) @@ -123,7 +126,8 @@ impl<'a> DoubleEndedIterator for DeclarationImportanceIterator<'a> { pub struct NormalDeclarationIterator<'a>(DeclarationImportanceIterator<'a>); impl<'a> NormalDeclarationIterator<'a> { - /// Constructor + /// Constructor. + #[inline] pub fn new(declarations: &'a [PropertyDeclaration], important: &'a SmallBitVec) -> Self { NormalDeclarationIterator( DeclarationImportanceIterator::new(declarations, important) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 0aa787f4231f..2c01ccedca5b 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -3129,6 +3129,9 @@ pub fn cascade( ) -> Arc { debug_assert_eq!(parent_style.is_some(), parent_style_ignoring_first_line.is_some()); let empty = SmallBitVec::new(); + + let property_restriction = pseudo.and_then(|p| p.property_restriction()); + let iter_declarations = || { rule_node.self_and_ancestors().flat_map(|node| { let cascade_level = node.cascade_level(); @@ -3142,8 +3145,6 @@ pub fn cascade( }; let node_importance = node.importance(); - let property_restriction = pseudo.and_then(|p| p.property_restriction()); - declarations // Yield declarations later in source order (with more precedence) first. .rev() @@ -3168,6 +3169,7 @@ pub fn cascade( }) }) }; + apply_declarations( device, pseudo, @@ -3187,7 +3189,6 @@ pub fn cascade( /// NOTE: This function expects the declaration with more priority to appear /// first. -#[allow(unused_mut)] // conditionally compiled code for "position" pub fn apply_declarations<'a, F, I>( device: &Device, pseudo: Option<<&PseudoElement>,