diff options
-rw-r--r-- | components/layout/data.rs | 2 | ||||
-rw-r--r-- | components/layout/traversal.rs | 2 | ||||
-rw-r--r-- | components/layout/wrapper.rs | 4 | ||||
-rw-r--r-- | components/script/dom/node.rs | 22 | ||||
-rw-r--r-- | tests/unit/script/size_of.rs | 14 |
5 files changed, 17 insertions, 27 deletions
diff --git a/components/layout/data.rs b/components/layout/data.rs index e26e0a28431..75831d7c2ff 100644 --- a/components/layout/data.rs +++ b/components/layout/data.rs @@ -7,7 +7,6 @@ use incremental::RestyleDamage; use msg::constellation_msg::ConstellationChan; use parallel::DomParallelInfo; use script::dom::node::SharedLayoutData; -use script::layout_interface::LayoutChan; use std::sync::Arc; use style::properties::ComputedValues; @@ -61,7 +60,6 @@ bitflags! { } pub struct LayoutDataWrapper { - pub chan: Option<LayoutChan>, pub shared_data: SharedLayoutData, pub data: Box<PrivateLayoutData>, } diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index dcfd4ef19bb..603245ecb88 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -132,7 +132,7 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> { // // FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML // parser. - node.initialize_layout_data(self.layout_context.shared.layout_chan.clone()); + node.initialize_layout_data(); // Get the parent node. let parent_opt = node.layout_parent_node(self.layout_context.shared); diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 020d6af3bbe..4de67c7e6c9 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -56,7 +56,6 @@ use script::dom::node::{Node, NodeTypeId}; use script::dom::node::{LayoutNodeHelpers, RawLayoutNodeHelpers, SharedLayoutData}; use script::dom::node::{HAS_CHANGED, IS_DIRTY, HAS_DIRTY_SIBLINGS, HAS_DIRTY_DESCENDANTS}; use script::dom::text::Text; -use script::layout_interface::LayoutChan; use smallvec::VecLike; use msg::constellation_msg::{PipelineId, SubpageId}; use util::str::is_whitespace; @@ -179,12 +178,11 @@ impl<'ln> LayoutNode<'ln> { /// Resets layout data and styles for the node. /// /// FIXME(pcwalton): Do this as part of fragment building instead of in a traversal. - pub fn initialize_layout_data(self, chan: LayoutChan) { + pub fn initialize_layout_data(self) { let mut layout_data_ref = self.mutate_layout_data(); match *layout_data_ref { None => { *layout_data_ref = Some(LayoutDataWrapper { - chan: Some(chan), shared_data: SharedLayoutData { style: None }, data: box PrivateLayoutData::new(), }); diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index b69dd3fad46..2d009dd4159 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -191,7 +191,7 @@ impl NodeFlags { impl Drop for Node { #[allow(unsafe_code)] fn drop(&mut self) { - self.layout_data.dispose(); + self.layout_data.dispose(self); } } @@ -212,7 +212,6 @@ pub struct SharedLayoutData { /// Encapsulates the abstract layout data. pub struct LayoutData { - chan: Option<LayoutChan>, _shared_data: SharedLayoutData, _data: NonZero<*const ()>, } @@ -234,17 +233,12 @@ impl LayoutDataRef { } /// Sends layout data, if any, back to the layout task to be destroyed. - pub fn dispose(&self) { + pub fn dispose(&self, node: &Node) { debug_assert!(task_state::get().is_script()); - if let Some(mut layout_data) = mem::replace(&mut *self.data_cell.borrow_mut(), None) { - let layout_chan = layout_data.chan.take(); - match layout_chan { - None => {} - Some(chan) => { - let LayoutChan(chan) = chan; - chan.send(Msg::ReapLayoutData(layout_data)).unwrap() - } - } + if let Some(layout_data) = mem::replace(&mut *self.data_cell.borrow_mut(), None) { + let win = window_from_node(node); + let LayoutChan(chan) = win.layout_chan(); + chan.send(Msg::ReapLayoutData(layout_data)).unwrap() } } @@ -317,7 +311,7 @@ impl<'a> PrivateNodeHelpers for &'a Node { node.r().set_flag(IS_IN_DOC, false); vtable_for(&node.r()).unbind_from_tree(parent_in_doc); } - self.layout_data.dispose(); + self.layout_data.dispose(self); } // @@ -535,7 +529,7 @@ pub trait NodeHelpers { impl<'a> NodeHelpers for &'a Node { fn teardown(self) { - self.layout_data.dispose(); + self.layout_data.dispose(self); for kid in self.children() { kid.r().teardown(); } diff --git a/tests/unit/script/size_of.rs b/tests/unit/script/size_of.rs index d32f2bf4375..cea905ef545 100644 --- a/tests/unit/script/size_of.rs +++ b/tests/unit/script/size_of.rs @@ -39,10 +39,10 @@ macro_rules! sizeof_checker ( // Update the sizes here sizeof_checker!(size_event_target, EventTarget, 48); -sizeof_checker!(size_node, Node, 216); -sizeof_checker!(size_element, Element, 328); -sizeof_checker!(size_htmlelement, HTMLElement, 344); -sizeof_checker!(size_div, HTMLDivElement, 344); -sizeof_checker!(size_span, HTMLSpanElement, 344); -sizeof_checker!(size_text, Text, 248); -sizeof_checker!(size_characterdata, CharacterData, 248); +sizeof_checker!(size_node, Node, 184); +sizeof_checker!(size_element, Element, 296); +sizeof_checker!(size_htmlelement, HTMLElement, 312); +sizeof_checker!(size_div, HTMLDivElement, 312); +sizeof_checker!(size_span, HTMLSpanElement, 312); +sizeof_checker!(size_text, Text, 216); +sizeof_checker!(size_characterdata, CharacterData, 216); |