backout of rev 45253e02bde3, fd02f1217e4c, 75217485ce5a b=981804

This commit is contained in:
Peter Chang 2014-03-12 15:16:20 +08:00
parent 3e3f551cea
commit 0feb380b0d
20 changed files with 54 additions and 186 deletions

View File

@ -1205,7 +1205,7 @@ MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName,
// Get the nsCSSProperty ID for our mapped attribute.
nsCSSProperty propertyID =
nsCSSProps::LookupProperty(nsDependentAtomString(aMappedAttrName),
nsCSSProps::eEnabledForAllContent);
nsCSSProps::eEnabled);
if (propertyID != eCSSProperty_UNKNOWN) {
bool changed; // outparam for ParseProperty. (ignored)
mParser.ParseProperty(propertyID, aMappedAttrValue, mDocURI, mBaseURI,
@ -2539,7 +2539,7 @@ nsSVGElement::GetAnimatedAttr(int32_t aNamespaceID, nsIAtom* aName)
if (IsAttributeMapped(aName)) {
nsCSSProperty prop =
nsCSSProps::LookupProperty(nsDependentAtomString(aName),
nsCSSProps::eEnabledForAllContent);
nsCSSProps::eEnabled);
// Check IsPropertyAnimatable to avoid attributes that...
// - map to explicitly unanimatable properties (e.g. 'direction')
// - map to unsupported attributes (e.g. 'glyph-orientation-horizontal')

View File

@ -2667,8 +2667,8 @@ nsDOMWindowUtils::ComputeAnimationDistance(nsIDOMElement* aElement,
// Convert direction-dependent properties as appropriate, e.g.,
// border-left to border-left-value.
nsCSSProperty property =
nsCSSProps::LookupProperty(aProperty, nsCSSProps::eIgnoreEnabledState);
nsCSSProperty property = nsCSSProps::LookupProperty(aProperty,
nsCSSProps::eAny);
if (property != eCSSProperty_UNKNOWN && nsCSSProps::IsShorthand(property)) {
nsCSSProperty subprop0 = *nsCSSProps::SubpropertyEntryFor(property);
if (nsCSSProps::PropHasFlags(subprop0, CSS_PROPERTY_REPORT_OTHER_NAME) &&

View File

@ -7,18 +7,9 @@ import string
propList = eval(sys.stdin.read())
props = ""
for [prop, id, flags, pref] in propList:
for [prop, 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:]

View File

@ -794,7 +794,7 @@ nsSMILAnimationController::GetTargetIdentifierForAnimation(
} else {
nsCSSProperty prop =
nsCSSProps::LookupProperty(nsDependentAtomString(attributeName),
nsCSSProps::eEnabledForAllContent);
nsCSSProps::eEnabled);
isCSS = nsSMILCSSProperty::IsPropertyAnimatable(prop);
}
}

View File

@ -125,7 +125,7 @@ nsSMILCompositor::CreateSMILAttr()
if (mKey.mIsCSS) {
nsCSSProperty propId =
nsCSSProps::LookupProperty(nsDependentAtomString(mKey.mAttributeName),
nsCSSProps::eEnabledForAllContent);
nsCSSProps::eEnabled);
if (nsSMILCSSProperty::IsPropertyAnimatable(propId)) {
return new nsSMILCSSProperty(propId, mKey.mElement.get());
}

View File

@ -5,16 +5,13 @@
[
#define PROP_STRINGIFY_INTERNAL(X) #X
#define PROP_STRINGIFY(X) PROP_STRINGIFY_INTERNAL(X)
#define DO_PROP(method, id, flags, pref) \
[ #method, #id, PROP_STRINGIFY(flags), pref ],
#define DO_PROP(method, pref) \
[ #method, pref ],
#define CSS_PROP(name, id, method, flags, pref, parsevariant, kwtable, \
stylestruct, stylestructofset, animtype) \
DO_PROP(method, id, flags, pref)
DO_PROP(method, pref)
#define CSS_PROP_SHORTHAND(name, id, method, flags, pref) \
DO_PROP(method, id, flags, pref)
DO_PROP(method, pref)
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
@ -26,14 +23,12 @@
#undef CSS_PROP
#define CSS_PROP_ALIAS(name, id, method, pref) \
DO_PROP(method, id, 0, pref)
DO_PROP(method, pref)
#include "nsCSSPropAliasList.h"
#undef CSS_PROP_ALIAS
#undef DO_PROP
#undef PROP_STRINGIFY
#undef PROP_STRINGIFY_INTERNAL
]

View File

@ -565,7 +565,7 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
}
nsCSSProperty prop =
nsCSSProps::LookupProperty(nsDependentAtomString(aProperty),
nsCSSProps::eEnabledForAllContent);
nsCSSProps::eEnabled);
MOZ_ASSERT(prop != eCSSProperty_UNKNOWN);
rule->GetDeclaration()->GetValue(prop, aValue);

View File

@ -227,7 +227,7 @@ inCSSValueSearch::AddPropertyCriteria(const char16_t *aPropName)
{
nsCSSProperty prop =
nsCSSProps::LookupProperty(nsDependentString(aPropName),
nsCSSProps::eIgnoreEnabledState);
nsCSSProps::eAny);
mProperties[mPropertyCount] = prop;
mPropertyCount++;
return NS_OK;

View File

@ -383,8 +383,8 @@ inDOMUtils::SelectorMatchesElement(nsIDOMElement* aElement,
NS_IMETHODIMP
inDOMUtils::IsInheritedProperty(const nsAString &aPropertyName, bool *_retval)
{
nsCSSProperty prop =
nsCSSProps::LookupProperty(aPropertyName, nsCSSProps::eIgnoreEnabledState);
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eAny);
if (prop == eCSSProperty_UNKNOWN) {
*_retval = false;
return NS_OK;
@ -565,7 +565,7 @@ inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty,
char16_t*** aValues)
{
nsCSSProperty propertyID = nsCSSProps::LookupProperty(aProperty,
nsCSSProps::eEnabledForAllContent);
nsCSSProps::eEnabled);
if (propertyID == eCSSProperty_UNKNOWN) {
return NS_ERROR_FAILURE;
}

View File

@ -959,8 +959,7 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
bool
Declaration::GetValueIsImportant(const nsAString& aProperty) const
{
nsCSSProperty propID =
nsCSSProps::LookupProperty(aProperty, nsCSSProps::eIgnoreEnabledState);
nsCSSProperty propID = nsCSSProps::LookupProperty(aProperty, nsCSSProps::eAny);
if (propID == eCSSProperty_UNKNOWN) {
return false;
}

View File

@ -45,7 +45,6 @@
#include "mozilla/Preferences.h"
#include "nsRuleData.h"
#include "mozilla/CSSVariableValues.h"
#include "mozilla/dom/URL.h"
using namespace mozilla;
@ -249,17 +248,9 @@ public:
uint32_t aLineOffset);
nsCSSProperty LookupEnabledProperty(const nsAString& aProperty) {
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 nsCSSProps::LookupProperty(aProperty, enabledState);
return nsCSSProps::LookupProperty(aProperty, mUnsafeRulesEnabled ?
nsCSSProps::eEnabledInUASheets :
nsCSSProps::eEnabled);
}
protected:
@ -922,12 +913,6 @@ 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;
@ -1022,7 +1007,6 @@ CSSParserImpl::CSSParserImpl()
mHashlessColorQuirk(false),
mUnitlessLengthQuirk(false),
mUnsafeRulesEnabled(false),
mIsChromeOrCertifiedApp(false),
mViewportUnitsEnabled(true),
mHTMLMediaMode(false),
mParsingCompoundProperty(false),
@ -1163,9 +1147,6 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
}
mUnsafeRulesEnabled = aAllowUnsafeRules;
mIsChromeOrCertifiedApp =
dom::IsChromeURI(aSheetURI) ||
aSheetPrincipal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED;
nsCSSToken* tk = &mToken;
for (;;) {
@ -1189,7 +1170,6 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
ReleaseScanner();
mUnsafeRulesEnabled = false;
mIsChromeOrCertifiedApp = false;
// XXX check for low level errors
return NS_OK;

View File

@ -3907,8 +3907,7 @@ CSS_PROP_DISPLAY(
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,
"layout.css.will-change.enabled",
0,
nullptr,

View File

@ -395,13 +395,13 @@ 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 or eEnabledInChromeOrCertifiedApp
// for aliases yet because it's unlikely there will be a need for it.
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
// We intentionally don't support eEnabledInUASheets for aliases yet
// because it's unlikely there will be a need for it.
if (IsEnabled(res) || aEnabled == eAny) {
res = gAliases[res - eCSSProperty_COUNT];
NS_ABORT_IF_FALSE(0 <= res && res < eCSSProperty_COUNT,
"aliases must not point to other aliases");
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
if (IsEnabled(res) || aEnabled == eAny) {
return res;
}
}
@ -431,11 +431,11 @@ nsCSSProps::LookupProperty(const nsAString& aProperty, EnabledState aEnabled)
"'res' must be an alias at this point so we better have some!");
// We intentionally don't support eEnabledInUASheets for aliases yet
// because it's unlikely there will be a need for it.
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
if (IsEnabled(res) || aEnabled == eAny) {
res = gAliases[res - eCSSProperty_COUNT];
NS_ABORT_IF_FALSE(0 <= res && res < eCSSProperty_COUNT,
"aliases must not point to other aliases");
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
if (IsEnabled(res) || aEnabled == eAny) {
return res;
}
}

View File

@ -201,14 +201,6 @@ 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.
*/
@ -266,21 +258,12 @@ public:
static void AddRefTable(void);
static void ReleaseTable(void);
// Given a property string, return the enum value
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
eEnabled,
eEnabledInUASheets,
eAny
};
// Looks up the property with name aProperty and returns its corresponding
// nsCSSProperty value. If aProperty is the name of a custom property,
// then eCSSPropertyExtra_variable will be returned.
@ -464,25 +447,11 @@ public:
return gPropertyEnabled[aProperty];
}
static bool IsEnabled(nsCSSProperty aProperty, EnabledState aEnabled)
{
if (IsEnabled(aProperty)) {
return true;
}
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;
static bool IsEnabled(nsCSSProperty aProperty, EnabledState aEnabled) {
return IsEnabled(aProperty) ||
(aEnabled == eEnabledInUASheets &&
PropHasFlags(aProperty, CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS)) ||
aEnabled == eAny;
}
public:
@ -640,28 +609,4 @@ public:
static const KTableValue kHyphensKTable[];
};
inline nsCSSProps::EnabledState operator|(nsCSSProps::EnabledState a,
nsCSSProps::EnabledState b)
{
return nsCSSProps::EnabledState(int(a) | int(b));
}
inline nsCSSProps::EnabledState operator&(nsCSSProps::EnabledState a,
nsCSSProps::EnabledState b)
{
return nsCSSProps::EnabledState(int(a) & int(b));
}
inline nsCSSProps::EnabledState& operator|=(nsCSSProps::EnabledState& a,
nsCSSProps::EnabledState b)
{
return a = a | b;
}
inline nsCSSProps::EnabledState& operator&=(nsCSSProps::EnabledState& a,
nsCSSProps::EnabledState b)
{
return a = a & b;
}
#endif /* nsCSSProps_h___ */

View File

@ -718,7 +718,7 @@ already_AddRefed<CSSValue>
nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorResult& aRv)
{
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabledForAllContent);
nsCSSProps::eEnabled);
bool needsLayoutFlush;
nsComputedStyleMap::Entry::ComputeMethod getter;

