From b9a0737946f809444037f8dc168508bf24bba889 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 18 May 2017 11:32:49 -0400 Subject: [PATCH] Use snapshot class/id flags to optimize out class/id gets. --- components/style/gecko/snapshot.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/components/style/gecko/snapshot.rs b/components/style/gecko/snapshot.rs index ea4871bc2a7..261af44f6d6 100644 --- a/components/style/gecko/snapshot.rs +++ b/components/style/gecko/snapshot.rs @@ -148,7 +148,12 @@ impl ElementSnapshot for GeckoElementSnapshot { self.has_any(Flags::Attributes) } + #[inline] fn id_attr(&self) -> Option { + if !self.has_any(Flags::Id) { + return None + } + let ptr = unsafe { bindings::Gecko_SnapshotAtomAttrValue(self, atom!("id").as_ptr()) @@ -161,15 +166,25 @@ impl ElementSnapshot for GeckoElementSnapshot { } } + #[inline] fn has_class(&self, name: &Atom) -> bool { + if !self.has_any(Flags::MaybeClass) { + return false; + } + snapshot_helpers::has_class(self.as_ptr(), name, bindings::Gecko_SnapshotClassOrClassList) } + #[inline] fn each_class(&self, callback: F) where F: FnMut(&Atom) { + if !self.has_any(Flags::MaybeClass) { + return; + } + snapshot_helpers::each_class(self.as_ptr(), callback, bindings::Gecko_SnapshotClassOrClassList)