mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
dom: Move child_list to rare data (#35592)
This is only created when calling the ChildNodes method. Gecko also stores it in their similar data structure at https://searchfox.org/mozilla-central/rev/155d514d72473453492a822e97dc1c68cf49d110/dom/base/nsINode.h#1464 Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
parent
6a182c345c
commit
f7c1cd4635
3 changed files with 19 additions and 15 deletions
|
@ -146,9 +146,6 @@ pub struct Node {
|
|||
/// Rare node data.
|
||||
rare_data: DomRefCell<Option<Box<NodeRareData>>>,
|
||||
|
||||
/// The live list of children return by .childNodes.
|
||||
child_list: MutNullableDom<NodeList>,
|
||||
|
||||
/// The live count of children of this node.
|
||||
children_count: Cell<u32>,
|
||||
|
||||
|
@ -1968,7 +1965,6 @@ impl Node {
|
|||
prev_sibling: Default::default(),
|
||||
owner_doc: MutNullableDom::new(doc),
|
||||
rare_data: Default::default(),
|
||||
child_list: Default::default(),
|
||||
children_count: Cell::new(0u32),
|
||||
flags: Cell::new(flags),
|
||||
inclusive_descendants_version: Cell::new(0),
|
||||
|
@ -2928,7 +2924,7 @@ impl NodeMethods<crate::DomTypeHolder> for Node {
|
|||
|
||||
/// <https://dom.spec.whatwg.org/#dom-node-childnodes>
|
||||
fn ChildNodes(&self) -> DomRoot<NodeList> {
|
||||
self.child_list.or_init(|| {
|
||||
self.ensure_rare_data().child_list.or_init(|| {
|
||||
let doc = self.owner_doc();
|
||||
let window = doc.window();
|
||||
NodeList::new_child_list(window, self)
|
||||
|
@ -3608,9 +3604,13 @@ impl VirtualMethods for Node {
|
|||
if let Some(s) = self.super_type() {
|
||||
s.children_changed(mutation);
|
||||
}
|
||||
if let Some(list) = self.child_list.get() {
|
||||
list.as_children_list().children_changed(mutation);
|
||||
|
||||
if let Some(data) = self.rare_data().as_ref() {
|
||||
if let Some(list) = data.child_list.get() {
|
||||
list.as_children_list().children_changed(mutation);
|
||||
}
|
||||
}
|
||||
|
||||
self.owner_doc().content_and_heritage_changed(self);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::rc::Rc;
|
|||
use euclid::default::Rect;
|
||||
use servo_atoms::Atom;
|
||||
|
||||
use crate::dom::bindings::root::Dom;
|
||||
use crate::dom::bindings::root::{Dom, MutNullableDom};
|
||||
use crate::dom::customelementregistry::{
|
||||
CustomElementDefinition, CustomElementReaction, CustomElementState,
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ use crate::dom::htmlslotelement::SlottableData;
|
|||
use crate::dom::intersectionobserver::IntersectionObserverRegistration;
|
||||
use crate::dom::mutationobserver::RegisteredObserver;
|
||||
use crate::dom::node::UniqueId;
|
||||
use crate::dom::nodelist::NodeList;
|
||||
use crate::dom::range::WeakRangeVec;
|
||||
use crate::dom::shadowroot::ShadowRoot;
|
||||
use crate::dom::window::LayoutValue;
|
||||
|
@ -42,6 +43,9 @@ pub(crate) struct NodeRareData {
|
|||
/// twice in this vector, even if both the start and end containers
|
||||
/// are this node.
|
||||
pub(crate) ranges: WeakRangeVec,
|
||||
|
||||
/// The live list of children return by .childNodes.
|
||||
pub(crate) child_list: MutNullableDom<NodeList>,
|
||||
}
|
||||
|
||||
#[derive(Default, JSTraceable, MallocSizeOf)]
|
||||
|
|
|
@ -30,10 +30,10 @@ macro_rules! sizeof_checker (
|
|||
|
||||
// Update the sizes here
|
||||
sizeof_checker!(size_event_target, EventTarget, 48);
|
||||
sizeof_checker!(size_node, Node, 176);
|
||||
sizeof_checker!(size_element, Element, 352);
|
||||
sizeof_checker!(size_htmlelement, HTMLElement, 368);
|
||||
sizeof_checker!(size_div, HTMLDivElement, 368);
|
||||
sizeof_checker!(size_span, HTMLSpanElement, 368);
|
||||
sizeof_checker!(size_text, Text, 208);
|
||||
sizeof_checker!(size_characterdata, CharacterData, 208);
|
||||
sizeof_checker!(size_node, Node, 168);
|
||||
sizeof_checker!(size_element, Element, 344);
|
||||
sizeof_checker!(size_htmlelement, HTMLElement, 360);
|
||||
sizeof_checker!(size_div, HTMLDivElement, 360);
|
||||
sizeof_checker!(size_span, HTMLSpanElement, 360);
|
||||
sizeof_checker!(size_text, Text, 200);
|
||||
sizeof_checker!(size_characterdata, CharacterData, 200);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue