diff options
Diffstat (limited to 'components')
29 files changed, 40 insertions, 46 deletions
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 99ded2b9fe8..8902ab4efc6 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -132,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; @@ -177,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..83ca3e3d4fb 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 @@ -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/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}; |