summaryrefslogtreecommitdiff
path: root/content/handlers/html
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2019-11-05 23:05:42 +0000
committerVincent Sanders <vince@kyllikki.org>2019-11-05 23:05:42 +0000
commitcbb0c05258e91fc3c3c6a421141df738fcfe7473 (patch)
tree7be33ccd8daeeb452dd429e58500c2d009180fc4 /content/handlers/html
parent78aa34e5d761c2597f24ebba89c69ac6fda2f3a8 (diff)
downloadnetsurf-cbb0c05258e91fc3c3c6a421141df738fcfe7473.tar.gz
netsurf-cbb0c05258e91fc3c3c6a421141df738fcfe7473.tar.bz2
remove unecessary user warning calls and improve error propogation in html box
Diffstat (limited to 'content/handlers/html')
-rw-r--r--content/handlers/html/box.c74
-rw-r--r--content/handlers/html/box.h13
-rw-r--r--content/handlers/html/html_redraw.c22
3 files changed, 63 insertions, 46 deletions
diff --git a/content/handlers/html/box.c b/content/handlers/html/box.c
index 30cb4e2a0..475e86b47 100644
--- a/content/handlers/html/box.c
+++ b/content/handlers/html/box.c
@@ -1114,22 +1114,18 @@ void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
}
}
-/**
- * Applies the given scroll setup to a box. This includes scroll
- * creation/deletion as well as scroll dimension updates.
- *
- * \param c content in which the box is located
- * \param box the box to handle the scrolls for
- * \param bottom whether the horizontal scrollbar should be present
- * \param right whether the vertical scrollbar should be present
- * \return true on success false otherwise
- */
-bool box_handle_scrollbars(struct content *c, struct box *box,
- bool bottom, bool right)
+
+/* exported interface documented in html/box.h */
+nserror
+box_handle_scrollbars(struct content *c,
+ struct box *box,
+ bool bottom,
+ bool right)
{
struct html_scrollbar_data *data;
int visible_width, visible_height;
int full_width, full_height;
+ nserror res;
if (!bottom && box->scroll_x != NULL) {
data = scrollbar_get_data(box->scroll_x);
@@ -1145,8 +1141,9 @@ bool box_handle_scrollbars(struct content *c, struct box *box,
box->scroll_y = NULL;
}
- if (!bottom && !right)
- return true;
+ if (!bottom && !right) {
+ return NSERROR_OK;
+ }
visible_width = box->width + box->padding[RIGHT] + box->padding[LEFT];
visible_height = box->height + box->padding[TOP] + box->padding[BOTTOM];
@@ -1164,40 +1161,44 @@ bool box_handle_scrollbars(struct content *c, struct box *box,
if (box->scroll_y == NULL) {
data = malloc(sizeof(struct html_scrollbar_data));
if (data == NULL) {
- NSLOG(netsurf, INFO, "malloc failed");
- guit->misc->warning("NoMemory", 0);
- return false;
+ return NSERROR_NOMEM;
}
data->c = c;
data->box = box;
- if (scrollbar_create(false, visible_height,
- full_height, visible_height,
- data, html_overflow_scroll_callback,
- &(box->scroll_y)) != NSERROR_OK) {
- return false;
+ res = scrollbar_create(false,
+ visible_height,
+ full_height,
+ visible_height,
+ data,
+ html_overflow_scroll_callback,
+ &(box->scroll_y));
+ if (res != NSERROR_OK) {
+ return res;
}
} else {
- scrollbar_set_extents(box->scroll_y, visible_height,
- visible_height, full_height);
+ scrollbar_set_extents(box->scroll_y,
+ visible_height,
+ visible_height,
+ full_height);
}
}
if (bottom) {
if (box->scroll_x == NULL) {
data = malloc(sizeof(struct html_scrollbar_data));
if (data == NULL) {
- NSLOG(netsurf, INFO, "malloc failed");
- guit->misc->warning("NoMemory", 0);
- return false;
+ return NSERROR_OK;
}
data->c = c;
data->box = box;
- if (scrollbar_create(true,
- visible_width -
- (right ? SCROLLBAR_WIDTH : 0),
- full_width, visible_width,
- data, html_overflow_scroll_callback,
- &box->scroll_x) != NSERROR_OK) {
- return false;
+ res = scrollbar_create(true,
+ visible_width - (right ? SCROLLBAR_WIDTH : 0),
+ full_width,
+ visible_width,
+ data,
+ html_overflow_scroll_callback,
+ &box->scroll_x);
+ if (res != NSERROR_OK) {
+ return res;
}
} else {
scrollbar_set_extents(box->scroll_x,
@@ -1207,10 +1208,11 @@ bool box_handle_scrollbars(struct content *c, struct box *box,
}
}
- if (right && bottom)
+ if (right && bottom) {
scrollbar_make_pair(box->scroll_x, box->scroll_y);
+ }
- return true;
+ return NSERROR_OK;
}
/**
diff --git a/content/handlers/html/box.h b/content/handlers/html/box.h
index 089c66433..8ab2875a0 100644
--- a/content/handlers/html/box.h
+++ b/content/handlers/html/box.h
@@ -353,8 +353,19 @@ void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style);
*/
bool box_extract_link(const struct html_content *content, const struct dom_string *dsrel, struct nsurl *base, struct nsurl **result);
-bool box_handle_scrollbars(struct content *c, struct box *box,
+/**
+ * Applies the given scroll setup to a box. This includes scroll
+ * creation/deletion as well as scroll dimension updates.
+ *
+ * \param c content in which the box is located
+ * \param box the box to handle the scrolls for
+ * \param bottom whether the horizontal scrollbar should be present
+ * \param right whether the vertical scrollbar should be present
+ * \return true on success false otherwise
+ */
+nserror box_handle_scrollbars(struct content *c, struct box *box,
bool bottom, bool right);
+
bool box_vscrollbar_present(const struct box *box);
bool box_hscrollbar_present(const struct box *box);
diff --git a/content/handlers/html/html_redraw.c b/content/handlers/html/html_redraw.c
index 6216d607e..268bd62d3 100644
--- a/content/handlers/html/html_redraw.c
+++ b/content/handlers/html/html_redraw.c
@@ -1841,20 +1841,24 @@ bool html_redraw_box(const html_content *html, struct box *box,
/* scrollbars */
if (((box->style && box->type != BOX_BR &&
- box->type != BOX_TABLE && box->type != BOX_INLINE &&
- (overflow_x == CSS_OVERFLOW_SCROLL ||
- overflow_x == CSS_OVERFLOW_AUTO ||
- overflow_y == CSS_OVERFLOW_SCROLL ||
- overflow_y == CSS_OVERFLOW_AUTO)) ||
- (box->object && content_get_type(box->object) ==
- CONTENT_HTML)) && box->parent != NULL) {
+ box->type != BOX_TABLE && box->type != BOX_INLINE &&
+ (overflow_x == CSS_OVERFLOW_SCROLL ||
+ overflow_x == CSS_OVERFLOW_AUTO ||
+ overflow_y == CSS_OVERFLOW_SCROLL ||
+ overflow_y == CSS_OVERFLOW_AUTO)) ||
+ (box->object && content_get_type(box->object) ==
+ CONTENT_HTML)) && box->parent != NULL) {
+ nserror res;
has_x_scroll = box_hscrollbar_present(box);
has_y_scroll = box_vscrollbar_present(box);
- if (!box_handle_scrollbars((struct content *)html,
- box, has_x_scroll, has_y_scroll))
+ res = box_handle_scrollbars((struct content *)html,
+ box, has_x_scroll, has_y_scroll);
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO, "%s", messages_get_errorcode(res));
return false;
+ }
if (box->scroll_x != NULL)
scrollbar_redraw(box->scroll_x,