servo: Merge #18842 - style: Skip custom properties comparison if other inherited properties changed (from heycam:skip-var-check); r=emilio
authorCameron McCormack <cam@mcc.id.au>
Wed, 11 Oct 2017 21:45:51 -0500
changeset 679165 16003b36a7b36b4d92fef7c12b76c5492a026cf2
parent 679164 e92ca171760d45bc16813e6f235bb7bd2c48ca81
child 679166 4cc45d7c8cafd210b8efdd32b91194f81baf807e
push id84141
push userbmo:schien@mozilla.com
push dateThu, 12 Oct 2017 11:13:04 +0000
reviewersemilio
milestone58.0a1
servo: Merge #18842 - style: Skip custom properties comparison if other inherited properties changed (from heycam:skip-var-check); r=emilio Servo half of https://bugzilla.mozilla.org/show_bug.cgi?id=1407246, reviewed there by Emilio. Source-Repo: https://github.com/servo/servo Source-Revision: 9f8514d2b94713b6dc3bb918f8ffa9fac66021a3
servo/components/style/gecko/restyle_damage.rs
--- a/servo/components/style/gecko/restyle_damage.rs
+++ b/servo/components/style/gecko/restyle_damage.rs
@@ -52,16 +52,26 @@ impl GeckoRestyleDamage {
         let hint = unsafe {
             bindings::Gecko_CalcStyleDifference(
                 old_style,
                 new_style,
                 &mut any_style_changed,
                 &mut reset_only,
             )
         };
+        if reset_only &&
+           old_style.custom_properties() != new_style.custom_properties() {
+            // The Gecko_CalcStyleDifference call only checks the non-custom
+            // property structs, so we check the custom properties here. Since
+            // they generate no damage themselves, we can skip this check if we
+            // already know we had some inherited (regular) property
+            // differences.
+            any_style_changed = true;
+            reset_only = false;
+        }
         let change = if any_style_changed {
             StyleChange::Changed { reset_only }
         } else {
             StyleChange::Unchanged
         };
         StyleDifference::new(GeckoRestyleDamage(nsChangeHint(hint)), change)
     }