NetSurf
object.c
Go to the documentation of this file.
1/*
2 * Copyright 2013 Vincent Sanders <vince@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * \file
21 * Processing for html content object operations.
22 */
23
24#include <assert.h>
25#include <ctype.h>
26#include <stdint.h>
27#include <string.h>
28#include <strings.h>
29#include <stdlib.h>
30#include <nsutils/time.h>
31
32#include "utils/corestrings.h"
33#include "utils/config.h"
34#include "utils/log.h"
35#include "utils/nsoption.h"
36#include "netsurf/content.h"
37#include "netsurf/misc.h"
38#include "content/hlcache.h"
39#include "css/utils.h"
40#include "desktop/scrollbar.h"
42
43#include "html/html.h"
44#include "html/private.h"
45#include "html/interaction.h"
46#include "html/box.h"
47#include "html/box_inspect.h"
48#include "html/object.h"
49
50/* break reference loop */
51static void html_object_refresh(void *p);
52
53/**
54 * Retrieve objects used by HTML document
55 *
56 * \param h Content to retrieve objects from
57 * \param n Pointer to location to receive number of objects
58 * \return Pointer to list of objects
59 */
61{
63
64 assert(c != NULL);
65 assert(n != NULL);
66
67 *n = c->num_objects;
68
69 return c->object_list;
70}
71
72/**
73 * Handle object fetching or loading failure.
74 *
75 * \param box box containing object which failed to load
76 * \param content document of type CONTENT_HTML
77 * \param background the object was the background image for the box
78 */
79
80static void
82{
83 /* Nothing to do */
84 return;
85}
86
87/**
88 * Update a box whose content has completed rendering.
89 */
90
91static void
93 hlcache_handle *object,
94 bool background)
95{
96 struct box *b;
97
98 if (background) {
100 return;
101 }
102
103 box->object = object;
104
105 /* Normalise the box type, now it has been replaced. */
106 switch (box->type) {
107 case BOX_TABLE:
108 box->type = BOX_BLOCK;
109 break;
110 default:
111 /* TODO: Any other box types need mapping? */
112 break;
113 }
114
115 if (!(box->flags & REPLACE_DIM)) {
116 /* invalidate parent min, max widths */
117 for (b = box; b; b = b->parent)
119
120 /* delete any clones of this box */
121 while (box->next && (box->next->flags & CLONE)) {
122 /* box_free_box(box->next); */
123 box->next = box->next->next;
124 }
125 }
126}
127
128
129/**
130 * Callback for hlcache_handle_retrieve() for objects with no box.
131 */
132static nserror
134 const hlcache_event *event,
135 void *pw)
136{
137 struct content_html_object *chobject = pw;
138
139 switch (event->type) {
142
143 chobject->content = NULL;
144 break;
145
146 default:
147 break;
148 }
149
150 return NSERROR_OK;
151}
152
153
154/**
155 * Callback for hlcache_handle_retrieve() for objects with a box.
156 */
157static nserror
159 const hlcache_event *event,
160 void *pw)
161{
162 struct content_html_object *o = pw;
163 html_content *c = (html_content *) o->parent;
164 int x, y;
165 struct box *box;
166
167 box = o->box;
168
169 switch (event->type) {
171 if (c->base.status != CONTENT_STATUS_LOADING && c->bw != NULL)
172 content_open(object,
173 c->bw, &c->base,
175 break;
176
178 if (content_can_reformat(object)) {
179 /* TODO: avoid knowledge of box internals here */
180 content_reformat(object, false,
182 box->width : 0,
184 box->height : 0);
185
186 /* Adjust parent content for new object size */
187 html_object_done(box, object, o->background);
188 if (c->base.status == CONTENT_STATUS_READY ||
190 content__reformat(&c->base, false,
193 }
194 break;
195
196 case CONTENT_MSG_DONE:
197 c->base.active--;
198 NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
199
200 html_object_done(box, object, o->background);
201
203 box->flags & REPLACE_DIM) {
204 union content_msg_data data;
205
206 if (c->had_initial_layout == false) {
207 break;
208 }
209
210 if (!box_visible(box))
211 break;
212
213 box_coords(box, &x, &y);
214
215 data.redraw.x = x + box->padding[LEFT];
216 data.redraw.y = y + box->padding[TOP];
217 data.redraw.width = box->width;
218 data.redraw.height = box->height;
219
221 }
222 break;
223
226
227 o->content = NULL;
228
229 c->base.active--;
230 NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
231
233
234 break;
235
238 union content_msg_data data = event->data;
239
240 if (c->had_initial_layout == false) {
241 break;
242 }
243
244 if (!box_visible(box))
245 break;
246
247 box_coords(box, &x, &y);
248
249 if (object == box->background) {
250 /* Redraw request is for background */
251 css_fixed hpos = 0, vpos = 0;
252 css_unit hunit = CSS_UNIT_PX;
253 css_unit vunit = CSS_UNIT_PX;
254 int width = box->padding[LEFT] + box->width +
255 box->padding[RIGHT];
256 int height = box->padding[TOP] + box->height +
258 int t, h, l, w;
259
260 /* Need to know background-position */
261 css_computed_background_position(box->style,
262 &hpos, &hunit, &vpos, &vunit);
263
265 if (hunit == CSS_UNIT_PCT) {
266 l = (width - w) * hpos / INTTOFIX(100);
267 } else {
268 l = FIXTOINT(css_unit_len2device_px(
269 box->style,
270 &c->unit_len_ctx,
271 hpos, hunit));
272 }
273
275 if (vunit == CSS_UNIT_PCT) {
276 t = (height - h) * vpos / INTTOFIX(100);
277 } else {
278 t = FIXTOINT(css_unit_len2device_px(
279 box->style,
280 &c->unit_len_ctx,
281 vpos, vunit));
282 }
283
284 /* Redraw area depends on background-repeat */
285 switch (css_computed_background_repeat(
286 box->style)) {
287 case CSS_BACKGROUND_REPEAT_REPEAT:
288 data.redraw.x = 0;
289 data.redraw.y = 0;
290 data.redraw.width = box->width;
291 data.redraw.height = box->height;
292 break;
293
294 case CSS_BACKGROUND_REPEAT_REPEAT_X:
295 data.redraw.x = 0;
296 data.redraw.y += t;
297 data.redraw.width = box->width;
298 break;
299
300 case CSS_BACKGROUND_REPEAT_REPEAT_Y:
301 data.redraw.x += l;
302 data.redraw.y = 0;
303 data.redraw.height = box->height;
304 break;
305
306 case CSS_BACKGROUND_REPEAT_NO_REPEAT:
307 data.redraw.x += l;
308 data.redraw.y += t;
309 break;
310
311 default:
312 break;
313 }
314
315 /* Add offset to box */
316 data.redraw.x += x;
317 data.redraw.y += y;
318
319 } else {
320 /* Non-background case */
321 int w = content_get_width(object);
322 int h = content_get_height(object);
323
324 if (w != 0 && box->width != w) {
325 /* Not showing image at intrinsic
326 * width; need to scale the redraw
327 * request area. */
328 data.redraw.x = data.redraw.x *
329 box->width / w;
330 data.redraw.width =
331 data.redraw.width *
332 box->width / w;
333 }
334
335 if (h != 0 && box->height != w) {
336 /* Not showing image at intrinsic
337 * height; need to scale the redraw
338 * request area. */
339 data.redraw.y = data.redraw.y *
340 box->height / h;
341 data.redraw.height =
342 data.redraw.height *
343 box->height / h;
344 }
345
346 data.redraw.x += x + box->padding[LEFT];
347 data.redraw.y += y + box->padding[TOP];
348 }
349
351 }
352 break;
353
355 if (content_get_type(object) == CONTENT_HTML) {
356 /* only for HTML objects */
357 guit->misc->schedule(event->data.delay * 1000,
359 }
360
361 break;
362
363 case CONTENT_MSG_LINK:
364 /* Don't care about favicons that aren't on top level content */
365 break;
366
368 /* Objects don't have JS threads */
369 *(event->data.jsthread) = NULL;
370 break;
371
373 *(event->data.getdims.viewport_width) =
375 *(event->data.getdims.viewport_height) =
377 break;
378
380 if (box->scroll_x != NULL)
382 false);
383 if (box->scroll_y != NULL)
385 false);
386 break;
387
389 {
390 union content_msg_data msg_data;
391 if (event->data.dragsave.content == NULL)
392 msg_data.dragsave.content = object;
393 else
394 msg_data.dragsave.content =
395 event->data.dragsave.content;
396
398 }
399 break;
400
405 /* These messages are for browser window layer.
406 * we're not interested, so pass them on. */
407 content_broadcast(&c->base, event->type, &event->data);
408 break;
409
411 {
412 union html_focus_owner focus_owner;
413 focus_owner.content = box;
414
415 switch (event->data.caret.type) {
416 case CONTENT_CARET_REMOVE:
417 case CONTENT_CARET_HIDE:
418 html_set_focus(c, HTML_FOCUS_CONTENT, focus_owner,
419 true, 0, 0, 0, NULL);
420 break;
421 case CONTENT_CARET_SET_POS:
422 html_set_focus(c, HTML_FOCUS_CONTENT, focus_owner,
423 false, event->data.caret.pos.x,
424 event->data.caret.pos.y,
425 event->data.caret.pos.height,
426 event->data.caret.pos.clip);
427 break;
428 }
429 }
430 break;
431
432 case CONTENT_MSG_DRAG:
433 {
434 html_drag_type drag_type = HTML_DRAG_NONE;
435 union html_drag_owner drag_owner;
436 drag_owner.content = box;
437
438 switch (event->data.drag.type) {
439 case CONTENT_DRAG_NONE:
440 drag_type = HTML_DRAG_NONE;
441 drag_owner.no_owner = true;
442 break;
443 case CONTENT_DRAG_SCROLL:
444 drag_type = HTML_DRAG_CONTENT_SCROLL;
445 break;
446 case CONTENT_DRAG_SELECTION:
447 drag_type = HTML_DRAG_CONTENT_SELECTION;
448 break;
449 }
450 html_set_drag_type(c, drag_type, drag_owner,
451 event->data.drag.rect);
452 }
453 break;
454
456 {
457 html_selection_type sel_type;
458 union html_selection_owner sel_owner;
459
460 if (event->data.selection.selection) {
461 sel_type = HTML_SELECTION_CONTENT;
462 sel_owner.content = box;
463 } else {
464 sel_type = HTML_SELECTION_NONE;
465 sel_owner.none = true;
466 }
467 html_set_selection(c, sel_type, sel_owner,
468 event->data.selection.read_only);
469 }
470 break;
471
472 default:
473 break;
474 }
475
476 if (c->base.status == CONTENT_STATUS_READY &&
477 c->base.active == 0 &&
478 (event->type == CONTENT_MSG_LOADING ||
479 event->type == CONTENT_MSG_DONE ||
480 event->type == CONTENT_MSG_ERROR)) {
481 /* all objects have arrived */
485 } else if (nsoption_bool(incremental_reflow) &&
486 event->type == CONTENT_MSG_DONE &&
487 box != NULL &&
488 !(box->flags & REPLACE_DIM) &&
491 /* 1) the configuration option to reflow pages while
492 * objects are fetched is set
493 * 2) an object is newly fetched & converted,
494 * 3) the box's dimensions need to change due to being replaced
495 * 4) the object's parent HTML is ready for reformat,
496 */
497 uint64_t ms_now;
498 nsu_getmonotonic_ms(&ms_now);
499 if (ms_now > c->base.reformat_time) {
500 /* The time since the previous reformat is
501 * more than the configured minimum time
502 * between reformats so reformat the page to
503 * display newly fetched objects
504 */
506 false,
509 }
510 }
511
512 return NSERROR_OK;
513}
514
515
516/**
517 * Start a fetch for an object required by a page, replacing an existing object.
518 *
519 * \param object Object to replace
520 * \param url URL of object to fetch (copied)
521 * \return true on success, false on memory exhaustion
522 */
523static bool html_replace_object(struct content_html_object *object, nsurl *url)
524{
525 html_content *c;
527 html_content *page;
528 nserror error;
529
530 assert(object != NULL);
531 assert(object->box != NULL);
532
533 c = (html_content *) object->parent;
534
535 child.charset = c->encoding;
536 child.quirks = c->base.quirks;
537
538 if (object->content != NULL) {
539 /* remove existing object */
541 c->base.active--;
542 NSLOG(netsurf, INFO, "%d fetches active",
543 c->base.active);
544 }
545
547 object->content = NULL;
548
549 object->box->object = NULL;
550 }
551
552 /* initialise fetch */
554 content_get_url(&c->base), NULL,
555 html_object_callback, object, &child,
556 object->permitted_types,
557 &object->content);
558
559 if (error != NSERROR_OK)
560 return false;
561
562 for (page = c; page != NULL; page = page->page) {
563 page->base.active++;
564 NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
565
567 }
568
569 return true;
570}
571
572/**
573 * schedule callback for object refresh
574 */
575static void html_object_refresh(void *p)
576{
577 struct content_html_object *object = p;
578 nsurl *refresh_url;
579
580 assert(content_get_type(object->content) == CONTENT_HTML);
581
582 refresh_url = content_get_refresh_url(object->content);
583
584 /* Ignore if refresh URL has gone
585 * (may happen if fetch errored) */
586 if (refresh_url == NULL)
587 return;
588
590
591 if (!html_replace_object(object, refresh_url)) {
592 /** \todo handle memory exhaustion */
593 }
594}
595
596
597/* exported interface documented in html/object.h */
599{
600 struct content_html_object *object, *next;
601
602 for (object = html->object_list; object != NULL; object = next) {
603 next = object->next;
604
605 if (object->content == NULL || object->box == NULL)
606 continue;
607
608 if (content_get_type(object->content) == CONTENT_NONE)
609 continue;
610
611 content_open(object->content,
612 bw,
613 &html->base,
614 object->box->object_params);
615 }
616 return NSERROR_OK;
617}
618
619
620/* exported interface documented in html/object.h */
622{
623 struct content_html_object *object;
624
625 for (object = htmlc->object_list;
626 object != NULL;
627 object = object->next) {
628 if (object->content == NULL)
629 continue;
630
631 switch (content_get_status(object->content)) {
633 /* already loaded: do nothing */
634 break;
635
638 /* Active count will be updated when
639 * html_object_callback receives
640 * CONTENT_MSG_DONE from this object
641 */
642 break;
643
644 default:
647 object->content = NULL;
648 if (object->box != NULL) {
649 htmlc->base.active--;
650 NSLOG(netsurf, INFO, "%d fetches active",
651 htmlc->base.active);
652 }
653 break;
654
655 }
656 }
657
658 return NSERROR_OK;
659}
660
661
662/* exported interface documented in html/object.h */
664{
665 struct content_html_object *object, *next;
666
667 for (object = html->object_list; object != NULL; object = next) {
668 next = object->next;
669
670 if (object->content == NULL || object->box == NULL)
671 continue;
672
673 if (content_get_type(object->content) == CONTENT_NONE)
674 continue;
675
676 if (content_get_type(object->content) == CONTENT_HTML) {
677 guit->misc->schedule(-1, html_object_refresh, object);
678 }
679
680 content_close(object->content);
681 }
682 return NSERROR_OK;
683}
684
685
686/* exported interface documented in html/object.h */
688{
689 while (html->object_list != NULL) {
690 struct content_html_object *victim = html->object_list;
691
692 if (victim->content != NULL) {
693 NSLOG(netsurf, INFO, "object %p", victim->content);
694
695 if (content_get_type(victim->content) == CONTENT_HTML) {
696 guit->misc->schedule(-1, html_object_refresh, victim);
697 }
699 }
700
701 html->object_list = victim->next;
702 free(victim);
703 }
704 return NSERROR_OK;
705}
706
707
708/* exported interface documented in html/object.h */
709bool
711 nsurl *url,
712 struct box *box,
714 bool background)
715{
716 struct content_html_object *object;
717 hlcache_handle_callback object_callback;
719 nserror error;
720
721 /* If we've already been aborted, don't bother attempting the fetch */
722 if (c->aborted)
723 return true;
724
725 child.charset = c->encoding;
726 child.quirks = c->base.quirks;
727
728 object = calloc(1, sizeof(struct content_html_object));
729 if (object == NULL) {
730 return false;
731 }
732
733 if (box == NULL) {
734 object_callback = html_object_nobox_callback;
735 } else {
736 object_callback = html_object_callback;
737 }
738
739 object->parent = (struct content *) c;
740 object->next = NULL;
741 object->content = NULL;
742 object->box = box;
743 object->permitted_types = permitted_types;
744 object->background = background;
745
746 error = hlcache_handle_retrieve(url,
749 NULL,
750 object_callback,
751 object,
752 &child,
753 object->permitted_types,
754 &object->content);
755 if (error != NSERROR_OK) {
756 free(object);
757 return error != NSERROR_NOMEM;
758 }
759
760 /* add to content object list */
761 object->next = c->object_list;
762 c->object_list = object;
763
764 c->num_objects++;
765 if (box != NULL) {
766 c->base.active++;
767 NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
768 }
769
770 return true;
771}
Box interface.
#define UNKNOWN_MAX_WIDTH
Definition: box.h:46
@ BOX_BLOCK
Definition: box.h:56
@ BOX_TABLE
Definition: box.h:59
@ CLONE
Definition: box.h:83
@ REPLACE_DIM
Definition: box.h:88
@ TOP
Definition: box.h:98
@ BOTTOM
Definition: box.h:98
@ LEFT
Definition: box.h:98
@ RIGHT
Definition: box.h:98
void box_coords(struct box *box, int *x, int *y)
Find the absolute coordinates of a box.
Definition: box_inspect.c:549
bool box_visible(struct box *box)
Determine if a box is visible when the tree is rendered.
Definition: box_inspect.c:636
HTML Box tree inspection interface.
static void html_object_refresh(void *p)
schedule callback for object refresh
Definition: object.c:575
bool html_fetch_object(html_content *c, nsurl *url, struct box *box, content_type permitted_types, bool background)
Start a fetch for an object required by a page.
Definition: object.c:710
nserror html_object_abort_objects(html_content *htmlc)
abort any content objects that have not completed fetching.
Definition: object.c:621
static bool html_replace_object(struct content_html_object *object, nsurl *url)
Start a fetch for an object required by a page, replacing an existing object.
Definition: object.c:523
nserror html_object_close_objects(html_content *html)
close content of content objects associated with a HTML content
Definition: object.c:663
static void html_object_done(struct box *box, hlcache_handle *object, bool background)
Update a box whose content has completed rendering.
Definition: object.c:92
static nserror html_object_callback(hlcache_handle *object, const hlcache_event *event, void *pw)
Callback for hlcache_handle_retrieve() for objects with a box.
Definition: object.c:158
struct content_html_object * html_get_objects(hlcache_handle *h, unsigned int *n)
Retrieve objects used by HTML document.
Definition: object.c:60
static void html_object_failed(struct box *box, html_content *content, bool background)
Handle object fetching or loading failure.
Definition: object.c:81
static nserror html_object_nobox_callback(hlcache_handle *object, const hlcache_event *event, void *pw)
Callback for hlcache_handle_retrieve() for objects with no box.
Definition: object.c:133
nserror html_object_free_objects(html_content *html)
release memory of content objects associated with a HTML content
Definition: object.c:687
nserror html_object_open_objects(html_content *html, struct browser_window *bw)
open content of content objects associated with a HTML content
Definition: object.c:598
HTML content object interface.
void content__reformat(struct content *c, bool background, int width, int height)
cause a content to be reformatted.
Definition: content.c:331
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
Definition: content.c:752
int content__get_height(struct content *c)
Retrieve height of content.
Definition: content.c:1182
nserror content_close(hlcache_handle *h)
The window containing the content has been closed.
Definition: content.c:813
void content_set_done(struct content *c)
Put a content in status CONTENT_STATUS_DONE.
Definition: content.c:299
int content__get_width(struct content *c)
Retrieve width of content.
Definition: content.c:1165
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
Definition: content.c:1051
bool content_can_reformat(hlcache_handle *h)
Get whether a content can reformat.
Definition: content.c:258
void content_reformat(hlcache_handle *h, bool background, int width, int height)
Reformat to new size.
Definition: content.c:321
nsurl * content_get_refresh_url(hlcache_handle *h)
Retrieve the refresh URL for a content.
Definition: content.c:1247
nserror content_open(hlcache_handle *h, struct browser_window *bw, struct content *page, struct object_params *params)
A window containing the content has been opened.
Definition: content.c:791
content_status content_get_status(hlcache_handle *h)
Retrieve status of content.
Definition: content.c:1124
@ CONTENT_STATUS_READY
Some parts of content still being loaded, but can be displayed.
Definition: content_type.h:92
@ CONTENT_STATUS_DONE
Content has completed all processing.
Definition: content_type.h:95
@ CONTENT_STATUS_LOADING
Content is being fetched or converted and is not safe to display.
Definition: content_type.h:89
content_type
The type of a content.
Definition: content_type.h:53
@ CONTENT_NONE
no type for content
Definition: content_type.h:55
@ CONTENT_HTML
content is HTML
Definition: content_type.h:58
@ CONTENT_MSG_LINK
RFC5988 link.
Definition: content_type.h:143
@ CONTENT_MSG_SELECTMENU
Create a select menu.
Definition: content_type.h:173
@ CONTENT_MSG_REFRESH
wants refresh
Definition: content_type.h:137
@ CONTENT_MSG_GETDIMS
Get viewport dimensions.
Definition: content_type.h:149
@ CONTENT_MSG_GADGETCLICK
A gadget has been clicked on (mainly for file)
Definition: content_type.h:176
@ CONTENT_MSG_SCROLL
Request to scroll content.
Definition: content_type.h:152
@ CONTENT_MSG_DONE
content has finished processing
Definition: content_type.h:119
@ CONTENT_MSG_LOADING
fetching or converting
Definition: content_type.h:113
@ CONTENT_MSG_ERROR
error occurred
Definition: content_type.h:122
@ CONTENT_MSG_DRAGSAVE
Allow drag saving of content.
Definition: content_type.h:155
@ CONTENT_MSG_POINTER
Wants a specific mouse pointer set.
Definition: content_type.h:161
@ CONTENT_MSG_SELECTION
A selection made or cleared.
Definition: content_type.h:164
@ CONTENT_MSG_DRAG
A drag started or ended.
Definition: content_type.h:170
@ CONTENT_MSG_GETTHREAD
Javascript thread.
Definition: content_type.h:146
@ CONTENT_MSG_REDRAW
needs redraw (eg.
Definition: content_type.h:134
@ CONTENT_MSG_READY
may be displayed
Definition: content_type.h:116
@ CONTENT_MSG_SAVELINK
Allow URL to be saved.
Definition: content_type.h:158
@ CONTENT_MSG_CARET
Caret movement / hiding.
Definition: content_type.h:167
Useful interned string pointers (interface).
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_NOMEM
Memory exhaustion.
Definition: errors.h:32
@ NSERROR_OK
No error.
Definition: errors.h:30
struct netsurf_table * guit
The global interface table.
Definition: gui_factory.c:50
Interface to core interface table.
struct content * hlcache_handle_get_content(const hlcache_handle *handle)
Retrieve a content object from a cache handle.
Definition: hlcache.c:776
nserror hlcache_handle_abort(hlcache_handle *handle)
Abort a high-level cache fetch.
Definition: hlcache.c:786
nserror hlcache_handle_release(hlcache_handle *handle)
Release a high-level cache handle.
Definition: hlcache.c:740
nserror hlcache_handle_retrieve(nsurl *url, uint32_t flags, nsurl *referer, llcache_post_data *post, hlcache_handle_callback cb, void *pw, hlcache_child_context *child, content_type accepted_types, hlcache_handle **result)
Retrieve a high-level cache handle for an object.
Definition: hlcache.c:679
High-level resource cache interface.
nserror(* hlcache_handle_callback)(hlcache_handle *handle, const hlcache_event *event, void *pw)
Client callback for high-level cache events.
Definition: hlcache.h:63
@ HLCACHE_RETRIEVE_SNIFF_TYPE
Definition: hlcache.h:75
Interface to text/html content handler.
Public content interface.
int content_get_height(struct hlcache_handle *h)
Retrieve height of content.
Definition: content.c:1175
int content_get_width(struct hlcache_handle *h)
Retrieve width of content.
Definition: content.c:1158
void content_invalidate_reuse_data(struct hlcache_handle *h)
Invalidate content reuse data.
Definition: content.c:1229
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
Definition: content.c:1061
Interface to platform-specific miscellaneous browser operation table.
void html_set_drag_type(html_content *html, html_drag_type drag_type, union html_drag_owner drag_owner, const struct rect *rect)
Set our drag status, and inform whatever owns the content.
Definition: interaction.c:1659
void html_set_focus(html_content *html, html_focus_type focus_type, union html_focus_owner focus_owner, bool hide_caret, int x, int y, int height, const struct rect *clip)
Set our input focus, and inform whatever owns the content.
Definition: interaction.c:1696
void html_set_selection(html_content *html, html_selection_type selection_type, union html_selection_owner selection_owner, bool read_only)
Set our selection status, and inform whatever owns the content.
Definition: interaction.c:1754
HTML content user interaction handling.
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
Private data for text/html content.
html_drag_type
Definition: private.h:39
@ HTML_DRAG_CONTENT_SELECTION
Not own; drag in textarea widget.
Definition: private.h:45
@ HTML_DRAG_NONE
Definition: private.h:40
@ HTML_DRAG_CONTENT_SCROLL
Not own; drag in child content.
Definition: private.h:46
@ HTML_FOCUS_CONTENT
Focus belongs to child content.
Definition: private.h:77
html_selection_type
Definition: private.h:59
@ HTML_SELECTION_NONE
Definition: private.h:60
@ HTML_SELECTION_CONTENT
Selection in this html content.
Definition: private.h:63
int width
Definition: gui.c:160
int height
Definition: gui.c:161
void scrollbar_set(struct scrollbar *s, int value, bool bar_pos)
Set the scroll value of the scrollbar.
Definition: scrollbar.c:512
Scrollbar widget interface.
Interface to utility string handling.
Node in box tree.
Definition: box.h:177
int width
Width of content box (excluding padding etc.).
Definition: box.h:289
struct box * parent
Parent box, or NULL.
Definition: box.h:236
struct scrollbar * scroll_x
Horizontal scroll.
Definition: box.h:332
int height
Height of content box (excluding padding etc.).
Definition: box.h:293
struct hlcache_handle * background
Background image for this box, or NULL if none.
Definition: box.h:435
int max_width
Width that would be taken with no line breaks.
Definition: box.h:349
struct box * next
Next sibling box, or NULL.
Definition: box.h:216
struct scrollbar * scroll_y
Vertical scroll.
Definition: box.h:337
box_type type
Type of box.
Definition: box.h:181
css_computed_style * style
Style for this box.
Definition: box.h:205
struct object_params * object_params
Parameters for the object, or NULL.
Definition: box.h:446
struct hlcache_handle * object
Object in this box (usually an image), or NULL if none.
Definition: box.h:441
int padding[4]
Padding: TOP, RIGHT, BOTTOM, LEFT.
Definition: box.h:322
box_flags flags
Box flags.
Definition: box.h:186
Browser window data.
An object (img, object, etc.
Definition: html.h:93
bool background
This object is a background image.
Definition: html.h:101
struct content_html_object * next
Next in chain.
Definition: html.h:95
content_type permitted_types
Bitmap of acceptable content types.
Definition: html.h:100
struct box * box
Node in box tree containing it.
Definition: html.h:98
struct content * parent
Parent document.
Definition: html.h:94
struct hlcache_handle * content
Content, or 0.
Definition: html.h:97
Content which corresponds to a single URL.
bool quirks
Content is in quirks mode.
unsigned int active
Number of child fetches or conversions currently in progress.
int available_height
Viewport height.
content_status status
Current status.
uint64_t reformat_time
Earliest time to attempt a period reflow while fetching a page's objects.
int available_width
Viewport width.
nserror(* schedule)(int t, void(*callback)(void *p), void *p)
Schedule a callback.
Definition: misc.h:58
Context for retrieving a child object.
Definition: hlcache.h:37
bool quirks
Whether parent is quirky.
Definition: hlcache.h:39
const char * charset
Charset of parent.
Definition: hlcache.h:38
High-level cache event.
Definition: hlcache.h:43
content_msg type
Event type.
Definition: hlcache.h:44
union content_msg_data data
Event data.
Definition: hlcache.h:45
High-level cache handle.
Definition: hlcache.c:66
Data specific to CONTENT_HTML.
Definition: private.h:93
struct content_html_object * object_list
List of objects.
Definition: private.h:170
char * encoding
Encoding of source, NULL if unknown.
Definition: private.h:106
struct browser_window * bw
Browser window containing this document, or NULL if not open.
Definition: private.h:177
unsigned int num_objects
Number of entries in object_list.
Definition: private.h:168
struct html_content * page
Content of type CONTENT_HTML containing this, or NULL if not an object within a page.
Definition: private.h:187
struct content base
Definition: private.h:94
bool aborted
Content has been aborted in the LOADING state.
Definition: private.h:116
bool had_initial_layout
Whether an initial layout has been done.
Definition: private.h:125
css_unit_ctx unit_len_ctx
CSS length conversion context for document.
Definition: private.h:163
struct gui_misc_table * misc
Browser table.
Definition: gui_table.h:57
Extra data for some content_msg messages.
Definition: content.h:60
struct content_msg_data::@103 scroll
CONTENT_MSG_SCROLL - Part of content to scroll to show.
int x
Carret x-coord.
Definition: content.h:110
const struct rect * clip
Carret clip rect.
Definition: content.h:215
int delay
CONTENT_MSG_REFRESH - Minimum delay.
Definition: content.h:116
int height
Carret height.
Definition: content.h:110
struct content_msg_data::@107 caret
CONTENT_MSG_CARET - set caret position or, hide caret.
bool selection
false for selection cleared
Definition: content.h:198
struct hlcache_handle * content
if NULL, save the content generating the message
Definition: content.h:178
struct content_msg_data::@104 dragsave
CONTENT_MSG_DRAGSAVE - Drag save a content.
struct content_msg_data::@108 drag
CONTENT_MSG_DRAG - Drag start or end.
enum content_msg_data::@104::@112 type
int y
Carret y-coord.
Definition: content.h:110
const struct rect * rect
Definition: content.h:228
struct content_msg_data::@101 redraw
CONTENT_MSG_REDRAW - Area of content which needs redrawing.
struct content_msg_data::@107::@114 pos
With CONTENT_CARET_SET_POS.
For drags we don't own.
Definition: private.h:52
bool no_owner
Definition: private.h:53
struct box * content
Definition: private.h:54
For directing input.
Definition: private.h:84
struct box * content
Definition: private.h:87
For getting at selections in this content or things in this content.
Definition: private.h:69
struct box * content
Definition: private.h:72
Option reading and saving interface.
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Definition: nsoption.h:304