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