Use the LonghandIdSet to check whether a property is set. r?Manishearth draft
authorXidorn Quan <me@upsuper.org>
Mon, 11 Sep 2017 12:32:14 +1000
changeset 662118 828c70c9b38dedd7145cb22f4176b4ba3fd7ec47
parent 662117 1d3ceb995429d6e0bf98f67908c149802c6e28ff
child 662119 eedb2472a5536fd8eabc178cbbadda95c5dfe0f4
push id78952
push userxquan@mozilla.com
push dateMon, 11 Sep 2017 02:33:50 +0000
reviewersManishearth
milestone57.0a1
Use the LonghandIdSet to check whether a property is set. r?Manishearth MozReview-Commit-ID: 49G0WcRe4pJ
servo/components/style/properties/declaration_block.rs
servo/ports/geckolib/glue.rs
--- 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,