aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-05-02 20:01:10 -0500
committerGitHub <noreply@github.com>2017-05-02 20:01:10 -0500
commit7b1006936a27232fb77fef5893cc141e66bb12b7 (patch)
tree750a15b93482d99f1aadd7afe507dd910516a6d1
parent536d63c67028c7368dff780945626283d2c48f1c (diff)
parentfd1c814e7812e68e1207165c9387ddcfd8a6379b (diff)
downloadservo-7b1006936a27232fb77fef5893cc141e66bb12b7.tar.gz
servo-7b1006936a27232fb77fef5893cc141e66bb12b7.zip
Auto merge of #16702 - bholley:custom_arc, r=emilio
Use a custom arc in the style system See https://bugzilla.mozilla.org/show_bug.cgi?id=1360889 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16702) <!-- Reviewable:end -->
-rw-r--r--components/gfx/font_context.rs5
-rw-r--r--components/layout/block.rs2
-rw-r--r--components/layout/construct.rs7
-rw-r--r--components/layout/display_list_builder.rs2
-rw-r--r--components/layout/flex.rs3
-rw-r--r--components/layout/flow.rs6
-rw-r--r--components/layout/fragment.rs16
-rw-r--r--components/layout/generated_content.rs5
-rw-r--r--components/layout/inline.rs10
-rw-r--r--components/layout/lib.rs12
-rw-r--r--components/layout/list_item.rs3
-rw-r--r--components/layout/multicol.rs5
-rw-r--r--components/layout/query.rs2
-rw-r--r--components/layout/table.rs3
-rw-r--r--components/layout/table_caption.rs3
-rw-r--r--components/layout/table_cell.rs3
-rw-r--r--components/layout/table_colgroup.rs3
-rw-r--r--components/layout/table_row.rs3
-rw-r--r--components/layout/table_rowgroup.rs3
-rw-r--r--components/layout/table_wrapper.rs3
-rw-r--r--components/layout/text.rs2
-rw-r--r--components/layout_thread/lib.rs19
-rw-r--r--components/script/dom/bindings/trace.rs7
-rw-r--r--components/script/dom/cssconditionrule.rs2
-rw-r--r--components/script/dom/cssfontfacerule.rs2
-rw-r--r--components/script/dom/cssgroupingrule.rs2
-rw-r--r--components/script/dom/cssimportrule.rs2
-rw-r--r--components/script/dom/csskeyframerule.rs2
-rw-r--r--components/script/dom/csskeyframesrule.rs2
-rw-r--r--components/script/dom/cssmediarule.rs2
-rw-r--r--components/script/dom/cssnamespacerule.rs2
-rw-r--r--components/script/dom/cssrulelist.rs2
-rw-r--r--components/script/dom/cssstyledeclaration.rs2
-rw-r--r--components/script/dom/cssstylerule.rs2
-rw-r--r--components/script/dom/cssstylesheet.rs2
-rw-r--r--components/script/dom/csssupportsrule.rs2
-rw-r--r--components/script/dom/cssviewportrule.rs2
-rw-r--r--components/script/dom/document.rs2
-rw-r--r--components/script/dom/element.rs2
-rw-r--r--components/script/dom/htmllinkelement.rs2
-rw-r--r--components/script/dom/htmlmetaelement.rs2
-rwxr-xr-xcomponents/script/dom/htmlobjectelement.rs2
-rw-r--r--components/script/dom/htmlstyleelement.rs2
-rw-r--r--components/script/dom/medialist.rs2
-rw-r--r--components/script/dom/node.rs2
-rw-r--r--components/script/layout_wrapper.rs2
-rw-r--r--components/script/stylesheet_loader.rs5
-rw-r--r--components/script_layout_interface/message.rs4
-rw-r--r--components/script_layout_interface/wrapper_traits.rs2
-rw-r--r--components/style/animation.rs2
-rw-r--r--components/style/attr.rs2
-rw-r--r--components/style/context.rs3
-rw-r--r--components/style/custom_properties.rs2
-rw-r--r--components/style/data.rs2
-rw-r--r--components/style/dom.rs2
-rw-r--r--components/style/encoding_support.rs2
-rw-r--r--components/style/gecko/data.rs2
-rw-r--r--components/style/gecko/media_queries.rs2
-rw-r--r--components/style/gecko/restyle_damage.rs2
-rw-r--r--components/style/gecko/url.rs2
-rw-r--r--components/style/gecko/wrapper.rs2
-rw-r--r--components/style/gecko_bindings/sugar/ownership.rs2
-rw-r--r--components/style/gecko_bindings/sugar/refptr.rs2
-rw-r--r--components/style/keyframes.rs2
-rw-r--r--components/style/lib.rs11
-rw-r--r--components/style/matching.rs6
-rw-r--r--components/style/properties/gecko.mako.rs2
-rw-r--r--components/style/properties/helpers.mako.rs4
-rw-r--r--components/style/properties/longhand/svg.mako.rs2
-rw-r--r--components/style/properties/properties.mako.rs18
-rw-r--r--components/style/rule_tree/mod.rs9
-rw-r--r--components/style/selector_parser.rs2
-rw-r--r--components/style/servo/restyle_damage.rs2
-rw-r--r--components/style/servo/url.rs3
-rw-r--r--components/style/shared_lock.rs4
-rw-r--r--components/style/stylearc.rs380
-rw-r--r--components/style/stylesheet_set.rs2
-rw-r--r--components/style/stylesheets.rs2
-rw-r--r--components/style/stylist.rs2
-rw-r--r--ports/geckolib/glue.rs3
-rw-r--r--ports/geckolib/stylesheet_loader.rs2
-rw-r--r--tests/unit/script/size_of.rs8
-rw-r--r--tests/unit/style/keyframes.rs2
-rw-r--r--tests/unit/style/media_queries.rs2
-rw-r--r--tests/unit/style/rule_tree/bench.rs2
-rw-r--r--tests/unit/style/stylesheets.rs2
-rw-r--r--tests/unit/style/stylist.rs2
-rw-r--r--tests/unit/style/viewport.rs2
88 files changed, 540 insertions, 149 deletions
diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs
index b1b9bbc6838..2e91e549611 100644
--- a/components/gfx/font_context.rs
+++ b/components/gfx/font_context.rs
@@ -21,6 +21,7 @@ use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use style::computed_values::{font_style, font_variant_caps};
use style::properties::style_structs;
+use style::stylearc::Arc as StyleArc;
use webrender_traits;
static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h)
@@ -109,7 +110,7 @@ impl FontContext {
/// Create a group of fonts for use in layout calculations. May return
/// a cached font if this font instance has already been used by
/// this context.
- pub fn layout_font_group_for_style(&mut self, style: Arc<style_structs::Font>)
+ pub fn layout_font_group_for_style(&mut self, style: StyleArc<style_structs::Font>)
-> Rc<FontGroup> {
self.expire_font_caches_if_necessary();
@@ -239,7 +240,7 @@ impl HeapSizeOf for FontContext {
#[derive(Debug)]
struct LayoutFontGroupCacheKey {
- pointer: Arc<style_structs::Font>,
+ pointer: StyleArc<style_structs::Font>,
size: Au,
}
diff --git a/components/layout/block.rs b/components/layout/block.rs
index 297bfcdc689..5e30c6f08ee 100644
--- a/components/layout/block.rs
+++ b/components/layout/block.rs
@@ -2134,7 +2134,7 @@ impl Flow for BlockFlow {
self.build_display_list_for_block(state, BorderPaintingMode::Separate);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.fragment.repair_style(new_style)
}
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index 089209551ac..2f24629b5e4 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -13,6 +13,7 @@
#![deny(unsafe_code)]
+use StyleArc;
use app_units::Au;
use block::BlockFlow;
use context::{LayoutContext, with_thread_local_font_context};
@@ -107,7 +108,7 @@ pub enum ConstructionItem {
/// Inline fragments and associated {ib} splits that have not yet found flows.
InlineFragments(InlineFragmentsConstructionResult),
/// Potentially ignorable whitespace.
- Whitespace(OpaqueNode, PseudoElementType<()>, Arc<ServoComputedValues>, RestyleDamage),
+ Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ServoComputedValues>, RestyleDamage),
/// TableColumn Fragment
TableColumnFragment(Fragment),
}
@@ -675,7 +676,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
fn create_fragments_for_node_text_content(&self,
fragments: &mut IntermediateInlineFragments,
node: &ConcreteThreadSafeLayoutNode,
- style: &Arc<ServoComputedValues>) {
+ style: &StyleArc<ServoComputedValues>) {
// Fast path: If there is no text content, return immediately.
let text_content = node.text_content();
if text_content.is_empty() {
@@ -1804,7 +1805,7 @@ pub fn strip_ignorable_whitespace_from_end(this: &mut LinkedList<Fragment>) {
/// If the 'unicode-bidi' property has a value other than 'normal', return the bidi control codes
/// to inject before and after the text content of the element.
-fn bidi_control_chars(style: &Arc<ServoComputedValues>) -> Option<(&'static str, &'static str)> {
+fn bidi_control_chars(style: &StyleArc<ServoComputedValues>) -> Option<(&'static str, &'static str)> {
use style::computed_values::direction::T::*;
use style::computed_values::unicode_bidi::T::*;
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index a2453067e1f..878b1220336 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -577,7 +577,7 @@ fn build_border_radius(abs_bounds: &Rect<Au>,
/// Get the border radius for the rectangle inside of a rounded border. This is useful
/// for building the clip for the content inside the border.
fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>,
- style: Arc<ServoComputedValues>)
+ style: ::StyleArc<ServoComputedValues>)
-> BorderRadii<Au> {
let mut radii = build_border_radius(&outer_rect, style.get_border());
if radii.is_square() {
diff --git a/components/layout/flex.rs b/components/layout/flex.rs
index cf77455afa8..dd990c61510 100644
--- a/components/layout/flex.rs
+++ b/components/layout/flex.rs
@@ -21,7 +21,6 @@ use model::{IntrinsicISizes, MaybeAuto, SizeConstraint};
use model::{specified, specified_or_none};
use std::cmp::{max, min};
use std::ops::Range;
-use std::sync::Arc;
use style::computed_values::{align_content, align_self, flex_direction, flex_wrap, justify_content};
use style::computed_values::border_collapse;
use style::logical_geometry::{Direction, LogicalSize};
@@ -970,7 +969,7 @@ impl Flow for FlexFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index 27b5c291cc8..1944f0decbd 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -424,7 +424,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
/// Attempts to perform incremental fixup of this flow by replacing its fragment's style with
/// the new style. This can only succeed if the flow has exactly one fragment.
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>);
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>);
/// Print any extra children (such as fragments) contained in this Flow
/// for debugging purposes. Any items inserted into the tree will become
@@ -561,7 +561,7 @@ pub trait MutableFlowUtils {
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
/// calling them individually, since there is no reason not to perform both operations.
- fn repair_style_and_bubble_inline_sizes(self, style: &Arc<ServoComputedValues>);
+ fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>);
}
pub trait MutableOwnedFlowUtils {
@@ -1361,7 +1361,7 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
/// calling them individually, since there is no reason not to perform both operations.
- fn repair_style_and_bubble_inline_sizes(self, style: &Arc<ServoComputedValues>) {
+ fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>) {
self.repair_style(style);
self.bubble_inline_sizes();
}
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index 5c311ec3311..9f98ff318ec 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -6,6 +6,7 @@
#![deny(unsafe_code)]
+use StyleArc;
use app_units::Au;
use canvas_traits::CanvasMsg;
use context::{LayoutContext, with_thread_local_font_context};
@@ -39,7 +40,6 @@ use std::borrow::ToOwned;
use std::cmp::{Ordering, max, min};
use std::collections::LinkedList;
use std::sync::{Arc, Mutex};
-use style::arc_ptr_eq;
use style::computed_values::{border_collapse, box_sizing, clear, color, display, mix_blend_mode};
use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration_line, transform};
use style::computed_values::{transform_style, vertical_align, white_space, word_break};
@@ -95,10 +95,10 @@ pub struct Fragment {
pub node: OpaqueNode,
/// The CSS style of this fragment.
- pub style: Arc<ServoComputedValues>,
+ pub style: StyleArc<ServoComputedValues>,
/// The CSS style of this fragment when it's selected
- pub selected_style: Arc<ServoComputedValues>,
+ pub selected_style: StyleArc<ServoComputedValues>,
/// The position of this fragment relative to its owning flow. The size includes padding and
/// border, but not margin.
@@ -672,8 +672,8 @@ impl Fragment {
/// Constructs a new `Fragment` instance from an opaque node.
pub fn from_opaque_node_and_style(node: OpaqueNode,
pseudo: PseudoElementType<()>,
- style: Arc<ServoComputedValues>,
- selected_style: Arc<ServoComputedValues>,
+ style: StyleArc<ServoComputedValues>,
+ selected_style: StyleArc<ServoComputedValues>,
mut restyle_damage: RestyleDamage,
specific: SpecificFragmentInfo)
-> Fragment {
@@ -702,7 +702,7 @@ impl Fragment {
/// type. For the new anonymous fragment, layout-related values (border box, etc.) are reset to
/// initial values.
pub fn create_similar_anonymous_fragment(&self,
- style: Arc<ServoComputedValues>,
+ style: StyleArc<ServoComputedValues>,
specific: SpecificFragmentInfo)
-> Fragment {
let writing_mode = style.writing_mode;
@@ -1846,7 +1846,7 @@ impl Fragment {
match (&mut self.specific, &next_fragment.specific) {
(&mut SpecificFragmentInfo::ScannedText(ref mut this_info),
&SpecificFragmentInfo::ScannedText(ref other_info)) => {
- debug_assert!(arc_ptr_eq(&this_info.run, &other_info.run));
+ debug_assert!(::arc_ptr_eq(&this_info.run, &other_info.run));
this_info.range_end_including_stripped_whitespace =
other_info.range_end_including_stripped_whitespace;
if other_info.requires_line_break_afterward_if_wrapping_on_newlines() {
@@ -2398,7 +2398,7 @@ impl Fragment {
}
}
- pub fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ pub fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) {
self.style = (*new_style).clone()
}
diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs
index a23fd165ecf..5f6f9b1e706 100644
--- a/components/layout/generated_content.rs
+++ b/components/layout/generated_content.rs
@@ -16,7 +16,6 @@ use gfx::display_list::OpaqueNode;
use script_layout_interface::wrapper_traits::PseudoElementType;
use smallvec::SmallVec;
use std::collections::{HashMap, LinkedList};
-use std::sync::Arc;
use style::computed_values::{display, list_style_type};
use style::computed_values::content::ContentItem;
use style::properties::ServoComputedValues;
@@ -369,7 +368,7 @@ impl Counter {
layout_context: &LayoutContext,
node: OpaqueNode,
pseudo: PseudoElementType<()>,
- style: Arc<ServoComputedValues>,
+ style: ::StyleArc<ServoComputedValues>,
list_style_type: list_style_type::T,
mode: RenderingMode)
-> Option<SpecificFragmentInfo> {
@@ -432,7 +431,7 @@ struct CounterValue {
fn render_text(layout_context: &LayoutContext,
node: OpaqueNode,
pseudo: PseudoElementType<()>,
- style: Arc<ServoComputedValues>,
+ style: ::StyleArc<ServoComputedValues>,
string: String)
-> Option<SpecificFragmentInfo> {
let mut fragments = LinkedList::new();
diff --git a/components/layout/inline.rs b/components/layout/inline.rs
index f28e583460f..d8cd4003ab3 100644
--- a/components/layout/inline.rs
+++ b/components/layout/inline.rs
@@ -4,6 +4,7 @@
#![deny(unsafe_code)]
+use StyleArc;
use app_units::Au;
use block::AbsoluteAssignBSizesTraversal;
use context::LayoutContext;
@@ -29,7 +30,6 @@ use std::{fmt, i32, isize, mem};
use std::cmp::max;
use std::collections::VecDeque;
use std::sync::Arc;
-use style::arc_ptr_eq;
use style::computed_values::{display, overflow_x, position, text_align, text_justify};
use style::computed_values::{vertical_align, white_space};
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
@@ -398,7 +398,7 @@ impl LineBreaker {
result.border_padding.inline_end == Au(0) &&
candidate.border_padding.inline_start == Au(0) &&
result_info.selected() == candidate_info.selected() &&
- arc_ptr_eq(&result_info.run, &candidate_info.run) &&
+ ::arc_ptr_eq(&result_info.run, &candidate_info.run) &&
inline_contexts_are_equal(&result.inline_context,
&candidate.inline_context)
}
@@ -1657,7 +1657,7 @@ impl Flow for InlineFlow {
self.build_display_list_for_inline(state);
}
- fn repair_style(&mut self, _: &Arc<ServoComputedValues>) {}
+ fn repair_style(&mut self, _: &StyleArc<ServoComputedValues>) {}
fn compute_overflow(&self) -> Overflow {
let mut overflow = Overflow::new();
@@ -1746,8 +1746,8 @@ impl fmt::Debug for InlineFlow {
#[derive(Clone)]
pub struct InlineFragmentNodeInfo {
pub address: OpaqueNode,
- pub style: Arc<ServoComputedValues>,
- pub selected_style: Arc<ServoComputedValues>,
+ pub style: StyleArc<ServoComputedValues>,
+ pub selected_style: StyleArc<ServoComputedValues>,
pub pseudo: PseudoElementType<()>,
pub flags: InlineFragmentNodeFlags,
}
diff --git a/components/layout/lib.rs b/components/layout/lib.rs
index 4c5bd766e24..dd86ba46cde 100644
--- a/components/layout/lib.rs
+++ b/components/layout/lib.rs
@@ -93,3 +93,15 @@ pub mod wrapper;
// For unit tests:
pub use fragment::Fragment;
pub use fragment::SpecificFragmentInfo;
+
+/// Returns whether the two arguments point to the same value.
+///
+/// FIXME: Remove this and use Arc::ptr_eq once we require Rust 1.17
+#[inline]
+pub fn arc_ptr_eq<T: 'static>(a: &::std::sync::Arc<T>, b: &::std::sync::Arc<T>) -> bool {
+ ::style::ptr_eq::<T>(&**a, &**b)
+}
+
+// We can't use stylearc for everything in layout, because the Flow stuff uses
+// weak references.
+use style::stylearc::Arc as StyleArc;
diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs
index cb260480cb9..8a79aaa40b7 100644
--- a/components/layout/list_item.rs
+++ b/components/layout/list_item.rs
@@ -18,7 +18,6 @@ use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedC
use fragment::Overflow;
use generated_content;
use inline::InlineFlow;
-use std::sync::Arc;
use style::computed_values::{list_style_type, position};
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
@@ -148,7 +147,7 @@ impl Flow for ListItemFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs
index 18cfe6409cb..b43a6eb17ff 100644
--- a/components/layout/multicol.rs
+++ b/components/layout/multicol.rs
@@ -6,6 +6,7 @@
#![deny(unsafe_code)]
+use StyleArc;
use app_units::Au;
use block::BlockFlow;
use context::LayoutContext;
@@ -193,7 +194,7 @@ impl Flow for MulticolFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
@@ -275,7 +276,7 @@ impl Flow for MulticolColumnFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
diff --git a/components/layout/query.rs b/components/layout/query.rs
index 92c3a1525dd..6b594066963 100644
--- a/components/layout/query.rs
+++ b/components/layout/query.rs
@@ -55,7 +55,7 @@ pub struct LayoutThreadData {
pub display_list: Option<Arc<DisplayList>>,
/// Performs CSS selector matching and style resolution.
- pub stylist: Arc<Stylist>,
+ pub stylist: ::StyleArc<Stylist>,
/// A queued response for the union of the content boxes of a node.
pub content_box_response: Option<Rect<Au>>,
diff --git a/components/layout/table.rs b/components/layout/table.rs
index b130b62bd04..c3ba52a305b 100644
--- a/components/layout/table.rs
+++ b/components/layout/table.rs
@@ -21,7 +21,6 @@ use layout_debug;
use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
use std::cmp;
use std::fmt;
-use std::sync::Arc;
use style::computed_values::{border_collapse, border_spacing, table_layout};
use style::context::SharedStyleContext;
use style::logical_geometry::LogicalSize;
@@ -507,7 +506,7 @@ impl Flow for TableFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs
index fe3eb5bf692..99d95fd9587 100644
--- a/components/layout/table_caption.rs
+++ b/components/layout/table_caption.rs
@@ -15,7 +15,6 @@ use flow::{Flow, FlowClass, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx_traits::print_tree::PrintTree;
use std::fmt;
-use std::sync::Arc;
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
@@ -84,7 +83,7 @@ impl Flow for TableCaptionFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs
index b40d25e936c..8c54297d4b5 100644
--- a/components/layout/table_cell.rs
+++ b/components/layout/table_cell.rs
@@ -19,7 +19,6 @@ use layout_debug;
use model::MaybeAuto;
use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode;
use std::fmt;
-use std::sync::Arc;
use style::computed_values::{border_collapse, border_top_style, vertical_align};
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues;
@@ -264,7 +263,7 @@ impl Flow for TableCellFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs
index 5603a02e3c9..85d5207646e 100644
--- a/components/layout/table_colgroup.rs
+++ b/components/layout/table_colgroup.rs
@@ -15,7 +15,6 @@ use fragment::{Fragment, FragmentBorderBoxIterator, Overflow, SpecificFragmentIn
use layout_debug;
use std::cmp::max;
use std::fmt;
-use std::sync::Arc;
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
use style::values::computed::LengthOrPercentageOrAuto;
@@ -95,7 +94,7 @@ impl Flow for TableColGroupFlow {
fn collect_stacking_contexts(&mut self, _: &mut DisplayListBuildState) {}
- fn repair_style(&mut self, _: &Arc<ServoComputedValues>) {}
+ fn repair_style(&mut self, _: &::StyleArc<ServoComputedValues>) {}
fn compute_overflow(&self) -> Overflow {
Overflow::new()
diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs
index d1c7146d247..8d074f59c52 100644
--- a/components/layout/table_row.rs
+++ b/components/layout/table_row.rs
@@ -22,7 +22,6 @@ use serde::{Serialize, Serializer};
use std::cmp::max;
use std::fmt;
use std::iter::{Enumerate, IntoIterator, Peekable};
-use std::sync::Arc;
use style::computed_values::{border_collapse, border_spacing, border_top_style};
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
use style::properties::ServoComputedValues;
@@ -483,7 +482,7 @@ impl Flow for TableRowFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs
index e4c4291bce4..7664796b082 100644
--- a/components/layout/table_rowgroup.rs
+++ b/components/layout/table_rowgroup.rs
@@ -18,7 +18,6 @@ use layout_debug;
use serde::{Serialize, Serializer};
use std::fmt;
use std::iter::{IntoIterator, Iterator, Peekable};
-use std::sync::Arc;
use style::computed_values::{border_collapse, border_spacing};
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
@@ -186,7 +185,7 @@ impl Flow for TableRowGroupFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs
index 64799a37e42..015f32a9762 100644
--- a/components/layout/table_wrapper.rs
+++ b/components/layout/table_wrapper.rs
@@ -27,7 +27,6 @@ use model::MaybeAuto;
use std::cmp::{max, min};
use std::fmt;
use std::ops::Add;
-use std::sync::Arc;
use style::computed_values::{border_collapse, position, table_layout};
use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalRect, LogicalSize};
@@ -467,7 +466,7 @@ impl Flow for TableWrapperFlow {
self.block_flow.collect_stacking_contexts(state);
}
- fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
+ fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
diff --git a/components/layout/text.rs b/components/layout/text.rs
index 5c9b93edee1..43b2fd086e7 100644
--- a/components/layout/text.rs
+++ b/components/layout/text.rs
@@ -435,7 +435,7 @@ fn bounding_box_for_run_metrics(metrics: &RunMetrics, writing_mode: WritingMode)
///
/// `#[inline]` because often the caller only needs a few fields from the font metrics.
#[inline]
-pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<style_structs::Font>)
+pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: ::StyleArc<style_structs::Font>)
-> FontMetrics {
let fontgroup = font_context.layout_font_group_for_style(font_style);
// FIXME(https://github.com/rust-lang/rust/issues/23338)
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 30d59180a3c..054d82397d5 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -115,6 +115,7 @@ use style::logical_geometry::LogicalPoint;
use style::media_queries::{Device, MediaList, MediaType};
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
+use style::stylearc::Arc as StyleArc;
use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
use style::stylist::{ExtraStyleData, Stylist};
use style::thread_state;
@@ -192,10 +193,10 @@ pub struct LayoutThread {
document_shared_lock: Option<SharedRwLock>,
/// The list of currently-running animations.
- running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
+ running_animations: StyleArc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
/// The list of animations that have expired since the last style recalculation.
- expired_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
+ expired_animations: StyleArc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
/// A counter for epoch messages
epoch: Epoch,
@@ -412,7 +413,7 @@ impl LayoutThread {
let font_cache_receiver =
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver);
- let stylist = Arc::new(Stylist::new(device));
+ let stylist = StyleArc::new(Stylist::new(device));
let outstanding_web_fonts_counter = Arc::new(AtomicUsize::new(0));
let ua_stylesheets = &*UA_STYLESHEETS;
let guard = ua_stylesheets.shared_lock.read();
@@ -448,8 +449,8 @@ impl LayoutThread {
outstanding_web_fonts: outstanding_web_fonts_counter,
root_flow: None,
document_shared_lock: None,
- running_animations: Arc::new(RwLock::new(HashMap::new())),
- expired_animations: Arc::new(RwLock::new(HashMap::new())),
+ running_animations: StyleArc::new(RwLock::new(HashMap::new())),
+ expired_animations: StyleArc::new(RwLock::new(HashMap::new())),
epoch: Epoch(0),
viewport_size: Size2D::new(Au(0), Au(0)),
webrender_api: webrender_api_sender.create_api(),
@@ -741,7 +742,7 @@ impl LayoutThread {
}
fn handle_add_stylesheet<'a, 'b>(&self,
- stylesheet: Arc<Stylesheet>,
+ stylesheet: StyleArc<Stylesheet>,
possibly_locked_rw_data: &mut RwData<'a, 'b>) {
// Find all font-face rules and notify the font cache of them.
// GWTODO: Need to handle unloading web fonts.
@@ -776,7 +777,7 @@ impl LayoutThread {
possibly_locked_rw_data: &mut RwData<'a, 'b>,
quirks_mode: QuirksMode) {
let mut rw_data = possibly_locked_rw_data.lock();
- Arc::get_mut(&mut rw_data.stylist).unwrap().set_quirks_mode(quirks_mode);
+ StyleArc::get_mut(&mut rw_data.stylist).unwrap().set_quirks_mode(quirks_mode);
possibly_locked_rw_data.block(rw_data);
}
@@ -1034,7 +1035,7 @@ impl LayoutThread {
self.document_shared_lock = Some(document_shared_lock.clone());
let author_guard = document_shared_lock.read();
let device = Device::new(MediaType::Screen, initial_viewport);
- Arc::get_mut(&mut rw_data.stylist).unwrap()
+ StyleArc::get_mut(&mut rw_data.stylist).unwrap()
.set_device(device, &author_guard, &data.document_stylesheets);
self.viewport_size =
@@ -1088,7 +1089,7 @@ impl LayoutThread {
let mut extra_data = ExtraStyleData {
marker: PhantomData,
};
- let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update(
+ let needs_dirtying = StyleArc::get_mut(&mut rw_data.stylist).unwrap().update(
&data.document_stylesheets,
&guards,
Some(ua_stylesheets),
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index 1bc9c165fb1..2ecae0d9d73 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -99,6 +99,7 @@ use style::media_queries::MediaList;
use style::properties::PropertyDeclarationBlock;
use style::selector_parser::{PseudoElement, Snapshot};
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, Locked as StyleLocked};
+use style::stylearc::Arc as StyleArc;
use style::stylesheets::{CssRules, FontFaceRule, KeyframesRule, MediaRule};
use style::stylesheets::{NamespaceRule, StyleRule, ImportRule, SupportsRule};
use style::values::specified::Length;
@@ -166,6 +167,12 @@ unsafe impl<T: JSTraceable> JSTraceable for Arc<T> {
}
}
+unsafe impl<T: JSTraceable> JSTraceable for StyleArc<T> {
+ unsafe fn trace(&self, trc: *mut JSTracer) {
+ (**self).trace(trc)
+ }
+}
+
unsafe impl<T: JSTraceable + ?Sized> JSTraceable for Box<T> {
unsafe fn trace(&self, trc: *mut JSTracer) {
(**self).trace(trc)
diff --git a/components/script/dom/cssconditionrule.rs b/components/script/dom/cssconditionrule.rs
index 8bf5dad6c93..1944c28c379 100644
--- a/components/script/dom/cssconditionrule.rs
+++ b/components/script/dom/cssconditionrule.rs
@@ -10,8 +10,8 @@ use dom::cssmediarule::CSSMediaRule;
use dom::cssstylesheet::CSSStyleSheet;
use dom::csssupportsrule::CSSSupportsRule;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::shared_lock::{SharedRwLock, Locked};
+use style::stylearc::Arc;
use style::stylesheets::CssRules as StyleCssRules;
#[dom_struct]
diff --git a/components/script/dom/cssfontfacerule.rs b/components/script/dom/cssfontfacerule.rs
index 1f247c25fdc..560722d2452 100644
--- a/components/script/dom/cssfontfacerule.rs
+++ b/components/script/dom/cssfontfacerule.rs
@@ -10,8 +10,8 @@ use dom::cssrule::{CSSRule, SpecificCSSRule};
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::shared_lock::{Locked, ToCssWithGuard};
+use style::stylearc::Arc;
use style::stylesheets::FontFaceRule;
#[dom_struct]
diff --git a/components/script/dom/cssgroupingrule.rs b/components/script/dom/cssgroupingrule.rs
index 249aaccd42e..4fd77b46a7c 100644
--- a/components/script/dom/cssgroupingrule.rs
+++ b/components/script/dom/cssgroupingrule.rs
@@ -12,8 +12,8 @@ use dom::cssrule::CSSRule;
use dom::cssrulelist::{CSSRuleList, RulesSource};
use dom::cssstylesheet::CSSStyleSheet;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::shared_lock::{SharedRwLock, Locked};
+use style::stylearc::Arc;
use style::stylesheets::CssRules as StyleCssRules;
#[dom_struct]
diff --git a/components/script/dom/cssimportrule.rs b/components/script/dom/cssimportrule.rs
index 3c0eb7eb4aa..d9d867cbc19 100644
--- a/components/script/dom/cssimportrule.rs
+++ b/components/script/dom/cssimportrule.rs
@@ -10,8 +10,8 @@ use dom::cssrule::{CSSRule, SpecificCSSRule};
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::shared_lock::{Locked, ToCssWithGuard};
+use style::stylearc::Arc;
use style::stylesheets::ImportRule;
#[dom_struct]
diff --git a/components/script/dom/csskeyframerule.rs b/components/script/dom/csskeyframerule.rs
index d36e8988e04..46dac811d9f 100644
--- a/components/script/dom/csskeyframerule.rs
+++ b/components/script/dom/csskeyframerule.rs
@@ -12,9 +12,9 @@ use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSSt
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::keyframes::Keyframe;
use style::shared_lock::{Locked, ToCssWithGuard};
+use style::stylearc::Arc;
#[dom_struct]
pub struct CSSKeyframeRule {
diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs
index a3715e914ed..f48abe60751 100644
--- a/components/script/dom/csskeyframesrule.rs
+++ b/components/script/dom/csskeyframesrule.rs
@@ -16,9 +16,9 @@ use dom::cssrulelist::{CSSRuleList, RulesSource};
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::keyframes::{Keyframe, KeyframeSelector};
use style::shared_lock::{Locked, ToCssWithGuard};
+use style::stylearc::Arc;
use style::stylesheets::KeyframesRule;
use style::values::KeyframesName;
diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs
index 45bf65b1adf..afc41d31be0 100644
--- a/components/script/dom/cssmediarule.rs
+++ b/components/script/dom/cssmediarule.rs
@@ -15,10 +15,10 @@ use dom::cssstylesheet::CSSStyleSheet;
use dom::medialist::MediaList;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::media_queries::parse_media_query_list;
use style::parser::{LengthParsingMode, ParserContext};
use style::shared_lock::{Locked, ToCssWithGuard};
+use style::stylearc::Arc;
use style::stylesheets::{CssRuleType, MediaRule};
use style_traits::ToCss;
diff --git a/components/script/dom/cssnamespacerule.rs b/components/script/dom/cssnamespacerule.rs
index 744a8020667..eafabf8a4a6 100644
--- a/components/script/dom/cssnamespacerule.rs
+++ b/components/script/dom/cssnamespacerule.rs
@@ -11,8 +11,8 @@ use dom::cssrule::{CSSRule, SpecificCSSRule};
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::shared_lock::{Locked, ToCssWithGuard};
+use style::stylearc::Arc;
use style::stylesheets::NamespaceRule;
#[dom_struct]
diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs
index 67eac2beda2..d0dfe120410 100644
--- a/components/script/dom/cssrulelist.rs
+++ b/components/script/dom/cssrulelist.rs
@@ -13,8 +13,8 @@ use dom::cssrule::CSSRule;
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::shared_lock::Locked;
+use style::stylearc::Arc;
use style::stylesheets::{CssRules, CssRulesHelpers, KeyframesRule, RulesMutateError};
#[allow(unsafe_code)]
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index d0996f04567..8b81201de77 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -16,13 +16,13 @@ use dom::window::Window;
use dom_struct::dom_struct;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
-use std::sync::Arc;
use style::attr::AttrValue;
use style::parser::LengthParsingMode;
use style::properties::{Importance, PropertyDeclarationBlock, PropertyId, LonghandId, ShorthandId};
use style::properties::{parse_one_declaration, parse_style_attribute};
use style::selector_parser::PseudoElement;
use style::shared_lock::Locked;
+use style::stylearc::Arc;
use style_traits::ToCss;
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
diff --git a/components/script/dom/cssstylerule.rs b/components/script/dom/cssstylerule.rs
index fed2b947f90..607f2cfb816 100644
--- a/components/script/dom/cssstylerule.rs
+++ b/components/script/dom/cssstylerule.rs
@@ -12,8 +12,8 @@ use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSSt
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::shared_lock::{Locked, ToCssWithGuard};
+use style::stylearc::Arc;
use style::stylesheets::StyleRule;
#[dom_struct]
diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs
index ee097313c2e..cb378b2261a 100644
--- a/components/script/dom/cssstylesheet.rs
+++ b/components/script/dom/cssstylesheet.rs
@@ -15,8 +15,8 @@ use dom::stylesheet::StyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
use std::cell::Cell;
-use std::sync::Arc;
use style::shared_lock::SharedRwLock;
+use style::stylearc::Arc;
use style::stylesheets::Stylesheet as StyleStyleSheet;
#[dom_struct]
diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs
index 86aedf10864..9a0743856d6 100644
--- a/components/script/dom/csssupportsrule.rs
+++ b/components/script/dom/csssupportsrule.rs
@@ -13,9 +13,9 @@ use dom::cssrule::SpecificCSSRule;
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::parser::{LengthParsingMode, ParserContext};
use style::shared_lock::{Locked, ToCssWithGuard};
+use style::stylearc::Arc;
use style::stylesheets::{CssRuleType, SupportsRule};
use style::supports::SupportsCondition;
use style_traits::ToCss;
diff --git a/components/script/dom/cssviewportrule.rs b/components/script/dom/cssviewportrule.rs
index 38abf909ff0..4438aabb53e 100644
--- a/components/script/dom/cssviewportrule.rs
+++ b/components/script/dom/cssviewportrule.rs
@@ -10,8 +10,8 @@ use dom::cssrule::{CSSRule, SpecificCSSRule};
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::shared_lock::{Locked, ToCssWithGuard};
+use style::stylearc::Arc;
use style::viewport::ViewportRule;
#[dom_struct]
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 06b8f7596cf..024c201a85c 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -128,7 +128,6 @@ use std::default::Default;
use std::iter::once;
use std::mem;
use std::rc::Rc;
-use std::sync::Arc;
use std::time::{Duration, Instant};
use style::attr::AttrValue;
use style::context::{QuirksMode, ReflowGoal};
@@ -136,6 +135,7 @@ use style::restyle_hints::{RestyleHint, RESTYLE_SELF, RESTYLE_STYLE_ATTRIBUTE};
use style::selector_parser::{RestyleDamage, Snapshot};
use style::shared_lock::SharedRwLock as StyleSharedRwLock;
use style::str::{HTML_SPACE_CHARACTERS, split_html_space_chars, str_join};
+use style::stylearc::Arc;
use style::stylesheets::Stylesheet;
use task_source::TaskSource;
use time;
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index d6974fb9075..a7d2d96fe73 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -96,7 +96,6 @@ use std::convert::TryFrom;
use std::default::Default;
use std::fmt;
use std::rc::Rc;
-use std::sync::Arc;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::context::{QuirksMode, ReflowGoal};
use style::element_state::*;
@@ -107,6 +106,7 @@ use style::rule_tree::CascadeLevel;
use style::selector_parser::{NonTSPseudoClass, RestyleDamage, SelectorImpl, SelectorParser};
use style::shared_lock::{SharedRwLock, Locked};
use style::sink::Push;
+use style::stylearc::Arc;
use style::stylist::ApplicableDeclarationBlock;
use style::thread_state;
use style::values::CSSFloat;
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index bf36d28b29d..f3c12a30699 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -30,11 +30,11 @@ use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
use std::default::Default;
-use std::sync::Arc;
use style::attr::AttrValue;
use style::media_queries::parse_media_query_list;
use style::parser::{LengthParsingMode, ParserContext as CssParserContext};
use style::str::HTML_SPACE_CHARACTERS;
+use style::stylearc::Arc;
use style::stylesheets::{CssRuleType, Stylesheet};
use stylesheet_loader::{StylesheetLoader, StylesheetContextSource, StylesheetOwner};
diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs
index 62d7215e3df..0c1ac5a0229 100644
--- a/components/script/dom/htmlmetaelement.rs
+++ b/components/script/dom/htmlmetaelement.rs
@@ -21,11 +21,11 @@ use dom_struct::dom_struct;
use html5ever_atoms::LocalName;
use servo_config::prefs::PREFS;
use std::ascii::AsciiExt;
-use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use style::attr::AttrValue;
use style::media_queries::MediaList;
use style::str::HTML_SPACE_CHARACTERS;
+use style::stylearc::Arc;
use style::stylesheets::{Stylesheet, CssRule, CssRules, Origin};
use style::viewport::ViewportRule;
diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs
index c80a7838198..ee847610791 100755
--- a/components/script/dom/htmlobjectelement.rs
+++ b/components/script/dom/htmlobjectelement.rs
@@ -21,7 +21,7 @@ use dom_struct::dom_struct;
use html5ever_atoms::LocalName;
use net_traits::image::base::Image;
use std::default::Default;
-use std::sync::Arc;
+use style::stylearc::Arc;
#[dom_struct]
pub struct HTMLObjectElement {
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs
index 8905c3baa65..8b9a2c74fcb 100644
--- a/components/script/dom/htmlstyleelement.rs
+++ b/components/script/dom/htmlstyleelement.rs
@@ -23,9 +23,9 @@ use html5ever_atoms::LocalName;
use net_traits::ReferrerPolicy;
use script_layout_interface::message::Msg;
use std::cell::Cell;
-use std::sync::Arc;
use style::media_queries::parse_media_query_list;
use style::parser::{LengthParsingMode, ParserContext as CssParserContext};
+use style::stylearc::Arc;
use style::stylesheets::{CssRuleType, Stylesheet, Origin};
use stylesheet_loader::{StylesheetLoader, StylesheetOwner};
diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs
index f2a2299d169..514bccecc4a 100644
--- a/components/script/dom/medialist.rs
+++ b/components/script/dom/medialist.rs
@@ -12,11 +12,11 @@ use dom::bindings::str::DOMString;
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
-use std::sync::Arc;
use style::media_queries::{MediaQuery, parse_media_query_list};
use style::media_queries::MediaList as StyleMediaList;
use style::parser::{LengthParsingMode, ParserContext};
use style::shared_lock::{SharedRwLock, Locked};
+use style::stylearc::Arc;
use style::stylesheets::CssRuleType;
use style_traits::ToCss;
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 0384c4ed19d..aa0fcc9a2a1 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -78,10 +78,10 @@ use std::default::Default;
use std::iter;
use std::mem;
use std::ops::Range;
-use std::sync::Arc;
use style::context::QuirksMode;
use style::dom::OpaqueNode;
use style::selector_parser::{SelectorImpl, SelectorParser};
+use style::stylearc::Arc;
use style::stylesheets::Stylesheet;
use style::thread_state;
use uuid::Uuid;
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs
index 3ddb1d2b5c9..5fe45595388 100644
--- a/components/script/layout_wrapper.rs
+++ b/components/script/layout_wrapper.rs
@@ -58,7 +58,6 @@ use std::fmt::Debug;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use std::mem::transmute;
-use std::sync::Arc;
use std::sync::atomic::Ordering;
use style;
use style::attr::AttrValue;
@@ -74,6 +73,7 @@ use style::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl};
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, Locked as StyleLocked};
use style::sink::Push;
use style::str::is_whitespace;
+use style::stylearc::Arc;
use style::stylist::ApplicableDeclarationBlock;
#[derive(Copy, Clone)]
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs
index 14b8c385e39..3143d8b34ad 100644
--- a/components/script/stylesheet_loader.rs
+++ b/components/script/stylesheet_loader.rs
@@ -24,9 +24,10 @@ use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestIni
use network_listener::{NetworkListener, PreInvoke};
use servo_url::ServoUrl;
use std::mem;
-use std::sync::{Arc, Mutex};
+use std::sync::Mutex;
use style::media_queries::MediaList;
use style::shared_lock::Locked as StyleLocked;
+use style::stylearc::Arc;
use style::stylesheets::{ImportRule, Stylesheet, Origin};
use style::stylesheets::StylesheetLoader as StyleStylesheetLoader;
@@ -207,7 +208,7 @@ impl<'a> StylesheetLoader<'a> {
let document = document_from_node(self.elem);
let gen = self.elem.downcast::<HTMLLinkElement>()
.map(HTMLLinkElement::get_request_generation_id);
- let context = Arc::new(Mutex::new(StylesheetContext {
+ let context = ::std::sync::Arc::new(Mutex::new(StylesheetContext {
elem: Trusted::new(&*self.elem),
source: source,
url: url.clone(),
diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs
index b94b6cd8d14..8b04a131404 100644
--- a/components/script_layout_interface/message.rs
+++ b/components/script_layout_interface/message.rs
@@ -25,7 +25,7 @@ use style::stylesheets::Stylesheet;
/// Asynchronous messages that script can send to layout.
pub enum Msg {
/// Adds the given stylesheet to the document.
- AddStylesheet(Arc<Stylesheet>),
+ AddStylesheet(::style::stylearc::Arc<Stylesheet>),
/// Change the quirks mode.
SetQuirksMode(QuirksMode),
@@ -116,7 +116,7 @@ pub struct ScriptReflow {
/// The document node.
pub document: TrustedNodeAddress,
/// The document's list of stylesheets.
- pub document_stylesheets: Vec<Arc<Stylesheet>>,
+ pub document_stylesheets: Vec<::style::stylearc::Arc<Stylesheet>>,
/// Whether the document's stylesheets have changed since the last script reflow.
pub stylesheets_changed: bool,
/// The current window size.
diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs
index 4abc74bcac0..bb7d1e373cf 100644
--- a/components/script_layout_interface/wrapper_traits.rs
+++ b/components/script_layout_interface/wrapper_traits.rs
@@ -15,7 +15,6 @@ use msg::constellation_msg::PipelineId;
use range::Range;
use servo_url::ServoUrl;
use std::fmt::Debug;
-use std::sync::Arc;
use style::computed_values::display;
use style::context::SharedStyleContext;
use style::data::ElementData;
@@ -24,6 +23,7 @@ use style::dom::OpaqueNode;
use style::font_metrics::ServoMetricsProvider;
use style::properties::{CascadeFlags, ServoComputedValues};
use style::selector_parser::{PseudoElement, PseudoElementCascadeType, SelectorImpl};
+use style::stylearc::Arc;
use webrender_traits::ClipId;
#[derive(Copy, PartialEq, Clone, Debug)]
diff --git a/components/style/animation.rs b/components/style/animation.rs
index 941db59cc85..0a4c7cab345 100644
--- a/components/style/animation.rs
+++ b/components/style/animation.rs
@@ -19,8 +19,8 @@ use properties::longhands::animation_iteration_count::single_value::computed_val
use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState;
use properties::longhands::transition_timing_function::single_value::computed_value::StartEnd;
use properties::longhands::transition_timing_function::single_value::computed_value::T as TransitionTimingFunction;
-use std::sync::Arc;
use std::sync::mpsc::Sender;
+use stylearc::Arc;
use timer::Timer;
use values::computed::Time;
diff --git a/components/style/attr.rs b/components/style/attr.rs
index 1989816329d..101810212b7 100644
--- a/components/style/attr.rs
+++ b/components/style/attr.rs
@@ -16,10 +16,10 @@ use servo_url::ServoUrl;
use shared_lock::Locked;
use std::ascii::AsciiExt;
use std::str::FromStr;
-use std::sync::Arc;
use str::{HTML_SPACE_CHARACTERS, read_exponent, read_fraction};
use str::{read_numbers, split_commas, split_html_space_chars};
use str::str_join;
+use stylearc::Arc;
use values::specified::Length;
// Duplicated from script::dom::values.
diff --git a/components/style/context.rs b/components/style/context.rs
index 581a7c12cd3..1cdd8c00636 100644
--- a/components/style/context.rs
+++ b/components/style/context.rs
@@ -27,8 +27,9 @@ use std::collections::HashMap;
#[cfg(not(feature = "servo"))] use std::env;
use std::fmt;
use std::ops::Add;
-use std::sync::{Arc, Mutex};
+use std::sync::Mutex;
use std::sync::mpsc::Sender;
+use stylearc::Arc;
use stylist::Stylist;
use thread_state;
use time;
diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs
index 95e43b46fdf..071efade790 100644
--- a/components/style/custom_properties.rs
+++ b/components/style/custom_properties.rs
@@ -14,8 +14,8 @@ use std::ascii::AsciiExt;
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::fmt;
-use std::sync::Arc;
use style_traits::ToCss;
+use stylearc::Arc;
/// A custom property name is just an `Atom`.
///
diff --git a/components/style/data.rs b/components/style/data.rs
index 4052f0b30a3..651f003e4e9 100644
--- a/components/style/data.rs
+++ b/components/style/data.rs
@@ -16,7 +16,7 @@ use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage, Snapshot
use std::fmt;
#[cfg(feature = "servo")] use std::hash::BuildHasherDefault;
use std::ops::Deref;
-use std::sync::Arc;
+use stylearc::Arc;
use stylist::Stylist;
use thread_state;
use traversal::TraversalFlags;
diff --git a/components/style/dom.rs b/components/style/dom.rs
index ffc46b0cc94..7a4fe5d1003 100644
--- a/components/style/dom.rs
+++ b/components/style/dom.rs
@@ -26,7 +26,7 @@ use std::fmt;
use std::fmt::Debug;
use std::hash::Hash;
use std::ops::Deref;
-use std::sync::Arc;
+use stylearc::Arc;
use stylist::ApplicableDeclarationBlock;
use thread_state;
diff --git a/components/style/encoding_support.rs b/components/style/encoding_support.rs
index 2775de54893..92620378b30 100644
--- a/components/style/encoding_support.rs
+++ b/components/style/encoding_support.rs
@@ -13,7 +13,7 @@ use media_queries::MediaList;
use self::encoding::{EncodingRef, DecoderTrap};
use shared_lock::SharedRwLock;
use std::str;
-use std::sync::Arc;
+use stylearc::Arc;
use stylesheets::{Stylesheet, StylesheetLoader, Origin, UrlExtraData};
struct RustEncoding;
diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs
index 942aaf4f7b5..2e1e17a2ebc 100644
--- a/components/style/gecko/data.rs
+++ b/components/style/gecko/data.rs
@@ -15,8 +15,8 @@ use parking_lot::RwLock;
use properties::ComputedValues;
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
use std::collections::HashMap;
-use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
+use stylearc::Arc;
use stylesheet_set::StylesheetSet;
use stylesheets::{FontFaceRule, Origin, Stylesheet};
use stylist::{ExtraStyleData, Stylist};
diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs
index a0aeaec2e5c..2444338f174 100644
--- a/components/style/gecko/media_queries.rs
+++ b/components/style/gecko/media_queries.rs
@@ -18,11 +18,11 @@ use media_queries::MediaType;
use parser::ParserContext;
use properties::{ComputedValues, StyleBuilder};
use std::fmt::{self, Write};
-use std::sync::Arc;
use str::starts_with_ignore_ascii_case;
use string_cache::Atom;
use style_traits::ToCss;
use style_traits::viewport::ViewportConstraints;
+use stylearc::Arc;
use values::{CSSFloat, specified};
use values::computed::{self, ToComputedValue};
diff --git a/components/style/gecko/restyle_damage.rs b/components/style/gecko/restyle_damage.rs
index 4d6c1269eb8..39fdafebd5d 100644
--- a/components/style/gecko/restyle_damage.rs
+++ b/components/style/gecko/restyle_damage.rs
@@ -10,7 +10,7 @@ use gecko_bindings::structs::{nsChangeHint, nsStyleContext};
use gecko_bindings::sugar::ownership::FFIArcHelpers;
use properties::ComputedValues;
use std::ops::{BitAnd, BitOr, BitOrAssign, Not};
-use std::sync::Arc;
+use stylearc::Arc;
/// The representation of Gecko's restyle damage is just a wrapper over
/// `nsChangeHint`.
diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs
index 286094bcb0e..191ae082726 100644
--- a/components/style/gecko/url.rs
+++ b/components/style/gecko/url.rs
@@ -10,8 +10,8 @@ use gecko_bindings::sugar::refptr::RefPtr;
use parser::ParserContext;
use std::borrow::Cow;
use std::fmt::{self, Write};
-use std::sync::Arc;
use style_traits::ToCss;
+use stylearc::Arc;
/// A specified url() value for gecko. Gecko does not eagerly resolve SpecifiedUrls.
#[derive(Clone, Debug, PartialEq)]
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index 100830c0e0d..f71ef0a6c9c 100644
--- a/components/style/gecko/wrapper.rs
+++ b/components/style/gecko/wrapper.rs
@@ -71,8 +71,8 @@ use std::collections::HashMap;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::ptr;
-use std::sync::Arc;
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
+use stylearc::Arc;
use stylesheets::UrlExtraData;
use stylist::ApplicableDeclarationBlock;
diff --git a/components/style/gecko_bindings/sugar/ownership.rs b/components/style/gecko_bindings/sugar/ownership.rs
index abcf5c65a8a..6c4746013b3 100644
--- a/components/style/gecko_bindings/sugar/ownership.rs
+++ b/components/style/gecko_bindings/sugar/ownership.rs
@@ -8,7 +8,7 @@ use std::marker::PhantomData;
use std::mem::{forget, transmute};
use std::ops::{Deref, DerefMut};
use std::ptr;
-use std::sync::Arc;
+use stylearc::Arc;
/// Indicates that a given Servo type has a corresponding Gecko FFI type.
pub unsafe trait HasFFI : Sized {
diff --git a/components/style/gecko_bindings/sugar/refptr.rs b/components/style/gecko_bindings/sugar/refptr.rs
index 3c3dec9aee3..9ca1d3dc7b6 100644
--- a/components/style/gecko_bindings/sugar/refptr.rs
+++ b/components/style/gecko_bindings/sugar/refptr.rs
@@ -9,7 +9,7 @@ use gecko_bindings::sugar::ownership::HasArcFFI;
use std::{mem, ptr};
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
-use std::sync::Arc;
+use stylearc::Arc;
/// Trait for all objects that have Addref() and Release
/// methods and can be placed inside RefPtr<T>
diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs
index 8113c06bb6c..3a80320bb52 100644
--- a/components/style/keyframes.rs
+++ b/components/style/keyframes.rs
@@ -17,8 +17,8 @@ use properties::animated_properties::TransitionProperty;
use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction;
use shared_lock::{SharedRwLock, SharedRwLockReadGuard, Locked, ToCssWithGuard};
use std::fmt;
-use std::sync::Arc;
use style_traits::ToCss;
+use stylearc::Arc;
use stylesheets::{CssRuleType, Stylesheet, VendorPrefix};
/// A number from 0 to 1, indicating the percentage of the animation when this
diff --git a/components/style/lib.rs b/components/style/lib.rs
index 7479279418d..8902ab4efc6 100644
--- a/components/style/lib.rs
+++ b/components/style/lib.rs
@@ -70,6 +70,7 @@ extern crate pdqsort;
#[cfg(feature = "gecko")] extern crate precomputed_hash;
extern crate rayon;
extern crate selectors;
+#[cfg(feature = "servo")] extern crate serde;
#[cfg(feature = "servo")] #[macro_use] extern crate serde_derive;
#[cfg(feature = "servo")] #[macro_use] extern crate servo_atoms;
#[cfg(feature = "servo")] extern crate servo_config;
@@ -118,6 +119,7 @@ pub mod sequential;
pub mod sink;
pub mod str;
pub mod style_adjuster;
+pub mod stylearc;
pub mod stylesheet_set;
pub mod stylesheets;
pub mod supports;
@@ -130,7 +132,6 @@ pub mod values;
pub mod viewport;
use std::fmt;
-use std::sync::Arc;
use style_traits::ToCss;
#[cfg(feature = "gecko")] pub use gecko_string_cache as string_cache;
@@ -175,14 +176,6 @@ macro_rules! reexport_computed_values {
}
longhand_properties_idents!(reexport_computed_values);
-/// Returns whether the two arguments point to the same value.
-///
-/// FIXME: Remove this and use Arc::ptr_eq once we require Rust 1.17
-#[inline]
-pub fn arc_ptr_eq<T: 'static>(a: &Arc<T>, b: &Arc<T>) -> bool {
- ptr_eq::<T>(&**a, &**b)
-}
-
/// Pointer equality
///
/// FIXME: Remove this and use std::ptr::eq once we require Rust 1.17
diff --git a/components/style/matching.rs b/components/style/matching.rs
index ca2db43c4b9..8da1192d4d3 100644
--- a/components/style/matching.rs
+++ b/components/style/matching.rs
@@ -27,7 +27,7 @@ use selectors::bloom::BloomFilter;
use selectors::matching::{ElementSelectorFlags, StyleRelations};
use selectors::matching::AFFECTED_BY_PSEUDO_ELEMENTS;
use sink::ForgetfulSink;
-use std::sync::Arc;
+use stylearc::Arc;
use stylist::ApplicableDeclarationBlock;
/// The way a style should be inherited.
@@ -120,8 +120,8 @@ fn same_computed_values<E: TElement>(first: Option<E>, second: Option<E>) -> boo
_ => return false,
};
- let eq = ::arc_ptr_eq(a.borrow_data().unwrap().styles().primary.values(),
- b.borrow_data().unwrap().styles().primary.values());
+ let eq = Arc::ptr_eq(a.borrow_data().unwrap().styles().primary.values(),
+ b.borrow_data().unwrap().styles().primary.values());
eq
}
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 4643d176949..b428ec3e198 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -61,7 +61,7 @@ use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarat
use std::fmt::{self, Debug};
use std::mem::{forget, transmute, zeroed};
use std::ptr;
-use std::sync::Arc;
+use stylearc::Arc;
use std::cmp;
use values::computed::ToComputedValue;
use values::{Either, Auto, KeyframesName};
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs
index 4db19381e1f..3c3bb537320 100644
--- a/components/style/properties/helpers.mako.rs
+++ b/components/style/properties/helpers.mako.rs
@@ -252,7 +252,7 @@
use properties::{DeclaredValue, LonghandId, LonghandIdSet};
use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration};
use properties::style_structs;
- use std::sync::Arc;
+ use stylearc::Arc;
use values::computed::{Context, ToComputedValue};
use values::{computed, generics, specified};
use Atom;
@@ -716,7 +716,7 @@
use properties::{PropertyDeclaration, ParsedDeclaration};
use properties::{ShorthandId, UnparsedValue, longhands};
use std::fmt;
- use std::sync::Arc;
+ use stylearc::Arc;
use style_traits::ToCss;
pub struct Longhands {
diff --git a/components/style/properties/longhand/svg.mako.rs b/components/style/properties/longhand/svg.mako.rs
index 7a764fbe9f5..45cb125bf33 100644
--- a/components/style/properties/longhand/svg.mako.rs
+++ b/components/style/properties/longhand/svg.mako.rs
@@ -197,7 +197,7 @@ ${helpers.single_keyword("mask-composite",
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-image">
use std::fmt;
use style_traits::ToCss;
- use std::sync::Arc;
+ use stylearc::Arc;
use values::specified::Image;
use values::specified::url::SpecifiedUrl;
use values::HasViewportPercentage;
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index aba24623855..ff2361fb792 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -14,7 +14,7 @@ use std::borrow::Cow;
use std::collections::HashSet;
use std::fmt;
use std::ops::Deref;
-use std::sync::Arc;
+use stylearc::Arc;
use app_units::Au;
#[cfg(feature = "servo")] use cssparser::{Color as CSSParserColor, RGBA};
@@ -178,7 +178,7 @@ pub mod shorthands {
use cssparser::Parser;
use parser::ParserContext;
use properties::{ParsedDeclaration, ShorthandId, UnparsedValue};
- use std::sync::Arc;
+ use stylearc::Arc;
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<ParsedDeclaration, ()> {
// This function is like the parse() that is generated by
@@ -2056,7 +2056,7 @@ pub enum StyleStructRef<'a, T: 'a> {
/// A borrowed struct from the parent, for example, for inheriting style.
Borrowed(&'a Arc<T>),
/// An owned struct, that we've already mutated.
- Owned(T),
+ Owned(Arc<T>),
}
impl<'a, T: 'a> StyleStructRef<'a, T>
@@ -2066,11 +2066,11 @@ impl<'a, T: 'a> StyleStructRef<'a, T>
/// borrowed value, or returning the owned one.
pub fn mutate(&mut self) -> &mut T {
if let StyleStructRef::Borrowed(v) = *self {
- *self = StyleStructRef::Owned((**v).clone());
+ *self = StyleStructRef::Owned(Arc::new((**v).clone()));
}
match *self {
- StyleStructRef::Owned(ref mut v) => v,
+ StyleStructRef::Owned(ref mut v) => Arc::get_mut(v).unwrap(),
StyleStructRef::Borrowed(..) => unreachable!(),
}
}
@@ -2079,7 +2079,7 @@ impl<'a, T: 'a> StyleStructRef<'a, T>
/// hasn't been mutated.
pub fn get_if_mutated(&mut self) -> Option<<&mut T> {
match *self {
- StyleStructRef::Owned(ref mut v) => Some(v),
+ StyleStructRef::Owned(ref mut v) => Some(Arc::get_mut(v).unwrap()),
StyleStructRef::Borrowed(..) => None,
}
}
@@ -2088,7 +2088,7 @@ impl<'a, T: 'a> StyleStructRef<'a, T>
/// appropriate.
pub fn build(self) -> Arc<T> {
match self {
- StyleStructRef::Owned(v) => Arc::new(v),
+ StyleStructRef::Owned(v) => v,
StyleStructRef::Borrowed(v) => v.clone(),
}
}
@@ -2099,7 +2099,7 @@ impl<'a, T: 'a> Deref for StyleStructRef<'a, T> {
fn deref(&self) -> &T {
match *self {
- StyleStructRef::Owned(ref v) => v,
+ StyleStructRef::Owned(ref v) => &**v,
StyleStructRef::Borrowed(v) => &**v,
}
}
@@ -2246,7 +2246,7 @@ pub use self::lazy_static_module::INITIAL_SERVO_VALUES;
#[allow(missing_docs)]
mod lazy_static_module {
use logical_geometry::WritingMode;
- use std::sync::Arc;
+ use stylearc::Arc;
use super::{ComputedValues, longhands, style_structs};
/// The initial values for all style structs as defined by the specification.
diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs
index fa6acaa92b5..0947198e2da 100644
--- a/components/style/rule_tree/mod.rs
+++ b/components/style/rule_tree/mod.rs
@@ -6,15 +6,14 @@
//! The rule tree.
-use arc_ptr_eq;
#[cfg(feature = "servo")]
use heapsize::HeapSizeOf;
use properties::{Importance, PropertyDeclarationBlock};
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
use std::io::{self, Write};
use std::ptr;
-use std::sync::Arc;
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
+use stylearc::Arc;
use stylesheets::StyleRule;
use thread_state;
@@ -65,8 +64,8 @@ impl StyleSource {
fn ptr_equals(&self, other: &Self) -> bool {
use self::StyleSource::*;
match (self, other) {
- (&Style(ref one), &Style(ref other)) => arc_ptr_eq(one, other),
- (&Declarations(ref one), &Declarations(ref other)) => arc_ptr_eq(one, other),
+ (&Style(ref one), &Style(ref other)) => Arc::ptr_eq(one, other),
+ (&Declarations(ref one), &Declarations(ref other)) => Arc::ptr_eq(one, other),
_ => false,
}
}
@@ -203,7 +202,7 @@ impl RuleTree {
// so let's skip it for now.
let is_here_already = match current.get().source.as_ref() {
Some(&StyleSource::Declarations(ref already_here)) => {
- arc_ptr_eq(pdb, already_here)
+ Arc::ptr_eq(pdb, already_here)
},
_ => unreachable!("Replacing non-declarations style?"),
};
diff --git a/components/style/selector_parser.rs b/components/style/selector_parser.rs
index 0664483cbe7..0af60279af8 100644
--- a/components/style/selector_parser.rs
+++ b/components/style/selector_parser.rs
@@ -37,7 +37,7 @@ pub use gecko::restyle_damage::GeckoRestyleDamage as RestyleDamage;
/// A type that represents the previous computed values needed for restyle
/// damage calculation.
#[cfg(feature = "servo")]
-pub type PreExistingComputedValues = ::std::sync::Arc<::properties::ServoComputedValues>;
+pub type PreExistingComputedValues = ::stylearc::Arc<::properties::ServoComputedValues>;
/// A type that represents the previous computed values needed for restyle
/// damage calculation.
diff --git a/components/style/servo/restyle_damage.rs b/components/style/servo/restyle_damage.rs
index 0ad934278c1..1fd7b38cae2 100644
--- a/components/style/servo/restyle_damage.rs
+++ b/components/style/servo/restyle_damage.rs
@@ -11,7 +11,7 @@ use computed_values::display;
use heapsize::HeapSizeOf;
use properties::ServoComputedValues;
use std::fmt;
-use std::sync::Arc;
+use stylearc::Arc;
bitflags! {
#[doc = "Individual layout actions that may be necessary after restyling."]
diff --git a/components/style/servo/url.rs b/components/style/servo/url.rs
index c59c6bcb0b7..467f7a45715 100644
--- a/components/style/servo/url.rs
+++ b/components/style/servo/url.rs
@@ -9,6 +9,9 @@ use parser::ParserContext;
use servo_url::ServoUrl;
use std::borrow::Cow;
use std::fmt::{self, Write};
+// Note: We use std::sync::Arc rather than stylearc::Arc here because the
+// nonzero optimization is important in keeping the size of SpecifiedUrl below
+// the threshold.
use std::sync::Arc;
use style_traits::ToCss;
diff --git a/components/style/shared_lock.rs b/components/style/shared_lock.rs
index 2dec153f342..360118d472e 100644
--- a/components/style/shared_lock.rs
+++ b/components/style/shared_lock.rs
@@ -10,7 +10,7 @@ use atomic_refcell::{AtomicRefCell, AtomicRef, AtomicRefMut};
use parking_lot::RwLock;
use std::cell::UnsafeCell;
use std::fmt;
-use std::sync::Arc;
+use stylearc::Arc;
/// A shared read/write lock that can protect multiple objects.
///
@@ -149,7 +149,7 @@ impl<T: fmt::Debug> fmt::Debug for Locked<T> {
impl<T> Locked<T> {
#[cfg(feature = "servo")]
fn same_lock_as(&self, lock: &SharedRwLock) -> bool {
- ::arc_ptr_eq(&self.shared_lock.arc, &lock.arc)
+ Arc::ptr_eq(&self.shared_lock.arc, &lock.arc)
}
#[cfg(feature = "gecko")]
diff --git a/components/style/stylearc.rs b/components/style/stylearc.rs
new file mode 100644
index 00000000000..01885dc481b
--- /dev/null
+++ b/components/style/stylearc.rs
@@ -0,0 +1,380 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Fork of Arc for the style system. This has the following advantages over std::Arc:
+//! * We don't waste storage on the weak reference count.
+//! * We don't do extra RMU operations to handle the possibility of weak references.
+//! * We can experiment with arena allocation (todo).
+//! * We can add methods to support our custom use cases [1].
+//!
+//! [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1360883
+
+// The semantics of Arc are alread documented in the Rust docs, so we don't
+// duplicate those here.
+#![allow(missing_docs)]
+
+#[cfg(feature = "servo")]
+use heapsize::HeapSizeOf;
+#[cfg(feature = "servo")]
+use serde::{Deserialize, Serialize};
+use std::{isize, usize};
+use std::borrow;
+use std::cmp::Ordering;
+use std::convert::From;
+use std::fmt;
+use std::hash::{Hash, Hasher};
+use std::mem;
+use std::ops::Deref;
+use std::sync::atomic;
+use std::sync::atomic::Ordering::{Acquire, Relaxed, Release};
+
+// Private macro to get the offset of a struct field in bytes from the address of the struct.
+macro_rules! offset_of {
+ ($container:path, $field:ident) => {{
+ // Make sure the field actually exists. This line ensures that a compile-time error is
+ // generated if $field is accessed through a Deref impl.
+ let $container { $field: _, .. };
+
+ // Create an (invalid) instance of the container and calculate the offset to its
+ // field. Using a null pointer might be UB if `&(*(0 as *const T)).field` is interpreted to
+ // be nullptr deref.
+ let invalid: $container = ::std::mem::uninitialized();
+ let offset = &invalid.$field as *const _ as usize - &invalid as *const _ as usize;
+
+ // Do not run destructors on the made up invalid instance.
+ ::std::mem::forget(invalid);
+ offset as isize
+ }};
+}
+
+/// A soft limit on the amount of references that may be made to an `Arc`.
+///
+/// Going above this limit will abort your program (although not
+/// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references.
+const MAX_REFCOUNT: usize = (isize::MAX) as usize;
+
+pub struct Arc<T: ?Sized> {
+ // FIXME(bholley): When NonZero/Shared/Unique are stabilized, we should use
+ // Shared here to get the NonZero optimization. Gankro is working on this.
+ //
+ // If we need a compact Option<Arc<T>> beforehand, we can make a helper
+ // class that wraps the result of Arc::into_raw.
+ //
+ // https://github.com/rust-lang/rust/issues/27730
+ ptr: *mut ArcInner<T>,
+}
+
+unsafe impl<T: ?Sized + Sync + Send> Send for Arc<T> {}
+unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> {}
+
+struct ArcInner<T: ?Sized> {
+ count: atomic::AtomicUsize,
+ data: T,
+}
+
+unsafe impl<T: ?Sized + Sync + Send> Send for ArcInner<T> {}
+unsafe impl<T: ?Sized + Sync + Send> Sync for ArcInner<T> {}
+
+impl<T> Arc<T> {
+ #[inline]
+ pub fn new(data: T) -> Self {
+ let x = Box::new(ArcInner {
+ count: atomic::AtomicUsize::new(1),
+ data: data,
+ });
+ Arc { ptr: Box::into_raw(x) }
+ }
+
+ pub fn into_raw(this: Self) -> *const T {
+ let ptr = unsafe { &((*this.ptr).data) as *const _ };
+ mem::forget(this);
+ ptr
+ }
+
+ pub unsafe fn from_raw(ptr: *const T) -> Self {
+ // To find the corresponding pointer to the `ArcInner` we need
+ // to subtract the offset of the `data` field from the pointer.
+ let ptr = (ptr as *const u8).offset(-offset_of!(ArcInner<T>, data));
+ Arc {
+ ptr: ptr as *mut ArcInner<T>,
+ }
+ }
+}
+
+impl<T: ?Sized> Arc<T> {
+ #[inline]
+ fn inner(&self) -> &ArcInner<T> {
+ // This unsafety is ok because while this arc is alive we're guaranteed
+ // that the inner pointer is valid. Furthermore, we know that the
+ // `ArcInner` structure itself is `Sync` because the inner data is
+ // `Sync` as well, so we're ok loaning out an immutable pointer to these
+ // contents.
+ unsafe { &*self.ptr }
+ }
+
+ // Non-inlined part of `drop`. Just invokes the destructor.
+ #[inline(never)]
+ unsafe fn drop_slow(&mut self) {
+ let _ = Box::from_raw(self.ptr);
+ }
+
+
+ #[inline]
+ pub fn ptr_eq(this: &Self, other: &Self) -> bool {
+ this.ptr == other.ptr
+ }
+}
+
+impl<T: ?Sized> Clone for Arc<T> {
+ #[inline]
+ fn clone(&self) -> Self {
+ // Using a relaxed ordering is alright here, as knowledge of the
+ // original reference prevents other threads from erroneously deleting
+ // the object.
+ //
+ // As explained in the [Boost documentation][1], Increasing the
+ // reference counter can always be done with memory_order_relaxed: New
+ // references to an object can only be formed from an existing
+ // reference, and passing an existing reference from one thread to
+ // another must already provide any required synchronization.
+ //
+ // [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
+ let old_size = self.inner().count.fetch_add(1, Relaxed);
+
+ // However we need to guard against massive refcounts in case someone
+ // is `mem::forget`ing Arcs. If we don't do this the count can overflow
+ // and users will use-after free. We racily saturate to `isize::MAX` on
+ // the assumption that there aren't ~2 billion threads incrementing
+ // the reference count at once. This branch will never be taken in
+ // any realistic program.
+ //
+ // We abort because such a program is incredibly degenerate, and we
+ // don't care to support it.
+ if old_size > MAX_REFCOUNT {
+ // Note: std::process::abort is stable in 1.17, which we don't yet
+ // require for Gecko. Panic is good enough in practice here (it will
+ // trigger an abort at least in Gecko, and this case is degenerate
+ // enough that Servo shouldn't have code that triggers it).
+ //
+ // We should fix this when we require 1.17.
+ panic!();
+ }
+
+ Arc { ptr: self.ptr }
+ }
+}
+
+impl<T: ?Sized> Deref for Arc<T> {
+ type Target = T;
+
+ #[inline]
+ fn deref(&self) -> &T {
+ &self.inner().data
+ }
+}
+
+impl<T: Clone> Arc<T> {
+ #[inline]
+ pub fn make_mut(this: &mut Self) -> &mut T {
+ if !this.is_unique() {
+ // Another pointer exists; clone
+ *this = Arc::new((**this).clone());
+ }
+
+ unsafe {
+ // This unsafety is ok because we're guaranteed that the pointer
+ // returned is the *only* pointer that will ever be returned to T. Our
+ // reference count is guaranteed to be 1 at this point, and we required
+ // the Arc itself to be `mut`, so we're returning the only possible
+ // reference to the inner data.
+ &mut (*this.ptr).data
+ }
+ }
+}
+
+impl<T: ?Sized> Arc<T> {
+ #[inline]
+ pub fn get_mut(this: &mut Self) -> Option<&mut T> {
+ if this.is_unique() {
+ unsafe {
+ // See make_mut() for documentation of the threadsafety here.
+ Some(&mut (*this.ptr).data)
+ }
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ fn is_unique(&self) -> bool {
+ // We can use Relaxed here, but the justification is a bit subtle.
+ //
+ // The reason to use Acquire would be to synchronize with other threads
+ // that are modifying the refcount with Release, i.e. to ensure that
+ // their writes to memory guarded by this refcount are flushed. However,
+ // we know that threads only modify the contents of the Arc when they
+ // observe the refcount to be 1, and no other thread could observe that
+ // because we're holding one strong reference here.
+ self.inner().count.load(Relaxed) == 1
+ }
+}
+
+impl<T: ?Sized> Drop for Arc<T> {
+ #[inline]
+ fn drop(&mut self) {
+ // Because `fetch_sub` is already atomic, we do not need to synchronize
+ // with other threads unless we are going to delete the object.
+ if self.inner().count.fetch_sub(1, Release) != 1 {
+ return;
+ }
+
+ // FIXME(bholley): Use the updated comment when [2] is merged.
+ //
+ // This load is needed to prevent reordering of use of the data and
+ // deletion of the data. Because it is marked `Release`, the decreasing
+ // of the reference count synchronizes with this `Acquire` load. This
+ // means that use of the data happens before decreasing the reference
+ // count, which happens before this load, which happens before the
+ // deletion of the data.
+ //
+ // As explained in the [Boost documentation][1],
+ //
+ // > It is important to enforce any possible access to the object in one
+ // > thread (through an existing reference) to *happen before* deleting
+ // > the object in a different thread. This is achieved by a "release"
+ // > operation after dropping a reference (any access to the object
+ // > through this reference must obviously happened before), and an
+ // > "acquire" operation before deleting the object.
+ //
+ // [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
+ // [2]: https://github.com/rust-lang/rust/pull/41714
+ self.inner().count.load(Acquire);
+
+ unsafe {
+ self.drop_slow();
+ }
+ }
+}
+
+impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
+ fn eq(&self, other: &Arc<T>) -> bool {
+ *(*self) == *(*other)
+ }
+
+ fn ne(&self, other: &Arc<T>) -> bool {
+ *(*self) != *(*other)
+ }
+}
+impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
+ fn partial_cmp(&self, other: &Arc<T>) -> Option<Ordering> {
+ (**self).partial_cmp(&**other)
+ }
+
+ fn lt(&self, other: &Arc<T>) -> bool {
+ *(*self) < *(*other)
+ }
+
+ fn le(&self, other: &Arc<T>) -> bool {
+ *(*self) <= *(*other)
+ }
+
+ fn gt(&self, other: &Arc<T>) -> bool {
+ *(*self) > *(*other)
+ }
+
+ fn ge(&self, other: &Arc<T>) -> bool {
+ *(*self) >= *(*other)
+ }
+}
+impl<T: ?Sized + Ord> Ord for Arc<T> {
+ fn cmp(&self, other: &Arc<T>) -> Ordering {
+ (**self).cmp(&**other)
+ }
+}
+impl<T: ?Sized + Eq> Eq for Arc<T> {}
+
+impl<T: ?Sized + fmt::Display> fmt::Display for Arc<T> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Display::fmt(&**self, f)
+ }
+}
+
+impl<T: ?Sized + fmt::Debug> fmt::Debug for Arc<T> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Debug::fmt(&**self, f)
+ }
+}
+
+impl<T: ?Sized> fmt::Pointer for Arc<T> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Pointer::fmt(&self.ptr, f)
+ }
+}
+
+impl<T: Default> Default for Arc<T> {
+ fn default() -> Arc<T> {
+ Arc::new(Default::default())
+ }
+}
+
+impl<T: ?Sized + Hash> Hash for Arc<T> {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ (**self).hash(state)
+ }
+}
+
+impl<T> From<T> for Arc<T> {
+ fn from(t: T) -> Self {
+ Arc::new(t)
+ }
+}
+
+impl<T: ?Sized> borrow::Borrow<T> for Arc<T> {
+ fn borrow(&self) -> &T {
+ &**self
+ }
+}
+
+impl<T: ?Sized> AsRef<T> for Arc<T> {
+ fn as_ref(&self) -> &T {
+ &**self
+ }
+}
+
+// This is what the HeapSize crate does for regular arc, but is questionably
+// sound. See https://github.com/servo/heapsize/issues/37
+#[cfg(feature = "servo")]
+impl<T: HeapSizeOf> HeapSizeOf for Arc<T> {
+ fn heap_size_of_children(&self) -> usize {
+ (**self).heap_size_of_children()
+ }
+}
+
+#[cfg(feature = "servo")]
+impl<T: Deserialize> Deserialize for Arc<T>
+{
+ fn deserialize<D>(deserializer: D) -> Result<Arc<T>, D::Error>
+ where
+ D: ::serde::de::Deserializer,
+ {
+ T::deserialize(deserializer).map(Arc::new)
+ }
+}
+
+#[cfg(feature = "servo")]
+impl<T: Serialize> Serialize for Arc<T>
+{
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: ::serde::ser::Serializer,
+ {
+ (**self).serialize(serializer)
+ }
+}
diff --git a/components/style/stylesheet_set.rs b/components/style/stylesheet_set.rs
index 78e0c9cd558..0cc6f4fbf51 100644
--- a/components/style/stylesheet_set.rs
+++ b/components/style/stylesheet_set.rs
@@ -4,7 +4,7 @@
//! A centralized set of stylesheets for a document.
-use std::sync::Arc;
+use stylearc::Arc;
use stylesheets::Stylesheet;
/// Entry for a StylesheetSet. We don't bother creating a constructor, because
diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs
index 97dfce4c51f..36e5a2a936e 100644
--- a/components/style/stylesheets.rs
+++ b/components/style/stylesheets.rs
@@ -36,10 +36,10 @@ use servo_url::ServoUrl;
use shared_lock::{SharedRwLock, Locked, ToCssWithGuard, SharedRwLockReadGuard};
use std::cell::Cell;
use std::fmt;
-use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use str::starts_with_ignore_ascii_case;
use style_traits::ToCss;
+use stylearc::Arc;
use stylist::FnvHashMap;
use supports::SupportsCondition;
use values::{CustomIdent, KeyframesName};
diff --git a/components/style/stylist.rs b/components/style/stylist.rs
index cda795d559c..5dc3e807374 100644
--- a/components/style/stylist.rs
+++ b/components/style/stylist.rs
@@ -39,8 +39,8 @@ use std::fmt;
use std::hash::Hash;
#[cfg(feature = "servo")]
use std::marker::PhantomData;
-use std::sync::Arc;
use style_traits::viewport::ViewportConstraints;
+use stylearc::Arc;
use stylesheets::{CssRule, FontFaceRule, Origin, StyleRule, Stylesheet, UserAgentStylesheets};
use thread_state;
use viewport::{self, MaybeNew, ViewportRule};
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index dff56ce8b0f..f53a47f0af7 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -11,7 +11,7 @@ use std::borrow::Cow;
use std::env;
use std::fmt::Write;
use std::ptr;
-use std::sync::{Arc, Mutex};
+use std::sync::Mutex;
use style::context::{QuirksMode, SharedStyleContext, StyleContext};
use style::context::{ThreadLocalStyleContext, ThreadLocalStyleContextCreationInfo};
use style::data::{ElementData, ElementStyles, RestyleData};
@@ -83,6 +83,7 @@ use style::sequential;
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked};
use style::string_cache::Atom;
use style::style_adjuster::StyleAdjuster;
+use style::stylearc::Arc;
use style::stylesheets::{CssRule, CssRules, CssRuleType, CssRulesHelpers};
use style::stylesheets::{ImportRule, MediaRule, NamespaceRule, Origin};
use style::stylesheets::{PageRule, Stylesheet, StyleRule, SupportsRule};
diff --git a/ports/geckolib/stylesheet_loader.rs b/ports/geckolib/stylesheet_loader.rs
index a79aa6e192f..87fdc4d39f3 100644
--- a/ports/geckolib/stylesheet_loader.rs
+++ b/ports/geckolib/stylesheet_loader.rs
@@ -2,12 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use std::sync::Arc;
use style::gecko_bindings::bindings::Gecko_LoadStyleSheet;
use style::gecko_bindings::structs::{Loader, ServoStyleSheet};
use style::gecko_bindings::sugar::ownership::{HasArcFFI, FFIArcHelpers};
use style::media_queries::MediaList;
use style::shared_lock::Locked;
+use style::stylearc::Arc;
use style::stylesheets::{ImportRule, Stylesheet, StylesheetLoader as StyleStylesheetLoader};
pub struct StylesheetLoader(*mut Loader, *mut ServoStyleSheet);
diff --git a/tests/unit/script/size_of.rs b/tests/unit/script/size_of.rs
index a328bcbf6f5..c319c0b77c5 100644
--- a/tests/unit/script/size_of.rs
+++ b/tests/unit/script/size_of.rs
@@ -31,10 +31,10 @@ macro_rules! sizeof_checker (
// Update the sizes here
sizeof_checker!(size_event_target, EventTarget, 40);
sizeof_checker!(size_node, Node, 152);
-sizeof_checker!(size_element, Element, 320);
-sizeof_checker!(size_htmlelement, HTMLElement, 336);
-sizeof_checker!(size_div, HTMLDivElement, 336);
-sizeof_checker!(size_span, HTMLSpanElement, 336);
+sizeof_checker!(size_element, Element, 328);
+sizeof_checker!(size_htmlelement, HTMLElement, 344);
+sizeof_checker!(size_div, HTMLDivElement, 344);
+sizeof_checker!(size_span, HTMLSpanElement, 344);
sizeof_checker!(size_text, Text, 184);
sizeof_checker!(size_characterdata, CharacterData, 184);
sizeof_checker!(size_servothreadsafelayoutnode, ServoThreadSafeLayoutNode, 16);
diff --git a/tests/unit/style/keyframes.rs b/tests/unit/style/keyframes.rs
index 4f96b5f88a9..1f3947c5815 100644
--- a/tests/unit/style/keyframes.rs
+++ b/tests/unit/style/keyframes.rs
@@ -2,12 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use std::sync::Arc;
use style::keyframes::{Keyframe, KeyframesAnimation, KeyframePercentage, KeyframeSelector};
use style::keyframes::{KeyframesStep, KeyframesStepValue};
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, Importance};
use style::properties::animated_properties::TransitionProperty;
use style::shared_lock::SharedRwLock;
+use style::stylearc::Arc;
use style::values::specified::{LengthOrPercentageOrAuto, NoCalcLength};
#[test]
diff --git a/tests/unit/style/media_queries.rs b/tests/unit/style/media_queries.rs
index 10634a6f134..d538225d9d8 100644
--- a/tests/unit/style/media_queries.rs
+++ b/tests/unit/style/media_queries.rs
@@ -6,13 +6,13 @@ use cssparser::{Parser, SourcePosition};
use euclid::size::TypedSize2D;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
-use std::sync::Arc;
use style::Atom;
use style::context::QuirksMode;
use style::error_reporting::ParseErrorReporter;
use style::media_queries::*;
use style::servo::media_queries::*;
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard};
+use style::stylearc::Arc;
use style::stylesheets::{Stylesheet, Origin, CssRule};
use style::values::specified;
use style_traits::ToCss;
diff --git a/tests/unit/style/rule_tree/bench.rs b/tests/unit/style/rule_tree/bench.rs
index ed73bd11d6f..68d253b2965 100644
--- a/tests/unit/style/rule_tree/bench.rs
+++ b/tests/unit/style/rule_tree/bench.rs
@@ -5,13 +5,13 @@
use cssparser::{Parser, SourcePosition};
use rayon;
use servo_url::ServoUrl;
-use std::sync::Arc;
use style::context::QuirksMode;
use style::error_reporting::ParseErrorReporter;
use style::media_queries::MediaList;
use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDeclarationBlock};
use style::rule_tree::{CascadeLevel, RuleTree, StrongRuleNode, StyleSource};
use style::shared_lock::SharedRwLock;
+use style::stylearc::Arc;
use style::stylesheets::{Origin, Stylesheet, CssRule};
use test::{self, Bencher};
diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs
index 47aa1ea9730..e599e9687ae 100644
--- a/tests/unit/style/stylesheets.rs
+++ b/tests/unit/style/stylesheets.rs
@@ -10,7 +10,6 @@ use selectors::parser::*;
use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
-use std::sync::Arc;
use std::sync::Mutex;
use std::sync::atomic::AtomicBool;
use style::context::QuirksMode;
@@ -22,6 +21,7 @@ use style::properties::{CSSWideKeyword, DeclaredValueOwned, PropertyDeclaration,
use style::properties::longhands;
use style::properties::longhands::animation_play_state;
use style::shared_lock::SharedRwLock;
+use style::stylearc::Arc;
use style::stylesheets::{Origin, Namespaces};
use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, CssRules, StyleRule, KeyframesRule};
use style::values::{KeyframesName, CustomIdent};
diff --git a/tests/unit/style/stylist.rs b/tests/unit/style/stylist.rs
index ea89dfde06b..096af2d0006 100644
--- a/tests/unit/style/stylist.rs
+++ b/tests/unit/style/stylist.rs
@@ -6,12 +6,12 @@ use html5ever_atoms::LocalName;
use selectors::parser::LocalName as LocalNameSelector;
use selectors::parser::Selector;
use servo_atoms::Atom;
-use std::sync::Arc;
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration};
use style::properties::{longhands, Importance};
use style::rule_tree::CascadeLevel;
use style::selector_parser::{SelectorImpl, SelectorParser};
use style::shared_lock::SharedRwLock;
+use style::stylearc::Arc;
use style::stylesheets::StyleRule;
use style::stylist::{Rule, SelectorMap};
use style::stylist::needs_revalidation;
diff --git a/tests/unit/style/viewport.rs b/tests/unit/style/viewport.rs
index fb29e87debf..ed8b9b527ee 100644
--- a/tests/unit/style/viewport.rs
+++ b/tests/unit/style/viewport.rs
@@ -7,11 +7,11 @@ use euclid::size::TypedSize2D;
use media_queries::CSSErrorReporterTest;
use servo_config::prefs::{PREFS, PrefValue};
use servo_url::ServoUrl;
-use std::sync::Arc;
use style::context::QuirksMode;
use style::media_queries::{Device, MediaList, MediaType};
use style::parser::{LengthParsingMode, Parse, ParserContext};
use style::shared_lock::SharedRwLock;
+use style::stylearc::Arc;
use style::stylesheets::{CssRuleType, Stylesheet, Origin};
use style::values::specified::LengthOrPercentageOrAuto::{self, Auto};
use style::values::specified::NoCalcLength::{self, ViewportPercentage};