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;
|
2006-02-16 02:09:55 +03:00
|
|
|
struct rect;
|
2003-09-08 01:08:13 +04:00
|
|
|
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;
|
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
struct frame_dimension {
|
|
|
|
float value;
|
|
|
|
enum {
|
|
|
|
FRAME_DIMENSION_PIXELS, /* '100', '200' */
|
|
|
|
FRAME_DIMENSION_PERCENT, /* '5%', '20%' */
|
|
|
|
FRAME_DIMENSION_RELATIVE /* '*', '2*' */
|
|
|
|
} unit;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SCROLLING_AUTO,
|
|
|
|
SCROLLING_YES,
|
|
|
|
SCROLLING_NO
|
|
|
|
} frame_scrolling;
|
|
|
|
|
|
|
|
|
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. */
|
2006-09-02 19:52:41 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Frame tree (<frameset>, <frame>) */
|
|
|
|
struct content_html_frames {
|
|
|
|
int cols; /** number of columns in frameset */
|
|
|
|
int rows; /** number of rows in frameset */
|
|
|
|
|
|
|
|
struct frame_dimension width; /** frame width */
|
|
|
|
struct frame_dimension height; /** frame width */
|
|
|
|
int margin_width; /** frame margin width */
|
|
|
|
int margin_height; /** frame margin height */
|
|
|
|
|
|
|
|
char *name; /** frame name (for targetting) */
|
|
|
|
char *url; /** frame url */
|
|
|
|
|
|
|
|
bool no_resize; /** frame is not resizable */
|
|
|
|
frame_scrolling scrolling; /** scrolling characteristics */
|
|
|
|
bool border; /** frame has a border */
|
|
|
|
colour border_colour; /** frame border colour */
|
|
|
|
|
|
|
|
struct content_html_frames *children; /** [cols * rows] children */
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Inline frame list (<iframe>) */
|
|
|
|
struct content_html_iframe {
|
|
|
|
struct box *box;
|
|
|
|
|
|
|
|
int margin_width; /** frame margin width */
|
|
|
|
int margin_height; /** frame margin height */
|
|
|
|
|
|
|
|
char *name; /** frame name (for targetting) */
|
|
|
|
char *url; /** frame url */
|
|
|
|
|
|
|
|
frame_scrolling scrolling; /** scrolling characteristics */
|
|
|
|
bool border; /** frame has a border */
|
|
|
|
colour border_colour; /** frame border colour */
|
|
|
|
|
|
|
|
struct content_html_iframe *next;
|
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). */
|
2006-09-02 19:52:41 +04:00
|
|
|
char *base_target; /**< Base target */
|
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
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** Frameset information */
|
|
|
|
struct content_html_frames *frameset;
|
|
|
|
|
|
|
|
/** Inline frame information */
|
|
|
|
struct content_html_iframe *iframe;
|
|
|
|
|
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,
|
2006-09-02 19:52:41 +04:00
|
|
|
bool background);
|
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);
|
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
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
|
|
|
|
/* redraw a short text string, complete with highlighting
|
|
|
|
(for selection/search) and ghost caret */
|
|
|
|
|
|
|
|
bool text_redraw(const char *utf8_text, size_t utf8_len,
|
|
|
|
size_t offset, bool space,
|
|
|
|
struct css_style *style,
|
|
|
|
int x, int y,
|
|
|
|
struct rect *clip,
|
|
|
|
int height,
|
|
|
|
float scale, colour current_background_color,
|
|
|
|
bool excluded);
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
#endif
|