diff options
author | moz-servo-sync <developer-services+moz-servo-sync@mozilla.org> | 2017-06-23 20:47:48 +0000 |
---|---|---|
committer | moz-servo-sync <developer-services+moz-servo-sync@mozilla.org> | 2017-06-23 20:47:48 +0000 |
commit | 38f172e7f55db3daeb93f61fd97919ae4ff1f1cf (patch) | |
tree | f2f98517572a812f3f16fba1fc05a9536c9cd353 /components/style | |
parent | c292287adf39ab1c49b696d1a115ec4e3b0b2e9f (diff) | |
parent | bc5e8f89fff9bf1922638b3eb2f4c75148dcad1e (diff) | |
download | servo-38f172e7f55db3daeb93f61fd97919ae4ff1f1cf.tar.gz servo-38f172e7f55db3daeb93f61fd97919ae4ff1f1cf.zip |
Merge commit 'refs/upstream/master' into gecko-backout
Diffstat (limited to 'components/style')
-rw-r--r-- | components/style/gecko/global_style_data.rs | 28 | ||||
-rw-r--r-- | components/style/properties/helpers.mako.rs | 12 | ||||
-rw-r--r-- | components/style/properties/helpers/animated_properties.mako.rs | 2 | ||||
-rw-r--r-- | components/style/properties/longhand/box.mako.rs | 45 | ||||
-rw-r--r-- | components/style/properties/longhand/inherited_svg.mako.rs | 23 | ||||
-rw-r--r-- | components/style/properties/properties.mako.rs | 16 |
6 files changed, 71 insertions, 55 deletions
diff --git a/components/style/gecko/global_style_data.rs b/components/style/gecko/global_style_data.rs index 0f80a18816e..f396a4ee451 100644 --- a/components/style/gecko/global_style_data.rs +++ b/components/style/gecko/global_style_data.rs @@ -16,12 +16,6 @@ use std::ffi::CString; /// Global style data pub struct GlobalStyleData { - /// How many threads parallel styling can use. - pub num_threads: usize, - - /// The parallel styling thread pool. - pub style_thread_pool: Option<rayon::ThreadPool>, - /// Shared RWLock for CSSOM objects pub shared_lock: SharedRwLock, @@ -29,6 +23,15 @@ pub struct GlobalStyleData { pub options: StyleSystemOptions, } +/// Global thread pool +pub struct StyleThreadPool { + /// How many threads parallel styling can use. + pub num_threads: usize, + + /// The parallel styling thread pool. + pub style_thread_pool: Option<rayon::ThreadPool>, +} + fn thread_name(index: usize) -> String { format!("StyleThread#{}", index) } @@ -53,8 +56,8 @@ fn thread_shutdown(_: usize) { } lazy_static! { - /// Global style data - pub static ref GLOBAL_STYLE_DATA: GlobalStyleData = { + /// Global thread pool + pub static ref STYLE_THREAD_POOL: StyleThreadPool = { let stylo_threads = env::var("STYLO_THREADS") .map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS value")); let mut num_threads = match stylo_threads { @@ -93,11 +96,14 @@ lazy_static! { pool }; - GlobalStyleData { + StyleThreadPool { num_threads: num_threads, style_thread_pool: pool, - shared_lock: SharedRwLock::new(), - options: StyleSystemOptions::default(), } }; + /// Global style data + pub static ref GLOBAL_STYLE_DATA: GlobalStyleData = GlobalStyleData { + shared_lock: SharedRwLock::new(), + options: StyleSystemOptions::default(), + }; } diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 54b5c313e36..8c6701497e4 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -9,7 +9,7 @@ <%def name="predefined_type(name, type, initial_value, parse_method='parse', needs_context=True, vector=False, computed_type=None, initial_specified_value=None, - allow_quirks=False, **kwargs)"> + allow_quirks=False, allow_empty=False, **kwargs)"> <%def name="predefined_type_inner(name, type, initial_value, parse_method)"> #[allow(unused_imports)] use app_units::Au; @@ -27,7 +27,9 @@ pub use values::computed::${type} as T; % endif } + % if initial_value: #[inline] pub fn get_initial_value() -> computed_value::T { ${initial_value} } + % endif % if initial_specified_value: #[inline] pub fn get_initial_specified_value() -> SpecifiedValue { ${initial_specified_value} } % endif @@ -46,7 +48,9 @@ } </%def> % if vector: - <%call expr="vector_longhand(name, predefined_type=type, **kwargs)"> + <%call + expr="vector_longhand(name, predefined_type=type, allow_empty=allow_empty or not initial_value, **kwargs)" + > ${predefined_type_inner(name, type, initial_value, parse_method)} % if caller: ${caller.body()} @@ -202,7 +206,7 @@ } pub fn get_initial_value() -> computed_value::T { - % if allow_empty: + % if allow_empty and allow_empty != "NotInitial": computed_value::T(SmallVec::new()) % else: let mut v = SmallVec::new(); @@ -333,7 +337,7 @@ let quirks_mode = context.quirks_mode; ::properties::substitute_variables_${property.ident}( &declared_value, &custom_props, - |value| { + &mut |value| { if let Some(ref mut cascade_info) = *cascade_info { cascade_info.on_cascade_property(&declaration, &value); diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 3874f972a25..99b2cc377f6 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -582,7 +582,7 @@ impl AnimationValue { &variables.url_data, variables.from_shorthand, &custom_props, - |v| { + &mut |v| { let declaration = match *v { DeclaredValue::Value(value) => { PropertyDeclaration::${prop.camel_case}(value.clone()) diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 4f0449ad0bf..871eb37513d 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -429,17 +429,19 @@ ${helpers.predefined_type("transition-timing-function", extra_prefixes="moz webkit", spec="https://drafts.csswg.org/css-transitions/#propdef-transition-timing-function")} -${helpers.predefined_type("transition-property", - "TransitionProperty", - "computed::TransitionProperty::All", - initial_specified_value="specified::TransitionProperty::All", - vector=True, - allow_empty=True, - need_index=True, - needs_context=False, - animation_value_type="none", - extra_prefixes="moz webkit", - spec="https://drafts.csswg.org/css-transitions/#propdef-transition-property")} +${helpers.predefined_type( + "transition-property", + "TransitionProperty", + "computed::TransitionProperty::All", + initial_specified_value="specified::TransitionProperty::All", + vector=True, + allow_empty="NotInitial", + need_index=True, + needs_context=False, + animation_value_type="none", + extra_prefixes="moz webkit", + spec="https://drafts.csswg.org/css-transitions/#propdef-transition-property", +)} ${helpers.predefined_type("transition-delay", "Time", @@ -668,16 +670,17 @@ ${helpers.predefined_type("scroll-snap-destination", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)", animation_value_type="ComputedValue")} -${helpers.predefined_type("scroll-snap-coordinate", - "Position", - "computed::Position::zero()", - vector=True, - products="gecko", - spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)", - animation_value_type="ComputedValue", - allow_empty=True, - delegate_animate=True)} - +${helpers.predefined_type( + "scroll-snap-coordinate", + "Position", + "computed::Position::zero()", + vector=True, + products="gecko", + spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)", + animation_value_type="ComputedValue", + allow_empty="NotInitial", + delegate_animate=True, +)} <%helpers:longhand name="transform" extra_prefixes="webkit" animation_value_type="ComputedValue" diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs index 3799c89d3ad..1d7fd7a985a 100644 --- a/components/style/properties/longhand/inherited_svg.mako.rs +++ b/components/style/properties/longhand/inherited_svg.mako.rs @@ -88,17 +88,18 @@ ${helpers.predefined_type("stroke-opacity", "Opacity", "1.0", products="gecko", animation_value_type="ComputedValue", spec="https://www.w3.org/TR/SVG11/painting.html#StrokeOpacityProperty")} -${helpers.predefined_type("stroke-dasharray", - "LengthOrPercentageOrNumber", - "Either::First(0.0)", - "parse_non_negative", - vector="True", - delegate_animate="True", - allow_empty="True", - products="gecko", - animation_value_type="ComputedValue", - space_separated_allowed="True", - spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing")} +${helpers.predefined_type( + "stroke-dasharray", + "LengthOrPercentageOrNumber", + None, + "parse_non_negative", + vector=True, + delegate_animate=True, + products="gecko", + animation_value_type="ComputedValue", + space_separated_allowed="True", + spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing", +)} ${helpers.predefined_type( "stroke-dashoffset", "LengthOrPercentageOrNumber", diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 390ad3d3c27..4507ea5119a 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -373,13 +373,13 @@ impl PropertyDeclarationIdSet { value: &DeclaredValue<longhands::${property.ident}::SpecifiedValue>, % endif custom_properties: &Option<Arc<::custom_properties::ComputedValuesMap>>, - f: F, + f: &mut F, error_reporter: &ParseErrorReporter, quirks_mode: QuirksMode) % if property.boxed: - where F: FnOnce(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>) + where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>) % else: - where F: FnOnce(&DeclaredValue<longhands::${property.ident}::SpecifiedValue>) + where F: FnMut(&DeclaredValue<longhands::${property.ident}::SpecifiedValue>) % endif { if let DeclaredValue::WithVariables(ref with_variables) = *value { @@ -404,13 +404,13 @@ impl PropertyDeclarationIdSet { url_data: &UrlExtraData, from_shorthand: Option<ShorthandId>, custom_properties: &Option<Arc<::custom_properties::ComputedValuesMap>>, - f: F, + f: &mut F, error_reporter: &ParseErrorReporter, quirks_mode: QuirksMode) % if property.boxed: - where F: FnOnce(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>) + where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>) % else: - where F: FnOnce(&DeclaredValue<longhands::${property.ident}::SpecifiedValue>) + where F: FnMut(&DeclaredValue<longhands::${property.ident}::SpecifiedValue>) % endif { f(& @@ -1765,7 +1765,9 @@ pub mod style_structs { /// Returns whether there are any transitions specified. #[cfg(feature = "servo")] pub fn specifies_transitions(&self) -> bool { - self.transition_property_count() > 0 + self.transition_duration_iter() + .take(self.transition_property_count()) + .any(|t| t.seconds() > 0.) } % endif } |