mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
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:
parent
a23ad3be50
commit
627514b737
4 changed files with 40 additions and 12 deletions
|
@ -573,6 +573,11 @@ impl<'le> GeckoElement<'le> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn get_part_attr(&self) -> Option<&structs::nsAttrValue> {
|
||||
snapshot_helpers::find_attr(self.attrs(), &atom!("part"))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn get_class_attr(&self) -> Option<&structs::nsAttrValue> {
|
||||
if !self.may_have_class() {
|
||||
|
@ -2259,8 +2264,14 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
case_sensitivity.eq_atom(element_id, id)
|
||||
}
|
||||
|
||||
fn is_part(&self, _name: &Atom) -> bool {
|
||||
unimplemented!();
|
||||
#[inline]
|
||||
fn is_part(&self, name: &Atom) -> bool {
|
||||
let attr = match self.get_part_attr() {
|
||||
Some(c) => c,
|
||||
None => return false,
|
||||
};
|
||||
|
||||
snapshot_helpers::has_class_or_part(name, CaseSensitivity::CaseSensitive, attr)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -2270,7 +2281,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
None => return false,
|
||||
};
|
||||
|
||||
snapshot_helpers::has_class(name, case_sensitivity, attr)
|
||||
snapshot_helpers::has_class_or_part(name, case_sensitivity, attr)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue