diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 090d2096d07..0f8c9d3e91a 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -503,8 +503,6 @@ extern "C" { pub fn Gecko_RecordTraversalStatistics ( total : u32 , parallel : u32 , total_t : u32 , parallel_t : u32 , total_s : u32 , parallel_s : u32 , ) ; } extern "C" { pub fn Gecko_IsInDocument ( node : RawGeckoNodeBorrowed , ) -> bool ; -} extern "C" { - pub fn Gecko_FlattenedTreeParentIsParent ( node : RawGeckoNodeBorrowed , ) -> bool ; } extern "C" { pub fn Gecko_IsSignificantChild ( node : RawGeckoNodeBorrowed , text_is_significant : bool , whitespace_is_significant : bool , ) -> bool ; } extern "C" { @@ -1599,4 +1597,4 @@ extern "C" { pub fn Gecko_GetElementsWithId ( aDocument : * const nsIDocument , aId : * mut nsAtom , ) -> * const nsTArray < * mut Element > ; } extern "C" { pub fn Gecko_GetBoolPrefValue ( pref_name : * const :: std :: os :: raw :: c_char , ) -> bool ; -} \ No newline at end of file +} diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 5aa09092492..f8a1837de33 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -236,13 +236,23 @@ impl<'ln> GeckoNode<'ln> { #[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) }); - if fast_path { - unsafe { self.0.mParent.as_ref().map(GeckoNode) } - } else { - unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).map(GeckoNode) } + // TODO(emilio): Measure and consider not doing this fast-path and take + // always the common path, it's only a function call and from profiles + // it seems that keeping this fast path makes the compiler not inline + // `flattened_tree_parent`. + if self.flattened_tree_parent_is_parent() { + debug_assert_eq!( + unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).map(GeckoNode) }, + self.parent_node(), + "Fast path stopped holding!" + ); + + return self.parent_node(); } + + // NOTE(emilio): If this call is too expensive, we could manually + // inline more aggressively. + unsafe { bindings::Gecko_GetFlattenedTreeParentNode(self.0).map(GeckoNode) } } #[inline]