Reap layout data whenever a node is removed from the tree.

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:
Glenn Watson 2015-02-27 16:29:02 +10:00
parent 8ad3c5aeb6
commit 611fd7a846
5 changed files with 35 additions and 40 deletions

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.