1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/src/foxitlib.h"
8 #include "fde_cssdatatable.h"
9
FDE_CSSLengthToFloat(const FDE_CSSLENGTH & len,FX_FLOAT fPercentBase,FX_FLOAT & fResult)10 FX_BOOL FDE_CSSLengthToFloat(const FDE_CSSLENGTH& len,
11 FX_FLOAT fPercentBase,
12 FX_FLOAT& fResult) {
13 switch (len.GetUnit()) {
14 case FDE_CSSLENGTHUNIT_Point:
15 fResult = len.GetValue();
16 return TRUE;
17 case FDE_CSSLENGTHUNIT_Percent:
18 fResult = len.GetValue() * fPercentBase;
19 return TRUE;
20 default:
21 return FALSE;
22 }
23 }
FDE_CSSBoundaryToRect(IFDE_CSSBoundaryStyle * pBoundStyle,FX_FLOAT fContainerWidth,FX_BOOL bPadding,FX_BOOL bBorder,FX_BOOL bMargin)24 CFX_FloatRect FDE_CSSBoundaryToRect(IFDE_CSSBoundaryStyle* pBoundStyle,
25 FX_FLOAT fContainerWidth,
26 FX_BOOL bPadding,
27 FX_BOOL bBorder,
28 FX_BOOL bMargin) {
29 FXSYS_assert(pBoundStyle != NULL);
30 FX_FLOAT fResult;
31 const FDE_CSSRECT* pRect;
32 CFX_FloatRect rect(0, 0, 0, 0);
33 if (bPadding) {
34 pRect = pBoundStyle->GetPaddingWidth();
35 if (pRect != NULL) {
36 if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) {
37 rect.left += fResult;
38 }
39 if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) {
40 rect.top += fResult;
41 }
42 if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) {
43 rect.right += fResult;
44 }
45 if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) {
46 rect.bottom += fResult;
47 }
48 }
49 }
50 if (bBorder) {
51 pRect = pBoundStyle->GetBorderWidth();
52 if (pRect != NULL) {
53 if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) {
54 rect.left += fResult;
55 }
56 if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) {
57 rect.top += fResult;
58 }
59 if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) {
60 rect.right += fResult;
61 }
62 if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) {
63 rect.bottom += fResult;
64 }
65 }
66 }
67 if (bMargin) {
68 pRect = pBoundStyle->GetMarginWidth();
69 if (pRect != NULL) {
70 if (FDE_CSSLengthToFloat(pRect->left, fContainerWidth, fResult)) {
71 rect.left += fResult;
72 }
73 if (FDE_CSSLengthToFloat(pRect->top, fContainerWidth, fResult)) {
74 rect.top += fResult;
75 }
76 if (FDE_CSSLengthToFloat(pRect->right, fContainerWidth, fResult)) {
77 rect.right += fResult;
78 }
79 if (FDE_CSSLengthToFloat(pRect->bottom, fContainerWidth, fResult)) {
80 rect.bottom += fResult;
81 }
82 }
83 }
84 return rect;
85 }
FDE_CSSFontStyleToFDE(IFDE_CSSFontStyle * pFontStyle)86 FX_DWORD FDE_CSSFontStyleToFDE(IFDE_CSSFontStyle* pFontStyle) {
87 FXSYS_assert(pFontStyle != NULL);
88 FX_DWORD dwFontStyle = FX_FONTSTYLE_Normal;
89 if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) {
90 dwFontStyle |= FX_FONTSTYLE_Italic;
91 }
92 if (pFontStyle->GetFontWeight() >= 700) {
93 dwFontStyle |= FX_FONTSTYLE_Bold;
94 }
95 return dwFontStyle;
96 }
97 static const FDE_CSSPROPERTYTABLE g_FDE_CSSProperties[] = {
98 {FDE_CSSPROPERTY_WritingMode, L"writing-mode", 0x01878076,
99 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
100 {FDE_CSSPROPERTY_ColumnRuleWidth, L"column-rule-width", 0x0200FB00,
101 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
102 FDE_CSSVALUETYPE_MaybeNumber},
103 {FDE_CSSPROPERTY_BorderLeft, L"border-left", 0x04080036,
104 FDE_CSSVALUETYPE_Shorthand},
105 {FDE_CSSPROPERTY_ColumnRule, L"column-rule", 0x04C83DF3,
106 FDE_CSSVALUETYPE_Shorthand},
107 {FDE_CSSPROPERTY_Height, L"height", 0x05A5C519,
108 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
109 FDE_CSSVALUETYPE_MaybeNumber},
110 {FDE_CSSPROPERTY_CounterReset, L"counter-reset", 0x0894F9B0,
111 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
112 FDE_CSSVALUETYPE_MaybeNumber | FDE_CSSVALUETYPE_MaybeString},
113 {FDE_CSSPROPERTY_Content, L"content", 0x097BE91B,
114 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
115 FDE_CSSVALUETYPE_MaybeURI | FDE_CSSVALUETYPE_MaybeString},
116 {FDE_CSSPROPERTY_RubyPosition, L"ruby-position", 0x09ACD024,
117 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
118 {FDE_CSSPROPERTY_BackgroundColor, L"background-color", 0x09E8E8AC,
119 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
120 FDE_CSSVALUETYPE_MaybeColor},
121 {FDE_CSSPROPERTY_Width, L"width", 0x0A8A8F80,
122 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
123 FDE_CSSVALUETYPE_MaybeNumber},
124 {FDE_CSSPROPERTY_Src, L"src", 0x0BD37048,
125 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeURI},
126 {FDE_CSSPROPERTY_Top, L"top", 0x0BEDAF33, FDE_CSSVALUETYPE_Primitive |
127 FDE_CSSVALUETYPE_MaybeEnum |
128 FDE_CSSVALUETYPE_MaybeNumber},
129 {FDE_CSSPROPERTY_Margin, L"margin", 0x0CB016BE,
130 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
131 FDE_CSSVALUETYPE_MaybeNumber},
132 {FDE_CSSPROPERTY_BorderColor, L"border-color", 0x0CBB528A,
133 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
134 FDE_CSSVALUETYPE_MaybeColor},
135 {FDE_CSSPROPERTY_Widows, L"widows", 0x1026C59D,
136 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
137 {FDE_CSSPROPERTY_BorderBottomColor, L"border-bottom-color", 0x121E22EC,
138 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
139 FDE_CSSVALUETYPE_MaybeColor},
140 {FDE_CSSPROPERTY_TextIndent, L"text-indent", 0x169ADB74,
141 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
142 {FDE_CSSPROPERTY_Right, L"right", 0x193ADE3E,
143 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
144 FDE_CSSVALUETYPE_MaybeNumber},
145 {FDE_CSSPROPERTY_TextEmphasisStyle, L"text-emphasis-style", 0x20DBAF4A,
146 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
147 FDE_CSSVALUETYPE_MaybeString},
148 {FDE_CSSPROPERTY_PaddingLeft, L"padding-left", 0x228CF02F,
149 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
150 {FDE_CSSPROPERTY_ColumnWidth, L"column-width", 0x24C9AC9B,
151 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
152 FDE_CSSVALUETYPE_MaybeNumber},
153 {FDE_CSSPROPERTY_MarginLeft, L"margin-left", 0x297C5656,
154 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
155 FDE_CSSVALUETYPE_MaybeEnum},
156 {FDE_CSSPROPERTY_Border, L"border", 0x2A23349E, FDE_CSSVALUETYPE_Shorthand},
157 {FDE_CSSPROPERTY_BorderTop, L"border-top", 0x2B866ADE,
158 FDE_CSSVALUETYPE_Shorthand},
159 {FDE_CSSPROPERTY_RubyOverhang, L"ruby-overhang", 0x2CCA0D89,
160 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
161 {FDE_CSSPROPERTY_PageBreakBefore, L"page-break-before", 0x3119B36F,
162 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
163 {FDE_CSSPROPERTY_MaxHeight, L"max-height", 0x343597EC,
164 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
165 {FDE_CSSPROPERTY_MinWidth, L"min-width", 0x35832871,
166 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
167 {FDE_CSSPROPERTY_BorderLeftColor, L"border-left-color", 0x35C64022,
168 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
169 FDE_CSSVALUETYPE_MaybeColor},
170 {FDE_CSSPROPERTY_Bottom, L"bottom", 0x399F02B5,
171 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
172 FDE_CSSVALUETYPE_MaybeNumber},
173 {FDE_CSSPROPERTY_Quotes, L"quotes", 0x3D8C6A01,
174 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeString},
175 {FDE_CSSPROPERTY_MaxWidth, L"max-width", 0x3EA274F3,
176 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
177 {FDE_CSSPROPERTY_PaddingRight, L"padding-right", 0x3F616AC2,
178 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
179 {FDE_CSSPROPERTY_ListStyleImage, L"list-style-image", 0x42A8A86A,
180 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
181 FDE_CSSVALUETYPE_MaybeURI},
182 {FDE_CSSPROPERTY_WhiteSpace, L"white-space", 0x42F0429A,
183 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
184 {FDE_CSSPROPERTY_BorderBottom, L"border-bottom", 0x452CE780,
185 FDE_CSSVALUETYPE_Shorthand},
186 {FDE_CSSPROPERTY_ListStyleType, L"list-style-type", 0x48094789,
187 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
188 {FDE_CSSPROPERTY_WordBreak, L"word-break", 0x4D74A3CE,
189 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
190 {FDE_CSSPROPERTY_OverflowX, L"overflow-x", 0x4ECEBF99,
191 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
192 {FDE_CSSPROPERTY_OverflowY, L"overflow-y", 0x4ECEBF9A,
193 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
194 {FDE_CSSPROPERTY_BorderTopColor, L"border-top-color", 0x5109B8CA,
195 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
196 FDE_CSSVALUETYPE_MaybeColor},
197 {FDE_CSSPROPERTY_FontFamily, L"font-family", 0x574686E6,
198 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeString},
199 {FDE_CSSPROPERTY_Cursor, L"cursor", 0x59DFCA5E,
200 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
201 FDE_CSSVALUETYPE_MaybeString},
202 {FDE_CSSPROPERTY_RubyAlign, L"ruby-align", 0x6077BDFA,
203 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
204 {FDE_CSSPROPERTY_ColumnRuleColor, L"column-rule-color", 0x65DDFD9F,
205 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
206 FDE_CSSVALUETYPE_MaybeColor},
207 {FDE_CSSPROPERTY_FontWeight, L"font-weight", 0x6692F60C,
208 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
209 FDE_CSSVALUETYPE_MaybeNumber},
210 {FDE_CSSPROPERTY_BorderRightStyle, L"border-right-style", 0x6920DDA7,
211 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
212 {FDE_CSSPROPERTY_MinHeight, L"min-height", 0x6AAE312A,
213 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
214 {FDE_CSSPROPERTY_Color, L"color", 0x6E67921F,
215 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
216 FDE_CSSVALUETYPE_MaybeColor},
217 {FDE_CSSPROPERTY_LetterSpacing, L"letter-spacing", 0x70536102,
218 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
219 FDE_CSSVALUETYPE_MaybeNumber},
220 {FDE_CSSPROPERTY_EmptyCells, L"empty-cells", 0x7531528F,
221 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
222 {FDE_CSSPROPERTY_TextAlign, L"text-align", 0x7553F1BD,
223 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
224 {FDE_CSSPROPERTY_RubySpan, L"ruby-span", 0x76FCFCE1,
225 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
226 FDE_CSSVALUETYPE_MaybeFunction},
227 {FDE_CSSPROPERTY_Position, L"position", 0x814F82B5,
228 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
229 {FDE_CSSPROPERTY_BorderStyle, L"border-style", 0x82A4CD5C,
230 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum},
231 {FDE_CSSPROPERTY_BorderBottomStyle, L"border-bottom-style", 0x88079DBE,
232 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
233 {FDE_CSSPROPERTY_BorderCollapse, L"border-collapse", 0x8883C7FE,
234 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
235 {FDE_CSSPROPERTY_ColumnCount, L"column-count", 0x89936A64,
236 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
237 FDE_CSSVALUETYPE_MaybeNumber},
238 {FDE_CSSPROPERTY_BorderRightWidth, L"border-right-width", 0x8F5A6036,
239 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
240 FDE_CSSVALUETYPE_MaybeNumber},
241 {FDE_CSSPROPERTY_UnicodeBidi, L"unicode-bidi", 0x91670F6C,
242 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
243 {FDE_CSSPROPERTY_VerticalAlign, L"vertical-align", 0x934A87D2,
244 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
245 FDE_CSSVALUETYPE_MaybeNumber},
246 {FDE_CSSPROPERTY_PaddingTop, L"padding-top", 0x959D22B7,
247 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
248 {FDE_CSSPROPERTY_Columns, L"columns", 0x96FA5D81,
249 FDE_CSSVALUETYPE_Shorthand},
250 {FDE_CSSPROPERTY_Overflow, L"overflow", 0x97B76B54,
251 FDE_CSSVALUETYPE_Shorthand},
252 {FDE_CSSPROPERTY_TableLayout, L"table-layout", 0x9B1CB4B3,
253 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
254 {FDE_CSSPROPERTY_FontVariant, L"font-variant", 0x9C785779,
255 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
256 {FDE_CSSPROPERTY_ListStyle, L"list-style", 0x9E6C471A,
257 FDE_CSSVALUETYPE_Shorthand},
258 {FDE_CSSPROPERTY_BackgroundPosition, L"background-position", 0xA8846D22,
259 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
260 FDE_CSSVALUETYPE_MaybeNumber},
261 {FDE_CSSPROPERTY_BorderWidth, L"border-width", 0xA8DE4FEB,
262 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
263 FDE_CSSVALUETYPE_MaybeNumber},
264 {FDE_CSSPROPERTY_TextEmphasisColor, L"text-emphasis-color", 0xAAF23478,
265 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
266 FDE_CSSVALUETYPE_MaybeColor},
267 {FDE_CSSPROPERTY_BorderLeftStyle, L"border-left-style", 0xABAFBAF4,
268 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
269 {FDE_CSSPROPERTY_PageBreakInside, L"page-break-inside", 0xACB695F8,
270 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
271 {FDE_CSSPROPERTY_TextEmphasis, L"text-emphasis", 0xAD0E580C,
272 FDE_CSSVALUETYPE_Shorthand},
273 {FDE_CSSPROPERTY_BorderBottomWidth, L"border-bottom-width", 0xAE41204D,
274 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
275 FDE_CSSVALUETYPE_MaybeNumber},
276 {FDE_CSSPROPERTY_ColumnGap, L"column-gap", 0xB5C1BA73,
277 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
278 FDE_CSSVALUETYPE_MaybeNumber},
279 {FDE_CSSPROPERTY_Orphans, L"orphans", 0xB716467B,
280 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
281 {FDE_CSSPROPERTY_BorderRight, L"border-right", 0xB78E9EA9,
282 FDE_CSSVALUETYPE_Shorthand},
283 {FDE_CSSPROPERTY_FontSize, L"font-size", 0xB93956DF,
284 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
285 FDE_CSSVALUETYPE_MaybeNumber},
286 {FDE_CSSPROPERTY_PageBreakAfter, L"page-break-after", 0xBC358AEE,
287 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
288 {FDE_CSSPROPERTY_CaptionSide, L"caption-side", 0xC03F3560,
289 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
290 {FDE_CSSPROPERTY_BackgroundRepeat, L"background-repeat", 0xC2C2FDCE,
291 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
292 {FDE_CSSPROPERTY_BorderTopStyle, L"border-top-style", 0xC6F3339C,
293 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
294 {FDE_CSSPROPERTY_BorderSpacing, L"border-spacing", 0xC72030F0,
295 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber},
296 {FDE_CSSPROPERTY_TextTransform, L"text-transform", 0xC88EEA6E,
297 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
298 {FDE_CSSPROPERTY_FontStyle, L"font-style", 0xCB1950F5,
299 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
300 {FDE_CSSPROPERTY_Font, L"font", 0xCD308B77, FDE_CSSVALUETYPE_Shorthand},
301 {FDE_CSSPROPERTY_LineHeight, L"line-height", 0xCFCACE2E,
302 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
303 FDE_CSSVALUETYPE_MaybeNumber},
304 {FDE_CSSPROPERTY_MarginRight, L"margin-right", 0xD13C58C9,
305 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
306 FDE_CSSVALUETYPE_MaybeEnum},
307 {FDE_CSSPROPERTY_Float, L"float", 0xD1532876,
308 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
309 {FDE_CSSPROPERTY_BorderLeftWidth, L"border-left-width", 0xD1E93D83,
310 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
311 FDE_CSSVALUETYPE_MaybeNumber},
312 {FDE_CSSPROPERTY_Display, L"display", 0xD4224C36,
313 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
314 {FDE_CSSPROPERTY_Clear, L"clear", 0xD8ED1467,
315 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
316 {FDE_CSSPROPERTY_ColumnRuleStyle, L"column-rule-style", 0xDBC77871,
317 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
318 {FDE_CSSPROPERTY_TextCombine, L"text-combine", 0xDC5207CF,
319 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
320 FDE_CSSVALUETYPE_MaybeNumber},
321 {FDE_CSSPROPERTY_ListStylePosition, L"list-style-position", 0xE1A1DE3C,
322 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
323 {FDE_CSSPROPERTY_Visibility, L"visibility", 0xE29F5168,
324 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
325 {FDE_CSSPROPERTY_PaddingBottom, L"padding-bottom", 0xE555B3B9,
326 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber},
327 {FDE_CSSPROPERTY_BackgroundAttachment, L"background-attachment", 0xE77981F6,
328 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
329 {FDE_CSSPROPERTY_BackgroundImage, L"background-image", 0xE9AEB710,
330 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
331 FDE_CSSVALUETYPE_MaybeURI},
332 {FDE_CSSPROPERTY_LineBreak, L"line-break", 0xEA2D1D9A,
333 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
334 {FDE_CSSPROPERTY_Background, L"background", 0xEB49DD40,
335 FDE_CSSVALUETYPE_Shorthand},
336 {FDE_CSSPROPERTY_BorderTopWidth, L"border-top-width", 0xED2CB62B,
337 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
338 FDE_CSSVALUETYPE_MaybeNumber},
339 {FDE_CSSPROPERTY_WordSpacing, L"word-spacing", 0xEDA63BAE,
340 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
341 FDE_CSSVALUETYPE_MaybeNumber},
342 {FDE_CSSPROPERTY_BorderRightColor, L"border-right-color", 0xF33762D5,
343 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
344 FDE_CSSVALUETYPE_MaybeColor},
345 {FDE_CSSPROPERTY_CounterIncrement, L"counter-increment", 0xF4CFB1B2,
346 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum |
347 FDE_CSSVALUETYPE_MaybeNumber | FDE_CSSVALUETYPE_MaybeString},
348 {FDE_CSSPROPERTY_Left, L"left", 0xF5AD782B,
349 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum |
350 FDE_CSSVALUETYPE_MaybeNumber},
351 {FDE_CSSPROPERTY_TextDecoration, L"text-decoration", 0xF7C634BA,
352 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeEnum},
353 {FDE_CSSPROPERTY_Padding, L"padding", 0xF8C373F7,
354 FDE_CSSVALUETYPE_List | FDE_CSSVALUETYPE_MaybeNumber},
355 {FDE_CSSPROPERTY_MarginBottom, L"margin-bottom", 0xF93485A0,
356 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
357 FDE_CSSVALUETYPE_MaybeEnum},
358 {FDE_CSSPROPERTY_MarginTop, L"margin-top", 0xFE51DCFE,
359 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeNumber |
360 FDE_CSSVALUETYPE_MaybeEnum},
361 {FDE_CSSPROPERTY_Direction, L"direction", 0xFE746E61,
362 FDE_CSSVALUETYPE_Primitive | FDE_CSSVALUETYPE_MaybeEnum},
363 };
364 static const FDE_CSSPROPERTYVALUETABLE g_FDE_CSSPropertyValues[] = {
365 {FDE_CSSPROPERTYVALUE_Bolder, L"bolder", 0x009F1058},
366 {FDE_CSSPROPERTYVALUE_LowerLatin, L"lower-latin", 0x016014CE},
367 {FDE_CSSPROPERTYVALUE_Lowercase, L"lowercase", 0x02ACB805},
368 {FDE_CSSPROPERTYVALUE_LowerGreek, L"lower-greek", 0x03D81D64},
369 {FDE_CSSPROPERTYVALUE_Sesame, L"sesame", 0x0432ECDE},
370 {FDE_CSSPROPERTYVALUE_None, L"none", 0x048B6670},
371 {FDE_CSSPROPERTYVALUE_NwResize, L"nw-resize", 0x054B4BE4},
372 {FDE_CSSPROPERTYVALUE_WResize, L"w-resize", 0x0A2F8D76},
373 {FDE_CSSPROPERTYVALUE_Dot, L"dot", 0x0A48CB27},
374 {FDE_CSSPROPERTYVALUE_End, L"end", 0x0A631437},
375 {FDE_CSSPROPERTYVALUE_Ltr, L"ltr", 0x0B1B56D2},
376 {FDE_CSSPROPERTYVALUE_Pre, L"pre", 0x0B848587},
377 {FDE_CSSPROPERTYVALUE_Rtl, L"rtl", 0x0BB92C52},
378 {FDE_CSSPROPERTYVALUE_Sub, L"sub", 0x0BD37FAA},
379 {FDE_CSSPROPERTYVALUE_Top, L"top", 0x0BEDAF33},
380 {FDE_CSSPROPERTYVALUE_Visible, L"visible", 0x0F55D7EE},
381 {FDE_CSSPROPERTYVALUE_Filled, L"filled", 0x10827DD0},
382 {FDE_CSSPROPERTYVALUE_SwResize, L"sw-resize", 0x10B548E9},
383 {FDE_CSSPROPERTYVALUE_NoRepeat, L"no-repeat", 0x1235C18B},
384 {FDE_CSSPROPERTYVALUE_Default, L"default", 0x14DA2125},
385 {FDE_CSSPROPERTYVALUE_Transparent, L"transparent", 0x17B64DB2},
386 {FDE_CSSPROPERTYVALUE_Ridge, L"ridge", 0x18EBEE4B},
387 {FDE_CSSPROPERTYVALUE_Right, L"right", 0x193ADE3E},
388 {FDE_CSSPROPERTYVALUE_HorizontalTb, L"horizontal-tb", 0x1A66A86D},
389 {FDE_CSSPROPERTYVALUE_DistributeLetter, L"distribute-letter", 0x1EDBD75C},
390 {FDE_CSSPROPERTYVALUE_DoubleCircle, L"double-circle", 0x1FF082BA},
391 {FDE_CSSPROPERTYVALUE_Ruby, L"ruby", 0x20D66C02},
392 {FDE_CSSPROPERTYVALUE_Collapse, L"collapse", 0x2128D673},
393 {FDE_CSSPROPERTYVALUE_Normal, L"normal", 0x247CF3E9},
394 {FDE_CSSPROPERTYVALUE_Avoid, L"avoid", 0x24E684B3},
395 {FDE_CSSPROPERTYVALUE_UpperRoman, L"upper-roman", 0x28BAC2B6},
396 {FDE_CSSPROPERTYVALUE_Auto, L"auto", 0x2B35B6D9},
397 {FDE_CSSPROPERTYVALUE_Text, L"text", 0x2D08AF85},
398 {FDE_CSSPROPERTYVALUE_XSmall, L"x-small", 0x2D2FCAFE},
399 {FDE_CSSPROPERTYVALUE_Thin, L"thin", 0x2D574D53},
400 {FDE_CSSPROPERTYVALUE_Repeat, L"repeat", 0x306614A1},
401 {FDE_CSSPROPERTYVALUE_Small, L"small", 0x316A3739},
402 {FDE_CSSPROPERTYVALUE_NeResize, L"ne-resize", 0x31FD5E12},
403 {FDE_CSSPROPERTYVALUE_NoContent, L"no-content", 0x33A1C545},
404 {FDE_CSSPROPERTYVALUE_Outside, L"outside", 0x36DF693D},
405 {FDE_CSSPROPERTYVALUE_EResize, L"e-resize", 0x36E19FA4},
406 {FDE_CSSPROPERTYVALUE_TableRow, L"table-row", 0x3912A02D},
407 {FDE_CSSPROPERTYVALUE_Bottom, L"bottom", 0x399F02B5},
408 {FDE_CSSPROPERTYVALUE_Underline, L"underline", 0x3A0273A6},
409 {FDE_CSSPROPERTYVALUE_CjkIdeographic, L"cjk-ideographic", 0x3A641CC4},
410 {FDE_CSSPROPERTYVALUE_SeResize, L"se-resize", 0x3D675B17},
411 {FDE_CSSPROPERTYVALUE_Fixed, L"fixed", 0x3D7DEB10},
412 {FDE_CSSPROPERTYVALUE_Double, L"double", 0x3D98515B},
413 {FDE_CSSPROPERTYVALUE_Solid, L"solid", 0x40623B5B},
414 {FDE_CSSPROPERTYVALUE_RubyBaseGroup, L"ruby-base-group", 0x41014E84},
415 {FDE_CSSPROPERTYVALUE_OpenQuote, L"open-quote", 0x44A41E8D},
416 {FDE_CSSPROPERTYVALUE_Lighter, L"lighter", 0x45BEB7AF},
417 {FDE_CSSPROPERTYVALUE_LowerRoman, L"lower-roman", 0x5044D253},
418 {FDE_CSSPROPERTYVALUE_Strict, L"strict", 0x52F4EBD9},
419 {FDE_CSSPROPERTYVALUE_TableCaption, L"table-caption", 0x5325CD63},
420 {FDE_CSSPROPERTYVALUE_Oblique, L"oblique", 0x53EBDDB1},
421 {FDE_CSSPROPERTYVALUE_Decimal, L"decimal", 0x54034C2F},
422 {FDE_CSSPROPERTYVALUE_Loose, L"loose", 0x54D3A1E2},
423 {FDE_CSSPROPERTYVALUE_Hebrew, L"hebrew", 0x565792DD},
424 {FDE_CSSPROPERTYVALUE_Hidden, L"hidden", 0x573CB40C},
425 {FDE_CSSPROPERTYVALUE_Dashed, L"dashed", 0x58A3DD29},
426 {FDE_CSSPROPERTYVALUE_Embed, L"embed", 0x59C8F27D},
427 {FDE_CSSPROPERTYVALUE_TableRowGroup, L"table-row-group", 0x5A43BD07},
428 {FDE_CSSPROPERTYVALUE_TableColumn, L"table-column", 0x5E705DA3},
429 {FDE_CSSPROPERTYVALUE_Static, L"static", 0x5E7555E8},
430 {FDE_CSSPROPERTYVALUE_Outset, L"outset", 0x61236164},
431 {FDE_CSSPROPERTYVALUE_DecimalLeadingZero, L"decimal-leading-zero",
432 0x61DFC55D},
433 {FDE_CSSPROPERTYVALUE_KeepWords, L"keep-words", 0x63964801},
434 {FDE_CSSPROPERTYVALUE_KatakanaIroha, L"katakana-iroha", 0x65D7C91C},
435 {FDE_CSSPROPERTYVALUE_Super, L"super", 0x6A4F842F},
436 {FDE_CSSPROPERTYVALUE_Center, L"center", 0x6C51AFC1},
437 {FDE_CSSPROPERTYVALUE_TableHeaderGroup, L"table-header-group", 0x706103D8},
438 {FDE_CSSPROPERTYVALUE_Inside, L"inside", 0x709CB0FC},
439 {FDE_CSSPROPERTYVALUE_XxLarge, L"xx-large", 0x70BB1508},
440 {FDE_CSSPROPERTYVALUE_Triangle, L"triangle", 0x7524EDF6},
441 {FDE_CSSPROPERTYVALUE_RubyTextGroup, L"ruby-text-group", 0x78C2B98E},
442 {FDE_CSSPROPERTYVALUE_Circle, L"circle", 0x7ABEC0D2},
443 {FDE_CSSPROPERTYVALUE_Hiragana, L"hiragana", 0x7BF5E25B},
444 {FDE_CSSPROPERTYVALUE_RepeatX, L"repeat-x", 0x7C8F3226},
445 {FDE_CSSPROPERTYVALUE_RepeatY, L"repeat-y", 0x7C8F3227},
446 {FDE_CSSPROPERTYVALUE_Move, L"move", 0x7DA03417},
447 {FDE_CSSPROPERTYVALUE_HiraganaIroha, L"hiragana-iroha", 0x7EE863FB},
448 {FDE_CSSPROPERTYVALUE_RubyBase, L"ruby-base", 0x7FD1B1EA},
449 {FDE_CSSPROPERTYVALUE_Scroll, L"scroll", 0x84787AEF},
450 {FDE_CSSPROPERTYVALUE_Smaller, L"smaller", 0x849769F0},
451 {FDE_CSSPROPERTYVALUE_TableFooterGroup, L"table-footer-group", 0x85BDD97E},
452 {FDE_CSSPROPERTYVALUE_Baseline, L"baseline", 0x87436BA3},
453 {FDE_CSSPROPERTYVALUE_Separate, L"separate", 0x877C66B5},
454 {FDE_CSSPROPERTYVALUE_Armenian, L"armenian", 0x889BE4EB},
455 {FDE_CSSPROPERTYVALUE_Open, L"open", 0x8B90E1F2},
456 {FDE_CSSPROPERTYVALUE_Relative, L"relative", 0x8C995B5C},
457 {FDE_CSSPROPERTYVALUE_Thick, L"thick", 0x8CC35EB3},
458 {FDE_CSSPROPERTYVALUE_Justify, L"justify", 0x8D269CAE},
459 {FDE_CSSPROPERTYVALUE_Middle, L"middle", 0x947FA00F},
460 {FDE_CSSPROPERTYVALUE_Always, L"always", 0x959AB231},
461 {FDE_CSSPROPERTYVALUE_DistributeSpace, L"distribute-space", 0x97A20E58},
462 {FDE_CSSPROPERTYVALUE_LineEdge, L"line-edge", 0x9A845D2A},
463 {FDE_CSSPROPERTYVALUE_PreWrap, L"pre-wrap", 0x9D59588E},
464 {FDE_CSSPROPERTYVALUE_Medium, L"medium", 0xA084A381},
465 {FDE_CSSPROPERTYVALUE_NResize, L"n-resize", 0xA088968D},
466 {FDE_CSSPROPERTYVALUE_ListItem, L"list-item", 0xA32382B8},
467 {FDE_CSSPROPERTYVALUE_Show, L"show", 0xA66C10C1},
468 {FDE_CSSPROPERTYVALUE_Currentcolor, L"currentColor", 0xA7883922},
469 {FDE_CSSPROPERTYVALUE_NoCloseQuote, L"no-close-quote", 0xA79CBFFB},
470 {FDE_CSSPROPERTYVALUE_VerticalLr, L"vertical-lr", 0xA8673F65},
471 {FDE_CSSPROPERTYVALUE_VerticalRl, L"vertical-rl", 0xA8675E25},
472 {FDE_CSSPROPERTYVALUE_Pointer, L"pointer", 0xA90929C1},
473 {FDE_CSSPROPERTYVALUE_XxSmall, L"xx-small", 0xADE1FC76},
474 {FDE_CSSPROPERTYVALUE_Bold, L"bold", 0xB18313A1},
475 {FDE_CSSPROPERTYVALUE_Both, L"both", 0xB1833CAD},
476 {FDE_CSSPROPERTYVALUE_SmallCaps, L"small-caps", 0xB299428D},
477 {FDE_CSSPROPERTYVALUE_Katakana, L"katakana", 0xB421A4BC},
478 {FDE_CSSPROPERTYVALUE_After, L"after", 0xB6B44172},
479 {FDE_CSSPROPERTYVALUE_Horizontal, L"horizontal", 0xB7732DEA},
480 {FDE_CSSPROPERTYVALUE_Dotted, L"dotted", 0xB88652A4},
481 {FDE_CSSPROPERTYVALUE_Disc, L"disc", 0xBEBC18C3},
482 {FDE_CSSPROPERTYVALUE_Georgian, L"georgian", 0xBEF99E8C},
483 {FDE_CSSPROPERTYVALUE_Inline, L"inline", 0xC02D649F},
484 {FDE_CSSPROPERTYVALUE_Overline, L"overline", 0xC0EC9FA4},
485 {FDE_CSSPROPERTYVALUE_Wait, L"wait", 0xC1613BB5},
486 {FDE_CSSPROPERTYVALUE_BreakAll, L"break-all", 0xC3145BAB},
487 {FDE_CSSPROPERTYVALUE_UpperAlpha, L"upper-alpha", 0xC52D4A9F},
488 {FDE_CSSPROPERTYVALUE_Capitalize, L"capitalize", 0xC5321D46},
489 {FDE_CSSPROPERTYVALUE_Nowrap, L"nowrap", 0xC7994417},
490 {FDE_CSSPROPERTYVALUE_TextBottom, L"text-bottom", 0xC7D08D87},
491 {FDE_CSSPROPERTYVALUE_NoOpenQuote, L"no-open-quote", 0xC8CD7877},
492 {FDE_CSSPROPERTYVALUE_Groove, L"groove", 0xCB24A412},
493 {FDE_CSSPROPERTYVALUE_Progress, L"progress", 0xCD1D9835},
494 {FDE_CSSPROPERTYVALUE_Larger, L"larger", 0xCD3C409D},
495 {FDE_CSSPROPERTYVALUE_CloseQuote, L"close-quote", 0xCF8696D1},
496 {FDE_CSSPROPERTYVALUE_TableCell, L"table-cell", 0xCFB5E595},
497 {FDE_CSSPROPERTYVALUE_PreLine, L"pre-line", 0xD04FEDBC},
498 {FDE_CSSPROPERTYVALUE_Absolute, L"absolute", 0xD0B2D55F},
499 {FDE_CSSPROPERTYVALUE_InlineTable, L"inline-table", 0xD131F494},
500 {FDE_CSSPROPERTYVALUE_BidiOverride, L"bidi-override", 0xD161FDE5},
501 {FDE_CSSPROPERTYVALUE_InlineBlock, L"inline-block", 0xD26A8BD7},
502 {FDE_CSSPROPERTYVALUE_Inset, L"inset", 0xD6F23243},
503 {FDE_CSSPROPERTYVALUE_Crosshair, L"crosshair", 0xD6F8018E},
504 {FDE_CSSPROPERTYVALUE_UpperLatin, L"upper-latin", 0xD9D60531},
505 {FDE_CSSPROPERTYVALUE_Help, L"help", 0xDA002969},
506 {FDE_CSSPROPERTYVALUE_Hide, L"hide", 0xDA69395A},
507 {FDE_CSSPROPERTYVALUE_Uppercase, L"uppercase", 0xDAD595A8},
508 {FDE_CSSPROPERTYVALUE_SResize, L"s-resize", 0xDB3AADF2},
509 {FDE_CSSPROPERTYVALUE_Table, L"table", 0xDB9BE968},
510 {FDE_CSSPROPERTYVALUE_Blink, L"blink", 0xDC36E390},
511 {FDE_CSSPROPERTYVALUE_Block, L"block", 0xDCD480AB},
512 {FDE_CSSPROPERTYVALUE_Start, L"start", 0xE1D9D5AE},
513 {FDE_CSSPROPERTYVALUE_TableColumnGroup, L"table-column-group", 0xE2258EFD},
514 {FDE_CSSPROPERTYVALUE_Italic, L"italic", 0xE31D5396},
515 {FDE_CSSPROPERTYVALUE_LineThrough, L"line-through", 0xE4C5A276},
516 {FDE_CSSPROPERTYVALUE_KeepAll, L"keep-all", 0xE704A72B},
517 {FDE_CSSPROPERTYVALUE_LowerAlpha, L"lower-alpha", 0xECB75A3C},
518 {FDE_CSSPROPERTYVALUE_RunIn, L"run-in", 0xEEC930B9},
519 {FDE_CSSPROPERTYVALUE_Square, L"square", 0xEF85D351},
520 {FDE_CSSPROPERTYVALUE_XLarge, L"x-large", 0xF008E390},
521 {FDE_CSSPROPERTYVALUE_Large, L"large", 0xF4434FCB},
522 {FDE_CSSPROPERTYVALUE_Before, L"before", 0xF4FFCE73},
523 {FDE_CSSPROPERTYVALUE_Left, L"left", 0xF5AD782B},
524 {FDE_CSSPROPERTYVALUE_TextTop, L"text-top", 0xFCB58D45},
525 {FDE_CSSPROPERTYVALUE_RubyText, L"ruby-text", 0xFCC77174},
526 {FDE_CSSPROPERTYVALUE_NoDisplay, L"no-display", 0xFE482860},
527 };
528 static const FDE_CSSMEDIATYPETABLE g_FDE_CSSMediaTypes[] = {
529 {0xF09, 0x02}, {0x4880, 0x20}, {0x536A, 0x80},
530 {0x741D, 0x10}, {0x76ED, 0x08}, {0x7CFB, 0x01},
531 {0x9578, 0x04}, {0xC8E1, 0x40}, {0xD0F9, 0xFF},
532 };
533 static const FDE_CSSLENGTHUNITTABLE g_FDE_CSSLengthUnits[] = {
534 {0x0672, 3}, {0x067D, 4}, {0x1AF7, 8}, {0x2F7A, 7},
535 {0x3ED3, 10}, {0x3EE4, 9}, {0x3EE8, 5}, {0xFC30, 6},
536 };
537 static const FDE_CSSCOLORTABLE g_FDE_CSSColors[] = {
538 {0x031B47FE, 0xff000080}, {0x0BB8DF5B, 0xffff0000},
539 {0x0D82A78C, 0xff800000}, {0x2ACC82E8, 0xff00ffff},
540 {0x2D083986, 0xff008080}, {0x4A6A6195, 0xffc0c0c0},
541 {0x546A8EF3, 0xff808080}, {0x65C9169C, 0xffffa500},
542 {0x8422BB61, 0xffffffff}, {0x9271A558, 0xff800080},
543 {0xA65A3EE3, 0xffff00ff}, {0xB1345708, 0xff0000ff},
544 {0xB6D2CF1F, 0xff808000}, {0xD19B5E1C, 0xffffff00},
545 {0xDB64391D, 0xff000000}, {0xF616D507, 0xff00ff00},
546 {0xF6EFFF31, 0xff008000},
547 };
548 static const FDE_CSSPERSUDOTABLE g_FDE_CSSPersudoType[] = {
549 {FDE_CSSPERSUDO_After, L":after", 0x16EE1FEC},
550 {FDE_CSSPERSUDO_Before, L":before", 0x7DCDDE2D},
551 };
FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo)552 FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo) {
553 return (ePersudo < FDE_CSSPERSUDO_NONE) ? (g_FDE_CSSPersudoType + ePersudo)
554 : NULL;
555 }
FDE_GetCSSPropertyByName(const FX_WCHAR * pszName,int32_t iLength)556 FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const FX_WCHAR* pszName,
557 int32_t iLength) {
558 FXSYS_assert(pszName != NULL && iLength > 0);
559 FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE);
560 int32_t iEnd = FDE_CSSPROPERTY_MAX - 1;
561 int32_t iMid, iStart = 0;
562 FX_DWORD dwMid;
563 do {
564 iMid = (iStart + iEnd) / 2;
565 dwMid = g_FDE_CSSProperties[iMid].dwHash;
566 if (dwHash == dwMid) {
567 return g_FDE_CSSProperties + iMid;
568 } else if (dwHash > dwMid) {
569 iStart = iMid + 1;
570 } else {
571 iEnd = iMid - 1;
572 }
573 } while (iStart <= iEnd);
574 return NULL;
575 }
FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName)576 FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName) {
577 return (eName < FDE_CSSPROPERTY_MAX) ? (g_FDE_CSSProperties + eName) : NULL;
578 }
FDE_GetCSSPropertyValueByName(const FX_WCHAR * pszName,int32_t iLength)579 FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName(
580 const FX_WCHAR* pszName,
581 int32_t iLength) {
582 FXSYS_assert(pszName != NULL && iLength > 0);
583 FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE);
584 int32_t iEnd = FDE_CSSPROPERTYVALUE_MAX - 1;
585 int32_t iMid, iStart = 0;
586 FX_DWORD dwMid;
587 do {
588 iMid = (iStart + iEnd) / 2;
589 dwMid = g_FDE_CSSPropertyValues[iMid].dwHash;
590 if (dwHash == dwMid) {
591 return g_FDE_CSSPropertyValues + iMid;
592 } else if (dwHash > dwMid) {
593 iStart = iMid + 1;
594 } else {
595 iEnd = iMid - 1;
596 }
597 } while (iStart <= iEnd);
598 return NULL;
599 }
FDE_GetCSSPropertyValueByEnum(FDE_CSSPROPERTYVALUE eName)600 FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum(
601 FDE_CSSPROPERTYVALUE eName) {
602 return (eName < FDE_CSSPROPERTYVALUE_MAX) ? (g_FDE_CSSPropertyValues + eName)
603 : NULL;
604 }
FDE_GetCSSMediaTypeByName(const FX_WCHAR * pszName,int32_t iLength)605 FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName,
606 int32_t iLength) {
607 FXSYS_assert(pszName != NULL && iLength > 0);
608 FX_WORD wHash = (FX_WORD)FX_HashCode_String_GetW(pszName, iLength, TRUE);
609 int32_t iEnd =
610 sizeof(g_FDE_CSSMediaTypes) / sizeof(FDE_CSSMEDIATYPETABLE) - 1;
611 int32_t iMid, iStart = 0;
612 FX_WORD uMid;
613 do {
614 iMid = (iStart + iEnd) / 2;
615 uMid = g_FDE_CSSMediaTypes[iMid].wHash;
616 if (wHash == uMid) {
617 return g_FDE_CSSMediaTypes + iMid;
618 } else if (wHash > uMid) {
619 iStart = iMid + 1;
620 } else {
621 iEnd = iMid - 1;
622 }
623 } while (iStart <= iEnd);
624 return NULL;
625 }
FDE_GetCSSLengthUnitByName(const FX_WCHAR * pszName,int32_t iLength)626 FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName,
627 int32_t iLength) {
628 FXSYS_assert(pszName != NULL && iLength > 0);
629 FX_WORD wHash = (FX_WORD)FX_HashCode_String_GetW(pszName, iLength, TRUE);
630 int32_t iEnd =
631 sizeof(g_FDE_CSSLengthUnits) / sizeof(FDE_CSSLENGTHUNITTABLE) - 1;
632 int32_t iMid, iStart = 0;
633 FX_WORD wMid;
634 do {
635 iMid = (iStart + iEnd) / 2;
636 wMid = g_FDE_CSSLengthUnits[iMid].wHash;
637 if (wHash == wMid) {
638 return g_FDE_CSSLengthUnits + iMid;
639 } else if (wHash > wMid) {
640 iStart = iMid + 1;
641 } else {
642 iEnd = iMid - 1;
643 }
644 } while (iStart <= iEnd);
645 return NULL;
646 }
FDE_GetCSSColorByName(const FX_WCHAR * pszName,int32_t iLength)647 FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName,
648 int32_t iLength) {
649 FXSYS_assert(pszName != NULL && iLength > 0);
650 FX_DWORD dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE);
651 int32_t iEnd = sizeof(g_FDE_CSSColors) / sizeof(FDE_CSSCOLORTABLE) - 1;
652 int32_t iMid, iStart = 0;
653 FX_DWORD dwMid;
654 do {
655 iMid = (iStart + iEnd) / 2;
656 dwMid = g_FDE_CSSColors[iMid].dwHash;
657 if (dwHash == dwMid) {
658 return g_FDE_CSSColors + iMid;
659 } else if (dwHash > dwMid) {
660 iStart = iMid + 1;
661 } else {
662 iEnd = iMid - 1;
663 }
664 } while (iStart <= iEnd);
665 return NULL;
666 }
FDE_ParseCSSNumber(const FX_WCHAR * pszValue,int32_t iValueLen,FX_FLOAT & fValue,FDE_CSSPRIMITIVETYPE & eUnit)667 FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue,
668 int32_t iValueLen,
669 FX_FLOAT& fValue,
670 FDE_CSSPRIMITIVETYPE& eUnit) {
671 FXSYS_assert(pszValue != NULL && iValueLen > 0);
672 int32_t iUsedLen = 0;
673 fValue = FX_wcstof(pszValue, iValueLen, &iUsedLen);
674 if (iUsedLen <= 0) {
675 return FALSE;
676 }
677 iValueLen -= iUsedLen;
678 pszValue += iUsedLen;
679 eUnit = FDE_CSSPRIMITIVETYPE_Number;
680 if (iValueLen >= 1 && *pszValue == '%') {
681 eUnit = FDE_CSSPRIMITIVETYPE_Percent;
682 } else if (iValueLen == 2) {
683 FDE_LPCCSSLENGTHUNITTABLE pUnit = FDE_GetCSSLengthUnitByName(pszValue, 2);
684 if (pUnit != NULL) {
685 eUnit = (FDE_CSSPRIMITIVETYPE)pUnit->wValue;
686 }
687 }
688 return TRUE;
689 }
690
FDE_ParseCSSString(const FX_WCHAR * pszValue,int32_t iValueLen,int32_t & iOffset,int32_t & iLength)691 FX_BOOL FDE_ParseCSSString(const FX_WCHAR* pszValue,
692 int32_t iValueLen,
693 int32_t& iOffset,
694 int32_t& iLength) {
695 FXSYS_assert(pszValue != NULL && iValueLen > 0);
696 iOffset = 0;
697 iLength = iValueLen;
698 if (iValueLen >= 2) {
699 FX_WCHAR first = pszValue[0], last = pszValue[iValueLen - 1];
700 if ((first == '\"' && last == '\"') || (first == '\'' && last == '\'')) {
701 iOffset = 1, iLength -= 2;
702 }
703 }
704 return iValueLen > 0;
705 }
706
FDE_ParseCSSURI(const FX_WCHAR * pszValue,int32_t iValueLen,int32_t & iOffset,int32_t & iLength)707 FX_BOOL FDE_ParseCSSURI(const FX_WCHAR* pszValue,
708 int32_t iValueLen,
709 int32_t& iOffset,
710 int32_t& iLength) {
711 FXSYS_assert(pszValue != NULL && iValueLen > 0);
712 if (iValueLen < 6 || pszValue[iValueLen - 1] != ')' ||
713 FX_wcsnicmp(L"url(", pszValue, 4)) {
714 return FALSE;
715 }
716 if (FDE_ParseCSSString(pszValue + 4, iValueLen - 5, iOffset, iLength)) {
717 iOffset += 4;
718 return TRUE;
719 }
720 return FALSE;
721 }
722
FDE_ParseCSSColor(const FX_WCHAR * pszValue,int32_t iValueLen,FX_ARGB & dwColor)723 FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue,
724 int32_t iValueLen,
725 FX_ARGB& dwColor) {
726 FXSYS_assert(pszValue != NULL && iValueLen > 0);
727 if (*pszValue == '#') {
728 switch (iValueLen) {
729 case 4: {
730 uint8_t red = FX_Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[1]);
731 uint8_t green = FX_Hex2Dec((uint8_t)pszValue[2], (uint8_t)pszValue[2]);
732 uint8_t blue = FX_Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[3]);
733 dwColor = ArgbEncode(255, red, green, blue);
734 }
735 return TRUE;
736 case 7: {
737 uint8_t red = FX_Hex2Dec((uint8_t)pszValue[1], (uint8_t)pszValue[2]);
738 uint8_t green = FX_Hex2Dec((uint8_t)pszValue[3], (uint8_t)pszValue[4]);
739 uint8_t blue = FX_Hex2Dec((uint8_t)pszValue[5], (uint8_t)pszValue[6]);
740 dwColor = ArgbEncode(255, red, green, blue);
741 }
742 return TRUE;
743 }
744 } else if (iValueLen >= 10) {
745 if (pszValue[iValueLen - 1] != ')' || FX_wcsnicmp(L"rgb(", pszValue, 4)) {
746 return FALSE;
747 }
748 uint8_t rgb[3] = {0};
749 FX_FLOAT fValue;
750 FDE_CSSPRIMITIVETYPE eType;
751 CFDE_CSSValueListParser list(pszValue + 4, iValueLen - 5, ',');
752 for (int32_t i = 0; i < 3; ++i) {
753 if (!list.NextValue(eType, pszValue, iValueLen)) {
754 return FALSE;
755 }
756 if (eType != FDE_CSSPRIMITIVETYPE_Number) {
757 return FALSE;
758 }
759 if (!FDE_ParseCSSNumber(pszValue, iValueLen, fValue, eType)) {
760 return FALSE;
761 }
762 rgb[i] = eType == FDE_CSSPRIMITIVETYPE_Percent
763 ? FXSYS_round(fValue * 2.55f)
764 : FXSYS_round(fValue);
765 }
766 dwColor = ArgbEncode(255, rgb[0], rgb[1], rgb[2]);
767 return TRUE;
768 } else {
769 FDE_LPCCSSCOLORTABLE pColor = FDE_GetCSSColorByName(pszValue, iValueLen);
770 if (pColor != NULL) {
771 dwColor = pColor->dwValue;
772 return TRUE;
773 }
774 }
775 return FALSE;
776 }
777
CFDE_CSSValueList(IFX_MEMAllocator * pStaticStore,const CFDE_CSSValueArray & list)778 CFDE_CSSValueList::CFDE_CSSValueList(IFX_MEMAllocator* pStaticStore,
779 const CFDE_CSSValueArray& list) {
780 m_iCount = list.GetSize();
781 int32_t iByteCount = m_iCount * sizeof(IFDE_CSSValue*);
782 m_ppList = (IFDE_CSSValue**)pStaticStore->Alloc(iByteCount);
783 FXSYS_memcpy(m_ppList, list.GetData(), iByteCount);
784 }
NextValue(FDE_CSSPRIMITIVETYPE & eType,const FX_WCHAR * & pStart,int32_t & iLength)785 FX_BOOL CFDE_CSSValueListParser::NextValue(FDE_CSSPRIMITIVETYPE& eType,
786 const FX_WCHAR*& pStart,
787 int32_t& iLength) {
788 while (m_pCur < m_pEnd && (*m_pCur <= ' ' || *m_pCur == m_Separator)) {
789 ++m_pCur;
790 }
791 if (m_pCur >= m_pEnd) {
792 return FALSE;
793 }
794 eType = FDE_CSSPRIMITIVETYPE_Unknown;
795 pStart = m_pCur;
796 iLength = 0;
797 FX_WCHAR wch = *m_pCur;
798 if (wch == '#') {
799 iLength = SkipTo(' ');
800 if (iLength == 4 || iLength == 7) {
801 eType = FDE_CSSPRIMITIVETYPE_RGB;
802 }
803 } else if ((wch >= '0' && wch <= '9') || wch == '.' || wch == '-' ||
804 wch == '+') {
805 while (m_pCur < m_pEnd && (*m_pCur > ' ' && *m_pCur != m_Separator)) {
806 ++m_pCur;
807 }
808 iLength = m_pCur - pStart;
809 if (iLength > 0) {
810 eType = FDE_CSSPRIMITIVETYPE_Number;
811 }
812 } else if (wch == '\"' || wch == '\'') {
813 pStart++;
814 iLength = SkipTo(wch) - 1;
815 m_pCur++;
816 eType = FDE_CSSPRIMITIVETYPE_String;
817 } else if (m_pEnd - m_pCur > 5 && m_pCur[3] == '(') {
818 if (FX_wcsnicmp(L"url", m_pCur, 3) == 0) {
819 wch = m_pCur[4];
820 if (wch == '\"' || wch == '\'') {
821 pStart += 5;
822 iLength = SkipTo(wch) - 6;
823 m_pCur += 2;
824 } else {
825 pStart += 4;
826 iLength = SkipTo(')') - 4;
827 m_pCur++;
828 }
829 eType = FDE_CSSPRIMITIVETYPE_URI;
830 } else if (FX_wcsnicmp(L"rgb", m_pCur, 3) == 0) {
831 iLength = SkipTo(')') + 1;
832 m_pCur++;
833 eType = FDE_CSSPRIMITIVETYPE_RGB;
834 }
835 } else {
836 iLength = SkipTo(m_Separator, TRUE, TRUE);
837 eType = FDE_CSSPRIMITIVETYPE_String;
838 }
839 return m_pCur <= m_pEnd && iLength > 0;
840 }
SkipTo(FX_WCHAR wch,FX_BOOL bWSSeparator,FX_BOOL bBrContinue)841 int32_t CFDE_CSSValueListParser::SkipTo(FX_WCHAR wch,
842 FX_BOOL bWSSeparator,
843 FX_BOOL bBrContinue) {
844 const FX_WCHAR* pStart = m_pCur;
845 if (!bBrContinue) {
846 if (bWSSeparator)
847 while (++m_pCur<m_pEnd&& * m_pCur != wch&& * m_pCur> ' ')
848 ;
849 else
850 while (++m_pCur < m_pEnd && *m_pCur != wch)
851 ;
852 } else {
853 int32_t iBracketCount = 0;
854 if (bWSSeparator) {
855 while (m_pCur<m_pEnd&& * m_pCur != wch&& * m_pCur> ' ') {
856 if (*m_pCur == '(') {
857 iBracketCount++;
858 } else if (*m_pCur == ')') {
859 iBracketCount--;
860 }
861 m_pCur++;
862 }
863 } else {
864 while (m_pCur < m_pEnd && *m_pCur != wch) {
865 if (*m_pCur == '(') {
866 iBracketCount++;
867 } else if (*m_pCur == ')') {
868 iBracketCount--;
869 }
870 m_pCur++;
871 }
872 }
873 while (iBracketCount > 0 && m_pCur < m_pEnd) {
874 if (*m_pCur == ')') {
875 iBracketCount--;
876 }
877 m_pCur++;
878 }
879 }
880 return m_pCur - pStart;
881 }
882