From 270ef59a98d34fef418fb6cd27e46f3edc912948 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 28 Mar 2010 12:56:39 +0000 Subject: Merge jmb/new-cache; r=dsilvers,rs=vince svn path=/trunk/netsurf/; revision=10180 --- content/content.h | 295 +++++++++++------------------------------------------- 1 file changed, 61 insertions(+), 234 deletions(-) (limited to 'content/content.h') diff --git a/content/content.h b/content/content.h index db35b39a2..1dd7f83cd 100644 --- a/content/content.h +++ b/content/content.h @@ -26,64 +26,31 @@ #ifndef _NETSURF_CONTENT_CONTENT_H_ #define _NETSURF_CONTENT_CONTENT_H_ -/* Irritatingly this must come first, or odd include errors - * will occur to do with setjmp.h. - */ -#ifdef WITH_PNG -#include "image/png.h" -#endif +#include -#include -#include #include "utils/config.h" #include "content/content_type.h" -#include "css/css.h" -#include "render/html.h" -#include "render/textplain.h" -#ifdef WITH_JPEG -#include "image/jpeg.h" -#endif -#ifdef WITH_GIF -#include "image/gif.h" -#endif -#ifdef WITH_BMP -#include "image/bmp.h" -#include "image/ico.h" -#endif -#ifdef WITH_PLUGIN -#include "riscos/plugin.h" -#endif -#ifdef WITH_MNG -#include "image/mng.h" -#endif -#ifdef WITH_SPRITE -#include "riscos/sprite.h" -#endif -#ifdef WITH_NSSPRITE -#include "image/nssprite.h" -#endif -#ifdef WITH_DRAW -#include "riscos/draw.h" -#endif -#ifdef WITH_ARTWORKS -#include "riscos/artworks.h" -#endif -#ifdef WITH_NS_SVG -#include "image/svg.h" -#endif -#ifdef WITH_RSVG -#include "image/rsvg.h" -#endif +#include "desktop/plot_style.h" +struct llcache_handle; -struct bitmap; struct box; struct browser_window; struct content; -struct fetch; +struct hlcache_handle; struct object_params; -struct ssl_cert_info; +/** Status of a content */ +typedef enum { + CONTENT_STATUS_TYPE_UNKNOWN, /**< Type not yet known. */ + 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 { @@ -129,204 +96,64 @@ union content_msg_data { } ssl; }; -struct cache_data { - time_t req_time; /**< Time of request */ - time_t res_time; /**< Time of response */ - time_t date; /**< Date: response header */ - time_t expires; /**< Expires: response header */ -#define INVALID_AGE -1 - int age; /**< Age: response header */ - int max_age; /**< Max-age Cache-control parameter */ - bool no_cache; /**< no-cache Cache-control parameter */ - char *etag; /**< Etag: response header */ - time_t last_modified; /**< Last-Modified: response header */ -}; - -/** Linked list of users of a content. */ -struct content_user -{ - void (*callback)(content_msg msg, struct content *c, intptr_t p1, - intptr_t p2, union content_msg_data data); - intptr_t p1; - intptr_t p2; - bool stop; - struct content_user *next; -}; - -/** Corresponds to a single URL. */ -struct content { - char *url; /**< URL, in standard form as from url_join. */ - content_type type; /**< Type of content. */ - char *mime_type; /**< Original MIME type of data, or 0. */ - enum { - CONTENT_STATUS_TYPE_UNKNOWN, /**< Type not yet known. */ - 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. */ - } status; /**< Current status. */ - - int width, height; /**< Dimensions, if applicable. */ - int available_width; /**< Available width (eg window width). */ - - /** Data dependent on type. */ - union { - struct content_html_data html; - struct content_textplain_data textplain; - struct content_css_data css; -#ifdef WITH_JPEG - struct content_jpeg_data jpeg; -#endif -#ifdef WITH_GIF - struct content_gif_data gif; -#endif -#ifdef WITH_BMP - struct content_bmp_data bmp; - struct content_ico_data ico; -#endif -#ifdef WITH_MNG - struct content_mng_data mng; -#endif -#ifdef WITH_SPRITE - struct content_sprite_data sprite; -#endif -#ifdef WITH_NSSPRITE - struct content_nssprite_data nssprite; -#endif -#ifdef WITH_DRAW - struct content_draw_data draw; -#endif -#ifdef WITH_PLUGIN - struct content_plugin_data plugin; -#endif -#ifdef WITH_ARTWORKS - struct content_artworks_data artworks; -#endif -#ifdef WITH_NS_SVG - struct content_svg_data svg; -#endif -#ifdef WITH_RSVG - struct content_rsvg_data rsvg; -#endif -#ifdef WITH_PNG - struct content_png_data png; -#endif - } data; - - /**< URL for refresh request, in standard form as from url_join. */ - char *refresh; - - /** Bitmap, for various image contents. */ - struct bitmap *bitmap; - - /** This content may be given to new users. Indicates that the content - * was fetched using a simple GET, has not expired, and may be - * shared between users. */ - bool fresh; - struct cache_data cache_data; /**< Cache control data */ - unsigned int time; /**< Creation time, if TYPE_UNKNOWN, - LOADING or READY, - otherwise total time. */ - - unsigned int reformat_time; /**< Earliest time to attempt a - period reflow while fetching a - page's objects. */ - - unsigned int size; /**< Estimated size of all data - associated with this content, except - alloced as talloc children of this. */ - off_t talloc_size; /**< Used by content_clean() */ - char *title; /**< Title for browser window. */ - unsigned int active; /**< Number of child fetches or - conversions currently in progress. */ - struct content_user *user_list; /**< List of users. */ - char status_message[120]; /**< Full text for status bar. */ - char sub_status[80]; /**< Status of content. */ - /** Content is being processed: data structures may be inconsistent - * and content must not be redrawn or modified. */ - bool locked; - - struct fetch *fetch; /**< Associated fetch, or 0. */ - char *source_data; /**< Source data, as received. */ - unsigned long source_size; /**< Amount of data fetched so far. */ - unsigned long source_allocated; /**< Amount of space allocated so far. */ - unsigned long total_size; /**< Total data size, 0 if unknown. */ - long http_code; /**< HTTP status code, 0 if not HTTP. */ - - bool no_error_pages; /**< Used by fetchcache(). */ - bool download; /**< Used by fetchcache(). */ - bool tried_with_auth; /**< Used by fetchcache(). */ - unsigned int redirect_count; /**< Used by fetchcache(). */ - - /** Array of first n rendering errors or warnings. */ - struct { - const char *token; - unsigned int line; /**< Line no, 0 if not applicable. */ - } error_list[40]; - unsigned int error_count; /**< Number of valid error entries. */ - - struct content *prev; /**< Previous in global content list. */ - struct content *next; /**< Next in global content list. */ -}; +/* The following are for hlcache */ +content_type content_lookup(const char *mime_type); +struct content *content_create(struct llcache_handle *llcache, + const char *fallback_charset, bool quirks); +void content_destroy(struct content *c); + +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); -extern struct content *content_list; -extern const char * const content_type_name[]; -extern const char * const content_status_name[]; +const struct llcache_handle *content_get_llcache_handle(struct content *c); -content_type content_lookup(const char *mime_type); -struct content * content_create(const char *url); -struct content * content_get(const char *url); -struct content * content_get_ready(const char *url); -bool content_can_reformat(struct content *c); -bool content_set_type(struct content *c, content_type type, - const char *mime_type, const char *params[], - struct content *parent); -void content_set_status(struct content *c, const char *status_message, ...); -bool content_process_data(struct content *c, const char *data, - unsigned int size); -void content_convert(struct content *c, int width, int height); -void content_set_done(struct content *c); -void content_reformat(struct content *c, int width, int height); -void content_clean(void); -void content_reset(struct content *c); -void content_quit(void); -bool content_redraw(struct content *c, int x, int y, +/* Client functions */ +bool content_can_reformat(struct hlcache_handle *h); +void content_reformat(struct hlcache_handle *h, int width, int height); +void content_request_redraw(struct hlcache_handle *h, + int x, int y, int width, int height); +bool content_redraw(struct hlcache_handle *h, int x, int y, int width, int height, int clip_x0, int clip_y0, int clip_x1, int clip_y1, float scale, colour background_colour); -bool content_redraw_tiled(struct content *c, int x, int y, +bool content_redraw_tiled(struct hlcache_handle *h, int x, int y, int width, int height, int clip_x0, int clip_y0, int clip_x1, int clip_y1, float scale, colour background_colour, bool repeat_x, bool repeat_y); -bool content_add_user(struct content *c, - void (*callback)(content_msg msg, struct content *c, - intptr_t p1, intptr_t p2, union content_msg_data data), - intptr_t p1, intptr_t p2); -struct content_user * content_find_user(struct content *c, - void (*callback)(content_msg msg, struct content *c, - intptr_t p1, intptr_t p2, union content_msg_data data), - intptr_t p1, intptr_t p2); -void content_remove_user(struct content *c, - void (*callback)(content_msg msg, struct content *c, - intptr_t p1, intptr_t p2, union content_msg_data data), - intptr_t p1, intptr_t p2); -void content_broadcast(struct content *c, content_msg msg, - union content_msg_data data); -void content_stop(struct content *c, - void (*callback)(content_msg msg, struct content *c, - intptr_t p1, intptr_t p2, union content_msg_data data), - intptr_t p1, intptr_t p2); -void content_open(struct content *c, struct browser_window *bw, +void content_stop(struct hlcache_handle *h, + void (*callback)(struct content *c, content_msg msg, + union content_msg_data data, void *pw), + void *pw); +void content_open(struct hlcache_handle *h, struct browser_window *bw, struct content *page, unsigned int index, struct box *box, struct object_params *params); -void content_close(struct content *c); -void content_add_error(struct content *c, const char *token, - unsigned int line); +void content_close(struct hlcache_handle *h); + +/* Member accessors */ +content_type content_get_type(struct hlcache_handle *c); +const char *content_get_url(struct hlcache_handle *c); +const char *content_get_title(struct hlcache_handle *c); +content_status content_get_status(struct hlcache_handle *c); +const char *content_get_status_message(struct hlcache_handle *c); +int content_get_width(struct hlcache_handle *c); +int content_get_height(struct hlcache_handle *c); +int content_get_available_width(struct hlcache_handle *c); +const char *content_get_source_data(struct hlcache_handle *c, + unsigned long *size); +void content_invalidate_reuse_data(struct hlcache_handle *c); +const char *content_get_refresh_url(struct hlcache_handle *c); +struct bitmap *content_get_bitmap(struct hlcache_handle *c); + +/* Download support */ +struct llcache_handle *content_convert_to_download(struct hlcache_handle *c); #endif -- cgit v1.2.3