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
--- a/devtools/shared/css/generated/properties-db.js
+++ b/devtools/shared/css/generated/properties-db.js
@@ -2877,17 +2877,16 @@ exports.CSS_PROPERTIES = {
"block-size",
"border-block-end-color",
"border-block-end-style",
"border-block-end-width",
"border-block-start-color",
"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",
"border-bottom-width",
"border-collapse",
"border-image-outset",
"border-image-repeat",
"border-image-slice",
@@ -2895,26 +2894,23 @@ exports.CSS_PROPERTIES = {
"border-image-width",
"border-inline-end-color",
"border-inline-end-style",
"border-inline-end-width",
"border-inline-start-color",
"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",
"border-top-width",
"bottom",
"-moz-box-align",
"box-decoration-break",
"-moz-box-direction",
@@ -4967,33 +4963,48 @@ exports.CSS_PROPERTIES = {
},
"clip": {
"isInherited": false,
"subproperties": [
"clip"
],
"supports": [],
"values": [
- "inherit",
- "initial",
+ "auto",
+ "inherit",
+ "initial",
+ "rect",
"unset"
]
},
"clip-path": {
"isInherited": false,
"subproperties": [
"clip-path"
],
"supports": [
11
],
"values": [
- "inherit",
- "initial",
- "unset"
+ "border-box",
+ "circle",
+ "content-box",
+ "ellipse",
+ "fill-box",
+ "inherit",
+ "initial",
+ "inset",
+ "margin-box",
+ "none",
+ "padding-box",
+ "polygon",
+ "stroke-box",
+ "unset",
+ "url",
+ "view-box"
]
},
"clip-rule": {
"isInherited": true,
"subproperties": [
"clip-rule"
],
"supports": [],
--- a/layout/inspector/InspectorUtils.cpp
+++ b/layout/inspector/InspectorUtils.cpp
@@ -449,16 +449,24 @@ static void GetKeywordsForProperty(const
nsTArray<nsString>& aArray)
{
if (nsCSSProps::IsShorthand(aProperty)) {
// Shorthand props have no keywords.
return;
}
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;
// These are extra -moz values which are added while rebuilding
// the properties db. These values are not relevant and are not
// documented on MDN, so filter these out
// eCSSKeyword_UNKNOWN is ignored because it indicates an
@@ -466,16 +474,26 @@ static void GetKeywordsForProperty(const
if (word != eCSSKeyword__moz_zoom_in && word != eCSSKeyword__moz_zoom_out &&
word != eCSSKeyword__moz_grab && word != eCSSKeyword__moz_grabbing &&
word != eCSSKeyword_UNKNOWN) {
InsertNoDuplicates(aArray,
NS_ConvertASCIItoUTF16(nsCSSKeywords::GetStringValue(word)));
}
}
}
+
+ // 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,
nsTArray<nsString>& aArray)
{
if (aParserVariant & VARIANT_COLOR) {
// GetKeywordsForProperty and GetOtherValuesForProperty assume aArray is sorted,
// and if aArray is not empty here, then it's not going to be sorted coming out.
@@ -669,17 +687,16 @@ PropertySupportsVariant(nsCSSPropertyID
break;
case eCSSProperty_border_spacing:
supported |= VARIANT_LENGTH;
break;
case eCSSProperty_content:
case eCSSProperty_cursor:
- case eCSSProperty_clip_path:
supported |= VARIANT_URL;
break;
case eCSSProperty_shape_outside:
supported |= VARIANT_IMAGE;
break;
case eCSSProperty_fill:
--- a/layout/inspector/tests/test_bug877690.html
+++ b/layout/inspector/tests/test_bug877690.html
@@ -191,16 +191,28 @@ function do_test() {
var expected = [ "inherit", "initial", "unset", "none", "calc", ...allColors ];
var values = InspectorUtils.getCSSValuesForProperty("text-shadow");
ok(testValues(values, expected), "property text-shadow's values");
var expected = [ "inherit", "initial", "unset", "inset", "none", "calc", ...allColors ];
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();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(do_test);
</script>
</head>
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -1357,30 +1357,30 @@ CSS_PROP_DISPLAY(
eStyleAnimType_Discrete)
CSS_PROP_EFFECTS(
clip,
clip,
Clip,
CSS_PROPERTY_PARSE_FUNCTION |
CSS_PROPERTY_UNITLESS_LENGTH_QUIRK,
"",
- 0,
+ VARIANT_AH,
nullptr,
offsetof(nsStyleEffects, mClip),
eStyleAnimType_Custom)
CSS_PROP_SVGRESET(
clip-path,
clip_path,
ClipPath,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_VALUE_PARSER_FUNCTION |
CSS_PROPERTY_CREATES_STACKING_CONTEXT |
CSS_PROPERTY_STORES_CALC,
"",
- 0,
+ VARIANT_HUO,
nullptr,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Custom)
CSS_PROP_SVG(
clip-rule,
clip_rule,
ClipRule,
CSS_PROPERTY_PARSE_VALUE,