summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2020-05-07 20:55:44 +0100
committerVincent Sanders <vince@kyllikki.org>2020-05-07 20:55:44 +0100
commitab952e063444544d57e86ff089715dd0b6558342 (patch)
treea4ae7751848bf6d42cda6b8df1397d6a489c81c8 /content
parent5f8b1497e1489e2b3c11e8a49f01770433115ee2 (diff)
downloadnetsurf-ab952e063444544d57e86ff089715dd0b6558342.tar.gz
netsurf-ab952e063444544d57e86ff089715dd0b6558342.tar.bz2
improve content header usage
Diffstat (limited to 'content')
-rw-r--r--content/content.h155
-rw-r--r--content/content_factory.h5
-rw-r--r--content/content_protected.h115
-rw-r--r--content/handlers/css/css.c10
-rw-r--r--content/handlers/html/box_special.c1
-rw-r--r--content/handlers/html/dom_event.c2
-rw-r--r--content/handlers/html/html.c1
-rw-r--r--content/handlers/html/layout.c1
-rw-r--r--content/handlers/html/redraw.c1
-rw-r--r--content/handlers/html/script.c1
-rw-r--r--content/handlers/image/bmp.c13
-rw-r--r--content/handlers/image/gif.c2
-rw-r--r--content/handlers/image/ico.c1
-rw-r--r--content/handlers/image/jpeg.c2
-rw-r--r--content/handlers/image/png.c1
-rw-r--r--content/handlers/image/rsvg.c1
-rw-r--r--content/handlers/image/svg.c1
-rw-r--r--content/handlers/javascript/content.c2
-rw-r--r--content/handlers/text/textplain.c1
-rw-r--r--content/hlcache.c1
20 files changed, 153 insertions, 164 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 <libwapcaplet/libwapcaplet.h>
-#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 <stdio.h>
+#include <libwapcaplet/libwapcaplet.h>
#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 <libwapcaplet/libwapcaplet.h>
#include <dom/dom.h>
-#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 <stdbool.h>
#include <stdlib.h>
+#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;