style: Pass old ComputedValues and old cached struct bits to Gecko_CalcStyleDifference. draft
authorCameron McCormack <cam@mcc.id.au>
Wed, 19 Jul 2017 17:48:53 +0800
changeset 611829 d314e31dc7ff5670b82ddc0689c63502481e5cfb
parent 611828 c0da59ab2cdaf5f52007408078edbfb1aca94384
child 611830 84380ce64306ff2f51bcdd447fc089b861edfc48
push id69301
push userbmo:cam@mcc.id.au
push dateThu, 20 Jul 2017 02:49:51 +0000
milestone56.0a1
style: Pass old ComputedValues and old cached struct bits to Gecko_CalcStyleDifference. MozReview-Commit-ID: 94fuzB6lHd8
servo/components/style/gecko/restyle_damage.rs
servo/components/style/matching.rs
--- a/servo/components/style/gecko/restyle_damage.rs
+++ b/servo/components/style/gecko/restyle_damage.rs
@@ -43,24 +43,24 @@ impl GeckoRestyleDamage {
     /// (in the form of `ComputedValues`).
     ///
     /// Note that we could in theory just get two `ComputedValues` here and diff
     /// them, but Gecko has an interesting optimization when they mark accessed
     /// structs, so they effectively only diff structs that have ever been
     /// accessed from layout.
     pub fn compute_style_difference(
         source: &nsStyleContext,
-        new_style: &Arc<ComputedValues>
+        old_style: &ComputedValues,
+        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,
+            bindings::Gecko_CalcStyleDifference(old_style.as_style_context(),
                                                 new_style.as_style_context(),
+                                                source.mBits,
                                                 &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/matching.rs
+++ b/servo/components/style/matching.rs
@@ -763,17 +763,17 @@ pub trait MatchMethods : TElement {
     fn compute_style_difference(
         &self,
         old_values: &ComputedValues,
         new_values: &Arc<ComputedValues>,
         pseudo: Option<&PseudoElement>
     ) -> StyleDifference {
         debug_assert!(pseudo.map_or(true, |p| p.is_eager()));
         if let Some(source) = self.existing_style_for_restyle_damage(old_values, pseudo) {
-            return RestyleDamage::compute_style_difference(source, new_values)
+            return RestyleDamage::compute_style_difference(source, old_values, new_values)
         }
 
         let new_display = new_values.get_box().clone_display();
         let old_display = old_values.get_box().clone_display();
 
         let new_style_is_display_none = new_display == display::T::none;
         let old_style_is_display_none = old_display == display::T::none;