diff options
Diffstat (limited to 'include/netsurf')
-rw-r--r-- | include/netsurf/bitmap.h | 154 | ||||
-rw-r--r-- | include/netsurf/browser.h | 42 | ||||
-rw-r--r-- | include/netsurf/browser_window.h | 199 | ||||
-rw-r--r-- | include/netsurf/console.h | 68 | ||||
-rw-r--r-- | include/netsurf/content.h | 2 | ||||
-rw-r--r-- | include/netsurf/content_type.h | 119 | ||||
-rw-r--r-- | include/netsurf/core_window.h | 39 | ||||
-rw-r--r-- | include/netsurf/fetch.h | 25 | ||||
-rw-r--r-- | include/netsurf/inttypes.h | 9 | ||||
-rw-r--r-- | include/netsurf/keypress.h | 2 | ||||
-rw-r--r-- | include/netsurf/misc.h | 75 | ||||
-rw-r--r-- | include/netsurf/plot_style.h | 85 | ||||
-rw-r--r-- | include/netsurf/ssl_certs.h | 145 | ||||
-rw-r--r-- | include/netsurf/window.h | 145 |
14 files changed, 867 insertions, 242 deletions
diff --git a/include/netsurf/bitmap.h b/include/netsurf/bitmap.h index a85efce99..10e9a07fb 100644 --- a/include/netsurf/bitmap.h +++ b/include/netsurf/bitmap.h @@ -20,64 +20,120 @@ * \file * Generic bitmap handling interface. * - * This interface wraps the native platform-specific image format, so that - * portable image convertors can be written. + * This interface wraps the native platform-specific image format. * - * Bitmaps are required to be 32bpp with components in the order RR GG BB AA. + * Bitmaps are required to be 32bpp with 8-bit components. The components are + * red, green, blue, and alpha, in client specified order. * - * For example, an opaque 1x1 pixel image would yield the following bitmap - * data: - * - * > Red : 0xff 0x00 0x00 0x00 - * > Green: 0x00 0xff 0x00 0x00 - * > Blue : 0x00 0x00 0xff 0x00 - * - * Any attempt to read pixels by casting bitmap data to uint32_t or similar - * will need to cater for the order of bytes in a word being different on - * big and little endian systems. To avoid confusion, it is recommended - * that pixel data is loaded as follows: - * - * uint32_t read_pixel(const uint8_t *bmp) - * { - * // red green blue alpha - * return bmp[0] | (bmp[1] << 8) | (bmp[2] << 16) | (bmp[3] << 24); - * } - * - * and *not* as follows: - * - * uint32_t read_pixel(const uint8_t *bmp) - * { - * return *((uint32_t *) bmp); - * } + * The component order may be set in the front ends by calling + * \ref bitmap_set_format(). */ #ifndef _NETSURF_BITMAP_H_ #define _NETSURF_BITMAP_H_ -#define BITMAP_NEW 0 -#define BITMAP_OPAQUE (1 << 0) /**< image is opaque */ -#define BITMAP_MODIFIED (1 << 1) /**< buffer has been modified */ -#define BITMAP_CLEAR_MEMORY (1 << 2) /**< memory should be wiped */ +/** Bitmap creation flags. */ +enum gui_bitmap_flags { + BITMAP_NONE = 0, + BITMAP_OPAQUE = (1 << 0), /**< image is opaque */ + BITMAP_CLEAR = (1 << 1), /**< memory should be wiped to 0 */ +}; + +/** + * NetSurf bitmap pixel layout. + * + * All pixels are 32 bits per pixel (bpp). The different layouts allow control + * over the ordering of colour channels. All colour channels are 8 bits wide. + */ +enum bitmap_layout { + /** Bite-wise RGBA: Byte order: 0xRR, 0xGG, 0xBB, 0xAA. */ + BITMAP_LAYOUT_R8G8B8A8, + + /** Bite-wise BGRA: Byte order: 0xBB, 0xGG, 0xRR, 0xAA. */ + BITMAP_LAYOUT_B8G8R8A8, + + /** Bite-wise ARGB: Byte order: 0xAA, 0xRR, 0xGG, 0xBB. */ + BITMAP_LAYOUT_A8R8G8B8, + + /** Bite-wise ABGR: Byte order: 0xAA, 0xBB, 0xGG, 0xRR. */ + BITMAP_LAYOUT_A8B8G8R8, + + /** + * 32-bit RGBA (0xRRGGBBAA). + * + * * On little endian host, same as \ref BITMAP_LAYOUT_A8B8G8R8. + * * On big endian host, same as \ref BITMAP_LAYOUT_R8G8B8A8. + */ + BITMAP_LAYOUT_RGBA8888, + + /** + * 32-bit BGRA (0xBBGGRRAA). + * + * * On little endian host, same as \ref BITMAP_LAYOUT_A8R8G8B8. + * * On big endian host, same as \ref BITMAP_LAYOUT_B8G8R8A8. + */ + BITMAP_LAYOUT_BGRA8888, + + /** + * 32-bit ARGB (0xAARRGGBB). + * + * * On little endian host, same as \ref BITMAP_LAYOUT_B8G8R8A8. + * * On big endian host, same as \ref BITMAP_LAYOUT_A8R8G8B8. + */ + BITMAP_LAYOUT_ARGB8888, + + /** + * 32-bit BGRA (0xAABBGGRR). + * + * * On little endian host, same as \ref BITMAP_LAYOUT_R8G8B8A8. + * * On big endian host, same as \ref BITMAP_LAYOUT_A8B8G8R8. + */ + BITMAP_LAYOUT_ABGR8888, +}; + +/** Bitmap format specifier. */ +typedef struct bitmap_fmt { + enum bitmap_layout layout; /**< Colour component layout. */ + bool pma; /**< Premultiplied alpha. */ +} bitmap_fmt_t; struct content; struct bitmap; struct hlcache_handle; /** + * Set client bitmap format. + * + * Set this to ensure that the bitmaps decoded by the core are in the + * correct format for the front end. + * + * \param[in] bitmap_format The bitmap format specification to set. + */ +void bitmap_set_format(const bitmap_fmt_t *bitmap_format); + +/** + * Test whether a bitmap is completely opaque (no transparency). + * + * \param[in] bitmap The bitmap to test. + * \return Returns true if the bitmap is opaque, false otherwise. + */ +bool bitmap_test_opaque(void *bitmap); + +/** * Bitmap operations. */ struct gui_bitmap_table { - /* Mandantory entries */ + /* Mandatory entries */ /** * Create a new bitmap. * - * \param width width of image in pixels - * \param height width of image in pixels - * \param state The state to create the bitmap in. + * \param width width of image in pixels + * \param height height of image in pixels + * \param flags flags for bitmap creation * \return A bitmap structure or NULL on error. */ - void *(*create)(int width, int height, unsigned int state); + void *(*create)(int width, int height, enum gui_bitmap_flags flags); /** * Destroy a bitmap. @@ -103,16 +159,10 @@ struct gui_bitmap_table { bool (*get_opaque)(void *bitmap); /** - * Test if a bitmap is opaque. - * - * \param bitmap The bitmap to examine. - * \return The bitmap opacity. - */ - bool (*test_opaque)(void *bitmap); - - /** * Get the image buffer from a bitmap * + * Note that all pixels must be 4-byte aligned. + * * \param bitmap The bitmap to get the buffer from. * \return The image buffer or NULL if there is none. */ @@ -143,22 +193,6 @@ struct gui_bitmap_table { int (*get_height)(void *bitmap); /** - * The the *bytes* per pixel. - * - * \param bitmap The bitmap - */ - size_t (*get_bpp)(void *bitmap); - - /** - * Savde a bitmap to disc. - * - * \param bitmap The bitmap to save - * \param path The path to save the bitmap to. - * \param flags Flags affecting the save. - */ - bool (*save)(void *bitmap, const char *path, unsigned flags); - - /** * Marks a bitmap as modified. * * \param bitmap The bitmap set as modified. diff --git a/include/netsurf/browser.h b/include/netsurf/browser.h new file mode 100644 index 000000000..dfe8eb3df --- /dev/null +++ b/include/netsurf/browser.h @@ -0,0 +1,42 @@ +/* + * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net> + * 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 + * Browser interfaces. + */ + +#ifndef NETSURF_BROWSER_H_ +#define NETSURF_BROWSER_H_ + +/** + * Set the DPI of the browser. + * + * \param dpi The DPI to set. + */ +nserror browser_set_dpi(int dpi); + +/** + * Get the browser DPI. + * + * \return The DPI in use. + */ +int browser_get_dpi(void); + +#endif diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h index 439b0785d..521340a82 100644 --- a/include/netsurf/browser_window.h +++ b/include/netsurf/browser_window.h @@ -22,14 +22,15 @@ * Browser window creation and manipulation interface. */ -#ifndef _NETSURF_BROWSER_WINDOW_H_ -#define _NETSURF_BROWSER_WINDOW_H_ +#ifndef NETSURF_BROWSER_WINDOW_H_ +#define NETSURF_BROWSER_WINDOW_H_ #include <stdbool.h> #include <stdio.h> #include "utils/errors.h" #include "netsurf/mouse.h" +#include "netsurf/console.h" struct browser_window; struct hlcache_handle; @@ -41,6 +42,7 @@ struct form_control; struct nsurl; struct rect; struct redraw_context; +struct cert_chain; enum content_debug; /** @@ -57,6 +59,20 @@ typedef enum { DRAGGING_OTHER } browser_drag_type; +/** + * Browser window page information states + */ +typedef enum { + PAGE_STATE_UNKNOWN, /**< Unable to determine */ + PAGE_STATE_INTERNAL, /**< Page loaded from internal handler */ + PAGE_STATE_LOCAL, /**< Page loaded from file:/// etc */ + PAGE_STATE_INSECURE, /**< Insecure page load */ + PAGE_STATE_SECURE_OVERRIDE, /**< Secure load, but had to override */ + PAGE_STATE_SECURE_ISSUES, /**< Secure load, but has insecure elements */ + PAGE_STATE_SECURE, /**< Secure load */ + PAGE_STATE__COUNT, /**< Count of number of valid page states */ +} browser_window_page_info_state; + typedef enum { BW_EDITOR_NONE = 0, /**< No selection, no editing */ BW_EDITOR_CAN_COPY = (1 << 0), /**< Have selection */ @@ -94,6 +110,12 @@ enum browser_window_create_flags { * have that option. */ BW_CREATE_UNVERIFIABLE = (1 << 3), + + /** Request foreground opening. */ + BW_CREATE_FOREGROUND = (1 << 4), + + /** Request location bar focus. */ + BW_CREATE_FOCUS_LOCATION = (1 << 5), }; /** flags to browser_window_navigate */ @@ -119,7 +141,10 @@ enum browser_window_nav_flags { BW_NAVIGATE_UNVERIFIABLE = (1 << 2), /** suppress initial history updates (used by back/fwd/etc) */ - BW_NAVIGATE_NO_TERMINAL_HISTORY_UPDATE = (1 << 3) + BW_NAVIGATE_NO_TERMINAL_HISTORY_UPDATE = (1 << 3), + + /** Internal navigation (set only by core features using such) */ + BW_NAVIGATE_INTERNAL = (1 << 4) }; /** @@ -207,7 +232,7 @@ nserror browser_window_navigate_up(struct browser_window *bw, bool new_window); * * \note guaranteed to return a valid nsurl ptr, never returns NULL. */ -struct nsurl* browser_window_access_url(struct browser_window *bw); +struct nsurl* browser_window_access_url(const struct browser_window *bw); /** * Access a browser window's URL. @@ -264,6 +289,7 @@ bool browser_window_has_content(struct browser_window *bw); */ struct hlcache_handle *browser_window_get_content(struct browser_window *bw); + /** * Set the dimensions of the area a browser window occupies * @@ -274,21 +300,6 @@ struct hlcache_handle *browser_window_get_content(struct browser_window *bw); void browser_window_set_dimensions(struct browser_window *bw, int width, int height); -/** - * Redraw browser window, set extent to content, and update title. - * - * \param bw browser_window - * \param scroll_to_top move view to top of page - */ -void browser_window_update(struct browser_window *bw, bool scroll_to_top); - -/** - * update an area of a browser window. - * - * \param bw The browser window to update. - * \param rect The area to redraw - */ -void browser_window_update_box(struct browser_window *bw, struct rect *rect); /** * Stop all fetching activity in a browser window. @@ -297,13 +308,16 @@ void browser_window_update_box(struct browser_window *bw, struct rect *rect); */ void browser_window_stop(struct browser_window *bw); + /** * Reload the page in a browser window. * - * \param bw browser window - * \param all whether to reload all objects associated with the page + * \param bw browser window + * \param all whether to reload all objects associated with the page + * \return NSERROR_OK on success else error code. */ -void browser_window_reload(struct browser_window *bw, bool all); +nserror browser_window_reload(struct browser_window *bw, bool all); + /** * Close and destroy a browser window. @@ -336,9 +350,10 @@ void browser_window_reformat(struct browser_window *bw, bool background, int wid * * \param bw The browser window to scale. * \param scale The new scale. - * \param all Scale all windows in the tree (ie work up as well as down) + * \param absolute If the scale value is absolute or relative to current value + * \return NSERROR_OK and scale applied else other error code caused by reflow etc. */ -void browser_window_set_scale(struct browser_window *bw, float scale, bool all); +nserror browser_window_set_scale(struct browser_window *bw, float scale, bool absolute); /** @@ -349,6 +364,7 @@ void browser_window_set_scale(struct browser_window *bw, float scale, bool all); */ float browser_window_get_scale(struct browser_window *bw); + /** * Get access to any page features at the given coordinates. * @@ -367,6 +383,7 @@ float browser_window_get_scale(struct browser_window *bw); nserror browser_window_get_features(struct browser_window *bw, int x, int y, struct browser_window_features *data); + /** * Send a scroll request to a browser window at a particular point. The * 'deepest' scrollable object which can be scrolled in the requested @@ -382,6 +399,7 @@ nserror browser_window_get_features(struct browser_window *bw, bool browser_window_scroll_at_point(struct browser_window *bw, int x, int y, int scrx, int scry); + /** * Drop a file onto a browser window at a particular point, or determine if a * file may be dropped onto the content at given point. @@ -395,6 +413,7 @@ bool browser_window_scroll_at_point(struct browser_window *bw, bool browser_window_drop_file_at_point(struct browser_window *bw, int x, int y, char *file); + /** * set filename on form control. * @@ -405,6 +424,7 @@ bool browser_window_drop_file_at_point(struct browser_window *bw, void browser_window_set_gadget_filename(struct browser_window *bw, struct form_control *gadget, const char *fn); + /** * Update URL bar for a given browser window to bw's content's URL * @@ -412,6 +432,7 @@ void browser_window_set_gadget_filename(struct browser_window *bw, */ nserror browser_window_refresh_url_bar(struct browser_window *bw); + /** * Handle mouse clicks in a browser window. * @@ -423,6 +444,7 @@ nserror browser_window_refresh_url_bar(struct browser_window *bw); void browser_window_mouse_click(struct browser_window *bw, browser_mouse_state mouse, int x, int y); + /** * Handle non-click mouse action in a browser window. (drag ends, movements) * @@ -465,26 +487,6 @@ nserror browser_window_schedule_reformat(struct browser_window *bw); /** - * callback for select menu widget - * - * \todo This API needs investigating - */ -void browser_select_menu_callback(void *client_data, - int x, int y, int width, int height); - -/** - * Redraw a rectangular region of a browser window. - * - * \param bw browser window to be redrawn - * \param x x co-ord of top-left - * \param y y co-ord of top-left - * \param width width of rectangle - * \param height height of rectangle - */ -void browser_window_redraw_rect(struct browser_window *bw, int x, int y, - int width, int height); - -/** * Change the shape of the mouse pointer * * \param bw Browser window to set shape in @@ -493,6 +495,7 @@ void browser_window_redraw_rect(struct browser_window *bw, int x, int y, void browser_window_set_pointer(struct browser_window *bw, browser_pointer_shape shape); + /** * Start drag scrolling the contents of the browser window * @@ -502,6 +505,7 @@ void browser_window_set_pointer(struct browser_window *bw, */ void browser_window_page_drag_start(struct browser_window *bw, int x, int y); + /** * Check availability of Back action for a given browser window * @@ -510,6 +514,7 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y); */ bool browser_window_back_available(struct browser_window *bw); + /** * Check availability of Forward action for a given browser window * @@ -518,6 +523,7 @@ bool browser_window_back_available(struct browser_window *bw); */ bool browser_window_forward_available(struct browser_window *bw); + /** * Check availability of Reload action for a given browser window * @@ -526,6 +532,7 @@ bool browser_window_forward_available(struct browser_window *bw); */ bool browser_window_reload_available(struct browser_window *bw); + /** * Check availability of Stop action for a given browser window * @@ -534,6 +541,7 @@ bool browser_window_reload_available(struct browser_window *bw); */ bool browser_window_stop_available(struct browser_window *bw); + /** * Redraw an area of a window. * @@ -558,6 +566,7 @@ bool browser_window_stop_available(struct browser_window *bw); bool browser_window_redraw(struct browser_window *bw, int x, int y, const struct rect *clip, const struct redraw_context *ctx); + /** * Check whether browser window is ready for redraw * @@ -665,19 +674,6 @@ bool browser_window_is_frameset(struct browser_window *bw); nserror browser_window_get_scrollbar_type(struct browser_window *bw, browser_scrolling *h, browser_scrolling *v); -/** - * Set the DPI of the browser. - * - * \param dpi The DPI to set. - */ -nserror browser_set_dpi(int dpi); - -/** - * Get the browser DPI. - * - * \return The DPI in use. - */ -int browser_get_dpi(void); /** * Dump debug info concerning the browser window's contents to file @@ -725,4 +721,93 @@ nserror browser_window_get_name(struct browser_window *bw, const char **name); */ nserror browser_window_set_name(struct browser_window *bw, const char *name); +/** + * Execute some JavaScript code in a browsing context. + * + * Runs the passed in JavaScript code in the browsing context. + * + * \param bw The browser window + * \param src The JavaScript source code + * \param srclen The length of the source code + * \return Whether the JS function was successfully injected into the content + */ +bool browser_window_exec(struct browser_window *bw, const char *src, size_t srclen); + +/** + * Log a console message into the browser window console. + * + * If the targetted browser window is a frame, the message will be bubbled + * to the outermost window to be logged. + * + * \param bw The browser window + * \param src The source of the message + * \param msg The text of the message + * \param msglen The length of the text of the message + * \param flags Flags for the message + * \return Whether or not the logged message succeeded in being stored + */ +nserror browser_window_console_log(struct browser_window *bw, + browser_window_console_source src, + const char *msg, + size_t msglen, + browser_window_console_flags flags); + +/** + * Request the current browser window page info state. + * + * The page information state is an indicator enumeration to be used by + * frontends to indicate to the user if the page they are viewing is able + * to be trusted. This is often shown as a padlock of some kind. + * + * This is also used by the internal page information corewindow to render + * to the user what the situation is. + * + * \param bw The browser window + * \return The state of the browser window + */ +browser_window_page_info_state browser_window_get_page_info_state( + const struct browser_window *bw); + +/** + * Request the current browser window SSL certificate chain. + * + * When the page has SSL information, this will retrieve the certificate chain. + * + * If there is no chain available, this will return NSERROR_NOT_FOUND + * + * \param bw The browser window + * \param chain Pointer to be filled out with certificate chain + * \return Whether or not the chain is available + */ +nserror browser_window_get_ssl_chain(struct browser_window *bw, struct cert_chain **chain); + +/** + * Get the number of cookies in use for the current page. + * + * \param bw A browser window. + * \return Number of cookies in use, or 0 on error. + */ +int browser_window_get_cookie_count( + const struct browser_window *bw); + +/** + * Open cookie viewer for the current page. + * + * \param bw A browser window. + * \return NSERROR_OK, or appropriate error otherwise. + */ +nserror browser_window_show_cookies( + const struct browser_window *bw); + +/** + * Show the certificate page for the current page. + * + * Does nothing for a page without certificates. + * + * \param bw A browser window. + * \return NSERROR_OK, or appropriate error otherwise. + */ +nserror browser_window_show_certificates( + struct browser_window *bw); + #endif diff --git a/include/netsurf/console.h b/include/netsurf/console.h new file mode 100644 index 000000000..dead3fd2e --- /dev/null +++ b/include/netsurf/console.h @@ -0,0 +1,68 @@ +/* + * Copyright 2019 Daniel Silverstone <dsilvers@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 + * Browser window console stuff + */ + +#ifndef _NETSURF_CONSOLE_H_ +#define _NETSURF_CONSOLE_H_ + +/** + * Sources of messages which end up in the browser window console + */ +typedef enum { + BW_CS_INPUT, /**< Input from the client */ + BW_CS_SCRIPT_ERROR, /**< Error from some running script */ + BW_CS_SCRIPT_CONSOLE, /**< Logging from some running script */ +} browser_window_console_source; + +/** + * Flags for browser window console logging. + * + * It is valid to bitwise-or some of these flags together where indicated. + */ +typedef enum { + /** + * The log entry is foldable. + * + * Set this to indicate that the text should be folded on the first + * newline on display. If this is set but there are no newlines in + * the logged text, the core will unset it before passing on to + * callbacks or storing the log entry. + */ + BW_CS_FLAG_FOLDABLE = 1 << 0, + + /** Logged at the 'debug' level, please use only one of the LEVEL flags */ + BW_CS_FLAG_LEVEL_DEBUG = 0 << 1, + /** Logged at the 'log' level, please only use one of the LEVEL flags */ + BW_CS_FLAG_LEVEL_LOG = 1 << 1, + /** Logged at the 'info' level, please use only one of the LEVEL flags */ + BW_CS_FLAG_LEVEL_INFO = 2 << 1, + /** Logged at the 'warn' level, please use only one of the LEVEL flags */ + BW_CS_FLAG_LEVEL_WARN = 3 << 1, + /** Logged at the 'error' level, please use only one of the LEVEL flags */ + BW_CS_FLAG_LEVEL_ERROR = 4 << 1, + /* Levels 5, 6, 7 unused as yet */ + /** Mask for the error level to allow easy comparison using the above */ + BW_CS_FLAG_LEVEL_MASK = 7 << 1, +} browser_window_console_flags; + +#endif /* _NETSURF_CONSOLE_H_ */ + diff --git a/include/netsurf/content.h b/include/netsurf/content.h index 5eee59acd..d8adca040 100644 --- a/include/netsurf/content.h +++ b/include/netsurf/content.h @@ -94,7 +94,7 @@ lwc_string *content_get_mime_type(struct hlcache_handle *h); * \param size Pointer to location to receive byte size of source * \return Pointer to source data */ -const char *content_get_source_data(struct hlcache_handle *h, unsigned long *size); +const uint8_t *content_get_source_data(struct hlcache_handle *h, size_t *size); /** diff --git a/include/netsurf/content_type.h b/include/netsurf/content_type.h index ef654cd70..0a6b83009 100644 --- a/include/netsurf/content_type.h +++ b/include/netsurf/content_type.h @@ -18,7 +18,7 @@ /** * \file - * Declaration of content type enumerations. + * Declaration of content enumerations. * * The content enumerations are defined here. */ @@ -28,17 +28,27 @@ /** Debugging dump operations */ enum content_debug { - CONTENT_DEBUG_RENDER, /** Debug the contents rendering. */ - CONTENT_DEBUG_DOM, /** Debug the contents Document Object. */ - CONTENT_DEBUG_REDRAW /** Debug redraw operations. */ + /** Debug the contents rendering. */ + CONTENT_DEBUG_RENDER, + + /** Debug the contents Document Object. */ + CONTENT_DEBUG_DOM, + + /** Debug redraw operations. */ + CONTENT_DEBUG_REDRAW }; + /** Content encoding information types */ enum content_encoding_type { - CONTENT_ENCODING_NORMAL, /** The content encoding */ - CONTENT_ENCODING_SOURCE /** The content encoding source */ + /** The content encoding */ + CONTENT_ENCODING_NORMAL, + + /** The content encoding source */ + CONTENT_ENCODING_SOURCE }; + /** The type of a content. */ typedef enum { /** no type for content */ @@ -73,4 +83,101 @@ typedef enum { } content_type; +/** Status of a content */ +typedef enum { + /** Content is being fetched or converted and is not safe to display. */ + CONTENT_STATUS_LOADING, + + /** Some parts of content still being loaded, but can be displayed. */ + CONTENT_STATUS_READY, + + /** Content has completed all processing. */ + CONTENT_STATUS_DONE, + + /** Error occurred, content will be destroyed imminently. */ + CONTENT_STATUS_ERROR +} content_status; + + +/** + * Used in callbacks to indicate what has occurred. + */ +typedef enum { + /** Content wishes to log something */ + CONTENT_MSG_LOG, + + /** Content is from SSL and this is its chain */ + CONTENT_MSG_SSL_CERTS, + + /** fetching or converting */ + CONTENT_MSG_LOADING, + + /** may be displayed */ + CONTENT_MSG_READY, + + /** content has finished processing */ + CONTENT_MSG_DONE, + + /** error occurred */ + CONTENT_MSG_ERROR, + + /** fetch url redirect occured */ + CONTENT_MSG_REDIRECT, + + /** new status string */ + CONTENT_MSG_STATUS, + + /** content_reformat done */ + CONTENT_MSG_REFORMAT, + + /** needs redraw (eg. new animation frame) */ + CONTENT_MSG_REDRAW, + + /** wants refresh */ + CONTENT_MSG_REFRESH, + + /** download, not for display */ + CONTENT_MSG_DOWNLOAD, + + /** RFC5988 link */ + CONTENT_MSG_LINK, + + /** Javascript thread */ + CONTENT_MSG_GETTHREAD, + + /** Get viewport dimensions. */ + CONTENT_MSG_GETDIMS, + + /** Request to scroll content */ + CONTENT_MSG_SCROLL, + + /** Allow drag saving of content */ + CONTENT_MSG_DRAGSAVE, + + /** Allow URL to be saved */ + CONTENT_MSG_SAVELINK, + + /** Wants a specific mouse pointer set */ + CONTENT_MSG_POINTER, + + /** A selection made or cleared */ + CONTENT_MSG_SELECTION, + + /** Caret movement / hiding */ + CONTENT_MSG_CARET, + + /** A drag started or ended */ + CONTENT_MSG_DRAG, + + /** Create a select menu */ + CONTENT_MSG_SELECTMENU, + + /** A gadget has been clicked on (mainly for file) */ + CONTENT_MSG_GADGETCLICK, + + /** A free text search action has occurred */ + CONTENT_MSG_TEXTSEARCH +} content_msg; + + #endif diff --git a/include/netsurf/core_window.h b/include/netsurf/core_window.h index 77d220b9c..b7c245aff 100644 --- a/include/netsurf/core_window.h +++ b/include/netsurf/core_window.h @@ -46,9 +46,11 @@ typedef enum { } core_window_drag_status; /** - * Callbacks to achieve various core window functionality. + * Core user interface window function table. + * + * function table implementing core window operations */ -struct core_window_callback_table { +struct core_window_table { /** * Invalidate an area of a window. * @@ -69,21 +71,38 @@ struct core_window_callback_table { nserror (*invalidate)(struct core_window *cw, const struct rect *rect); /** - * Update the limits of the window + * Update the logical extent of the window * * \param[in] cw the core window object * \param[in] width the width in px, or negative if don't care * \param[in] height the height in px, or negative if don't care + * \return NSERROR_OK on success or appropriate error code + */ + nserror (*set_extent)(struct core_window *cw, int width, int height); + + /** + * Scroll the window to given scroll offsets + * + * Note: Core callers of this may want to look at calling + * the `cw_helper_scroll_visible()`, rather than calling + * this directly. + * + * \param[in] cw the core window object + * \param[in] x x-scroll value to set + * \param[in] y y-scroll value to set + * \return NSERROR_OK on success or appropriate error code */ - void (*update_size)(struct core_window *cw, int width, int height); + nserror (*set_scroll)(struct core_window *cw, int x, int y); /** - * Scroll the window to make area visible + * Get the current scroll offsets * * \param[in] cw the core window object - * \param[in] r rectangle to make visible + * \param[out] returns horizontal scroll in px + * \param[out] returns vertical scroll in px + * \return NSERROR_OK on success or appropriate error code */ - void (*scroll_visible)(struct core_window *cw, const struct rect *r); + nserror (*get_scroll)(const struct core_window *cw, int *x, int *y); /** * Get window viewport dimensions @@ -91,8 +110,9 @@ struct core_window_callback_table { * \param[in] cw the core window object * \param[out] width to be set to viewport width in px * \param[out] height to be set to viewport height in px + * \return NSERROR_OK on success or appropriate error code */ - void (*get_window_dimensions)(struct core_window *cw, + nserror (*get_dimensions)(const struct core_window *cw, int *width, int *height); /** @@ -100,8 +120,9 @@ struct core_window_callback_table { * * \param[in] cw the core window object * \param[in] ds the current drag status + * \return NSERROR_OK on success or appropriate error code */ - void (*drag_status)(struct core_window *cw, + nserror (*drag_status)(struct core_window *cw, core_window_drag_status ds); }; diff --git a/include/netsurf/fetch.h b/include/netsurf/fetch.h index 6e6d653ee..156f4d1ef 100644 --- a/include/netsurf/fetch.h +++ b/include/netsurf/fetch.h @@ -49,15 +49,15 @@ struct gui_fetch_table { /** * Translate resource to full url. * - * @note Only used in resource fetcher + * @note Only used in resource protocol fetcher * - * Transforms a resource: path into a full URL. The returned URL + * Transforms a resource protocol path into a full URL. The returned URL * is used as the target for a redirect. The caller takes ownership of * the returned nsurl including unrefing it when finished with it. * * \param path The path of the resource to locate. - * \return A string containing the full URL of the target object or - * NULL if no suitable resource can be found. + * \return A netsurf url object containing the full URL of the resource + * path or NULL if a suitable resource URL can not be generated. */ struct nsurl* (*get_resource_url)(const char *path); @@ -99,6 +99,23 @@ struct gui_fetch_table { */ char *(*mimetype)(const char *ro_path); + /** + * Open a socket + * + * \param domain Communication domain + * \param type Socket type + * \param protocol Protocol + * \return Socket descriptor on success, -1 on error and errno set + */ + int (*socket_open)(int domain, int type, int protocol); + + /** + * Close a socket + * + * \param socket Socket descriptor + * \return 0 on success, -1 on error and errno set + */ + int (*socket_close)(int socket); }; #endif diff --git a/include/netsurf/inttypes.h b/include/netsurf/inttypes.h index 874d83f3d..e2229085a 100644 --- a/include/netsurf/inttypes.h +++ b/include/netsurf/inttypes.h @@ -34,6 +34,10 @@ #define PRId64 "lld" #endif +#ifndef PRIu64 +#define PRIu64 "llu" +#endif + /* Windows does not have sizet formating codes */ #if defined(_WIN32) @@ -48,8 +52,13 @@ /** c99 standard printf formatting for size_t type */ #define PRIsizet "zu" +#if defined(__riscos__) +/** riscos/unixlib defines ssize_t as a long int */ +#define PRIssizet "ld" +#else /** c99 standard printf formatting for ssize_t type */ #define PRIssizet "zd" +#endif #endif diff --git a/include/netsurf/keypress.h b/include/netsurf/keypress.h index 604d2dd9b..84d9d41c8 100644 --- a/include/netsurf/keypress.h +++ b/include/netsurf/keypress.h @@ -59,7 +59,9 @@ enum input_key { NS_KEY_TEXT_START, NS_KEY_TEXT_END, NS_KEY_WORD_LEFT, + NS_KEY_DELETE_WORD_LEFT, NS_KEY_WORD_RIGHT, + NS_KEY_DELETE_WORD_RIGHT, NS_KEY_PAGE_UP, NS_KEY_PAGE_DOWN, NS_KEY_DELETE_LINE_END, diff --git a/include/netsurf/misc.h b/include/netsurf/misc.h index cd86cf644..00ac705cc 100644 --- a/include/netsurf/misc.h +++ b/include/netsurf/misc.h @@ -22,12 +22,12 @@ * Interface to platform-specific miscellaneous browser operation table. */ -#ifndef _NETSURF_MISC_H_ -#define _NETSURF_MISC_H_ +#ifndef NETSURF_MISC_H_ +#define NETSURF_MISC_H_ struct form_control; struct gui_window; -struct ssl_cert_info; +struct cert_chain; struct nsurl; /** @@ -57,17 +57,6 @@ struct gui_misc_table { */ nserror (*schedule)(int t, void (*callback)(void *p), void *p); - /** - * Warn the user of an event. - * - * \param[in] message A warning looked up in the message - * translation table - * \param[in] detail Additional text to be displayed or NULL. - * \return NSERROR_OK on success or error code if there was a - * faliure displaying the message to the user. - */ - nserror (*warning)(const char *message, const char *detail); - /* Optional entries */ @@ -82,35 +71,29 @@ struct gui_misc_table { nserror (*launch_url)(struct nsurl *url); /** - * Prompt the user to verify a certificate with issuse. - * - * \param url The URL being verified. - * \param certs The certificate to be verified - * \param num The number of certificates to be verified. - * \param cb Callback upon user decision. - * \param cbpw Context pointer passed to cb - * \return NSERROR_OK on sucess else error and cb never called - */ - nserror (*cert_verify)(struct nsurl *url, - const struct ssl_cert_info *certs, - unsigned long num, - nserror (*cb)(bool proceed, void *pw), - void *cbpw); - - /** - * Prompt user for login + * Retrieve username/password for a given url+realm if there is one + * stored in a frontend-specific way (e.g. gnome-keyring) * - * To cancel a login, clients should call the `cb` callback passing - * NULL for username, and password. Otherwise, for logins, username - * and password should both be non-NULL. Pass "" if the empty string + * To respond, call the callback with the url, realm, username, + * and password. Pass "" if the empty string * is required. * - * If the front end returns NSERROR_OK for this function, they must, + * To keep hold of the url, remember to nsurl_ref() it, and to keep + * the realm, you will need to strdup() it. + * + * If the front end returns NSERROR_OK for this function, they may, * at some future time, call the `cb` with `cbpw` callback exactly once. * - * If ther front end returns other than NSERROR_OK, they should not + * If the front end returns other than NSERROR_OK, they should not * call the `cb` callback. * + * The callback should not be called immediately upon receipt of this + * call as the browser window may not be reentered. + * + * **NOTE** The lifetime of the cbpw is not well defined. In general + * do not use the cb if *any* browser window has navigated or been + * destroyed. + * * \param url The URL being verified. * \param realm The authorization realm. * \param username Any current username (or empty string). @@ -120,17 +103,27 @@ struct gui_misc_table { * \return NSERROR_OK on sucess else error and cb never called */ nserror (*login)(struct nsurl *url, const char *realm, - const char *username, const char *password, - nserror (*cb)(const char *username, - const char *password, - void *pw), - void *cbpw); + const char *username, const char *password, + nserror (*cb)(struct nsurl *url, + const char *realm, + const char *username, + const char *password, + void *pw), + void *cbpw); /** * Prompt the user for a password for a PDF. */ void (*pdf_password)(char **owner_pass, char **user_pass, char *path); + /** + * Request that the cookie manager be displayed + * + * \param search_term The search term to be set (NULL if no search) + * + * \return NSERROR_OK on success + */ + nserror (*present_cookies)(const char *search_term); }; #endif diff --git a/include/netsurf/plot_style.h b/include/netsurf/plot_style.h index f1b617231..875020cd8 100644 --- a/include/netsurf/plot_style.h +++ b/include/netsurf/plot_style.h @@ -124,8 +124,13 @@ typedef struct plot_font_style { } plot_font_style_t; +/* Darken a colour by taking seven eighths of each channel's intensity */ +#define half_darken_colour(c1) \ + ((((7 * (c1 & 0xff00ff)) >> 3) & 0xff00ff) | \ + (((7 * (c1 & 0x00ff00)) >> 3) & 0x00ff00)) + /* Darken a colour by taking three quarters of each channel's intensity */ -#define darken_colour(c1) \ +#define darken_colour(c1) \ ((((3 * (c1 & 0xff00ff)) >> 2) & 0xff00ff) | \ (((3 * (c1 & 0x00ff00)) >> 2) & 0x00ff00)) @@ -134,6 +139,12 @@ typedef struct plot_font_style { ((((9 * (c1 & 0xff00ff)) >> 4) & 0xff00ff) | \ (((9 * (c1 & 0x00ff00)) >> 4) & 0x00ff00)) +/* Lighten a colour by taking seven eighths of each channel's intensity + * and adding a full one eighth intensity */ +#define half_lighten_colour(c1) \ + (((((7 * (c1 & 0xff00ff)) >> 3) + 0x200020) & 0xff00ff) | \ + ((((7 * (c1 & 0x00ff00)) >> 3) + 0x002000) & 0x00ff00)) + /* Lighten a colour by taking 12/16ths of each channel's intensity * and adding a full 4/16ths intensity */ #define lighten_colour(c1) \ @@ -153,13 +164,34 @@ typedef struct plot_font_style { (((((c0 & 0xff00ff) + (c1 & 0xff00ff)) >> 1) & 0xff00ff) | \ ((((c0 & 0x00ff00) + (c1 & 0x00ff00)) >> 1) & 0x00ff00)) +/** + * Obtain the luminance of a colour according to ITU BT.601 + * + * ITU BT.601 formula is + * Y = 0.299 R + 0.587 G + 0.114 B + * actual values are + * Y = 76/255 R + 150/255 G + 29/255 B + * Y = 0.298 R + 0.588 G + 0.113 B + * + * @note if additional performance is required this could be altered to + * Y = 0.375 R + 0.5 G + 0.125 B + * with + * Y = (R << 1 + R + G << 2 + B) >> 3 + */ +#define colour_lightness(c0) \ + ((((c0 & 0x0000ff) * 77) >> 8) + \ + (((c0 & 0x00ff00) * 151) >> 16) + \ + (((c0 & 0xff0000) * 30) >> 24)) + +/* Choose either black or white, depending on which is nearest to the + * percieved lightness of the supplied colour, c0. */ +#define colour_to_bw_nearest(c0) \ + ((colour_lightness(c0) > (0xff / 2)) ? 0xffffff : 0x000000) + /* Choose either black or white, depending on which is furthest from the * percieved lightness of the supplied colour, c0. */ #define colour_to_bw_furthest(c0) \ - ((((((c0 & 0x0000ff) * 77) >> 8) + \ - (((c0 & 0x00ff00) * 151) >> 16) + \ - (((c0 & 0xff0000) * 28) >> 24)) > \ - (0xff / 2)) ? 0x000000 : 0xffffff) + ((colour_lightness(c0) > (0xff / 2)) ? 0x000000 : 0xffffff) /* Mix two colours according to the proportion given by p, where 0 <= p <= 255 * p = 0 gives result ==> c1, p = 255 gives result ==> c0 */ @@ -169,10 +201,6 @@ typedef struct plot_font_style { (((((c1 & 0x00ff00) * (255 - p)) + \ ((c0 & 0x00ff00) * ( p)) ) >> 8) & 0x00ff00)) -/* get a bitmap pixel (image/bitmap.h) into a plot colour */ -#define pixel_to_colour(b) \ - b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24) - /* Get the red channel from a colour */ #define red_from_colour(c) \ ((c ) & 0xff) @@ -185,6 +213,45 @@ typedef struct plot_font_style { #define blue_from_colour(c) \ ((c >> 16) & 0xff) +/* Swap red and blue channels in a colour */ +#define colour_rb_swap(c) \ + (((0x000000ff & c) << 16) | \ + ((0x0000ff00 & c) ) | \ + ((0x00ff0000 & c) >> 16)) + +/** Colour components */ +enum plot_colour_component { + PLOT_COLOUR_COMPONENT_RED, + PLOT_COLOUR_COMPONENT_GREEN, + PLOT_COLOUR_COMPONENT_BLUE, + PLOT_COLOUR_COMPONENT_ALPHA, +}; + +/** + * Engorge a particular colour channel. + * + * \param[in] col The colour to engorge a component of. + * \param[in] dark Whether col is a dark colour. + * \param[in] comp Colour component to engorge. + */ +static inline colour colour_engorge_component( + colour col, + bool dark, + enum plot_colour_component comp) +{ + static const colour msk[PLOT_COLOUR_COMPONENT_ALPHA] = { + [PLOT_COLOUR_COMPONENT_RED] = 0x0000ff, + [PLOT_COLOUR_COMPONENT_GREEN] = 0x00ff00, + [PLOT_COLOUR_COMPONENT_BLUE] = 0xff0000, + }; + colour d = dark ? darken_colour(col) : double_darken_colour(col); + colour l = dark ? double_lighten_colour(col) : lighten_colour(col); + + assert(comp < PLOT_COLOUR_COMPONENT_ALPHA); + + return (msk[comp] & l) | (~msk[comp] & d); +} + /* global fill styles */ extern plot_style_t *plot_style_fill_white; diff --git a/include/netsurf/ssl_certs.h b/include/netsurf/ssl_certs.h new file mode 100644 index 000000000..05ff13161 --- /dev/null +++ b/include/netsurf/ssl_certs.h @@ -0,0 +1,145 @@ +/* + * Copyright 2019 Daniel Silverstone <dsilvers@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 + * + * SSL related types and values + */ + +#ifndef NETSURF_SSL_CERTS_H_ +#define NETSURF_SSL_CERTS_H_ + +struct nsurl; + +/** + * ssl certificate error status + * + * Do not reorder / remove entries because these may be persisted to the disk + * cache as simple ints. + */ +typedef enum { + SSL_CERT_ERR_OK, /**< Nothing wrong with this certificate */ + SSL_CERT_ERR_UNKNOWN, /**< Unknown error */ + SSL_CERT_ERR_BAD_ISSUER, /**< Bad issuer */ + SSL_CERT_ERR_BAD_SIG, /**< Bad signature on this certificate */ + SSL_CERT_ERR_TOO_YOUNG, /**< This certificate is not yet valid */ + SSL_CERT_ERR_TOO_OLD, /**< This certificate is no longer valid */ + SSL_CERT_ERR_SELF_SIGNED, /**< This certificate (or the chain) is self signed */ + SSL_CERT_ERR_CHAIN_SELF_SIGNED, /**< This certificate chain is self signed */ + SSL_CERT_ERR_REVOKED, /**< This certificate has been revoked */ + SSL_CERT_ERR_HOSTNAME_MISMATCH, /**< This certificate host did not match the server */ + SSL_CERT_ERR_CERT_MISSING, /**< This certificate was missing from the chain, its data is useless */ +} ssl_cert_err; + +/** Always the max known ssl certificate error type */ +#define SSL_CERT_ERR_MAX_KNOWN SSL_CERT_ERR_HOSTNAME_MISMATCH + +/** maximum number of X509 certificates in chain for TLS connection */ +#define MAX_CERT_DEPTH 10 + +/** + * X509 certificate chain + */ +struct cert_chain { + /** + * the number of certificates in the chain + * */ + size_t depth; + struct { + /** + * Whatever is wrong with this certificate + */ + ssl_cert_err err; + + /** + * data in Distinguished Encoding Rules (DER) format + */ + uint8_t *der; + + /** + * DER length + */ + size_t der_length; + } certs[MAX_CERT_DEPTH]; +}; + +/** + * create new certificate chain + * + * \param dpth the depth to set in the new chain. + * \param chain_out A pointer to recive the new chain. + * \return NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion + */ +nserror cert_chain_alloc(size_t depth, struct cert_chain **chain_out); + +/** + * duplicate a certificate chain into an existing chain + * + * \param src The certificate chain to copy from + * \param dst The chain to overwrite with a copy of src + * \return NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion + * + * NOTE: if this returns NSERROR_NOMEM then the destination chain will have + * some amount of content and should be cleaned up with cert_chain_free. + */ +nserror cert_chain_dup_into(const struct cert_chain *src, struct cert_chain *dst); + +/** + * duplicate a certificate chain + * + * \param src The certificate chain to copy from + * \param dst_out A pointer to recive the duplicated chain + * \return NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion + */ +nserror cert_chain_dup(const struct cert_chain *src, struct cert_chain **dst_out); + +/** + * create a certificate chain from a fetch query string + * + * \param url The url to convert the query from + * \param dst_out A pointer to recive the duplicated chain + * \return NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion + */ +nserror cert_chain_from_query(struct nsurl *url, struct cert_chain **chain_out); + +/** + * create a fetch query string from a certificate chain + * + * + * \return NSERROR_OK on success or NSERROR_NOMEM on memory exhaustion + */ +nserror cert_chain_to_query(struct cert_chain *chain, struct nsurl **url_out); + +/** + * free a certificate chain + * + * \param chain The certificate chain to free + * \return NSERROR_OK on success + */ +nserror cert_chain_free(struct cert_chain *chain); + +/** + * total number of data bytes in a chain + * + * \param chain The chain to size + * \return the number of bytes used by the chain + */ +size_t cert_chain_size(const struct cert_chain *chain); + +#endif /* NETSURF_SSL_CERTS_H_ */ diff --git a/include/netsurf/window.h b/include/netsurf/window.h index 53d9b30f2..16fd95e30 100644 --- a/include/netsurf/window.h +++ b/include/netsurf/window.h @@ -26,6 +26,16 @@ #ifndef NETSURF_WINDOW_H #define NETSURF_WINDOW_H +#include "netsurf/console.h" + +struct browser_window; +struct form_control; +struct rect; +struct hlcache_handle; +struct nsurl; + +enum gui_pointer_shape; + typedef enum gui_save_type { GUI_SAVE_SOURCE, GUI_SAVE_DRAW, @@ -56,16 +66,68 @@ typedef enum { typedef enum { GW_CREATE_NONE = 0, /**< New window */ GW_CREATE_CLONE = (1 << 0), /**< Clone existing window */ - GW_CREATE_TAB = (1 << 1) /**< Create tab in same window as existing */ + GW_CREATE_TAB = (1 << 1), /**< Create tab in same window as existing */ + GW_CREATE_FOREGROUND = (1 << 2), /**< Request this window/tab is foregrounded */ + GW_CREATE_FOCUS_LOCATION = (1 << 3) , /** Request this window/tab focusses the URL input */ } gui_window_create_flags; -struct browser_window; -struct form_control; -struct rect; -struct hlcache_handle; -struct nsurl; +/** + * Window events + * + * these are events delivered to a gui window which have no additional + * parameters and hence do not require separate callbacks. + */ +enum gui_window_event { + /** + * An empty event should never occur + */ + GW_EVENT_NONE = 0, -enum gui_pointer_shape; + /** + * Update the extent of the inside of a browser window to that of the + * current content. + * + * @todo this is used to update scroll bars does it need + * renaming? some frontends (windows) do not even implement it. + */ + GW_EVENT_UPDATE_EXTENT, + + /** + * Remove the caret, if present. + */ + GW_EVENT_REMOVE_CARET, + + /** + * start the navigation throbber. + */ + GW_EVENT_START_THROBBER, + + /** + * stop the navigation throbber. + */ + GW_EVENT_STOP_THROBBER, + + /** + * Starts drag scrolling of a browser window + */ + GW_EVENT_SCROLL_START, + + /** + * Called when the gui_window has new content. + */ + GW_EVENT_NEW_CONTENT, + + /** + * selection started + */ + GW_EVENT_START_SELECTION, + + /** + * Page status has changed and so the padlock should be + * updated. + */ + GW_EVENT_PAGE_INFO_CHANGE, +}; /** * Graphical user interface window function table. @@ -173,24 +235,23 @@ struct gui_window_table { * \param gw The gui window to measure content area of. * \param width receives width of window * \param height receives height of window - * \param scaled whether to return scaled values * \return NSERROR_OK on success and width and height updated * else error code. */ - nserror (*get_dimensions)(struct gui_window *gw, int *width, int *height, bool scaled); + nserror (*get_dimensions)(struct gui_window *gw, int *width, int *height); /** - * Update the extent of the inside of a browser window to that of the - * current content. + * Miscellaneous event occurred for a window * - * @todo this is used to update scroll bars does it need - * renaming? some frontends (windows) do not even implement it. + * This is used to inform the frontend of window events which + * require no additional parameters. * - * \param gw The gui window to update the extent of. + * \param gw The gui window the event occurred for + * \param event Which event has occurred. + * \return NSERROR_OK if the event was processed else error code. */ - void (*update_extent)(struct gui_window *gw); - + nserror (*event)(struct gui_window *gw, enum gui_window_event event); /* Optional entries */ @@ -246,27 +307,6 @@ struct gui_window_table { void (*place_caret)(struct gui_window *g, int x, int y, int height, const struct rect *clip); /** - * Remove the caret, if present. - * - * \param g window with caret - */ - void (*remove_caret)(struct gui_window *g); - - /** - * start the navigation throbber. - * - * \param g window in which to start throbber. - */ - void (*start_throbber)(struct gui_window *g); - - /** - * stop the navigation throbber. - * - * \param g window with throbber to stop - */ - void (*stop_throbber)(struct gui_window *g); - - /** * start a drag operation within a window * * \param g window to start drag from. @@ -286,21 +326,6 @@ struct gui_window_table { */ nserror (*save_link)(struct gui_window *g, struct nsurl *url, const char *title); - - /** - * Starts drag scrolling of a browser window - * - * \param g the window to scroll - */ - bool (*scroll_start)(struct gui_window *g); - - /** - * Called when the gui_window has new content. - * - * \param gw The gui window that has new content - */ - void (*new_content)(struct gui_window *gw); - /** * create a form select menu * @@ -336,11 +361,21 @@ struct gui_window_table { void (*drag_save_selection)(struct gui_window *gw, const char *selection); /** - * selection started + * console logging happening. + * + * See \ref browser_window_console_log * - * \param gw The gui window to start selection in. + * \param gw The gui window receiving the logging. + * \param src The source of the logging message + * \param msg The text of the logging message + * \param msglen The length of the text of the logging message + * \param flags Flags associated with the logging. */ - void (*start_selection)(struct gui_window *gw); + void (*console_log)(struct gui_window *gw, + browser_window_console_source src, + const char *msg, + size_t msglen, + browser_window_console_flags flags); }; #endif |