diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index fcb05c8dc34..7281f11692c 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -15,7 +15,7 @@ use properties::{PropertyDeclarationId, LonghandId, DeclaredValue}; use properties::PropertyDeclarationParseResult; use properties::animated_properties::TransitionProperty; use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; -use properties::property_bit_field::PropertyBitField; +use properties::PropertyBitField; use std::fmt; use std::sync::Arc; use style_traits::ToCss; diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index a6c21c430f4..44a893a671e 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -230,7 +230,7 @@ use cascade_info::CascadeInfo; use error_reporting::ParseErrorReporter; use properties::longhands; - use properties::property_bit_field::PropertyBitField; + use properties::PropertyBitField; use properties::{ComputedValues, PropertyDeclaration}; use properties::style_structs; use std::boxed::Box as StdBox; diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 1297f5e227f..03a8924b78d 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -29,6 +29,7 @@ use font_metrics::FontMetricsProvider; #[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide}; use logical_geometry::WritingMode; use parser::{Parse, ParserContext, ParserContextExtraData}; +use properties::animated_properties::TransitionProperty; #[cfg(feature = "servo")] use servo_config::prefs::PREFS; use servo_url::ServoUrl; use style_traits::ToCss; @@ -39,7 +40,6 @@ use cascade_info::CascadeInfo; use rule_tree::StrongRuleNode; #[cfg(feature = "servo")] use values::specified::BorderStyle; -use self::property_bit_field::PropertyBitField; pub use self::declaration_block::*; #[cfg(feature = "gecko")] @@ -178,61 +178,55 @@ pub mod animated_properties { <%include file="/helpers/animated_properties.mako.rs" /> } -#[allow(missing_docs)] -pub mod property_bit_field { - use properties::animated_properties::TransitionProperty; - use properties::LonghandId; +/// A set of longhand properties +pub struct PropertyBitField { + storage: [u32; (${len(data.longhands)} - 1 + 32) / 32] +} - /// A set of longhand properties - pub struct PropertyBitField { - storage: [u32; (${len(data.longhands)} - 1 + 32) / 32] +impl PropertyBitField { + /// Create an empty set + #[inline] + pub fn new() -> PropertyBitField { + PropertyBitField { storage: [0; (${len(data.longhands)} - 1 + 32) / 32] } } - impl PropertyBitField { - /// Create an empty set - #[inline] - pub fn new() -> PropertyBitField { - PropertyBitField { storage: [0; (${len(data.longhands)} - 1 + 32) / 32] } - } + /// Return whether the given property is in the set + #[inline] + pub fn contains(&self, id: LonghandId) -> bool { + let bit = id as usize; + (self.storage[bit / 32] & (1 << (bit % 32))) != 0 + } - /// Return whether the given property is in the set - #[inline] - pub fn contains(&self, id: LonghandId) -> bool { - let bit = id as usize; - (self.storage[bit / 32] & (1 << (bit % 32))) != 0 - } + /// Add the given property to the set + #[inline] + pub fn insert(&mut self, id: LonghandId) { + let bit = id as usize; + self.storage[bit / 32] |= 1 << (bit % 32); + } - /// Add the given property to the set - #[inline] - pub fn insert(&mut self, id: LonghandId) { - let bit = id as usize; - self.storage[bit / 32] |= 1 << (bit % 32); + /// Set the corresponding bit of TransitionProperty. + /// This function will panic if TransitionProperty::All is given. + pub fn set_transition_property_bit(&mut self, property: &TransitionProperty) { + match *property { + % for prop in data.longhands: + % if prop.animatable: + TransitionProperty::${prop.camel_case} => self.insert(LonghandId::${prop.camel_case}), + % endif + % endfor + TransitionProperty::All => unreachable!("Tried to set TransitionProperty::All in a PropertyBitfield"), } + } - /// Set the corresponding bit of TransitionProperty. - /// This function will panic if TransitionProperty::All is given. - pub fn set_transition_property_bit(&mut self, property: &TransitionProperty) { - match *property { - % for prop in data.longhands: - % if prop.animatable: - TransitionProperty::${prop.camel_case} => self.insert(LonghandId::${prop.camel_case}), - % endif - % endfor - TransitionProperty::All => unreachable!("Tried to set TransitionProperty::All in a PropertyBitfield"), - } - } - - /// Return true if the corresponding bit of TransitionProperty is set. - /// This function will panic if TransitionProperty::All is given. - pub fn has_transition_property_bit(&self, property: &TransitionProperty) -> bool { - match *property { - % for prop in data.longhands: - % if prop.animatable: - TransitionProperty::${prop.camel_case} => self.contains(LonghandId::${prop.camel_case}), - % endif - % endfor - TransitionProperty::All => unreachable!("Tried to get TransitionProperty::All in a PropertyBitfield"), - } + /// Return true if the corresponding bit of TransitionProperty is set. + /// This function will panic if TransitionProperty::All is given. + pub fn has_transition_property_bit(&self, property: &TransitionProperty) -> bool { + match *property { + % for prop in data.longhands: + % if prop.animatable: + TransitionProperty::${prop.camel_case} => self.contains(LonghandId::${prop.camel_case}), + % endif + % endfor + TransitionProperty::All => unreachable!("Tried to get TransitionProperty::All in a PropertyBitfield"), } } } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 4cfba96bd4a..74d556f8da7 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1339,7 +1339,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis computed_keyframes: RawGeckoComputedKeyframeValuesListBorrowedMut) { use style::properties::declaration_block::Importance; - use style::properties::property_bit_field::PropertyBitField; + use style::properties::PropertyBitField; use style::values::computed::Context; let style = ComputedValues::as_arc(&style); @@ -1429,7 +1429,7 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet style: ServoComputedValuesBorrowed, keyframes: RawGeckoKeyframeListBorrowedMut) -> bool { use style::gecko_bindings::structs::Keyframe; - use style::properties::property_bit_field::PropertyBitField; + use style::properties::PropertyBitField; let data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); let name = unsafe { Atom::from(name.as_ref().unwrap().as_str_unchecked()) };