mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Register/unregister shadow roots in documents when they are connected
This commit is contained in:
parent
cd07574235
commit
18c1b8f690
2 changed files with 30 additions and 6 deletions
|
@ -486,9 +486,13 @@ impl Element {
|
|||
}
|
||||
|
||||
// Steps 4, 5 and 6.
|
||||
Ok(self
|
||||
let shadow_root = self
|
||||
.shadow_root
|
||||
.or_init(|| ShadowRoot::new(self, &*self.node.owner_doc())))
|
||||
.or_init(|| ShadowRoot::new(self, &*self.node.owner_doc()));
|
||||
|
||||
self.node.owner_doc().register_shadow_root(&*shadow_root);
|
||||
|
||||
Ok(shadow_root)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2787,8 +2791,9 @@ impl VirtualMethods for Element {
|
|||
return;
|
||||
}
|
||||
|
||||
if self.is_shadow_host() {
|
||||
let shadow_root = self.shadow_root.get().unwrap();
|
||||
let doc = document_from_node(self);
|
||||
|
||||
if let Some(shadow_root) = self.upcast::<Node>().owner_shadow_root() {
|
||||
let shadow_root = shadow_root.upcast::<Node>();
|
||||
shadow_root.set_flag(NodeFlags::IS_CONNECTED, tree_connected);
|
||||
for node in shadow_root.children() {
|
||||
|
@ -2797,7 +2802,6 @@ impl VirtualMethods for Element {
|
|||
}
|
||||
}
|
||||
|
||||
let doc = document_from_node(self);
|
||||
if let Some(ref value) = *self.id_attribute.borrow() {
|
||||
doc.register_named_element(self, value.clone());
|
||||
}
|
||||
|
@ -2816,8 +2820,12 @@ impl VirtualMethods for Element {
|
|||
return;
|
||||
}
|
||||
|
||||
let doc = document_from_node(self);
|
||||
|
||||
if self.is_shadow_host() {
|
||||
let shadow_root = self.shadow_root.get().unwrap();
|
||||
doc.unregister_shadow_root(&shadow_root);
|
||||
let shadow_root = shadow_root.upcast::<Node>();
|
||||
let shadow_root = shadow_root.upcast::<Node>();
|
||||
shadow_root.set_flag(NodeFlags::IS_CONNECTED, false);
|
||||
for node in shadow_root.children() {
|
||||
|
@ -2826,7 +2834,6 @@ impl VirtualMethods for Element {
|
|||
}
|
||||
}
|
||||
|
||||
let doc = document_from_node(self);
|
||||
let fullscreen = doc.GetFullscreenElement();
|
||||
if fullscreen.deref() == Some(self) {
|
||||
doc.exit_fullscreen();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue