mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Use snapshot class/id flags to optimize out class/id gets.
This commit is contained in:
parent
8783254d3d
commit
b9a0737946
1 changed files with 15 additions and 0 deletions
|
@ -148,7 +148,12 @@ impl ElementSnapshot for GeckoElementSnapshot {
|
|||
self.has_any(Flags::Attributes)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn id_attr(&self) -> Option<Atom> {
|
||||
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<F>(&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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue