Merge m-c to fx-team

This commit is contained in:
Wes Kocher 2014-03-12 19:01:29 -07:00
commit 926e5adef5
21 changed files with 189 additions and 55 deletions

View File

@ -3,6 +3,8 @@ support-files = head.js
[browser_bug400731.js]
[browser_bug415846.js]
skip-if = os == "mac"
skip-if = true
# Disabled because it seems to now touch network resources
# skip-if = os == "mac"
# Disabled on Mac because of its bizarre special-and-unique
# snowflake of a help menu.

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::eEnabled);
nsCSSProps::eEnabledForAllContent);
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::eEnabled);
nsCSSProps::eEnabledForAllContent);
// 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::eAny);
nsCSSProperty property =
nsCSSProps::LookupProperty(aProperty, nsCSSProps::eIgnoreEnabledState);
if (property != eCSSProperty_UNKNOWN && nsCSSProps::IsShorthand(property)) {
nsCSSProperty subprop0 = *nsCSSProps::SubpropertyEntryFor(property);
if (nsCSSProps::PropHasFlags(subprop0, CSS_PROPERTY_REPORT_OTHER_NAME) &&

View File

@ -7,9 +7,18 @@ import string
propList = eval(sys.stdin.read())
props = ""
for [prop, pref] in propList:
for [prop, id, flags, pref] in propList:
extendedAttrs = ["Throws", "TreatNullAs=EmptyString"]
if pref is not "":
# 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 "":
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::eEnabled);
nsCSSProps::eEnabledForAllContent);
isCSS = nsSMILCSSProperty::IsPropertyAnimatable(prop);
}
}

View File

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

View File

@ -5,13 +5,16 @@
[
#define DO_PROP(method, pref) \
[ #method, pref ],
#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 CSS_PROP(name, id, method, flags, pref, parsevariant, kwtable, \
stylestruct, stylestructofset, animtype) \
DO_PROP(method, pref)
DO_PROP(method, id, flags, pref)
#define CSS_PROP_SHORTHAND(name, id, method, flags, pref) \
DO_PROP(method, pref)
DO_PROP(method, id, flags, pref)
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
@ -23,12 +26,14 @@
#undef CSS_PROP
#define CSS_PROP_ALIAS(name, id, method, pref) \
DO_PROP(method, pref)
DO_PROP(method, id, 0, 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::eEnabled);
nsCSSProps::eEnabledForAllContent);
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::eAny);
nsCSSProps::eIgnoreEnabledState);
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::eAny);
nsCSSProperty prop =
nsCSSProps::LookupProperty(aPropertyName, nsCSSProps::eIgnoreEnabledState);
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::eEnabled);
nsCSSProps::eEnabledForAllContent);
if (propertyID == eCSSProperty_UNKNOWN) {
return NS_ERROR_FAILURE;
}

View File

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

View File

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

View File

@ -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,

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 for aliases yet
// because it's unlikely there will be a need for it.
if (IsEnabled(res) || aEnabled == eAny) {
// 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];
NS_ABORT_IF_FALSE(0 <= res && res < eCSSProperty_COUNT,
"aliases must not point to other aliases");
if (IsEnabled(res) || aEnabled == eAny) {
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
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 == eAny) {
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
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 == eAny) {
if (IsEnabled(res) || aEnabled == eIgnoreEnabledState) {
return res;
}
}

View File

@ -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.
*/
@ -258,12 +266,21 @@ public:
static void AddRefTable(void);
static void ReleaseTable(void);
// Given a property string, return the enum value
enum EnabledState {
eEnabled,
eEnabledInUASheets,
eAny
// 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
// nsCSSProperty value. If aProperty is the name of a custom property,
// then eCSSPropertyExtra_variable will be returned.
@ -447,11 +464,25 @@ public:
return gPropertyEnabled[aProperty];
}
static bool IsEnabled(nsCSSProperty aProperty, EnabledState aEnabled) {
return IsEnabled(aProperty) ||
(aEnabled == eEnabledInUASheets &&
PropHasFlags(aProperty, CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS)) ||
aEnabled == eAny;
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;
}
public:
@ -609,4 +640,28 @@ 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::eEnabled);
nsCSSProps::eEnabledForAllContent);
bool needsLayoutFlush;
nsComputedStyleMap::Entry::ComputeMethod getter;

