diff options
author | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-01-27 17:11:11 +0100 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-04-26 10:17:45 +0200 |
commit | 441357b74e38b604a60206ff38e5cf3719a15e08 (patch) | |
tree | 58cc06819fac57dfe6687807842a903bdb1b2cb0 /components/script/dom/element.rs | |
parent | 640fc04743e38491e582a6ba30ded5bebb0a3ebb (diff) | |
download | servo-441357b74e38b604a60206ff38e5cf3719a15e08.tar.gz servo-441357b74e38b604a60206ff38e5cf3719a15e08.zip |
Add is_connected flag to node and use it to replace most uses of is_in_doc
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r-- | components/script/dom/element.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 20b51fbfaa1..5d23400e745 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -9,6 +9,7 @@ use crate::dom::attr::{Attr, AttrHelpersForLayout}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; +use crate::dom::bindings::codegen::Bindings::DocumentFragmentBinding::DocumentFragmentBinding::DocumentFragmentMethods; use crate::dom::bindings::codegen::Bindings::ElementBinding; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; @@ -1202,7 +1203,13 @@ impl Element { } pub fn root_element(&self) -> DomRoot<Element> { - if self.node.is_in_doc() { + if self.node.is_in_shadow_tree() { + self.upcast::<Node>() + .owner_shadow_root() + .upcast::<DocumentFragment>() + .GetFirstElementChild() + .unwrap() + } else if self.node.is_in_doc() { self.upcast::<Node>() .owner_doc() .GetDocumentElement() @@ -2718,7 +2725,7 @@ impl VirtualMethods for Element { None } }); - if node.is_in_doc() { + if node.is_connected() { let value = attr.value().as_atom().clone(); match mutation { AttributeMutation::Set(old_value) => { @@ -2764,16 +2771,16 @@ impl VirtualMethods for Element { } } - fn bind_to_tree(&self, tree_in_doc: bool) { + fn bind_to_tree(&self, tree_connected: bool) { if let Some(ref s) = self.super_type() { - s.bind_to_tree(tree_in_doc); + s.bind_to_tree(tree_connected); } if let Some(f) = self.as_maybe_form_control() { f.bind_form_control_to_tree(); } - if !tree_in_doc { + if !tree_connected { return; } @@ -2792,7 +2799,7 @@ impl VirtualMethods for Element { f.unbind_form_control_from_tree(); } - if !context.tree_in_doc { + if !context.tree_connected { return; } |