2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
|
|
|
* Copyright 2003 Philip Pemberton <philpem@users.sourceforge.net>
|
2003-02-09 15:58:15 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_DESKTOP_CONTENT_H_
|
|
|
|
#define _NETSURF_DESKTOP_CONTENT_H_
|
|
|
|
|
|
|
|
#include "libxml/HTMLparser.h"
|
2003-06-17 23:24:21 +04:00
|
|
|
#ifdef riscos
|
2003-05-10 15:15:49 +04:00
|
|
|
#include "libpng/png.h"
|
2003-06-05 17:17:55 +04:00
|
|
|
#include "libungif/gif_lib.h"
|
2003-05-10 15:15:49 +04:00
|
|
|
#include "oslib/osspriteop.h"
|
2003-06-17 23:24:21 +04:00
|
|
|
#endif
|
2003-02-09 15:58:15 +03:00
|
|
|
#include "netsurf/content/cache.h"
|
2003-06-17 23:24:21 +04:00
|
|
|
#include "netsurf/content/fetch.h"
|
2003-04-04 19:19:32 +04:00
|
|
|
#include "netsurf/css/css.h"
|
2003-02-09 15:58:15 +03:00
|
|
|
#include "netsurf/render/box.h"
|
2003-06-17 23:24:21 +04:00
|
|
|
#ifdef riscos
|
2003-02-09 15:58:15 +03:00
|
|
|
#include "netsurf/riscos/font.h"
|
2003-06-17 23:24:21 +04:00
|
|
|
#endif
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A struct content corresponds to a single url.
|
|
|
|
*
|
|
|
|
* It is in one of the following states:
|
|
|
|
* CONTENT_FETCHING - the data is being fetched and/or converted
|
|
|
|
* for use by the browser
|
|
|
|
* CONTENT_READY - the content has been processed and is ready
|
|
|
|
* to display
|
|
|
|
*
|
|
|
|
* The converted data is stored in the cache, not the source data.
|
|
|
|
* Users of the structure are counted in use_count; when use_count = 0
|
|
|
|
* the content may be removed from the memory cache.
|
|
|
|
*/
|
|
|
|
|
2003-04-10 01:57:09 +04:00
|
|
|
typedef enum {
|
|
|
|
CONTENT_HTML,
|
|
|
|
CONTENT_TEXTPLAIN,
|
2003-06-17 23:24:21 +04:00
|
|
|
#ifdef riscos
|
2003-04-10 01:57:09 +04:00
|
|
|
CONTENT_JPEG,
|
2003-06-17 23:24:21 +04:00
|
|
|
#endif
|
2003-04-10 01:57:09 +04:00
|
|
|
CONTENT_CSS,
|
2003-06-17 23:24:21 +04:00
|
|
|
#ifdef riscos
|
2003-04-10 01:57:09 +04:00
|
|
|
CONTENT_PNG,
|
2003-06-05 17:17:55 +04:00
|
|
|
CONTENT_GIF,
|
2003-07-08 02:10:51 +04:00
|
|
|
CONTENT_PLUGIN,
|
2003-06-17 23:24:21 +04:00
|
|
|
#endif
|
|
|
|
CONTENT_OTHER,
|
|
|
|
CONTENT_UNKNOWN /* content-type not received yet */
|
2003-04-10 01:57:09 +04:00
|
|
|
} content_type;
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
struct box_position
|
|
|
|
{
|
|
|
|
struct box* box;
|
|
|
|
int actual_box_x;
|
|
|
|
int actual_box_y;
|
|
|
|
int plot_index;
|
|
|
|
int pixel_offset;
|
|
|
|
int char_offset;
|
|
|
|
};
|
|
|
|
|
2003-06-17 23:24:21 +04:00
|
|
|
typedef enum {
|
|
|
|
CONTENT_MSG_LOADING, /* fetching or converting */
|
|
|
|
CONTENT_MSG_READY, /* may be displayed */
|
|
|
|
CONTENT_MSG_DONE, /* finished */
|
|
|
|
CONTENT_MSG_ERROR, /* error occurred */
|
2003-06-26 15:41:26 +04:00
|
|
|
CONTENT_MSG_STATUS, /* new status string */
|
|
|
|
CONTENT_MSG_REDIRECT /* replacement URL */
|
2003-06-17 23:24:21 +04:00
|
|
|
} content_msg;
|
|
|
|
|
|
|
|
struct content_user
|
|
|
|
{
|
|
|
|
void (*callback)(content_msg msg, struct content *c, void *p1,
|
|
|
|
void *p2, const char *error);
|
|
|
|
void *p1;
|
|
|
|
void *p2;
|
|
|
|
struct content_user *next;
|
|
|
|
};
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
struct content
|
|
|
|
{
|
|
|
|
char *url;
|
|
|
|
content_type type;
|
2003-07-08 02:10:51 +04:00
|
|
|
char *mime_type;
|
2003-04-15 21:53:00 +04:00
|
|
|
enum {
|
2003-06-17 23:24:21 +04:00
|
|
|
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 */
|
2003-04-15 21:53:00 +04:00
|
|
|
} status;
|
2003-02-26 00:00:27 +03:00
|
|
|
unsigned long width, height;
|
2003-04-15 21:53:00 +04:00
|
|
|
unsigned long available_width;
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
htmlParserCtxt* parser;
|
|
|
|
struct box* layout;
|
2003-04-06 01:38:06 +04:00
|
|
|
unsigned int stylesheet_count;
|
|
|
|
struct content **stylesheet_content;
|
2003-02-09 15:58:15 +03:00
|
|
|
struct css_style* style;
|
|
|
|
struct {
|
|
|
|
struct box_position start;
|
|
|
|
struct box_position end;
|
|
|
|
enum {alter_UNKNOWN, alter_START, alter_END} altering;
|
|
|
|
int selected; /* 0 = unselected, 1 = selected */
|
|
|
|
} text_selection;
|
|
|
|
struct font_set* fonts;
|
|
|
|
struct page_elements elements;
|
2003-04-15 21:53:00 +04:00
|
|
|
unsigned int object_count; /* images etc. */
|
|
|
|
struct {
|
|
|
|
char *url;
|
|
|
|
struct content *content;
|
|
|
|
struct box *box;
|
|
|
|
} *object;
|
2003-02-09 15:58:15 +03:00
|
|
|
} html;
|
|
|
|
|
2003-04-06 22:09:34 +04:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct css_stylesheet *css;
|
|
|
|
unsigned int import_count;
|
2003-04-10 01:57:09 +04:00
|
|
|
char **import_url;
|
2003-04-06 22:09:34 +04:00
|
|
|
struct content **import_content;
|
|
|
|
} css;
|
2003-06-17 23:24:21 +04:00
|
|
|
#ifdef riscos
|
2003-02-09 15:58:15 +03:00
|
|
|
struct
|
|
|
|
{
|
2003-02-26 00:00:27 +03:00
|
|
|
char * data;
|
|
|
|
unsigned long length;
|
|
|
|
} jpeg;
|
2003-04-04 19:19:32 +04:00
|
|
|
|
2003-05-10 15:15:49 +04:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
png_structp png;
|
|
|
|
png_infop info;
|
|
|
|
unsigned long rowbytes;
|
2003-06-30 19:57:08 +04:00
|
|
|
int interlace;
|
2003-05-10 15:15:49 +04:00
|
|
|
osspriteop_area *sprite_area;
|
|
|
|
char *sprite_image;
|
|
|
|
enum { PNG_PALETTE, PNG_DITHER, PNG_DEEP } type;
|
|
|
|
} png;
|
|
|
|
|
2003-06-05 17:17:55 +04:00
|
|
|
// Structure for the GIF handler
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
GifFileType *giffile; // GIF file handler
|
|
|
|
char *data; // GIF data
|
|
|
|
unsigned long length; // Length of GIF data
|
|
|
|
unsigned long buffer_pos; // Position in the buffer
|
|
|
|
osspriteop_area *sprite_area; // Sprite area
|
|
|
|
char *sprite_image; // Sprite image
|
|
|
|
} gif;
|
2003-07-08 02:10:51 +04:00
|
|
|
|
|
|
|
/* Structure for plugin */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char *data; /* object data */
|
|
|
|
unsigned long length; /* object length */
|
|
|
|
char* sysvar; /* system variable set by plugin */
|
|
|
|
} plugin;
|
2003-06-17 23:24:21 +04:00
|
|
|
#endif
|
|
|
|
/* downloads */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char *data;
|
|
|
|
unsigned long length;
|
|
|
|
} other;
|
2003-06-05 17:17:55 +04:00
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
} data;
|
|
|
|
|
|
|
|
struct cache_entry *cache;
|
|
|
|
unsigned long size;
|
|
|
|
char *title;
|
2003-04-04 19:19:32 +04:00
|
|
|
unsigned int active;
|
|
|
|
int error;
|
2003-06-17 23:24:21 +04:00
|
|
|
struct content_user *user_list;
|
2003-04-15 21:53:00 +04:00
|
|
|
char status_message[80];
|
2003-06-17 23:24:21 +04:00
|
|
|
struct fetch *fetch;
|
|
|
|
unsigned long fetch_size;
|
2003-02-09 15:58:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-07-15 02:57:45 +04:00
|
|
|
struct browser_window;
|
|
|
|
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
content_type content_lookup(const char *mime_type);
|
2003-06-17 23:24:21 +04:00
|
|
|
struct content * content_create(char *url);
|
2003-07-08 02:10:51 +04:00
|
|
|
void content_set_type(struct content *c, content_type type, char *mime_type);
|
2003-02-09 15:58:15 +03:00
|
|
|
void content_process_data(struct content *c, char *data, unsigned long size);
|
2003-06-17 23:24:21 +04:00
|
|
|
void content_convert(struct content *c, unsigned long width, unsigned long height);
|
2003-02-09 15:58:15 +03:00
|
|
|
void content_revive(struct content *c, unsigned long width, unsigned long height);
|
|
|
|
void content_reformat(struct content *c, unsigned long width, unsigned long height);
|
|
|
|
void content_destroy(struct content *c);
|
2003-05-10 15:15:49 +04:00
|
|
|
void content_redraw(struct content *c, long x, long y,
|
|
|
|
unsigned long width, unsigned long height);
|
2003-06-17 23:24:21 +04:00
|
|
|
void content_add_user(struct content *c,
|
|
|
|
void (*callback)(content_msg msg, struct content *c, void *p1,
|
|
|
|
void *p2, const char *error),
|
2003-07-15 02:57:45 +04:00
|
|
|
void *p1, void *p2);
|
2003-06-17 23:24:21 +04:00
|
|
|
void content_remove_user(struct content *c,
|
|
|
|
void (*callback)(content_msg msg, struct content *c, void *p1,
|
|
|
|
void *p2, const char *error),
|
2003-07-15 02:57:45 +04:00
|
|
|
void *p1, void *p2);
|
2003-06-17 23:24:21 +04:00
|
|
|
void content_broadcast(struct content *c, content_msg msg, char *error);
|
2003-07-15 02:57:45 +04:00
|
|
|
void content_add_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state);
|
|
|
|
void content_remove_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state);
|
|
|
|
void content_reshape_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state);
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
#endif
|