style: Add FFI function to compare ComputedValues for custom property differences. draft
authorCameron McCormack <cam@mcc.id.au>
Thu, 13 Jul 2017 16:50:22 +0800
changeset 608216 728cad53680f7c5ead3fb23510226969e3201a9d
parent 608215 47ba06b370d484fc08a9bbb356c608a5b01967d1
child 608217 f6584be1d1622658659d6bdfa0c09ba021fb18f9
push id68205
push userbmo:cam@mcc.id.au
push dateThu, 13 Jul 2017 08:57:29 +0000
milestone56.0a1
style: Add FFI function to compare ComputedValues for custom property differences. MozReview-Commit-ID: 9ayoBjzZTdG
servo/components/style/properties/gecko.mako.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -187,16 +187,21 @@ impl ComputedValues {
     }
 
     /// Clone the visited style.  Used for inheriting parent styles in
     /// StyleBuilder::for_inheritance.
     pub fn clone_visited_style(&self) -> Option<Arc<ComputedValues>> {
         self.visited_style.clone()
     }
 
+    /// Gets a reference to the custom properties map (if one exists).
+    pub fn get_custom_properties(&self) -> Option<<&::custom_properties::CustomPropertiesMap> {
+        self.custom_properties.as_ref().map(|x| &**x)
+    }
+
     pub fn custom_properties(&self) -> Option<Arc<CustomPropertiesMap>> {
         self.custom_properties.clone()
     }
 
     #[allow(non_snake_case)]
     pub fn has_moz_binding(&self) -> bool {
         !self.get_box().gecko.mBinding.mPtr.mRawPtr.is_null()
     }
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1728,16 +1728,26 @@ pub extern "C" fn Servo_ComputedValues_G
 pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(values: ServoComputedValuesBorrowed)
                                                                         -> bool {
     let values = ComputedValues::as_arc(&values);
     let b = values.get_box();
     b.specifies_animations() || b.specifies_transitions()
 }
 
 #[no_mangle]
+pub extern "C" fn Servo_ComputedValues_EqualCustomProperties(
+    first: ServoComputedValuesBorrowed,
+    second: ServoComputedValuesBorrowed
+) -> bool {
+    let first = ComputedValues::as_arc(&first);
+    let second = ComputedValues::as_arc(&second);
+    first.get_custom_properties() == second.get_custom_properties()
+}
+
+#[no_mangle]
 pub extern "C" fn Servo_ComputedValues_GetStyleRuleList(values: ServoComputedValuesBorrowed,
                                                         rules: RawGeckoServoStyleRuleListBorrowedMut) {
     let values = ComputedValues::as_arc(&values);
     if let Some(ref rule_node) = values.rules {
         let mut result = vec![];
         for node in rule_node.self_and_ancestors() {
             if let &StyleSource::Style(ref rule) = node.style_source() {
                 result.push(Locked::<StyleRule>::arc_as_borrowed(&rule));