Bug 458861. Validate TrueType headers before activating downloaded font. r=roc, sr...
[wine-gecko.git] / layout / style / test / ListCSSProperties.cpp
blob5fdd00d51cb4e82175ae6bf5c78cb2046dfafdfa
1 /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is ListCSSProperties.
17 * The Initial Developer of the Original Code is the Mozilla Foundation.
18 * Portions created by the Initial Developer are Copyright (C) 2007
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (original author)
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* build (from code) lists of all supported CSS properties */
40 #include <stdio.h>
41 #include <string.h>
42 #include <stdlib.h>
44 struct PropertyInfo {
45 const char *propName;
46 const char *domName;
49 const PropertyInfo gLonghandProperties[] = {
51 #define CSS_PROP_NOTIMPLEMENTED(name_, id_, method_, flags_) \
52 { #name_, #method_ },
53 #define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, kwtable_) \
54 { #name_, #method_ },
56 #include "nsCSSPropList.h"
58 #undef CSS_PROP_NOTIMPLEMENTED
59 #undef CSS_PROP
64 * These are the properties for which domName in the above list should
65 * be used. They're in the same order as the above list, with some
66 * items skipped.
68 const char* gLonghandPropertiesWithDOMProp[] = {
70 #define CSS_PROP_LIST_EXCLUDE_INTERNAL
71 #define CSS_PROP_NOTIMPLEMENTED(name_, id_, method_, flags_) \
72 #name_,
73 #define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, kwtable_) \
74 #name_,
76 #include "nsCSSPropList.h"
78 #undef CSS_PROP_NOTIMPLEMENTED
79 #undef CSS_PROP
80 #undef CSS_PROP_LIST_EXCLUDE_INTERNAL
84 const PropertyInfo gShorthandProperties[] = {
86 #define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \
87 { #name_, #method_ },
89 #include "nsCSSPropList.h"
91 #undef CSS_PROP_SHORTHAND
95 /* see gLonghandPropertiesWithDOMProp */
96 const char* gShorthandPropertiesWithDOMProp[] = {
98 #define CSS_PROP_LIST_EXCLUDE_INTERNAL
99 #define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \
100 #name_,
102 #include "nsCSSPropList.h"
104 #undef CSS_PROP_SHORTHAND
105 #undef CSS_PROP_LIST_EXCLUDE_INTERNAL
110 #define ARRAY_LENGTH(a_) (sizeof(a_)/sizeof((a_)[0]))
112 const char *gInaccessibleProperties[] = {
113 // Don't print the properties that aren't accepted by the parser, per
114 // CSSParserImpl::ParseProperty
115 "-x-system-font",
116 "border-end-color-value",
117 "border-end-style-value",
118 "border-end-width-value",
119 "border-left-color-value",
120 "border-left-color-ltr-source",
121 "border-left-color-rtl-source",
122 "border-left-style-value",
123 "border-left-style-ltr-source",
124 "border-left-style-rtl-source",
125 "border-left-width-value",
126 "border-left-width-ltr-source",
127 "border-left-width-rtl-source",
128 "border-right-color-value",
129 "border-right-color-ltr-source",
130 "border-right-color-rtl-source",
131 "border-right-style-value",
132 "border-right-style-ltr-source",
133 "border-right-style-rtl-source",
134 "border-right-width-value",
135 "border-right-width-ltr-source",
136 "border-right-width-rtl-source",
137 "border-start-color-value",
138 "border-start-style-value",
139 "border-start-width-value",
140 "margin-end-value",
141 "margin-left-value",
142 "margin-right-value",
143 "margin-start-value",
144 "margin-left-ltr-source",
145 "margin-left-rtl-source",
146 "margin-right-ltr-source",
147 "margin-right-rtl-source",
148 "padding-end-value",
149 "padding-left-value",
150 "padding-right-value",
151 "padding-start-value",
152 "padding-left-ltr-source",
153 "padding-left-rtl-source",
154 "padding-right-ltr-source",
155 "padding-right-rtl-source",
156 "-moz-script-level", // parsed by UA sheets only
157 "-moz-script-size-multiplier",
158 "-moz-script-min-size"
161 inline int
162 is_inaccessible(const char* aPropName)
164 for (unsigned j = 0; j < ARRAY_LENGTH(gInaccessibleProperties); ++j) {
165 if (strcmp(aPropName, gInaccessibleProperties[j]) == 0)
166 return 1;
168 return 0;
171 void
172 print_array(const char *aName,
173 const PropertyInfo *aProps, unsigned aPropsLength,
174 const char * const * aDOMProps, unsigned aDOMPropsLength)
176 printf("var %s = [\n", aName);
178 int first = 1;
179 unsigned j = 0; // index into DOM prop list
180 for (unsigned i = 0; i < aPropsLength; ++i) {
181 const PropertyInfo *p = aProps + i;
183 if (is_inaccessible(p->propName))
184 // inaccessible properties never have DOM props, so don't
185 // worry about incrementing j. The assertion below will
186 // catch if they do.
187 continue;
189 if (first)
190 first = 0;
191 else
192 printf(",\n");
194 printf("\t{ name: \"%s\", prop: ", p->propName);
195 if (j >= aDOMPropsLength || strcmp(p->propName, aDOMProps[j]) != 0)
196 printf("null");
197 else {
198 ++j;
199 if (strncmp(p->domName, "Moz", 3) == 0)
200 printf("\"%s\"", p->domName);
201 else
202 // lowercase the first letter
203 printf("\"%c%s\"", p->domName[0] + 32, p->domName + 1);
205 printf("}");
208 if (j != aDOMPropsLength) {
209 fprintf(stderr, "Assertion failure %s:%d\n", __FILE__, __LINE__);
210 fprintf(stderr, "j==%d, aDOMPropsLength == %d\n", j, aDOMPropsLength);
211 exit(1);
214 printf("\n];\n\n");
218 main()
220 print_array("gLonghandProperties",
221 gLonghandProperties,
222 ARRAY_LENGTH(gLonghandProperties),
223 gLonghandPropertiesWithDOMProp,
224 ARRAY_LENGTH(gLonghandPropertiesWithDOMProp));
225 print_array("gShorthandProperties",
226 gShorthandProperties,
227 ARRAY_LENGTH(gShorthandProperties),
228 gShorthandPropertiesWithDOMProp,
229 ARRAY_LENGTH(gShorthandPropertiesWithDOMProp));
230 return 0;