зеркало из https://github.com/mozilla/gecko-dev.git
Bug 977757 - 2/3 - add nsCSSProps::eEnabledInChromeOrCertifiedApp bit, and use it for will-change - r=dbaron,bz
This commit is contained in:
Родитель
56cf1149be
Коммит
f9d8543c89
|
@ -45,6 +45,7 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "nsRuleData.h"
|
||||
#include "mozilla/CSSVariableValues.h"
|
||||
#include "mozilla/dom/URL.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -255,6 +256,9 @@ public:
|
|||
if (mUnsafeRulesEnabled) {
|
||||
enabledState |= nsCSSProps::eEnabledInUASheets;
|
||||
}
|
||||
if (mIsChromeOrCertifiedApp) {
|
||||
enabledState |= nsCSSProps::eEnabledInChromeOrCertifiedApp;
|
||||
}
|
||||
return nsCSSProps::LookupProperty(aProperty, enabledState);
|
||||
}
|
||||
|
||||
|
@ -918,6 +922,12 @@ protected:
|
|||
// 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;
|
||||
|
||||
|
@ -1012,6 +1022,7 @@ CSSParserImpl::CSSParserImpl()
|
|||
mHashlessColorQuirk(false),
|
||||
mUnitlessLengthQuirk(false),
|
||||
mUnsafeRulesEnabled(false),
|
||||
mIsChromeOrCertifiedApp(false),
|
||||
mViewportUnitsEnabled(true),
|
||||
mHTMLMediaMode(false),
|
||||
mParsingCompoundProperty(false),
|
||||
|
@ -1152,6 +1163,9 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
|
|||
}
|
||||
|
||||
mUnsafeRulesEnabled = aAllowUnsafeRules;
|
||||
mIsChromeOrCertifiedApp =
|
||||
dom::IsChromeURI(aSheetURI) ||
|
||||
aSheetPrincipal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED;
|
||||
|
||||
nsCSSToken* tk = &mToken;
|
||||
for (;;) {
|
||||
|
@ -1175,6 +1189,7 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
|
|||
ReleaseScanner();
|
||||
|
||||
mUnsafeRulesEnabled = false;
|
||||
mIsChromeOrCertifiedApp = false;
|
||||
|
||||
// XXX check for low level errors
|
||||
return NS_OK;
|
||||
|
|
|
@ -3907,7 +3907,8 @@ CSS_PROP_DISPLAY(
|
|||
will_change,
|
||||
WillChange,
|
||||
CSS_PROPERTY_PARSE_FUNCTION |
|
||||
CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
|
||||
CSS_PROPERTY_VALUE_LIST_USES_COMMAS |
|
||||
CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP,
|
||||
"layout.css.will-change.enabled",
|
||||
0,
|
||||
nullptr,
|
||||
|
|
|
@ -395,7 +395,7 @@ nsCSSProps::LookupProperty(const nsACString& aProperty,
|
|||
}
|
||||
MOZ_ASSERT(eCSSAliasCount != 0,
|
||||
"'res' must be an alias at this point so we better have some!");
|
||||
// We intentionally don't support eEnabledInUASheets
|
||||
// We intentionally don't support eEnabledInUASheets or eEnabledInChromeOrCertifiedApp
|
||||
// for aliases yet because it's unlikely there will be a need for it.
|
||||
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
|
||||
res = gAliases[res - eCSSProperty_COUNT];
|
||||
|
|
|
@ -201,6 +201,14 @@ static_assert((CSS_PROPERTY_PARSE_PROPERTY_MASK &
|
|||
// 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)
|
||||
|
||||
/**
|
||||
* Types of animatable values.
|
||||
*/
|
||||
|
@ -264,6 +272,8 @@ public:
|
|||
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
|
||||
|
@ -467,6 +477,11 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
if ((aEnabled & eEnabledInChromeOrCertifiedApp) &&
|
||||
PropHasFlags(aProperty, CSS_PROPERTY_ALWAYS_ENABLED_IN_CHROME_OR_CERTIFIED_APP))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче