1 #ifndef EL__DOCUMENT_DOCUMENT_H
2 #define EL__DOCUMENT_DOCUMENT_H
4 #include "document/options.h"
5 #include "intl/charsets.h" /* unicode_val_T */
6 #include "main/object.h"
7 #include "protocol/uri.h"
8 #include "util/color.h"
9 #include "util/lists.h"
13 struct document_refresh
;
20 /* Nodes are used for marking areas of text on the document canvas as
23 LIST_HEAD(struct node
);
29 /* The document line consisting of the chars ready to be copied to the terminal
32 struct screen_char
*chars
;
60 struct script_event_hook
{
61 LIST_HEAD(struct script_event_hook
);
63 enum script_event_hook_type
{
76 unicode_val_T accesskey
;
81 unsigned char *target
;
82 unsigned char *where_img
;
85 /* The set of characters belonging to this link (their coordinates
86 * in the document) - each character has own {struct point}. */
92 /* This is supposed to be the colour-pair of the link, but the actual
93 * colours on the canvas can differ--e.g., with image links. */
94 struct color_pair color
;
96 /* XXX: They don't neccessary need to be link-specific, but we just
97 * don't support them for any other elements for now. Well, we don't
98 * even have a good place where to store them in that case. */
99 struct list_head
*event_hooks
; /* -> struct script_event_hook */
103 struct form_control
*form_control
;
107 #define get_link_index(document, link) (link - document->links)
109 #define link_is_textinput(link) \
110 ((link)->type == LINK_FIELD || (link)->type == LINK_AREA)
112 #define link_is_form(link) \
113 ((link)->type != LINK_HYPERTEXT && (link)->type != LINK_MAP)
115 #define get_link_form_control(link) \
116 (link_is_form(link) ? (link)->data.form_control : NULL)
118 #define get_link_name(link) \
119 (!link_is_form(link) ? (link)->data.name : NULL)
124 signed int n
:24; /* This structure is size-critical */
130 OBJECT_HEAD(struct document
);
132 struct document_options options
;
134 struct list_head forms
; /* -> struct form */
135 struct list_head tags
; /* -> struct tag */
136 struct list_head nodes
; /* -> struct node */
138 #ifdef CONFIG_ECMASCRIPT
139 /* ECMAScript snippets to be executed during loading the document into
140 * a window. This currently involves <script>s and onLoad handlers.
141 * Note that if you hit a string beginning by '^' here, it is followed
142 * by an external reference - you must wait with processing other items
143 * until it gets resolved and loaded. New items are guaranteed to
144 * always appear at the list end. */
145 struct list_head onload_snippets
; /* -> struct string_list_item */
146 /* FIXME: We should externally maybe using cache_entry store the
147 * dependencies between the various entries so nothing gets removed
149 struct uri_list ecmascript_imports
;
152 /* FIXME: We should externally maybe using cache_entry store the
153 * dependencies between the various entries so nothing gets removed
155 struct uri_list css_imports
;
156 /* Calculated from the id's of all the cache entries in css_imports.
157 * Used for checking rerendering for available CSS imports. */
158 unsigned long css_magic
;
162 unsigned char *title
;
164 struct frame_desc
*frame
;
165 struct frameset_desc
*frame_desc
; /* RENAME ME */
166 struct document_refresh
*refresh
;
171 /* Arrays with one item per rendered document's line. */
172 struct link
**lines1
; /* The first link on the line. */
173 struct link
**lines2
; /* The last link on the line. */
175 struct search
*search
;
176 struct search
**slines1
;
177 struct search
**slines2
;
179 unsigned int id
; /* Used to check cache entries. */
182 int width
, height
; /* size of document */
187 enum cp_status cp_status
;
190 #define document_has_frames(document_) ((document_) && (document_)->frame_desc)
192 /* Initializes a document and its canvas. */
193 /* Return NULL on allocation failure. */
195 init_document(struct cache_entry
*cached
, struct document_options
*options
);
197 /* Releases the document and all its resources. */
198 void done_document(struct document
*document
);
200 /* Free's the allocated members of the link. */
201 void done_link_members(struct link
*link
);
203 /* Calculates css magic from available CSS imports. Used for determining
204 * validity of formatted documents in the cache. */
205 unsigned long get_document_css_magic(struct document
*document
);
207 void update_cached_document_options(void);
209 struct document
*get_cached_document(struct cache_entry
*cached
, struct document_options
*options
);
211 /* Release a reference to the document. */
212 void release_document(struct document
*document
);
214 int get_format_cache_size(void);
215 int get_format_cache_used_count(void);
216 int get_format_cache_refresh_count(void);
218 void shrink_format_cache(int);
220 extern struct module document_module
;
222 /* FIXME: support for entities and all Unicode characters.
223 * For now, we only support simple printable character. */
224 #define accesskey_string_to_unicode(s) (((s)[0] && !(s)[1] && isprint((s)[0])) ? (s)[0] : 0)