aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2015-11-06 23:15:41 +0100
committerMs2ger <Ms2ger@gmail.com>2015-11-07 11:23:49 +0100
commit647232a495ddeaa403ea3a846ff7699a3d04266b (patch)
tree6b860f020c6d191428f04b49eef0070bcbe84653
parente9b77628ce1caf4c9bb77d98c95fe7ff71dddb32 (diff)
downloadservo-647232a495ddeaa403ea3a846ff7699a3d04266b.tar.gz
servo-647232a495ddeaa403ea3a846ff7699a3d04266b.zip
Wrap SharedLayoutContext::stylist in a wrapper to make it Sync.
-rw-r--r--components/layout/context.rs9
-rw-r--r--components/layout/layout_task.rs4
-rw-r--r--components/layout/traversal.rs2
3 files changed, 10 insertions, 5 deletions
diff --git a/components/layout/context.rs b/components/layout/context.rs
index 86d98e8a4fa..3d5196fac84 100644
--- a/components/layout/context.rs
+++ b/components/layout/context.rs
@@ -74,6 +74,12 @@ fn create_or_get_local_context(shared_layout_context: &SharedLayoutContext)
})
}
+pub struct StylistWrapper(pub *const Stylist);
+
+// FIXME(#6569) This implementation is unsound.
+#[allow(unsafe_code)]
+unsafe impl Sync for StylistWrapper {}
+
/// Layout information shared among all workers. This must be thread-safe.
pub struct SharedLayoutContext {
/// The shared image cache task.
@@ -94,7 +100,7 @@ pub struct SharedLayoutContext {
/// The CSS selector stylist.
///
/// FIXME(#2604): Make this no longer an unsafe pointer once we have fast `RWArc`s.
- pub stylist: *const Stylist,
+ pub stylist: StylistWrapper,
/// The URL.
pub url: Url,
@@ -122,7 +128,6 @@ pub struct SharedLayoutContext {
// FIXME(#6569) This implementations is unsound:
// XXX UNSOUND!!! for image_cache_task
-// XXX UNSOUND!!! for stylist
#[allow(unsafe_code)]
unsafe impl Sync for SharedLayoutContext {}
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs
index d39f6c06a7a..8881a174dec 100644
--- a/components/layout/layout_task.rs
+++ b/components/layout/layout_task.rs
@@ -12,7 +12,7 @@ use app_units::Au;
use azure::azure::AzColor;
use canvas_traits::CanvasMsg;
use construct::ConstructionResult;
-use context::{SharedLayoutContext, heap_size_of_local_context};
+use context::{SharedLayoutContext, StylistWrapper, heap_size_of_local_context};
use cssparser::ToCss;
use data::LayoutDataWrapper;
use display_list_builder::ToGfxColor;
@@ -457,7 +457,7 @@ impl LayoutTask {
screen_size_changed: screen_size_changed,
font_cache_task: Mutex::new(self.font_cache_task.clone()),
canvas_layers_sender: Mutex::new(self.canvas_layers_sender.clone()),
- stylist: &*rw_data.stylist,
+ stylist: StylistWrapper(&*rw_data.stylist),
url: (*url).clone(),
visible_rects: rw_data.visible_rects.clone(),
generation: rw_data.generation,
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs
index 34427b9d8d9..3a1fcf38bc6 100644
--- a/components/layout/traversal.rs
+++ b/components/layout/traversal.rs
@@ -188,7 +188,7 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
let shareable_element = match node.as_element() {
Some(element) => {
// Perform the CSS selector matching.
- let stylist = unsafe { &*self.layout_context.shared.stylist };
+ let stylist = unsafe { &*self.layout_context.shared.stylist.0 };
if element.match_element(stylist,
Some(&*bf),
&mut applicable_declarations) {