<style>
p
{
- color:red;
+ color:blue;
text-align:center;
}
</style>
return -1;
}
+
+int abc_css_use(abc_html_t* html, abc_obj_t* obj)
+{
+ if (!html->root || !obj)
+ return -EINVAL;
+
+ scf_list_t* l;
+ abc_obj_t* css;
+ abc_obj_t* label;
+ abc_obj_t* attr;
+
+ css = abc_obj_find_type(html->root, ABC_HTML_STYLE);
+ if (!css)
+ return 0;
+
+ label = abc_obj_find_type(css, obj->type);
+ if (label) {
+ for (l = scf_list_head(&label->attrs); l != scf_list_sentinel(&label->attrs); l = scf_list_next(l)) {
+ attr = scf_list_data(l, abc_obj_t, list);
+
+ abc_obj_set_attr(obj, attr->type, attr->value->data);
+ }
+ }
+
+ return 0;
+}
case ABC_HTML_AUDIO:
if (__html_add_controls(obj) < 0)
return -1;
- break;
+
default:
+ if (abc_css_use(html, obj) < 0)
+ return -1;
break;
};
int abc_html_parse(abc_html_t* html);
int abc_css_parse (abc_obj_t* css);
+int abc_css_use (abc_html_t* html, abc_obj_t* obj);
#endif
return root;
}
+abc_obj_t* abc_obj_find_type(abc_obj_t* root, int type)
+{
+ scf_list_t* l;
+ abc_obj_t* child;
+ abc_obj_t* obj;
+
+ if (type == root->type)
+ return root;
+
+ for (l = scf_list_head(&root->childs); l != scf_list_sentinel(&root->childs); l = scf_list_next(l)) {
+ child = scf_list_data(l, abc_obj_t, list);
+
+ obj = abc_obj_find_type(child, type);
+ if (obj)
+ return obj;
+ }
+
+ return NULL;
+}
+
int abc_obj_set_attr(abc_obj_t* obj, int key, const char* value)
{
scf_string_t* s;
abc_obj_t* abc_obj_get_attr (abc_obj_t* obj, int key);
abc_obj_t* abc_obj_find_attr(abc_obj_t* obj, int key);
+abc_obj_t* abc_obj_find_type(abc_obj_t* root, int type);
+
scf_string_t* abc_obj_to_string(abc_obj_t* obj);
#endif
CFILES += abc_render_audio.c
CFILES += ../html/abc_html.c
+CFILES += ../html/abc_css.c
CFILES += ../html/abc_obj.c
CFILES += ../html/abc_io_util.c
CFILES += ../html/abc_io_file.c
[ABC_HTML_PROGRESS] = abc_layout_empty,
[ABC_HTML_SCRIPT] = abc_layout_empty,
+ [ABC_HTML_STYLE] = abc_layout_empty,
};
int abc_layout_obj(abc_layout_t* layout, abc_obj_t* obj, int width, int height)
[ABC_HTML_PROGRESS] = &abc_render_empty,
[ABC_HTML_SCRIPT] = &abc_render_empty,
+ [ABC_HTML_STYLE] = &abc_render_empty,
};
int abc_renders_fini()
cairo_set_font_size(cr, atoi(attr->value->data));
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);
+ attr = abc_obj_find_attr(obj, ABC_HTML_ATTR_FONT_COLOR);
+ if (attr) {
+ if (!strcmp(attr->value->data, "red"))
+ cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 1.0);
+
+ else if (!strcmp(attr->value->data, "green"))
+ cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 1.0);
+
+ else if (!strcmp(attr->value->data, "blue"))
+ cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 1.0);
+ }
+
cairo_text_extents(cr, obj->text->data, &extents);
cairo_move_to (cr, extents.x_bearing, -extents.y_bearing);