michael@0: /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* build (from code) lists of all supported CSS properties */ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: struct PropertyInfo { michael@0: const char *propName; michael@0: const char *domName; michael@0: const char *pref; michael@0: }; michael@0: michael@0: const PropertyInfo gLonghandProperties[] = { michael@0: michael@0: #define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_ michael@0: #define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, \ michael@0: stylestruct_, stylestructoffset_, animtype_) \ michael@0: { #name_, #method_, pref_ }, michael@0: michael@0: #include "nsCSSPropList.h" michael@0: michael@0: #undef CSS_PROP michael@0: #undef CSS_PROP_PUBLIC_OR_PRIVATE michael@0: michael@0: }; michael@0: michael@0: /* michael@0: * These are the properties for which domName in the above list should michael@0: * be used. They're in the same order as the above list, with some michael@0: * items skipped. michael@0: */ michael@0: const char* gLonghandPropertiesWithDOMProp[] = { michael@0: michael@0: #define CSS_PROP_LIST_EXCLUDE_INTERNAL michael@0: #define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, \ michael@0: stylestruct_, stylestructoffset_, animtype_) \ michael@0: #name_, michael@0: michael@0: #include "nsCSSPropList.h" michael@0: michael@0: #undef CSS_PROP michael@0: #undef CSS_PROP_LIST_EXCLUDE_INTERNAL michael@0: michael@0: }; michael@0: michael@0: const PropertyInfo gShorthandProperties[] = { michael@0: michael@0: #define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_ michael@0: // Need an extra level of macro nesting to force expansion of method_ michael@0: // params before they get pasted. michael@0: #define LISTCSSPROPERTIES_INNER_MACRO(method_) #method_ michael@0: #define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_) \ michael@0: { #name_, LISTCSSPROPERTIES_INNER_MACRO(method_), pref_ }, michael@0: michael@0: #include "nsCSSPropList.h" michael@0: michael@0: #undef CSS_PROP_SHORTHAND michael@0: #undef LISTCSSPROPERTIES_INNER_MACRO michael@0: #undef CSS_PROP_PUBLIC_OR_PRIVATE michael@0: michael@0: #define CSS_PROP_ALIAS(name_, id_, method_, pref_) \ michael@0: { #name_, #method_, pref_ }, michael@0: michael@0: #include "nsCSSPropAliasList.h" michael@0: michael@0: #undef CSS_PROP_ALIAS michael@0: michael@0: }; michael@0: michael@0: /* see gLonghandPropertiesWithDOMProp */ michael@0: const char* gShorthandPropertiesWithDOMProp[] = { michael@0: michael@0: #define CSS_PROP_LIST_EXCLUDE_INTERNAL michael@0: #define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_) \ michael@0: #name_, michael@0: michael@0: #include "nsCSSPropList.h" michael@0: michael@0: #undef CSS_PROP_SHORTHAND michael@0: #undef CSS_PROP_LIST_EXCLUDE_INTERNAL michael@0: michael@0: #define CSS_PROP_ALIAS(name_, id_, method_, pref_) \ michael@0: #name_, michael@0: michael@0: #include "nsCSSPropAliasList.h" michael@0: michael@0: #undef CSS_PROP_ALIAS michael@0: michael@0: }; michael@0: michael@0: michael@0: #define ARRAY_LENGTH(a_) (sizeof(a_)/sizeof((a_)[0])) michael@0: michael@0: const char *gInaccessibleProperties[] = { michael@0: // Don't print the properties that aren't accepted by the parser, per michael@0: // CSSParserImpl::ParseProperty michael@0: "-x-cols", michael@0: "-x-lang", michael@0: "-x-span", michael@0: "-x-system-font", michael@0: "-x-text-zoom", michael@0: "border-end-color-value", michael@0: "border-end-style-value", michael@0: "border-end-width-value", michael@0: "border-left-color-value", michael@0: "border-left-color-ltr-source", michael@0: "border-left-color-rtl-source", michael@0: "border-left-style-value", michael@0: "border-left-style-ltr-source", michael@0: "border-left-style-rtl-source", michael@0: "border-left-width-value", michael@0: "border-left-width-ltr-source", michael@0: "border-left-width-rtl-source", michael@0: "border-right-color-value", michael@0: "border-right-color-ltr-source", michael@0: "border-right-color-rtl-source", michael@0: "border-right-style-value", michael@0: "border-right-style-ltr-source", michael@0: "border-right-style-rtl-source", michael@0: "border-right-width-value", michael@0: "border-right-width-ltr-source", michael@0: "border-right-width-rtl-source", michael@0: "border-start-color-value", michael@0: "border-start-style-value", michael@0: "border-start-width-value", michael@0: "margin-end-value", michael@0: "margin-left-value", michael@0: "margin-right-value", michael@0: "margin-start-value", michael@0: "margin-left-ltr-source", michael@0: "margin-left-rtl-source", michael@0: "margin-right-ltr-source", michael@0: "margin-right-rtl-source", michael@0: "padding-end-value", michael@0: "padding-left-value", michael@0: "padding-right-value", michael@0: "padding-start-value", michael@0: "padding-left-ltr-source", michael@0: "padding-left-rtl-source", michael@0: "padding-right-ltr-source", michael@0: "padding-right-rtl-source", michael@0: "-moz-control-character-visibility", michael@0: "-moz-script-level", // parsed by UA sheets only michael@0: "-moz-script-size-multiplier", michael@0: "-moz-script-min-size", michael@0: "-moz-math-variant", michael@0: "-moz-math-display" // parsed by UA sheets only michael@0: }; michael@0: michael@0: inline int michael@0: is_inaccessible(const char* aPropName) michael@0: { michael@0: for (unsigned j = 0; j < ARRAY_LENGTH(gInaccessibleProperties); ++j) { michael@0: if (strcmp(aPropName, gInaccessibleProperties[j]) == 0) michael@0: return 1; michael@0: } michael@0: return 0; michael@0: } michael@0: michael@0: void michael@0: print_array(const char *aName, michael@0: const PropertyInfo *aProps, unsigned aPropsLength, michael@0: const char * const * aDOMProps, unsigned aDOMPropsLength) michael@0: { michael@0: printf("var %s = [\n", aName); michael@0: michael@0: int first = 1; michael@0: unsigned j = 0; // index into DOM prop list michael@0: for (unsigned i = 0; i < aPropsLength; ++i) { michael@0: const PropertyInfo *p = aProps + i; michael@0: michael@0: if (is_inaccessible(p->propName)) michael@0: // inaccessible properties never have DOM props, so don't michael@0: // worry about incrementing j. The assertion below will michael@0: // catch if they do. michael@0: continue; michael@0: michael@0: if (first) michael@0: first = 0; michael@0: else michael@0: printf(",\n"); michael@0: michael@0: printf("\t{ name: \"%s\", prop: ", p->propName); michael@0: if (j >= aDOMPropsLength || strcmp(p->propName, aDOMProps[j]) != 0) michael@0: printf("null"); michael@0: else { michael@0: ++j; michael@0: if (strncmp(p->domName, "Moz", 3) == 0) michael@0: printf("\"%s\"", p->domName); michael@0: else michael@0: // lowercase the first letter michael@0: printf("\"%c%s\"", p->domName[0] + 32, p->domName + 1); michael@0: } michael@0: if (p->pref[0]) { michael@0: printf(", pref: \"%s\"", p->pref); michael@0: } michael@0: printf(" }"); michael@0: } michael@0: michael@0: if (j != aDOMPropsLength) { michael@0: fprintf(stderr, "Assertion failure %s:%d\n", __FILE__, __LINE__); michael@0: fprintf(stderr, "j==%d, aDOMPropsLength == %d\n", j, aDOMPropsLength); michael@0: exit(1); michael@0: } michael@0: michael@0: printf("\n];\n\n"); michael@0: } michael@0: michael@0: int michael@0: main() michael@0: { michael@0: print_array("gLonghandProperties", michael@0: gLonghandProperties, michael@0: ARRAY_LENGTH(gLonghandProperties), michael@0: gLonghandPropertiesWithDOMProp, michael@0: ARRAY_LENGTH(gLonghandPropertiesWithDOMProp)); michael@0: print_array("gShorthandProperties", michael@0: gShorthandProperties, michael@0: ARRAY_LENGTH(gShorthandProperties), michael@0: gShorthandPropertiesWithDOMProp, michael@0: ARRAY_LENGTH(gShorthandPropertiesWithDOMProp)); michael@0: return 0; michael@0: }