1 /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* build (from code) lists of all supported CSS properties */
11 #include "mozilla/ArrayUtils.h"
13 // Do not consider properties not valid in style rules
14 #define CSS_PROP_LIST_EXCLUDE_NOT_IN_STYLE
16 // Need an extra level of macro nesting to force expansion of method_
17 // params before they get pasted.
18 #define STRINGIFY_METHOD(method_) #method_
26 const PropertyInfo gLonghandProperties
[] = {
28 #define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_
29 #define CSS_PROP_LONGHAND(name_, id_, method_, flags_, pref_, ...) \
30 {#name_, STRINGIFY_METHOD(method_), pref_},
32 #include "mozilla/ServoCSSPropList.h"
34 #undef CSS_PROP_LONGHAND
35 #undef CSS_PROP_PUBLIC_OR_PRIVATE
40 * These are the properties for which domName in the above list should
41 * be used. They're in the same order as the above list, with some
44 const char* gLonghandPropertiesWithDOMProp
[] = {
46 #define CSS_PROP_LIST_EXCLUDE_INTERNAL
47 #define CSS_PROP_LONGHAND(name_, ...) #name_,
49 #include "mozilla/ServoCSSPropList.h"
51 #undef CSS_PROP_LONGHAND
52 #undef CSS_PROP_LIST_EXCLUDE_INTERNAL
56 const PropertyInfo gShorthandProperties
[] = {
58 #define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_
59 #define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_) \
60 {#name_, STRINGIFY_METHOD(method_), pref_},
61 #define CSS_PROP_ALIAS(name_, aliasid_, id_, method_, flags_, pref_) \
62 {#name_, #method_, pref_},
64 #include "mozilla/ServoCSSPropList.h"
67 #undef CSS_PROP_SHORTHAND
68 #undef CSS_PROP_PUBLIC_OR_PRIVATE
72 /* see gLonghandPropertiesWithDOMProp */
73 const char* gShorthandPropertiesWithDOMProp
[] = {
75 #define CSS_PROP_LIST_EXCLUDE_INTERNAL
76 #define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_) #name_,
77 #define CSS_PROP_ALIAS(name_, aliasid_, id_, method_, flags_, pref_) #name_,
79 #include "mozilla/ServoCSSPropList.h"
82 #undef CSS_PROP_SHORTHAND
83 #undef CSS_PROP_LIST_EXCLUDE_INTERNAL
87 #undef STRINGIFY_METHOD
89 const char* gInaccessibleProperties
[] = {
90 // Don't print the properties that aren't accepted by the parser, per
91 // CSSParserImpl::ParseProperty
96 "-moz-default-appearance",
99 "-moz-script-level", // parsed by UA sheets only
101 "-moz-math-display", // parsed by UA sheets only
102 "-moz-top-layer", // parsed by UA sheets only
103 "-moz-min-font-size-ratio", // parsed by UA sheets only
104 "-moz-box-collapse", // chrome-only internal properties
105 "-moz-subtree-hidden-only-visually", // chrome-only internal properties
106 "-moz-user-focus", // chrome-only internal properties
107 "-moz-window-input-region-margin", // chrome-only internal properties
108 "-moz-window-opacity", // chrome-only internal properties
109 "-moz-window-transform", // chrome-only internal properties
110 "-moz-window-transform-origin", // chrome-only internal properties
111 "-moz-window-shadow", // chrome-only internal properties
114 inline int is_inaccessible(const char* aPropName
) {
115 for (unsigned j
= 0; j
< MOZ_ARRAY_LENGTH(gInaccessibleProperties
); ++j
) {
116 if (strcmp(aPropName
, gInaccessibleProperties
[j
]) == 0) return 1;
121 void print_array(const char* aName
, const PropertyInfo
* aProps
,
122 unsigned aPropsLength
, const char* const* aDOMProps
,
123 unsigned aDOMPropsLength
) {
124 printf("var %s = [\n", aName
);
127 unsigned j
= 0; // index into DOM prop list
128 for (unsigned i
= 0; i
< aPropsLength
; ++i
) {
129 const PropertyInfo
* p
= aProps
+ i
;
131 if (is_inaccessible(p
->propName
))
132 // inaccessible properties never have DOM props, so don't
133 // worry about incrementing j. The assertion below will
142 printf("\t{ name: \"%s\", prop: ", p
->propName
);
143 if (j
>= aDOMPropsLength
|| strcmp(p
->propName
, aDOMProps
[j
]) != 0)
147 if (strncmp(p
->domName
, "Moz", 3) == 0)
148 printf("\"%s\"", p
->domName
);
150 // lowercase the first letter
151 printf("\"%c%s\"", p
->domName
[0] + 32, p
->domName
+ 1);
154 printf(", pref: \"%s\"", p
->pref
);
159 if (j
!= aDOMPropsLength
) {
160 fprintf(stderr
, "Assertion failure %s:%d\n", __FILE__
, __LINE__
);
161 fprintf(stderr
, "j==%d, aDOMPropsLength == %d\n", j
, aDOMPropsLength
);
169 print_array("gLonghandProperties", gLonghandProperties
,
170 MOZ_ARRAY_LENGTH(gLonghandProperties
),
171 gLonghandPropertiesWithDOMProp
,
172 MOZ_ARRAY_LENGTH(gLonghandPropertiesWithDOMProp
));
173 print_array("gShorthandProperties", gShorthandProperties
,
174 MOZ_ARRAY_LENGTH(gShorthandProperties
),
175 gShorthandPropertiesWithDOMProp
,
176 MOZ_ARRAY_LENGTH(gShorthandPropertiesWithDOMProp
));