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