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
|
2004-02-15 23:39:53 +03:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2003-02-09 15:58:15 +03:00
|
|
|
*/
|
|
|
|
|
2004-02-20 03:43:17 +03:00
|
|
|
/** \file
|
|
|
|
* Content for text/html (interface).
|
|
|
|
*
|
|
|
|
* These functions should in general be called via the content interface.
|
|
|
|
*/
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
#ifndef _NETSURF_RENDER_HTML_H_
|
|
|
|
#define _NETSURF_RENDER_HTML_H_
|
|
|
|
|
2004-06-09 23:55:06 +04:00
|
|
|
#include <stdbool.h>
|
2004-02-20 03:43:17 +03:00
|
|
|
#include "libxml/HTMLparser.h"
|
2004-01-24 20:08:16 +03:00
|
|
|
#include "netsurf/content/content_type.h"
|
2003-09-08 01:08:13 +04:00
|
|
|
#include "netsurf/css/css.h"
|
|
|
|
|
|
|
|
struct box;
|
|
|
|
struct browser_window;
|
|
|
|
struct content;
|
2005-10-31 00:23:03 +03:00
|
|
|
struct form_successful_control;
|
2004-03-27 01:16:31 +03:00
|
|
|
struct imagemap;
|
2004-10-18 01:10:19 +04:00
|
|
|
struct object_params;
|
|
|
|
struct plotters;
|
2003-09-08 01:08:13 +04:00
|
|
|
|
2004-07-31 03:40:01 +04:00
|
|
|
/* entries in stylesheet_content */
|
|
|
|
#define STYLESHEET_BASE 0 /* base style sheet */
|
|
|
|
#define STYLESHEET_ADBLOCK 1 /* adblocking stylesheet */
|
|
|
|
#define STYLESHEET_STYLE 2 /* <style> elements (not cached) */
|
|
|
|
#define STYLESHEET_START 3 /* start of document stylesheets */
|
|
|
|
|
2004-10-18 02:13:35 +04:00
|
|
|
extern char *default_stylesheet_url;
|
|
|
|
extern char *adblock_stylesheet_url;
|
|
|
|
|
2005-01-02 01:05:21 +03:00
|
|
|
/** An object (<img>, <object>, etc.) in a CONTENT_HTML document. */
|
|
|
|
struct content_html_object {
|
|
|
|
char *url; /**< URL of this object. */
|
|
|
|
struct content *content; /**< Content, or 0. */
|
|
|
|
struct box *box; /**< Node in box tree containing it. */
|
|
|
|
/** Pointer to array of permitted content_type, terminated by
|
|
|
|
* CONTENT_UNKNOWN, or 0 if any type is acceptable. */
|
|
|
|
const content_type *permitted_types;
|
2005-08-21 02:52:20 +04:00
|
|
|
bool background; /**< This object is a background image. */
|
|
|
|
char *frame; /**< Name of frame, or 0 if not a frame. */
|
2005-01-02 01:05:21 +03:00
|
|
|
};
|
|
|
|
|
2004-02-20 03:43:17 +03:00
|
|
|
/** Data specific to CONTENT_HTML. */
|
2003-09-08 01:08:13 +04:00
|
|
|
struct content_html_data {
|
2004-02-20 03:43:17 +03:00
|
|
|
htmlParserCtxt *parser; /**< HTML parser context. */
|
2005-01-02 01:05:21 +03:00
|
|
|
/** HTML parser encoding handler. */
|
|
|
|
xmlCharEncodingHandler *encoding_handler;
|
2004-02-20 03:43:17 +03:00
|
|
|
|
2005-01-02 01:05:21 +03:00
|
|
|
char *encoding; /**< Encoding of source, 0 if unknown. */
|
|
|
|
enum { ENCODING_SOURCE_HEADER, ENCODING_SOURCE_DETECTED,
|
|
|
|
ENCODING_SOURCE_META } encoding_source;
|
|
|
|
/**< Source of encoding information. */
|
2004-07-18 21:38:01 +04:00
|
|
|
bool getenc; /**< Need to get the encoding from the document, as it
|
|
|
|
* wasn't specified in the Content-Type header. */
|
2004-02-20 03:43:17 +03:00
|
|
|
|
2003-12-26 03:17:55 +03:00
|
|
|
char *base_url; /**< Base URL (may be a copy of content->url). */
|
2004-02-20 03:43:17 +03:00
|
|
|
|
|
|
|
struct box *layout; /**< Box tree, or 0. */
|
|
|
|
colour background_colour; /**< Document background colour. */
|
|
|
|
|
|
|
|
/** Number of entries in stylesheet_content. */
|
2003-09-08 01:08:13 +04:00
|
|
|
unsigned int stylesheet_count;
|
2004-07-31 03:40:01 +04:00
|
|
|
/** Stylesheets. Each may be 0. */
|
2003-09-08 01:08:13 +04:00
|
|
|
struct content **stylesheet_content;
|
2004-02-20 03:43:17 +03:00
|
|
|
struct css_style *style; /**< Base style. */
|
2005-05-22 03:30:19 +04:00
|
|
|
/** Working stylesheet. */
|
|
|
|
struct css_working_stylesheet *working_stylesheet;
|
2004-02-20 03:43:17 +03:00
|
|
|
|
|
|
|
/** Number of entries in object. */
|
|
|
|
unsigned int object_count;
|
|
|
|
/** Objects. Each may be 0. */
|
2005-01-02 01:05:21 +03:00
|
|
|
struct content_html_object *object;
|
2005-04-09 13:47:37 +04:00
|
|
|
/** Forms, in reverse order to document. */
|
|
|
|
struct form *forms;
|
2005-08-21 02:52:20 +04:00
|
|
|
/** Hash table of imagemaps. */
|
2005-04-09 13:47:37 +04:00
|
|
|
struct imagemap **imagemaps;
|
2004-08-12 02:08:26 +04:00
|
|
|
|
2005-08-21 02:52:20 +04:00
|
|
|
/** Browser window containing this document, or 0 if not open. */
|
2004-08-12 02:08:26 +04:00
|
|
|
struct browser_window *bw;
|
2005-10-31 00:23:03 +03:00
|
|
|
|
|
|
|
/** Content of type CONTENT_HTML containing this, or 0 if not an object
|
|
|
|
* within a page. */
|
|
|
|
struct content *page;
|
|
|
|
/** Index in page->data.html.object, or 0 if not an object. */
|
|
|
|
unsigned int index;
|
|
|
|
/** Box containing this, or 0 if not an object. */
|
|
|
|
struct box *box;
|
2003-09-08 01:08:13 +04:00
|
|
|
};
|
2003-02-09 15:58:15 +03:00
|
|
|
|
2004-10-18 01:10:19 +04:00
|
|
|
/** Render padding and margin box outlines in html_redraw(). */
|
|
|
|
extern bool html_redraw_debug;
|
|
|
|
|
2004-02-20 03:43:17 +03:00
|
|
|
|
2004-06-11 00:41:26 +04:00
|
|
|
bool html_create(struct content *c, const char *params[]);
|
|
|
|
bool html_process_data(struct content *c, char *data, unsigned int size);
|
|
|
|
bool html_convert(struct content *c, int width, int height);
|
|
|
|
void html_reformat(struct content *c, int width, int height);
|
2003-02-09 15:58:15 +03:00
|
|
|
void html_destroy(struct content *c);
|
2005-01-02 01:05:21 +03:00
|
|
|
bool html_fetch_object(struct content *c, char *url, struct box *box,
|
2004-05-21 18:26:59 +04:00
|
|
|
const content_type *permitted_types,
|
2004-06-10 03:13:55 +04:00
|
|
|
int available_width, int available_height,
|
2005-08-21 02:52:20 +04:00
|
|
|
bool background, char *frame);
|
2005-10-31 00:23:03 +03:00
|
|
|
bool html_replace_object(struct content *c, unsigned int i, char *url,
|
|
|
|
char *post_urlenc,
|
|
|
|
struct form_successful_control *post_multipart);
|
2004-06-21 03:09:52 +04:00
|
|
|
void html_stop(struct content *c);
|
2004-08-12 02:08:26 +04:00
|
|
|
void html_open(struct content *c, struct browser_window *bw,
|
2005-10-31 00:23:03 +03:00
|
|
|
struct content *page, unsigned int index, struct box *box,
|
2004-08-12 02:08:26 +04:00
|
|
|
struct object_params *params);
|
|
|
|
void html_close(struct content *c);
|
2005-10-31 00:23:03 +03:00
|
|
|
void html_find_target(struct content *c, const char *target,
|
|
|
|
struct content **page, unsigned int *i);
|
2003-11-13 01:22:45 +03:00
|
|
|
|
2004-10-18 01:10:19 +04:00
|
|
|
/* in render/html_redraw.c */
|
2004-08-11 20:26:13 +04:00
|
|
|
bool html_redraw(struct content *c, int x, int y,
|
2004-06-11 00:41:26 +04:00
|
|
|
int width, int height,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2004-08-15 23:06:24 +04:00
|
|
|
float scale, unsigned long background_colour);
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
#endif
|