aboutsummaryrefslogtreecommitdiffstats
path: root/components/style
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2023-05-22 10:03:20 +0200
committerOriol Brufau <obrufau@igalia.com>2023-05-24 18:32:37 +0200
commit1918c1c2034ca0ac75744bfa08c53ddfc8fb1caf (patch)
treededa3d7bfb19ac3eb8e6027266287fe86043694f /components/style
parent695ff236c81e7fc7c4f73db35ce12b3dcce40fb6 (diff)
downloadservo-1918c1c2034ca0ac75744bfa08c53ddfc8fb1caf.tar.gz
servo-1918c1c2034ca0ac75744bfa08c53ddfc8fb1caf.zip
style: Inline GeckoNode::prev_sibling
It's very hot when matching some kind of selectors like the ones in bug 1717267, and the two function calls show up in the profiles. Differential Revision: https://phabricator.services.mozilla.com/D119505
Diffstat (limited to 'components/style')
-rw-r--r--components/style/dom.rs2
-rw-r--r--components/style/gecko/wrapper.rs8
2 files changed, 6 insertions, 4 deletions
diff --git a/components/style/dom.rs b/components/style/dom.rs
index c70a8fd26be..c85ff1edaff 100644
--- a/components/style/dom.rs
+++ b/components/style/dom.rs
@@ -151,7 +151,7 @@ pub trait TNode: Sized + Copy + Clone + Debug + NodeInfo + PartialEq {
/// Get this node's first child.
fn first_child(&self) -> Option<Self>;
- /// Get this node's first child.
+ /// Get this node's last child.
fn last_child(&self) -> Option<Self>;
/// Get this node's previous sibling.
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index 3f23981a823..476e710795d 100644
--- a/components/style/gecko/wrapper.rs
+++ b/components/style/gecko/wrapper.rs
@@ -409,9 +409,11 @@ impl<'ln> TNode for GeckoNode<'ln> {
#[inline]
fn prev_sibling(&self) -> Option<Self> {
unsafe {
- bindings::Gecko_GetPreviousSibling(self.0)
- .as_ref()
- .map(GeckoNode)
+ let prev_or_last = GeckoNode::from_content(self.0.mPreviousOrLastSibling.as_ref()?);
+ if prev_or_last.0.mNextSibling.raw::<nsIContent>().is_null() {
+ return None;
+ }
+ Some(prev_or_last)
}
}