1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Simplify init_dom_renderer, drop get_css_property

This commit is contained in:
Miciah Dashiel Butler Masters 2006-12-08 15:02:59 +00:00 committed by Miciah Dashiel Butler Masters
parent 04dd7199bc
commit 1442f551aa

View File

@ -84,18 +84,6 @@ init_template(struct screen_char *template, struct document_options *options,
options->color_flags, options->color_mode); options->color_flags, options->color_mode);
} }
static inline struct css_property *
get_css_property(struct list_head *list, enum css_property_type type)
{
struct css_property *property;
foreach (property, *list)
if (property->type == type)
return property;
return NULL;
}
/* Checks the user CSS for properties for each DOM node type name */ /* Checks the user CSS for properties for each DOM node type name */
static inline void static inline void
@ -160,39 +148,40 @@ init_dom_renderer(struct dom_renderer *renderer, struct document *document,
name->string, name->length); name->string, name->length);
if (selector) { if (selector) {
struct list_head *properties = &selector->properties;
struct css_property *property; struct css_property *property;
property = get_css_property(properties, CSS_PT_BACKGROUND_COLOR); foreach (property, selector->properties) {
if (!property) switch (property->type) {
property = get_css_property(properties, CSS_PT_BACKGROUND); case CSS_PT_BACKGROUND_COLOR:
case CSS_PT_BACKGROUND:
if (property && property->value_type == CSS_VT_COLOR) if (property->value_type == CSS_VT_COLOR)
background = property->value.color; background = property->value.color;
break;
property = get_css_property(properties, CSS_PT_COLOR); case CSS_PT_COLOR:
if (property) foreground = property->value.color; foreground = property->value.color;
break;
property = get_css_property(properties, CSS_PT_FONT_WEIGHT); case CSS_PT_FONT_WEIGHT:
if (property) {
if (property->value.font_attribute.add & AT_BOLD) if (property->value.font_attribute.add & AT_BOLD)
attr |= SCREEN_ATTR_BOLD; attr |= SCREEN_ATTR_BOLD;
} break;
case CSS_PT_FONT_STYLE:
property = get_css_property(properties, CSS_PT_FONT_STYLE);
if (property) {
if (property->value.font_attribute.add & AT_UNDERLINE) if (property->value.font_attribute.add & AT_UNDERLINE)
attr |= SCREEN_ATTR_UNDERLINE; attr |= SCREEN_ATTR_UNDERLINE;
if (property->value.font_attribute.add & AT_ITALIC) if (property->value.font_attribute.add & AT_ITALIC)
attr |= SCREEN_ATTR_ITALIC; attr |= SCREEN_ATTR_ITALIC;
break;
} case CSS_PT_TEXT_DECORATION:
property = get_css_property(properties, CSS_PT_TEXT_DECORATION);
if (property) {
if (property->value.font_attribute.add & AT_UNDERLINE) if (property->value.font_attribute.add & AT_UNDERLINE)
attr |= SCREEN_ATTR_UNDERLINE; attr |= SCREEN_ATTR_UNDERLINE;
break;
case CSS_PT_DISPLAY:
case CSS_PT_NONE:
case CSS_PT_TEXT_ALIGN:
case CSS_PT_WHITE_SPACE:
case CSS_PT_LAST:
break;
}
} }
} }