View File

@ -16,8 +16,6 @@
#include "nsCOMPtr.h"
#include "mozAutoDocUpdate.h"
#include "nsIURI.h"
#include "mozilla/dom/BindingUtils.h"
#include "nsContentUtils.h"
using namespace mozilla;
@ -171,9 +169,8 @@ NS_IMETHODIMP
nsDOMCSSDeclaration::GetPropertyValue(const nsAString& aPropertyName,
nsAString& aReturn)
{
const nsCSSProperty propID =
nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabledForAllContent);
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabled);
if (propID == eCSSProperty_UNKNOWN) {
aReturn.Truncate();
return NS_OK;
@ -191,9 +188,8 @@ NS_IMETHODIMP
nsDOMCSSDeclaration::GetAuthoredPropertyValue(const nsAString& aPropertyName,
nsAString& aReturn)
{
const nsCSSProperty propID =
nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabledForAllContent);
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabled);
if (propID == eCSSProperty_UNKNOWN) {
aReturn.Truncate();
return NS_OK;
@ -233,9 +229,8 @@ nsDOMCSSDeclaration::SetProperty(const nsAString& aPropertyName,
const nsAString& aPriority)
{
// In the common (and fast) cases we can use the property id
nsCSSProperty propID =
nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabledForAllContent);
nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabled);
if (propID == eCSSProperty_UNKNOWN) {
return NS_OK;
}
@ -270,9 +265,8 @@ NS_IMETHODIMP
nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName,
nsAString& aReturn)
{
const nsCSSProperty propID =
nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabledForAllContent);
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabled);
if (propID == eCSSProperty_UNKNOWN) {
aReturn.Truncate();
return NS_OK;
@ -431,24 +425,3 @@ nsDOMCSSDeclaration::RemoveCustomProperty(const nsAString& aPropertyName)
decl->RemoveVariableDeclaration(Substring(aPropertyName, VAR_PREFIX_LENGTH));
return SetCSSDeclaration(decl);
}
bool IsCSSPropertyExposedToJS(nsCSSProperty aProperty, JSContext* cx, JSObject* obj)
{
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);
}

