#include "cssproperties.h"
struct props {
const char *name;
int id;
};
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static unsigned int
hash_prop (register const char *str, register unsigned int len)
{
static const unsigned short asso_values[] =
{
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 0, 860, 860, 860, 860,
860, 0, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 25, 35, 0,
0, 0, 160, 0, 30, 0, 0, 100, 0, 135,
158, 0, 10, 5, 0, 20, 0, 110, 15, 220,
95, 210, 10, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
860, 860, 860, 860, 860, 860
};
register int hval = len;
switch (hval)
{
default:
case 26:
hval += asso_values[(unsigned char)str[25]];
case 25:
hval += asso_values[(unsigned char)str[24]];
case 24:
hval += asso_values[(unsigned char)str[23]];
case 23:
hval += asso_values[(unsigned char)str[22]];
case 22:
hval += asso_values[(unsigned char)str[21]];
case 21:
hval += asso_values[(unsigned char)str[20]];
case 20:
hval += asso_values[(unsigned char)str[19]];
case 19:
hval += asso_values[(unsigned char)str[18]];
case 18:
hval += asso_values[(unsigned char)str[17]];
case 17:
hval += asso_values[(unsigned char)str[16]];
case 16:
hval += asso_values[(unsigned char)str[15]];
case 15:
hval += asso_values[(unsigned char)str[14]];
case 14:
hval += asso_values[(unsigned char)str[13]];
case 13:
hval += asso_values[(unsigned char)str[12]];
case 12:
hval += asso_values[(unsigned char)str[11]];
case 11:
hval += asso_values[(unsigned char)str[10]];
case 10:
hval += asso_values[(unsigned char)str[9]];
case 9:
hval += asso_values[(unsigned char)str[8]];
case 8:
hval += asso_values[(unsigned char)str[7]];
case 7:
hval += asso_values[(unsigned char)str[6]];
case 6:
hval += asso_values[(unsigned char)str[5]];
case 5:
hval += asso_values[(unsigned char)str[4]];
case 4:
hval += asso_values[(unsigned char)str[3]];
case 3:
hval += asso_values[(unsigned char)str[2]];
case 2:
hval += asso_values[(unsigned char)str[1]];
case 1:
hval += asso_values[(unsigned char)str[0]];
break;
}
return hval;
}
#ifdef __GNUC__
__inline
#endif
const struct props *
findProp (register const char *str, register unsigned int len)
{
enum
{
TOTAL_KEYWORDS = 121,
MIN_WORD_LENGTH = 3,
MAX_WORD_LENGTH = 26,
MIN_HASH_VALUE = 5,
MAX_HASH_VALUE = 859
};
static const struct props wordlist_prop[] =
{
{"color", CSS_PROP_COLOR},
{"top", CSS_PROP_TOP},
{"clip", CSS_PROP_CLIP},
{"clear", CSS_PROP_CLEAR},
{"size", CSS_PROP_SIZE},
{"right", CSS_PROP_RIGHT},
{"page", CSS_PROP_PAGE},
{"border", CSS_PROP_BORDER},
{"border-color", CSS_PROP_BORDER_COLOR},
{"border-top", CSS_PROP_BORDER_TOP},
{"border-top-color", CSS_PROP_BORDER_TOP_COLOR},
{"height", CSS_PROP_HEIGHT},
{"border-right", CSS_PROP_BORDER_RIGHT},
{"border-right-color", CSS_PROP_BORDER_RIGHT_COLOR},
{"border-collapse", CSS_PROP_BORDER_COLLAPSE},
{"scrollbar-3dlight-color", CSS_PROP_SCROLLBAR_3DLIGHT_COLOR},
{"cursor", CSS_PROP_CURSOR},
{"quotes", CSS_PROP_QUOTES},
{"left", CSS_PROP_LEFT},
{"direction", CSS_PROP_DIRECTION},
{"bottom", CSS_PROP_BOTTOM},
{"float", CSS_PROP_FLOAT},
{"scrollbar-highlight-color", CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR},
{"position", CSS_PROP_POSITION},
{"padding", CSS_PROP_PADDING},
{"border-left", CSS_PROP_BORDER_LEFT},
{"border-left-color", CSS_PROP_BORDER_LEFT_COLOR},
{"padding-top", CSS_PROP_PADDING_TOP},
{"border-bottom", CSS_PROP_BORDER_BOTTOM},
{"border-bottom-color", CSS_PROP_BORDER_BOTTOM_COLOR},
{"caption-side", CSS_PROP_CAPTION_SIDE},
{"scrollbar-track-color", CSS_PROP_SCROLLBAR_TRACK_COLOR},
{"letter-spacing", CSS_PROP_LETTER_SPACING},
{"line-height", CSS_PROP_LINE_HEIGHT},
{"padding-right", CSS_PROP_PADDING_RIGHT},
{"vertical-align", CSS_PROP_VERTICAL_ALIGN},
{"orphans", CSS_PROP_ORPHANS},
{"width", CSS_PROP_WIDTH},
{"list-style", CSS_PROP_LIST_STYLE},
{"border-spacing", CSS_PROP_BORDER_SPACING},
{"z-index", CSS_PROP_Z_INDEX},
{"display", CSS_PROP_DISPLAY},
{"outline", CSS_PROP_OUTLINE},
{"border-style", CSS_PROP_BORDER_STYLE},
{"outline-color", CSS_PROP_OUTLINE_COLOR},
{"scrollbar-face-color", CSS_PROP_SCROLLBAR_FACE_COLOR},
{"text-align", CSS_PROP_TEXT_ALIGN},
{"visibility", CSS_PROP_VISIBILITY},
{"border-top-style", CSS_PROP_BORDER_TOP_STYLE},
{"text-decoration", CSS_PROP_TEXT_DECORATION},
{"border-width", CSS_PROP_BORDER_WIDTH},
{"text-decoration-color", CSS_PROP_TEXT_DECORATION_COLOR},
{"counter-reset", CSS_PROP_COUNTER_RESET},
{"border-top-width", CSS_PROP_BORDER_TOP_WIDTH},
{"border-right-style", CSS_PROP_BORDER_RIGHT_STYLE},
{"unicode-bidi", CSS_PROP_UNICODE_BIDI},
{"white-space", CSS_PROP_WHITE_SPACE},
{"font", CSS_PROP_FONT},
{"content", CSS_PROP_CONTENT},
{"margin", CSS_PROP_MARGIN},
{"max-height", CSS_PROP_MAX_HEIGHT},
{"border-right-width", CSS_PROP_BORDER_RIGHT_WIDTH},
{"margin-top", CSS_PROP_MARGIN_TOP},
{"scrollbar-arrow-color", CSS_PROP_SCROLLBAR_ARROW_COLOR},
{"font-size", CSS_PROP_FONT_SIZE},
{"margin-right", CSS_PROP_MARGIN_RIGHT},
{"min-height", CSS_PROP_MIN_HEIGHT},
{"padding-left", CSS_PROP_PADDING_LEFT},
{"padding-bottom", CSS_PROP_PADDING_BOTTOM},
{"font-stretch", CSS_PROP_FONT_STRETCH},
{"empty-cells", CSS_PROP_EMPTY_CELLS},
{"page-break-inside", CSS_PROP_PAGE_BREAK_INSIDE},
{"page-break-after", CSS_PROP_PAGE_BREAK_AFTER},
{"scrollbar-shadow-color", CSS_PROP_SCROLLBAR_SHADOW_COLOR},
{"text-shadow", CSS_PROP_TEXT_SHADOW},
{"overflow", CSS_PROP_OVERFLOW},
{"page-break-before", CSS_PROP_PAGE_BREAK_BEFORE},
{"table-layout", CSS_PROP_TABLE_LAYOUT},
{"text-indent", CSS_PROP_TEXT_INDENT},
{"list-style-image", CSS_PROP_LIST_STYLE_IMAGE},
{"background", CSS_PROP_BACKGROUND},
{"border-left-style", CSS_PROP_BORDER_LEFT_STYLE},
{"background-color", CSS_PROP_BACKGROUND_COLOR},
{"word-spacing", CSS_PROP_WORD_SPACING},
{"border-bottom-style", CSS_PROP_BORDER_BOTTOM_STYLE},
{"list-style-position", CSS_PROP_LIST_STYLE_POSITION},
{"border-left-width", CSS_PROP_BORDER_LEFT_WIDTH},
{"widows", CSS_PROP_WIDOWS},
{"border-bottom-width", CSS_PROP_BORDER_BOTTOM_WIDTH},
{"background-repeat", CSS_PROP_BACKGROUND_REPEAT},
{"list-style-type", CSS_PROP_LIST_STYLE_TYPE},
{"margin-left", CSS_PROP_MARGIN_LEFT},
{"margin-bottom", CSS_PROP_MARGIN_BOTTOM},
{"outline-style", CSS_PROP_OUTLINE_STYLE},
{"max-width", CSS_PROP_MAX_WIDTH},
{"font-size-adjust", CSS_PROP_FONT_SIZE_ADJUST},
{"-khtml-opacity", CSS_PROP__KHTML_OPACITY},
{"scrollbar-darkshadow-color", CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR},
{"outline-width", CSS_PROP_OUTLINE_WIDTH},
{"-khtml-box-pack", CSS_PROP__KHTML_BOX_PACK},
{"min-width", CSS_PROP_MIN_WIDTH},
{"font-variant", CSS_PROP_FONT_VARIANT},
{"font-style", CSS_PROP_FONT_STYLE},
{"-khtml-box-orient", CSS_PROP__KHTML_BOX_ORIENT},
{"-khtml-box-direction", CSS_PROP__KHTML_BOX_DIRECTION},
{"font-weight", CSS_PROP_FONT_WEIGHT},
{"-khtml-box-lines", CSS_PROP__KHTML_BOX_LINES},
{"-khtml-box-align", CSS_PROP__KHTML_BOX_ALIGN},
{"background-image", CSS_PROP_BACKGROUND_IMAGE},
{"text-transform", CSS_PROP_TEXT_TRANSFORM},
{"marker-offset", CSS_PROP_MARKER_OFFSET},
{"background-position", CSS_PROP_BACKGROUND_POSITION},
{"-khtml-box-flex", CSS_PROP__KHTML_BOX_FLEX},
{"-khtml-box-ordinal-group", CSS_PROP__KHTML_BOX_ORDINAL_GROUP},
{"background-position-x", CSS_PROP_BACKGROUND_POSITION_X},
{"counter-increment", CSS_PROP_COUNTER_INCREMENT},
{"-khtml-box-flex-group", CSS_PROP__KHTML_BOX_FLEX_GROUP},
{"-khtml-flow-mode", CSS_PROP__KHTML_FLOW_MODE},
{"background-attachment", CSS_PROP_BACKGROUND_ATTACHMENT},
{"background-position-y", CSS_PROP_BACKGROUND_POSITION_Y},
{"font-family", CSS_PROP_FONT_FAMILY}
};
static const signed char lookup[] =
{
-1, -1, -1, -1, -1, 0, -1, -1, -1, -1,
-1, -1, -1, 1, 2, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3, -1, -1, -1, 4, 5, -1, -1, -1, 6,
-1, 7, -1, -1, -1, -1, -1, 8, -1, -1,
-1, -1, -1, -1, -1, 9, -1, -1, -1, -1,
-1, 10, -1, -1, -1, -1, 11, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 12, -1, -1,
-1, -1, -1, 13, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 14, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 15, -1, -1, 16, -1, -1, -1,
-1, 17, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 18, -1, -1, 19, -1, -1,
-1, -1, -1, -1, -1, -1, 20, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
21, -1, -1, -1, -1, 22, 23, -1, -1, -1,
24, -1, -1, -1, -1, -1, 25, -1, -1, -1,
-1, -1, 26, -1, 27, -1, -1, -1, 28, -1,
-1, -1, -1, -1, 29, 30, 31, 32, -1, 33,
-1, -1, -1, -1, -1, -1, 34, 35, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
36, -1, -1, -1, -1, 37, -1, -1, -1, -1,
38, -1, 39, -1, -1, -1, -1, -1, -1, -1,
40, -1, 41, -1, -1, 42, -1, 43, -1, -1,
-1, 44, -1, -1, -1, 45, -1, -1, 46, -1,
47, 48, -1, 49, -1, -1, -1, 50, -1, 51,
-1, 52, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 53, -1, 54, -1, 55, 56, -1, -1, -1,
-1, -1, 57, 58, 59, 60, -1, -1, -1, -1,
-1, -1, -1, 61, -1, -1, -1, -1, 62, -1,
-1, -1, -1, -1, -1, -1, 63, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 64, -1, -1,
65, -1, -1, 66, -1, 67, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 68, -1, -1,
69, -1, -1, -1, -1, -1, 70, -1, -1, -1,
71, -1, -1, -1, -1, -1, 72, 73, -1, -1,
-1, 74, -1, 75, -1, -1, -1, 76, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 77, -1, -1,
-1, -1, 78, -1, -1, -1, 79, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 80, -1,
-1, -1, 81, -1, 82, 83, -1, -1, -1, -1,
-1, -1, -1, -1, 84, -1, -1, 85, -1, -1,
-1, -1, 86, -1, -1, -1, 87, -1, -1, -1,
-1, -1, -1, -1, 88, -1, -1, -1, -1, -1,
89, -1, -1, -1, -1, 90, -1, -1, -1, 91,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 92, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 93, -1, -1, 94, -1, -1, -1, -1, 95,
-1, -1, -1, -1, 96, -1, 97, -1, -1, -1,
-1, 98, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 99, -1, -1, -1, -1,
-1, -1, 100, 101, -1, -1, -1, -1, 102, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
103, -1, -1, 104, -1, -1, -1, -1, -1, 105,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 106,
-1, -1, -1, -1, 107, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 108, -1, -1, 109, -1, -1,
-1, -1, -1, 110, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 111, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 112, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 113, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 114, -1, -1, -1, 115, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 116, -1, -1, -1, -1, 117, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 118, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 119, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 120
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash_prop (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register int index = lookup[key];
if (index >= 0)
{
register const char *s = wordlist_prop[index].name;
if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
return &wordlist_prop[index];
}
}
}
return 0;
}
static const char * const propertyList[] = {
"",
"background-color",
"background-image",
"background-repeat",
"background-attachment",
"background-position",
"background-position-x",
"background-position-y",
"border-collapse",
"border-spacing",
"border-top-color",
"border-right-color",
"border-bottom-color",
"border-left-color",
"border-top-style",
"border-right-style",
"border-bottom-style",
"border-left-style",
"border-top-width",
"border-right-width",
"border-bottom-width",
"border-left-width",
"bottom",
"-khtml-box-align",
"-khtml-box-direction",
"-khtml-box-flex",
"-khtml-box-flex-group",
"-khtml-box-lines",
"-khtml-box-ordinal-group",
"-khtml-box-orient",
"-khtml-box-pack",
"caption-side",
"clear",
"clip",
"color",
"content",
"counter-increment",
"counter-reset",
"cursor",
"direction",
"display",
"empty-cells",
"float",
"font-family",
"font-size",
"font-size-adjust",
"font-stretch",
"font-style",
"font-variant",
"font-weight",
"height",
"left",
"letter-spacing",
"line-height",
"list-style-image",
"list-style-position",
"list-style-type",
"margin-top",
"margin-right",
"margin-bottom",
"margin-left",
"marker-offset",
"max-height",
"max-width",
"min-height",
"min-width",
"-khtml-opacity",
"orphans",
"outline-color",
"outline-style",
"outline-width",
"overflow",
"padding-top",
"padding-right",
"padding-bottom",
"padding-left",
"page",
"page-break-after",
"page-break-before",
"page-break-inside",
"position",
"quotes",
"right",
"size",
"table-layout",
"text-align",
"text-decoration",
"text-decoration-color",
"text-indent",
"text-shadow",
"text-transform",
"top",
"unicode-bidi",
"vertical-align",
"visibility",
"white-space",
"widows",
"width",
"word-spacing",
"z-index",
"background",
"border",
"border-color",
"border-style",
"border-top",
"border-right",
"border-bottom",
"border-left",
"border-width",
"font",
"list-style",
"margin",
"outline",
"padding",
"scrollbar-face-color",
"scrollbar-shadow-color",
"scrollbar-highlight-color",
"scrollbar-3dlight-color",
"scrollbar-darkshadow-color",
"scrollbar-track-color",
"scrollbar-arrow-color",
"-khtml-flow-mode",
0
};
DOMString getPropertyName(unsigned short id)
{
if(id >= CSS_PROP_TOTAL || id == 0)
return DOMString();
else
return DOMString(propertyList[id]);
};