☠☠ backed out by 33ebe0407469 ☠ ☠ | |
author | L. David Baron <dbaron@dbaron.org> |
Mon, 16 Jul 2012 01:10:06 -0400 | |
changeset 99420 | ac282e15dc027d7b3898e817b46f7c4ffb07fb09 |
parent 99419 | 0e6039a2c90a3e247726263701364ac1bab5a6ba |
child 99421 | e3007422b98954bb6da16fb3e369d909da26810f |
push id | 23135 |
push user | emorley@mozilla.com |
push date | Tue, 17 Jul 2012 09:04:49 +0000 |
treeherder | mozilla-central@ba8463beab13 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bzbarsky |
bugs | 774122 |
milestone | 16.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -648,16 +648,19 @@ protected: // After an UngetToken is done this flag is true. The next call to // GetToken clears the flag. bool mHavePushBack : 1; // True if we are in quirks mode; false in standards or almost standards mode bool mNavQuirkMode : 1; + // True when the hashless color quirk applies. + bool mHashlessColorQuirk : 1; + // True if unsafe rules should be allowed bool mUnsafeRulesEnabled : 1; // True for parsing media lists for HTML attributes, where we have to // ignore CSS comments. bool mHTMLMediaMode : 1; // This flag is set when parsing a non-box shorthand; it's used to not apply @@ -741,16 +744,17 @@ static void AppendRuleToSheet(css::Rule* CSSParserImpl::CSSParserImpl() : mToken(), mScanner(), mChildLoader(nsnull), mSection(eCSSSection_Charset), mNameSpaceMap(nsnull), mHavePushBack(false), mNavQuirkMode(false), + mHashlessColorQuirk(false), mUnsafeRulesEnabled(false), mHTMLMediaMode(false), mParsingCompoundProperty(false) #ifdef DEBUG , mScannerInited(false) #endif , mNextFree(nsnull) { @@ -3747,17 +3751,17 @@ CSSParserImpl::ParseColor(nsCSSValue& aV return false; } break; default: break; } // try 'xxyyzz' without '#' prefix for compatibility with IE and Nav4x (bug 23236 and 45804) - if (mNavQuirkMode && !IsParsingCompoundProperty()) { + if (mHashlessColorQuirk) { // - If the string starts with 'a-f', the nsCSSScanner builds the // token as a eCSSToken_Ident and we can parse the string as a // 'xxyyzz' RGB color. // - If it only contains '0-9' digits, the token is a // eCSSToken_Number and it must be converted back to a 6 // characters string to be parsed as a RGB color. // - If it starts with '0-9' and contains any 'a-f', the token is a // eCSSToken_Dimension, the mNumber part must be converted back to @@ -4548,17 +4552,17 @@ CSSParserImpl::ParseVariant(nsCSSValue& return ParseImageRect(aValue); } if ((aVariantMask & VARIANT_ELEMENT) != 0 && eCSSToken_Function == tk->mType && tk->mIdent.LowerCaseEqualsLiteral("-moz-element")) { return ParseElement(aValue); } if ((aVariantMask & VARIANT_COLOR) != 0) { - if ((mNavQuirkMode && !IsParsingCompoundProperty()) || // NONSTANDARD: Nav interprets 'xxyyzz' values even without '#' prefix + if (mHashlessColorQuirk || // NONSTANDARD: Nav interprets 'xxyyzz' values even without '#' prefix (eCSSToken_ID == tk->mType) || (eCSSToken_Ref == tk->mType) || (eCSSToken_Ident == tk->mType) || ((eCSSToken_Function == tk->mType) && (tk->mIdent.LowerCaseEqualsLiteral("rgb") || tk->mIdent.LowerCaseEqualsLiteral("hsl") || tk->mIdent.LowerCaseEqualsLiteral("-moz-rgba") || tk->mIdent.LowerCaseEqualsLiteral("-moz-hsla") || @@ -5609,46 +5613,68 @@ static const nsCSSProperty kOutlineRadiu eCSSProperty__moz_outline_radius_topRight, eCSSProperty__moz_outline_radius_bottomRight, eCSSProperty__moz_outline_radius_bottomLeft }; bool CSSParserImpl::ParseProperty(nsCSSProperty aPropID) { + // Can't use AutoRestore<bool> because it's a bitfield. + NS_ABORT_IF_FALSE(!mHashlessColorQuirk, + "hashless color quirk should not be set"); + if (mNavQuirkMode) { + mHashlessColorQuirk = + nsCSSProps::PropHasFlags(aPropID, CSS_PROPERTY_HASHLESS_COLOR_QUIRK); + } + NS_ASSERTION(aPropID < eCSSProperty_COUNT, "index out of range"); + bool result; switch (nsCSSProps::PropertyParseType(aPropID)) { case CSS_PROPERTY_PARSE_INACCESSIBLE: { // The user can't use these REPORT_UNEXPECTED(PEInaccessibleProperty2); - return false; + result = false; + break; } case CSS_PROPERTY_PARSE_FUNCTION: { - return ParsePropertyByFunction(aPropID); + result = ParsePropertyByFunction(aPropID); + break; } case CSS_PROPERTY_PARSE_VALUE: { + result = false; nsCSSValue value; if (ParseSingleValueProperty(value, aPropID)) { if (ExpectEndProperty()) { AppendValue(aPropID, value); - return true; + result = true; } // XXX Report errors? } // XXX Report errors? - return false; + break; } case CSS_PROPERTY_PARSE_VALUE_LIST: { - return ParseValueList(aPropID); - } - } - NS_ABORT_IF_FALSE(false, - "Property's flags field in nsCSSPropList.h is missing " - "one of the CSS_PROPERTY_PARSE_* constants"); - return false; + result = ParseValueList(aPropID); + break; + } + default: { + result = false; + NS_ABORT_IF_FALSE(false, + "Property's flags field in nsCSSPropList.h is missing " + "one of the CSS_PROPERTY_PARSE_* constants"); + break; + } + } + + if (mNavQuirkMode) { + mHashlessColorQuirk = false; + } + + return result; } bool CSSParserImpl::ParsePropertyByFunction(nsCSSProperty aPropID) { switch (aPropID) { // handle shorthand or multiple properties case eCSSProperty_background: return ParseBackground();
--- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -477,17 +477,18 @@ CSS_PROP_BACKGROUND( CSS_PROP_NO_OFFSET, eStyleAnimType_None) CSS_PROP_BACKGROUND( background-color, background_color, BackgroundColor, CSS_PROPERTY_PARSE_VALUE | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE | - CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, + CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED | + CSS_PROPERTY_HASHLESS_COLOR_QUIRK, "", VARIANT_HC, nsnull, offsetof(nsStyleBackground, mBackgroundColor), eStyleAnimType_Color) CSS_PROP_BACKGROUND( background-image, background_image, @@ -587,17 +588,18 @@ CSS_PROP_SHORTHAND( CSS_PROPERTY_PARSE_FUNCTION, "") CSS_PROP_BORDER( border-bottom-color, border_bottom_color, BorderBottomColor, CSS_PROPERTY_PARSE_VALUE | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | - CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, + CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED | + CSS_PROPERTY_HASHLESS_COLOR_QUIRK, "", VARIANT_HCK, kBorderColorKTable, CSS_PROP_NO_OFFSET, eStyleAnimType_Custom) CSS_PROP_BORDER( -moz-border-bottom-colors, border_bottom_colors, @@ -642,17 +644,18 @@ CSS_PROP_TABLEBORDER( VARIANT_HK, kBorderCollapseKTable, CSS_PROP_NO_OFFSET, eStyleAnimType_None) CSS_PROP_SHORTHAND( border-color, border_color, BorderColor, - CSS_PROPERTY_PARSE_FUNCTION, + CSS_PROPERTY_PARSE_FUNCTION | + CSS_PROPERTY_HASHLESS_COLOR_QUIRK, "") CSS_PROP_SHORTHAND( -moz-border-end, border_end, CSS_PROP_DOMPROP_PREFIXED(BorderEnd), CSS_PROPERTY_PARSE_FUNCTION, "") CSS_PROP_SHORTHAND( @@ -780,17 +783,18 @@ CSS_PROP_SHORTHAND( border_left, BorderLeft, CSS_PROPERTY_PARSE_FUNCTION, "") CSS_PROP_SHORTHAND( border-left-color, border_left_color, BorderLeftColor, - CSS_PROPERTY_PARSE_FUNCTION, + CSS_PROPERTY_PARSE_FUNCTION | + CSS_PROPERTY_HASHLESS_COLOR_QUIRK, "") #ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL CSS_PROP_BORDER( border-left-color-value, border_left_color_value, BorderLeftColorValue, CSS_PROPERTY_PARSE_INACCESSIBLE | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | @@ -934,17 +938,18 @@ CSS_PROP_SHORTHAND( border_right, BorderRight, CSS_PROPERTY_PARSE_FUNCTION, "") CSS_PROP_SHORTHAND( border-right-color, border_right_color, BorderRightColor, - CSS_PROPERTY_PARSE_FUNCTION, + CSS_PROPERTY_PARSE_FUNCTION | + CSS_PROPERTY_HASHLESS_COLOR_QUIRK, "") #ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL CSS_PROP_BORDER( border-right-color-value, border_right_color_value, BorderRightColorValue, CSS_PROPERTY_PARSE_INACCESSIBLE | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | @@ -1171,17 +1176,18 @@ CSS_PROP_SHORTHAND( CSS_PROPERTY_PARSE_FUNCTION, "") CSS_PROP_BORDER( border-top-color, border_top_color, BorderTopColor, CSS_PROPERTY_PARSE_VALUE | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER | - CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, + CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED | + CSS_PROPERTY_HASHLESS_COLOR_QUIRK, "", VARIANT_HCK, kBorderColorKTable, CSS_PROP_NO_OFFSET, eStyleAnimType_Custom) CSS_PROP_BORDER( -moz-border-top-colors, border_top_colors, @@ -1347,17 +1353,18 @@ CSS_PROP_DISPLAY( offsetof(nsStyleDisplay, mClip), eStyleAnimType_Custom) CSS_PROP_COLOR( color, color, Color, CSS_PROPERTY_PARSE_VALUE | CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE | - CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED, + CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED | + CSS_PROPERTY_HASHLESS_COLOR_QUIRK, "", VARIANT_HC, nsnull, offsetof(nsStyleColor, mColor), eStyleAnimType_Color) CSS_PROP_SHORTHAND( -moz-columns, _moz_columns,
--- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -87,17 +87,18 @@ MOZ_STATIC_ASSERT((CSS_PROPERTY_PARSE_PR #define CSS_PROPERTY_VALUE_RESTRICTION_MASK (3<<13) // The parser (in particular, CSSParserImpl::ParseSingleValueProperty) // should enforce that the value of this property must be 0 or larger. #define CSS_PROPERTY_VALUE_NONNEGATIVE (1<<13) // The parser (in particular, CSSParserImpl::ParseSingleValueProperty) // should enforce that the value of this property must be 1 or larger. #define CSS_PROPERTY_VALUE_AT_LEAST_ONE (2<<13) -// NOTE: next free bit is (1<<15) +// Does this property suppor the hashless hex color quirk in quirks mode? +#define CSS_PROPERTY_HASHLESS_COLOR_QUIRK (1<<15) /** * Types of animatable values. */ enum nsStyleAnimType { // requires a custom implementation in // nsStyleAnimation::ExtractComputedValue eStyleAnimType_Custom,
--- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -24,16 +24,18 @@ const CSS_TYPE_SHORTHAND_AND_LONGHAND = // initial_values: Values whose computed value should be the same as the // computed value for the property's initial value. // other_values: Values whose computed value should be different from the // computed value for the property's initial value. // XXX Should have a third field for values whose computed value may or // may not be the same as for the property's initial value. // invalid_values: Things that are not values for the property and // should be rejected. +// quirks_values: Values that should be accepted in quirks mode only, +// mapped to the values they are equivalent to. // Helper functions used to construct gCSSProperties. function initial_font_family_is_sans_serif() { // The initial value of 'font-family' might be 'serif' or // 'sans-serif'. var div = document.createElement("div"); @@ -143,17 +145,17 @@ var gCSSProperties = { invalid_values: [] }, "-moz-border-bottom-colors": { domProp: "MozBorderBottomColors", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ], - invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red" ] + invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red", "ff00cc" ] }, "-moz-border-end": { domProp: "MozBorderEnd", inherited: false, type: CSS_TYPE_TRUE_SHORTHAND, subproperties: [ "-moz-border-end-color", "-moz-border-end-style", "-moz-border-end-width" ], initial_values: [ "none", "medium", "currentColor", "thin", "none medium currentcolor" ], other_values: [ "solid", "green", "medium solid", "green solid", "10px solid", "thick solid", "5px green none" ], @@ -161,17 +163,17 @@ var gCSSProperties = { }, "-moz-border-end-color": { domProp: "MozBorderEndColor", inherited: false, type: CSS_TYPE_SHORTHAND_AND_LONGHAND, get_computed: logical_box_prop_get_computed, initial_values: [ "currentColor" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000" ] }, "-moz-border-end-style": { domProp: "MozBorderEndStyle", inherited: false, type: CSS_TYPE_SHORTHAND_AND_LONGHAND, get_computed: logical_box_prop_get_computed, /* XXX hidden is sometimes the same as initial */ initial_values: [ "none" ], @@ -274,17 +276,17 @@ var gCSSProperties = { invalid_values: [ "none", "stretch stretch stretch", "0", "10", "0%", "0px" ] }, "-moz-border-left-colors": { domProp: "MozBorderLeftColors", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ], - invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red" ] + invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red", "ff00cc" ] }, "border-radius": { domProp: "borderRadius", inherited: false, type: CSS_TYPE_TRUE_SHORTHAND, prerequisites: { "width": "200px", "height": "100px", "display": "inline-block"}, subproperties: [ "border-bottom-left-radius", "border-bottom-right-radius", "border-top-left-radius", "border-top-right-radius" ], initial_values: [ "0", "0px", "0%", "0px 0 0 0px", "calc(-2px)", "calc(-1%)", "calc(0px) calc(0pt) calc(0%) calc(0em)" ], @@ -380,17 +382,17 @@ var gCSSProperties = { invalid_values: [ "-1px", "4px -2px", "inherit 2px", "2px inherit" ] }, "-moz-border-right-colors": { domProp: "MozBorderRightColors", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ], - invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red" ] + invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red", "ff00cc" ] }, "-moz-border-start": { domProp: "MozBorderStart", inherited: false, type: CSS_TYPE_TRUE_SHORTHAND, subproperties: [ "-moz-border-start-color", "-moz-border-start-style", "-moz-border-start-width" ], initial_values: [ "none", "medium", "currentColor", "thin", "none medium currentcolor" ], other_values: [ "solid", "green", "medium solid", "green solid", "10px solid", "thick solid", "5px green none" ], @@ -398,17 +400,17 @@ var gCSSProperties = { }, "-moz-border-start-color": { domProp: "MozBorderStartColor", inherited: false, type: CSS_TYPE_SHORTHAND_AND_LONGHAND, get_computed: logical_box_prop_get_computed, initial_values: [ "currentColor" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000" ] }, "-moz-border-start-style": { domProp: "MozBorderStartStyle", inherited: false, type: CSS_TYPE_SHORTHAND_AND_LONGHAND, get_computed: logical_box_prop_get_computed, /* XXX hidden is sometimes the same as initial */ initial_values: [ "none" ], @@ -435,17 +437,17 @@ var gCSSProperties = { invalid_values: [ "5%" ] }, "-moz-border-top-colors": { domProp: "MozBorderTopColors", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "red green", "red #fc3", "#ff00cc", "currentColor", "blue currentColor orange currentColor" ], - invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red" ] + invalid_values: [ "red none", "red inherit", "red, green", "none red", "inherit red", "ff00cc" ] }, "-moz-box-align": { domProp: "MozBoxAlign", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "stretch" ], other_values: [ "start", "center", "baseline", "end" ], invalid_values: [] @@ -824,17 +826,17 @@ var gCSSProperties = { }, "-moz-column-rule-color": { domProp: "MozColumnRuleColor", inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "color": "green" }, initial_values: [ "currentColor", "-moz-use-text-color" ], other_values: [ "red", "blue", "#ffff00" ], - invalid_values: [ ] + invalid_values: [ "ffff00" ] }, "-moz-column-width": { domProp: "MozColumnWidth", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "auto" ], other_values: [ "15px", @@ -1463,16 +1465,18 @@ var gCSSProperties = { /* test cases with clip+origin in the shorthand */ "url(404.png) green padding-box", "url(404.png) border-box transparent", "content-box url(404.png) blue", ], invalid_values: [ /* mixes with keywords have to be in correct order */ "50% left", "top 50%", + /* no quirks mode colors */ + "-moz-radial-gradient(10% bottom, ffffff, black) scroll no-repeat", /* bug 258080: don't accept background-position separated */ "left url(404.png) top", "top url(404.png) left", /* not allowed to have color in non-bottom layer */ "url(404.png) transparent, url(404.png)", "url(404.png) red, url(404.png)", "url(404.png) transparent, url(404.png) transparent", "url(404.png) transparent red, url(404.png) transparent red", "url(404.png) red, url(404.png) red", @@ -1507,17 +1511,18 @@ var gCSSProperties = { invalid_values: [ "margin-box", "border-box border-box" ] }, "background-color": { domProp: "backgroundColor", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "transparent", "rgba(255, 127, 15, 0)", "hsla(240, 97%, 50%, 0.0)", "rgba(0, 0, 0, 0)", "rgba(255,255,255,-3.7)" ], other_values: [ "green", "rgb(255, 0, 128)", "#fc2", "#96ed2a", "black", "rgba(255,255,0,3)" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "rgb(255.0,0.387,3489)" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "rgb(255.0,0.387,3489)" ], + quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" }, }, "background-image": { domProp: "backgroundImage", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR42u3NQQ0AAAgEoNP+nTWFDzcoQE1udQQCgUAgEAgEAsGTYAGjxAE/G/Q2tQAAAABJRU5ErkJggg==)", "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR42u3NQQ0AAAgEoNP+nTWFDzcoQE1udQQCgUAgEAgEAsGTYAGjxAE/G/Q2tQAAAABJRU5ErkJggg==')", 'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR42u3NQQ0AAAgEoNP+nTWFDzcoQE1udQQCgUAgEAgEAsGTYAGjxAE/G/Q2tQAAAABJRU5ErkJggg==")', @@ -1788,16 +1793,18 @@ var gCSSProperties = { "-moz-radial-gradient(left calc(100px + -25px), red, blue)", ], invalid_values: [ "-moz-element(#a:1)", "-moz-element(a#a)", "-moz-element(#a a)", "-moz-element(#a+a)", "-moz-element(#a()", + /* no quirks mode colors */ + "linear-gradient(red, ff00ff)", /* Old syntax */ "-moz-linear-gradient(10px 10px, 20px, 30px 30px, 40px, from(blue), to(red))", "-moz-radial-gradient(20px 20px, 10px 10px, from(green), to(#ff00ff))", "-moz-radial-gradient(10px 10px, 20%, 40px 40px, 10px, from(green), to(#ff00ff))", "-moz-linear-gradient(10px, 20px, 30px, 40px, color-stop(0.5, #00ccff))", "-moz-linear-gradient(20px 20px, from(blue), to(red))", "-moz-linear-gradient(40px 40px, 10px 10px, from(blue) to(red) color-stop(10%, fuchsia))", "-moz-linear-gradient(20px 20px 30px, 10px 10px, from(red), to(#ff0000))", @@ -2100,17 +2107,17 @@ var gCSSProperties = { }, "border": { domProp: "border", inherited: false, type: CSS_TYPE_TRUE_SHORTHAND, subproperties: [ "border-bottom-color", "border-bottom-style", "border-bottom-width", "border-left-color", "border-left-style", "border-left-width", "border-right-color", "border-right-style", "border-right-width", "border-top-color", "border-top-style", "border-top-width", "-moz-border-top-colors", "-moz-border-right-colors", "-moz-border-bottom-colors", "-moz-border-left-colors", "border-image-source", "border-image-slice", "border-image-width", "border-image-outset", "border-image-repeat" ], initial_values: [ "none", "medium", "currentColor", "thin", "none medium currentcolor", "calc(4px - 1px) none" ], other_values: [ "solid", "medium solid", "green solid", "10px solid", "thick solid", "calc(2px) solid blue" ], - invalid_values: [ "5%" ] + invalid_values: [ "5%", "medium solid ff00ff" ] }, "border-bottom": { domProp: "borderBottom", inherited: false, type: CSS_TYPE_TRUE_SHORTHAND, subproperties: [ "border-bottom-color", "border-bottom-style", "border-bottom-width" ], initial_values: [ "none", "medium", "currentColor", "thin", "none medium currentcolor" ], other_values: [ "solid", "green", "medium solid", "green solid", "10px solid", "thick solid", "5px green none" ], @@ -2118,17 +2125,18 @@ var gCSSProperties = { }, "border-bottom-color": { domProp: "borderBottomColor", inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "color": "black" }, initial_values: [ "currentColor", "-moz-use-text-color" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ], + quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" }, }, "border-bottom-style": { domProp: "borderBottomStyle", inherited: false, type: CSS_TYPE_LONGHAND, /* XXX hidden is sometimes the same as initial */ initial_values: [ "none" ], other_values: [ "solid", "dashed", "dotted", "double", "outset", "inset", "groove", "ridge" ], @@ -2162,17 +2170,18 @@ var gCSSProperties = { }, "border-color": { domProp: "borderColor", inherited: false, type: CSS_TYPE_TRUE_SHORTHAND, subproperties: [ "border-top-color", "border-right-color", "border-bottom-color", "border-left-color" ], initial_values: [ "currentColor", "currentColor currentColor", "currentColor currentColor currentColor", "currentColor currentColor currentcolor CURRENTcolor" ], other_values: [ "green", "currentColor green", "currentColor currentColor green", "currentColor currentColor currentColor green", "rgba(255,128,0,0.5)", "transparent" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ], + quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" }, }, "border-left": { domProp: "borderLeft", inherited: false, type: CSS_TYPE_TRUE_SHORTHAND, subproperties: [ "border-left-color", "border-left-style", "border-left-width" ], initial_values: [ "none", "medium", "currentColor", "thin", "none medium currentcolor" ], other_values: [ "solid", "green", "medium solid", "green solid", "10px solid", "thick solid", "5px green none" ], @@ -2180,17 +2189,18 @@ var gCSSProperties = { }, "border-left-color": { domProp: "borderLeftColor", inherited: false, type: CSS_TYPE_SHORTHAND_AND_LONGHAND, prerequisites: { "color": "black" }, initial_values: [ "currentColor", "-moz-use-text-color" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ], + quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" }, }, "border-left-style": { domProp: "borderLeftStyle", inherited: false, type: CSS_TYPE_SHORTHAND_AND_LONGHAND, /* XXX hidden is sometimes the same as initial */ initial_values: [ "none" ], other_values: [ "solid", "dashed", "dotted", "double", "outset", "inset", "groove", "ridge" ], @@ -2225,17 +2235,18 @@ var gCSSProperties = { }, "border-right-color": { domProp: "borderRightColor", inherited: false, type: CSS_TYPE_SHORTHAND_AND_LONGHAND, prerequisites: { "color": "black" }, initial_values: [ "currentColor", "-moz-use-text-color" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ], + quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" }, }, "border-right-style": { domProp: "borderRightStyle", inherited: false, type: CSS_TYPE_SHORTHAND_AND_LONGHAND, /* XXX hidden is sometimes the same as initial */ initial_values: [ "none" ], other_values: [ "solid", "dashed", "dotted", "double", "outset", "inset", "groove", "ridge" ], @@ -2288,17 +2299,18 @@ var gCSSProperties = { }, "border-top-color": { domProp: "borderTopColor", inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "color": "black" }, initial_values: [ "currentColor", "-moz-use-text-color" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ], + quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a" }, }, "border-top-style": { domProp: "borderTopStyle", inherited: false, type: CSS_TYPE_LONGHAND, /* XXX hidden is sometimes the same as initial */ initial_values: [ "none" ], other_values: [ "solid", "dashed", "dotted", "double", "outset", "inset", "groove", "ridge" ], @@ -2398,17 +2410,18 @@ var gCSSProperties = { }, "color": { domProp: "color", inherited: true, type: CSS_TYPE_LONGHAND, /* XXX should test currentColor, but may or may not be initial */ initial_values: [ "black", "#000" ], other_values: [ "green", "#f3c", "#fed292", "rgba(45,300,12,2)", "transparent", "-moz-nativehyperlinktext", "rgba(255,128,0,0.5)" ], - invalid_values: [ "fff", "ffffff", "#f", "#ff", "#ffff", "#fffff", "#fffffff", "#ffffffff", "#fffffffff" ] + invalid_values: [ "#f", "#ff", "#ffff", "#fffff", "#fffffff", "#ffffffff", "#fffffffff" ], + quirks_values: { "000000": "#000000", "96ed2a": "#96ed2a", "fff": "#ffffff", "ffffff": "#ffffff", }, }, "content": { domProp: "content", inherited: false, type: CSS_TYPE_LONGHAND, /* XXX needs to be on pseudo-elements */ initial_values: [ "normal", "none" ], other_values: [ '""', "''", '"hello"', "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR42u3NQQ0AAAgEoNP+nTWFDzcoQE1udQQCgUAgEAgEAsGTYAGjxAE/G/Q2tQAAAABJRU5ErkJggg==)", "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR42u3NQQ0AAAgEoNP+nTWFDzcoQE1udQQCgUAgEAgEAsGTYAGjxAE/G/Q2tQAAAABJRU5ErkJggg==')", 'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR42u3NQQ0AAAgEoNP+nTWFDzcoQE1udQQCgUAgEAgEAsGTYAGjxAE/G/Q2tQAAAABJRU5ErkJggg==")', 'counter(foo)', 'counter(bar, upper-roman)', 'counters(foo, ".")', "counters(bar, '-', lower-greek)", "'-' counter(foo) '.'", "attr(title)", "open-quote", "close-quote", "no-open-quote", "no-close-quote", "close-quote attr(title) counters(foo, '.', upper-alpha)", "counter(foo, none)", "counters(bar, '.', none)", "attr(\\32)", "attr(\\2)", "attr(-\\2)", "attr(-\\32)", "counter(\\2)", "counters(\\32, '.')", "counter(-\\32, upper-roman)", "counters(-\\2, '-', lower-greek)", "counter(\\()", "counters(a\\+b, '.')", "counter(\\}, upper-alpha)", "-moz-alt-content" ], @@ -2920,17 +2933,17 @@ var gCSSProperties = { }, "outline-color": { domProp: "outlineColor", inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "color": "black" }, initial_values: [ "currentColor", "-moz-use-text-color" ], // XXX should be invert other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000", "cc00ff" ] }, "outline-offset": { domProp: "outlineOffset", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "0", "0px", "-0", "calc(0px)", "calc(3em + 2px - 2px - 3em)", "calc(-0em)" ], other_values: [ "-3px", "1em", "calc(3em)", "calc(7pt + 3 * 2em)", "calc(-3px)" ], invalid_values: [ "5%" ] @@ -3193,17 +3206,17 @@ var gCSSProperties = { }, "-moz-text-decoration-color": { domProp: "MozTextDecorationColor", inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "color": "black" }, initial_values: [ "currentColor", "-moz-use-text-color" ], other_values: [ "green", "rgba(255,128,0,0.5)", "transparent" ], - invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000" ] + invalid_values: [ "#0", "#00", "#0000", "#00000", "#0000000", "#00000000", "#000000000", "000000", "ff00ff" ] }, "-moz-text-decoration-line": { domProp: "MozTextDecorationLine", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "underline", "overline", "line-through", "line-through underline", "underline overline line-through", "-moz-anchor-decoration", "-moz-anchor-decoration" ], invalid_values: [ "none none", "underline none", "none underline", "line-through blink line-through", "underline overline line-through blink none", "underline overline line-throuh blink blink" ] @@ -3564,17 +3577,17 @@ var gCSSProperties = { }, "fill": { domProp: "fill", inherited: true, type: CSS_TYPE_LONGHAND, prerequisites: { "color": "blue" }, initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ], other_values: [ "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "none", "currentColor" ], - invalid_values: [] + invalid_values: [ "000000", "ff00ff" ] }, "fill-opacity": { domProp: "fillOpacity", inherited: true, type: CSS_TYPE_LONGHAND, initial_values: [ "1", "2.8", "1.000" ], other_values: [ "0", "0.3", "-7.3" ], invalid_values: [] @@ -3597,17 +3610,17 @@ var gCSSProperties = { }, "flood-color": { domProp: "floodColor", inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "color": "blue" }, initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ], other_values: [ "green", "#fc3", "currentColor" ], - invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green' ] + invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "000000", "ff00ff" ] }, "flood-opacity": { domProp: "floodOpacity", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "1", "2.8", "1.000" ], other_values: [ "0", "0.3", "-7.3" ], invalid_values: [] @@ -3622,17 +3635,17 @@ var gCSSProperties = { }, "lighting-color": { domProp: "lightingColor", inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "color": "blue" }, initial_values: [ "white", "#fff", "#ffffff", "rgb(255,255,255)", "rgba(255,255,255,1.0)", "rgba(255,255,255,42.0)" ], other_values: [ "green", "#fc3", "currentColor" ], - invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green' ] + invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "000000", "ff00ff" ] }, "marker": { domProp: "marker", inherited: true, type: CSS_TYPE_TRUE_SHORTHAND, subproperties: [ "marker-start", "marker-mid", "marker-end" ], initial_values: [ "none" ], other_values: [ "url(#mysym)" ], @@ -3680,33 +3693,33 @@ var gCSSProperties = { }, "stop-color": { domProp: "stopColor", inherited: false, type: CSS_TYPE_LONGHAND, prerequisites: { "color": "blue" }, initial_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)" ], other_values: [ "green", "#fc3", "currentColor" ], - invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green' ] + invalid_values: [ "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "000000", "ff00ff" ] }, "stop-opacity": { domProp: "stopOpacity", inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "1", "2.8", "1.000" ], other_values: [ "0", "0.3", "-7.3" ], invalid_values: [] }, "stroke": { domProp: "stroke", inherited: true, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "black", "#000", "#000000", "rgb(0,0,0)", "rgba(0,0,0,1)", "green", "#fc3", "url('#myserver')", "url(foo.svg#myserver)", 'url("#myserver") green', "currentColor" ], - invalid_values: [] + invalid_values: [ "000000", "ff00ff" ] }, "stroke-dasharray": { domProp: "strokeDasharray", inherited: true, type: CSS_TYPE_LONGHAND, initial_values: [ "none" ], other_values: [ "5px,3px,2px", "5px 3px 2px", " 5px ,3px , 2px ", "1px", "5%", "3em" ], invalid_values: [ "-5px,3px,2px", "5px,3px,-2px" ]
--- a/layout/style/test/test_property_syntax_errors.html +++ b/layout/style/test/test_property_syntax_errors.html @@ -3,60 +3,95 @@ <!-- --> <head> <title>Test that we reject syntax errors listed in property_database.js</title> <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> <script type="text/javascript" src="property_database.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> </head> -<body> +<body onload="run()"> <p id="display"></p> +<iframe id="quirks" src="data:text/html,<div id='testnode'></div>"></iframe> <div id="content" style="display: none"> <div id="testnode"></div> </div> <pre id="test"> <script class="testbody" type="text/javascript"> -var gDeclaration = document.getElementById("testnode").style; +SimpleTest.waitForExplicitFinish(); + +function check_not_accepted(decl, property, info, badval) +{ + decl.setProperty(property, badval, ""); + + is(decl.getPropertyValue(property), "", + "invalid value '" + badval + "' not accepted for '" + property + + "' property"); -var gKnownFails = { - "pitch-range": [ " -0.01", "100.2", "108", "-3" ], - "richness": [ " -0.01", "100.2", "108", "-3" ], - "stress": [ " -0.01", "100.2", "108", "-3" ], - "volume": [ " -0.01", "100.2", "108", "-3" ] + if ("subproperties" in info) { + for (var sidx in info.subproperties) { + var subprop = info.subproperties[sidx]; + is(decl.getPropertyValue(subprop), "", + "invalid value '" + badval + "' not accepted for '" + property + + "' property when testing subproperty '" + subprop + "'"); + } + } + + decl.removeProperty(property); } -for (var property in gCSSProperties) { - var info = gCSSProperties[property]; - for (var idx in info.invalid_values) { - var badval = info.invalid_values[idx]; +function run() +{ + var gDeclaration = document.getElementById("testnode").style; + var gQuirksDeclaration = document.getElementById("quirks").contentDocument + .getElementById("testnode").style; - gDeclaration.setProperty(property, badval, ""); + for (var property in gCSSProperties) { + var info = gCSSProperties[property]; + for (var idx in info.invalid_values) { + check_not_accepted(gDeclaration, property, info, + info.invalid_values[idx]); + check_not_accepted(gQuirksDeclaration, property, info, + info.invalid_values[idx]); + } + + if ("quirks_values" in info) { + for (var quirkval in info.quirks_values) { + var standardval = info.quirks_values[quirkval]; + check_not_accepted(gDeclaration, property, info, quirkval); - var func = is; - if (property in gKnownFails && - gKnownFails[property].indexOf(badval) != -1) - func = todo_is; + gQuirksDeclaration.setProperty(property, quirkval, ""); + gDeclaration.setProperty(property, standardval, ""); + var quirkret = gQuirksDeclaration.getPropertyValue(property); + var standardret = gDeclaration.getPropertyValue(property); + isnot(quirkret, "", property + ": " + quirkval + + " should be accepted in quirks mode"); + is(quirkret, standardret, property + ": " + quirkval + " result"); - func(gDeclaration.getPropertyValue(property), "", - "invalid value '" + badval + "' not accepted for '" + property + - "' property"); + if ("subproperties" in info) { + for (var sidx in info.subproperties) { + var subprop = info.subproperties[sidx]; + var quirksub = gQuirksDeclaration.getPropertyValue(subprop); + var standardsub = gDeclaration.getPropertyValue(subprop); + isnot(quirksub, "", property + ": " + quirkval + + " should be accepted in quirks mode" + + " when testing subproperty " + subprop); + is(quirksub, standardsub, property + ": " + quirkval + " result" + + " when testing subproperty " + subprop); + } + } - if ("subproperties" in info) { - for (var sidx in info.subproperties) { - var subprop = info.subproperties[sidx]; - func(gDeclaration.getPropertyValue(subprop), "", - "invalid value '" + badval + "' not accepted for '" + property + - "' property when testing subproperty '" + subprop + "'"); + gQuirksDeclaration.removeProperty(property); + gDeclaration.removeProperty(property); } } + } - gDeclaration.removeProperty(property); - } + SimpleTest.finish(); } </script> </pre> </body> </html>