View File

@ -16,6 +16,8 @@
#include "nsCOMPtr.h"
#include "mozAutoDocUpdate.h"
#include "nsIURI.h"
#include "mozilla/dom/BindingUtils.h"
#include "nsContentUtils.h"
using namespace mozilla;
@ -169,8 +171,9 @@ NS_IMETHODIMP
nsDOMCSSDeclaration::GetPropertyValue(const nsAString& aPropertyName,
nsAString& aReturn)
{
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabled);
const nsCSSProperty propID =
nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabledForAllContent);
if (propID == eCSSProperty_UNKNOWN) {
aReturn.Truncate();
return NS_OK;
@ -188,8 +191,9 @@ NS_IMETHODIMP
nsDOMCSSDeclaration::GetAuthoredPropertyValue(const nsAString& aPropertyName,
nsAString& aReturn)
{
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabled);
const nsCSSProperty propID =
nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabledForAllContent);
if (propID == eCSSProperty_UNKNOWN) {
aReturn.Truncate();
return NS_OK;
@ -229,8 +233,9 @@ 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::eEnabled);
nsCSSProperty propID =
nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabledForAllContent);
if (propID == eCSSProperty_UNKNOWN) {
return NS_OK;
}
@ -265,8 +270,9 @@ NS_IMETHODIMP
nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName,
nsAString& aReturn)
{
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabled);
const nsCSSProperty propID =
nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabledForAllContent);
if (propID == eCSSProperty_UNKNOWN) {
aReturn.Truncate();
return NS_OK;
@ -425,3 +431,24 @@ 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,6 +15,8 @@
class nsIPrincipal;
class nsIDocument;
struct JSContext;
class JSObject;
namespace mozilla {
namespace css {
@ -152,4 +154,12 @@ 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,8 +4859,9 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
if (val.GetUnit() == eCSSUnit_Ident) {
nsDependentString
propertyStr(property.list->mValue.GetStringBufferValue());
nsCSSProperty prop = nsCSSProps::LookupProperty(propertyStr,
nsCSSProps::eEnabled);
nsCSSProperty prop =
nsCSSProps::LookupProperty(propertyStr,
nsCSSProps::eEnabledForAllContent);
if (prop == eCSSProperty_UNKNOWN) {
transition->SetUnknownProperty(propertyStr);
} else {
@ -5503,7 +5504,8 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
}
nsCSSProperty prop =
nsCSSProps::LookupProperty(buffer, nsCSSProps::eEnabled);
nsCSSProps::LookupProperty(buffer,
nsCSSProps::eEnabledForAllContent);
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::eEnabled) ==
nsCSSProps::eEnabledForAllContent) ==
eCSSProperty_UNKNOWN,
"should be unknown property");
mProperty = eCSSProperty_UNKNOWN;

View File

@ -40,7 +40,8 @@ TestProps()
PL_strcpy(tagName, *et);
index = nsCSSProperty(int32_t(index) + 1);
id = nsCSSProps::LookupProperty(nsCString(tagName), nsCSSProps::eAny);
id = nsCSSProps::LookupProperty(nsCString(tagName),
nsCSSProps::eIgnoreEnabledState);
if (id == eCSSProperty_UNKNOWN) {
printf("bug: can't find '%s'\n", tagName);
success = false;
@ -55,7 +56,7 @@ TestProps()
tagName[0] = tagName[0] - 32;
}
id = nsCSSProps::LookupProperty(NS_ConvertASCIItoUTF16(tagName),
nsCSSProps::eAny);
nsCSSProps::eIgnoreEnabledState);
if (id < 0) {
printf("bug: can't find '%s'\n", tagName);
success = false;
@ -70,7 +71,8 @@ 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::eAny);
id = nsCSSProps::LookupProperty(nsAutoCString(tag),
nsCSSProps::eIgnoreEnabledState);
if (id >= 0) {
printf("bug: found '%s'\n", tag ? tag : "(null)");
success = false;