mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Move mutation observers list to NodeRareData
This commit is contained in:
parent
6af4729f42
commit
a9019da39d
2 changed files with 7 additions and 8 deletions
|
@ -5,7 +5,6 @@
|
||||||
//! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements.
|
//! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements.
|
||||||
|
|
||||||
use crate::document_loader::DocumentLoader;
|
use crate::document_loader::DocumentLoader;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
|
||||||
use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
||||||
|
@ -152,9 +151,6 @@ pub struct Node {
|
||||||
/// node is finalized.
|
/// node is finalized.
|
||||||
style_and_layout_data: Cell<Option<OpaqueStyleAndLayoutData>>,
|
style_and_layout_data: Cell<Option<OpaqueStyleAndLayoutData>>,
|
||||||
|
|
||||||
/// Registered observers for this node.
|
|
||||||
mutation_observers: DomRefCell<Vec<RegisteredObserver>>,
|
|
||||||
|
|
||||||
unique_id: UniqueId,
|
unique_id: UniqueId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,12 +450,13 @@ impl Node {
|
||||||
|
|
||||||
/// Return all registered mutation observers for this node.
|
/// Return all registered mutation observers for this node.
|
||||||
pub fn registered_mutation_observers(&self) -> RefMut<Vec<RegisteredObserver>> {
|
pub fn registered_mutation_observers(&self) -> RefMut<Vec<RegisteredObserver>> {
|
||||||
self.mutation_observers.borrow_mut()
|
self.rare_data.mutation_observers.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes the mutation observer for a given node.
|
/// Removes the mutation observer for a given node.
|
||||||
pub fn remove_mutation_observer(&self, observer: &MutationObserver) {
|
pub fn remove_mutation_observer(&self, observer: &MutationObserver) {
|
||||||
self.mutation_observers
|
self.rare_data
|
||||||
|
.mutation_observers
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.retain(|reg_obs| &*reg_obs.observer != observer)
|
.retain(|reg_obs| &*reg_obs.observer != observer)
|
||||||
}
|
}
|
||||||
|
@ -1652,8 +1649,6 @@ impl Node {
|
||||||
|
|
||||||
style_and_layout_data: Cell::new(None),
|
style_and_layout_data: Cell::new(None),
|
||||||
|
|
||||||
mutation_observers: Default::default(),
|
|
||||||
|
|
||||||
unique_id: UniqueId::new(),
|
unique_id: UniqueId::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::root::MutNullableDom;
|
use crate::dom::bindings::root::MutNullableDom;
|
||||||
|
use crate::dom::mutationobserver::RegisteredObserver;
|
||||||
use crate::dom::shadowroot::ShadowRoot;
|
use crate::dom::shadowroot::ShadowRoot;
|
||||||
|
|
||||||
#[derive(Default, JSTraceable, MallocSizeOf)]
|
#[derive(Default, JSTraceable, MallocSizeOf)]
|
||||||
|
@ -12,6 +14,8 @@ pub struct NodeRareData {
|
||||||
/// This is None if the node is not in a shadow tree or
|
/// This is None if the node is not in a shadow tree or
|
||||||
/// if it is a ShadowRoot.
|
/// if it is a ShadowRoot.
|
||||||
pub owner_shadow_root: MutNullableDom<ShadowRoot>,
|
pub owner_shadow_root: MutNullableDom<ShadowRoot>,
|
||||||
|
/// Registered observers for this node.
|
||||||
|
pub mutation_observers: DomRefCell<Vec<RegisteredObserver>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, JSTraceable, MallocSizeOf)]
|
#[derive(Default, JSTraceable, MallocSizeOf)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue