aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/layout_wrapper.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_wrapper.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_wrapper.rs')
-rw-r--r--components/script/layout_wrapper.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs
index 5241d01785d..bf75761cba6 100644
--- a/components/script/layout_wrapper.rs
+++ b/components/script/layout_wrapper.rs
@@ -47,7 +47,7 @@ use html5ever::{LocalName, Namespace};
use msg::constellation_msg::{BrowsingContextId, PipelineId};
use range::Range;
use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress};
-use script_layout_interface::{OpaqueStyleAndLayoutData, PartialPersistentLayoutData};
+use script_layout_interface::{OpaqueStyleAndLayoutData, StyleData};
use script_layout_interface::wrapper_traits::{DangerousThreadSafeLayoutNode, GetLayoutData, LayoutNode};
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use selectors::attr::{AttrSelectorOperation, NamespaceConstraint};
@@ -452,12 +452,12 @@ impl<'le> TElement for ServoLayoutElement<'le> {
}
fn store_children_to_process(&self, n: isize) {
- let data = self.get_partial_layout_data().unwrap().borrow();
+ let data = self.get_style_data().unwrap();
data.parallel.children_to_process.store(n, Ordering::Relaxed);
}
fn did_process_child(&self) -> isize {
- let data = self.get_partial_layout_data().unwrap().borrow();
+ let data = self.get_style_data().unwrap();
let old_value = data.parallel.children_to_process.fetch_sub(1, Ordering::Relaxed);
debug_assert!(old_value >= 1);
old_value - 1
@@ -466,9 +466,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
fn get_data(&self) -> Option<&AtomicRefCell<ElementData>> {
unsafe {
self.get_style_and_layout_data().map(|d| {
- let ppld: &AtomicRefCell<PartialPersistentLayoutData> = &*d.ptr.get();
- let psd: &AtomicRefCell<ElementData> = transmute(ppld);
- psd
+ &(*d.ptr.get()).element_data
})
}
}
@@ -537,7 +535,7 @@ impl<'le> ServoLayoutElement<'le> {
}
}
- fn get_partial_layout_data(&self) -> Option<&AtomicRefCell<PartialPersistentLayoutData>> {
+ fn get_style_data(&self) -> Option<&StyleData> {
unsafe {
self.get_style_and_layout_data().map(|d| &*d.ptr.get())
}