From ab952e063444544d57e86ff089715dd0b6558342 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 May 2020 20:55:44 +0100 Subject: [PATCH] improve content header usage --- content/content.h | 155 +------------------ content/content_factory.h | 5 +- content/content_protected.h | 115 +++++++++++++- content/handlers/css/css.c | 10 +- content/handlers/html/box_special.c | 1 + content/handlers/html/dom_event.c | 2 + content/handlers/html/html.c | 1 + content/handlers/html/layout.c | 1 + content/handlers/html/redraw.c | 1 + content/handlers/html/script.c | 1 + content/handlers/image/bmp.c | 13 +- content/handlers/image/gif.c | 2 + content/handlers/image/ico.c | 1 + content/handlers/image/jpeg.c | 2 + content/handlers/image/png.c | 1 + content/handlers/image/rsvg.c | 1 + content/handlers/image/svg.c | 1 + content/handlers/javascript/content.c | 2 + content/handlers/text/textplain.c | 1 + content/hlcache.c | 1 + desktop/search.c | 1 + desktop/textinput.c | 5 +- frontends/amiga/dt_anim.c | 2 + frontends/amiga/dt_picture.c | 2 + frontends/amiga/dt_sound.c | 1 + frontends/amiga/file.c | 1 + frontends/amiga/icon.c | 2 + frontends/amiga/plugin_hack.c | 1 + frontends/riscos/content-handlers/artworks.c | 2 + frontends/riscos/content-handlers/draw.c | 2 + frontends/riscos/content-handlers/sprite.c | 2 + include/netsurf/content_type.h | 116 +++++++++++++- 32 files changed, 281 insertions(+), 173 deletions(-) diff --git a/content/content.h b/content/content.h index 169fd5ae3..2b16c5225 100644 --- a/content/content.h +++ b/content/content.h @@ -24,14 +24,13 @@ * The content functions manipulate struct contents, which correspond to URLs. */ -#ifndef _NETSURF_CONTENT_CONTENT_H_ -#define _NETSURF_CONTENT_CONTENT_H_ +#ifndef NETSURF_CONTENT_CONTENT_H_ +#define NETSURF_CONTENT_CONTENT_H_ #include -#include "utils/errors.h" -#include "content/content_factory.h" #include "desktop/search.h" /* search flags enum */ +#include "netsurf/content_type.h" #include "netsurf/mouse.h" /* mouse state enums */ #include "netsurf/console.h" /* console state and flags enums */ @@ -43,48 +42,8 @@ struct hlcache_handle; struct object_params; struct rect; struct redraw_context; -struct llcache_query_msg; struct cert_chain; -/** Status of a content */ -typedef enum { - CONTENT_STATUS_LOADING, /**< Content is being fetched or - converted and is not safe to display. */ - CONTENT_STATUS_READY, /**< Some parts of content still being - loaded, but can be displayed. */ - CONTENT_STATUS_DONE, /**< All finished. */ - CONTENT_STATUS_ERROR /**< Error occurred, content will be - destroyed imminently. */ -} content_status; - -/** Used in callbacks to indicate what has occurred. */ -typedef enum { - CONTENT_MSG_LOG, /**< Content wishes to log something */ - CONTENT_MSG_SSL_CERTS, /**< Content is from SSL and this is its chain */ - CONTENT_MSG_LOADING, /**< fetching or converting */ - CONTENT_MSG_READY, /**< may be displayed */ - CONTENT_MSG_DONE, /**< finished */ - CONTENT_MSG_ERROR, /**< error occurred */ - CONTENT_MSG_REDIRECT, /**< fetch url redirect occured */ - CONTENT_MSG_STATUS, /**< new status string */ - CONTENT_MSG_REFORMAT, /**< content_reformat done */ - CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */ - CONTENT_MSG_REFRESH, /**< wants refresh */ - CONTENT_MSG_DOWNLOAD, /**< download, not for display */ - CONTENT_MSG_LINK, /**< RFC5988 link */ - CONTENT_MSG_GETTHREAD, /**< Javascript thread */ - CONTENT_MSG_GETDIMS, /**< Get viewport dimensions. */ - CONTENT_MSG_SCROLL, /**< Request to scroll content */ - CONTENT_MSG_DRAGSAVE, /**< Allow drag saving of content */ - CONTENT_MSG_SAVELINK, /**< Allow URL to be saved */ - CONTENT_MSG_POINTER, /**< Wants a specific mouse pointer set */ - CONTENT_MSG_SELECTION, /**< A selection made or cleared */ - CONTENT_MSG_CARET, /**< Caret movement / hiding */ - CONTENT_MSG_DRAG, /**< A drag started or ended */ - CONTENT_MSG_SELECTMENU,/**< Create a select menu */ - CONTENT_MSG_GADGETCLICK/**< A gadget has been clicked on (mainly for file) */ -} content_msg; - /** RFC5988 metadata link */ struct content_rfc5988_link { @@ -286,114 +245,6 @@ union content_msg_data { }; -/* The following are for hlcache */ - -/** - * Destroy and free a content. - * - * Calls the destroy function for the content, and frees the structure. - */ -void content_destroy(struct content *c); - -/** - * Register a user for callbacks. - * - * \param c the content to register - * \param callback the user callback function - * \param pw callback private data - * \return true on success, false otherwise on memory exhaustion - * - * The callback will be called when content_broadcast() is - * called with the content. - */ -bool content_add_user(struct content *h, - void (*callback)( - struct content *c, - content_msg msg, - const union content_msg_data *data, - void *pw), - void *pw); - -/** - * Remove a callback user. - * - * The callback function and pw must be identical to those passed to - * content_add_user(). - * - * \param c Content to remove user from - * \param callback passed when added - * \param ctx Context passed when added - */ -void content_remove_user(struct content *c, - void (*callback)( - struct content *c, - content_msg msg, - const union content_msg_data *data, - void *pw), - void *ctx); - - -/** - * Count users for the content. - * - * \param c Content to consider - */ -uint32_t content_count_users(struct content *c); - - -/** - * Determine if quirks mode matches - * - * \param c Content to consider - * \param quirks Quirks mode to match - * \return True if quirks match, false otherwise - */ -bool content_matches_quirks(struct content *c, bool quirks); - -/** - * Determine if a content is shareable - * - * \param c Content to consider - * \return True if content is shareable, false otherwise - */ -bool content_is_shareable(struct content *c); - -/** - * Retrieve the low-level cache handle for a content - * - * \note only used by hlcache - * - * \param c Content to retrieve from - * \return Low-level cache handle - */ -const struct llcache_handle *content_get_llcache_handle(struct content *c); - -/** - * Retrieve URL associated with content - * - * \param c Content to retrieve URL from - * \return Pointer to URL, or NULL if not found. - */ -struct nsurl *content_get_url(struct content *c); - -/** - * Clone a content object in its current state. - * - * \param c Content to clone - * \return Clone of \a c - */ -struct content *content_clone(struct content *c); - -/** - * Abort a content object - * - * \param c The content object to abort - * \return NSERROR_OK on success, otherwise appropriate error - */ -nserror content_abort(struct content *c); - -/* Client functions */ - /** * Get whether a content can reformat * diff --git a/content/content_factory.h b/content/content_factory.h index 9beeb193c..354a1789f 100644 --- a/content/content_factory.h +++ b/content/content_factory.h @@ -46,13 +46,12 @@ nserror HNAME##_init(void) \ struct content; struct llcache_handle; - -typedef struct content_handler content_handler; +struct content_handler; void content_factory_fini(void); nserror content_factory_register_handler(const char *mime_type, - const content_handler *handler); + const struct content_handler *handler); struct content *content_factory_create_content(struct llcache_handle *llcache, const char *fallback_charset, bool quirks, diff --git a/content/content_protected.h b/content/content_protected.h index 3b6d1f7d3..314a0a9a3 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -28,15 +28,24 @@ #define NETSURF_CONTENT_CONTENT_PROTECTED_H_ #include +#include #include "netsurf/content_type.h" -#include "content/content.h" +#include "desktop/search.h" /* search flags enum */ +#include "netsurf/mouse.h" /* mouse state enums */ struct nsurl; struct content_redraw_data; +union content_msg_data; struct http_parameter; struct llcache_handle; struct object_params; +struct content; +struct redraw_context; +struct rect; +struct browser_window_features; + +typedef struct content_handler content_handler; /** * Content operation function table @@ -457,4 +466,108 @@ const char *content__get_encoding(struct content *c, enum content_encoding_type */ bool content__is_locked(struct content *c); +/** + * Destroy and free a content. + * + * Calls the destroy function for the content, and frees the structure. + */ +void content_destroy(struct content *c); + +/** + * Register a user for callbacks. + * + * \param c the content to register + * \param callback the user callback function + * \param pw callback private data + * \return true on success, false otherwise on memory exhaustion + * + * The callback will be called when content_broadcast() is + * called with the content. + */ +bool content_add_user(struct content *h, + void (*callback)( + struct content *c, + content_msg msg, + const union content_msg_data *data, + void *pw), + void *pw); + +/** + * Remove a callback user. + * + * The callback function and pw must be identical to those passed to + * content_add_user(). + * + * \param c Content to remove user from + * \param callback passed when added + * \param ctx Context passed when added + */ +void content_remove_user(struct content *c, + void (*callback)( + struct content *c, + content_msg msg, + const union content_msg_data *data, + void *pw), + void *ctx); + + +/** + * Count users for the content. + * + * \param c Content to consider + */ +uint32_t content_count_users(struct content *c); + + +/** + * Determine if quirks mode matches + * + * \param c Content to consider + * \param quirks Quirks mode to match + * \return True if quirks match, false otherwise + */ +bool content_matches_quirks(struct content *c, bool quirks); + +/** + * Determine if a content is shareable + * + * \param c Content to consider + * \return True if content is shareable, false otherwise + */ +bool content_is_shareable(struct content *c); + +/** + * Retrieve the low-level cache handle for a content + * + * \note only used by hlcache + * + * \param c Content to retrieve from + * \return Low-level cache handle + */ +const struct llcache_handle *content_get_llcache_handle(struct content *c); + +/** + * Retrieve URL associated with content + * + * \param c Content to retrieve URL from + * \return Pointer to URL, or NULL if not found. + */ +struct nsurl *content_get_url(struct content *c); + +/** + * Clone a content object in its current state. + * + * \param c Content to clone + * \return Clone of \a c + */ +struct content *content_clone(struct content *c); + +/** + * Abort a content object + * + * \param c The content object to abort + * \return NSERROR_OK on success, otherwise appropriate error + */ +nserror content_abort(struct content *c); + #endif diff --git a/content/handlers/css/css.c b/content/handlers/css/css.c index af2a9bc88..6bdc124e2 100644 --- a/content/handlers/css/css.c +++ b/content/handlers/css/css.c @@ -20,15 +20,17 @@ #include #include -#include "content/content_protected.h" -#include "content/fetch.h" -#include "content/hlcache.h" -#include "desktop/system_colour.h" +#include "utils/errors.h" #include "utils/corestrings.h" #include "utils/utils.h" #include "utils/http.h" #include "utils/log.h" #include "utils/messages.h" +#include "content/content_protected.h" +#include "content/content_factory.h" +#include "content/fetch.h" +#include "content/hlcache.h" +#include "desktop/system_colour.h" #include "css/css.h" #include "css/hints.h" diff --git a/content/handlers/html/box_special.c b/content/handlers/html/box_special.c index a369ec8ce..23cfeec0b 100644 --- a/content/handlers/html/box_special.c +++ b/content/handlers/html/box_special.c @@ -40,6 +40,7 @@ #include "netsurf/plot_style.h" #include "css/hints.h" #include "desktop/frame_types.h" +#include "content/content_factory.h" #include "html/html.h" #include "html/private.h" diff --git a/content/handlers/html/dom_event.c b/content/handlers/html/dom_event.c index 08a1e45f2..b702cb304 100644 --- a/content/handlers/html/dom_event.c +++ b/content/handlers/html/dom_event.c @@ -22,12 +22,14 @@ * Implementation of HTML content DOM event handling. */ +#include "utils/config.h" #include "utils/corestrings.h" #include "utils/nsoption.h" #include "utils/log.h" #include "utils/ascii.h" #include "utils/string.h" #include "utils/nsurl.h" +#include "content/content.h" #include "javascript/js.h" #include "html/private.h" diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c index 0e13b9407..af06431bf 100644 --- a/content/handlers/html/html.c +++ b/content/handlers/html/html.c @@ -48,6 +48,7 @@ #include "netsurf/layout.h" #include "netsurf/misc.h" #include "content/hlcache.h" +#include "content/content_factory.h" #include "desktop/selection.h" #include "desktop/scrollbar.h" #include "desktop/textarea.h" diff --git a/content/handlers/html/layout.c b/content/handlers/html/layout.c index b87fd16c4..ddf1d1632 100644 --- a/content/handlers/html/layout.c +++ b/content/handlers/html/layout.c @@ -52,6 +52,7 @@ #include "netsurf/content.h" #include "netsurf/browser_window.h" #include "netsurf/layout.h" +#include "content/content.h" #include "content/content_protected.h" #include "css/utils.h" #include "desktop/scrollbar.h" diff --git a/content/handlers/html/redraw.c b/content/handlers/html/redraw.c index fa4cd954d..936c1b333 100644 --- a/content/handlers/html/redraw.c +++ b/content/handlers/html/redraw.c @@ -45,6 +45,7 @@ #include "netsurf/plotters.h" #include "netsurf/bitmap.h" #include "netsurf/layout.h" +#include "content/content.h" #include "content/content_protected.h" #include "css/utils.h" #include "desktop/selection.h" diff --git a/content/handlers/html/script.c b/content/handlers/html/script.c index faab08ba6..962386d68 100644 --- a/content/handlers/html/script.c +++ b/content/handlers/html/script.c @@ -36,6 +36,7 @@ #include "netsurf/content.h" #include "javascript/js.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/fetch.h" #include "content/hlcache.h" diff --git a/content/handlers/image/bmp.c b/content/handlers/image/bmp.c index 448728ede..a1a6ce686 100644 --- a/content/handlers/image/bmp.c +++ b/content/handlers/image/bmp.c @@ -33,6 +33,7 @@ #include "netsurf/content.h" #include "content/llcache.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "desktop/gui_internal.h" #include "image/bmp.h" @@ -87,10 +88,14 @@ static nserror nsbmp_create_bmp_data(nsbmp_content *bmp) return NSERROR_OK; } -static nserror nsbmp_create(const content_handler *handler, - lwc_string *imime_type, const struct http_parameter *params, - llcache_handle *llcache, const char *fallback_charset, - bool quirks, struct content **c) +static nserror +nsbmp_create(const struct content_handler *handler, + lwc_string *imime_type, + const struct http_parameter *params, + llcache_handle *llcache, + const char *fallback_charset, + bool quirks, + struct content **c) { nsbmp_content *bmp; nserror error; diff --git a/content/handlers/image/gif.c b/content/handlers/image/gif.c index fa09f401c..6ef4fa7e7 100644 --- a/content/handlers/image/gif.c +++ b/content/handlers/image/gif.c @@ -43,7 +43,9 @@ #include "netsurf/bitmap.h" #include "netsurf/content.h" #include "content/llcache.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "desktop/gui_internal.h" #include "image/image.h" diff --git a/content/handlers/image/ico.c b/content/handlers/image/ico.c index fdaff829a..312127869 100644 --- a/content/handlers/image/ico.c +++ b/content/handlers/image/ico.c @@ -32,6 +32,7 @@ #include "netsurf/content.h" #include "content/llcache.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "desktop/gui_internal.h" #include "image/image.h" diff --git a/content/handlers/image/jpeg.c b/content/handlers/image/jpeg.c index 9df084b74..09e68fd29 100644 --- a/content/handlers/image/jpeg.c +++ b/content/handlers/image/jpeg.c @@ -33,7 +33,9 @@ #include "utils/messages.h" #include "netsurf/bitmap.h" #include "content/llcache.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "desktop/gui_internal.h" #include "image/image_cache.h" diff --git a/content/handlers/image/png.c b/content/handlers/image/png.c index cf8e780d6..1fa707d35 100644 --- a/content/handlers/image/png.c +++ b/content/handlers/image/png.c @@ -29,6 +29,7 @@ #include "netsurf/bitmap.h" #include "content/llcache.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "desktop/gui_internal.h" #include "image/image_cache.h" diff --git a/content/handlers/image/rsvg.c b/content/handlers/image/rsvg.c index c7cb6257e..5cf900dac 100644 --- a/content/handlers/image/rsvg.c +++ b/content/handlers/image/rsvg.c @@ -49,6 +49,7 @@ #include "netsurf/content.h" #include "content/llcache.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "desktop/gui_internal.h" #include "image/rsvg.h" diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c index 6194389bf..895d799df 100644 --- a/content/handlers/image/svg.c +++ b/content/handlers/image/svg.c @@ -34,6 +34,7 @@ #include "netsurf/plotters.h" #include "netsurf/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "image/svg.h" diff --git a/content/handlers/javascript/content.c b/content/handlers/javascript/content.c index 2cb5ecd6f..9f37e126c 100644 --- a/content/handlers/javascript/content.c +++ b/content/handlers/javascript/content.c @@ -26,8 +26,10 @@ #include #include +#include "utils/errors.h" #include "utils/config.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/hlcache.h" #include "utils/log.h" #include "utils/messages.h" diff --git a/content/handlers/text/textplain.c b/content/handlers/text/textplain.c index 86122ff73..e9037f9ba 100644 --- a/content/handlers/text/textplain.c +++ b/content/handlers/text/textplain.c @@ -45,6 +45,7 @@ #include "netsurf/plotters.h" #include "netsurf/layout.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/hlcache.h" #include "css/utils.h" #include "utils/nsoption.h" diff --git a/content/hlcache.c b/content/hlcache.c index 23dbc5706..2e15edd56 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -38,6 +38,7 @@ #include "content/hlcache.h" // Note, this is *ONLY* so that we can abort cleanly during shutdown of the cache #include "content/content_protected.h" +#include "content/content_factory.h" typedef struct hlcache_entry hlcache_entry; typedef struct hlcache_retrieval_ctx hlcache_retrieval_ctx; diff --git a/desktop/search.c b/desktop/search.c index 3d3e7704f..c4b5b3535 100644 --- a/desktop/search.c +++ b/desktop/search.c @@ -23,6 +23,7 @@ * Free text search (core) */ +#include "utils/errors.h" #include "content/content.h" #include "netsurf/types.h" #include "netsurf/browser_window.h" diff --git a/desktop/textinput.c b/desktop/textinput.c index e19fb61d2..b8dced689 100644 --- a/desktop/textinput.c +++ b/desktop/textinput.c @@ -33,14 +33,13 @@ #include "utils/talloc.h" #include "utils/utf8.h" #include "utils/utils.h" +#include "netsurf/types.h" #include "netsurf/mouse.h" #include "netsurf/form.h" #include "netsurf/window.h" #include "netsurf/browser_window.h" #include "netsurf/keypress.h" -#include "html/box.h" -#include "html/private.h" -#include "html/layout.h" +#include "content/content.h" #include "desktop/browser_private.h" #include "desktop/textinput.h" diff --git a/frontends/amiga/dt_anim.c b/frontends/amiga/dt_anim.c index 70f7e6ba6..99ccffe32 100644 --- a/frontends/amiga/dt_anim.c +++ b/frontends/amiga/dt_anim.c @@ -40,7 +40,9 @@ #include "netsurf/plotters.h" #include "netsurf/bitmap.h" #include "netsurf/content.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/llcache.h" #include "amiga/bitmap.h" diff --git a/frontends/amiga/dt_picture.c b/frontends/amiga/dt_picture.c index 3b2b942b0..2e5d1555b 100644 --- a/frontends/amiga/dt_picture.c +++ b/frontends/amiga/dt_picture.c @@ -36,7 +36,9 @@ #include "netsurf/plotters.h" #include "netsurf/bitmap.h" #include "content/llcache.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/handlers/image/image_cache.h" #include "amiga/bitmap.h" diff --git a/frontends/amiga/dt_sound.c b/frontends/amiga/dt_sound.c index e0a794fa9..e0081039e 100644 --- a/frontends/amiga/dt_sound.c +++ b/frontends/amiga/dt_sound.c @@ -36,6 +36,7 @@ #include "html/box.h" #include "content/llcache.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "amiga/filetype.h" #include "amiga/datatypes.h" diff --git a/frontends/amiga/file.c b/frontends/amiga/file.c index 67866aa48..2fe7d6635 100644 --- a/frontends/amiga/file.c +++ b/frontends/amiga/file.c @@ -29,6 +29,7 @@ #include "utils/nsurl.h" #include "netsurf/browser_window.h" #include "netsurf/content.h" +#include "content/content_factory.h" #include "desktop/save_complete.h" #include "desktop/save_pdf.h" #include "desktop/save_text.h" diff --git a/frontends/amiga/icon.c b/frontends/amiga/icon.c index 914ab65f2..353ba9196 100644 --- a/frontends/amiga/icon.c +++ b/frontends/amiga/icon.c @@ -45,7 +45,9 @@ #include "netsurf/plotters.h" #include "netsurf/bitmap.h" #include "netsurf/content.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "amiga/os3support.h" #include "amiga/bitmap.h" diff --git a/frontends/amiga/plugin_hack.c b/frontends/amiga/plugin_hack.c index 5d7ec19c1..fa75bd910 100644 --- a/frontends/amiga/plugin_hack.c +++ b/frontends/amiga/plugin_hack.c @@ -35,6 +35,7 @@ #include "amiga/filetype.h" #include "amiga/plugin_hack.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/llcache.h" diff --git a/frontends/riscos/content-handlers/artworks.c b/frontends/riscos/content-handlers/artworks.c index eecb0f8ab..0227603d9 100644 --- a/frontends/riscos/content-handlers/artworks.c +++ b/frontends/riscos/content-handlers/artworks.c @@ -38,7 +38,9 @@ #include "utils/utils.h" #include "netsurf/plotters.h" #include "netsurf/content.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/llcache.h" #include "riscos/content-handlers/artworks.h" diff --git a/frontends/riscos/content-handlers/draw.c b/frontends/riscos/content-handlers/draw.c index 870e33be3..522d5d3fe 100644 --- a/frontends/riscos/content-handlers/draw.c +++ b/frontends/riscos/content-handlers/draw.c @@ -35,7 +35,9 @@ #include "utils/utils.h" #include "netsurf/plotters.h" #include "netsurf/content.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "content/llcache.h" #include "riscos/content-handlers/draw.h" diff --git a/frontends/riscos/content-handlers/sprite.c b/frontends/riscos/content-handlers/sprite.c index 86749096f..f6ab68451 100644 --- a/frontends/riscos/content-handlers/sprite.c +++ b/frontends/riscos/content-handlers/sprite.c @@ -36,7 +36,9 @@ #include "netsurf/plotters.h" #include "netsurf/content.h" #include "content/llcache.h" +#include "content/content.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "riscos/gui.h" #include "riscos/image.h" diff --git a/include/netsurf/content_type.h b/include/netsurf/content_type.h index ef654cd70..b6bc5c218 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,98 @@ 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 +} content_msg; + + #endif