View File

@ -15,8 +15,6 @@
class nsIPrincipal;
class nsIDocument;
struct JSContext;
class JSObject;
namespace mozilla {
namespace css {
@ -154,12 +152,4 @@ protected:
}
};
bool IsCSSPropertyExposedToJS(nsCSSProperty aProperty, JSContext* cx, JSObject* obj);
template <nsCSSProperty Property>
MOZ_ALWAYS_INLINE bool IsCSSPropertyExposedToJS(JSContext* cx, JSObject* obj)
{
return IsCSSPropertyExposedToJS(Property, cx, obj);
}
#endif // nsDOMCSSDeclaration_h___

View File

@ -4859,9 +4859,8 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
if (val.GetUnit() == eCSSUnit_Ident) {
nsDependentString
propertyStr(property.list->mValue.GetStringBufferValue());
nsCSSProperty prop =
nsCSSProps::LookupProperty(propertyStr,
nsCSSProps::eEnabledForAllContent);
nsCSSProperty prop = nsCSSProps::LookupProperty(propertyStr,
nsCSSProps::eEnabled);
if (prop == eCSSProperty_UNKNOWN) {
transition->SetUnknownProperty(propertyStr);
} else {
@ -5504,8 +5503,7 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
}
nsCSSProperty prop =
nsCSSProps::LookupProperty(buffer,
nsCSSProps::eEnabledForAllContent);
nsCSSProps::LookupProperty(buffer, nsCSSProps::eEnabled);
if (prop != eCSSProperty_UNKNOWN &&
nsCSSProps::PropHasFlags(prop,
CSS_PROPERTY_CREATES_STACKING_CONTEXT))

View File

@ -2303,7 +2303,7 @@ void nsTransition::SetInitialValues()
void nsTransition::SetUnknownProperty(const nsAString& aUnknownProperty)
{
NS_ASSERTION(nsCSSProps::LookupProperty(aUnknownProperty,
nsCSSProps::eEnabledForAllContent) ==
nsCSSProps::eEnabled) ==
eCSSProperty_UNKNOWN,
"should be unknown property");
mProperty = eCSSProperty_UNKNOWN;

View File

@ -40,8 +40,7 @@ TestProps()
PL_strcpy(tagName, *et);
index = nsCSSProperty(int32_t(index) + 1);
id = nsCSSProps::LookupProperty(nsCString(tagName),
nsCSSProps::eIgnoreEnabledState);
id = nsCSSProps::LookupProperty(nsCString(tagName), nsCSSProps::eAny);
if (id == eCSSProperty_UNKNOWN) {
printf("bug: can't find '%s'\n", tagName);
success = false;
@ -56,7 +55,7 @@ TestProps()
tagName[0] = tagName[0] - 32;
}
id = nsCSSProps::LookupProperty(NS_ConvertASCIItoUTF16(tagName),
nsCSSProps::eIgnoreEnabledState);
nsCSSProps::eAny);
if (id < 0) {
printf("bug: can't find '%s'\n", tagName);
success = false;
@ -71,8 +70,7 @@ TestProps()
// Now make sure we don't find some garbage
for (int i = 0; i < (int) (sizeof(kJunkNames) / sizeof(const char*)); i++) {
const char* const tag = kJunkNames[i];
id = nsCSSProps::LookupProperty(nsAutoCString(tag),
nsCSSProps::eIgnoreEnabledState);
id = nsCSSProps::LookupProperty(nsAutoCString(tag), nsCSSProps::eAny);
if (id >= 0) {
printf("bug: found '%s'\n", tag ? tag : "(null)");
success = false;