Use the LonghandIdSet to check whether a property is set. r?Manishearth
draft
Use the LonghandIdSet to check whether a property is set. r?Manishearth
MozReview-Commit-ID: 49G0WcRe4pJ
--- a/servo/components/style/properties/declaration_block.rs
+++ b/servo/components/style/properties/declaration_block.rs
@@ -217,16 +217,21 @@ impl PropertyDeclarationBlock {
///
/// This is based on the `important_count` counter,
/// which should be maintained whenever `declarations` is changed.
// FIXME: make fields private and maintain it here in methods?
pub fn any_normal(&self) -> bool {
self.declarations.len() > self.important_count
}
+ /// Returns whether this block contains a declaration of a given longhand.
+ pub fn contains(&self, id: LonghandId) -> bool {
+ self.longhands.contains(id)
+ }
+
/// Get a declaration for a given property.
///
/// NOTE: This is linear time.
pub fn get(&self, property: PropertyDeclarationId) -> Option< &(PropertyDeclaration, Importance)> {
self.declarations.iter().find(|&&(ref decl, _)| decl.id() == property)
}
/// Find the value of the given property in this block and serialize it
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -2561,20 +2561,18 @@ macro_rules! match_wrap_declared {
)
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_PropertyIsSet(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID)
-> bool {
- use style::properties::PropertyDeclarationId;
- let long = get_longhand_from_id!(property);
read_locked_arc(declarations, |decls: &PropertyDeclarationBlock| {
- decls.get(PropertyDeclarationId::Longhand(long)).is_some()
+ decls.contains(get_longhand_from_id!(property))
})
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(declarations:
RawServoDeclarationBlockBorrowed,
property:
nsCSSPropertyID,