mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +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
|
@ -29,7 +29,7 @@ unsafe fn ptr<T>(attr: &structs::nsAttrValue) -> *const T {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn get_class_from_attr(attr: &structs::nsAttrValue) -> Class {
|
||||
unsafe fn get_class_or_part_from_attr(attr: &structs::nsAttrValue) -> Class {
|
||||
debug_assert!(bindings::Gecko_AssertClassAttrValueIsSane(attr));
|
||||
let base_type = base_type(attr);
|
||||
if base_type == structs::nsAttrValue_ValueBaseType_eStringBase {
|
||||
|
@ -82,15 +82,15 @@ pub fn get_id(attrs: &[structs::AttrArray_InternalAttr]) -> Option<&WeakAtom> {
|
|||
Some(unsafe { get_id_from_attr(find_attr(attrs, &atom!("id"))?) })
|
||||
}
|
||||
|
||||
/// Given a class name, a case sensitivity, and an array of attributes, returns
|
||||
/// whether the class has the attribute that name represents.
|
||||
/// Given a class or part name, a case sensitivity, and an array of attributes,
|
||||
/// returns whether the attribute has that name.
|
||||
#[inline(always)]
|
||||
pub fn has_class(
|
||||
pub fn has_class_or_part(
|
||||
name: &Atom,
|
||||
case_sensitivity: CaseSensitivity,
|
||||
attr: &structs::nsAttrValue,
|
||||
) -> bool {
|
||||
match unsafe { get_class_from_attr(attr) } {
|
||||
match unsafe { get_class_or_part_from_attr(attr) } {
|
||||
Class::None => false,
|
||||
Class::One(atom) => unsafe { case_sensitivity.eq_atom(name, WeakAtom::new(atom)) },
|
||||
Class::More(atoms) => match case_sensitivity {
|
||||
|
@ -114,7 +114,7 @@ where
|
|||
F: FnMut(&Atom),
|
||||
{
|
||||
unsafe {
|
||||
match get_class_from_attr(attr) {
|
||||
match get_class_or_part_from_attr(attr) {
|
||||
Class::None => {},
|
||||
Class::One(atom) => Atom::with(atom, callback),
|
||||
Class::More(atoms) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue