Bug 1471116 - Use nsCSSProps::kPropertyPrefTable for pref callback register of nsComputedDOMStyle. r?emilio draft
authorXidorn Quan <me@upsuper.org>
Tue, 26 Jun 2018 14:06:46 +1000
changeset 810550 b3ee5422bdd378fab3f54ca52662ea27b457cede
parent 810535 d642afdeb2ac57bd55eb29173698a575e49e6fb9
child 810741 6e2448ce3f4d9965749298a575795dfab926b9cb
push id114032
push userxquan@mozilla.com
push dateTue, 26 Jun 2018 04:07:38 +0000
reviewersemilio
bugs1471116
milestone63.0a1
Bug 1471116 - Use nsCSSProps::kPropertyPrefTable for pref callback register of nsComputedDOMStyle. r?emilio MozReview-Commit-ID: 7VvFGYi12te
layout/style/nsComputedDOMStyle.cpp
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -7192,45 +7192,23 @@ nsComputedDOMStyle::GetComputedStyleMap(
 /* static */ void
 nsComputedDOMStyle::RegisterPrefChangeCallbacks()
 {
   // Note that this will register callbacks for all properties with prefs, not
   // just those that are implemented on computed style objects, as it's not
   // easy to grab specific property data from ServoCSSPropList.h based on the
   // entries iterated in nsComputedDOMStylePropertyList.h.
   ComputedStyleMap* data = GetComputedStyleMap();
-#define REGISTER_CALLBACK(pref_)                                             \
-  if (pref_[0]) {                                                            \
-    Preferences::RegisterCallback(MarkComputedStyleMapDirty, pref_, data);   \
-  }
-#define CSS_PROP_LONGHAND(prop_, id_, method_, flags_, pref_) \
-  REGISTER_CALLBACK(pref_)
-#define CSS_PROP_SHORTHAND(prop_, id_, method_, flags_, pref_) \
-  REGISTER_CALLBACK(pref_)
-#define CSS_PROP_ALIAS(prop_, aliasid_, id_, method_, pref_) \
-  REGISTER_CALLBACK(pref_)
-#include "mozilla/ServoCSSPropList.h"
-#undef CSS_PROP_ALIAS
-#undef CSS_PROP_SHORTHAND
-#undef CSS_PROP_LONGHAND
-#undef REGISTER_CALLBACK
+  for (const auto* p = nsCSSProps::kPropertyPrefTable;
+       p->mPropID != eCSSProperty_UNKNOWN; p++) {
+    Preferences::RegisterCallback(MarkComputedStyleMapDirty, p->mPref, data);
+  }
 }
 
 /* static */ void
 nsComputedDOMStyle::UnregisterPrefChangeCallbacks()
 {
   ComputedStyleMap* data = GetComputedStyleMap();
-#define UNREGISTER_CALLBACK(pref_)                                             \
-  if (pref_[0]) {                                                              \
-    Preferences::UnregisterCallback(MarkComputedStyleMapDirty, pref_, data);   \
-  }
-#define CSS_PROP_LONGHAND(prop_, id_, method_, flags_, pref_) \
-  UNREGISTER_CALLBACK(pref_)
-#define CSS_PROP_SHORTHAND(prop_, id_, method_, flags_, pref_) \
-  UNREGISTER_CALLBACK(pref_)
-#define CSS_PROP_ALIAS(prop_, aliasid_, id_, method_, pref_) \
-  UNREGISTER_CALLBACK(pref_)
-#include "mozilla/ServoCSSPropList.h"
-#undef CSS_PROP_ALIAS
-#undef CSS_PROP_SHORTHAND
-#undef CSS_PROP_LONGHAND
-#undef UNREGISTER_CALLBACK
-}
+  for (const auto* p = nsCSSProps::kPropertyPrefTable;
+       p->mPropID != eCSSProperty_UNKNOWN; p++) {
+    Preferences::UnregisterCallback(MarkComputedStyleMapDirty, p->mPref, data);
+  }
+}