mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Support exporting shadow parts with the exportparts
attribute (#37345)
The attribute is implemented as a new `AttrValue` variant containing the mappings of exported part names (https://github.com/servo/stylo/pull/197). Take a look at the [MDN page](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/exportparts) for more information about the attribute. Testing: Covered by WPT Fixes: https://github.com/servo/servo/issues/35349 --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
730fe35b42
commit
6cac782fb1
12 changed files with 42 additions and 45 deletions
|
@ -4226,6 +4226,7 @@ impl VirtualMethods for Element {
|
|||
local_name!("class") | local_name!("part") => {
|
||||
AttrValue::from_serialized_tokenlist(value.into())
|
||||
},
|
||||
local_name!("exportparts") => AttrValue::from_shadow_parts(value.into()),
|
||||
_ => self
|
||||
.super_type()
|
||||
.unwrap()
|
||||
|
|
|
@ -307,6 +307,21 @@ impl<'dom> style::dom::TElement for ServoLayoutElement<'dom> {
|
|||
}
|
||||
}
|
||||
|
||||
fn each_exported_part<F>(&self, name: &AtomIdent, callback: F)
|
||||
where
|
||||
F: FnMut(&AtomIdent),
|
||||
{
|
||||
let Some(exported_parts) = self
|
||||
.element
|
||||
.get_attr_for_layout(&ns!(), &local_name!("exportparts"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
exported_parts
|
||||
.as_shadow_parts()
|
||||
.for_each_exported_part(AtomIdent::cast(name), callback);
|
||||
}
|
||||
|
||||
fn has_dirty_descendants(&self) -> bool {
|
||||
unsafe {
|
||||
self.as_node()
|
||||
|
@ -751,8 +766,12 @@ impl<'dom> ::selectors::Element for ServoLayoutElement<'dom> {
|
|||
)
|
||||
}
|
||||
|
||||
fn imported_part(&self, _: &AtomIdent) -> Option<AtomIdent> {
|
||||
None
|
||||
fn imported_part(&self, name: &AtomIdent) -> Option<AtomIdent> {
|
||||
self.element
|
||||
.get_attr_for_layout(&ns!(), &local_name!("exportparts"))?
|
||||
.as_shadow_parts()
|
||||
.imported_part(name)
|
||||
.map(|import| AtomIdent::new(import.clone()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue