2005-09-15 09:58:31 -04:00
|
|
|
#ifndef EL__DOCUMENT_DOCUMENT_H
|
|
|
|
#define EL__DOCUMENT_DOCUMENT_H
|
|
|
|
|
|
|
|
#include "document/options.h"
|
|
|
|
#include "intl/charsets.h" /* unicode_val_T */
|
|
|
|
#include "main/object.h"
|
2006-10-24 10:47:41 -04:00
|
|
|
#include "main/timer.h"
|
2005-09-15 09:58:31 -04:00
|
|
|
#include "protocol/uri.h"
|
|
|
|
#include "util/color.h"
|
|
|
|
#include "util/lists.h"
|
|
|
|
#include "util/box.h"
|
|
|
|
|
2020-10-05 14:14:55 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
struct cache_entry;
|
|
|
|
struct document_refresh;
|
2018-09-09 13:18:53 -04:00
|
|
|
struct el_form_control;
|
2005-09-15 09:58:31 -04:00
|
|
|
struct frame_desc;
|
|
|
|
struct frameset_desc;
|
|
|
|
struct module;
|
|
|
|
struct screen_char;
|
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** Nodes are used for marking areas of text on the document canvas as
|
2005-09-15 09:58:31 -04:00
|
|
|
* searchable. */
|
|
|
|
struct node {
|
|
|
|
LIST_HEAD(struct node);
|
|
|
|
|
2018-09-09 13:14:56 -04:00
|
|
|
struct el_box box;
|
2005-09-15 09:58:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** The document line consisting of the chars ready to be copied to
|
|
|
|
* the terminal screen. */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct line {
|
|
|
|
struct screen_char *chars;
|
|
|
|
int length;
|
|
|
|
};
|
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** Codepage status */
|
2005-09-15 09:58:31 -04:00
|
|
|
enum cp_status {
|
|
|
|
CP_STATUS_NONE,
|
|
|
|
CP_STATUS_SERVER,
|
|
|
|
CP_STATUS_ASSUMED,
|
|
|
|
CP_STATUS_IGNORED
|
|
|
|
};
|
|
|
|
|
2020-08-01 17:25:21 -04:00
|
|
|
/** Clipboard state */
|
|
|
|
enum clipboard_status {
|
|
|
|
CLIPBOARD_NONE,
|
|
|
|
CLIPBOARD_FIRST_POINT,
|
|
|
|
CLIPBOARD_SECOND_POINT
|
|
|
|
};
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
struct point {
|
|
|
|
int x, y;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-08-30 20:09:40 -04:00
|
|
|
/* Tags are used for ``id''s or anchors in the document referenced by the
|
|
|
|
* fragment part of the URI. */
|
|
|
|
struct tag {
|
|
|
|
LIST_HEAD(struct tag);
|
|
|
|
|
|
|
|
int x, y;
|
2021-01-02 10:20:27 -05:00
|
|
|
char name[1]; /* must be last of struct. --Zas */
|
2007-08-30 20:09:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
enum link_type {
|
|
|
|
LINK_HYPERTEXT,
|
|
|
|
LINK_MAP,
|
|
|
|
LINK_BUTTON,
|
|
|
|
LINK_CHECKBOX,
|
|
|
|
LINK_SELECT,
|
|
|
|
LINK_FIELD,
|
|
|
|
LINK_AREA,
|
|
|
|
};
|
|
|
|
|
2016-04-20 15:23:55 -04:00
|
|
|
enum script_event_hook_type {
|
|
|
|
SEVHOOK_ONCLICK,
|
|
|
|
SEVHOOK_ONDBLCLICK,
|
|
|
|
SEVHOOK_ONMOUSEOVER,
|
|
|
|
SEVHOOK_ONHOVER,
|
|
|
|
SEVHOOK_ONFOCUS,
|
|
|
|
SEVHOOK_ONMOUSEOUT,
|
|
|
|
SEVHOOK_ONBLUR,
|
|
|
|
};
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
struct script_event_hook {
|
|
|
|
LIST_HEAD(struct script_event_hook);
|
|
|
|
|
2016-04-20 15:23:55 -04:00
|
|
|
enum script_event_hook_type type;
|
2021-01-02 10:20:27 -05:00
|
|
|
char *src;
|
2005-09-15 09:58:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct link {
|
|
|
|
unicode_val_T accesskey;
|
|
|
|
|
|
|
|
enum link_type type;
|
|
|
|
|
2021-01-02 10:20:27 -05:00
|
|
|
char *where;
|
|
|
|
char *target;
|
|
|
|
char *where_img;
|
2011-04-17 16:23:00 -04:00
|
|
|
|
|
|
|
/** The title of the link. This is in the document charset,
|
|
|
|
* and entities have already been decoded. */
|
2021-01-02 10:20:27 -05:00
|
|
|
char *title;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** The set of characters belonging to this link (their coordinates
|
|
|
|
* in the document) - each character has own struct point. */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct point *points;
|
|
|
|
int npoints;
|
|
|
|
|
|
|
|
int number;
|
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** This is supposed to be the colour-pair of the link, but the actual
|
2005-09-15 09:58:31 -04:00
|
|
|
* colours on the canvas can differ--e.g., with image links. */
|
|
|
|
struct color_pair color;
|
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/*! XXX: They don't neccessary need to be link-specific, but we just
|
2005-09-15 09:58:31 -04:00
|
|
|
* don't support them for any other elements for now. Well, we don't
|
|
|
|
* even have a good place where to store them in that case. */
|
2007-07-26 12:04:35 -04:00
|
|
|
LIST_OF(struct script_event_hook) *event_hooks;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
union {
|
2021-01-02 10:20:27 -05:00
|
|
|
char *name;
|
2018-09-09 13:18:53 -04:00
|
|
|
struct el_form_control *form_control;
|
2005-09-15 09:58:31 -04:00
|
|
|
} data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define get_link_index(document, link) (link - document->links)
|
|
|
|
|
|
|
|
#define link_is_textinput(link) \
|
|
|
|
((link)->type == LINK_FIELD || (link)->type == LINK_AREA)
|
|
|
|
|
|
|
|
#define link_is_form(link) \
|
|
|
|
((link)->type != LINK_HYPERTEXT && (link)->type != LINK_MAP)
|
|
|
|
|
|
|
|
#define get_link_form_control(link) \
|
|
|
|
(link_is_form(link) ? (link)->data.form_control : NULL)
|
|
|
|
|
|
|
|
#define get_link_name(link) \
|
|
|
|
(!link_is_form(link) ? (link)->data.name : NULL)
|
|
|
|
|
2006-09-17 09:12:47 -04:00
|
|
|
#ifdef CONFIG_UTF8
|
2008-12-27 07:02:22 -05:00
|
|
|
/** A searchable character on the document canvas.
|
|
|
|
*
|
|
|
|
* struct document.search is an array of struct search, initialised by
|
|
|
|
* get_src, q.v. The elements of the array roughly correspond to the document
|
|
|
|
* canvas, document.data; each element corresponds to a regular character, a
|
|
|
|
* run of one or more control characters, or the end of a line on the canvas.
|
|
|
|
*
|
|
|
|
* If an instance of struct search corresponds to a regular character, then that
|
|
|
|
* character is stored in @a c and @a n is equal to 1. If an instance of struct
|
|
|
|
* search corresponds to a run of control characters, then a space character ' '
|
|
|
|
* is stored in @a c and @a n is equal to to the length of the run. If an instance
|
|
|
|
* of struct search corresponds to the end of a line, then a space is stored in
|
|
|
|
* @a c and @a n is equal to 0.
|
|
|
|
*/
|
2006-07-17 16:14:45 -04:00
|
|
|
struct search {
|
2008-12-27 07:02:22 -05:00
|
|
|
int x, y; /* Co-ordinates on the document canvas,
|
|
|
|
* document.data. */
|
|
|
|
|
|
|
|
signed int n; /* The number of characters on the
|
|
|
|
* document canvas to which this object
|
|
|
|
* corresponds. If the value is 0, then this
|
|
|
|
* object marks the end of a line. If the value
|
|
|
|
* is 1, then this object corresponds to a
|
|
|
|
* single character. If the value is greater
|
|
|
|
* than 1, then this object corresponds to a run
|
|
|
|
* of control characters. */
|
|
|
|
|
|
|
|
unicode_val_T c; /* The character on the document canvas to which
|
|
|
|
* this object corresponds or ' ' if that
|
|
|
|
* character is a control character or if this
|
|
|
|
* object marks the end of a line. */
|
|
|
|
|
|
|
|
/* RAM is cheap nowadays */
|
2006-07-17 16:14:45 -04:00
|
|
|
};
|
|
|
|
#else
|
2005-09-15 09:58:31 -04:00
|
|
|
struct search {
|
|
|
|
int x, y;
|
|
|
|
signed int n:24; /* This structure is size-critical */
|
|
|
|
unsigned char c;
|
|
|
|
};
|
2006-07-17 16:14:45 -04:00
|
|
|
#endif
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
struct document {
|
|
|
|
OBJECT_HEAD(struct document);
|
|
|
|
|
|
|
|
struct document_options options;
|
|
|
|
|
2007-07-26 12:04:35 -04:00
|
|
|
LIST_OF(struct form) forms;
|
|
|
|
LIST_OF(struct tag) tags;
|
|
|
|
LIST_OF(struct node) nodes;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
#ifdef CONFIG_ECMASCRIPT
|
2007-07-27 12:45:02 -04:00
|
|
|
/** ECMAScript snippets to be executed during loading the document into
|
2007-07-31 06:48:20 -04:00
|
|
|
* a window. This currently involves @<script>s and onLoad handlers.
|
2005-09-15 09:58:31 -04:00
|
|
|
* Note that if you hit a string beginning by '^' here, it is followed
|
|
|
|
* by an external reference - you must wait with processing other items
|
|
|
|
* until it gets resolved and loaded. New items are guaranteed to
|
|
|
|
* always appear at the list end. */
|
2007-07-26 12:04:35 -04:00
|
|
|
LIST_OF(struct string_list_item) onload_snippets;
|
2007-07-31 06:38:00 -04:00
|
|
|
/** @todo FIXME: We should externally maybe using cache_entry store the
|
2005-09-15 09:58:31 -04:00
|
|
|
* dependencies between the various entries so nothing gets removed
|
|
|
|
* unneeded. */
|
|
|
|
struct uri_list ecmascript_imports;
|
2007-07-27 12:45:02 -04:00
|
|
|
/** used by setTimeout */
|
2006-10-24 10:47:41 -04:00
|
|
|
timer_id_T timeout;
|
2021-02-24 05:23:34 -05:00
|
|
|
int ecmascript_counter;
|
2021-05-02 11:27:35 -04:00
|
|
|
void *dom;
|
2021-07-18 07:35:31 -04:00
|
|
|
char *text;
|
2005-09-15 09:58:31 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CSS
|
2007-07-31 06:38:00 -04:00
|
|
|
/** @todo FIXME: We should externally maybe using cache_entry store the
|
2005-09-15 09:58:31 -04:00
|
|
|
* dependencies between the various entries so nothing gets removed
|
|
|
|
* unneeded. */
|
|
|
|
struct uri_list css_imports;
|
2007-07-27 12:45:02 -04:00
|
|
|
/** Calculated from the id's of all the cache entries in #css_imports.
|
2005-09-15 09:58:31 -04:00
|
|
|
* Used for checking rerendering for available CSS imports. */
|
|
|
|
unsigned long css_magic;
|
|
|
|
#endif
|
2021-07-25 17:07:05 -04:00
|
|
|
struct iframeset_desc *iframe_desc;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
struct uri *uri;
|
2008-11-16 15:32:32 -05:00
|
|
|
|
2010-03-30 08:45:19 -04:00
|
|
|
/* for obtaining IP */
|
|
|
|
void *querydns;
|
2021-01-02 10:20:27 -05:00
|
|
|
char *ip;
|
2008-11-16 15:32:32 -05:00
|
|
|
/** The title of the document. The charset of this string is
|
|
|
|
* document.options.cp. */
|
2021-01-02 10:20:27 -05:00
|
|
|
char *title;
|
2006-12-09 22:11:04 -05:00
|
|
|
struct cache_entry *cached;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
struct frame_desc *frame;
|
2007-07-31 06:38:00 -04:00
|
|
|
struct frameset_desc *frame_desc; /**< @todo RENAME ME */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct document_refresh *refresh;
|
|
|
|
|
|
|
|
struct line *data;
|
|
|
|
|
|
|
|
struct link *links;
|
2007-07-27 12:45:02 -04:00
|
|
|
/** @name Arrays with one item per rendered document's line.
|
|
|
|
* @{ */
|
|
|
|
struct link **lines1; /**< The first link on the line. */
|
|
|
|
struct link **lines2; /**< The last link on the line. */
|
|
|
|
/** @} */
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
struct search *search;
|
|
|
|
struct search **slines1;
|
|
|
|
struct search **slines2;
|
2018-04-14 15:49:52 -04:00
|
|
|
struct point *search_points;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
2006-09-17 09:12:47 -04:00
|
|
|
#ifdef CONFIG_UTF8
|
2021-01-02 10:20:27 -05:00
|
|
|
char buf[7];
|
2006-07-21 16:10:18 -04:00
|
|
|
unsigned char buf_length;
|
2008-01-19 12:56:50 -05:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_COMBINE
|
2008-01-03 07:03:08 -05:00
|
|
|
/* base char + 5 combining chars = 6 */
|
|
|
|
unicode_val_T combi[UCS_MAX_LENGTH_COMBINED];
|
|
|
|
/* the number of combining characters. The base char is not counted. */
|
|
|
|
unsigned int combi_length;
|
|
|
|
/* Positions of the last base character.*/
|
|
|
|
int comb_x, comb_y;
|
2006-07-21 16:10:18 -04:00
|
|
|
#endif
|
2008-04-20 16:25:10 -04:00
|
|
|
unsigned int cache_id; /**< Used to check cache entries. */
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
int cp;
|
2007-07-27 12:45:02 -04:00
|
|
|
int width, height; /**< size of document */
|
2005-09-15 09:58:31 -04:00
|
|
|
int nlinks;
|
|
|
|
int nsearch;
|
2018-04-14 15:49:52 -04:00
|
|
|
int number_of_search_points;
|
2007-10-12 10:50:47 -04:00
|
|
|
|
|
|
|
struct {
|
|
|
|
color_T background;
|
|
|
|
} color;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
enum cp_status cp_status;
|
2007-07-27 12:45:02 -04:00
|
|
|
unsigned int links_sorted:1; /**< whether links are already sorted */
|
2020-08-01 17:25:21 -04:00
|
|
|
|
|
|
|
struct el_box clipboard_box;
|
|
|
|
enum clipboard_status clipboard_status;
|
2005-09-15 09:58:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define document_has_frames(document_) ((document_) && (document_)->frame_desc)
|
2021-07-25 17:07:05 -04:00
|
|
|
#define document_has_iframes(document_) ((document_) && (document_)->iframe_desc)
|
2005-09-15 09:58:31 -04:00
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** Initializes a document and its canvas.
|
|
|
|
* @returns NULL on allocation failure.
|
|
|
|
* @relates document */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct document *
|
|
|
|
init_document(struct cache_entry *cached, struct document_options *options);
|
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** Releases the document and all its resources.
|
|
|
|
* @relates document */
|
2005-09-15 09:58:31 -04:00
|
|
|
void done_document(struct document *document);
|
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** Free's the allocated members of the link. */
|
2005-09-15 09:58:31 -04:00
|
|
|
void done_link_members(struct link *link);
|
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** Calculates css magic from available CSS imports. Used for determining
|
2005-09-15 09:58:31 -04:00
|
|
|
* validity of formatted documents in the cache. */
|
|
|
|
unsigned long get_document_css_magic(struct document *document);
|
|
|
|
|
2007-08-30 15:08:24 -04:00
|
|
|
void update_cached_document_options(struct session *ses);
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
struct document *get_cached_document(struct cache_entry *cached, struct document_options *options);
|
|
|
|
|
2007-07-27 12:45:02 -04:00
|
|
|
/** Release a reference to the document.
|
|
|
|
* @relates document */
|
2005-09-15 09:58:31 -04:00
|
|
|
void release_document(struct document *document);
|
|
|
|
|
2021-06-27 07:01:19 -04:00
|
|
|
void reset_document(struct document *document);
|
|
|
|
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
int get_format_cache_size(void);
|
|
|
|
int get_format_cache_used_count(void);
|
|
|
|
int get_format_cache_refresh_count(void);
|
|
|
|
|
|
|
|
void shrink_format_cache(int);
|
|
|
|
|
|
|
|
extern struct module document_module;
|
|
|
|
|
2007-07-31 06:38:00 -04:00
|
|
|
/** @todo FIXME: support for entities and all Unicode characters.
|
2006-08-27 04:45:11 -04:00
|
|
|
* (Unpaired surrogates should be rejected, so that the ECMAScript
|
|
|
|
* interface can convert the access key to UTF-16.)
|
|
|
|
* For now, we only support simple printable character. */
|
2005-09-15 09:58:31 -04:00
|
|
|
#define accesskey_string_to_unicode(s) (((s)[0] && !(s)[1] && isprint((s)[0])) ? (s)[0] : 0)
|
|
|
|
|
2021-01-02 10:20:27 -05:00
|
|
|
int find_tag(struct document *document, char *name, int namelen);
|
2007-08-30 20:09:40 -04:00
|
|
|
|
2020-10-05 14:14:55 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
#endif
|