mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Document owner_shadow_root
This commit is contained in:
parent
ea1fe15dfe
commit
ccf8a43649
2 changed files with 10 additions and 7 deletions
|
@ -125,6 +125,8 @@ pub struct Node {
|
||||||
owner_doc: MutNullableDom<Document>,
|
owner_doc: MutNullableDom<Document>,
|
||||||
|
|
||||||
/// The shadow root this node belongs to.
|
/// The shadow root this node belongs to.
|
||||||
|
/// This is None if the node is not in a shadow tree or
|
||||||
|
/// if it is a ShadowRoot.
|
||||||
owner_shadow_root: MutNullableDom<ShadowRoot>,
|
owner_shadow_root: MutNullableDom<ShadowRoot>,
|
||||||
|
|
||||||
/// The live list of children return by .childNodes.
|
/// The live list of children return by .childNodes.
|
||||||
|
@ -284,11 +286,10 @@ impl Node {
|
||||||
|
|
||||||
for node in new_child.traverse_preorder(ShadowIncluding::No) {
|
for node in new_child.traverse_preorder(ShadowIncluding::No) {
|
||||||
if parent_in_shadow_tree {
|
if parent_in_shadow_tree {
|
||||||
if let Some(shadow_root) = self.downcast::<ShadowRoot>() {
|
if let Some(shadow_root) = self.owner_shadow_root() {
|
||||||
node.set_owner_shadow_root(&*shadow_root);
|
|
||||||
} else if let Some(shadow_root) = self.owner_shadow_root() {
|
|
||||||
node.set_owner_shadow_root(&*shadow_root);
|
node.set_owner_shadow_root(&*shadow_root);
|
||||||
}
|
}
|
||||||
|
debug_assert!(node.owner_shadow_root().is_some());
|
||||||
}
|
}
|
||||||
node.set_flag(NodeFlags::IS_IN_DOC, parent_in_doc);
|
node.set_flag(NodeFlags::IS_IN_DOC, parent_in_doc);
|
||||||
node.set_flag(NodeFlags::IS_IN_SHADOW_TREE, parent_in_shadow_tree);
|
node.set_flag(NodeFlags::IS_IN_SHADOW_TREE, parent_in_shadow_tree);
|
||||||
|
@ -930,6 +931,9 @@ impl Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn owner_shadow_root(&self) -> Option<DomRoot<ShadowRoot>> {
|
pub fn owner_shadow_root(&self) -> Option<DomRoot<ShadowRoot>> {
|
||||||
|
if let Some(ref shadow_root) = self.downcast::<ShadowRoot>() {
|
||||||
|
return Some(DomRoot::from_ref(shadow_root));
|
||||||
|
}
|
||||||
self.owner_shadow_root.get()
|
self.owner_shadow_root.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,9 @@ impl ShadowRoot {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
fn new_inherited(host: &Element, document: &Document) -> ShadowRoot {
|
fn new_inherited(host: &Element, document: &Document) -> ShadowRoot {
|
||||||
let document_fragment = DocumentFragment::new_inherited(document);
|
let document_fragment = DocumentFragment::new_inherited(document);
|
||||||
document_fragment
|
let node = document_fragment.upcast::<Node>();
|
||||||
.upcast::<Node>()
|
node.set_flag(NodeFlags::IS_IN_SHADOW_TREE, true);
|
||||||
.set_flag(NodeFlags::IS_IN_SHADOW_TREE, true);
|
node.set_flag(
|
||||||
document_fragment.upcast::<Node>().set_flag(
|
|
||||||
NodeFlags::IS_CONNECTED,
|
NodeFlags::IS_CONNECTED,
|
||||||
host.upcast::<Node>().is_connected(),
|
host.upcast::<Node>().is_connected(),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue