Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/570f2dc03608d525ef02102ff0ca8225d57b40ed
...commit
http://git.netsurf-browser.org/netsurf.git/commit/570f2dc03608d525ef02102ff0ca8225d57b40ed
...tree
http://git.netsurf-browser.org/netsurf.git/tree/570f2dc03608d525ef02102ff0ca8225d57b40ed
The branch, master has been updated
via 570f2dc03608d525ef02102ff0ca8225d57b40ed (commit)
from 7de3100624bf77980e92f8e507a209dfe34a8309 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=570f2dc03608d525ef02102ff0ca8225d57b40ed
commit 570f2dc03608d525ef02102ff0ca8225d57b40ed
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
remove user warning and fix up error handling in form select menus
diff --git a/content/handlers/html/form.c b/content/handlers/html/form.c
index 2918ce7..fd0f2fa 100644
--- a/content/handlers/html/form.c
+++ b/content/handlers/html/form.c
@@ -1486,10 +1486,11 @@ form_encode_item(const char *item,
}
/* exported interface documented in html/form_internal.h */
-bool form_open_select_menu(void *client_data,
- struct form_control *control,
- select_menu_redraw_callback callback,
- struct content *c)
+nserror
+form_open_select_menu(void *client_data,
+ struct form_control *control,
+ select_menu_redraw_callback callback,
+ struct content *c)
{
int line_height_with_spacing;
struct box *box;
@@ -1497,15 +1498,14 @@ bool form_open_select_menu(void *client_data,
int total_height;
struct form_select_menu *menu;
html_content *html = (html_content *)c;
-
+ nserror res;
/* if the menu is opened for the first time */
if (control->data.select.menu == NULL) {
menu = calloc(1, sizeof (struct form_select_menu));
if (menu == NULL) {
- guit->misc->warning("NoMemory", 0);
- return false;
+ return NSERROR_NOMEM;
}
control->data.select.menu = menu;
@@ -1513,9 +1513,8 @@ bool form_open_select_menu(void *client_data,
box = control->box;
menu->width = box->width +
- box->border[RIGHT].width +
- box->border[LEFT].width +
- box->padding[RIGHT] + box->padding[LEFT];
+ box->border[RIGHT].width + box->padding[RIGHT] +
+ box->border[LEFT].width + box->padding[LEFT];
font_plot_style_from_css(&html->len_ctx, control->box->style,
&fstyle);
@@ -1535,28 +1534,31 @@ bool form_open_select_menu(void *client_data,
menu->height = total_height;
if (menu->height > MAX_SELECT_HEIGHT) {
-
menu->height = MAX_SELECT_HEIGHT;
}
+
menu->client_data = client_data;
menu->callback = callback;
- if (scrollbar_create(false,
- menu->height,
- total_height,
- menu->height,
- control,
- form_select_menu_scroll_callback,
- &(menu->scrollbar)) != NSERROR_OK) {
+ res = scrollbar_create(false,
+ menu->height,
+ total_height,
+ menu->height,
+ control,
+ form_select_menu_scroll_callback,
+ &(menu->scrollbar));
+ if (res != NSERROR_OK) {
+ control->data.select.menu = NULL;
free(menu);
- return false;
+ return res;
}
menu->c = c;
+ } else {
+ menu = control->data.select.menu;
}
- else menu = control->data.select.menu;
menu->callback(client_data, 0, 0, menu->width, menu->height);
- return true;
+ return NSERROR_OK;
}
diff --git a/content/handlers/html/form_internal.h
b/content/handlers/html/form_internal.h
index 6575224..45f861f 100644
--- a/content/handlers/html/form_internal.h
+++ b/content/handlers/html/form_internal.h
@@ -200,13 +200,13 @@ bool form_successful_controls(struct form *form,
/**
* Open a select menu for a select form control, creating it if necessary.
*
- * \param client_data data passed to the redraw callback
- * \param control The select form control for which the menu is being opened
- * \param redraw_callback The callback to redraw the select menu.
- * \param c The content the select menu is opening for.
- * \return false on memory exhaustion, true otherwise
+ * \param client_data data passed to the redraw callback
+ * \param control The select form control for which the menu is being opened
+ * \param redraw_callback The callback to redraw the select menu.
+ * \param c The content the select menu is opening for.
+ * \return NSERROR_OK on sucess else error code.
*/
-bool form_open_select_menu(void *client_data,
+nserror form_open_select_menu(void *client_data,
struct form_control *control,
select_menu_redraw_callback redraw_callback,
struct content *c);
diff --git a/content/handlers/html/html_interaction.c
b/content/handlers/html/html_interaction.c
index 330dd24..4de15f8 100644
--- a/content/handlers/html/html_interaction.c
+++ b/content/handlers/html/html_interaction.c
@@ -716,9 +716,15 @@ void html_mouse_action(struct content *c, struct
browser_window *bw,
if (mouse & BROWSER_MOUSE_CLICK_1 &&
nsoption_bool(core_select_menu)) {
html->visible_select_menu = gadget;
- form_open_select_menu(c, gadget,
+ res = form_open_select_menu(c, gadget,
form_select_menu_callback,
c);
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, ERROR,
+ "%s",
+ messages_get_errorcode(res));
+ html->visible_select_menu = NULL;
+ }
pointer = BROWSER_POINTER_DEFAULT;
} else if (mouse & BROWSER_MOUSE_CLICK_1) {
msg_data.select_menu.gadget = gadget;
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/form.c | 44 ++++++++++++++++--------------
content/handlers/html/form_internal.h | 12 ++++----
content/handlers/html/html_interaction.c | 8 +++++-
3 files changed, 36 insertions(+), 28 deletions(-)
diff --git a/content/handlers/html/form.c b/content/handlers/html/form.c
index 2918ce7..fd0f2fa 100644
--- a/content/handlers/html/form.c
+++ b/content/handlers/html/form.c
@@ -1486,10 +1486,11 @@ form_encode_item(const char *item,
}
/* exported interface documented in html/form_internal.h */
-bool form_open_select_menu(void *client_data,
- struct form_control *control,
- select_menu_redraw_callback callback,
- struct content *c)
+nserror
+form_open_select_menu(void *client_data,
+ struct form_control *control,
+ select_menu_redraw_callback callback,
+ struct content *c)
{
int line_height_with_spacing;
struct box *box;
@@ -1497,15 +1498,14 @@ bool form_open_select_menu(void *client_data,
int total_height;
struct form_select_menu *menu;
html_content *html = (html_content *)c;
-
+ nserror res;
/* if the menu is opened for the first time */
if (control->data.select.menu == NULL) {
menu = calloc(1, sizeof (struct form_select_menu));
if (menu == NULL) {
- guit->misc->warning("NoMemory", 0);
- return false;
+ return NSERROR_NOMEM;
}
control->data.select.menu = menu;
@@ -1513,9 +1513,8 @@ bool form_open_select_menu(void *client_data,
box = control->box;
menu->width = box->width +
- box->border[RIGHT].width +
- box->border[LEFT].width +
- box->padding[RIGHT] + box->padding[LEFT];
+ box->border[RIGHT].width + box->padding[RIGHT] +
+ box->border[LEFT].width + box->padding[LEFT];
font_plot_style_from_css(&html->len_ctx, control->box->style,
&fstyle);
@@ -1535,28 +1534,31 @@ bool form_open_select_menu(void *client_data,
menu->height = total_height;
if (menu->height > MAX_SELECT_HEIGHT) {
-
menu->height = MAX_SELECT_HEIGHT;
}
+
menu->client_data = client_data;
menu->callback = callback;
- if (scrollbar_create(false,
- menu->height,
- total_height,
- menu->height,
- control,
- form_select_menu_scroll_callback,
- &(menu->scrollbar)) != NSERROR_OK) {
+ res = scrollbar_create(false,
+ menu->height,
+ total_height,
+ menu->height,
+ control,
+ form_select_menu_scroll_callback,
+ &(menu->scrollbar));
+ if (res != NSERROR_OK) {
+ control->data.select.menu = NULL;
free(menu);
- return false;
+ return res;
}
menu->c = c;
+ } else {
+ menu = control->data.select.menu;
}
- else menu = control->data.select.menu;
menu->callback(client_data, 0, 0, menu->width, menu->height);
- return true;
+ return NSERROR_OK;
}
diff --git a/content/handlers/html/form_internal.h
b/content/handlers/html/form_internal.h
index 6575224..45f861f 100644
--- a/content/handlers/html/form_internal.h
+++ b/content/handlers/html/form_internal.h
@@ -200,13 +200,13 @@ bool form_successful_controls(struct form *form,
/**
* Open a select menu for a select form control, creating it if necessary.
*
- * \param client_data data passed to the redraw callback
- * \param control The select form control for which the menu is being opened
- * \param redraw_callback The callback to redraw the select menu.
- * \param c The content the select menu is opening for.
- * \return false on memory exhaustion, true otherwise
+ * \param client_data data passed to the redraw callback
+ * \param control The select form control for which the menu is being opened
+ * \param redraw_callback The callback to redraw the select menu.
+ * \param c The content the select menu is opening for.
+ * \return NSERROR_OK on sucess else error code.
*/
-bool form_open_select_menu(void *client_data,
+nserror form_open_select_menu(void *client_data,
struct form_control *control,
select_menu_redraw_callback redraw_callback,
struct content *c);
diff --git a/content/handlers/html/html_interaction.c
b/content/handlers/html/html_interaction.c
index 330dd24..4de15f8 100644
--- a/content/handlers/html/html_interaction.c
+++ b/content/handlers/html/html_interaction.c
@@ -716,9 +716,15 @@ void html_mouse_action(struct content *c, struct
browser_window *bw,
if (mouse & BROWSER_MOUSE_CLICK_1 &&
nsoption_bool(core_select_menu)) {
html->visible_select_menu = gadget;
- form_open_select_menu(c, gadget,
+ res = form_open_select_menu(c, gadget,
form_select_menu_callback,
c);
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, ERROR,
+ "%s",
+ messages_get_errorcode(res));
+ html->visible_select_menu = NULL;
+ }
pointer = BROWSER_POINTER_DEFAULT;
} else if (mouse & BROWSER_MOUSE_CLICK_1) {
msg_data.select_menu.gadget = gadget;
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org