style: Allow to export a shadow part under multiple names.

Other browsers allow this and the spec doesn't really disallow it, so fix it,
add a test and carry on.

Differential Revision: https://phabricator.services.mozilla.com/D65107
This commit is contained in:
Emilio Cobos Álvarez 2020-03-09 13:04:21 +00:00
parent 614d3e746f
commit 635f5fbf1b
8 changed files with 46 additions and 46 deletions

View file

@ -83,16 +83,32 @@ pub fn get_id(attrs: &[structs::AttrArray_InternalAttr]) -> Option<&WeakAtom> {
}
#[inline(always)]
pub(super) fn exported_part(
pub(super) fn each_exported_part(
attrs: &[structs::AttrArray_InternalAttr],
name: &Atom,
) -> Option<Atom> {
let attr = find_attr(attrs, &atom!("exportparts"))?;
let atom = unsafe { bindings::Gecko_Element_ExportedPart(attr, name.as_ptr()) };
if atom.is_null() {
return None;
mut callback: impl FnMut(&Atom),
) {
let attr = match find_attr(attrs, &atom!("exportparts")) {
Some(attr) => attr,
None => return,
};
let mut length = 0;
let atoms = unsafe {
bindings::Gecko_Element_ExportedParts(
attr,
name.as_ptr(),
&mut length,
)
};
if atoms.is_null() {
return;
}
unsafe {
for atom in std::slice::from_raw_parts(atoms, length) {
Atom::with(*atom, &mut callback)
}
}
Some(unsafe { Atom::from_raw(atom) })
}
#[inline(always)]