style: Implement selector-matching for ::part().

Also fairly straight-forward. This may get more complicated when we do part
forwarding, if any.

I've opened https://github.com/w3c/csswg-drafts/issues/3841 in what I think
would be a cleaner model for forwarding.

Differential Revision: https://phabricator.services.mozilla.com/D28063
This commit is contained in:
Emilio Cobos Álvarez 2019-05-01 17:28:23 +00:00
parent a23ad3be50
commit 627514b737
4 changed files with 40 additions and 12 deletions

View file

@ -183,13 +183,23 @@ impl ElementSnapshot for GeckoElementSnapshot {
snapshot_helpers::get_id(&*self.mAttrs)
}
#[inline]
fn is_part(&self, name: &Atom) -> bool {
let attr = match snapshot_helpers::find_attr(&*self.mAttrs, &atom!("part")) {
Some(attr) => attr,
None => return false,
};
snapshot_helpers::has_class_or_part(name, CaseSensitivity::CaseSensitive, attr)
}
#[inline]
fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
if !self.has_any(Flags::MaybeClass) {
return false;
}
snapshot_helpers::has_class(name, case_sensitivity, &self.mClass)
snapshot_helpers::has_class_or_part(name, case_sensitivity, &self.mClass)
}
#[inline]