mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #26105 - servo:layout-2020-less-opaque, r=emilio
Make DOM own the style and layout data, in an UnsafeCell
This commit is contained in:
commit
d64f7d427a
21 changed files with 184 additions and 247 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);
|
||||
|
@ -446,7 +446,8 @@ where
|
|||
self.opaque()
|
||||
}
|
||||
|
||||
fn layout_data_mut(&self) -> AtomicRefMut<LayoutDataForElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn layout_data_mut(self) -> AtomicRefMut<'dom, LayoutDataForElement> {
|
||||
self.get_raw_data()
|
||||
.map(|d| d.layout_data.borrow_mut())
|
||||
.unwrap()
|
||||
|
|
|
@ -7,18 +7,16 @@
|
|||
use crate::data::StyleAndLayoutData;
|
||||
use script_layout_interface::wrapper_traits::GetLayoutData;
|
||||
|
||||
pub trait GetRawData {
|
||||
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>,
|
||||
{
|
||||
fn get_raw_data(&self) -> Option<&StyleAndLayoutData> {
|
||||
self.get_style_and_layout_data().map(|opaque| {
|
||||
let container = opaque.ptr.as_ptr() as *mut StyleAndLayoutData;
|
||||
unsafe { &*container }
|
||||
})
|
||||
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