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 "main/timer.h"
8 #include "protocol/uri.h"
9 #include "util/color.h"
10 #include "util/lists.h"
14 struct document_refresh
;
21 /** Nodes are used for marking areas of text on the document canvas as
24 LIST_HEAD(struct node
);
30 /** The document line consisting of the chars ready to be copied to
31 * the terminal screen. */
33 struct screen_char
*chars
;
37 /** Codepage status */
51 /* Tags are used for ``id''s or anchors in the document referenced by the
52 * fragment part of the URI. */
54 LIST_HEAD(struct tag
);
57 unsigned char name
[1]; /* must be last of struct. --Zas */
71 struct script_event_hook
{
72 LIST_HEAD(struct script_event_hook
);
74 enum script_event_hook_type
{
87 unicode_val_T accesskey
;
92 unsigned char *target
;
93 unsigned char *where_img
;
96 /** The set of characters belonging to this link (their coordinates
97 * in the document) - each character has own struct point. */
103 /** This is supposed to be the colour-pair of the link, but the actual
104 * colours on the canvas can differ--e.g., with image links. */
105 struct color_pair color
;
107 /*! XXX: They don't neccessary need to be link-specific, but we just
108 * don't support them for any other elements for now. Well, we don't
109 * even have a good place where to store them in that case. */
110 LIST_OF(struct script_event_hook
) *event_hooks
;
114 struct form_control
*form_control
;
118 #define get_link_index(document, link) (link - document->links)
120 #define link_is_textinput(link) \
121 ((link)->type == LINK_FIELD || (link)->type == LINK_AREA)
123 #define link_is_form(link) \
124 ((link)->type != LINK_HYPERTEXT && (link)->type != LINK_MAP)
126 #define get_link_form_control(link) \
127 (link_is_form(link) ? (link)->data.form_control : NULL)
129 #define get_link_name(link) \
130 (!link_is_form(link) ? (link)->data.name : NULL)
135 signed int n
; /* RAM is cheap nowadays */
141 signed int n
:24; /* This structure is size-critical */
147 OBJECT_HEAD(struct document
);
149 struct document_options options
;
151 LIST_OF(struct form
) forms
;
152 LIST_OF(struct tag
) tags
;
153 LIST_OF(struct node
) nodes
;
155 #ifdef CONFIG_ECMASCRIPT
156 /** ECMAScript snippets to be executed during loading the document into
157 * a window. This currently involves @<script>s and onLoad handlers.
158 * Note that if you hit a string beginning by '^' here, it is followed
159 * by an external reference - you must wait with processing other items
160 * until it gets resolved and loaded. New items are guaranteed to
161 * always appear at the list end. */
162 LIST_OF(struct string_list_item
) onload_snippets
;
163 /** @todo FIXME: We should externally maybe using cache_entry store the
164 * dependencies between the various entries so nothing gets removed
166 struct uri_list ecmascript_imports
;
167 /** used by setTimeout */
171 /** @todo FIXME: We should externally maybe using cache_entry store the
172 * dependencies between the various entries so nothing gets removed
174 struct uri_list css_imports
;
175 /** Calculated from the id's of all the cache entries in #css_imports.
176 * Used for checking rerendering for available CSS imports. */
177 unsigned long css_magic
;
181 unsigned char *title
;
182 struct cache_entry
*cached
;
184 struct frame_desc
*frame
;
185 struct frameset_desc
*frame_desc
; /**< @todo RENAME ME */
186 struct document_refresh
*refresh
;
191 /** @name Arrays with one item per rendered document's line.
193 struct link
**lines1
; /**< The first link on the line. */
194 struct link
**lines2
; /**< The last link on the line. */
197 struct search
*search
;
198 struct search
**slines1
;
199 struct search
**slines2
;
202 unsigned char buf
[7];
203 unsigned char buf_length
;
205 unsigned int id
; /**< Used to check cache entries. */
208 int width
, height
; /**< size of document */
213 enum cp_status cp_status
;
214 unsigned int links_sorted
:1; /**< whether links are already sorted */
217 #define document_has_frames(document_) ((document_) && (document_)->frame_desc)
219 /** Initializes a document and its canvas.
220 * @returns NULL on allocation failure.
221 * @relates document */
223 init_document(struct cache_entry
*cached
, struct document_options
*options
);
225 /** Releases the document and all its resources.
226 * @relates document */
227 void done_document(struct document
*document
);
229 /** Free's the allocated members of the link. */
230 void done_link_members(struct link
*link
);
232 /** Calculates css magic from available CSS imports. Used for determining
233 * validity of formatted documents in the cache. */
234 unsigned long get_document_css_magic(struct document
*document
);
236 void update_cached_document_options(void);
238 struct document
*get_cached_document(struct cache_entry
*cached
, struct document_options
*options
);
240 /** Release a reference to the document.
241 * @relates document */
242 void release_document(struct document
*document
);
244 int get_format_cache_size(void);
245 int get_format_cache_used_count(void);
246 int get_format_cache_refresh_count(void);
248 void shrink_format_cache(int);
250 extern struct module document_module
;
252 /** @todo FIXME: support for entities and all Unicode characters.
253 * (Unpaired surrogates should be rejected, so that the ECMAScript
254 * interface can convert the access key to UTF-16.)
255 * For now, we only support simple printable character. */
256 #define accesskey_string_to_unicode(s) (((s)[0] && !(s)[1] && isprint((s)[0])) ? (s)[0] : 0)
258 int find_tag(struct document
*document
, unsigned char *name
, int namelen
);