style: Implement GeckoElement::each_part.

This should make all the pieces come together.

Note that we don't need to look at the snapshot for ::part() for now (other than
when selector-matching normally) because I decided to just restyle the element
for now when the part attribute changes.

::part() can't affect descendants anyway (as long as we don't do the forwarding
stuff), and eager pseudo-elements are handled during the normal element restyle,
so it seems to me that adding all the complexity that we have for classes to
part may not be worth it at least yet.

Differential Revision: https://phabricator.services.mozilla.com/D32648
This commit is contained in:
Emilio Cobos Álvarez 2019-06-11 17:42:49 +00:00
parent 7139a4185a
commit e272bfed70
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
3 changed files with 16 additions and 4 deletions

View file

@ -211,7 +211,7 @@ impl ElementSnapshot for GeckoElementSnapshot {
return; return;
} }
snapshot_helpers::each_class(&self.mClass, callback) snapshot_helpers::each_class_or_part(&self.mClass, callback)
} }
#[inline] #[inline]

View file

@ -107,9 +107,9 @@ pub fn has_class_or_part(
} }
/// Given an item, a callback, and a getter, execute `callback` for each class /// Given an item, a callback, and a getter, execute `callback` for each class
/// this `item` has. /// or part name this `item` has.
#[inline(always)] #[inline(always)]
pub fn each_class<F>(attr: &structs::nsAttrValue, mut callback: F) pub fn each_class_or_part<F>(attr: &structs::nsAttrValue, mut callback: F)
where where
F: FnMut(&Atom), F: FnMut(&Atom),
{ {

View file

@ -1372,7 +1372,19 @@ impl<'le> TElement for GeckoElement<'le> {
None => return, None => return,
}; };
snapshot_helpers::each_class(attr, callback) snapshot_helpers::each_class_or_part(attr, callback)
}
fn each_part<F>(&self, callback: F)
where
F: FnMut(&Atom),
{
let attr = match self.get_part_attr() {
Some(c) => c,
None => return,
};
snapshot_helpers::each_class_or_part(attr, callback)
} }
#[inline] #[inline]