From 76a68d7dd02f3819e4e60cd9febfd45e20821e14 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 6 Jun 2016 08:59:23 +0100 Subject: Update content to split public and internal API --- content/content.c | 18 +--- content/content.h | 179 ++++++++--------------------------- content/content_factory.h | 2 +- content/content_protected.h | 25 ++--- content/content_type.h | 55 ----------- content/fetchers/about.c | 1 - content/handlers/image/bmp.c | 6 +- content/handlers/image/gif.c | 6 +- content/handlers/image/ico.c | 4 +- content/handlers/image/image.c | 4 +- content/handlers/image/image.h | 2 + content/handlers/image/image_cache.c | 5 +- content/handlers/image/image_cache.h | 1 + content/handlers/image/jpeg.c | 3 +- content/handlers/image/nssprite.c | 8 +- content/handlers/image/png.c | 15 ++- content/handlers/image/svg.c | 5 +- content/hlcache.c | 2 +- content/hlcache.h | 7 -- content/urldb.h | 3 +- 20 files changed, 96 insertions(+), 255 deletions(-) delete mode 100644 content/content_type.h (limited to 'content') diff --git a/content/content.c b/content/content.c index 888202e6e..f650af22c 100644 --- a/content/content.c +++ b/content/content.c @@ -28,11 +28,12 @@ #include "utils/utils.h" #include "utils/log.h" #include "utils/messages.h" +#include "netsurf/browser_window.h" +#include "netsurf/bitmap.h" +#include "netsurf/content.h" #include "desktop/knockout.h" #include "desktop/gui_internal.h" -#include "netsurf/browser_window.h" -#include "netsurf/bitmap.h" #include "content/content_protected.h" #include "content/content_debug.h" #include "content/hlcache.h" @@ -542,12 +543,8 @@ void content__request_redraw(struct content *c, content_broadcast(c, CONTENT_MSG_REDRAW, data); } -/** - * Display content on screen with optional tiling. - * - * Calls the redraw function for the content. - */ +/* exported interface, documented in content/content.h */ bool content_redraw(hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx) { @@ -1050,12 +1047,7 @@ bool content__add_rfc5988_link(struct content *c, -/** - * Retrieve URL associated with content - * - * \param c Content to retrieve URL from - * \return Pointer to URL, or NULL if not found. - */ +/* exported interface documented in content/content.h */ nsurl *content_get_url(struct content *c) { if (c == NULL) diff --git a/content/content.h b/content/content.h index 1c7507721..308b2113b 100644 --- a/content/content.h +++ b/content/content.h @@ -17,8 +17,9 @@ * along with this program. If not, see . */ -/** \file - * Content handling (interface). +/** + * \file + * Content handling interface. * * The content functions manipulate struct contents, which correspond to URLs. */ @@ -30,10 +31,8 @@ #include "utils/errors.h" #include "content/content_factory.h" -#include "content/content_type.h" #include "desktop/search.h" /* search flags enum */ #include "netsurf/mouse.h" /* mouse state enums */ -#include "desktop/plot_style.h" /* color typedef */ struct browser_window; struct browser_window_features; @@ -81,18 +80,6 @@ typedef enum { CONTENT_MSG_GADGETCLICK/**< A gadget has been clicked on (mainly for file) */ } content_msg; -/** 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. */ -}; - -/** Content encoding informstion types */ -enum content_encoding_type { - CONTENT_ENCODING_NORMAL, /** The content encoding */ - CONTENT_ENCODING_SOURCE /** The content encoding source */ -}; /** RFC5988 metadata link */ struct content_rfc5988_link { @@ -208,44 +195,35 @@ union content_msg_data { } gadget_click; }; -/** parameters to content redraw */ -struct content_redraw_data { - int x; /**< coordinate for top-left of redraw */ - int y; /**< coordinate for top-left of redraw */ - /** dimensions to render content at - * (for scaling contents with intrinsic dimensions) */ - int width; /**< horizontal dimension */ - int height; /**< vertical dimension */ +/* The following are for hlcache */ +void content_destroy(struct content *c); - /** The background colour */ - colour background_colour; - /** Scale for redraw - * (for scaling contents without intrinsic dimensions) */ - float scale; /**< Scale factor for redraw */ +bool content_add_user(struct content *h, void (*callback)(struct content *c, content_msg msg, union content_msg_data data, void *pw), void *pw); - bool repeat_x; /**< whether content is tiled in x direction */ - bool repeat_y; /**< whether content is tiled in y direction */ -}; -/* The following are for hlcache */ -void content_destroy(struct content *c); +void content_remove_user(struct content *c, void (*callback)(struct content *c, content_msg msg, union content_msg_data data, void *pw), void *pw); -bool content_add_user(struct content *h, - void (*callback)(struct content *c, content_msg msg, - union content_msg_data data, void *pw), - void *pw); -void content_remove_user(struct content *c, - void (*callback)(struct content *c, content_msg msg, - union content_msg_data data, void *pw), - void *pw); uint32_t content_count_users(struct content *c); + + bool content_matches_quirks(struct content *c, bool quirks); + + bool content_is_shareable(struct content *c); +/* only used by cocoa apple image handling and for getting nsurl of content */ 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); struct content *content_clone(struct content *c); @@ -254,42 +232,29 @@ nserror content_abort(struct content *c); /* Client functions */ bool content_can_reformat(struct hlcache_handle *h); + void content_reformat(struct hlcache_handle *h, bool background, int width, int height); + void content_request_redraw(struct hlcache_handle *h, int x, int y, int width, int height); + void content_mouse_track(struct hlcache_handle *h, struct browser_window *bw, browser_mouse_state mouse, int x, int y); + void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw, browser_mouse_state mouse, int x, int y); -bool content_keypress(struct hlcache_handle *h, uint32_t key); -bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data, - const struct rect *clip, const struct redraw_context *ctx); +bool content_keypress(struct hlcache_handle *h, uint32_t key); -/** - * Redraw a content with scale set for horizontal fit. - * - * Redraws the content at a specified width and height with the - * content drawing scaled to fit within the area. - * - * \param content The content to redraw - * \param width The target width - * \param height The target height - * \param ctx current redraw context - * \return true if successful, false otherwise - * - * The thumbnail is guaranteed to be filled to its width/height extents, so - * there is no need to render a solid background first. - * - * Units for width and height are pixels. - */ -bool content_scaled_redraw(struct hlcache_handle *content, int width, int height, const struct redraw_context *ctx); void content_open(struct hlcache_handle *h, struct browser_window *bw, struct content *page, struct object_params *params); + void content_close(struct hlcache_handle *h); + void content_clear_selection(struct hlcache_handle *h); + char * content_get_selection(struct hlcache_handle *h); /** @@ -305,13 +270,16 @@ nserror content_get_contextual_content(struct hlcache_handle *h, bool content_scroll_at_point(struct hlcache_handle *h, int x, int y, int scrx, int scry); + bool content_drop_file_at_point(struct hlcache_handle *h, int x, int y, char *file); void content_search(struct hlcache_handle *h, void *context, search_flags_t flags, const char *string); + void content_search_clear(struct hlcache_handle *h); + /** * Control debug con a content. * @@ -320,6 +288,7 @@ void content_search_clear(struct hlcache_handle *h); */ nserror content_debug(struct hlcache_handle *h, enum content_debug op); + /** * find link in content that matches the rel string. * @@ -328,34 +297,8 @@ nserror content_debug(struct hlcache_handle *h, enum content_debug op); * \return A matching rfc5988 link or NULL if none is found. * */ -struct content_rfc5988_link *content_find_rfc5988_link(struct hlcache_handle *h, - lwc_string *rel); +struct content_rfc5988_link *content_find_rfc5988_link(struct hlcache_handle *h, lwc_string *rel); -/* Member accessors */ - -/** - * Retrieve computed type of content - * - * \param h handle to the content to retrieve tyoe of. - * \return Computed content type - */ -content_type content_get_type(struct hlcache_handle *h); - -/** - * Retrieve mime-type of content - * - * \param h handle to the content to retrieve mime type from - * \return Pointer to referenced mime type, or NULL if not found. - */ -lwc_string *content_get_mime_type(struct hlcache_handle *h); - -/** - * Retrieve title associated with content - * - * \param h handle to the content to retrieve title from - * \return Pointer to title, or NULL if not found. - */ -const char *content_get_title(struct hlcache_handle *h); /** * Retrieve status of content @@ -365,6 +308,7 @@ const char *content_get_title(struct hlcache_handle *h); */ content_status content_get_status(struct hlcache_handle *h); + /** * Retrieve status of content * @@ -373,6 +317,7 @@ content_status content_get_status(struct hlcache_handle *h); */ content_status content__get_status(struct content *c); + /** * Retrieve status message associated with content * @@ -381,21 +326,6 @@ content_status content__get_status(struct content *c); */ const char *content_get_status_message(struct hlcache_handle *h); -/** - * Retrieve width of content - * - * \param h handle to the content to get width of. - * \return Content width - */ -int content_get_width(struct hlcache_handle *h); - -/** - * Retrieve height of content - * - * \param h handle to the content to get height of. - * \return Content height - */ -int content_get_height(struct hlcache_handle *h); /** * Retrieve available width of content @@ -405,26 +335,6 @@ int content_get_height(struct hlcache_handle *h); */ int content_get_available_width(struct hlcache_handle *h); -/** - * Retrieve source of content - * - * \param h Content handle to retrieve source of - * \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); - -/** - * Invalidate content reuse data. - * - * causes subsequent requests for content URL to query server to - * determine if content can be reused. This is required behaviour for - * forced reloads etc. - * - * \param h Content handle to invalidate. - */ -void content_invalidate_reuse_data(struct hlcache_handle *h); /** * Retrieve the refresh URL for a content @@ -434,13 +344,6 @@ void content_invalidate_reuse_data(struct hlcache_handle *h); */ struct nsurl *content_get_refresh_url(struct hlcache_handle *h); -/** - * Retrieve the bitmap contained in an image content - * - * \param h handle to the content. - * \return Pointer to bitmap, or NULL if none. - */ -struct bitmap *content_get_bitmap(struct hlcache_handle *h); /** * Determine if a content is opaque from handle @@ -451,6 +354,7 @@ struct bitmap *content_get_bitmap(struct hlcache_handle *h); */ bool content_get_opaque(struct hlcache_handle *h); + /** * Retrieve quirkiness of a content * @@ -459,14 +363,6 @@ bool content_get_opaque(struct hlcache_handle *h); */ bool content_get_quirks(struct hlcache_handle *h); -/** - * Retrieve the encoding of a content - * - * \param h handle to the content. - * \param op encoding operation. - * \return Pointer to content info or NULL if none. - */ -const char *content_get_encoding(struct hlcache_handle *h, enum content_encoding_type op); /** * Return whether a content is currently locked @@ -476,4 +372,7 @@ const char *content_get_encoding(struct hlcache_handle *h, enum content_encoding */ bool content_is_locked(struct hlcache_handle *h); + + + #endif diff --git a/content/content_factory.h b/content/content_factory.h index 22205dc02..9beeb193c 100644 --- a/content/content_factory.h +++ b/content/content_factory.h @@ -23,7 +23,7 @@ #include -#include "content/content_type.h" +#include "netsurf/content_type.h" #include "utils/errors.h" #define CONTENT_FACTORY_REGISTER_TYPES(HNAME, HTYPELIST, HHANDLER) \ diff --git a/content/content_protected.h b/content/content_protected.h index fb810bd07..ef38cb12d 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -26,29 +26,22 @@ #ifndef _NETSURF_CONTENT_CONTENT_PROTECTED_H_ #define _NETSURF_CONTENT_CONTENT_PROTECTED_H_ -#include -#include #include -#include "utils/config.h" +#include "utils/nsurl.h" +#include "netsurf/content_type.h" #include "content/content.h" -#include "content/content_factory.h" -#include "content/llcache.h" -#include "utils/errors.h" - -struct bitmap; -struct content; -struct rect; -struct redraw_context; + +struct content_redraw_data; struct http_parameter; struct content_handler { void (*fini)(void); - nserror (*create)(const content_handler *handler, + nserror (*create)(const struct content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, - llcache_handle *llcache, + struct llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c); @@ -108,11 +101,11 @@ struct content_user /** Corresponds to a single URL. */ struct content { - llcache_handle *llcache; /**< Low-level cache object */ + struct llcache_handle *llcache; /**< Low-level cache object */ lwc_string *mime_type; /**< Original MIME type of data */ - const content_handler *handler; /**< Handler for content */ + const struct content_handler *handler; /**< Handler for content */ content_status status; /**< Current status. */ @@ -161,7 +154,7 @@ struct content { extern const char * const content_type_name[]; extern const char * const content_status_name[]; -nserror content__init(struct content *c, const content_handler *handler, +nserror content__init(struct content *c, const struct content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, struct llcache_handle *llcache, const char *fallback_charset, bool quirks); diff --git a/content/content_type.h b/content/content_type.h deleted file mode 100644 index 9f8c2f307..000000000 --- a/content/content_type.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2003 James Bursa - * - * 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 . - */ - -/** \file - * Declaration of content_type enum. - * - * The content_type enum is defined here to prevent cyclic dependencies. - */ - -#ifndef _NETSURF_DESKTOP_CONTENT_TYPE_H_ -#define _NETSURF_DESKTOP_CONTENT_TYPE_H_ - -/** The type of a content. */ -typedef enum { - CONTENT_NONE = 0x00, - - CONTENT_HTML = 0x01, - CONTENT_TEXTPLAIN = 0x02, - CONTENT_CSS = 0x04, - - /** All images */ - CONTENT_IMAGE = 0x08, - - /** Navigator API Plugins */ - CONTENT_PLUGIN = 0x10, - - /** Themes (only GTK and RISC OS) */ - CONTENT_THEME = 0x20, - - /** Javascript */ - CONTENT_JS = 0x40, - /** All script types. */ - CONTENT_SCRIPT = 0x40, - - /** Any content matches */ - CONTENT_ANY = 0x7f -} content_type; - - -#endif diff --git a/content/fetchers/about.c b/content/fetchers/about.c index 69ca0aed2..5fbdd225e 100644 --- a/content/fetchers/about.c +++ b/content/fetchers/about.c @@ -40,7 +40,6 @@ #include "content/fetch.h" #include "content/fetchers.h" #include "content/fetchers/about.h" -#include "content/content_type.h" #include "content/handlers/image/image_cache.h" diff --git a/content/handlers/image/bmp.c b/content/handlers/image/bmp.c index 114a551a6..8f787de37 100644 --- a/content/handlers/image/bmp.c +++ b/content/handlers/image/bmp.c @@ -28,10 +28,12 @@ #include "utils/utils.h" #include "utils/messages.h" -#include "content/content_protected.h" -#include "desktop/gui_internal.h" #include "netsurf/plotters.h" #include "netsurf/bitmap.h" +#include "netsurf/content.h" +#include "content/llcache.h" +#include "content/content_protected.h" +#include "desktop/gui_internal.h" #include "bmp.h" diff --git a/content/handlers/image/gif.c b/content/handlers/image/gif.c index 93970f96d..2a8ce3d20 100644 --- a/content/handlers/image/gif.c +++ b/content/handlers/image/gif.c @@ -39,10 +39,12 @@ #include "utils/utils.h" #include "utils/messages.h" #include "utils/nsoption.h" -#include "content/content_protected.h" #include "netsurf/misc.h" -#include "desktop/gui_internal.h" #include "netsurf/bitmap.h" +#include "netsurf/content.h" +#include "content/llcache.h" +#include "content/content_protected.h" +#include "desktop/gui_internal.h" #include "image.h" #include "gif.h" diff --git a/content/handlers/image/ico.c b/content/handlers/image/ico.c index 5ea29bfab..7b1e1271c 100644 --- a/content/handlers/image/ico.c +++ b/content/handlers/image/ico.c @@ -27,9 +27,11 @@ #include "utils/utils.h" #include "utils/log.h" #include "utils/messages.h" +#include "netsurf/bitmap.h" +#include "netsurf/content.h" +#include "content/llcache.h" #include "content/content_protected.h" #include "desktop/gui_internal.h" -#include "netsurf/bitmap.h" #include "image.h" #include "ico.h" diff --git a/content/handlers/image/image.c b/content/handlers/image/image.c index da5eea117..0b1ddc0e0 100644 --- a/content/handlers/image/image.c +++ b/content/handlers/image/image.c @@ -22,10 +22,10 @@ #include "utils/utils.h" #include "utils/log.h" #include "utils/messages.h" -#include "content/content.h" #include "netsurf/plotters.h" -#include "desktop/gui_internal.h" #include "netsurf/bitmap.h" +#include "netsurf/content.h" +#include "desktop/gui_internal.h" #include "bmp.h" #include "gif.h" diff --git a/content/handlers/image/image.h b/content/handlers/image/image.h index eb9482583..dac586c34 100644 --- a/content/handlers/image/image.h +++ b/content/handlers/image/image.h @@ -25,6 +25,8 @@ #include "utils/errors.h" +struct content_redraw_data; + /** Initialise the content handlers for image types. */ nserror image_init(void); diff --git a/content/handlers/image/image_cache.c b/content/handlers/image/image_cache.c index 4c008b7a9..dcb01dd87 100644 --- a/content/handlers/image/image_cache.c +++ b/content/handlers/image/image_cache.c @@ -25,10 +25,11 @@ #include "utils/utils.h" #include "utils/log.h" -#include "content/content_protected.h" #include "netsurf/misc.h" -#include "desktop/gui_internal.h" #include "netsurf/bitmap.h" +#include "content/llcache.h" +#include "content/content_protected.h" +#include "desktop/gui_internal.h" #include "image_cache.h" #include "image.h" diff --git a/content/handlers/image/image_cache.h b/content/handlers/image/image_cache.h index 2f1a5caee..d57a3a956 100644 --- a/content/handlers/image/image_cache.h +++ b/content/handlers/image/image_cache.h @@ -38,6 +38,7 @@ #define NETSURF_IMAGE_IMAGE_CACHE_H_ #include "utils/errors.h" +#include "netsurf/content_type.h" struct content_redraw_data; struct redraw_context; diff --git a/content/handlers/image/jpeg.c b/content/handlers/image/jpeg.c index 179b8fc5b..e3af00f9f 100644 --- a/content/handlers/image/jpeg.c +++ b/content/handlers/image/jpeg.c @@ -30,9 +30,10 @@ #include "utils/utils.h" #include "utils/log.h" #include "utils/messages.h" +#include "netsurf/bitmap.h" +#include "content/llcache.h" #include "content/content_protected.h" #include "desktop/gui_internal.h" -#include "netsurf/bitmap.h" #include "image_cache.h" diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index 8912f8356..9c4717fd6 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -28,10 +28,12 @@ #include "utils/utils.h" #include "utils/log.h" #include "utils/messages.h" -#include "content/content_protected.h" -#include "desktop/gui_internal.h" #include "netsurf/plotters.h" #include "netsurf/bitmap.h" +#include "netsurf/content.h" +#include "content/llcache.h" +#include "content/content_protected.h" +#include "desktop/gui_internal.h" #include "nssprite.h" @@ -62,7 +64,7 @@ typedef struct nssprite_content { static nserror nssprite_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, - llcache_handle *llcache, const char *fallback_charset, + struct llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { nssprite_content *sprite; diff --git a/content/handlers/image/png.c b/content/handlers/image/png.c index 04083d8a4..45f415a6b 100644 --- a/content/handlers/image/png.c +++ b/content/handlers/image/png.c @@ -25,9 +25,10 @@ #include "utils/utils.h" #include "utils/log.h" #include "utils/messages.h" +#include "netsurf/bitmap.h" +#include "content/llcache.h" #include "content/content_protected.h" #include "desktop/gui_internal.h" -#include "netsurf/bitmap.h" #include "image_cache.h" #include "png.h" @@ -277,10 +278,14 @@ static nserror nspng_create_png_data(nspng_content *png_c) return NSERROR_OK; } -static nserror nspng_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 +nspng_create(const content_handler *handler, + lwc_string *imime_type, + const struct http_parameter *params, + struct llcache_handle *llcache, + const char *fallback_charset, + bool quirks, + struct content **c) { nspng_content *png_c; nserror error; diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c index 82c85ac4c..b4532646c 100644 --- a/content/handlers/image/svg.c +++ b/content/handlers/image/svg.c @@ -29,8 +29,9 @@ #include "utils/messages.h" #include "utils/utils.h" -#include "content/content_protected.h" #include "netsurf/plotters.h" +#include "netsurf/content.h" +#include "content/content_protected.h" #include "svg.h" @@ -71,7 +72,7 @@ no_memory: static nserror svg_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, - llcache_handle *llcache, const char *fallback_charset, + struct llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { svg_content *svg; diff --git a/content/hlcache.c b/content/hlcache.c index 65210d5a8..042e1895e 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -30,9 +30,9 @@ #include "utils/ring.h" #include "utils/utils.h" #include "netsurf/misc.h" +#include "netsurf/content.h" #include "desktop/gui_internal.h" -#include "content/content.h" #include "content/mimesniff.h" #include "content/hlcache.h" diff --git a/content/hlcache.h b/content/hlcache.h index e0bf4161d..0dd102062 100644 --- a/content/hlcache.h +++ b/content/hlcache.h @@ -175,12 +175,5 @@ struct content *hlcache_handle_get_content(const hlcache_handle *handle); */ nserror hlcache_handle_clone(hlcache_handle *handle, hlcache_handle **result); -/** - * Retrieve the URL associated with a high level cache handle - * - * \param handle The handle to inspect - * \return Pointer to URL. - */ -nsurl *hlcache_handle_get_url(const hlcache_handle *handle); #endif diff --git a/content/urldb.h b/content/urldb.h index d7ca8b0f8..ddbac6a00 100644 --- a/content/urldb.h +++ b/content/urldb.h @@ -25,8 +25,9 @@ #include #include + #include "utils/nsurl.h" -#include "content/content_type.h" +#include "netsurf/content_type.h" typedef enum { COOKIE_NETSCAPE = 0, -- cgit v1.2.3