update scrollbar_create error handling to return nserror

This commit is contained in:
Vincent Sanders 2016-04-26 12:14:56 +01:00
parent dd14807c8c
commit 69cea38f41
5 changed files with 27 additions and 23 deletions

View File

@ -147,10 +147,11 @@ void browser_window_handle_scrollbars(struct browser_window *bw)
if (bw->scroll_y == NULL) {
/* create vertical scrollbar */
if (!scrollbar_create(false, length, c_height, visible,
bw, browser_window_scroll_callback,
&(bw->scroll_y)))
if (scrollbar_create(false, length, c_height, visible,
bw, browser_window_scroll_callback,
&(bw->scroll_y)) != NSERROR_OK) {
return;
}
} else {
/* update vertical scrollbar */
scrollbar_set_extents(bw->scroll_y, length,
@ -164,10 +165,11 @@ void browser_window_handle_scrollbars(struct browser_window *bw)
if (bw->scroll_x == NULL) {
/* create horizontal scrollbar */
if (!scrollbar_create(true, length, c_width, visible,
bw, browser_window_scroll_callback,
&(bw->scroll_x)))
if (scrollbar_create(true, length, c_width, visible,
bw, browser_window_scroll_callback,
&(bw->scroll_x)) != NSERROR_OK) {
return;
}
} else {
/* update horizontal scrollbar */
scrollbar_set_extents(bw->scroll_x, length,

View File

@ -70,9 +70,9 @@ struct scrollbar {
/*
* Exported function. Documented in scrollbar.h
* Exported function. Documented in desktop/scrollbar.h
*/
bool scrollbar_create(bool horizontal, int length, int full_size,
nserror scrollbar_create(bool horizontal, int length, int full_size,
int visible_size, void *client_data,
scrollbar_client_callback client_callback,
struct scrollbar **s)
@ -82,10 +82,8 @@ bool scrollbar_create(bool horizontal, int length, int full_size,
scrollbar = malloc(sizeof(struct scrollbar));
if (scrollbar == NULL) {
LOG("malloc failed");
warn_user("NoMemory", 0);
*s = NULL;
return false;
return NSERROR_NOMEM;
}
scrollbar->horizontal = horizontal;
@ -109,7 +107,7 @@ bool scrollbar_create(bool horizontal, int length, int full_size,
*s = scrollbar;
return true;
return NSERROR_OK;
}

View File

@ -1029,10 +1029,11 @@ static bool textarea_reflow_multiline(struct textarea *ta,
if (x > avail_width && ta->bar_x == NULL) {
/* We need to insert a horizontal scrollbar */
int w = ta->vis_width - 2 * ta->border_width;
if (!scrollbar_create(true, w, w, w,
if (scrollbar_create(true, w, w, w,
ta, textarea_scrollbar_callback,
&(ta->bar_x)))
&(ta->bar_x)) != NSERROR_OK) {
return false;
}
if (ta->bar_y != NULL)
scrollbar_make_pair(ta->bar_x,
ta->bar_y);
@ -1120,10 +1121,11 @@ static bool textarea_reflow_multiline(struct textarea *ta,
if (line > scroll_lines && ta->bar_y == NULL) {
/* Add vertical scrollbar */
int h = ta->vis_height - 2 * ta->border_width;
if (!scrollbar_create(false, h, h, h,
ta, textarea_scrollbar_callback,
&(ta->bar_y)))
if (scrollbar_create(false, h, h, h,
ta, textarea_scrollbar_callback,
&(ta->bar_y)) != NSERROR_OK) {
return false;
}
if (ta->bar_x != NULL)
scrollbar_make_pair(ta->bar_x,
ta->bar_y);

View File

@ -1151,11 +1151,12 @@ bool box_handle_scrollbars(struct content *c, struct box *box,
}
data->c = c;
data->box = box;
if (!scrollbar_create(false, visible_height,
if (scrollbar_create(false, visible_height,
full_height, visible_height,
data, html_overflow_scroll_callback,
&(box->scroll_y)))
&(box->scroll_y)) != NSERROR_OK) {
return false;
}
} else {
scrollbar_set_extents(box->scroll_y, visible_height,
visible_height, full_height);
@ -1171,13 +1172,14 @@ bool box_handle_scrollbars(struct content *c, struct box *box,
}
data->c = c;
data->box = box;
if (!scrollbar_create(true,
if (scrollbar_create(true,
visible_width -
(right ? SCROLLBAR_WIDTH : 0),
full_width, visible_width,
data, html_overflow_scroll_callback,
&box->scroll_x))
&box->scroll_x) != NSERROR_OK) {
return false;
}
} else {
scrollbar_set_extents(box->scroll_x,
visible_width -

View File

@ -1131,13 +1131,13 @@ bool form_open_select_menu(void *client_data,
}
menu->client_data = client_data;
menu->callback = callback;
if (!scrollbar_create(false,
if (scrollbar_create(false,
menu->height,
total_height,
menu->height,
control,
form_select_menu_scroll_callback,
&(menu->scrollbar))) {
&(menu->scrollbar)) != NSERROR_OK) {
free(menu);
return false;
}