diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index 3d6eef88696..58dc331c7a2 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -800,6 +800,7 @@ where } } +#[inline(always)] fn select_name<'a, T>(is_html: bool, local_name: &'a T, local_name_lower: &'a T) -> &'a T { if is_html { local_name_lower diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index 343d6fca05b..88ee70bde25 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -423,6 +423,7 @@ impl Selector { /// Whether this selector (pseudo-element part excluded) matches every element. /// /// Used for "pre-computed" pseudo-elements in components/style/stylist.rs + #[inline] pub fn is_universal(&self) -> bool { self.iter_raw_match_order().all(|c| matches!(*c, Component::ExplicitUniversalType | @@ -435,6 +436,7 @@ impl Selector { /// Returns an iterator over this selector in matching order (right-to-left). /// When a combinator is reached, the iterator will return None, and /// next_sequence() may be called to continue to the next sequence. + #[inline] pub fn iter(&self) -> SelectorIter { SelectorIter { iter: self.iter_raw_match_order(), @@ -444,6 +446,7 @@ impl Selector { /// Returns an iterator over this selector in matching order (right-to-left), /// skipping the rightmost |offset| Components. + #[inline] pub fn iter_from(&self, offset: usize) -> SelectorIter { let iter = self.0.slice[offset..].iter(); SelectorIter { @@ -467,6 +470,7 @@ impl Selector { /// Returns an iterator over the entire sequence of simple selectors and /// combinators, in matching order (from right to left). + #[inline] pub fn iter_raw_match_order(&self) -> slice::Iter> { self.0.slice.iter() } @@ -487,6 +491,7 @@ impl Selector { /// Returns an iterator over the sequence of simple selectors and /// combinators, in parse order (from left to right), starting from /// `offset`. + #[inline] pub fn iter_raw_parse_order_from(&self, offset: usize) -> Rev>> { self.0.slice[..self.len() - offset].iter().rev() } @@ -506,6 +511,7 @@ impl Selector { } /// Returns count of simple selectors and combinators in the Selector. + #[inline] pub fn len(&self) -> usize { self.0.slice.len() } @@ -525,11 +531,13 @@ pub struct SelectorIter<'a, Impl: 'a + SelectorImpl> { impl<'a, Impl: 'a + SelectorImpl> SelectorIter<'a, Impl> { /// Prepares this iterator to point to the next sequence to the left, /// returning the combinator if the sequence was found. + #[inline] pub fn next_sequence(&mut self) -> Option { self.next_combinator.take() } /// Returns remaining count of the simple selectors and combinators in the Selector. + #[inline] pub fn selector_length(&self) -> usize { self.iter.len() } @@ -537,6 +545,8 @@ impl<'a, Impl: 'a + SelectorImpl> SelectorIter<'a, Impl> { impl<'a, Impl: SelectorImpl> Iterator for SelectorIter<'a, Impl> { type Item = &'a Component; + + #[inline] fn next(&mut self) -> Option { debug_assert!(self.next_combinator.is_none(), "You should call next_sequence!"); @@ -624,6 +634,7 @@ pub enum Combinator { impl Combinator { /// Returns true if this combinator is a child or descendant combinator. + #[inline] pub fn is_ancestor(&self) -> bool { matches!(*self, Combinator::Child | Combinator::Descendant | @@ -631,11 +642,13 @@ impl Combinator { } /// Returns true if this combinator is a pseudo-element combinator. + #[inline] pub fn is_pseudo_element(&self) -> bool { matches!(*self, Combinator::PseudoElement) } /// Returns true if this combinator is a next- or later-sibling combinator. + #[inline] pub fn is_sibling(&self) -> bool { matches!(*self, Combinator::NextSibling | Combinator::LaterSibling) } diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index f25b93b8dec..27ec1d91338 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -99,14 +99,17 @@ pub struct GeckoDocument<'ld>(pub &'ld structs::nsIDocument); impl<'ld> TDocument for GeckoDocument<'ld> { type ConcreteNode = GeckoNode<'ld>; + #[inline] fn as_node(&self) -> Self::ConcreteNode { GeckoNode(&self.0._base) } + #[inline] fn is_html_document(&self) -> bool { self.0.mType == structs::root::nsIDocument_Type::eHTML } + #[inline] fn quirks_mode(&self) -> QuirksMode { self.0.mCompatMode.into() } @@ -144,6 +147,7 @@ impl<'ld> TDocument for GeckoDocument<'ld> { pub struct GeckoNode<'ln>(pub &'ln RawGeckoNode); impl<'ln> PartialEq for GeckoNode<'ln> { + #[inline] fn eq(&self, other: &Self) -> bool { self.0 as *const _ == other.0 as *const _ } @@ -302,6 +306,7 @@ impl<'ln> TNode for GeckoNode<'ln> { self.flattened_tree_parent().and_then(|n| n.as_element()) } + #[inline] fn opaque(&self) -> OpaqueNode { let ptr: usize = self.0 as *const _ as usize; OpaqueNode(ptr) @@ -329,6 +334,7 @@ impl<'ln> TNode for GeckoNode<'ln> { } } + #[inline] fn can_be_fragmented(&self) -> bool { // FIXME(SimonSapin): Servo uses this to implement CSS multicol / fragmentation // Maybe this isn’t useful for Gecko? @@ -397,14 +403,17 @@ impl<'a> Iterator for GeckoChildrenIterator<'a> { pub struct GeckoXBLBinding<'lb>(pub &'lb RawGeckoXBLBinding); impl<'lb> GeckoXBLBinding<'lb> { + #[inline] fn base_binding(&self) -> Option { unsafe { self.0.mNextBinding.mRawPtr.as_ref().map(GeckoXBLBinding) } } + #[inline] fn anon_content(&self) -> *const nsIContent { unsafe { self.0.mContent.raw::() } } + #[inline] fn inherits_style(&self) -> bool { unsafe { bindings::Gecko_XBLBinding_InheritsStyle(self.0) } } @@ -1024,6 +1033,7 @@ impl<'le> TElement for GeckoElement<'le> { } } + #[inline] fn as_node(&self) -> Self::ConcreteNode { unsafe { GeckoNode(&*(self.0 as *const _ as *const RawGeckoNode)) } } @@ -1080,6 +1090,7 @@ impl<'le> TElement for GeckoElement<'le> { get_animation_rule(self, CascadeLevel::Transitions) } + #[inline] fn get_state(&self) -> ElementState { ElementState::from_bits_truncate(self.get_state_internal()) } @@ -1752,6 +1763,7 @@ impl<'le> TElement for GeckoElement<'le> { } impl<'le> PartialEq for GeckoElement<'le> { + #[inline] fn eq(&self, other: &Self) -> bool { self.0 as *const _ == other.0 as *const _ } @@ -1760,6 +1772,7 @@ impl<'le> PartialEq for GeckoElement<'le> { impl<'le> Eq for GeckoElement<'le> {} impl<'le> Hash for GeckoElement<'le> { + #[inline] fn hash(&self, state: &mut H) { (self.0 as *const _).hash(state); } @@ -1902,6 +1915,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { } } + #[inline] fn is_root(&self) -> bool { unsafe { Gecko_IsRootElement(self.0)