Bug 774169, patch 3: Treat -moz-transform as a shorthand rather than an alias so the parsing function can know whether it is parsing a prefixed transform. r=bzbarsky

This commit is contained in:
L. David Baron 2012-09-18 11:37:14 -07:00
parent 5a6fcd294a
commit 1359267ffc
7 changed files with 62 additions and 4 deletions

View File

@ -818,6 +818,15 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
break;
}
#endif // MOZ_FLEXBOX
case eCSSProperty__moz_transform: {
// shorthands that are just aliases with different parsing rules
const nsCSSProperty* subprops =
nsCSSProps::SubpropertyEntryFor(aProperty);
NS_ABORT_IF_FALSE(subprops[1] == eCSSProperty_UNKNOWN,
"must have exactly one subproperty");
AppendValueToString(subprops[0], aValue);
break;
}
default:
NS_ABORT_IF_FALSE(false, "no other shorthands");
break;

View File

@ -509,7 +509,7 @@ protected:
bool ParseListStyle();
bool ParseMargin();
bool ParseMarks(nsCSSValue& aValue);
bool ParseTransform();
bool ParseTransform(bool aIsPrefixed);
bool ParseOutline();
bool ParseOverflow();
bool ParsePadding();
@ -6109,7 +6109,9 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSProperty aPropID)
case eCSSProperty_text_decoration:
return ParseTextDecoration();
case eCSSProperty_transform:
return ParseTransform();
return ParseTransform(false);
case eCSSProperty__moz_transform:
return ParseTransform(true);
case eCSSProperty_transform_origin:
return ParseTransformOrigin(false);
case eCSSProperty_perspective_origin:
@ -8575,7 +8577,7 @@ CSSParserImpl::ParseSingleTransform(nsCSSValue& aValue, bool& aIs3D)
/* Parses a transform property list by continuously reading in properties
* and constructing a matrix from it.
*/
bool CSSParserImpl::ParseTransform()
bool CSSParserImpl::ParseTransform(bool aIsPrefixed)
{
nsCSSValue value;
if (ParseVariant(value, VARIANT_INHERIT | VARIANT_NONE, nullptr)) {

View File

@ -35,7 +35,6 @@
******/
CSS_PROP_ALIAS(-moz-transform, transform, MozTransform, "")
CSS_PROP_ALIAS(-moz-transform-origin, transform_origin, MozTransformOrigin, "")
CSS_PROP_ALIAS(-moz-perspective-origin, perspective_origin, MozPerspectiveOrigin, "")
CSS_PROP_ALIAS(-moz-perspective, perspective, MozPerspective, "")

View File

@ -3358,6 +3358,16 @@ CSS_PROP_SVGRESET(
offsetof(nsStyleSVGReset, mVectorEffect),
eStyleAnimType_EnumU8)
// The shorthands below are essentially aliases, but they require different
// parsing rules, and are therefore implemented as shorthands.
CSS_PROP_SHORTHAND(
-moz-transform,
_moz_transform,
MozTransform,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_IS_ALIAS,
"")
#ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL
// We have a few properties that are in style structs but are not stored
// in style sheets (or nsCSS* structs). Some fields in these property

View File

@ -219,6 +219,11 @@ nsCSSProps::BuildShorthandsContainingTable()
subpropCounts[shorthand - eCSSProperty_COUNT_no_shorthands];
subpropCountsEntry.property = shorthand;
subpropCountsEntry.count = 0;
if (nsCSSProps::PropHasFlags(shorthand, CSS_PROPERTY_IS_ALIAS)) {
// Don't put shorthands that are acting as aliases in the
// shorthands-containing lists.
continue;
}
for (const nsCSSProperty* subprops = SubpropertyEntryFor(shorthand);
*subprops != eCSSProperty_UNKNOWN;
++subprops) {
@ -279,6 +284,12 @@ nsCSSProps::BuildShorthandsContainingTable()
shorthandAndCount->count,
nsCSSProps::GetStringValue(shorthandAndCount->property).get());
#endif
if (nsCSSProps::PropHasFlags(shorthandAndCount->property,
CSS_PROPERTY_IS_ALIAS)) {
// Don't put shorthands that are acting as aliases in the
// shorthands-containing lists.
continue;
}
for (const nsCSSProperty* subprops =
SubpropertyEntryFor(shorthandAndCount->property);
*subprops != eCSSProperty_UNKNOWN;
@ -307,6 +318,11 @@ nsCSSProps::BuildShorthandsContainingTable()
for (nsCSSProperty shorthand = eCSSProperty_COUNT_no_shorthands;
shorthand < eCSSProperty_COUNT;
shorthand = nsCSSProperty(shorthand + 1)) {
if (nsCSSProps::PropHasFlags(shorthand, CSS_PROPERTY_IS_ALIAS)) {
// Don't put shorthands that are acting as aliases in the
// shorthands-containing lists.
continue;
}
for (const nsCSSProperty* subprops = SubpropertyEntryFor(shorthand);
*subprops != eCSSProperty_UNKNOWN;
++subprops) {
@ -2243,6 +2259,13 @@ static const nsCSSProperty gMarkerSubpropTable[] = {
eCSSProperty_UNKNOWN
};
// Subproperty tables for shorthands that are just aliases with
// different parsing rules.
static const nsCSSProperty gMozTransformSubpropTable[] = {
eCSSProperty_transform,
eCSSProperty_UNKNOWN
};
const nsCSSProperty *const
nsCSSProps::kSubpropertyTable[eCSSProperty_COUNT - eCSSProperty_COUNT_no_shorthands] = {
#define CSS_PROP_DOMPROP_PREFIXED(prop_) prop_

View File

@ -98,6 +98,9 @@ MOZ_STATIC_ASSERT((CSS_PROPERTY_PARSE_PROPERTY_MASK &
// Does this property suppor the unitless length quirk in quirks mode?
#define CSS_PROPERTY_UNITLESS_LENGTH_QUIRK (1<<16)
// Is this property (which must be a shorthand) really an alias?
#define CSS_PROPERTY_IS_ALIAS (1<<17)
/**
* Types of animatable values.
*/

View File

@ -405,6 +405,18 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName,
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName,
nsCSSProps::eEnabled);
// We don't (for now, anyway, though it may make sense to change it
// for all aliases, including those in nsCSSPropAliasList) want
// aliases to be enumerable (via GetLength and IndexedGetter), so
// handle them here rather than adding entries to
// GetQueryablePropertyMap.
if (nsCSSProps::PropHasFlags(prop, CSS_PROPERTY_IS_ALIAS)) {
const nsCSSProperty* subprops = nsCSSProps::SubpropertyEntryFor(prop);
NS_ABORT_IF_FALSE(subprops[1] == eCSSProperty_UNKNOWN,
"must have list of length 1");
prop = subprops[0];
}
const ComputedStyleMapEntry* propEntry = nullptr;
{
uint32_t length = 0;