mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add is_connected flag to node and use it to replace most uses of is_in_doc
This commit is contained in:
parent
640fc04743
commit
441357b74e
29 changed files with 111 additions and 96 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue