From: yu.dongliang <18588496441@163.com> Date: Wed, 20 May 2026 16:37:00 +0000 (+0800) Subject: use abc_attr_t to save HTML attrs, abc_obj_t only save HTML objects, so can decrease... X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=4065695a515e71cb6a544809a9d8c7830339d3ae;p=abc.git use abc_attr_t to save HTML attrs, abc_obj_t only save HTML objects, so can decrease memory use --- diff --git a/examples/overflow.html b/examples/overflow.html index 55fcd84..54e5b71 100644 --- a/examples/overflow.html +++ b/examples/overflow.html @@ -9,7 +9,7 @@ div { height: 50px; border: 1px dotted black; padding: 25px; - overflow: visible; + overflow: scroll; scrollbar-width: 15px; scrollbar-color: orangeRed lightGray; } diff --git a/html/abc_css.c b/html/abc_css.c index 25aeac1..430b35c 100644 --- a/html/abc_css.c +++ b/html/abc_css.c @@ -133,7 +133,7 @@ static int __css_parse_str(abc_obj_t* css, scf_string_t* s, int (*end)(int c)) return tmp; } -static int __css_parse_value(abc_obj_t* css, abc_obj_t* attr) +static int __css_parse_value(abc_obj_t* css, abc_attr_t* attr) { scf_string_t* value = scf_string_alloc(); if (!value) @@ -182,8 +182,8 @@ static int __css_parse_attr2(abc_obj_t* css, abc_obj_t* obj, const html_attr_t* break; }; - scf_list_t* l; - abc_obj_t* attr; + scf_list_t* l; + abc_attr_t* attr; int i; int j; @@ -218,9 +218,6 @@ found: scf_string_free(key); key = NULL; - attr->line = css->text_line; - attr->pos = css->text_pos; - return __css_parse_value(css, attr); } @@ -499,7 +496,7 @@ int abc_css_parse(abc_obj_t* css) abc_char_t* c; abc_char_t* c2; abc_io_t* io = NULL; - abc_obj_t* href; + abc_attr_t* href; char* path; int n; @@ -607,7 +604,7 @@ int abc_css_parse(abc_obj_t* css) return ret; } -static void __css_background(abc_obj_t* obj, abc_obj_t* attr) +static void __css_background(abc_obj_t* obj, abc_attr_t* attr) { char* p0 = NULL; char* p1 = attr->value->data; @@ -702,7 +699,7 @@ static void __css_text_transform(abc_obj_t* obj, int case_flag) } } -static void __css_set_attr(abc_obj_t* obj, abc_obj_t* attr) +static void __css_set_attr(abc_obj_t* obj, abc_attr_t* attr) { switch (attr->type) { @@ -785,8 +782,8 @@ static int __css_set_pse_dynamic(abc_obj_t* obj, abc_obj_t* pse) static void __css_merge(abc_obj_t* dst, abc_obj_t* src) { - abc_obj_t* s; - abc_obj_t* d; + abc_attr_t* s; + abc_attr_t* d; int i; for (i = 0; i < sizeof(src->attrs) / sizeof(src->attrs[0]); i++) { @@ -887,7 +884,7 @@ int abc_css_merge(abc_html_t* html, abc_obj_t* css) return 0; } -static abc_obj_t* __css_filter_pse(abc_obj_t* current, abc_obj_t* pse) +static abc_obj_t* __css_filter_pse(abc_obj_t* current, abc_attr_t* pse) { scf_list_t* l; abc_obj_t* parent = current->parent; @@ -918,7 +915,7 @@ static abc_obj_t* __css_select_by_key(abc_obj_t* css, abc_obj_t* current, scf_ve { scf_list_t* l; abc_obj_t* tmp; - abc_obj_t* pse; + abc_attr_t* pse; pse_link_t* pseLink; assert(next >= 0 && next < vec->size); @@ -1026,8 +1023,8 @@ static abc_obj_t* __css_select_by_attr(abc_obj_t* css, abc_obj_t* current, scf_v { scf_list_t* l; abc_obj_t* tmp; - abc_obj_t* attr; - abc_obj_t* pse; + abc_attr_t* attr; + abc_attr_t* pse; pse_link_t* pseLink; assert(next >= 0 && next < vec->size); @@ -1239,41 +1236,44 @@ int abc_css_use(abc_html_t* html, abc_obj_t* obj) if (!html || !obj) return -EINVAL; - if (!html->css) - return 0; - scf_list_t* l; + abc_attr_t* attr; abc_obj_t* css; - abc_obj_t* attr; - for (l = scf_list_head(&html->css->childs); l != scf_list_sentinel(&html->css->childs); l = scf_list_next(l)) { - css = scf_list_data(l, abc_obj_t, list); + if (html->css) { + for (l = scf_list_head(&html->css->childs); l != scf_list_sentinel(&html->css->childs); l = scf_list_next(l)) { + css = scf_list_data(l, abc_obj_t, list); - switch (css->type) - { - case ABC_CSS_ID: - case ABC_CSS_CLASS: - case ABC_CSS_PSE_CLASS: - case ABC_CSS_PSE_ELEMENT: - case ABC_CSS_COMBINATOR: - __css_use_complex(css, obj); - break; + switch (css->type) + { + case ABC_CSS_ID: + case ABC_CSS_CLASS: + case ABC_CSS_PSE_CLASS: + case ABC_CSS_PSE_ELEMENT: + case ABC_CSS_COMBINATOR: + __css_use_complex(css, obj); + break; - default: - if (css->type == obj->type) - abc_obj_set_css(obj, css); - break; - }; + default: + if (css->type == obj->type) + abc_obj_set_css(obj, css); + break; + }; + } } // for inline css below - css = abc_obj_get_attr(obj, ABC_HTML_ATTR_STYLE); + attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_STYLE); - if (css && css->value && css->value->len > 0) + if (attr && attr->value && attr->value->len > 0) { html_label_t* label = __html_find_label2(obj->type); abc_io_t* io = abc_io_array[ABC_PROTO_STR]; + css = abc_obj_alloc(obj->file, obj->line, obj->pos, ABC_HTML_STYLE); + if (!css) + return -ENOMEM; + css->io.proto = io->proto; css->io.priv = NULL; css->io.open = io->open; @@ -1284,14 +1284,18 @@ int abc_css_use(abc_html_t* html, abc_obj_t* obj) css->text_line = 1; css->text_pos = 0; - int ret = io->open(&css->io, css->value->data); - if (ret < 0) + int ret = io->open(&css->io, attr->value->data); + if (ret < 0) { + abc_obj_free(css); return ret; + } ret = __css_parse_attr(css, css, label->attrs, label->n_attrs); io->close(&css->io); - if (ret < 0 && EOF != ret) + if (ret < 0 && EOF != ret) { + abc_obj_free(css); return ret; + } int i; for (i = 0; i < sizeof(css->attrs) / sizeof(css->attrs[0]); i++) { @@ -1300,10 +1304,9 @@ int abc_css_use(abc_html_t* html, abc_obj_t* obj) continue; __css_set_attr(obj, attr); - - abc_obj_free(attr); - css->attrs[i] = NULL; } + + abc_obj_free(css); } return 0; @@ -1311,7 +1314,7 @@ int abc_css_use(abc_html_t* html, abc_obj_t* obj) void abc_obj_set_css(abc_obj_t* obj, abc_obj_t* css) { - abc_obj_t* attr; + abc_attr_t* attr; int i; for (i = 0; i < sizeof(css->attrs) / sizeof(css->attrs[0]); i++) { diff --git a/html/abc_css_border.c b/html/abc_css_border.c index ab68fb4..00f836c 100644 --- a/html/abc_css_border.c +++ b/html/abc_css_border.c @@ -141,7 +141,7 @@ int abc_css_margin(abc_obj_t* obj) double g = 0.0; double b = 0.0; - abc_obj_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_MARGIN); + abc_attr_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_MARGIN); if (attr) margin = atoi(attr->value->data); diff --git a/html/abc_css_length.c b/html/abc_css_length.c index 2a4f479..26e650d 100644 --- a/html/abc_css_length.c +++ b/html/abc_css_length.c @@ -71,7 +71,7 @@ next: int abc_css_width(abc_obj_t* obj, int width, int margin) { - abc_obj_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_WIDTH); + abc_attr_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_WIDTH); if (attr && attr->value && attr->value->len > 0) { @@ -89,7 +89,7 @@ int abc_css_width(abc_obj_t* obj, int width, int margin) int abc_css_height(abc_obj_t* obj, int height, int margin) { - abc_obj_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_HEIGHT); + abc_attr_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_HEIGHT); if (attr && attr->value && attr->value->len > 0) { diff --git a/html/abc_css_position.c b/html/abc_css_position.c index 0c06da7..f3dc5ea 100644 --- a/html/abc_css_position.c +++ b/html/abc_css_position.c @@ -150,6 +150,17 @@ int abc_css_overflow(const uint8_t* str) return ABC_OVERFLOW_VISIBLE; } +int abc_css_scrollbar_width(const uint8_t* str) +{ + if (!__html_strcmp(str, "thin") || !__html_strcmp(str, "auto")) + return 15; + + else if (!__html_strcmp(str, "none")) + return 0; + + return atoi(str); +} + void abc_overflow_show(int* x, int* y, int* w, int* h, int mask_x, int mask_y, int mask_w, int mask_h) { #define CSS_OVERFLOW_SHOW(px, pw, x2, x3) \ diff --git a/html/abc_html.c b/html/abc_html.c index f10fb09..ca596fe 100644 --- a/html/abc_html.c +++ b/html/abc_html.c @@ -563,23 +563,23 @@ int __html_add_attr(abc_obj_t* obj, int type, char** names, const char* value, i if (type < ABC_HTML_ATTR_ID || type >= ABC_HTML_CSS_NB) return -EINVAL; - abc_obj_t* attr = abc_obj_alloc(NULL, 0, 0, type); + abc_attr_t* attr = calloc(1, sizeof(abc_attr_t)); if (!attr) return -ENOMEM; - attr->keys = names; - attr->value = scf_string_cstr(value); if (!attr->value) { - abc_obj_free(attr); + free(attr); return -ENOMEM; } + attr->type = type; + attr->keys = names; attr->flags = flags; int i = type - ABC_HTML_ATTR_ID; if (obj->attrs[i]) - abc_obj_free(obj->attrs[i]); + abc_attr_free(obj->attrs[i]); obj->attrs[i] = attr; return 0; @@ -618,9 +618,8 @@ static int __html_add_controls(abc_obj_t* obj) static int __html_load_attrs(abc_obj_t* obj, html_attr_t* attrs, int n_attrs) { - scf_list_t* l; - abc_obj_t* attr; - + scf_list_t* l; + abc_attr_t* attr; int ret; int i; @@ -656,7 +655,7 @@ int abc_html_post(abc_html_t** pp, abc_html_t* form, abc_obj_t* submit) scf_string_t* url; scf_string_t* content; abc_html_t* html; - abc_obj_t* action; + abc_attr_t* action; abc_io_t* io; int n; @@ -972,7 +971,7 @@ static int __html_parse_text(abc_html_t* html, abc_obj_t* obj) return __html_parse_end(html, obj); } -static int __html_parse_value(abc_html_t* html, abc_obj_t* attr) +static int __html_parse_value(abc_html_t* html, abc_attr_t* attr) { scf_string_t* value = scf_string_alloc(); if (!value) @@ -1082,7 +1081,7 @@ static int __html_parse_attr2(abc_html_t* html, abc_obj_t* obj, const html_attr_ free(c); c = NULL; - abc_obj_t* attr; + abc_attr_t* attr; int i; int j; @@ -1108,15 +1107,6 @@ found: scf_string_free(key); key = NULL; - assert(!attr->file); - - attr->file = scf_string_clone(html->file); - if (!attr->file) - return -ENOMEM; - - attr->line = html->n_lines; - attr->pos = html->pos; - return __html_parse_value(html, attr); } @@ -1289,11 +1279,10 @@ static int __html_run_js(abc_html_t* html, abc_obj_t* obj) static int __html_parse_obj(abc_html_t* html, abc_char_t* c) { - html_label_t* label; - abc_obj_t* obj; - abc_obj_t* type; - - scf_string_t* key = scf_string_cstr_len(c->utf8, c->len); + html_label_t* label; + abc_obj_t* obj; + abc_attr_t* type; + scf_string_t* key = scf_string_cstr_len(c->utf8, c->len); html->pos += c->len; free(c); diff --git a/html/abc_html.h b/html/abc_html.h index 4180674..be8c1ba 100644 --- a/html/abc_html.h +++ b/html/abc_html.h @@ -68,6 +68,9 @@ int abc_css_height(abc_obj_t* obj, int height, int margin); int abc_css_position(const uint8_t* str); int abc_css_overflow(const uint8_t* str); +int abc_css_scrollbar_width(const uint8_t* str); +int abc_css_scrollbar_color(double thumb[3], double track[3], const uint8_t* str); + void abc_overflow_show(int* x, int* y, int* w, int* h, int mask_x, int mask_y, int mask_w, int mask_h); #endif diff --git a/html/abc_obj.c b/html/abc_obj.c index ea0c89a..3a27037 100644 --- a/html/abc_obj.c +++ b/html/abc_obj.c @@ -55,6 +55,11 @@ void abc_obj_free(abc_obj_t* obj) if (obj->av_filter) abc_filter_close(obj->av_filter, 0); #endif + int i; + for (i = 0; i < sizeof(obj->attrs) / sizeof(obj->attrs[0]); i++) { + if (obj->attrs[i]) + abc_attr_free(obj->attrs[i]); + } scf_list_clear(&obj->childs, abc_obj_t, list, abc_obj_free); scf_list_clear(&obj->css_pse_rules, abc_obj_t, list, abc_obj_free); @@ -64,6 +69,16 @@ void abc_obj_free(abc_obj_t* obj) } } +void abc_attr_free(abc_attr_t* attr) +{ + if (attr) { + if (attr->value) + scf_string_free(attr->value); + + free(attr); + } +} + void abc_dfs_update_xy(abc_obj_t* root, int dx, int dy) { scf_list_t* l; @@ -122,6 +137,17 @@ abc_obj_t* abc_obj_find_type(abc_obj_t* root, int type) return NULL; } +int abc_attr_cmp_keys(abc_attr_t* attr, const char* name, size_t len) +{ + int i; + for (i = 0; attr->keys[i]; i++) { + + if (!__html_strncmp(attr->keys[i], name, len)) + return 0; + } + return -1; +} + int abc_obj_cmp_keys(abc_obj_t* obj, const char* name, size_t len) { int i; @@ -135,8 +161,8 @@ int abc_obj_cmp_keys(abc_obj_t* obj, const char* name, size_t len) int abc_obj_copy_attrs(abc_obj_t* dst, abc_obj_t* src) { - abc_obj_t* attr; - abc_obj_t* copy; + abc_attr_t* attr; + abc_attr_t* copy; int i; for (i = 0; i < sizeof(src->attrs) / sizeof(src->attrs[0]); i++) { @@ -144,21 +170,22 @@ int abc_obj_copy_attrs(abc_obj_t* dst, abc_obj_t* src) if (!attr) continue; - copy = abc_obj_alloc(attr->file, attr->line, attr->pos, attr->type); + copy = calloc(1, sizeof(abc_attr_t)); if (!copy) return -ENOMEM; copy->value = scf_string_clone(attr->value); if (!copy->value) { - abc_obj_free(copy); + abc_attr_free(copy); return -ENOMEM; } + copy->type = attr->type; copy->keys = attr->keys; copy->flags = attr->flags; if (dst->attrs[i]) - abc_obj_free(dst->attrs[i]); + abc_attr_free(dst->attrs[i]); dst->attrs[i] = copy; } @@ -169,7 +196,7 @@ int abc_obj_copy_attrs(abc_obj_t* dst, abc_obj_t* src) int abc_obj_set_attr(abc_obj_t* obj, int key, const char* value, size_t len) { scf_string_t* s; - abc_obj_t* attr; + abc_attr_t* attr; if (key < ABC_HTML_ATTR_ID || key >= ABC_HTML_CSS_NB) return -EINVAL; @@ -187,27 +214,23 @@ int abc_obj_set_attr(abc_obj_t* obj, int key, const char* value, size_t len) return 0; } -abc_obj_t* abc_obj_get_attr2(abc_obj_t* obj, const char* key, int len) +abc_attr_t* abc_obj_get_attr2(abc_obj_t* obj, const char* key, int len) { - abc_obj_t* attr; int i; - for (i = 0; i < sizeof(obj->attrs) / sizeof(obj->attrs[0]); i++) { - attr = obj->attrs[i]; + abc_attr_t* attr = obj->attrs[i]; - if (attr && !abc_obj_cmp_keys(attr, key, len)) + if (attr && !abc_attr_cmp_keys(attr, key, len)) return attr; } return NULL; } -abc_obj_t* abc_obj_find_attr(abc_obj_t* obj, int key) +abc_attr_t* abc_obj_find_attr(abc_obj_t* obj, int key) { - abc_obj_t* attr; - while (obj) { - attr = abc_obj_get_attr(obj, key); + abc_attr_t* attr = abc_obj_get_attr(obj, key); if (attr && attr->value && attr->value->len > 0) return attr; @@ -231,8 +254,8 @@ void abc_css_print(abc_obj_t* obj) else if (obj->keys) printf("%s ", obj->keys[0]); - pse_link_t* pseLink; - abc_obj_t* attr; + pse_link_t* pseLink; + abc_attr_t* attr; int i; printf("{\n"); @@ -259,11 +282,22 @@ void abc_css_print(abc_obj_t* obj) printf("}\n"); } +void abc_attr_print(abc_attr_t* attr) +{ + if (attr && attr->value && attr->value->len > 0) + { + if (!(ABC_HTML_FLAG_SHOW & attr->flags)) + return; + + printf(" %s=\"%s\"", attr->keys[0], attr->value->data); + } +} + void abc_obj_print(abc_obj_t* obj) { - scf_list_t* l; - abc_obj_t* attr; - abc_obj_t* child; + scf_list_t* l; + abc_attr_t* attr; + abc_obj_t* child; if (!obj) return; @@ -271,10 +305,7 @@ void abc_obj_print(abc_obj_t* obj) if (!(ABC_HTML_FLAG_SHOW & obj->flags)) return; - if (obj->value) { - if (obj->value->len > 0) - printf(" %s=\"%s\"", obj->keys[0], obj->value->data); - } else if (obj->keys) + if (obj->keys) printf("<%s", obj->keys[0]); int i; @@ -284,15 +315,13 @@ void abc_obj_print(abc_obj_t* obj) continue; if (ABC_HTML_FLAG_SHOW & attr->flags) - abc_obj_print(attr); + abc_attr_print(attr); } - if (!obj->value) { - if (obj->flags & ABC_HTML_FLAG_SINGLE) - printf(" />\n"); - else if (obj->keys) - printf(">\n"); - } + if (obj->flags & ABC_HTML_FLAG_SINGLE) + printf(" />\n"); + else if (obj->keys) + printf(">\n"); if (obj->text) printf("%s\n", obj->text->data); @@ -329,42 +358,47 @@ void abc_obj_print(abc_obj_t* obj) } } -static int __abc_obj_to_string(abc_obj_t* obj, scf_string_t* s) +static int __abc_attr_to_string(abc_attr_t* attr, scf_string_t* s) { - scf_list_t* l; - abc_obj_t* attr; - abc_obj_t* child; - - int ret; - - if (!obj) + if (!attr || !attr->value) return 0; - if (!(ABC_HTML_FLAG_SHOW & obj->flags)) + if (!(ABC_HTML_FLAG_SHOW & attr->flags)) return 0; - if (obj->value) { - ret = scf_string_cat_cstr(s, " "); - if (ret < 0) - return ret; + int ret = scf_string_cat_cstr(s, " "); + if (ret < 0) + return ret; - ret = scf_string_cat_cstr(s, obj->keys[0]); - if (ret < 0) - return ret; + ret = scf_string_cat_cstr(s, attr->keys[0]); + if (ret < 0) + return ret; - ret = scf_string_cat_cstr(s, "=\""); - if (ret < 0) - return ret; + ret = scf_string_cat_cstr(s, "=\""); + if (ret < 0) + return ret; - ret = scf_string_cat(s, obj->value); - if (ret < 0) - return ret; + ret = scf_string_cat(s, attr->value); + if (ret < 0) + return ret; - ret = scf_string_cat_cstr(s, "\""); - if (ret < 0) - return ret; + return scf_string_cat_cstr(s, "\""); +} - } else if (obj->keys) { +static int __abc_obj_to_string(abc_obj_t* obj, scf_string_t* s) +{ + scf_list_t* l; + abc_attr_t* attr; + abc_obj_t* child; + int ret; + + if (!obj) + return 0; + + if (!(ABC_HTML_FLAG_SHOW & obj->flags)) + return 0; + + if (obj->keys) { ret = scf_string_cat_cstr(s, "<"); if (ret < 0) return ret; @@ -381,24 +415,22 @@ static int __abc_obj_to_string(abc_obj_t* obj, scf_string_t* s) continue; if (ABC_HTML_FLAG_SHOW & attr->flags) { - ret = __abc_obj_to_string(attr, s); + ret = __abc_attr_to_string(attr, s); if (ret < 0) return ret; } } - if (!obj->value) { - if (obj->flags & ABC_HTML_FLAG_SINGLE) { + if (obj->flags & ABC_HTML_FLAG_SINGLE) { - ret = scf_string_cat_cstr(s, " />\n"); - if (ret < 0) - return ret; + ret = scf_string_cat_cstr(s, " />\n"); + if (ret < 0) + return ret; - } else if (obj->keys) { - ret = scf_string_cat_cstr(s, ">\n"); - if (ret < 0) - return ret; - } + } else if (obj->keys) { + ret = scf_string_cat_cstr(s, ">\n"); + if (ret < 0) + return ret; } if (obj->text) { @@ -542,7 +574,7 @@ static const char* roman[] = {"m","cm", "d","cd", "c","xc", "l","xl","x","ix","v scf_string_t* abc_ol_list_style(abc_obj_t* obj, int num) { - abc_obj_t* attr = abc_obj_find_attr(obj, ABC_CSS_LIST_STYLE_TYPE); + abc_attr_t* attr = abc_obj_find_attr(obj, ABC_CSS_LIST_STYLE_TYPE); if (attr) { const char* p = attr->value->data; @@ -561,3 +593,41 @@ scf_string_t* abc_ol_list_style(abc_obj_t* obj, int num) return __li_style_number(num, 10, '0'); } + +static int __obj_scroll_xy(int* position, int move, int thumb, int track, int content_out) +{ + int range = track - thumb; + int min = thumb / 2; + int max = track - min; + + if (*position < min) + *position = min; + if (*position > max) + *position = max; + + if (move < min - *position) + move = min - *position; + if (move > max - *position) + move = max - *position; + + assert(move >= -range && move <= range); + + *position += move; + + int diff = -(*position - min) * content_out / range; + return diff; +} + +int abc_obj_scroll_y(abc_obj_t* obj, int thumb, int track, int move) +{ + int content_out = obj->content_h - obj->h; + + return __obj_scroll_xy(&obj->scroll_y, move, thumb, track, content_out); +} + +int abc_obj_scroll_x(abc_obj_t* obj, int thumb, int track, int move) +{ + int content_out = obj->content_w - obj->w; + + return __obj_scroll_xy(&obj->scroll_x, move, thumb, track, content_out); +} diff --git a/html/abc_obj.h b/html/abc_obj.h index f2d5715..591bf93 100644 --- a/html/abc_obj.h +++ b/html/abc_obj.h @@ -7,6 +7,7 @@ #include"abc_io.h" typedef struct abc_obj_s abc_obj_t; +typedef struct abc_attr_s abc_attr_t; typedef struct abc_text_s abc_text_t; typedef struct pse_link_s pse_link_t; @@ -223,6 +224,17 @@ struct pse_link_s #define ABC_HTML_FLAG_SINGLE 2 #define ABC_HTML_FLAG_SHOW 4 +struct abc_attr_s +{ + int type; + uint32_t flags; + + char** keys; + scf_string_t* value; + + abc_obj_t* parent; +}; + struct abc_obj_s { int type; @@ -238,7 +250,7 @@ struct abc_obj_s int n_childs; int index; - abc_obj_t* attrs[ABC_HTML_CSS_NB - ABC_HTML_ATTR_ID]; + abc_attr_t* attrs[ABC_HTML_CSS_NB - ABC_HTML_ATTR_ID]; void* gtk_builder; abc_filter_t* av_filter; @@ -309,6 +321,8 @@ struct abc_obj_s abc_obj_t* abc_obj_alloc(scf_string_t* file, int line, int pos, int type); void abc_obj_free (abc_obj_t* obj); +void abc_attr_free(abc_attr_t* attr); + abc_obj_t* abc_obj_find (abc_obj_t* root, int x, int y); void abc_obj_print(abc_obj_t* obj); @@ -318,18 +332,20 @@ int abc_obj_copy_attrs(abc_obj_t* dst, abc_obj_t* src); void abc_obj_set_css (abc_obj_t* obj, abc_obj_t* css); int abc_obj_set_attr (abc_obj_t* obj, int key, const char* value, size_t len); -abc_obj_t* abc_obj_get_attr2(abc_obj_t* obj, const char* key, int len); -abc_obj_t* abc_obj_find_attr(abc_obj_t* obj, int key); +abc_attr_t* abc_obj_get_attr2(abc_obj_t* obj, const char* key, int len); +abc_attr_t* abc_obj_find_attr(abc_obj_t* obj, int key); abc_obj_t* abc_obj_find_type(abc_obj_t* root, int type); -void abc_dfs_update_xy(abc_obj_t* root, int dx, int dy); +void abc_dfs_update_xy(abc_obj_t* root, int dx, int dy); +int abc_obj_scroll_y (abc_obj_t* obj, int thumb, int track, int move); +int abc_obj_scroll_x (abc_obj_t* obj, int thumb, int track, int move); scf_string_t* abc_obj_to_string(abc_obj_t* obj); scf_string_t* abc_ol_list_style(abc_obj_t* obj, int num); -static inline abc_obj_t* abc_obj_get_attr(abc_obj_t* obj, int key) +static inline abc_attr_t* abc_obj_get_attr(abc_obj_t* obj, int key) { if (key < ABC_HTML_ATTR_ID || key >= ABC_HTML_CSS_NB) return NULL; diff --git a/ui/__render_bg_image.c b/ui/__render_bg_image.c index eab0589..ba0325b 100644 --- a/ui/__render_bg_image.c +++ b/ui/__render_bg_image.c @@ -61,7 +61,7 @@ static int __render_fini_bg_image(abc_render_t* render) static int __render_draw_bg_image(abc_render_t* render, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_BG_IMAGE); + abc_attr_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_BG_IMAGE); if (!attr) return 0; if (!attr->value || attr->value->len <= 0) diff --git a/ui/__render_border.c b/ui/__render_border.c index 125d9d8..25404c3 100644 --- a/ui/__render_border.c +++ b/ui/__render_border.c @@ -88,6 +88,8 @@ static int __render_fini_border(abc_render_t* render) static int __render_draw_border(abc_render_t* render, abc_obj_t* obj, int width, int height) { + abc_obj_t* parent = obj->parent; + if (0 == program) __init_program(&program, vert_shader, frag_shader); @@ -101,9 +103,9 @@ static int __render_draw_border(abc_render_t* render, abc_obj_t* obj, int width, double fgColor[3] = {0.0, 0.0, 0.0}; double bgColor[4] = {0.0, 0.0, 0.0, 0.0}; - abc_obj_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_BG_COLOR); + abc_attr_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_BG_COLOR); if (attr && attr->value->len > 0) { - bgColor[4] = 1.0; + bgColor[3] = 1.0; abc_css_color(bgColor, bgColor + 1, bgColor + 2, attr->value->data, attr->value->len); } @@ -130,35 +132,31 @@ static int __render_draw_border(abc_render_t* render, abc_obj_t* obj, int width, obj->view_w = w; obj->view_h = h; - abc_obj_t* parent = obj->parent; + attr = abc_obj_find_attr(obj, ABC_CSS_OVERFLOW); + if (attr) + obj->overflow_type = abc_css_overflow(attr->value->data); - if (parent && (x < parent->view_x - || y < parent->view_y - || x + w > parent->view_x + parent->view_w - || y + h > parent->view_y + parent->view_h)) { + int scroll_flag = 0; + switch (obj->overflow_type) + { + case ABC_OVERFLOW_SCROLL: + case ABC_OVERFLOW_AUTO: + scroll_flag = 1; - attr = abc_obj_find_attr(obj, ABC_CSS_OVERFLOW); - if (attr) - obj->overflow_type = abc_css_overflow(attr->value->data); + case ABC_OVERFLOW_HIDDEN: + if (parent && (x < parent->view_x + || y < parent->view_y + || x + w > parent->view_x + parent->view_w + || y + h > parent->view_y + parent->view_h)) { - switch (obj->overflow_type) - { - case ABC_OVERFLOW_HIDDEN: abc_overflow_show(&obj->view_x, &obj->view_y, &obj->view_w, &obj->view_h, parent->view_x, parent->view_y, parent->view_w, parent->view_h); - - scf_logw("x: %d, y: %d, w: %d, h: %d, obj: x: %d, y: %d, w: %d, h: %d, parent: x: %d, y: %d, w: %d, h: %d\n", - x, y, w, h, - obj->view_x, obj->view_y, obj->view_w, obj->view_h, - parent->view_x, parent->view_y, parent->view_w, parent->view_h); - break; - case ABC_OVERFLOW_SCROLL: - break; - default: - break; - }; - } + } + break; + default: + break; + }; float mvp[16]; __compute_mvp(mvp, 0, 0, 0); @@ -196,13 +194,6 @@ static int __render_draw_border(abc_render_t* render, abc_obj_t* obj, int width, GLfloat x_border = border / (float)w; GLfloat y_border = border / (float)h; - if (ABC_OVERFLOW_HIDDEN == obj->overflow_type) { - for (int i = 0; i < sizeof(texture_update) / sizeof(texture_update[0]) / 2; i++) - scf_logi("%lg, %lg\n", texture_update[2 * i], texture_update[2 * i + 1]); - - printf(" x_border: %lg, y_border: %lg\n\n", x_border, y_border); - } - GLfloat aspect = w / (float)h; GLfloat w_scroll = 0.0; GLfloat scroll_y = 0.0; @@ -211,25 +202,8 @@ static int __render_draw_border(abc_render_t* render, abc_obj_t* obj, int width, double thumbColor[4] = {bgColor[0], bgColor[1], bgColor[2], bgColor[3]}; double trackColor[4] = {bgColor[0], bgColor[1], bgColor[2], bgColor[3]}; - if (obj->content_h > obj->h) + if (obj->content_h > obj->h && scroll_flag) { - float percent = h / (float)obj->content_h; - int len = h * percent; - int range = h - len; - int min = len / 2; - int max = h - min; - - if (obj->scroll_y < min) - obj->scroll_y = min; - if (obj->scroll_y > max) - obj->scroll_y = max; - - w_scroll = 25.0; - - attr = abc_obj_get_attr(obj, ABC_CSS_SCROLLBAR_WIDTH); - if (attr && attr->value->len > 0) - w_scroll = atof(attr->value->data); - attr = abc_obj_get_attr(obj, ABC_CSS_SCROLLBAR_COLOR); if (attr && attr->value->len > 0) { thumbColor[3] = 1.0; @@ -242,12 +216,22 @@ static int __render_draw_border(abc_render_t* render, abc_obj_t* obj, int width, thumbColor[3] = 1.0; } - scf_logi("obj mouse_down_x: %d, mouse_down_y: %d, mouse_move_x: %d, mouse_move_y: %d, x: %d, y: %d, x+w: %d, y+h: %d\n", - obj->mouse_down_x, - obj->mouse_down_x, obj->mouse_move_x, obj->mouse_move_y, - x, y, x + w, y + h); + w_scroll = 15.0; + + attr = abc_obj_get_attr(obj, ABC_CSS_SCROLLBAR_WIDTH); + if (attr && attr->value->len > 0) + w_scroll = abc_css_scrollbar_width(attr->value->data); - int dy = 0; + if (w_scroll > h / 2) + w_scroll = h / 2; + + float percent = h / (float)obj->content_h; + + scroll_h = h * percent; + if (scroll_h < w_scroll) + scroll_h = w_scroll; + + int move = 0; if (obj->mouse_move_x > x + w - w_scroll && obj->mouse_move_x < x + w && obj->mouse_move_y > y @@ -258,28 +242,17 @@ static int __render_draw_border(abc_render_t* render, abc_obj_t* obj, int width, && obj->mouse_down_y > y && obj->mouse_down_y < y + h) { - dy = obj->mouse_move_y - obj->mouse_down_y; - if (dy < min - obj->scroll_y) - dy = min - obj->scroll_y; - if (dy > max - obj->scroll_y) - dy = max - obj->scroll_y; - - assert(dy >= -range && dy <= range); - - obj->scroll_y += dy; + move = obj->mouse_move_y - obj->mouse_down_y; } } - dy = -(obj->scroll_y - min) * (obj->content_h - obj->h) / range; + int dy = abc_obj_scroll_y(obj, scroll_h, h, move); abc_dfs_update_xy(obj, 0, dy); - scroll_h = percent; - scroll_y = obj->scroll_y / (float)h; - + scroll_h /= (float)h; + scroll_y = obj->scroll_y / (float)h; w_scroll /= (float)w; - if (w_scroll > scroll_h / aspect) - w_scroll = scroll_h / aspect; scf_logi("aspect: %lg, w_scroll: %lg, scroll_y: %lg, scroll_h: %lg\n\n", aspect, w_scroll, scroll_y, scroll_h); } diff --git a/ui/__render_text.c b/ui/__render_text.c index ee2514a..bc8d491 100644 --- a/ui/__render_text.c +++ b/ui/__render_text.c @@ -79,12 +79,12 @@ void __draw_text(cairo_text_extents_t* extents, cairo_t* cr, const char* text, d int __init_text(cairo_t* cr, abc_obj_t* obj, int num_flag) { - abc_obj_t* attr = abc_obj_find_attr(obj, ABC_HTML_ATTR_FONT); + abc_attr_t* attr = abc_obj_find_attr(obj, ABC_HTML_ATTR_FONT); if (attr) { int bold = CAIRO_FONT_WEIGHT_NORMAL; int italic = CAIRO_FONT_SLANT_NORMAL; - abc_obj_t* style = abc_obj_find_attr(obj, ABC_HTML_ATTR_FONT_STYLE); + abc_attr_t* style = abc_obj_find_attr(obj, ABC_HTML_ATTR_FONT_STYLE); if (style) { if (!__html_strcmp(style->value->data, "bold")) bold = CAIRO_FONT_WEIGHT_BOLD; @@ -192,7 +192,7 @@ static int __render_draw_text(abc_render_t* render, abc_obj_t* obj, int width, i if (0 == texture_rgba) __init_texture(&texture_rgba, GL_RGBA, w, h, NULL); - abc_obj_t* attr; + abc_attr_t* attr; cairo_surface_t* surface; cairo_t* cr; @@ -233,6 +233,8 @@ static int __render_draw_text(abc_render_t* render, abc_obj_t* obj, int width, i switch (obj->overflow_type) { case ABC_OVERFLOW_HIDDEN: + case ABC_OVERFLOW_SCROLL: + case ABC_OVERFLOW_AUTO: abc_overflow_show(&view_x, &view_y, &view_w, &view_h, obj->view_x, obj->view_y, obj->view_w, obj->view_h); diff --git a/ui/abc_layout.c b/ui/abc_layout.c index de78ad1..5ca21b1 100644 --- a/ui/abc_layout.c +++ b/ui/abc_layout.c @@ -114,7 +114,7 @@ int abc_layout_obj(abc_layout_t* layout, abc_obj_t* obj, int width, int height) do { \ abc_obj_t* tmp = parent; \ while (tmp && ABC_HTML != tmp->type) { \ - abc_obj_t* attr = abc_obj_get_attr(tmp, ABC_CSS_POSITION); \ + abc_attr_t* attr = abc_obj_get_attr(tmp, ABC_CSS_POSITION); \ \ if (attr && attr->value->len > 0 \ && __html_strcmp(attr->value->data, "static")) \ @@ -131,8 +131,8 @@ int abc_layout_obj(abc_layout_t* layout, abc_obj_t* obj, int width, int height) int abc_layout_css(abc_obj_t* obj) { - abc_obj_t* parent = obj->parent; - abc_obj_t* attr; + abc_obj_t* parent = obj->parent; + abc_attr_t* attr; if (!parent || parent->w <= 0) return 0; diff --git a/ui/abc_layout_div.c b/ui/abc_layout_div.c index 6de919b..90097ad 100644 --- a/ui/abc_layout_div.c +++ b/ui/abc_layout_div.c @@ -2,7 +2,7 @@ int abc_layout_div(abc_layout_t* layout, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr; + abc_attr_t* attr; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_layout_form.c b/ui/abc_layout_form.c index 6023fdb..0df5f87 100644 --- a/ui/abc_layout_form.c +++ b/ui/abc_layout_form.c @@ -2,7 +2,7 @@ int abc_layout_form(abc_layout_t* layout, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr; + abc_attr_t* attr; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_layout_h1.c b/ui/abc_layout_h1.c index bcf6f83..720ce27 100644 --- a/ui/abc_layout_h1.c +++ b/ui/abc_layout_h1.c @@ -2,8 +2,8 @@ int abc_layout_h1(abc_layout_t* layout, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr; - abc_obj_t* style; + abc_attr_t* attr; + abc_attr_t* style; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_layout_input.c b/ui/abc_layout_input.c index b4fa92b..0cd7b6c 100644 --- a/ui/abc_layout_input.c +++ b/ui/abc_layout_input.c @@ -2,7 +2,7 @@ int abc_layout_input(abc_layout_t* layout, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr; + abc_attr_t* attr; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_layout_label.c b/ui/abc_layout_label.c index 53a5181..ba578cd 100644 --- a/ui/abc_layout_label.c +++ b/ui/abc_layout_label.c @@ -2,7 +2,7 @@ int abc_layout_label(abc_layout_t* layout, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr; + abc_attr_t* attr; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_layout_table.c b/ui/abc_layout_table.c index 23a727e..e806594 100644 --- a/ui/abc_layout_table.c +++ b/ui/abc_layout_table.c @@ -6,7 +6,7 @@ int abc_layout_table(abc_layout_t* layout, abc_obj_t* obj, int width, int height scf_list_t* l2; abc_obj_t* tr; abc_obj_t* td; - abc_obj_t* attr; + abc_attr_t* attr; int collapse = 0; diff --git a/ui/abc_layout_td.c b/ui/abc_layout_td.c index 82327ff..faa808f 100644 --- a/ui/abc_layout_td.c +++ b/ui/abc_layout_td.c @@ -3,7 +3,7 @@ int abc_layout_td(abc_layout_t* layout, abc_obj_t* obj, int width, int height) { abc_obj_t* table; - abc_obj_t* attr; + abc_attr_t* attr; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_layout_text.c b/ui/abc_layout_text.c index 6640045..0513c1b 100644 --- a/ui/abc_layout_text.c +++ b/ui/abc_layout_text.c @@ -29,8 +29,8 @@ static int __layout_text_split(cairo_text_extents_t* extents, cairo_t* cr, const int __layout_text(cairo_t* cr, abc_obj_t* obj, int x, int width, cairo_text_extents_t* extents) { - abc_obj_t* attr; - abc_obj_t* style; + abc_attr_t* attr; + abc_attr_t* style; attr = abc_obj_find_attr(obj, ABC_HTML_ATTR_FONT); if (attr) { @@ -127,7 +127,7 @@ int __layout_text(cairo_t* cr, abc_obj_t* obj, int x, int width, cairo_text_exte int abc_layout_text(abc_layout_t* layout, abc_obj_t* obj, int width, int height) { abc_obj_t* parent = obj->parent; - abc_obj_t* attr; + abc_attr_t* attr; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_layout_video.c b/ui/abc_layout_video.c index a0f107a..f46e7b3 100644 --- a/ui/abc_layout_video.c +++ b/ui/abc_layout_video.c @@ -6,7 +6,7 @@ static int __av_filter_init(abc_obj_t* obj) abc_avio_t* avin = NULL; abc_avio_t* vout = NULL; abc_avio_t* aout = NULL; - abc_obj_t* attr; + abc_attr_t* attr; abc_obj_t* src; int ret = abc_filter_open(&obj->av_filter); @@ -110,7 +110,7 @@ error: int abc_layout_video(abc_layout_t* layout, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr; + abc_attr_t* attr; int w = 0; int h = 0; diff --git a/ui/abc_render_a_href.c b/ui/abc_render_a_href.c index a10d927..7dff92c 100644 --- a/ui/abc_render_a_href.c +++ b/ui/abc_render_a_href.c @@ -40,7 +40,7 @@ static int _render_fini_a_href(abc_render_t* render) static int _render_draw_a_href(abc_render_t* render, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_HREF); + abc_attr_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_HREF); if (!attr || !attr->value || attr->value->len <= 0) { scf_loge("hyper link '%s' not found a URL\n", obj->text->data); diff --git a/ui/abc_render_audio.c b/ui/abc_render_audio.c index 7fd0394..6ba7dce 100644 --- a/ui/abc_render_audio.c +++ b/ui/abc_render_audio.c @@ -41,7 +41,7 @@ static int _render_fini_audio(abc_render_t* render) static int _render_draw_audio(abc_render_t* render, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_SRC); + abc_attr_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_SRC); if (!attr) { scf_loge("src audio of '%s' not found\n", obj->keys[0]); return -EINVAL; diff --git a/ui/abc_render_body.c b/ui/abc_render_body.c index d5dd756..3e3f364 100644 --- a/ui/abc_render_body.c +++ b/ui/abc_render_body.c @@ -9,7 +9,7 @@ static int _render_draw_body(abc_render_t* render, abc_obj_t* obj, int width, in { __render_border.draw(&__render_border, obj, width, height); - abc_obj_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_BG_IMAGE); + abc_attr_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_BG_IMAGE); if (attr && attr->value && attr->value->len > 0) { __render_bg_image.draw(&__render_bg_image, obj, width, height); diff --git a/ui/abc_render_form.c b/ui/abc_render_form.c index 34ccda5..6e86482 100644 --- a/ui/abc_render_form.c +++ b/ui/abc_render_form.c @@ -52,7 +52,7 @@ static int _render_draw_form(abc_render_t* render, abc_obj_t* obj, int width, in if (0 == texture_rgba) __init_texture(&texture_rgba, GL_RGBA, obj->w, obj->h, NULL); - abc_obj_t* attr; + abc_attr_t* attr; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_render_img.c b/ui/abc_render_img.c index 511e144..4e29a83 100644 --- a/ui/abc_render_img.c +++ b/ui/abc_render_img.c @@ -41,7 +41,7 @@ static int _render_fini_img(abc_render_t* render) static int _render_draw_img(abc_render_t* render, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr; + abc_attr_t* attr; abc_img_t* img = NULL; attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_SRC); diff --git a/ui/abc_render_input.c b/ui/abc_render_input.c index aab8976..95db757 100644 --- a/ui/abc_render_input.c +++ b/ui/abc_render_input.c @@ -49,8 +49,8 @@ static int _render_draw_input(abc_render_t* render, abc_obj_t* obj, int width, i if (0 == texture_rgba) __init_texture(&texture_rgba, GL_RGBA, obj->w, obj->h, NULL); - abc_obj_t* type; - abc_obj_t* attr; + abc_attr_t* type; + abc_attr_t* attr; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_render_label.c b/ui/abc_render_label.c index c006420..dcea464 100644 --- a/ui/abc_render_label.c +++ b/ui/abc_render_label.c @@ -52,7 +52,7 @@ static int _render_draw_label(abc_render_t* render, abc_obj_t* obj, int width, i if (0 == texture_rgba) __init_texture(&texture_rgba, GL_RGBA, obj->w, obj->h, NULL); - abc_obj_t* attr; + abc_attr_t* attr; cairo_text_extents_t extents; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_render_li.c b/ui/abc_render_li.c index ae56b27..b495202 100644 --- a/ui/abc_render_li.c +++ b/ui/abc_render_li.c @@ -52,7 +52,7 @@ static int _render_fini_li(abc_render_t* render) static int _render_draw_li(abc_render_t* render, abc_obj_t* obj, int width, int height) { - abc_obj_t* attr; + abc_attr_t* attr; cairo_surface_t* surface; cairo_t* cr; diff --git a/ui/abc_render_td.c b/ui/abc_render_td.c index 07d9136..61b449e 100644 --- a/ui/abc_render_td.c +++ b/ui/abc_render_td.c @@ -45,7 +45,7 @@ static int _render_draw_td(abc_render_t* render, abc_obj_t* obj, int width, int if (!obj->text) return 0; - abc_obj_t* attr; + abc_attr_t* attr; int margin = 0; int border = 1; diff --git a/ui/abc_render_text.c b/ui/abc_render_text.c index dae5e77..7bef4e6 100644 --- a/ui/abc_render_text.c +++ b/ui/abc_render_text.c @@ -60,7 +60,7 @@ static int _draw_text_line(abc_obj_t* obj, const char* text, cairo_fill(cr); cairo_stroke(cr); - abc_obj_t* attr = abc_obj_find_attr(obj, ABC_HTML_ATTR_FONT); + abc_attr_t* attr = abc_obj_find_attr(obj, ABC_HTML_ATTR_FONT); if (attr) cairo_select_font_face(cr, attr->value->data, italic, bold); @@ -142,7 +142,7 @@ static int _render_draw_text(abc_render_t* render, abc_obj_t* obj, int width, in __init_texture(&texture_rgba, GL_RGBA, obj->w, obj->h, NULL); abc_text_t* t; - abc_obj_t* attr; + abc_attr_t* attr; double bcolor[3] = {0.0}; double fcolor[3] = {0.0}; diff --git a/ui/main.c b/ui/main.c index 104eeca..db9a1ec 100644 --- a/ui/main.c +++ b/ui/main.c @@ -65,9 +65,9 @@ static int __do_button_move(abc_ctx_t* ctx, int x, int y) return 0; scf_list_t* l; + abc_attr_t* attr; abc_obj_t* prev = ctx->current->current; abc_obj_t* obj = abc_obj_find(ctx->current->root, x, y); - abc_obj_t* attr; abc_obj_t* css; int ret = 0; @@ -176,8 +176,8 @@ static int __do_button_move(abc_ctx_t* ctx, int x, int y) static int __do_button_release_a(abc_ctx_t* ctx, abc_obj_t* obj, int x, int y) { - abc_html_t* html = NULL; - abc_obj_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_HREF); + abc_html_t* html = NULL; + abc_attr_t* attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_HREF); int ret = abc_html_open(&html, attr->value->data); if (ret < 0) @@ -211,10 +211,10 @@ static int __do_button_release_a(abc_ctx_t* ctx, abc_obj_t* obj, int x, int y) static int __do_button_release(abc_ctx_t* ctx, int x, int y) { - abc_html_t* html; - abc_obj_t* obj = abc_obj_find(ctx->current->root, x, y); - abc_obj_t* css; - abc_obj_t* attr; + abc_html_t* html; + abc_attr_t* attr; + abc_obj_t* obj = abc_obj_find(ctx->current->root, x, y); + abc_obj_t* css; if (!obj) return __do_button_move(ctx, x, y); @@ -403,8 +403,8 @@ static gboolean button_press_event(GtkWidget* self, GdkEventButton* event, gpoin static void __utf8_delete(abc_ctx_t* ctx) { - abc_obj_t* obj; - abc_obj_t* attr; + abc_attr_t* attr; + abc_obj_t* obj; if (!ctx->current || !ctx->current->current) return; @@ -428,7 +428,6 @@ static void __utf8_delete(abc_ctx_t* ctx) if (c < 0x80) break; - if ((c >> 6) != 0x2) break; } @@ -536,9 +535,9 @@ static gboolean im_delete_surrounding(GtkIMContext* self, gint offset, gint n_ch static void im_commit(GtkIMContext* self, gchar* str, gpointer user_data) { - abc_ctx_t* ctx = user_data; - abc_obj_t* obj; - abc_obj_t* attr; + abc_ctx_t* ctx = user_data; + abc_obj_t* obj; + abc_attr_t* attr; scf_logw("str: %s\n", str);