aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_layout_interface/lib.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-05-24 19:15:12 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-05-25 10:31:40 +0200
commitdeaa935f5b776c6ca04ed37c8b5ae4c8311b0efb (patch)
tree4eebdabfe99772f4127a71705b451768c9b19cf0 /components/script_layout_interface/lib.rs
parentbb310efbb9e84cf0bd44170c4e08bac664f0ce86 (diff)
downloadservo-deaa935f5b776c6ca04ed37c8b5ae4c8311b0efb.tar.gz
servo-deaa935f5b776c6ca04ed37c8b5ae4c8311b0efb.zip
layout: Stop doing unsafe transmutes between refcell references.
This commit splits the style and layout data in two separate refcells. These transmutes have been a source of trouble (for example on Android), and they feel like a hack anyway. Fixes #16982
Diffstat (limited to 'components/script_layout_interface/lib.rs')
-rw-r--r--components/script_layout_interface/lib.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs
index ddeed0d6366..e3d791b7774 100644
--- a/components/script_layout_interface/lib.rs
+++ b/components/script_layout_interface/lib.rs
@@ -51,35 +51,32 @@ use std::sync::atomic::AtomicIsize;
use style::data::ElementData;
#[repr(C)]
-pub struct PartialPersistentLayoutData {
+pub struct StyleData {
/// Data that the style system associates with a node. When the
/// style system is being used standalone, this is all that hangs
/// off the node. This must be first to permit the various
/// transmutations between ElementData and PersistentLayoutData.
- pub style_data: ElementData,
+ pub element_data: AtomicRefCell<ElementData>,
/// Information needed during parallel traversals.
pub parallel: DomParallelInfo,
-
- // Required alignment for safe transmutes between PersistentLayoutData and PartialPersistentLayoutData.
- _align: [u64; 0]
}
-impl PartialPersistentLayoutData {
+impl StyleData {
pub fn new() -> Self {
- PartialPersistentLayoutData {
- style_data: ElementData::new(None),
+ Self {
+ element_data: AtomicRefCell::new(ElementData::new(None)),
parallel: DomParallelInfo::new(),
- _align: [],
}
}
}
#[derive(Copy, Clone, HeapSizeOf)]
pub struct OpaqueStyleAndLayoutData {
+ // NB: We really store a `StyleAndLayoutData` here, so be careful!
#[ignore_heap_size_of = "TODO(#6910) Box value that should be counted but \
the type lives in layout"]
- pub ptr: NonZero<*mut AtomicRefCell<PartialPersistentLayoutData>>
+ pub ptr: NonZero<*mut StyleData>
}
#[allow(unsafe_code)]