mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add shadow tree flags to Bind/UnbindContext (#34863)
* Rename IS_IN_DOC flag to IS_IN_A_DOCUMENT_TREE Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add BindContext::is_in_a_shadow_tree Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add UnbindContext::tree_is_in_shadow_tree Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * ./mach fmt Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update test expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * fix build after rebasing Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
82bc7cb5bb
commit
b6a5eaa3db
11 changed files with 77 additions and 43 deletions
|
@ -544,7 +544,8 @@ impl Element {
|
|||
|
||||
let bind_context = BindContext {
|
||||
tree_connected: self.upcast::<Node>().is_connected(),
|
||||
tree_in_doc: self.upcast::<Node>().is_in_doc(),
|
||||
tree_is_in_a_document_tree: self.upcast::<Node>().is_in_a_document_tree(),
|
||||
tree_is_in_a_shadow_tree: true,
|
||||
};
|
||||
shadow_root.bind_to_tree(&bind_context);
|
||||
|
||||
|
@ -1355,7 +1356,7 @@ impl Element {
|
|||
}
|
||||
|
||||
pub fn root_element(&self) -> DomRoot<Element> {
|
||||
if self.node.is_in_doc() {
|
||||
if self.node.is_in_a_document_tree() {
|
||||
self.upcast::<Node>()
|
||||
.owner_doc()
|
||||
.GetDocumentElement()
|
||||
|
@ -3512,7 +3513,7 @@ impl VirtualMethods for Element {
|
|||
});
|
||||
|
||||
let containing_shadow_root = self.containing_shadow_root();
|
||||
if node.is_connected_to_tree() {
|
||||
if node.is_in_a_document_tree() || node.is_in_a_shadow_tree() {
|
||||
let value = attr.value().as_atom().clone();
|
||||
match mutation {
|
||||
AttributeMutation::Set(old_value) => {
|
||||
|
@ -3619,7 +3620,7 @@ impl VirtualMethods for Element {
|
|||
shadow_root.bind_to_tree(context);
|
||||
}
|
||||
|
||||
if !context.tree_connected {
|
||||
if !context.is_in_tree() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3652,7 +3653,7 @@ impl VirtualMethods for Element {
|
|||
f.unbind_form_control_from_tree();
|
||||
}
|
||||
|
||||
if !context.tree_connected {
|
||||
if !context.tree_is_in_a_document_tree && !context.tree_is_in_a_shadow_tree {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3668,7 +3669,7 @@ impl VirtualMethods for Element {
|
|||
if let Some(ref shadow_root) = self.containing_shadow_root() {
|
||||
// Only unregister the element id if the node was disconnected from it's shadow root
|
||||
// (as opposed to the whole shadow tree being disconnected as a whole)
|
||||
if !self.upcast::<Node>().is_in_shadow_tree() {
|
||||
if !self.upcast::<Node>().is_in_a_shadow_tree() {
|
||||
shadow_root.unregister_element_id(self, value.clone());
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue