From 18ac41fe87055c8453ba4ac3fe1ac7dcc21f729c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 30 Oct 2017 22:44:24 +0100 Subject: [PATCH] style: Inline a bunch of stuff, fixup indentation of a couple things. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MozReview-Commit-ID: CgUNMeBDOCw Signed-off-by: Emilio Cobos Álvarez --- components/selectors/matching.rs | 10 ++++++---- components/style/gecko/wrapper.rs | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index c7ca5927e96..3d6eef88696 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -62,6 +62,7 @@ struct LocalMatchingContext<'a, 'b: 'a, Impl: SelectorImpl> { matches_hover_and_active_quirk: bool, } +#[inline(always)] pub fn matches_selector_list( selector_list: &SelectorList, element: &E, @@ -373,6 +374,7 @@ where } /// Matches a complex selector. +#[inline(always)] pub fn matches_complex_selector( mut iter: SelectorIter, element: &E, @@ -385,8 +387,8 @@ where { // If this is the special pseudo-element mode, consume the ::pseudo-element // before proceeding, since the caller has already handled that part. - if context.nesting_level == 0 && - context.matching_mode == MatchingMode::ForStatelessPseudoElement { + if context.matching_mode == MatchingMode::ForStatelessPseudoElement && + context.nesting_level == 0 { // Consume the pseudo. match *iter.next().unwrap() { Component::PseudoElement(ref pseudo) => { @@ -571,12 +573,12 @@ where // Only ancestor combinators are allowed while looking for // relevant links, so switch to not looking. *relevant_link = RelevantLinkStatus::NotLooking; - SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant + SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant } Combinator::Child | Combinator::Descendant | Combinator::PseudoElement => { - SelectorMatchingResult::NotMatchedGlobally + SelectorMatchingResult::NotMatchedGlobally } }; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index dbecac5133f..f25b93b8dec 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -262,6 +262,7 @@ impl<'ln> TNode for GeckoNode<'ln> { type ConcreteDocument = GeckoDocument<'ln>; type ConcreteElement = GeckoElement<'ln>; + #[inline] fn parent_node(&self) -> Option { unsafe { self.0.mParent.as_ref().map(GeckoNode) } } @@ -1767,10 +1768,12 @@ impl<'le> Hash for GeckoElement<'le> { impl<'le> ::selectors::Element for GeckoElement<'le> { type Impl = SelectorImpl; + #[inline] fn opaque(&self) -> OpaqueElement { OpaqueElement::new(self.0) } + #[inline] fn parent_element(&self) -> Option { // FIXME(emilio): This will need to jump across if the parent node is a // shadow root to get the shadow host. @@ -1783,6 +1786,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { self.closest_non_native_anonymous_ancestor() } + #[inline] fn first_child_element(&self) -> Option { let mut child = self.as_node().first_child(); while let Some(child_node) = child { @@ -1794,6 +1798,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { None } + #[inline] fn last_child_element(&self) -> Option { let mut child = self.as_node().last_child(); while let Some(child_node) = child { @@ -1805,6 +1810,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { None } + #[inline] fn prev_sibling_element(&self) -> Option { let mut sibling = self.as_node().prev_sibling(); while let Some(sibling_node) = sibling { @@ -1816,6 +1822,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { None } + #[inline] fn next_sibling_element(&self) -> Option { let mut sibling = self.as_node().next_sibling(); while let Some(sibling_node) = sibling { @@ -1907,12 +1914,14 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { }) } + #[inline] fn get_local_name(&self) -> &WeakAtom { unsafe { WeakAtom::new(self.as_node().node_info().mInner.mName) } } + #[inline] fn get_namespace(&self) -> &WeakNamespace { unsafe { WeakNamespace::new(Gecko_Namespace(self.0)) @@ -2079,6 +2088,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { self.get_state().intersects(NonTSPseudoClass::AnyLink.state_flag()) } + #[inline] fn has_id(&self, id: &Atom, case_sensitivity: CaseSensitivity) -> bool { if !self.has_id() { return false @@ -2095,6 +2105,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { } } + #[inline] fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool { if !self.may_have_class() { return false; @@ -2106,15 +2117,18 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { Gecko_ClassOrClassList) } + #[inline] fn is_html_element_in_html_document(&self) -> bool { self.is_html_element() && self.as_node().owner_doc().is_html_document() } + #[inline] fn ignores_nth_child_selectors(&self) -> bool { self.is_root_of_anonymous_subtree() } + #[inline] fn blocks_ancestor_combinators(&self) -> bool { if !self.is_root_of_anonymous_subtree() { return false