mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +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::PropertyDeclarationParseResult;
|
||||||
use properties::animated_properties::TransitionProperty;
|
use properties::animated_properties::TransitionProperty;
|
||||||
use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction;
|
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::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
|
@ -230,7 +230,7 @@
|
||||||
use cascade_info::CascadeInfo;
|
use cascade_info::CascadeInfo;
|
||||||
use error_reporting::ParseErrorReporter;
|
use error_reporting::ParseErrorReporter;
|
||||||
use properties::longhands;
|
use properties::longhands;
|
||||||
use properties::property_bit_field::PropertyBitField;
|
use properties::PropertyBitField;
|
||||||
use properties::{ComputedValues, PropertyDeclaration};
|
use properties::{ComputedValues, PropertyDeclaration};
|
||||||
use properties::style_structs;
|
use properties::style_structs;
|
||||||
use std::boxed::Box as StdBox;
|
use std::boxed::Box as StdBox;
|
||||||
|
|
|
@ -29,6 +29,7 @@ use font_metrics::FontMetricsProvider;
|
||||||
#[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
|
#[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
|
||||||
use logical_geometry::WritingMode;
|
use logical_geometry::WritingMode;
|
||||||
use parser::{Parse, ParserContext, ParserContextExtraData};
|
use parser::{Parse, ParserContext, ParserContextExtraData};
|
||||||
|
use properties::animated_properties::TransitionProperty;
|
||||||
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
|
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
@ -39,7 +40,6 @@ use cascade_info::CascadeInfo;
|
||||||
use rule_tree::StrongRuleNode;
|
use rule_tree::StrongRuleNode;
|
||||||
#[cfg(feature = "servo")] use values::specified::BorderStyle;
|
#[cfg(feature = "servo")] use values::specified::BorderStyle;
|
||||||
|
|
||||||
use self::property_bit_field::PropertyBitField;
|
|
||||||
pub use self::declaration_block::*;
|
pub use self::declaration_block::*;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
@ -178,61 +178,55 @@ pub mod animated_properties {
|
||||||
<%include file="/helpers/animated_properties.mako.rs" />
|
<%include file="/helpers/animated_properties.mako.rs" />
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
/// A set of longhand properties
|
||||||
pub mod property_bit_field {
|
pub struct PropertyBitField {
|
||||||
use properties::animated_properties::TransitionProperty;
|
storage: [u32; (${len(data.longhands)} - 1 + 32) / 32]
|
||||||
use properties::LonghandId;
|
}
|
||||||
|
|
||||||
/// A set of longhand properties
|
impl PropertyBitField {
|
||||||
pub struct PropertyBitField {
|
/// Create an empty set
|
||||||
storage: [u32; (${len(data.longhands)} - 1 + 32) / 32]
|
#[inline]
|
||||||
|
pub fn new() -> PropertyBitField {
|
||||||
|
PropertyBitField { storage: [0; (${len(data.longhands)} - 1 + 32) / 32] }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PropertyBitField {
|
/// Return whether the given property is in the set
|
||||||
/// Create an empty set
|
#[inline]
|
||||||
#[inline]
|
pub fn contains(&self, id: LonghandId) -> bool {
|
||||||
pub fn new() -> PropertyBitField {
|
let bit = id as usize;
|
||||||
PropertyBitField { storage: [0; (${len(data.longhands)} - 1 + 32) / 32] }
|
(self.storage[bit / 32] & (1 << (bit % 32))) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return whether the given property is in the set
|
/// Add the given property to the set
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn contains(&self, id: LonghandId) -> bool {
|
pub fn insert(&mut self, id: LonghandId) {
|
||||||
let bit = id as usize;
|
let bit = id as usize;
|
||||||
(self.storage[bit / 32] & (1 << (bit % 32))) != 0
|
self.storage[bit / 32] |= 1 << (bit % 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add the given property to the set
|
/// Set the corresponding bit of TransitionProperty.
|
||||||
#[inline]
|
/// This function will panic if TransitionProperty::All is given.
|
||||||
pub fn insert(&mut self, id: LonghandId) {
|
pub fn set_transition_property_bit(&mut self, property: &TransitionProperty) {
|
||||||
let bit = id as usize;
|
match *property {
|
||||||
self.storage[bit / 32] |= 1 << (bit % 32);
|
% 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.
|
/// Return true if the corresponding bit of TransitionProperty is set.
|
||||||
/// This function will panic if TransitionProperty::All is given.
|
/// This function will panic if TransitionProperty::All is given.
|
||||||
pub fn set_transition_property_bit(&mut self, property: &TransitionProperty) {
|
pub fn has_transition_property_bit(&self, property: &TransitionProperty) -> bool {
|
||||||
match *property {
|
match *property {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
TransitionProperty::${prop.camel_case} => self.insert(LonghandId::${prop.camel_case}),
|
TransitionProperty::${prop.camel_case} => self.contains(LonghandId::${prop.camel_case}),
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
TransitionProperty::All => unreachable!("Tried to set TransitionProperty::All in a PropertyBitfield"),
|
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)
|
computed_keyframes: RawGeckoComputedKeyframeValuesListBorrowedMut)
|
||||||
{
|
{
|
||||||
use style::properties::declaration_block::Importance;
|
use style::properties::declaration_block::Importance;
|
||||||
use style::properties::property_bit_field::PropertyBitField;
|
use style::properties::PropertyBitField;
|
||||||
use style::values::computed::Context;
|
use style::values::computed::Context;
|
||||||
|
|
||||||
let style = ComputedValues::as_arc(&style);
|
let style = ComputedValues::as_arc(&style);
|
||||||
|
@ -1429,7 +1429,7 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoComputedValuesBorrowed,
|
||||||
keyframes: RawGeckoKeyframeListBorrowedMut) -> bool {
|
keyframes: RawGeckoKeyframeListBorrowedMut) -> bool {
|
||||||
use style::gecko_bindings::structs::Keyframe;
|
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 data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
let name = unsafe { Atom::from(name.as_ref().unwrap().as_str_unchecked()) };
|
let name = unsafe { Atom::from(name.as_ref().unwrap().as_str_unchecked()) };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue