Bug 1202908 part 2 - Remove CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Fri, 11 Sep 2015 16:00:10 +1000
changeset 294503 9bc38465a23b9806131730f208afedc669287a73
parent 294502 6bc0228c2d3d4b0520b3d8b2dbc1c128446bf3c4
child 294504 f2d15b3f34ba558d9428cdfc29a65359c6be87ee
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1202908
milestone43.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 1202908 part 2 - Remove CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP. r=dbaron
dom/bindings/GenerateCSS2PropertiesWebIDL.py
layout/style/nsCSSParser.cpp
layout/style/nsCSSPropList.h
layout/style/nsCSSProps.cpp
layout/style/nsCSSProps.h
layout/style/nsDOMCSSDeclaration.cpp
--- a/dom/bindings/GenerateCSS2PropertiesWebIDL.py
+++ b/dom/bindings/GenerateCSS2PropertiesWebIDL.py
@@ -4,26 +4,17 @@
 
 import sys
 import string
 
 propList = eval(sys.stdin.read())
 props = ""
 for [name, prop, id, flags, pref] in propList:
     extendedAttrs = ["Throws", "TreatNullAs=EmptyString"]
-    # To limit the overhead of Func= annotations, we only generate them when
-    # necessary, which is when the
-    # CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP flag is set.
-    # Otherwise, we try to get by with just a Pref= annotation or no annotation
-    # at all.
-    if "CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP" in flags:
-        extendedAttrs.append('Func="IsCSSPropertyExposedToJS<eCSSProperty_%s>"' % id)
-    # The following is an 'elif' because it is the responsibility of
-    # IsCSSPropertyExposedToJS to handle the pref if there is one.
-    elif pref is not "":
+    if pref is not "":
         extendedAttrs.append('Pref="%s"' % pref)
     if not prop.startswith("Moz"):
         prop = prop[0].lower() + prop[1:]
     # Unfortunately, even some of the getters here are fallible
     # (e.g. on nsComputedDOMStyle).
     props += "  [%s] attribute DOMString %s;\n" % (", ".join(extendedAttrs),
                                                    prop)
     # Per spec, what's actually supposed to happen here is that we're supposed
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -316,19 +316,16 @@ public:
   nsCSSProps::EnabledState PropertyEnabledState() const {
     static_assert(nsCSSProps::eEnabledForAllContent == 0,
                   "nsCSSProps::eEnabledForAllContent should be zero for "
                   "this bitfield to work");
     nsCSSProps::EnabledState enabledState = nsCSSProps::eEnabledForAllContent;
     if (mUnsafeRulesEnabled) {
       enabledState |= nsCSSProps::eEnabledInUASheets;
     }
-    if (mIsChromeOrCertifiedApp) {
-      enabledState |= nsCSSProps::eEnabledInChromeOrCertifiedApp;
-    }
     return enabledState;
   }
 
   nsCSSProperty LookupEnabledProperty(const nsAString& aProperty) {
     return nsCSSProps::LookupProperty(aProperty, PropertyEnabledState());
   }
 
 protected:
@@ -1202,22 +1199,16 @@ protected:
   bool mHashlessColorQuirk : 1;
 
   // True when the unitless length quirk applies.
   bool mUnitlessLengthQuirk : 1;
 
   // True if unsafe rules should be allowed
   bool mUnsafeRulesEnabled : 1;
 
-  // True if we are in parsing rules for Chrome or Certified App content,
-  // in which case CSS properties with the
-  // CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP
-  // flag should be allowed.
-  bool mIsChromeOrCertifiedApp : 1;
-
   // True if viewport units should be allowed.
   bool mViewportUnitsEnabled : 1;
 
   // True for parsing media lists for HTML attributes, where we have to
   // ignore CSS comments.
   bool mHTMLMediaMode : 1;
 
   // This flag is set when parsing a non-box shorthand; it's used to not apply
@@ -1330,17 +1321,16 @@ CSSParserImpl::CSSParserImpl()
     mChildLoader(nullptr),
     mSection(eCSSSection_Charset),
     mNameSpaceMap(nullptr),
     mHavePushBack(false),
     mNavQuirkMode(false),
     mHashlessColorQuirk(false),
     mUnitlessLengthQuirk(false),
     mUnsafeRulesEnabled(false),
-    mIsChromeOrCertifiedApp(false),
     mViewportUnitsEnabled(true),
     mHTMLMediaMode(false),
     mParsingCompoundProperty(false),
     mInSupportsCondition(false),
     mInFailingSupportsRule(false),
     mSuppressErrors(false),
     mSheetPrincipalRequired(true),
     mWebkitBoxUnprefixState(eNotParsingDecls),
@@ -1482,19 +1472,16 @@ CSSParserImpl::ParseSheet(const nsAStrin
       }
     }
   }
   else {
     mSection = eCSSSection_Charset; // sheet is empty, any rules are fair
   }
 
   mUnsafeRulesEnabled = aAllowUnsafeRules;
-  mIsChromeOrCertifiedApp =
-    dom::IsChromeURI(aSheetURI) ||
-    aSheetPrincipal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED;
 
   nsCSSToken* tk = &mToken;
   for (;;) {
     // Get next non-whitespace token
     if (!GetToken(true)) {
       OUTPUT_ERROR();
       break;
     }
@@ -1508,17 +1495,16 @@ CSSParserImpl::ParseSheet(const nsAStrin
     UngetToken();
     if (ParseRuleSet(AppendRuleToSheet, this)) {
       mSection = eCSSSection_General;
     }
   }
   ReleaseScanner();
 
   mUnsafeRulesEnabled = false;
-  mIsChromeOrCertifiedApp = false;
 
   // XXX check for low level errors
   return NS_OK;
 }
 
 /**
  * Determines whether the identifier contained in the given string is a
  * vendor-specific identifier, as described in CSS 2.1 section 4.1.2.1.
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -4146,18 +4146,17 @@ CSS_PROP_SVGRESET(
     offsetof(nsStyleSVGReset, mVectorEffect),
     eStyleAnimType_EnumU8)
 
 CSS_PROP_DISPLAY(
     will-change,
     will_change,
     WillChange,
     CSS_PROPERTY_PARSE_FUNCTION |
-        CSS_PROPERTY_VALUE_LIST_USES_COMMAS |
-        CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP,
+        CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
     "",
     0,
     nullptr,
     CSS_PROP_NO_OFFSET,
     eStyleAnimType_None)
 
 // The shorthands below are essentially aliases, but they require different
 // parsing rules, and are therefore implemented as shorthands.
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -194,23 +194,21 @@ nsCSSProps::AddRefTable(void)
       #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.
+      // Assert that if CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS 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
+        CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS
       };
       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;
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -202,23 +202,17 @@ static_assert((CSS_PROPERTY_PARSE_PROPER
 
 // This property is always enabled in UA sheets.  This is meant to be used
 // together with a pref that enables the property for non-UA sheets.
 // Note that if such a property has an alias, then any use of that alias
 // in an UA sheet will still be ignored unless the pref is enabled.
 // In other words, this bit has no effect on the use of aliases.
 #define CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS  (1<<22)
 
-// This property is always enabled in chrome and in certified apps. This is
-// meant to be used together with a pref that enables the property for
-// non-privileged content. Note that if such a property has an alias, then any
-// use of that alias in privileged content will still be ignored unless the
-// pref is enabled. In other words, this bit has no effect on the use of
-// aliases.
-#define CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP (1<<23)
+// XXX (1<<23) will shortly be reused in bug 1069192.
 
 // This property's unitless values are pixels.
 #define CSS_PROPERTY_NUMBERS_ARE_PIXELS           (1<<24)
 
 // This property is a logical property for one of the two block axis
 // sides (such as margin-block-start or margin-block-end).  Must only be
 // set if CSS_PROPERTY_LOGICAL is set.  When not set, the logical
 // property is for one of the two inline axis sides (such as
@@ -294,18 +288,16 @@ public:
   static void ReleaseTable(void);
 
   enum EnabledState {
     // The default EnabledState: only enable what's enabled for all content,
     // given the current values of preferences.
     eEnabledForAllContent = 0,
     // Enable a property in UA sheets.
     eEnabledInUASheets    = 0x01,
-    // Enable a property in privileged content, i.e. chrome or Certified Apps
-    eEnabledInChromeOrCertifiedApp = 0x02,
     // Special value to unconditionally enable a property. This implies all the
     // bits above, but is strictly more than just their OR-ed union.
     // This just skips any test so a property will be enabled even if it would
     // have been disabled with all the bits above set.
     eIgnoreEnabledState   = 0xff
   };
 
   // Looks up the property with name aProperty and returns its corresponding
@@ -539,21 +531,16 @@ public:
     if (aEnabled == eIgnoreEnabledState) {
       return true;
     }
     if ((aEnabled & eEnabledInUASheets) &&
         PropHasFlags(aProperty, CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS))
     {
       return true;
     }
-    if ((aEnabled & eEnabledInChromeOrCertifiedApp) &&
-        PropHasFlags(aProperty, CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP))
-    {
-      return true;
-    }
     return false;
   }
 
 public:
 
 // Storing the enabledstate_ value in an nsCSSProperty variable is a small hack
 // to avoid needing a separate variable declaration for its real type
 // (nsCSSProps::EnabledState), which would then require using a block and
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -430,26 +430,13 @@ nsDOMCSSDeclaration::RemoveCustomPropert
   decl = decl->EnsureMutable();
   decl->RemoveVariableDeclaration(Substring(aPropertyName,
                                             CSS_CUSTOM_NAME_PREFIX_LENGTH));
   return SetCSSDeclaration(decl);
 }
 
 bool IsCSSPropertyExposedToJS(nsCSSProperty aProperty, JSContext* cx, JSObject* obj)
 {
+  MOZ_ASSERT_UNREACHABLE("This is currently not used anywhere, "
+                         "but should be reused soon in bug 1069192");
   nsCSSProps::EnabledState enabledState = nsCSSProps::eEnabledForAllContent;
-
-  // Optimization: we skip checking properties of the JSContext
-  // in the majority case where the property does not have the
-  // CSS_PROPERTY_ALWAYS_ENABLED_IN_PRIVILEGED_CONTENT flag.
-  bool isEnabledInChromeOrCertifiedApp
-    = nsCSSProps::PropHasFlags(aProperty,
-                               CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP);
-
-  if (isEnabledInChromeOrCertifiedApp) {
-    if (dom::IsInCertifiedApp(cx, obj) ||
-        nsContentUtils::ThreadsafeIsCallerChrome())
-    {
-      enabledState |= nsCSSProps::eEnabledInChromeOrCertifiedApp;
-    }
-  }
   return nsCSSProps::IsEnabled(aProperty, enabledState);
 }