diff options
Diffstat (limited to 'render')
-rw-r--r-- | render/html.c | 66 | ||||
-rw-r--r-- | render/html.h | 2 | ||||
-rw-r--r-- | render/html_css.c | 10 | ||||
-rw-r--r-- | render/html_interaction.c | 4 | ||||
-rw-r--r-- | render/html_object.c | 7 | ||||
-rw-r--r-- | render/html_script.c | 30 |
6 files changed, 51 insertions, 68 deletions
diff --git a/render/html.c b/render/html.c index 25147a0a0..e10f1e930 100644 --- a/render/html.c +++ b/render/html.c @@ -1762,6 +1762,44 @@ static void html__dom_user_data_handler(dom_node_operation operation, } } +static void html__set_file_gadget_filename(struct content *c, + struct form_control *gadget, const char *fn) +{ + utf8_convert_ret ret; + char *utf8_fn, *oldfile = NULL; + html_content *html = (html_content *)c; + struct box *file_box = gadget->box; + + ret = utf8_from_local_encoding(fn,0, &utf8_fn); + if (ret != UTF8_CONVERT_OK) { + assert(ret != UTF8_CONVERT_BADENC); + LOG(("utf8_from_local_encoding failed")); + /* Load was for us - just no memory */ + return; + } + + form_gadget_update_value(html, gadget, utf8_fn); + + /* corestring_dom___ns_key_file_name_node_data */ + if (dom_node_set_user_data((dom_node *)file_box->gadget->node, + corestring_dom___ns_key_file_name_node_data, + strdup(fn), html__dom_user_data_handler, + &oldfile) == DOM_NO_ERR) { + if (oldfile != NULL) + free(oldfile); + } + + /* Redraw box. */ + html__redraw_a_box(html, file_box); +} + +void html_set_file_gadget_filename(struct hlcache_handle *hl, + struct form_control *gadget, const char *fn) +{ + return html__set_file_gadget_filename(hlcache_handle_get_content(hl), + gadget, fn); +} + /** * Drop a file onto a content at a particular point, or determine if a file * may be dropped onto the content at given point. @@ -1827,33 +1865,7 @@ static bool html_drop_file_at_point(struct content *c, int x, int y, char *file) /* Handle the drop */ if (file_box) { /* File dropped on file input */ - utf8_convert_ret ret; - char *utf8_fn, *oldfile = NULL; - - ret = utf8_from_local_encoding(file, 0, - &utf8_fn); - if (ret != UTF8_CONVERT_OK) { - /* A bad encoding should never happen */ - assert(ret != UTF8_CONVERT_BADENC); - LOG(("utf8_from_local_encoding failed")); - /* Load was for us - just no memory */ - return true; - } - - /* Found: update form input */ - form_gadget_update_value(html, file_box->gadget, utf8_fn); - - /* corestring_dom___ns_key_file_name_node_data */ - if (dom_node_set_user_data((dom_node *)file_box->gadget->node, - corestring_dom___ns_key_file_name_node_data, - strdup(file), html__dom_user_data_handler, - &oldfile) == DOM_NO_ERR) { - if (oldfile != NULL) - free(oldfile); - } - - /* Redraw box. */ - html__redraw_a_box(html, file_box); + html__set_file_gadget_filename(c, box->gadget, file); } else { /* File dropped on text input */ diff --git a/render/html.h b/render/html.h index 162541d72..7ca75e713 100644 --- a/render/html.h +++ b/render/html.h @@ -178,6 +178,8 @@ struct content_html_frames *html_get_frameset(struct hlcache_handle *h); struct content_html_iframe *html_get_iframe(struct hlcache_handle *h); nsurl *html_get_base_url(struct hlcache_handle *h); const char *html_get_base_target(struct hlcache_handle *h); +void html_set_file_gadget_filename(struct hlcache_handle *hl, + struct form_control *gadget, const char *fn); /** * Retrieve stylesheets used by HTML document diff --git a/render/html_css.c b/render/html_css.c index 88c67697d..ad24804a9 100644 --- a/render/html_css.c +++ b/render/html_css.c @@ -97,14 +97,6 @@ html_convert_css_callback(hlcache_handle *css, assert(i != parent->stylesheet_count); switch (event->type) { - case CONTENT_MSG_LOADING: - break; - - case CONTENT_MSG_READY: - break; - - case CONTENT_MSG_REDIRECT: - break; case CONTENT_MSG_DONE: LOG(("done stylesheet slot %d '%s'", i, @@ -143,7 +135,7 @@ html_convert_css_callback(hlcache_handle *css, return NSERROR_OK; default: - assert(0); + break; } if (html_can_begin_conversion(parent)) { diff --git a/render/html_interaction.c b/render/html_interaction.c index 5d69c987f..84c64ca20 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -741,6 +741,10 @@ void html_mouse_action(struct content *c, struct browser_window *bw, break; case GADGET_FILE: status = messages_get("FormFile"); + if (mouse & BROWSER_MOUSE_CLICK_1) { + msg_data.gadget_click.gadget = gadget; + content_broadcast(c, CONTENT_MSG_GADGETCLICK, msg_data); + } break; case GADGET_BUTTON: /* This gadget cannot be activated */ diff --git a/render/html_object.c b/render/html_object.c index 6cd08c1ef..e76919dd4 100644 --- a/render/html_object.c +++ b/render/html_object.c @@ -208,10 +208,6 @@ html_object_callback(hlcache_handle *object, } break; - case CONTENT_MSG_REFORMAT: - case CONTENT_MSG_REDIRECT: - break; - case CONTENT_MSG_REDRAW: if (c->base.status != CONTENT_STATUS_LOADING) { union content_msg_data data = event->data; @@ -377,6 +373,7 @@ html_object_callback(hlcache_handle *object, case CONTENT_MSG_SAVELINK: case CONTENT_MSG_POINTER: + case CONTENT_MSG_GADGETCLICK: /* These messages are for browser window layer. * we're not interested, so pass them on. */ content_broadcast(&c->base, event->type, event->data); @@ -445,7 +442,7 @@ html_object_callback(hlcache_handle *object, break; default: - assert(0); + break; } if (c->base.status == CONTENT_STATUS_READY && c->base.active == 0 && diff --git a/render/html_script.c b/render/html_script.c index 4aa8aff11..4a82bcd70 100644 --- a/render/html_script.c +++ b/render/html_script.c @@ -172,8 +172,6 @@ convert_script_async_cb(hlcache_handle *script, parent->base.active--; LOG(("%d fetches active", parent->base.active)); - - break; case CONTENT_MSG_ERROR: @@ -188,11 +186,8 @@ convert_script_async_cb(hlcache_handle *script, break; - case CONTENT_MSG_STATUS: - break; - default: - assert(0); + break; } return NSERROR_OK; @@ -219,11 +214,6 @@ convert_script_defer_cb(hlcache_handle *script, assert(i != parent->scripts_count); switch (event->type) { - case CONTENT_MSG_LOADING: - break; - - case CONTENT_MSG_READY: - break; case CONTENT_MSG_DONE: LOG(("script %d done '%s'", i, @@ -245,11 +235,8 @@ convert_script_defer_cb(hlcache_handle *script, break; - case CONTENT_MSG_STATUS: - break; - default: - assert(0); + break; } /* if there are no active fetches remaining begin post parse @@ -333,19 +320,8 @@ convert_script_sync_cb(hlcache_handle *script, break; - case CONTENT_MSG_LOADING: - case CONTENT_MSG_READY: - case CONTENT_MSG_STATUS: - case CONTENT_MSG_REDIRECT: - /* messages content handler will legitamately recive - * but does not need to handle - */ - break; - default: - /* all other messages are unexpected and fatal */ - LOG(("Unhandled message type %d", event->type)); - assert(0); + break; } /* if there are no active fetches remaining begin post parse |