auto merge of #5086 : glennw/servo/reap-more-stuff, r=jdm

Also introduce a clear() function to layout data which will be used to clear items such as compositor layouts.

Clear the layout data when a node becomes display:none.
This commit is contained in:
bors-servo 2015-03-02 16:45:51 -07:00
commit 65454e51c8
5 changed files with 35 additions and 40 deletions

View file

@ -1329,6 +1329,13 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
let mut layout_data_ref = self.mutate_layout_data();
let layout_data = layout_data_ref.as_mut().expect("no layout data");
match result {
ConstructionResult::None => {
layout_data.clear();
}
_ => {}
}
let dst = self.get_construction_result(layout_data);
*dst = result;

View file

@ -35,7 +35,7 @@ use gfx::paint_task::Msg as PaintMsg;
use layout_traits::{LayoutControlMsg, LayoutTaskFactory};
use log;
use script::dom::bindings::js::LayoutJS;
use script::dom::node::{LayoutDataRef, Node, NodeTypeId};
use script::dom::node::{LayoutData, Node, NodeTypeId};
use script::dom::element::ElementTypeId;
use script::dom::htmlelement::HTMLElementTypeId;
use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse};
@ -937,11 +937,10 @@ impl LayoutTask {
}
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
/// because it contains local managed pointers.
unsafe fn handle_reap_layout_data(layout_data: LayoutDataRef) {
let mut layout_data_ref = layout_data.borrow_mut();
let _: Option<LayoutDataWrapper> = mem::transmute(
mem::replace(&mut *layout_data_ref, None));
/// because the struct type is transmuted to a different type on the script side.
unsafe fn handle_reap_layout_data(layout_data: LayoutData) {
let layout_data_wrapper: LayoutDataWrapper = mem::transmute(layout_data);
layout_data_wrapper.clear();
}
/// Returns profiling information which is passed to the time profiler.

View file

@ -78,6 +78,12 @@ pub struct LayoutDataWrapper {
pub data: Box<PrivateLayoutData>,
}
impl LayoutDataWrapper {
pub fn clear(&self) {
// TODO: Clear items related to this node, e.g. compositor layers
}
}
#[allow(dead_code)]
fn static_assertion(x: Option<LayoutDataWrapper>) {
unsafe {