diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-03-09 13:04:21 +0000 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-04-16 16:35:07 +0200 |
commit | 635f5fbf1b2a8b2127f5984acecbeda97637eb4e (patch) | |
tree | 1aa6656b2b7ad3919e5ebbad2d69bf565e9d2653 /components/style/gecko/snapshot_helpers.rs | |
parent | 614d3e746f54269fd06a1cc1e810549d1e9ca417 (diff) | |
download | servo-635f5fbf1b2a8b2127f5984acecbeda97637eb4e.tar.gz servo-635f5fbf1b2a8b2127f5984acecbeda97637eb4e.zip |
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
Diffstat (limited to 'components/style/gecko/snapshot_helpers.rs')
-rw-r--r-- | components/style/gecko/snapshot_helpers.rs | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/components/style/gecko/snapshot_helpers.rs b/components/style/gecko/snapshot_helpers.rs index cb3056e7bd5..f65fe55d8ff 100644 --- a/components/style/gecko/snapshot_helpers.rs +++ b/components/style/gecko/snapshot_helpers.rs @@ -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)] |