style: Pass a &ComputedValues (aka ServoStyleContext*) to Gecko_CalcStyleDifference. draft
authorCameron McCormack <cam@mcc.id.au>
Wed, 19 Jul 2017 14:15:07 +0800
changeset 611825 6a8de9b74e00bf1f7655c3a3be14cb4f6a3e09c4
parent 611824 4b138e1eb8544144fb60c1548162e0ead806fc81
child 611826 b47c94fa6998653cb74f76935dafe99520ed8c89
push id69301
push userbmo:cam@mcc.id.au
push dateThu, 20 Jul 2017 02:49:51 +0000
milestone56.0a1
style: Pass a &ComputedValues (aka ServoStyleContext*) to Gecko_CalcStyleDifference. MozReview-Commit-ID: J5xUn1nEqOB
servo/components/style/gecko/restyle_damage.rs
servo/components/style/properties/gecko.mako.rs
--- a/servo/components/style/gecko/restyle_damage.rs
+++ b/servo/components/style/gecko/restyle_damage.rs
@@ -50,17 +50,17 @@ impl GeckoRestyleDamage {
         source: &nsStyleContext,
         new_style: &Arc<ComputedValues>
     ) -> StyleDifference {
         // TODO(emilio): Const-ify this?
         let context = source as *const nsStyleContext as *mut nsStyleContext;
         let mut any_style_changed: bool = false;
         let hint = unsafe {
             bindings::Gecko_CalcStyleDifference(context,
-                                                &new_style,
+                                                new_style.as_style_context(),
                                                 &mut any_style_changed)
         };
         let change = if any_style_changed { StyleChange::Changed } else { StyleChange::Unchanged };
         StyleDifference::new(GeckoRestyleDamage(hint), change)
     }
 
     /// Returns true if this restyle damage contains all the damage of |other|.
     pub fn contains(self, other: Self) -> bool {
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -132,16 +132,20 @@ impl ComputedValues {
         let atom = (self.0)._base.mPseudoTag.raw::<structs::nsIAtom>();
         if atom.is_null() {
             return None;
         }
 
         let atom = Atom::from(atom);
         PseudoElement::from_atom(&atom)
     }
+
+    pub fn as_style_context(&self) -> &::gecko_bindings::structs::mozilla::ServoStyleContext {
+        &self.0
+    }
 }
 
 impl Drop for ComputedValues {
     fn drop(&mut self) {
         unsafe {
             bindings::Gecko_ServoStyleContext_Destroy(&mut self.0);
         }
     }