From 138c03b24d37aaeaefa2ebed1688acdfda8e262a Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 13 Jun 2017 00:51:41 +0200 Subject: [PATCH] Stylo: avoid atom refcount traffic in ID selector matching --- components/style/gecko/wrapper.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 2ec79c36372e..17be81fe1466 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1593,7 +1593,19 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { } fn has_id(&self, id: &Atom, case_sensitivity: CaseSensitivity) -> bool { - self.get_id().map_or(false, |atom| case_sensitivity.eq_atom(&atom, id)) + if !self.has_id() { + return false + } + + unsafe { + let ptr = bindings::Gecko_AtomAttrValue(self.0, atom!("id").as_ptr()); + + if ptr.is_null() { + false + } else { + case_sensitivity.eq_atom(WeakAtom::new(ptr), id) + } + } } fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {