aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-06-13 00:51:41 +0200
committerSimon Sapin <simon.sapin@exyr.org>2017-06-13 00:51:41 +0200
commit138c03b24d37aaeaefa2ebed1688acdfda8e262a (patch)
tree2693fb50f9189cdbb305871432fe2a73a67c97f0
parentb82713924c7d6b52348088f1409fb5f7a30379e9 (diff)
downloadservo-138c03b24d37aaeaefa2ebed1688acdfda8e262a.tar.gz
servo-138c03b24d37aaeaefa2ebed1688acdfda8e262a.zip
Stylo: avoid atom refcount traffic in ID selector matching
-rw-r--r--components/style/gecko/wrapper.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index 2ec79c36372..17be81fe146 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 {