mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Make DOM own the style and layout data, in an UnsafeCell
The previous Cell was a lie.
This commit is contained in:
parent
516e8e0aa6
commit
185a402d9c
17 changed files with 74 additions and 180 deletions
|
@ -369,7 +369,7 @@ pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode<'dom> + Send + Sync {
|
|||
fn style(self, context: &LayoutContext) -> ServoArc<ComputedValues>;
|
||||
|
||||
fn as_opaque(self) -> OpaqueNode;
|
||||
fn layout_data_mut(&self) -> AtomicRefMut<LayoutDataForElement>;
|
||||
fn layout_data_mut(self) -> AtomicRefMut<'dom, LayoutDataForElement>;
|
||||
fn element_box_slot(&self) -> BoxSlot<'dom>;
|
||||
fn pseudo_element_box_slot(&self, which: WhichPseudoElement) -> BoxSlot<'dom>;
|
||||
fn unset_pseudo_element_box(self, which: WhichPseudoElement);
|
||||
|
@ -447,12 +447,10 @@ where
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn layout_data_mut(&self) -> AtomicRefMut<LayoutDataForElement> {
|
||||
unsafe {
|
||||
self.get_raw_data()
|
||||
.map(|d| d.layout_data.borrow_mut())
|
||||
.unwrap()
|
||||
}
|
||||
fn layout_data_mut(self) -> AtomicRefMut<'dom, LayoutDataForElement> {
|
||||
self.get_raw_data()
|
||||
.map(|d| d.layout_data.borrow_mut())
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn element_box_slot(&self) -> BoxSlot<'dom> {
|
||||
|
|
|
@ -63,7 +63,7 @@ where
|
|||
}
|
||||
|
||||
fn text_node_needs_traversal(node: E::ConcreteNode, parent_data: &ElementData) -> bool {
|
||||
(unsafe { node.get_raw_data().is_none() }) || !parent_data.damage.is_empty()
|
||||
node.get_raw_data().is_none() || !parent_data.damage.is_empty()
|
||||
}
|
||||
|
||||
fn shared_context(&self) -> &SharedStyleContext {
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
use crate::data::StyleAndLayoutData;
|
||||
use script_layout_interface::wrapper_traits::GetLayoutData;
|
||||
|
||||
pub trait GetRawData {
|
||||
unsafe fn get_raw_data(&self) -> Option<&StyleAndLayoutData>;
|
||||
pub trait GetRawData<'dom> {
|
||||
fn get_raw_data(self) -> Option<&'dom StyleAndLayoutData>;
|
||||
}
|
||||
|
||||
impl<'dom, T> GetRawData for T
|
||||
impl<'dom, T> GetRawData<'dom> for T
|
||||
where
|
||||
T: GetLayoutData<'dom>,
|
||||
{
|
||||
unsafe fn get_raw_data(&self) -> Option<&StyleAndLayoutData> {
|
||||
fn get_raw_data(self) -> Option<&'dom StyleAndLayoutData> {
|
||||
self.get_style_and_layout_data()
|
||||
.map(|opaque| opaque.downcast_ref().unwrap())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue