mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +01:00
Drop style data from descendants on display:none.
MozReview-Commit-ID: 8ls43oAGWRg
This commit is contained in:
parent
1a5e2b4673
commit
fb70ee2c0c
8 changed files with 66 additions and 18 deletions
|
@ -28,6 +28,7 @@ pub struct RecalcStyleAndConstructFlows<'lc> {
|
|||
root: OpaqueNode,
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl<'lc, N> DomTraversalContext<N> for RecalcStyleAndConstructFlows<'lc>
|
||||
where N: LayoutNode + TNode,
|
||||
N::ConcreteElement: LayoutElement
|
||||
|
@ -133,12 +134,15 @@ impl<'lc, N> DomTraversalContext<N> for RecalcStyleAndConstructFlows<'lc>
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn ensure_element_data(element: &N::ConcreteElement) -> &AtomicRefCell<ElementData> {
|
||||
element.as_node().initialize_data();
|
||||
element.get_data().unwrap()
|
||||
}
|
||||
|
||||
unsafe fn clear_element_data(element: &N::ConcreteElement) {
|
||||
element.as_node().clear_data();
|
||||
}
|
||||
|
||||
fn local_context(&self) -> &LocalStyleContext {
|
||||
self.context.local_context()
|
||||
}
|
||||
|
|
|
@ -42,6 +42,12 @@ use style::traversal::prepare_for_styling;
|
|||
|
||||
pub type NonOpaqueStyleAndLayoutData = AtomicRefCell<PersistentLayoutData>;
|
||||
|
||||
pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) {
|
||||
let ptr: *mut AtomicRefCell<PartialPersistentLayoutData> = *data.ptr;
|
||||
let non_opaque: *mut NonOpaqueStyleAndLayoutData = ptr as *mut _;
|
||||
let _ = Box::from_raw(non_opaque);
|
||||
}
|
||||
|
||||
pub trait LayoutNodeLayoutData {
|
||||
/// Similar to borrow_data*, but returns the full PersistentLayoutData rather
|
||||
/// than only the style::data::ElementData.
|
||||
|
@ -79,6 +85,7 @@ impl<T: GetLayoutData> GetRawData for T {
|
|||
|
||||
pub trait LayoutNodeHelpers {
|
||||
fn initialize_data(&self);
|
||||
fn clear_data(&self);
|
||||
}
|
||||
|
||||
impl<T: LayoutNode> LayoutNodeHelpers for T {
|
||||
|
@ -95,6 +102,12 @@ impl<T: LayoutNode> LayoutNodeHelpers for T {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn clear_data(&self) {
|
||||
if self.get_raw_data().is_some() {
|
||||
unsafe { drop_style_and_layout_data(self.take_style_and_layout_data()) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ThreadSafeLayoutNodeHelpers {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue