diff options
Diffstat (limited to 'content/handlers')
28 files changed, 550 insertions, 166 deletions
diff --git a/content/handlers/css/dump.c b/content/handlers/css/dump.c index 4138f9343..c84b97ca4 100644 --- a/content/handlers/css/dump.c +++ b/content/handlers/css/dump.c @@ -19,6 +19,8 @@ #include <stdio.h> #include <libcss/libcss.h> +#include "netsurf/inttypes.h" + #include "css/dump.h" #include "css/utils.h" @@ -36,7 +38,7 @@ static void dump_css_fixed(FILE *stream, css_fixed f) uint32_t fracpart = ((NSCSS_ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10); #undef NSCSS_ABS - fprintf(stream, "%s%d.%03d", f < 0 ? "-" : "", uintpart, fracpart); + fprintf(stream, "%s%"PRIu32".%03"PRIu32, f < 0 ? "-" : "", uintpart, fracpart); } /** @@ -48,7 +50,7 @@ static void dump_css_fixed(FILE *stream, css_fixed f) static void dump_css_number(FILE *stream, css_fixed val) { if (INTTOFIX(FIXTOINT(val)) == val) - fprintf(stream, "%d", FIXTOINT(val)); + fprintf(stream, "%"PRId32, FIXTOINT(val)); else dump_css_fixed(stream, val); } @@ -143,6 +145,9 @@ static void dump_css_unit(FILE *stream, css_fixed val, css_unit unit) case CSS_UNIT_Q: fprintf(stream, "q"); break; + case CSS_UNIT_CALC: + fprintf(stream, "calc()"); + break; } } @@ -181,7 +186,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style) val = css_computed_background_color(style, &color); switch (val) { case CSS_BACKGROUND_COLOR_COLOR: - fprintf(stream, "background-color: #%08x ", color); + fprintf(stream, "background-color: #%08"PRIx32" ", color); break; default: break; @@ -255,7 +260,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style) val = css_computed_border_top_color(style, &color); switch (val) { case CSS_BORDER_COLOR_COLOR: - fprintf(stream, "border-top-color: #%08x ", color); + fprintf(stream, "border-top-color: #%08"PRIx32" ", color); break; default: break; @@ -265,7 +270,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style) val = css_computed_border_right_color(style, &color); switch (val) { case CSS_BORDER_COLOR_COLOR: - fprintf(stream, "border-right-color: #%08x ", color); + fprintf(stream, "border-right-color: #%08"PRIx32" ", color); break; default: break; @@ -275,7 +280,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style) val = css_computed_border_bottom_color(style, &color); switch (val) { case CSS_BORDER_COLOR_COLOR: - fprintf(stream, "border-bottom-color: #%08x ", color); + fprintf(stream, "border-bottom-color: #%08"PRIx32" ", color); break; default: break; @@ -285,7 +290,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style) val = css_computed_border_left_color(style, &color); switch (val) { case CSS_BORDER_COLOR_COLOR: - fprintf(stream, "border-left-color: #%08x ", color); + fprintf(stream, "border-left-color: #%08"PRIx32" ", color); break; default: break; @@ -610,7 +615,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style) /* color */ val = css_computed_color(style, &color); if (val == CSS_COLOR_COLOR) { - fprintf(stream, "color: #%08x ", color); + fprintf(stream, "color: #%08"PRIx32" ", color); } /* content */ @@ -1353,7 +1358,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style) fprintf(stream, "outline-color: invert "); break; case CSS_OUTLINE_COLOR_COLOR: - fprintf(stream, "outline-color: #%08x ", color); + fprintf(stream, "outline-color: #%08"PRIx32" ", color); break; default: break; @@ -1780,7 +1785,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style) } /* width */ - val = css_computed_width(style, &len1, &unit1); + val = css_computed_width_static(style, &len1, &unit1); switch (val) { case CSS_WIDTH_AUTO: fprintf(stream, "width: auto "); @@ -1820,7 +1825,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style) fprintf(stream, "z-index: auto "); break; case CSS_Z_INDEX_SET: - fprintf(stream, "z-index: %d ", zindex); + fprintf(stream, "z-index: %"PRId32" ", zindex); break; default: break; diff --git a/content/handlers/css/hints.c b/content/handlers/css/hints.c index defeae10a..0f246a64c 100644 --- a/content/handlers/css/hints.c +++ b/content/handlers/css/hints.c @@ -1624,13 +1624,19 @@ static void css_hint_list( } -/* Exported function, documeted in css/hints.h */ +/* Exported function, documented in css/hints.h */ css_error node_presentational_hint(void *pw, void *node, uint32_t *nhints, css_hint **hints) { dom_exception exc; dom_html_element_type tag_type; + if (nsoption_bool(author_level_css) == false) { + *nhints = 0; + *hints = NULL; + return CSS_OK; + } + css_hint_clean(); exc = dom_html_element_get_tag_type(node, &tag_type); @@ -1644,22 +1650,22 @@ css_error node_presentational_hint(void *pw, void *node, css_hint_width(pw, node); css_hint_table_cell_border_padding(pw, node); css_hint_white_space_nowrap(pw, node); - /* fall through */ + fallthrough; case DOM_HTML_ELEMENT_TYPE_TR: css_hint_height(pw, node); - /* fall through */ + fallthrough; case DOM_HTML_ELEMENT_TYPE_THEAD: case DOM_HTML_ELEMENT_TYPE_TBODY: case DOM_HTML_ELEMENT_TYPE_TFOOT: css_hint_text_align_special(pw, node); - /* fall through */ + fallthrough; case DOM_HTML_ELEMENT_TYPE_COL: css_hint_vertical_align_table_cells(pw, node); break; case DOM_HTML_ELEMENT_TYPE_APPLET: case DOM_HTML_ELEMENT_TYPE_IMG: css_hint_margin_hspace_vspace(pw, node); - /* fall through */ + fallthrough; case DOM_HTML_ELEMENT_TYPE_EMBED: case DOM_HTML_ELEMENT_TYPE_IFRAME: case DOM_HTML_ELEMENT_TYPE_OBJECT: @@ -1682,7 +1688,7 @@ css_error node_presentational_hint(void *pw, void *node, break; case DOM_HTML_ELEMENT_TYPE_CAPTION: css_hint_caption_side(pw, node); - /* fall through */ + fallthrough; case DOM_HTML_ELEMENT_TYPE_DIV: css_hint_text_align_special(pw, node); break; diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c index eeadb8453..8519c2b1d 100644 --- a/content/handlers/html/box_construct.c +++ b/content/handlers/html/box_construct.c @@ -249,16 +249,19 @@ box_get_style(html_content *c, const css_computed_style *root_style, dom_node *n) { - dom_string *s; - dom_exception err; + dom_string *s = NULL; css_stylesheet *inline_style = NULL; css_select_results *styles; nscss_select_ctx ctx; /* Firstly, construct inline stylesheet, if any */ - err = dom_element_get_attribute(n, corestring_dom_style, &s); - if (err != DOM_NO_ERR) - return NULL; + if (nsoption_bool(author_level_css)) { + dom_exception err; + err = dom_element_get_attribute(n, corestring_dom_style, &s); + if (err != DOM_NO_ERR) { + return NULL; + } + } if (s != NULL) { inline_style = nscss_create_inline_style( diff --git a/content/handlers/html/box_inspect.c b/content/handlers/html/box_inspect.c index 181f58cf8..6591b6446 100644 --- a/content/handlers/html/box_inspect.c +++ b/content/handlers/html/box_inspect.c @@ -25,6 +25,7 @@ #include <stdio.h> #include <dom/dom.h> +#include "utils/utils.h" #include "utils/nsurl.h" #include "utils/errors.h" #include "netsurf/types.h" @@ -212,7 +213,7 @@ box_move_xy(struct box *b, enum box_walk_dir dir, int *x, int *y) rb = b; break; } - /* fall through */ + fallthrough; case BOX_WALK_NEXT_SIBLING: do { diff --git a/content/handlers/html/box_special.c b/content/handlers/html/box_special.c index db3c4126d..aace1c8f9 100644 --- a/content/handlers/html/box_special.c +++ b/content/handlers/html/box_special.c @@ -1212,7 +1212,7 @@ box_image(dom_node *n, ok = html_fetch_object(content, url, box, image_types, false); nsurl_unref(url); - wtype = css_computed_width(box->style, &value, &wunit); + wtype = css_computed_width_static(box->style, &value, &wunit); htype = css_computed_height(box->style, &value, &hunit); if (wtype == CSS_WIDTH_SET && diff --git a/content/handlers/html/css.c b/content/handlers/html/css.c index 2434b1783..0bc38844f 100644 --- a/content/handlers/html/css.c +++ b/content/handlers/html/css.c @@ -33,6 +33,7 @@ #include "utils/nsoption.h" #include "utils/corestrings.h" #include "utils/log.h" +#include "netsurf/inttypes.h" #include "netsurf/misc.h" #include "netsurf/content.h" #include "content/hlcache.h" @@ -173,7 +174,7 @@ html_stylesheet_from_domnode(html_content *c, dom_string_unref(style); - snprintf(urlbuf, sizeof(urlbuf), "x-ns-css:%u", key); + snprintf(urlbuf, sizeof(urlbuf), "x-ns-css:%"PRIu32"", key); error = nsurl_create(urlbuf, &url); if (error != NSERROR_OK) { @@ -395,16 +396,20 @@ bool html_css_process_link(html_content *htmlc, dom_node *node) if (exc != DOM_NO_ERR || rel == NULL) return true; - if (strcasestr(dom_string_data(rel), "stylesheet") == 0) { + if (strcasestr(dom_string_data(rel), "stylesheet") == NULL) { dom_string_unref(rel); return true; - } else if (strcasestr(dom_string_data(rel), "alternate") != 0) { + } else if (strcasestr(dom_string_data(rel), "alternate") != NULL) { /* Ignore alternate stylesheets */ dom_string_unref(rel); return true; } dom_string_unref(rel); + if (nsoption_bool(author_level_css) == false) { + return true; + } + /* type='text/css' or not present */ exc = dom_element_get_attribute(node, corestring_dom_type, &type_attr); if (exc == DOM_NO_ERR && type_attr != NULL) { diff --git a/content/handlers/html/dom_event.c b/content/handlers/html/dom_event.c index 36a020b6d..d42882515 100644 --- a/content/handlers/html/dom_event.c +++ b/content/handlers/html/dom_event.c @@ -25,6 +25,7 @@ #include <string.h> #include "utils/config.h" +#include "utils/utils.h" #include "utils/corestrings.h" #include "utils/nsoption.h" #include "utils/log.h" @@ -622,7 +623,9 @@ dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw) break; case DOM_HTML_ELEMENT_TYPE_STYLE: - html_css_process_style(htmlc, (dom_node *)node); + if (nsoption_bool(author_level_css)) { + html_css_process_style(htmlc, (dom_node *)node); + } break; case DOM_HTML_ELEMENT_TYPE_SCRIPT: @@ -689,6 +692,7 @@ dom_default_action_DOMNodeInsertedIntoDocument_cb(struct dom_event *evt, switch (tag_type) { case DOM_HTML_ELEMENT_TYPE_SCRIPT: dom_SCRIPT_showed_up(htmlc, (dom_html_script_element *) node); + fallthrough; default: break; } @@ -730,11 +734,15 @@ dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw) switch (tag_type) { case DOM_HTML_ELEMENT_TYPE_STYLE: - html_css_update_style(htmlc, (dom_node *)node); + if (nsoption_bool(author_level_css)) { + html_css_update_style(htmlc, + (dom_node *)node); + } break; case DOM_HTML_ELEMENT_TYPE_TEXTAREA: case DOM_HTML_ELEMENT_TYPE_INPUT: html_texty_element_update(htmlc, (dom_node *)node); + fallthrough; default: break; } diff --git a/content/handlers/html/form.c b/content/handlers/html/form.c index 97ec19518..9b6768a56 100644 --- a/content/handlers/html/form.c +++ b/content/handlers/html/form.c @@ -41,6 +41,7 @@ #include "utils/utf8.h" #include "utils/ascii.h" #include "netsurf/browser_window.h" +#include "netsurf/inttypes.h" #include "netsurf/mouse.h" #include "netsurf/plotters.h" #include "netsurf/misc.h" @@ -486,7 +487,7 @@ form_dom_to_data_select(dom_html_select_element *select_element, &option_element); if (exp != DOM_NO_ERR) { NSLOG(netsurf, INFO, - "Could not get options item %d", option_index); + "Could not get options item %"PRId32, option_index); res = NSERROR_DOM; } else { res = form_dom_to_data_select_option( @@ -1100,7 +1101,7 @@ form_dom_to_data(struct form *form, exp = dom_html_collection_item(elements, element_idx, &element); if (exp != DOM_NO_ERR) { NSLOG(netsurf, INFO, - "retrieving form element %d failed with %d", + "retrieving form element %"PRIu32" failed with %d", element_idx, exp); res = NSERROR_DOM; goto form_dom_to_data_error; @@ -1110,7 +1111,7 @@ form_dom_to_data(struct form *form, exp = dom_node_get_node_name(element, &nodename); if (exp != DOM_NO_ERR) { NSLOG(netsurf, INFO, - "getting element node name %d failed with %d", + "getting element node name %"PRIu32" failed with %d", element_idx, exp); dom_node_unref(element); res = NSERROR_DOM; @@ -2001,15 +2002,33 @@ void form_radio_set(struct form_control *radio) if (radio->selected) return; - for (control = radio->form->controls; control; - control = control->next) { + /* Clear selected state for other controls in + * the same radio button group */ + for (control = radio->form->controls; + control != NULL; + control = control->next) { + /* Only interested in radio inputs */ if (control->type != GADGET_RADIO) continue; + + /* Ignore ourself */ if (control == radio) continue; - if (strcmp(control->name, radio->name) != 0) + + /* Ignore inputs where: + * a) this or the other control have no name attribute + * b) this or the other control have an empty name attribute + * c) the control names do not match + */ + if ((control->name == NULL) || + (radio->name == NULL) || + (control->name[0] == '\0') || + (radio->name[0] == '\0') || + strcmp(control->name, radio->name) != 0) continue; + /* Other control is in the same radio button group: clear its + * selected state */ if (control->selected) { control->selected = false; dom_html_input_element_set_checked(control->node, false); diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c index 2b6b1a865..82f5f1388 100644 --- a/content/handlers/html/html.c +++ b/content/handlers/html/html.c @@ -123,7 +123,7 @@ bool fire_generic_dom_event(dom_string *type, dom_node *target, return false; } NSLOG(netsurf, INFO, "Dispatching '%*s' against %p", - dom_string_length(type), dom_string_data(type), target); + (int)dom_string_length(type), dom_string_data(type), target); result = fire_dom_event(evt, target); dom_event_unref(evt); return result; @@ -200,7 +200,7 @@ bool fire_dom_keyboard_event(dom_string *type, dom_node *target, } NSLOG(netsurf, INFO, "Dispatching '%*s' against %p", - dom_string_length(type), dom_string_data(type), target); + (int)dom_string_length(type), dom_string_data(type), target); result = fire_dom_event((dom_event *) evt, target); dom_event_unref(evt); diff --git a/content/handlers/html/interaction.c b/content/handlers/html/interaction.c index 026ef1ee7..0a843e026 100644 --- a/content/handlers/html/interaction.c +++ b/content/handlers/html/interaction.c @@ -899,7 +899,7 @@ gadget_mouse_action(html_content *html, } free(oldcoords); } - /* Fall through */ + fallthrough; case GADGET_SUBMIT: if (mas->gadget.control->form) { @@ -1465,7 +1465,7 @@ html_mouse_action(struct content *c, int x, int y) { html_content *html = (html_content *)c; - nserror res; + nserror res = NSERROR_OK; /* handle open select menu */ if (html->visible_select_menu != NULL) { @@ -1493,7 +1493,7 @@ html_mouse_action(struct content *c, break; case HTML_DRAG_NONE: - res = mouse_action_drag_none(html, bw, mouse, x, y); + res = mouse_action_drag_none(html, bw, mouse, x, y); break; default: @@ -1669,7 +1669,7 @@ void html_set_drag_type(html_content *html, html_drag_type drag_type, case HTML_DRAG_SELECTION: assert(drag_owner.no_owner == true); - /* Fall through */ + fallthrough; case HTML_DRAG_TEXTAREA_SELECTION: case HTML_DRAG_CONTENT_SELECTION: msg_data.drag.type = CONTENT_DRAG_SELECTION; @@ -1800,7 +1800,7 @@ void html_set_selection(html_content *html, html_selection_type selection_type, break; case HTML_SELECTION_SELF: assert(selection_owner.none == false); - /* fall through */ + fallthrough; case HTML_SELECTION_TEXTAREA: case HTML_SELECTION_CONTENT: msg_data.selection.selection = true; diff --git a/content/handlers/html/layout.c b/content/handlers/html/layout.c index d9de14b37..280e5aade 100644 --- a/content/handlers/html/layout.c +++ b/content/handlers/html/layout.c @@ -259,15 +259,13 @@ static void layout_minmax_table(struct box *table, const html_content *content) { unsigned int i, j; + int width; int border_spacing_h = 0; int table_min = 0, table_max = 0; int extra_fixed = 0; float extra_frac = 0; struct column *col; struct box *row_group, *row, *cell; - enum css_width_e wtype; - css_fixed value = 0; - css_unit unit = CSS_UNIT_PX; /* check if the widths have already been calculated */ if (table->max_width != UNKNOWN_MAX_WIDTH) @@ -402,12 +400,8 @@ static void layout_minmax_table(struct box *table, } /* fixed width takes priority, unless it is too narrow */ - wtype = css_computed_width(table->style, &value, &unit); - if (wtype == CSS_WIDTH_SET && unit != CSS_UNIT_PCT) { - int width = FIXTOINT(css_unit_len2device_px( - table->style, - &content->unit_len_ctx, - value, unit)); + if (css_computed_width(table->style, &content->unit_len_ctx, + -1, &width) == CSS_WIDTH_SET) { if (table_min < width) table_min = width; if (table_max < width) @@ -669,35 +663,28 @@ layout_minmax_line(struct box *first, /* inline replaced, 10.3.2 and 10.6.2 */ assert(b->style); - /* calculate box width */ - wtype = css_computed_width(b->style, &value, &unit); bs = css_computed_box_sizing(block->style); - if (wtype == CSS_WIDTH_SET) { - if (unit == CSS_UNIT_PCT) { - width = AUTO; - } else { - width = FIXTOINT(css_unit_len2device_px( - b->style, - &content->unit_len_ctx, - value, unit)); - if (bs == CSS_BOX_SIZING_BORDER_BOX) { - fixed = frac = 0; - calculate_mbp_width(&content->unit_len_ctx, - block->style, LEFT, - false, true, true, - &fixed, &frac); - calculate_mbp_width(&content->unit_len_ctx, - block->style, RIGHT, - false, true, true, - &fixed, &frac); - if (width < fixed) { - width = fixed; - } + /* calculate box width */ + wtype = css_computed_width(b->style, + &content->unit_len_ctx, -1, &width); + if (wtype == CSS_WIDTH_SET) { + if (bs == CSS_BOX_SIZING_BORDER_BOX) { + fixed = frac = 0; + calculate_mbp_width(&content->unit_len_ctx, + block->style, LEFT, + false, true, true, + &fixed, &frac); + calculate_mbp_width(&content->unit_len_ctx, + block->style, RIGHT, + false, true, true, + &fixed, &frac); + if (width < fixed) { + width = fixed; } - if (width < 0) - width = 0; } + if (width < 0) + width = 0; } else { width = AUTO; } @@ -900,7 +887,7 @@ static void layout_minmax_block( return; if (block->style != NULL) { - wtype = css_computed_width(block->style, &width, &wunit); + wtype = css_computed_width_static(block->style, &width, &wunit); htype = css_computed_height(block->style, &height, &hunit); bs = css_computed_box_sizing(block->style); } @@ -1049,11 +1036,11 @@ static void layout_minmax_block( enum css_min_width_e min_type; css_unit unit = CSS_UNIT_PX; css_fixed value = 0; + int width; - if (wtype == CSS_WIDTH_SET && wunit != CSS_UNIT_PCT) { - min = max = FIXTOINT( - css_unit_len2device_px(block->style, - &content->unit_len_ctx, width, wunit)); + if (css_computed_width(block->style, &content->unit_len_ctx, + -1, &width) == CSS_WIDTH_SET) { + min = max = width; using_max_border_box = border_box; using_min_border_box = border_box; } @@ -1629,7 +1616,6 @@ bool layout_table( struct box **row_span_cell; struct column *col; const css_computed_style *style = table->style; - enum css_width_e wtype; enum css_height_e htype; css_fixed value = 0; css_unit unit = CSS_UNIT_PX; @@ -1707,17 +1693,8 @@ bool layout_table( } /* find specified table width, or available width if auto-width */ - wtype = css_computed_width(style, &value, &unit); - if (wtype == CSS_WIDTH_SET) { - if (unit == CSS_UNIT_PCT) { - table_width = FPCT_OF_INT_TOINT(value, available_width); - } else { - table_width = - FIXTOINT(css_unit_len2device_px( - style, &content->unit_len_ctx, - value, unit)); - } - + if (css_computed_width(style, &content->unit_len_ctx, + available_width, &table_width) == CSS_WIDTH_SET) { /* specified width includes border */ table_width -= table->border[LEFT].width + table->border[RIGHT].width; @@ -2305,7 +2282,7 @@ static bool layout_block_object(struct box *block) NSLOG(layout, DEBUG, "block %p, object %p, width %i", block, hlcache_handle_get_url(block->object), block->width); - if (content_get_type(block->object) == CONTENT_HTML) { + if (content_can_reformat(block->object)) { content_reformat(block->object, false, block->width, 1); } else { /* Non-HTML objects */ @@ -2984,7 +2961,7 @@ layout_line(struct box *first, } /* Reformat object to new box size */ - if (b->object && content_get_type(b->object) == CONTENT_HTML && + if (b->object && content_can_reformat(b->object) && b->width != content_get_available_width(b->object)) { css_fixed value = 0; @@ -3711,7 +3688,7 @@ bool layout_block_context( css_fixed width = 0; css_unit unit = CSS_UNIT_PX; - wtype = css_computed_width(box->style, &width, + wtype = css_computed_width_static(box->style, &width, &unit); if (wtype == CSS_WIDTH_AUTO) { @@ -3840,7 +3817,7 @@ bool layout_block_context( css_fixed width = 0; css_unit unit = CSS_UNIT_PX; - wtype = css_computed_width(box->style, + wtype = css_computed_width_static(box->style, &width, &unit); x0 = cx; @@ -4194,7 +4171,7 @@ layout__get_ol_reversed(dom_node *ol_node) */ static bool layout__get_list_item_count( - dom_node *list_owner, int *count_out) + dom_node *list_owner, dom_long *count_out) { dom_html_element_type tag_type; dom_exception exc; @@ -4266,7 +4243,7 @@ layout__ordered_list_count( dom_exception exc; dom_node *child; int step = 1; - int next; + dom_long next; if (box->node == NULL) { return; diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c index 61adcaa6c..bde3c5bd1 100644 --- a/content/handlers/html/layout_flex.c +++ b/content/handlers/html/layout_flex.c @@ -960,7 +960,6 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx, switch (lh__box_align_self(ctx->flex, b)) { default: - /* Fall through. */ case CSS_ALIGN_SELF_STRETCH: if (lh__box_size_cross_is_auto(ctx->horizontal, b)) { *box_size_cross += cross_free_space; @@ -970,7 +969,7 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx, return; } } - /* Fall through. */ + fallthrough; case CSS_ALIGN_SELF_FLEX_START: *box_pos_cross = ctx->flex->padding[cross_start] + line->pos + @@ -986,7 +985,6 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx, break; case CSS_ALIGN_SELF_BASELINE: - /* Fall through. */ case CSS_ALIGN_SELF_CENTER: *box_pos_cross = ctx->flex->padding[cross_start] + line->pos + cross_free_space / 2 + diff --git a/content/handlers/html/layout_internal.h b/content/handlers/html/layout_internal.h index d094462ec..e98e7a5f5 100644 --- a/content/handlers/html/layout_internal.h +++ b/content/handlers/html/layout_internal.h @@ -26,9 +26,6 @@ #define AUTO INT_MIN -/* Fixed point percentage (a) of an integer (b), to an integer */ -#define FPCT_OF_INT_TOINT(a, b) (FIXTOINT(FDIV((a * b), F_100))) - /** * Layout a block formatting context. * @@ -283,7 +280,7 @@ static inline bool lh__box_size_cross_is_auto( return css_computed_height(b->style, &length, &unit) == CSS_HEIGHT_AUTO; } else { - return css_computed_width(b->style, + return css_computed_width_static(b->style, &length, &unit) == CSS_WIDTH_AUTO; } } @@ -450,28 +447,12 @@ static inline void layout_find_dimensions( unsigned int i; if (width) { - enum css_width_e wtype; - css_fixed value = 0; - css_unit unit = CSS_UNIT_PX; - - wtype = css_computed_width(style, &value, &unit); - - if (wtype == CSS_WIDTH_SET) { - if (unit == CSS_UNIT_PCT) { - *width = FPCT_OF_INT_TOINT( - value, available_width); - } else { - *width = FIXTOINT(css_unit_len2device_px( - style, unit_len_ctx, - value, unit)); - } - } else { - *width = AUTO; - } - - if (*width != AUTO) { + if (css_computed_width(style, unit_len_ctx, + available_width, width) == CSS_WIDTH_SET) { layout_handle_box_sizing(unit_len_ctx, box, available_width, true, width); + } else { + *width = AUTO; } } diff --git a/content/handlers/html/redraw_border.c b/content/handlers/html/redraw_border.c index 39ed432cd..3a1f6f308 100644 --- a/content/handlers/html/redraw_border.c +++ b/content/handlers/html/redraw_border.c @@ -25,6 +25,7 @@ #include <stdbool.h> #include <stdlib.h> +#include "utils/utils.h" #include "utils/log.h" #include "netsurf/plotters.h" #include "netsurf/css.h" @@ -121,7 +122,7 @@ html_redraw_border_plot(const int side, switch (style) { case CSS_BORDER_STYLE_DOTTED: plot_style_bdr.stroke_type = PLOT_OP_TYPE_DOT; - /* fall through */ + fallthrough; case CSS_BORDER_STYLE_DASHED: rect.x0 = (p[0] + p[2]) / 2; rect.y0 = (p[1] + p[3]) / 2; @@ -131,7 +132,7 @@ html_redraw_border_plot(const int side, break; case CSS_BORDER_STYLE_SOLID: - /* fall through to default */ + /* solid is the default */ default: if (rectangular || thickness == 1) { @@ -190,7 +191,7 @@ html_redraw_border_plot(const int side, case CSS_BORDER_STYLE_GROOVE: light = 3 - light; - /* fall through */ + fallthrough; case CSS_BORDER_STYLE_RIDGE: /* choose correct colours for each part of the border line */ if (light <= 1) { @@ -300,7 +301,7 @@ html_redraw_border_plot(const int side, case CSS_BORDER_STYLE_INSET: light = (light + 2) % 4; - /* fall through */ + fallthrough; case CSS_BORDER_STYLE_OUTSET: /* choose correct colours for each part of the border line */ switch (light) { diff --git a/content/handlers/html/script.c b/content/handlers/html/script.c index 962386d68..554fc4f70 100644 --- a/content/handlers/html/script.c +++ b/content/handlers/html/script.c @@ -495,6 +495,7 @@ exec_src_script(html_content *c, switch (script_type) { case HTML_SCRIPT_SYNC: ret = DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED; + break; case HTML_SCRIPT_ASYNC: break; diff --git a/content/handlers/html/table.c b/content/handlers/html/table.c index 4ffcceab9..a0f5b94fa 100644 --- a/content/handlers/html/table.c +++ b/content/handlers/html/table.c @@ -26,6 +26,7 @@ #include <dom/dom.h> #include "utils/log.h" +#include "utils/utils.h" #include "utils/talloc.h" #include "css/utils.h" @@ -93,27 +94,27 @@ table_border_is_more_eyecatching(const css_unit_ctx *unit_len_ctx, /* 3b -- sort by style */ switch (a->style) { - case CSS_BORDER_STYLE_DOUBLE: impact++; /* Fall through */ - case CSS_BORDER_STYLE_SOLID: impact++; /* Fall through */ - case CSS_BORDER_STYLE_DASHED: impact++; /* Fall through */ - case CSS_BORDER_STYLE_DOTTED: impact++; /* Fall through */ - case CSS_BORDER_STYLE_RIDGE: impact++; /* Fall through */ - case CSS_BORDER_STYLE_OUTSET: impact++; /* Fall through */ - case CSS_BORDER_STYLE_GROOVE: impact++; /* Fall through */ - case CSS_BORDER_STYLE_INSET: impact++; /* Fall through */ + case CSS_BORDER_STYLE_DOUBLE: impact++; fallthrough; + case CSS_BORDER_STYLE_SOLID: impact++; fallthrough; + case CSS_BORDER_STYLE_DASHED: impact++; fallthrough; + case CSS_BORDER_STYLE_DOTTED: impact++; fallthrough; + case CSS_BORDER_STYLE_RIDGE: impact++; fallthrough; + case CSS_BORDER_STYLE_OUTSET: impact++; fallthrough; + case CSS_BORDER_STYLE_GROOVE: impact++; fallthrough; + case CSS_BORDER_STYLE_INSET: impact++; fallthrough; default: break; } switch (b->style) { - case CSS_BORDER_STYLE_DOUBLE: impact--; /* Fall through */ - case CSS_BORDER_STYLE_SOLID: impact--; /* Fall through */ - case CSS_BORDER_STYLE_DASHED: impact--; /* Fall through */ - case CSS_BORDER_STYLE_DOTTED: impact--; /* Fall through */ - case CSS_BORDER_STYLE_RIDGE: impact--; /* Fall through */ - case CSS_BORDER_STYLE_OUTSET: impact--; /* Fall through */ - case CSS_BORDER_STYLE_GROOVE: impact--; /* Fall through */ - case CSS_BORDER_STYLE_INSET: impact--; /* Fall through */ + case CSS_BORDER_STYLE_DOUBLE: impact--; fallthrough; + case CSS_BORDER_STYLE_SOLID: impact--; fallthrough; + case CSS_BORDER_STYLE_DASHED: impact--; fallthrough; + case CSS_BORDER_STYLE_DOTTED: impact--; fallthrough; + case CSS_BORDER_STYLE_RIDGE: impact--; fallthrough; + case CSS_BORDER_STYLE_OUTSET: impact--; fallthrough; + case CSS_BORDER_STYLE_GROOVE: impact--; fallthrough; + case CSS_BORDER_STYLE_INSET: impact--; fallthrough; default: break; } @@ -128,20 +129,20 @@ table_border_is_more_eyecatching(const css_unit_ctx *unit_len_ctx, /** \todo COL/COL_GROUP */ switch (a_src) { - case BOX_TABLE_CELL: impact++; /* Fall through */ - case BOX_TABLE_ROW: impact++; /* Fall through */ - case BOX_TABLE_ROW_GROUP: impact++; /* Fall through */ - case BOX_TABLE: impact++; /* Fall through */ + case BOX_TABLE_CELL: impact++; fallthrough; + case BOX_TABLE_ROW: impact++; fallthrough; + case BOX_TABLE_ROW_GROUP: impact++; fallthrough; + case BOX_TABLE: impact++; fallthrough; default: break; } /** \todo COL/COL_GROUP */ switch (b_src) { - case BOX_TABLE_CELL: impact--; /* Fall through */ - case BOX_TABLE_ROW: impact--; /* Fall through */ - case BOX_TABLE_ROW_GROUP: impact--; /* Fall through */ - case BOX_TABLE: impact--; /* Fall through */ + case BOX_TABLE_CELL: impact--; fallthrough; + case BOX_TABLE_ROW: impact--; fallthrough; + case BOX_TABLE_ROW_GROUP: impact--; fallthrough; + case BOX_TABLE: impact--; fallthrough; default: break; } @@ -851,7 +852,7 @@ table_calculate_column_types(const css_unit_ctx *unit_len_ctx, struct box *table col[i].positioned = false; } - type = css_computed_width(cell->style, &value, &unit); + type = css_computed_width_static(cell->style, &value, &unit); /* fixed width takes priority over any other width type */ if (col[i].type != COLUMN_WIDTH_FIXED && @@ -918,7 +919,7 @@ table_calculate_column_types(const css_unit_ctx *unit_len_ctx, struct box *table if (!unknown_columns) continue; - type = css_computed_width(cell->style, &value, &unit); + type = css_computed_width_static(cell->style, &value, &unit); /* if cell is fixed width, and all spanned columns are fixed * or unknown width, split extra width among unknown columns */ diff --git a/content/handlers/image/Makefile b/content/handlers/image/Makefile index afc90f407..ac052b37a 100644 --- a/content/handlers/image/Makefile +++ b/content/handlers/image/Makefile @@ -7,6 +7,7 @@ S_IMAGE_$(NETSURF_USE_BMP) += bmp.c S_IMAGE_$(NETSURF_USE_GIF) += gif.c S_IMAGE_$(NETSURF_USE_BMP) += ico.c S_IMAGE_$(NETSURF_USE_JPEG) += jpeg.c +S_IMAGE_$(NETSURF_USE_JPEGXL) += jpegxl.c S_IMAGE_$(NETSURF_USE_ROSPRITE) += nssprite.c S_IMAGE_$(NETSURF_USE_PNG) += png.c S_IMAGE_$(NETSURF_USE_NSSVG) += svg.c diff --git a/content/handlers/image/bmp.c b/content/handlers/image/bmp.c index 3fec2cc75..7139d86b4 100644 --- a/content/handlers/image/bmp.c +++ b/content/handlers/image/bmp.c @@ -77,7 +77,7 @@ static nserror nsbmp_create_bmp_data(nsbmp_content *bmp) .bitmap_get_buffer = guit->bitmap->get_buffer, }; - bmp->bmp = calloc(sizeof(struct bmp_image), 1); + bmp->bmp = calloc(1, sizeof(struct bmp_image)); if (bmp->bmp == NULL) { content_broadcast_error(&bmp->base, NSERROR_NOMEM, NULL); return NSERROR_NOMEM; diff --git a/content/handlers/image/ico.c b/content/handlers/image/ico.c index 871da41a9..6bca2a137 100644 --- a/content/handlers/image/ico.c +++ b/content/handlers/image/ico.c @@ -74,7 +74,7 @@ static nserror nsico_create_ico_data(nsico_content *c) .bitmap_get_buffer = guit->bitmap->get_buffer, }; - c->ico = calloc(sizeof(ico_collection), 1); + c->ico = calloc(1, sizeof(ico_collection)); if (c->ico == NULL) { content_broadcast_error(&c->base, NSERROR_NOMEM, NULL); return NSERROR_NOMEM; diff --git a/content/handlers/image/image.c b/content/handlers/image/image.c index 3107ee495..2bd5f5f8d 100644 --- a/content/handlers/image/image.c +++ b/content/handlers/image/image.c @@ -32,6 +32,7 @@ #include "image/gif.h" #include "image/ico.h" #include "image/jpeg.h" +#include "image/jpegxl.h" #include "image/nssprite.h" #include "image/png.h" #include "image/rsvg.h" @@ -72,6 +73,12 @@ nserror image_init(void) return error; #endif +#ifdef WITH_JPEGXL + error = nsjpegxl_init(); + if (error != NSERROR_OK) + return error; +#endif + #ifdef WITH_PNG error = nspng_init(); if (error != NSERROR_OK) diff --git a/content/handlers/image/jpeg.c b/content/handlers/image/jpeg.c index e07fb47bb..93372f15a 100644 --- a/content/handlers/image/jpeg.c +++ b/content/handlers/image/jpeg.c @@ -206,7 +206,9 @@ static inline void nsjpeg__decode_rgb( uint8_t * volatile pixels, size_t rowstride) { +#if RGB_RED != 0 || RGB_GREEN != 1 || RGB_BLUE != 2 || RGB_PIXELSIZE != 4 int width = cinfo->output_width; +#endif do { JSAMPROW scanlines[1] = { diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c new file mode 100644 index 000000000..01c704577 --- /dev/null +++ b/content/handlers/image/jpegxl.c @@ -0,0 +1,340 @@ +/* + * Copyright 2023 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * \file + * implementation of content handling for image/jpegxl + * + * This implementation uses the JXL library. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <setjmp.h> +#include <string.h> + +#include <jxl/decode.h> + +#include "utils/utils.h" +#include "utils/log.h" +#include "utils/messages.h" +#include "netsurf/bitmap.h" +#include "content/llcache.h" +#include "content/content.h" +#include "content/content_protected.h" +#include "content/content_factory.h" +#include "desktop/gui_internal.h" +#include "desktop/bitmap.h" + +#include "image/image_cache.h" + +#include "image/jpegxl.h" + + +/** + * output image format + */ +static const JxlPixelFormat jxl_output_format = { + .num_channels = 4, + .data_type = JXL_TYPE_UINT8, + .endianness = JXL_LITTLE_ENDIAN, + .align = 0, +}; + +/** + * Content create entry point. + */ +static nserror +nsjpegxl_create(const content_handler *handler, + lwc_string *imime_type, const struct http_parameter *params, + llcache_handle *llcache, const char *fallback_charset, + bool quirks, struct content **c) +{ + struct content *jpeg; + nserror error; + + jpeg = calloc(1, sizeof(struct content)); + if (jpeg == NULL) + return NSERROR_NOMEM; + + error = content__init(jpeg, handler, imime_type, params, + llcache, fallback_charset, quirks); + if (error != NSERROR_OK) { + free(jpeg); + return error; + } + + *c = jpeg; + + return NSERROR_OK; +} + +/** + * create a bitmap from jpeg xl content. + */ +static struct bitmap * +jpegxl_cache_convert(struct content *c) +{ + struct bitmap * bitmap = NULL; + JxlDecoder *jxldec; + JxlDecoderStatus decstatus; + JxlBasicInfo binfo; + const uint8_t *src_data; + size_t src_size; + uint8_t * output; + bitmap_fmt_t jxl_fmt = { + /** TODO: At the moment we have to set the layout to the only + * pixel layout that libjxl supports. It looks like they + * plan to add support for decoding to other layouts + * in the future, as shown by the TODO in the docs: + * + * https://libjxl.readthedocs.io/en/latest/api_common.html#_CPPv414JxlPixelFormat + */ + .layout = BITMAP_LAYOUT_R8G8B8A8, + .pma = bitmap_fmt.pma, + }; + + jxldec = JxlDecoderCreate(NULL); + if (jxldec == NULL) { + NSLOG(netsurf, ERROR, "Unable to allocate decoder"); + return NULL; + } + + decstatus = JxlDecoderSetUnpremultiplyAlpha(jxldec, !bitmap_fmt.pma); + if (decstatus != JXL_DEC_SUCCESS) { + NSLOG(netsurf, ERROR, "unable to set premultiplied alpha status: %d", + decstatus); + JxlDecoderDestroy(jxldec); + return NULL; + } + + decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_FULL_IMAGE); + if (decstatus != JXL_DEC_SUCCESS) { + NSLOG(netsurf, ERROR, "Unable to subscribe"); + return NULL; + } + src_data = content__get_source_data(c, &src_size); + + decstatus = JxlDecoderSetInput(jxldec, src_data, src_size); + if (decstatus != JXL_DEC_SUCCESS) { + NSLOG(netsurf, ERROR, "unable to set input"); + return NULL; + } + + decstatus = JxlDecoderProcessInput(jxldec); + if (decstatus != JXL_DEC_NEED_IMAGE_OUT_BUFFER) { + NSLOG(netsurf, ERROR, + "expected status JXL_DEC_NEED_IMAGE_OUT_BUFFER(%d) got %d", + JXL_DEC_NEED_IMAGE_OUT_BUFFER, + decstatus); + JxlDecoderDestroy(jxldec); + return NULL; + } + + decstatus = JxlDecoderGetBasicInfo(jxldec, &binfo); + if (decstatus != JXL_DEC_SUCCESS) { + NSLOG(netsurf, ERROR, "unable to get basic info status:%d",decstatus); + JxlDecoderDestroy(jxldec); + return NULL; + } + + /* create bitmap with appropriate opacity */ + if (binfo.alpha_bits > 0) { + bitmap = guit->bitmap->create(c->width, c->height, BITMAP_OPAQUE); + } else { + bitmap = guit->bitmap->create(c->width, c->height, BITMAP_NONE); + } + if (bitmap == NULL) { + /* empty bitmap could not be created */ + JxlDecoderDestroy(jxldec); + return NULL; + } + + /* ensure buffer was allocated */ + output = guit->bitmap->get_buffer(bitmap); + if (output == NULL) { + /* bitmap with no buffer available */ + guit->bitmap->destroy(bitmap); + JxlDecoderDestroy(jxldec); + return NULL; + } + decstatus = JxlDecoderSetImageOutBuffer(jxldec, &jxl_output_format, output, c->size); + if (decstatus != JXL_DEC_SUCCESS) { + NSLOG(netsurf, ERROR, "unable to set output buffer callback status:%d",decstatus); + guit->bitmap->destroy(bitmap); + JxlDecoderDestroy(jxldec); + return NULL; + } + + decstatus = JxlDecoderProcessInput(jxldec); + if (decstatus != JXL_DEC_FULL_IMAGE) { + NSLOG(netsurf, ERROR, "did not get decode event"); + guit->bitmap->destroy(bitmap); + JxlDecoderDestroy(jxldec); + return NULL; + } + + JxlDecoderDestroy(jxldec); + + bitmap_format_to_client(bitmap, &jxl_fmt); + guit->bitmap->modified(bitmap); + + return bitmap; +} + +/** + * report failiure + */ +static bool jxl_report_fail(struct content *c, JxlDecoderStatus decstatus, const char *msg) +{ + union content_msg_data msg_data; + NSLOG(netsurf, ERROR, "%s decoder status:%d", msg, decstatus); + msg_data.errordata.errorcode = NSERROR_UNKNOWN; + msg_data.errordata.errormsg = msg; + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + return false; +} + +/** + * Convert a CONTENT_JPEGXL for display. + */ +static bool nsjpegxl_convert(struct content *c) +{ + JxlDecoder *jxldec; + JxlSignature decsig; + JxlDecoderStatus decstatus = JXL_DEC_ERROR; + JxlBasicInfo binfo; + union content_msg_data msg_data; + const uint8_t *data; + size_t size; + char *title; + size_t image_size; + + /* check image header is valid and get width/height */ + data = content__get_source_data(c, &size); + + decsig = JxlSignatureCheck(data,size); + if ((decsig != JXL_SIG_CODESTREAM) && (decsig != JXL_SIG_CONTAINER)) { + NSLOG(netsurf, ERROR, "signature failed"); + msg_data.errordata.errorcode = NSERROR_UNKNOWN; + msg_data.errordata.errormsg = "Signature failed"; + content_broadcast(c, CONTENT_MSG_ERROR, &msg_data); + return false; + } + + jxldec = JxlDecoderCreate(NULL); + if (jxldec == NULL) { + return jxl_report_fail(c, decstatus, "Unable to allocate decoder"); + } + decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_BASIC_INFO); + if (decstatus != JXL_DEC_SUCCESS) { + return jxl_report_fail(c, decstatus, "Unable to subscribe"); + } + decstatus = JxlDecoderSetInput(jxldec, data,size); + if (decstatus != JXL_DEC_SUCCESS) { + return jxl_report_fail(c, decstatus, "unable to set input"); + } + decstatus = JxlDecoderProcessInput(jxldec); + if (decstatus != JXL_DEC_BASIC_INFO) { + return jxl_report_fail(c, decstatus, "did not get basic info event"); + } + decstatus = JxlDecoderGetBasicInfo(jxldec, &binfo); + if (decstatus != JXL_DEC_SUCCESS) { + return jxl_report_fail(c, decstatus, "unable to get basic info"); + } + decstatus = JxlDecoderImageOutBufferSize(jxldec, &jxl_output_format, &image_size); + if (decstatus != JXL_DEC_SUCCESS) { + return jxl_report_fail(c, decstatus, "unable get image size"); + } + + JxlDecoderDestroy(jxldec); + + NSLOG(netsurf, INFO, "got basic info size:%ld x:%d y:%d", image_size, binfo.xsize, binfo.ysize); + + c->width = binfo.xsize; + c->height = binfo.ysize; + c->size = image_size; + + image_cache_add(c, NULL, jpegxl_cache_convert); + + /* set title text */ + title = messages_get_buff("JPEGXLTitle", + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); + if (title != NULL) { + content__set_title(c, title); + free(title); + } + + content_set_ready(c); + content_set_done(c); + content_set_status(c, ""); /* Done: update status bar */ + + return true; +} + + +/** + * Clone content. + */ +static nserror nsjpegxl_clone(const struct content *old, struct content **newc) +{ + struct content *jpegxl_c; + nserror error; + + jpegxl_c = calloc(1, sizeof(struct content)); + if (jpegxl_c == NULL) + return NSERROR_NOMEM; + + error = content__clone(old, jpegxl_c); + if (error != NSERROR_OK) { + content_destroy(jpegxl_c); + return error; + } + + /* re-convert if the content is ready */ + if ((old->status == CONTENT_STATUS_READY) || + (old->status == CONTENT_STATUS_DONE)) { + if (nsjpegxl_convert(jpegxl_c) == false) { + content_destroy(jpegxl_c); + return NSERROR_CLONE_FAILED; + } + } + + *newc = jpegxl_c; + + return NSERROR_OK; +} + +static const content_handler nsjpegxl_content_handler = { + .create = nsjpegxl_create, + .data_complete = nsjpegxl_convert, + .destroy = image_cache_destroy, + .redraw = image_cache_redraw, + .clone = nsjpegxl_clone, + .get_internal = image_cache_get_internal, + .type = image_cache_content_type, + .is_opaque = image_cache_is_opaque, + .no_share = false, +}; + +static const char *nsjpegxl_types[] = { + "image/jxl", +}; + +CONTENT_FACTORY_REGISTER_TYPES(nsjpegxl, nsjpegxl_types, nsjpegxl_content_handler); diff --git a/content/handlers/image/jpegxl.h b/content/handlers/image/jpegxl.h new file mode 100644 index 000000000..e37d9344e --- /dev/null +++ b/content/handlers/image/jpegxl.h @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** \file + * Content for image/jpegxl (interface). + */ + +#ifndef _NETSURF_IMAGE_JPEGXL_H_ +#define _NETSURF_IMAGE_JPEGXL_H_ + +nserror nsjpegxl_init(void); + +#endif diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index a98c48aa2..c18f49063 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -124,7 +124,7 @@ static bool nssprite_convert(struct content *c) content_broadcast_error(c, NSERROR_NOMEM, NULL); return false; } - uint32_t* imagebuf = (uint32_t *)guit->bitmap->get_buffer(nssprite->bitmap); + uint32_t* imagebuf = (uint32_t *)(void *)guit->bitmap->get_buffer(nssprite->bitmap); if (!imagebuf) { content_broadcast_error(c, NSERROR_NOMEM, NULL); return false; diff --git a/content/handlers/image/webp.c b/content/handlers/image/webp.c index da13316bc..c04c0efd2 100644 --- a/content/handlers/image/webp.c +++ b/content/handlers/image/webp.c @@ -142,7 +142,7 @@ webp_cache_convert(struct content *c) default: /* WebP has no ABGR function, fall back to default. */ webp_fmt.layout = BITMAP_LAYOUT_R8G8B8A8; - /* Fall through. */ + fallthrough; case BITMAP_LAYOUT_R8G8B8A8: decoded = WebPDecodeRGBAInto(source_data, source_size, pixels, rowstride * webpfeatures.height, rowstride); diff --git a/content/handlers/javascript/duktape/Window.bnd b/content/handlers/javascript/duktape/Window.bnd index f7d143f6c..a5ff2002d 100644 --- a/content/handlers/javascript/duktape/Window.bnd +++ b/content/handlers/javascript/duktape/Window.bnd @@ -139,7 +139,7 @@ window_alloc_new_callback(duk_context *ctx, int timeout) { size_t new_handle = next_handle++; - window_schedule_t *sched = calloc(sizeof *sched, 1); + window_schedule_t *sched = calloc(1, sizeof *sched); if (sched == NULL) { return new_handle; } diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c index 52a9c82cf..a780b0067 100644 --- a/content/handlers/javascript/duktape/dukky.c +++ b/content/handlers/javascript/duktape/dukky.c @@ -385,7 +385,7 @@ static void dukky_html_element_class_from_tag_type(dom_html_element_type type, break; case DOM_HTML_ELEMENT_TYPE__COUNT: assert(type != DOM_HTML_ELEMENT_TYPE__COUNT); - /* fallthrough */ + fallthrough; case DOM_HTML_ELEMENT_TYPE__UNKNOWN: SET_HTML_CLASS(UNKNOWN) break; @@ -1156,7 +1156,7 @@ static void dukky_generic_event_handler(dom_event *evt, void *pw) NSLOG(dukky, DEBUG, "Unable to find the event name"); return; } - NSLOG(dukky, DEBUG, "Event's name is %*s", dom_string_length(name), + NSLOG(dukky, DEBUG, "Event's name is %*s", (int)dom_string_length(name), dom_string_data(name)); exc = dom_event_get_event_phase(evt, &phase); if (exc != DOM_NO_ERR) { @@ -1394,10 +1394,10 @@ void dukky_register_event_listener_for(duk_context *ctx, if (exc != DOM_NO_ERR) { NSLOG(dukky, DEBUG, "Unable to register listener for %p.%*s", ele, - dom_string_length(name), dom_string_data(name)); + (int)dom_string_length(name), dom_string_data(name)); } else { NSLOG(dukky, DEBUG, "have registered listener for %p.%*s", - ele, dom_string_length(name), dom_string_data(name)); + ele, (int)dom_string_length(name), dom_string_data(name)); } dom_event_listener_unref(listen); } diff --git a/content/handlers/text/textplain.c b/content/handlers/text/textplain.c index 60051f5c9..cee89a1a5 100644 --- a/content/handlers/text/textplain.c +++ b/content/handlers/text/textplain.c @@ -264,7 +264,7 @@ textplain_drain_input(textplain_content *c, parserutils_inputstream *stream, parserutils_error terminator) { - static const uint8_t *u_fffd = (const uint8_t *) "\xef\xbf\xfd"; + static const uint8_t *u_fffd = (const uint8_t *) "\xef\xbf\xbd"; const uint8_t *ch; size_t chlen, offset = 0; |