Bug 1121768 - Part 1: Require that shorthands with CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS or CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP have those flags on all subproperties. r=dbaron
authorCameron McCormack <cam@mcc.id.au>
Sat, 17 Jan 2015 15:55:07 +1100
changeset 224389 be159d9f6d92779bb0d4a77a26c6f79536c16de9
parent 224388 77dd16c161b11b143a56cc2d2e0700bb8706d343
child 224390 9a6692c19d67d50cded6b118d057d5362afee622
push id54202
push usercmccormack@mozilla.com
push dateSat, 17 Jan 2015 04:56:55 +0000
treeherdermozilla-inbound@cf403ce5f085 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1121768
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1121768 - Part 1: Require that shorthands with CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS or CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP have those flags on all subproperties. r=dbaron Requiring that UA style sheet-only shorthand properties only have UA style sheet-only subproperties makes it easier to deal with the subproperties outside of the CSS parser (which is where the information about whether a given property is enabled only in UA style sheets is stored). Similarly for certified app-only shorthands.
layout/style/nsCSSProps.cpp
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -183,16 +183,48 @@ nsCSSProps::AddRefTable(void)
 
       #define CSS_PROP_ALIAS(aliasname_, propid_, aliasmethod_, pref_)    \
         OBSERVE_PROP(pref_, eCSSPropertyAlias_##aliasmethod_)
       #include "nsCSSPropAliasList.h"
       #undef CSS_PROP_ALIAS
 
       #undef OBSERVE_PROP
     }
+
+#ifdef DEBUG
+    {
+      // Assert that if CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS or
+      // CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP is used on
+      // a shorthand property that all of its component longhands also
+      // has the flag.
+      static uint32_t flagsToCheck[] = {
+        CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS,
+        CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP
+      };
+      for (nsCSSProperty shorthand = eCSSProperty_COUNT_no_shorthands;
+           shorthand < eCSSProperty_COUNT;
+           shorthand = nsCSSProperty(shorthand + 1)) {
+        for (size_t i = 0; i < ArrayLength(flagsToCheck); i++) {
+          uint32_t flag = flagsToCheck[i];
+          if (!nsCSSProps::PropHasFlags(shorthand, flag)) {
+            continue;
+          }
+          for (const nsCSSProperty* p =
+                 nsCSSProps::SubpropertyEntryFor(shorthand);
+               *p != eCSSProperty_UNKNOWN;
+               ++p) {
+            MOZ_ASSERT(nsCSSProps::PropHasFlags(*p, flag),
+                       "all subproperties of a property with a "
+                       "CSS_PROPERTY_ALWAYS_ENABLED_* flag must also have "
+                       "the flag");
+          }
+        }
+      }
+    }
+#endif
   }
 }
 
 #undef  DEBUG_SHORTHANDS_CONTAINING
 
 bool
 nsCSSProps::BuildShorthandsContainingTable()
 {