From: L. David Baron Bug 837211: Off-by-default preference for testing the effect of supporting -webkit- prefixes or unprefixed properties. FIXME: Test that names are all correct FIXME: Add aliases for transition/animation events. FIXME: bz, were you aware that Webkit accepts element.style.WebkitTransform or element.style.webkitTransform (either case), but only lowercase shows up when you enumerate? dbaron: no, I was not dbaron: I knew it accepted element.style["-webkit-transform"] dbaron: that's interesting.... diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -1617,16 +1617,18 @@ CSSParserImpl::ParseAtRule(RuleAppendFun parseFunc = &CSSParserImpl::ParseFontFaceRule; newSection = eCSSSection_General; } else if (mToken.mIdent.LowerCaseEqualsLiteral("page")) { parseFunc = &CSSParserImpl::ParsePageRule; newSection = eCSSSection_General; } else if (mToken.mIdent.LowerCaseEqualsLiteral("-moz-keyframes") || + (nsCSSProps::IsEnabled(eCSSPropertyAlias_WebkitAnimation) && + mToken.mIdent.LowerCaseEqualsLiteral("-webkit-keyframes")) || mToken.mIdent.LowerCaseEqualsLiteral("keyframes")) { parseFunc = &CSSParserImpl::ParseKeyframesRule; newSection = eCSSSection_General; } else if (mToken.mIdent.LowerCaseEqualsLiteral("supports") && CSSSupportsRule::PrefEnabled()) { parseFunc = &CSSParserImpl::ParseSupportsRule; newSection = eCSSSection_General; diff --git a/layout/style/nsCSSPropAliasList.h b/layout/style/nsCSSPropAliasList.h --- a/layout/style/nsCSSPropAliasList.h +++ b/layout/style/nsCSSPropAliasList.h @@ -50,8 +50,50 @@ CSS_PROP_ALIAS(-moz-animation, animation CSS_PROP_ALIAS(-moz-animation-delay, animation_delay, MozAnimationDelay, "layout.css.prefixes.animations") CSS_PROP_ALIAS(-moz-animation-direction, animation_direction, MozAnimationDirection, "layout.css.prefixes.animations") CSS_PROP_ALIAS(-moz-animation-duration, animation_duration, MozAnimationDuration, "layout.css.prefixes.animations") CSS_PROP_ALIAS(-moz-animation-fill-mode, animation_fill_mode, MozAnimationFillMode, "layout.css.prefixes.animations") CSS_PROP_ALIAS(-moz-animation-iteration-count, animation_iteration_count, MozAnimationIterationCount, "layout.css.prefixes.animations") CSS_PROP_ALIAS(-moz-animation-name, animation_name, MozAnimationName, "layout.css.prefixes.animations") CSS_PROP_ALIAS(-moz-animation-play-state, animation_play_state, MozAnimationPlayState, "layout.css.prefixes.animations") CSS_PROP_ALIAS(-moz-animation-timing-function, animation_timing_function, MozAnimationTimingFunction, "layout.css.prefixes.animations") + +// -webkit- prefixes +CSS_PROP_ALIAS(-webkit-animation, animation, WebkitAnimation, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-animation-delay, animation_delay, WebkitAnimationDelay, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-animation-direction, animation_direction, WebkitAnimationDirection, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-animation-duration, animation_duration, WebkitAnimationDuration, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-animation-fill-mode, animation_fill_mode, WebkitAnimationFillMode, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-animation-iteration-count, animation_iteration_count, WebkitAnimationIterationCount, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-animation-name, animation_name, WebkitAnimationName, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-animation-play-state, animation_play_state, WebkitAnimationPlayState, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-animation-timing-function, animation_timing_function, WebkitAnimationTimingFunction, "layout.css.test-webkit-prefixes") + +CSS_PROP_ALIAS(-webkit-text-size-adjust, text_size_adjust, WebkitTextSizeAdjust, "layout.css.test-webkit-prefixes") + +CSS_PROP_ALIAS(-webkit-transform, transform, WebkitTransform, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-transform-origin, transform_origin, WebkitTransformOrigin, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-transform-style, transform_style, WebkitTransformStyle, "layout.css.test-webkit-prefixes") + +CSS_PROP_ALIAS(-webkit-transition, transition, WebkitTransition, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-transition-delay, transition_delay, WebkitTransitionDelay, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-transition-duration, transition_duration, WebkitTransitionDuration, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-transition-property, transition_property, WebkitTransitionProperty, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-transition-timing-function, transition_timing_function, WebkitTransitionTimingFunction, "layout.css.test-webkit-prefixes") + +CSS_PROP_ALIAS(-webkit-border-radius, border_radius, WebkitBorderRadius, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-border-top-left-radius, border_top_left_radius, WebkitBorderTopLeftRadius, "layout.css.test-webkit-prefixes") // really no dom property +CSS_PROP_ALIAS(-webkit-border-top-right-radius, border_top_right_radius, WebkitBorderTopRightRadius, "layout.css.test-webkit-prefixes") // really no dom property +CSS_PROP_ALIAS(-webkit-border-bottom-left-radius, border_bottom_left_radius, WebkitBorderBottomLeftRadius, "layout.css.test-webkit-prefixes") // really no dom property +CSS_PROP_ALIAS(-webkit-border-bottom-right-radius, border_bottom_right_radius, WebkitBorderBottomRightRadius, "layout.css.test-webkit-prefixes") // really no dom property + +CSS_PROP_ALIAS(-webkit-appearance, appearance, WebkitAppearance, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-background-clip, background_clip, WebkitBackgroundClip, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-background-origin, background_origin, WebkitBackgroundOrigin, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-background-size, background_size, WebkitBackgroundSize, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-border-image, border_image, WebkitBorderImage, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-box-shadow, box_shadow, WebkitBoxShadow, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(-webkit-user-select, user_select, WebkitUserSelect, "layout.css.test-webkit-prefixes") + +// no prefixes +CSS_PROP_ALIAS(text-size-adjust, text_size_adjust, TextSizeAdjust, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(appearance, appearance, Appearance, "layout.css.test-webkit-prefixes") +CSS_PROP_ALIAS(user-select, user_select, UserSelect, "layout.css.test-webkit-prefixes") diff --git a/layout/style/test/ListCSSProperties.cpp b/layout/style/test/ListCSSProperties.cpp --- a/layout/style/test/ListCSSProperties.cpp +++ b/layout/style/test/ListCSSProperties.cpp @@ -7,24 +7,25 @@ #include #include #include struct PropertyInfo { const char *propName; const char *domName; + const char *pref; }; const PropertyInfo gLonghandProperties[] = { #define CSS_PROP_DOMPROP_PREFIXED(prop_) Moz ## prop_ #define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, \ stylestruct_, stylestructoffset_, animtype_) \ - { #name_, #method_ }, + { #name_, #method_, pref_ }, #include "nsCSSPropList.h" #undef CSS_PROP #undef CSS_PROP_DOMPROP_PREFIXED }; @@ -47,28 +48,28 @@ const char* gLonghandPropertiesWithDOMPr }; const PropertyInfo gShorthandProperties[] = { #define CSS_PROP_DOMPROP_PREFIXED(prop_) Moz ## prop_ // Need an extra level of macro nesting to force expansion of method_ // params before they get pasted. -#define LISTCSSPROPERTIES_INNER_MACRO(method_) #method_, +#define LISTCSSPROPERTIES_INNER_MACRO(method_) #method_ #define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_) \ - { #name_, LISTCSSPROPERTIES_INNER_MACRO(method_) }, + { #name_, LISTCSSPROPERTIES_INNER_MACRO(method_), pref_ }, #include "nsCSSPropList.h" #undef CSS_PROP_SHORTHAND #undef LISTCSSPROPERTIES_INNER_MACRO #undef CSS_PROP_DOMPROP_PREFIXED #define CSS_PROP_ALIAS(name_, id_, method_, pref_) \ - { #name_, #method_ }, + { #name_, #method_, pref_ }, #include "nsCSSPropAliasList.h" #undef CSS_PROP_ALIAS }; /* see gLonghandPropertiesWithDOMProp */ @@ -142,24 +143,42 @@ const char *gInaccessibleProperties[] = "padding-left-rtl-source", "padding-right-ltr-source", "padding-right-rtl-source", "-moz-script-level", // parsed by UA sheets only "-moz-script-size-multiplier", "-moz-script-min-size" }; -inline int +const char *gPrefsToSkip[] = { + // Don't list properties that are conditional on these preferences. + "layout.css.test-webkit-prefixes" +}; + +inline bool is_inaccessible(const char* aPropName) { for (unsigned j = 0; j < ARRAY_LENGTH(gInaccessibleProperties); ++j) { if (strcmp(aPropName, gInaccessibleProperties[j]) == 0) - return 1; + return true; } - return 0; + return false; +} + +inline bool +is_skip_pref(const char* aPrefName) +{ + if (!aPrefName) { + return false; + } + for (unsigned j = 0; j < ARRAY_LENGTH(gPrefsToSkip); ++j) { + if (strcmp(aPrefName, gPrefsToSkip[j]) == 0) + return true; + } + return false; } void print_array(const char *aName, const PropertyInfo *aProps, unsigned aPropsLength, const char * const * aDOMProps, unsigned aDOMPropsLength) { printf("var %s = [\n", aName); @@ -170,16 +189,22 @@ print_array(const char *aName, const PropertyInfo *p = aProps + i; if (is_inaccessible(p->propName)) // inaccessible properties never have DOM props, so don't // worry about incrementing j. The assertion below will // catch if they do. continue; + if (is_skip_pref(p->pref)) { + if (j < aDOMPropsLength && strcmp(p->propName, aDOMProps[j]) == 0) + ++j; + continue; + } + if (first) first = 0; else printf(",\n"); printf("\t{ name: \"%s\", prop: ", p->propName); if (j >= aDOMPropsLength || strcmp(p->propName, aDOMProps[j]) != 0) printf("null");