mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Move PropertyBitField out of its module
This commit is contained in:
parent
16a34ef6b6
commit
c81ebca7df
4 changed files with 47 additions and 53 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue