Use StyleArc in the style system.

MozReview-Commit-ID: flF0fv9E9M
This commit is contained in:
Bobby Holley 2017-04-30 15:18:01 -07:00
parent 6d8fc600b8
commit d78ca4c4f9
37 changed files with 49 additions and 54 deletions

View file

@ -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;

View file

@ -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.

View file

@ -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;

View file

@ -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`.
///

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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};

View file

@ -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};

View file

@ -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`.

View file

@ -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)]

View file

@ -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;

View file

@ -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 {

View file

@ -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>

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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};

View file

@ -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 {

View file

@ -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;

View file

@ -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.

View file

@ -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?"),
};

View file

@ -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.

View file

@ -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."]

View file

@ -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;

View file

@ -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")]

View file

@ -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

View file

@ -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};

View file

@ -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};

View file

@ -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};

View file

@ -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);

View file

@ -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]

View file

@ -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;

View file

@ -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};

View file

@ -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};

View file

@ -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;

View file

@ -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};