diff options
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/Makefile | 2 | ||||
-rw-r--r-- | desktop/bitmap.c | 338 | ||||
-rw-r--r-- | desktop/bitmap.h | 147 | ||||
-rw-r--r-- | desktop/browser_history.c | 15 | ||||
-rw-r--r-- | desktop/browser_history.h | 11 | ||||
-rw-r--r-- | desktop/browser_window.c | 5 | ||||
-rw-r--r-- | desktop/cookie_manager.c | 30 | ||||
-rw-r--r-- | desktop/global_history.c | 22 | ||||
-rw-r--r-- | desktop/gui_factory.c | 30 | ||||
-rw-r--r-- | desktop/hotlist.c | 39 | ||||
-rw-r--r-- | desktop/local_history.c | 1 | ||||
-rw-r--r-- | desktop/local_history_private.h | 38 | ||||
-rw-r--r-- | desktop/netsurf.c | 8 | ||||
-rw-r--r-- | desktop/options.h | 6 | ||||
-rw-r--r-- | desktop/print.c | 38 | ||||
-rw-r--r-- | desktop/save_complete.c | 4 | ||||
-rw-r--r-- | desktop/searchweb.c | 6 | ||||
-rw-r--r-- | desktop/searchweb.h | 2 | ||||
-rw-r--r-- | desktop/selection.c | 2 | ||||
-rw-r--r-- | desktop/textarea.c | 101 | ||||
-rw-r--r-- | desktop/treeview.c | 97 | ||||
-rw-r--r-- | desktop/version.c | 4 |
22 files changed, 785 insertions, 161 deletions
diff --git a/desktop/Makefile b/desktop/Makefile index 63749a6f2..5e190275d 100644 --- a/desktop/Makefile +++ b/desktop/Makefile @@ -12,7 +12,7 @@ desktop/version.c: testament $(OBJROOT)/testament.h # S_BROWSER are sources related to full browsers but are common # between RISC OS, GTK, BeOS and AmigaOS builds -S_BROWSER := browser.c browser_window.c browser_history.c \ +S_BROWSER := bitmap.c browser.c browser_window.c browser_history.c \ download.c frames.c netsurf.c cw_helper.c \ save_complete.c save_text.c selection.c textinput.c gui_factory.c \ save_pdf.c font_haru.c diff --git a/desktop/bitmap.c b/desktop/bitmap.c new file mode 100644 index 000000000..0602773ca --- /dev/null +++ b/desktop/bitmap.c @@ -0,0 +1,338 @@ +/* + * Copyright 2022 Michael Drake <tlsa@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 + * Internal core bitmap interface. + */ + +#include <stddef.h> +#include <stdint.h> +#include <stdbool.h> + +#include "utils/log.h" +#include "utils/errors.h" + +#include "desktop/bitmap.h" +#include "desktop/gui_internal.h" + +/** The client bitmap format. */ +bitmap_fmt_t bitmap_fmt; + +/** The client bitmap colour channel layout. */ +struct bitmap_colour_layout bitmap_layout = { + .r = 0, + .g = 1, + .b = 2, + .a = 3, +}; + +/** + * Get the colour layout for the given bitmap format. + * + * \param[in] fmt Pixel format to get channel layout for, + * \return channel layout structure. + */ +static struct bitmap_colour_layout bitmap__get_colour_layout( + const bitmap_fmt_t *fmt) +{ + switch (fmt->layout) { + default: + /* Fall through. */ + case BITMAP_LAYOUT_R8G8B8A8: + return (struct bitmap_colour_layout) { + .r = 0, + .g = 1, + .b = 2, + .a = 3, + }; + + case BITMAP_LAYOUT_B8G8R8A8: + return (struct bitmap_colour_layout) { + .b = 0, + .g = 1, + .r = 2, + .a = 3, + }; + + case BITMAP_LAYOUT_A8R8G8B8: + return (struct bitmap_colour_layout) { + .a = 0, + .r = 1, + .g = 2, + .b = 3, + }; + + case BITMAP_LAYOUT_A8B8G8R8: + return (struct bitmap_colour_layout) { + .a = 0, + .b = 1, + .g = 2, + .r = 3, + }; + } +} + +/** + * Get string for given pixel layout. + * + * \param[in] layout The pixel layout to get string for, + * \return String for given layout. + */ +static const char *bitmap__layout_to_str(enum bitmap_layout layout) +{ + const char *const str[] = { + [BITMAP_LAYOUT_R8G8B8A8] = "Byte-wise RGBA", + [BITMAP_LAYOUT_B8G8R8A8] = "Byte-wise BGRA", + [BITMAP_LAYOUT_A8R8G8B8] = "Byte-wise ARGB", + [BITMAP_LAYOUT_A8B8G8R8] = "Byte-wise ABGR", + [BITMAP_LAYOUT_RGBA8888] = "0xRRGGBBAA (native endian)", + [BITMAP_LAYOUT_BGRA8888] = "0xBBGGRRAA (native endian)", + [BITMAP_LAYOUT_ARGB8888] = "0xAARRGGBB (native endian)", + [BITMAP_LAYOUT_ABGR8888] = "0xAABBGGRR (native endian)", + }; + + if ((size_t)layout >= (sizeof(str)) / sizeof(*str) || + str[layout] == NULL) { + return "Unknown"; + } + + return str[layout]; +} + +/* Exported function, documented in include/netsurf/bitmap.h */ +void bitmap_set_format(const bitmap_fmt_t *bitmap_format) +{ + bitmap_fmt = *bitmap_format; + + NSLOG(netsurf, INFO, "Setting core bitmap format to: %s%s", + bitmap__layout_to_str(bitmap_format->layout), + bitmap_format->pma ? " pre multiplied alpha" : ""); + + bitmap_fmt.layout = bitmap_sanitise_bitmap_layout(bitmap_fmt.layout); + + if (bitmap_format->layout != bitmap_fmt.layout) { + NSLOG(netsurf, INFO, "Sanitised layout to: %s", + bitmap__layout_to_str(bitmap_fmt.layout)); + } + + bitmap_layout = bitmap__get_colour_layout(&bitmap_fmt); +} + +/** + * Swap colour component order. + * + * \param[in] width Bitmap width in pixels. + * \param[in] height Bitmap height in pixels. + * \param[in] buffer Pixel buffer. + * \param[in] rowstride Pixel buffer row stride in bytes. + * \param[in] to Pixel layout to convert to. + * \param[in] from Pixel layout to convert from. + */ +static inline void bitmap__format_convert( + int width, + int height, + uint8_t *buffer, + size_t rowstride, + struct bitmap_colour_layout to, + struct bitmap_colour_layout from) +{ + /* Just swapping the components around */ + for (int y = 0; y < height; y++) { + uint8_t *row = buffer; + + for (int x = 0; x < width; x++) { + const uint32_t px = *((uint32_t *)(void *) row); + + row[to.r] = ((const uint8_t *) &px)[from.r]; + row[to.g] = ((const uint8_t *) &px)[from.g]; + row[to.b] = ((const uint8_t *) &px)[from.b]; + row[to.a] = ((const uint8_t *) &px)[from.a]; + + row += sizeof(uint32_t); + } + + buffer += rowstride; + } +} + +/** + * Convert plain alpha to premultiplied alpha. + * + * \param[in] width Bitmap width in pixels. + * \param[in] height Bitmap height in pixels. + * \param[in] buffer Pixel buffer. + * \param[in] rowstride Pixel buffer row stride in bytes. + * \param[in] to Pixel layout to convert to. + * \param[in] from Pixel layout to convert from. + */ +static inline void bitmap__format_convert_to_pma( + int width, + int height, + uint8_t *buffer, + size_t rowstride, + struct bitmap_colour_layout to, + struct bitmap_colour_layout from) +{ + for (int y = 0; y < height; y++) { + uint8_t *row = buffer; + + for (int x = 0; x < width; x++) { + const uint32_t px = *((uint32_t *)(void *) row); + uint32_t a, r, g, b; + + r = ((const uint8_t *) &px)[from.r]; + g = ((const uint8_t *) &px)[from.g]; + b = ((const uint8_t *) &px)[from.b]; + a = ((const uint8_t *) &px)[from.a]; + + if (a != 0) { + r = ((r * (a + 1)) >> 8) & 0xff; + g = ((g * (a + 1)) >> 8) & 0xff; + b = ((b * (a + 1)) >> 8) & 0xff; + } else { + r = g = b = 0; + } + + row[to.r] = r; + row[to.g] = g; + row[to.b] = b; + row[to.a] = a; + + row += sizeof(uint32_t); + } + + buffer += rowstride; + } +} + +/** + * Convert from premultiplied alpha to plain alpha. + * + * \param[in] width Bitmap width in pixels. + * \param[in] height Bitmap height in pixels. + * \param[in] buffer Pixel buffer. + * \param[in] rowstride Pixel buffer row stride in bytes. + * \param[in] to Pixel layout to convert to. + * \param[in] from Pixel layout to convert from. + */ +static inline void bitmap__format_convert_from_pma( + int width, + int height, + uint8_t *buffer, + size_t rowstride, + struct bitmap_colour_layout to, + struct bitmap_colour_layout from) +{ + for (int y = 0; y < height; y++) { + uint8_t *row = buffer; + + for (int x = 0; x < width; x++) { + const uint32_t px = *((uint32_t *)(void *) row); + uint32_t a, r, g, b; + + r = ((const uint8_t *) &px)[from.r]; + g = ((const uint8_t *) &px)[from.g]; + b = ((const uint8_t *) &px)[from.b]; + a = ((const uint8_t *) &px)[from.a]; + + if (a != 0) { + r = (r << 8) / a; + g = (g << 8) / a; + b = (b << 8) / a; + + r = (r > 255) ? 255 : r; + g = (g > 255) ? 255 : g; + b = (b > 255) ? 255 : b; + } else { + r = g = b = 0; + } + + row[to.r] = r; + row[to.g] = g; + row[to.b] = b; + row[to.a] = a; + + row += sizeof(uint32_t); + } + + buffer += rowstride; + } +} + +/* Exported function, documented in desktop/bitmap.h */ +void bitmap_format_convert(void *bitmap, + const bitmap_fmt_t *fmt_from, + const bitmap_fmt_t *fmt_to) +{ + int width = guit->bitmap->get_width(bitmap); + int height = guit->bitmap->get_height(bitmap); + bool opaque = guit->bitmap->get_opaque(bitmap); + uint8_t *buffer = guit->bitmap->get_buffer(bitmap); + size_t rowstride = guit->bitmap->get_rowstride(bitmap); + struct bitmap_colour_layout to = bitmap__get_colour_layout(fmt_to); + struct bitmap_colour_layout from = bitmap__get_colour_layout(fmt_from); + + NSLOG(netsurf, DEEPDEBUG, "%p: format conversion (%u%s --> %u%s)", + bitmap, + fmt_from->layout, fmt_from->pma ? " pma" : "", + fmt_to->layout, fmt_to->pma ? " pma" : ""); + + if (fmt_from->pma == fmt_to->pma) { + /* Just component order to switch. */ + bitmap__format_convert( + width, height, buffer, + rowstride, to, from); + + } else if (opaque == false) { + /* Need to do conversion to/from premultiplied alpha. */ + if (fmt_to->pma) { + bitmap__format_convert_to_pma( + width, height, buffer, + rowstride, to, from); + } else { + bitmap__format_convert_from_pma( + width, height, buffer, + rowstride, to, from); + } + } +} + +/* Exported function, documented in desktop/bitmap.h */ +bool bitmap_test_opaque(void *bitmap) +{ + int width = guit->bitmap->get_width(bitmap); + int height = guit->bitmap->get_height(bitmap); + size_t rowstride = guit->bitmap->get_rowstride(bitmap); + const uint8_t *buffer = guit->bitmap->get_buffer(bitmap); + + width *= sizeof(uint32_t); + + for (int y = 0; y < height; y++) { + const uint8_t *row = buffer; + + for (int x = bitmap_layout.a; x < width; x += 4) { + if (row[x] != 0xff) { + return false; + } + } + + buffer += rowstride; + } + + return true; +} diff --git a/desktop/bitmap.h b/desktop/bitmap.h new file mode 100644 index 000000000..51ce2c908 --- /dev/null +++ b/desktop/bitmap.h @@ -0,0 +1,147 @@ +/* + * Copyright 2022 Michael Drake <tlsa@nesturf-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 + * Internal core bitmap interface. + */ + +#ifndef _NETSURF_DESKTOP_BITMAP_H_ +#define _NETSURF_DESKTOP_BITMAP_H_ + +#include <nsutils/endian.h> + +#include "netsurf/types.h" +#include "netsurf/bitmap.h" + +/** Pixel format: colour component order. */ +struct bitmap_colour_layout { + uint8_t r; /**< Byte offset within pixel to red component. */ + uint8_t g; /**< Byte offset within pixel to green component. */ + uint8_t b; /**< Byte offset within pixel to blue component. */ + uint8_t a; /**< Byte offset within pixel to alpha component. */ +}; + +/** The client bitmap format. */ +extern bitmap_fmt_t bitmap_fmt; + +/** The client bitmap colour channel layout. */ +extern struct bitmap_colour_layout bitmap_layout; + +/** + * Convert a bitmap pixel to a NetSurf colour (0xAARRGGBB). + * + * The bitmap must be in the client format. + * + * \param[in] Pointer to a pixel in the bitmap's pixel data. + * \return The corresponding NetSurf colour. + */ +static inline colour bitmap_pixel_to_colour(const uint8_t *pixel) +{ + return (pixel[bitmap_layout.r] << 0) | + (pixel[bitmap_layout.g] << 8) | + (pixel[bitmap_layout.b] << 16) | + (pixel[bitmap_layout.a] << 24); +} + +/** + * Sanitise bitmap pixel component layout. + * + * Map endian-dependant layouts to byte-wise layout for the host. + * + * \param[in] layout Layout to convert. + * \return sanitised layout. + */ +static inline enum bitmap_layout bitmap_sanitise_bitmap_layout( + enum bitmap_layout layout) +{ + bool le = endian_host_is_le(); + + switch (layout) { + case BITMAP_LAYOUT_RGBA8888: + layout = (le) ? BITMAP_LAYOUT_A8B8G8R8 + : BITMAP_LAYOUT_R8G8B8A8; + break; + case BITMAP_LAYOUT_BGRA8888: + layout = (le) ? BITMAP_LAYOUT_A8R8G8B8 + : BITMAP_LAYOUT_B8G8R8A8; + break; + case BITMAP_LAYOUT_ARGB8888: + layout = (le) ? BITMAP_LAYOUT_B8G8R8A8 + : BITMAP_LAYOUT_A8R8G8B8; + break; + case BITMAP_LAYOUT_ABGR8888: + layout = (le) ? BITMAP_LAYOUT_R8G8B8A8 + : BITMAP_LAYOUT_A8B8G8R8; + break; + default: + break; + } + + return layout; +} + +/** + * Convert bitmap from one format to another. + * + * Note that both formats should be sanitised. + * + * \param[in] bitmap The bitmap to convert. + * \param[in] from The current bitmap format specifier. + * \param[in] to The bitmap format to convert to. + */ +void bitmap_format_convert(void *bitmap, + const bitmap_fmt_t *from, + const bitmap_fmt_t *to); + +/** + * Convert a bitmap to the client bitmap format. + * + * \param[in] bitmap The bitmap to convert. + * \param[in] current_fmt The current bitmap format specifier. + */ +static inline void bitmap_format_to_client( + void *bitmap, + const bitmap_fmt_t *current_fmt) +{ + bitmap_fmt_t from = *current_fmt; + + from.layout = bitmap_sanitise_bitmap_layout(from.layout); + if (from.layout != bitmap_fmt.layout || from.pma != bitmap_fmt.pma) { + bitmap_format_convert(bitmap, &from, &bitmap_fmt); + } +} + +/** + * Convert a bitmap to the client bitmap format. + * + * \param[in] bitmap The bitmap to convert. + * \param[in] target_fmt The target bitmap format specifier. + */ +static inline void bitmap_format_from_client( + void *bitmap, + const bitmap_fmt_t *target_fmt) +{ + bitmap_fmt_t to = *target_fmt; + + to.layout = bitmap_sanitise_bitmap_layout(to.layout); + if (to.layout != bitmap_fmt.layout || to.pma != bitmap_fmt.pma) { + bitmap_format_convert(bitmap, &bitmap_fmt, &to); + } +} + +#endif diff --git a/desktop/browser_history.c b/desktop/browser_history.c index 5b44670c1..ce9821af8 100644 --- a/desktop/browser_history.c +++ b/desktop/browser_history.c @@ -41,6 +41,7 @@ #include "desktop/gui_internal.h" #include "desktop/browser_private.h" +#include "desktop/local_history_private.h" #include "desktop/browser_history.h" /** @@ -105,7 +106,7 @@ browser_window_history__clone_entry(struct history *history, new_entry->page.bitmap = guit->bitmap->create( LOCAL_HISTORY_WIDTH, LOCAL_HISTORY_HEIGHT, - BITMAP_NEW | BITMAP_OPAQUE); + BITMAP_OPAQUE); if (new_entry->page.bitmap != NULL) { bmsrc_data = guit->bitmap->get_buffer(entry->page.bitmap); @@ -387,7 +388,7 @@ browser_window_history_add(struct browser_window *bw, entry->page.bitmap = guit->bitmap->create( LOCAL_HISTORY_WIDTH, LOCAL_HISTORY_HEIGHT, - BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE); + BITMAP_CLEAR | BITMAP_OPAQUE); if (entry->page.bitmap != NULL) { ret = guit->bitmap->render(entry->page.bitmap, content); if (ret != NSERROR_OK) { @@ -434,9 +435,7 @@ nserror browser_window_history_update(struct browser_window *bw, history = bw->history; - if (!history || - !history->current || - !history->current->page.bitmap) { + if ((history == NULL) || (history->current == NULL)) { return NSERROR_INVALID; } @@ -455,7 +454,7 @@ nserror browser_window_history_update(struct browser_window *bw, guit->bitmap->render(history->current->page.bitmap, content); } - if (bw->window != NULL && + if ((bw->window != NULL) && guit->window->get_scroll(bw->window, &sx, &sy)) { int content_height = content_get_height(content); int content_width = content_get_width(content); @@ -489,9 +488,7 @@ browser_window_history_get_scroll(struct browser_window *bw, history = bw->history; - if (!history || - !history->current || - !history->current->page.bitmap) { + if ((history== NULL) || (history->current == NULL)) { return NSERROR_INVALID; } diff --git a/desktop/browser_history.h b/desktop/browser_history.h index 06041ebf4..9b6f1fd42 100644 --- a/desktop/browser_history.h +++ b/desktop/browser_history.h @@ -35,17 +35,6 @@ #include "utils/errors.h" -#include "content/handlers/css/utils.h" - -#define LOCAL_HISTORY_WIDTH \ - (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(116)))) -#define LOCAL_HISTORY_HEIGHT \ - (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(100)))) -#define LOCAL_HISTORY_RIGHT_MARGIN \ - (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(50)))) -#define LOCAL_HISTORY_BOTTOM_MARGIN \ - (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(30)))) - struct browser_window; struct history_entry; struct bitmap; diff --git a/desktop/browser_window.c b/desktop/browser_window.c index 7b553f4e0..c70db7cf1 100644 --- a/desktop/browser_window.c +++ b/desktop/browser_window.c @@ -62,6 +62,11 @@ #include "desktop/hotlist.h" #include "desktop/knockout.h" #include "desktop/browser_history.h" +#include "desktop/theme.h" + +#ifdef WITH_THEME_INSTALL +#include "desktop/theme.h" +#endif /** * smallest scale that can be applied to a browser window diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c index 3e0417f23..b5ec89618 100644 --- a/desktop/cookie_manager.c +++ b/desktop/cookie_manager.c @@ -232,10 +232,6 @@ cookie_manager_field_builder(enum cookie_manager_field field, * * The time should be converted to text in the users locacle * - * \todo This should probably generate the user text using localtime - * and strftime with the c format specifier. Currently ctime will - * always generate output in the C locale. - * * \param field Cookie manager treeview field to build * \param fdata Cookie manager entry field data to set * \param value Time to show in field @@ -246,22 +242,20 @@ cookie_manager_field_builder_time(enum cookie_manager_field field, struct treeview_field_data *fdata, const time_t *value) { - const char *date; - char *date2; + struct tm *ftime; fdata->field = cm_ctx.fields[field].field; - - date = ctime(value); - date2 = strdup(date); - if (date2 == NULL) { - fdata->value = NULL; - fdata->value_len = 0; - } else { - assert(date2[24] == '\n'); - date2[24] = '\0'; - - fdata->value = date2; - fdata->value_len = strlen(date2); + fdata->value = NULL; + fdata->value_len = 0; + + if ((ftime = localtime(value)) != NULL) { + const size_t vsize = 256; + char *value = malloc(vsize); + if (value != NULL) { + fdata->value = value; + fdata->value_len = strftime(value, vsize, + "%a %b %e %H:%M:%S %Y", ftime); + } } return NSERROR_OK; diff --git a/desktop/global_history.c b/desktop/global_history.c index ad39a3e41..e98e4cb29 100644 --- a/desktop/global_history.c +++ b/desktop/global_history.c @@ -266,9 +266,9 @@ static nserror global_history_create_treeview_field_data( const char *title = (data->title != NULL) ? data->title : messages_get("NoTitle"); char buffer[16]; - const char *last_visited; - char *last_visited2; - int len; + struct tm *lvtime; + char *last_visited = NULL; + size_t len = 0; e->data[GH_TITLE].field = gh_ctx.fields[GH_TITLE].field; e->data[GH_TITLE].value = strdup(title); @@ -279,16 +279,18 @@ static nserror global_history_create_treeview_field_data( e->data[GH_URL].value = nsurl_access(e->url); e->data[GH_URL].value_len = nsurl_length(e->url); - last_visited = ctime(&data->last_visit); - last_visited2 = strdup(last_visited); - if (last_visited2 != NULL) { - assert(last_visited2[24] == '\n'); - last_visited2[24] = '\0'; + if ((lvtime = localtime(&data->last_visit)) != NULL) { + const size_t lvsize = 256; + last_visited = malloc(lvsize); + if (last_visited != NULL) { + len = strftime(last_visited, lvsize, + "%a %b %e %H:%M:%S %Y", lvtime); + } } e->data[GH_LAST_VISIT].field = gh_ctx.fields[GH_LAST_VISIT].field; - e->data[GH_LAST_VISIT].value = last_visited2; - e->data[GH_LAST_VISIT].value_len = (last_visited2 != NULL) ? 24 : 0; + e->data[GH_LAST_VISIT].value = last_visited; + e->data[GH_LAST_VISIT].value_len = len; len = snprintf(buffer, 16, "%u", data->visits); if (len == 16) { diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index a141d7d23..0d4d9a904 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -20,10 +20,12 @@ #include <stdint.h> #include <stdbool.h> #include <string.h> +#include <unistd.h> #include "utils/config.h" #include "utils/errors.h" #include "utils/file.h" +#include "utils/inet.h" #include "netsurf/bitmap.h" #include "content/hlcache.h" #include "content/backing_store.h" @@ -472,6 +474,16 @@ static char *gui_default_mimetype(const char *path) return strdup(guit->fetch->filetype(path)); } +static int gui_default_socket_open(int domain, int type, int protocol) +{ + return (int) socket(domain, type, protocol); +} + +static int gui_default_socket_close(int fd) +{ + return (int) ns_close_socket(fd); +} + /** verify fetch table is valid */ static nserror verify_fetch_register(struct gui_fetch_table *gft) { @@ -498,6 +510,12 @@ static nserror verify_fetch_register(struct gui_fetch_table *gft) if (gft->mimetype == NULL) { gft->mimetype = gui_default_mimetype; } + if (gft->socket_open == NULL) { + gft->socket_open = gui_default_socket_open; + } + if (gft->socket_close == NULL) { + gft->socket_close = gui_default_socket_close; + } return NSERROR_OK; } @@ -560,10 +578,6 @@ static nserror verify_bitmap_register(struct gui_bitmap_table *gbt) return NSERROR_BAD_PARAMETER; } - if (gbt->test_opaque == NULL) { - return NSERROR_BAD_PARAMETER; - } - if (gbt->get_buffer == NULL) { return NSERROR_BAD_PARAMETER; } @@ -580,14 +594,6 @@ static nserror verify_bitmap_register(struct gui_bitmap_table *gbt) return NSERROR_BAD_PARAMETER; } - if (gbt->get_bpp == NULL) { - return NSERROR_BAD_PARAMETER; - } - - if (gbt->save == NULL) { - return NSERROR_BAD_PARAMETER; - } - if (gbt->modified == NULL) { return NSERROR_BAD_PARAMETER; } diff --git a/desktop/hotlist.c b/desktop/hotlist.c index e9cbb5ffb..20c0890a1 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -193,29 +193,32 @@ static nserror hotlist_create_treeview_field_visits_data( struct hotlist_entry *e, const struct url_data *data) { char buffer[16]; - const char *last_visited; - char *last_visited2; - int len; + char *last_visited = NULL; + size_t len = 0; /* Last visited */ if (data->visits != 0) { - last_visited = ctime(&data->last_visit); - last_visited2 = strdup(last_visited); - len = 24; + const size_t lvsize = 256; + struct tm *lvtime; + + if ((lvtime = localtime(&data->last_visit)) != NULL) { + last_visited = malloc(lvsize); + if (last_visited != NULL) { + len = strftime(last_visited, lvsize, + "%a %b %e %H:%M:%S %Y", + lvtime); + } + } } else { - last_visited2 = strdup("-"); + last_visited = strdup("-"); len = 1; } - if (last_visited2 == NULL) { + if (last_visited == NULL) { return NSERROR_NOMEM; - - } else if (len == 24) { - assert(last_visited2[24] == '\n'); - last_visited2[24] = '\0'; } e->data[HL_LAST_VISIT].field = hl_ctx.fields[HL_LAST_VISIT].field; - e->data[HL_LAST_VISIT].value = last_visited2; + e->data[HL_LAST_VISIT].value = last_visited; e->data[HL_LAST_VISIT].value_len = len; /* Visits */ @@ -968,13 +971,13 @@ static nserror hotlist_generate(void) const char *url; const char *msg_key; } default_entries[] = { - { "http://www.netsurf-browser.org/", + { "https://www.netsurf-browser.org/", "HotlistHomepage" }, - { "http://www.netsurf-browser.org/downloads/", + { "https://www.netsurf-browser.org/downloads/", "HotlistDownloads" }, - { "http://www.netsurf-browser.org/documentation", + { "https://www.netsurf-browser.org/documentation", "HotlistDocumentation" }, - { "http://www.netsurf-browser.org/contact", + { "https://www.netsurf-browser.org/contact", "HotlistContact" } }; const int n_entries = sizeof(default_entries) / @@ -1626,7 +1629,7 @@ nserror hotlist_add_entry(nsurl *url, const char *title, bool at_y, int y) enum treeview_relationship rel; if (url == NULL) { - err = nsurl_create("http://netsurf-browser.org/", &url); + err = nsurl_create("https://netsurf-browser.org/", &url); if (err != NSERROR_OK) { return err; } diff --git a/desktop/local_history.c b/desktop/local_history.c index 412e893f5..5227c97e1 100644 --- a/desktop/local_history.c +++ b/desktop/local_history.c @@ -41,6 +41,7 @@ #include "desktop/system_colour.h" #include "desktop/browser_private.h" #include "desktop/browser_history.h" +#include "desktop/local_history_private.h" #include "desktop/local_history.h" /** diff --git a/desktop/local_history_private.h b/desktop/local_history_private.h new file mode 100644 index 000000000..fd25ab4d3 --- /dev/null +++ b/desktop/local_history_private.h @@ -0,0 +1,38 @@ +/* + * Copyright 2006 James Bursa <bursa@users.sourceforge.net> + * + * 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 + * Interface to browser history private operations + */ + +#ifndef NETSURF_DESKTOP_BROWSER_HISTORY_PRIVATE_H +#define NETSURF_DESKTOP_BROWSER_HISTORY_PRIVATE_H + +#include "content/handlers/css/utils.h" + +#define LOCAL_HISTORY_WIDTH \ + (FIXTOINT(css_unit_css2device_px(INTTOFIX(116), nscss_screen_dpi))) +#define LOCAL_HISTORY_HEIGHT \ + (FIXTOINT(css_unit_css2device_px(INTTOFIX(100), nscss_screen_dpi))) +#define LOCAL_HISTORY_RIGHT_MARGIN \ + (FIXTOINT(css_unit_css2device_px(INTTOFIX( 50), nscss_screen_dpi))) +#define LOCAL_HISTORY_BOTTOM_MARGIN \ + (FIXTOINT(css_unit_css2device_px(INTTOFIX( 30), nscss_screen_dpi))) + +#endif diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 6cc3a118f..bd785898f 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -99,7 +99,7 @@ static void netsurf_lwc_iterator(lwc_string *str, void *pw) { - NSLOG(netsurf, WARNING, "[%3u] %.*s", str->refcnt, + NSLOG(netsurf, WARNING, "[%3"PRIu32"] %.*s", str->refcnt, (int)lwc_string_length(str), lwc_string_data(str)); } @@ -155,10 +155,10 @@ nserror netsurf_init(const char *store_path) hlcache_parameters.llcache.fetch_attempts = nsoption_uint(max_retried_fetches); /* image cache is 25% of total memory cache size */ - image_cache_parameters.limit = (hlcache_parameters.llcache.limit * 25) / 100; + image_cache_parameters.limit = hlcache_parameters.llcache.limit / 4; /* image cache hysteresis is 20% of the image cache size */ - image_cache_parameters.hysteresis = (image_cache_parameters.limit * 20) / 100; + image_cache_parameters.hysteresis = image_cache_parameters.limit / 5; /* account for image cache use from total */ hlcache_parameters.llcache.limit -= image_cache_parameters.limit; @@ -167,7 +167,7 @@ nserror netsurf_init(const char *store_path) hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size); /* set backing store hysterissi to 20% */ - hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;; + hlcache_parameters.llcache.store.hysteresis = hlcache_parameters.llcache.store.limit / 5; /* set the path to the backing store */ hlcache_parameters.llcache.store.path = diff --git a/desktop/options.h b/desktop/options.h index 539ff21c8..b74fab829 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -123,6 +123,9 @@ NSOPTION_BOOL(animate_images, true) /** Whether to execute javascript */ NSOPTION_BOOL(enable_javascript, false) +/** Whether to allow Author level CSS. */ +NSOPTION_BOOL(author_level_css, true) + /** Maximum time (in seconds) to wait for a script to run */ NSOPTION_INTEGER(script_timeout, 10) @@ -255,6 +258,9 @@ NSOPTION_BOOL(enable_PDF_compression, true) /** setting a password and encoding PDF documents */ NSOPTION_BOOL(enable_PDF_password, false) +/** whether to prefer dark mode (light on dark) */ +NSOPTION_BOOL(prefer_dark_mode, false) + /******** System colours ********/ NSOPTION_COLOUR(sys_colour_ActiveBorder, 0x00d3d3d3) NSOPTION_COLOUR(sys_colour_ActiveCaption, 0x00f1f1f1) diff --git a/desktop/print.c b/desktop/print.c index de579dcf2..e90e322ac 100644 --- a/desktop/print.c +++ b/desktop/print.c @@ -257,9 +257,9 @@ struct print_settings *print_make_settings(print_configuration configuration, struct print_settings *settings; css_fixed length = 0; css_unit unit = CSS_UNIT_MM; - nscss_len_ctx len_ctx = { - .vw = DEFAULT_PAGE_WIDTH, - .vh = DEFAULT_PAGE_HEIGHT, + css_unit_ctx unit_len_ctx = { + .viewport_width = DEFAULT_PAGE_WIDTH, + .viewport_height = DEFAULT_PAGE_HEIGHT, .root_style = NULL, }; @@ -277,17 +277,17 @@ struct print_settings *print_make_settings(print_configuration configuration, settings->scale = DEFAULT_EXPORT_SCALE; length = INTTOFIX(DEFAULT_MARGIN_LEFT_MM); - settings->margins[MARGINLEFT] = nscss_len2px( - &len_ctx, length, unit, NULL); + settings->margins[MARGINLEFT] = css_unit_len2device_px( + NULL, &unit_len_ctx, length, unit); length = INTTOFIX(DEFAULT_MARGIN_RIGHT_MM); - settings->margins[MARGINRIGHT] = nscss_len2px( - &len_ctx, length, unit, NULL); + settings->margins[MARGINRIGHT] = css_unit_len2device_px( + NULL, &unit_len_ctx, length, unit); length = INTTOFIX(DEFAULT_MARGIN_TOP_MM); - settings->margins[MARGINTOP] = nscss_len2px( - &len_ctx, length, unit, NULL); + settings->margins[MARGINTOP] = css_unit_len2device_px( + NULL, &unit_len_ctx, length, unit); length = INTTOFIX(DEFAULT_MARGIN_BOTTOM_MM); - settings->margins[MARGINBOTTOM] = nscss_len2px( - &len_ctx, length, unit, NULL); + settings->margins[MARGINBOTTOM] = css_unit_len2device_px( + NULL, &unit_len_ctx, length, unit); break; /* use settings from the Export options tab */ case PRINT_OPTIONS: @@ -303,17 +303,17 @@ struct print_settings *print_make_settings(print_configuration configuration, settings->scale = (float)nsoption_int(export_scale) / 100; length = INTTOFIX(nsoption_int(margin_left)); - settings->margins[MARGINLEFT] = nscss_len2px( - &len_ctx, length, unit, NULL); + settings->margins[MARGINLEFT] = css_unit_len2device_px( + NULL, &unit_len_ctx, length, unit); length = INTTOFIX(nsoption_int(margin_right)); - settings->margins[MARGINRIGHT] = nscss_len2px( - &len_ctx, length, unit, NULL); + settings->margins[MARGINRIGHT] = css_unit_len2device_px( + NULL, &unit_len_ctx, length, unit); length = INTTOFIX(nsoption_int(margin_top)); - settings->margins[MARGINTOP] = nscss_len2px( - &len_ctx, length, unit, NULL); + settings->margins[MARGINTOP] = css_unit_len2device_px( + NULL, &unit_len_ctx, length, unit); length = INTTOFIX(nsoption_int(margin_bottom)); - settings->margins[MARGINBOTTOM] = nscss_len2px( - &len_ctx, length, unit, NULL); + settings->margins[MARGINBOTTOM] = css_unit_len2device_px( + NULL, &unit_len_ctx, length, unit); break; default: return NULL; diff --git a/desktop/save_complete.c b/desktop/save_complete.c index 24c188145..e4fadd274 100644 --- a/desktop/save_complete.c +++ b/desktop/save_complete.c @@ -51,7 +51,7 @@ #include "desktop/gui_internal.h" #include "desktop/save_complete.h" -regex_t save_complete_import_re; +static regex_t save_complete_import_re; /** An entry in save_complete_list. */ typedef struct save_complete_entry { @@ -196,7 +196,7 @@ save_complete_save_buffer(save_complete_ctx *ctx, * perform a posix regexec on a string without a null terminator */ static int -snregexec(const regex_t *preg, +snregexec(regex_t *preg, const char *string, size_t stringlen, size_t nmatch, diff --git a/desktop/searchweb.c b/desktop/searchweb.c index 597b8fffe..361860190 100644 --- a/desktop/searchweb.c +++ b/desktop/searchweb.c @@ -53,7 +53,7 @@ static struct search_web_ctx_s { } search_web_ctx; -static const char *default_providers = "Google|www.google.com|http://www.google.com/search?q=%s|http://www.google.com/favicon.ico|\n"; +static const char *default_providers = "Google|www.google.com|https://www.google.com/search?q=%s|https://www.google.com/favicon.ico|\n"; static const char *default_search_icon_url = "resource:icons/search.png"; @@ -333,11 +333,11 @@ search_web_omni(const char *term, } /* try with adding default scheme */ - eterm = malloc(strlen(term) + SLEN("http://") + 1); + eterm = malloc(strlen(term) + SLEN("https://") + 1); if (eterm == NULL) { return NSERROR_NOMEM; } - sprintf(eterm, "http://%s", term); + sprintf(eterm, "https://%s", term); ret = nsurl_create(eterm, &url); free(eterm); if (ret == NSERROR_OK) { diff --git a/desktop/searchweb.h b/desktop/searchweb.h index 69748b6d6..0712de9fe 100644 --- a/desktop/searchweb.h +++ b/desktop/searchweb.h @@ -62,7 +62,7 @@ enum search_web_omni_flags { * term. The flags allow control over the operation. By default the * operations are: * - interpret the \a term as a url - * - if missing a scheme as a http: url + * - if missing a scheme as a https: url * - combined with the search providers url into a url for that provider. * * \param term The search term. diff --git a/desktop/selection.c b/desktop/selection.c index 332e9dafa..8b1f127c4 100644 --- a/desktop/selection.c +++ b/desktop/selection.c @@ -54,7 +54,6 @@ typedef enum { struct selection { struct content *c; - struct box *root; unsigned max_idx; /* total bytes in text representation */ @@ -257,7 +256,6 @@ struct selection *selection_create(struct content *c) sel = calloc(1, sizeof(struct selection)); if (sel) { sel->c = c; - sel->root = NULL; sel->drag_state = DRAG_NONE; sel->max_idx = 0; selection_clear(sel, false); diff --git a/desktop/textarea.c b/desktop/textarea.c index 5bae27a5c..e0e87444c 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -58,7 +58,7 @@ struct line_info { struct textarea_drag { textarea_drag_type type; union { - struct scrollbar* scrollbar; + struct scrollbar *scrollbar; } data; }; @@ -625,7 +625,7 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end, * \param ta Text area * \return True on success, false otherwise */ -static bool textarea_select_fragment(struct textarea * ta) +static bool textarea_select_fragment(struct textarea *ta) { int caret_pos; size_t sel_start, sel_end; @@ -676,7 +676,7 @@ static bool textarea_select_fragment(struct textarea * ta) * \param ta textarea widget * \return True on success, false otherwise */ -static bool textarea_select_paragraph(struct textarea * ta) +static bool textarea_select_paragraph(struct textarea *ta) { int caret_pos; size_t sel_start, sel_end; @@ -1607,7 +1607,7 @@ static bool textarea_copy_to_undo_buffer(struct textarea *ta, * \param b_end End byte index of replaced section (exclusive) * \param rep Replacement UTF-8 text to insert * \param rep_len Byte length of replacement UTF-8 text - * \param add_to_clipboard True iff replaced text to be added to clipboard + * \param add_to_clipboard True if replaced text to be added to clipboard * \param byte_delta Updated to change in byte count in textarea (ta->show) * \param r Updated to area where redraw is required * \return false on memory exhaustion, true otherwise @@ -2452,7 +2452,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) struct textarea_msg msg; struct rect r; /**< Redraw rectangle */ char utf8[6]; - unsigned int caret, length, b_off, b_len; + unsigned int caret, caret_copy, length, b_off, b_len; int h_extent = ta->h_extent; int v_extent = ta->v_extent; int line; @@ -2466,7 +2466,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) /* Word separators */ static const char *sep = " .\n"; - caret = textarea_get_caret(ta); + caret = caret_copy = textarea_get_caret(ta); line = ta->caret_pos.line; readonly = (ta->flags & TEXTAREA_READONLY ? true : false); @@ -2743,6 +2743,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) case NS_KEY_WORD_LEFT: if (readonly) break; + if (ta->sel_start != -1) { + textarea_clear_selection(ta); + } if (caret == 0) break; caret--; @@ -2756,13 +2759,59 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) break; } } + break; + case NS_KEY_DELETE_WORD_LEFT: + if (readonly) + break; + + /* If there is a selection, remove the selected + * characters */ if (ta->sel_start != -1) { + if (!textarea_replace_text(ta, ta->sel_start, + ta->sel_end, "", 0, false, + &byte_delta, &r)) + return false; + caret = ta->sel_start; textarea_clear_selection(ta); + redraw = true; + break; + } + + if (caret == 0) + break; + + /* caret goes left until a non-separator is + * encountered */ + caret--; + while (strchr(sep, ta->show->data[caret]) != NULL && + caret > 0) + caret--; + + /* caret goes left until a separator is encountered */ + for (; caret > 0; caret--) { + if (strchr(sep, ta->show->data[caret]) != + NULL) { + caret++; + break; + } } + + /* Remove the characters from new caret position to + * original caret position */ + if (!textarea_replace_text(ta, caret, caret_copy, + "", 0, false, &byte_delta, &r)) + return false; + + redraw = true; break; case NS_KEY_WORD_RIGHT: if (readonly) break; + if (ta->sel_start != -1) { + textarea_clear_selection(ta); + } + if (caret == ta->show->len - 1) + break; if (strchr(sep, ta->show->data[caret]) != NULL && caret < ta->show->len - 1) { while (strchr(sep, ta->show->data[caret]) != @@ -2779,9 +2828,49 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) while (strchr(sep, ta->show->data[caret]) != NULL && caret < ta->show->len - 1) caret++; + break; + case NS_KEY_DELETE_WORD_RIGHT: + if (readonly) + break; + + /* If there is a selection, remove the selected + * characters */ if (ta->sel_start != -1) { + if (!textarea_replace_text(ta, ta->sel_start, + ta->sel_end, "", 0, false, + &byte_delta, &r)) + return false; + caret = ta->sel_start; textarea_clear_selection(ta); + redraw = true; + break; } + + if (caret == ta->show->len - 1) + break; + + /* caret_copy goes right until a non-separator is + * encountered */ + while (strchr(sep, ta->show->data[caret_copy]) != NULL + && caret_copy < ta->show->len - 1) + caret_copy++; + + /* caret_copy goes right until a separator is + * encountered */ + for (; caret_copy < ta->show->len - 1; caret_copy++) { + if (strchr(sep, ta->show->data[caret_copy]) != + NULL) { + break; + } + } + + /* Remove all the characters from original caret + * position to caret_copy */ + if (!textarea_replace_text(ta, caret, caret_copy, + "", 0, false, &byte_delta, &r)) + return false; + + redraw = true; break; case NS_KEY_DELETE_LINE: if (readonly) diff --git a/desktop/treeview.c b/desktop/treeview.c index feb1a7c6e..a65a37e72 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -41,6 +41,7 @@ #include "content/hlcache.h" #include "css/utils.h" +#include "desktop/bitmap.h" #include "desktop/knockout.h" #include "desktop/textarea.h" #include "desktop/treeview.h" @@ -5077,7 +5078,7 @@ treeview_generate_triangle_bitmap(colour bg, colour fg, int size) colour colour4 = fg; /* Create the bitmap */ - b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE); + b = guit->bitmap->create(size, size, BITMAP_OPAQUE); if (b == NULL) return NULL; @@ -5091,58 +5092,68 @@ treeview_generate_triangle_bitmap(colour bg, colour fg, int size) if (y < size / 2) { /* Top half */ for (x = 0; x < y * 2; x++) { - *(pos++) = red_from_colour(colour4); - *(pos++) = green_from_colour(colour4); - *(pos++) = blue_from_colour(colour4); - *(pos++) = 0xff; + pos[bitmap_layout.r] = red_from_colour(colour4); + pos[bitmap_layout.g] = green_from_colour(colour4); + pos[bitmap_layout.b] = blue_from_colour(colour4); + pos[bitmap_layout.a] = 0xff; + pos += 4; } - *(pos++) = red_from_colour(colour3); - *(pos++) = green_from_colour(colour3); - *(pos++) = blue_from_colour(colour3); - *(pos++) = 0xff; - *(pos++) = red_from_colour(colour1); - *(pos++) = green_from_colour(colour1); - *(pos++) = blue_from_colour(colour1); - *(pos++) = 0xff; + pos[bitmap_layout.r] = red_from_colour(colour3); + pos[bitmap_layout.g] = green_from_colour(colour3); + pos[bitmap_layout.b] = blue_from_colour(colour3); + pos[bitmap_layout.a] = 0xff; + pos += 4; + pos[bitmap_layout.r] = red_from_colour(colour1); + pos[bitmap_layout.g] = green_from_colour(colour1); + pos[bitmap_layout.b] = blue_from_colour(colour1); + pos[bitmap_layout.a] = 0xff; + pos += 4; for (x = y * 2 + 2; x < size ; x++) { - *(pos++) = red_from_colour(colour0); - *(pos++) = green_from_colour(colour0); - *(pos++) = blue_from_colour(colour0); - *(pos++) = 0xff; + pos[bitmap_layout.r] = red_from_colour(colour0); + pos[bitmap_layout.g] = green_from_colour(colour0); + pos[bitmap_layout.b] = blue_from_colour(colour0); + pos[bitmap_layout.a] = 0xff; + pos += 4; } } else if ((y == size / 2) && (size & 0x1)) { /* Middle row */ for (x = 0; x < size - 1; x++) { - *(pos++) = red_from_colour(colour4); - *(pos++) = green_from_colour(colour4); - *(pos++) = blue_from_colour(colour4); - *(pos++) = 0xff; + pos[bitmap_layout.r] = red_from_colour(colour4); + pos[bitmap_layout.g] = green_from_colour(colour4); + pos[bitmap_layout.b] = blue_from_colour(colour4); + pos[bitmap_layout.a] = 0xff; + pos += 4; } - *(pos++) = red_from_colour(colour2); - *(pos++) = green_from_colour(colour2); - *(pos++) = blue_from_colour(colour2); - *(pos++) = 0xff; + pos[bitmap_layout.r] = red_from_colour(colour2); + pos[bitmap_layout.g] = green_from_colour(colour2); + pos[bitmap_layout.b] = blue_from_colour(colour2); + pos[bitmap_layout.a] = 0xff; + pos += 4; } else { /* Bottom half */ for (x = 0; x < (size - y - 1) * 2; x++) { - *(pos++) = red_from_colour(colour4); - *(pos++) = green_from_colour(colour4); - *(pos++) = blue_from_colour(colour4); - *(pos++) = 0xff; + pos[bitmap_layout.r] = red_from_colour(colour4); + pos[bitmap_layout.g] = green_from_colour(colour4); + pos[bitmap_layout.b] = blue_from_colour(colour4); + pos[bitmap_layout.a] = 0xff; + pos += 4; } - *(pos++) = red_from_colour(colour3); - *(pos++) = green_from_colour(colour3); - *(pos++) = blue_from_colour(colour3); - *(pos++) = 0xff; - *(pos++) = red_from_colour(colour1); - *(pos++) = green_from_colour(colour1); - *(pos++) = blue_from_colour(colour1); - *(pos++) = 0xff; + pos[bitmap_layout.r] = red_from_colour(colour3); + pos[bitmap_layout.g] = green_from_colour(colour3); + pos[bitmap_layout.b] = blue_from_colour(colour3); + pos[bitmap_layout.a] = 0xff; + pos += 4; + pos[bitmap_layout.r] = red_from_colour(colour1); + pos[bitmap_layout.g] = green_from_colour(colour1); + pos[bitmap_layout.b] = blue_from_colour(colour1); + pos[bitmap_layout.a] = 0xff; + pos += 4; for (x = (size - y) * 2; x < size ; x++) { - *(pos++) = red_from_colour(colour0); - *(pos++) = green_from_colour(colour0); - *(pos++) = blue_from_colour(colour0); - *(pos++) = 0xff; + pos[bitmap_layout.r] = red_from_colour(colour0); + pos[bitmap_layout.g] = green_from_colour(colour0); + pos[bitmap_layout.b] = blue_from_colour(colour0); + pos[bitmap_layout.a] = 0xff; + pos += 4; } } @@ -5176,7 +5187,7 @@ treeview_generate_copy_bitmap(struct bitmap *orig, int size) assert(size == guit->bitmap->get_height(orig)); /* Create the bitmap */ - b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE); + b = guit->bitmap->create(size, size, BITMAP_OPAQUE); if (b == NULL) return NULL; @@ -5224,7 +5235,7 @@ treeview_generate_rotate_bitmap(struct bitmap *orig, int size) assert(size == guit->bitmap->get_height(orig)); /* Create the bitmap */ - b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE); + b = guit->bitmap->create(size, size, BITMAP_OPAQUE); if (b == NULL) return NULL; diff --git a/desktop/version.c b/desktop/version.c index f0ed06d5f..91a7532f4 100644 --- a/desktop/version.c +++ b/desktop/version.c @@ -20,11 +20,11 @@ #include "desktop/version.h" -const char * const netsurf_version = "3.11 (Dev" +const char * const netsurf_version = "3.12 (Dev" #if defined(CI_BUILD) " CI #" CI_BUILD #endif ")" ; const int netsurf_version_major = 3; -const int netsurf_version_minor = 11; +const int netsurf_version_minor = 12; |