Bug 1255379 - fix getCSSValuesForProperty for clip and clip-path; r=xidorn

This fixes getCSSValuesForProperty for clip and clip-path.

Although clip is deprecated, it seemed harmless to fix it as well;
when it is removed this code will also be readily found and removed.

It wasn't clear to me if setting the keyword table for clip-path in
nsCSSPropList.h would be ok, so I added a special case in
InspectorUtils.

MozReview-Commit-ID: Ghawr17HjKk

--HG--
extra : rebase_source : 29c094afd678019b4f3f49ac55493ef0d7d6848f
This commit is contained in:
Tom Tromey 2018-01-22 13:26:14 -07:00
Родитель ce234fa0c1
Коммит 3728debffe
4 изменённых файлов: 48 добавлений и 8 удалений

Просмотреть файл

@ -2882,7 +2882,6 @@ exports.CSS_PROPERTIES = {
"border-block-start-style",
"border-block-start-width",
"border-bottom-color",
"-moz-border-bottom-colors",
"border-bottom-left-radius",
"border-bottom-right-radius",
"border-bottom-style",
@ -2900,16 +2899,13 @@ exports.CSS_PROPERTIES = {
"border-inline-start-style",
"border-inline-start-width",
"border-left-color",
"-moz-border-left-colors",
"border-left-style",
"border-left-width",
"border-right-color",
"-moz-border-right-colors",
"border-right-style",
"border-right-width",
"border-spacing",
"border-top-color",
"-moz-border-top-colors",
"border-top-left-radius",
"border-top-right-radius",
"border-top-style",
@ -4972,8 +4968,10 @@ exports.CSS_PROPERTIES = {
],
"supports": [],
"values": [
"auto",
"inherit",
"initial",
"rect",
"unset"
]
},
@ -4986,9 +4984,22 @@ exports.CSS_PROPERTIES = {
11
],
"values": [
"border-box",
"circle",
"content-box",
"ellipse",
"fill-box",
"inherit",
"initial",
"unset"
"inset",
"margin-box",
"none",
"padding-box",
"polygon",
"stroke-box",
"unset",
"url",
"view-box"
]
},
"clip-rule": {

Просмотреть файл

@ -454,6 +454,14 @@ static void GetKeywordsForProperty(const nsCSSPropertyID aProperty,
}
const nsCSSProps::KTableEntry* keywordTable =
nsCSSProps::kKeywordTableTable[aProperty];
// Special cases where nsCSSPropList.h doesn't hold the table.
if (keywordTable == nullptr) {
if (aProperty == eCSSProperty_clip_path) {
keywordTable = nsCSSProps::kClipPathGeometryBoxKTable;
}
}
if (keywordTable) {
for (size_t i = 0; !keywordTable[i].IsSentinel(); ++i) {
nsCSSKeyword word = keywordTable[i].mKeyword;
@ -471,6 +479,16 @@ static void GetKeywordsForProperty(const nsCSSPropertyID aProperty,
}
}
}
// More special cases.
if (aProperty == eCSSProperty_clip_path) {
InsertNoDuplicates(aArray, NS_LITERAL_STRING("circle"));
InsertNoDuplicates(aArray, NS_LITERAL_STRING("ellipse"));
InsertNoDuplicates(aArray, NS_LITERAL_STRING("inset"));
InsertNoDuplicates(aArray, NS_LITERAL_STRING("polygon"));
} else if (aProperty == eCSSProperty_clip) {
InsertNoDuplicates(aArray, NS_LITERAL_STRING("rect"));
}
}
static void GetColorsForProperty(const uint32_t aParserVariant,
@ -674,7 +692,6 @@ PropertySupportsVariant(nsCSSPropertyID aPropertyID, uint32_t aVariant)
case eCSSProperty_content:
case eCSSProperty_cursor:
case eCSSProperty_clip_path:
supported |= VARIANT_URL;
break;

Просмотреть файл

@ -196,6 +196,18 @@ function do_test() {
var values = InspectorUtils.getCSSValuesForProperty("box-shadow");
ok(testValues(values, expected), "property box-shadow's values");
// Regression test for bug 1255379.
var expected = [ "inherit", "initial", "unset", "none", "url",
"polygon", "circle", "ellipse", "inset",
"fill-box", "stroke-box", "view-box", "margin-box",
"border-box", "padding-box", "content-box" ];
var values = InspectorUtils.getCSSValuesForProperty("clip-path");
ok(testValues(values, expected), "property clip-path's values");
var expected = [ "inherit", "initial", "unset", "auto", "rect" ];
var values = InspectorUtils.getCSSValuesForProperty("clip");
ok(testValues(values, expected), "property clip's values");
SimpleTest.finish();
}

Просмотреть файл

@ -1362,7 +1362,7 @@ CSS_PROP_EFFECTS(
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_UNITLESS_LENGTH_QUIRK,
"",
0,
VARIANT_AH,
nullptr,
offsetof(nsStyleEffects, mClip),
eStyleAnimType_Custom)
@ -1375,7 +1375,7 @@ CSS_PROP_SVGRESET(
CSS_PROPERTY_CREATES_STACKING_CONTEXT |
CSS_PROPERTY_STORES_CALC,
"",
0,
VARIANT_HUO,
nullptr,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Custom)