mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Add invalidation support for ::slotted().
Bug: 1424607 Reviewed-by: heycam MozReview-Commit-ID: 8pIVUx27o7x
This commit is contained in:
parent
040379208e
commit
b26f3280d2
7 changed files with 294 additions and 110 deletions
|
@ -610,10 +610,7 @@ impl<'le> GeckoElement<'le> {
|
|||
self.as_node().node_info().mInner.mNamespaceID
|
||||
}
|
||||
|
||||
fn is_html_element(&self) -> bool {
|
||||
self.namespace_id() == (structs::root::kNameSpaceID_XHTML as i32)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_xul_element(&self) -> bool {
|
||||
self.namespace_id() == (structs::root::kNameSpaceID_XUL as i32)
|
||||
}
|
||||
|
@ -974,6 +971,40 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
self.as_node().owner_doc().as_node()
|
||||
}
|
||||
|
||||
|
||||
#[inline]
|
||||
fn is_html_element(&self) -> bool {
|
||||
self.namespace_id() == (structs::root::kNameSpaceID_XHTML as i32)
|
||||
}
|
||||
|
||||
/// Return the list of slotted nodes of this node.
|
||||
#[inline]
|
||||
fn slotted_nodes(&self) -> &[Self::ConcreteNode] {
|
||||
if !self.is_html_slot_element() || !self.is_in_shadow_tree() {
|
||||
return &[];
|
||||
}
|
||||
|
||||
let slot: &structs::HTMLSlotElement = unsafe {
|
||||
mem::transmute(self.0)
|
||||
};
|
||||
|
||||
if cfg!(debug_assertions) {
|
||||
let base: &RawGeckoElement = &slot._base._base._base._base;
|
||||
assert_eq!(base as *const _, self.0 as *const _, "Bad cast");
|
||||
}
|
||||
|
||||
let assigned_nodes: &[structs::RefPtr<structs::nsINode>] =
|
||||
&*slot.mAssignedNodes;
|
||||
|
||||
debug_assert_eq!(
|
||||
mem::size_of::<structs::RefPtr<structs::nsINode>>(),
|
||||
mem::size_of::<Self::ConcreteNode>(),
|
||||
"Bad cast!"
|
||||
);
|
||||
|
||||
unsafe { mem::transmute(assigned_nodes) }
|
||||
}
|
||||
|
||||
/// Execute `f` for each anonymous content child element (apart from
|
||||
/// ::before and ::after) whose originating element is `self`.
|
||||
fn each_anonymous_content_child<F>(&self, mut f: F)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue