NetSurf
html_css.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 css operations.
22  */
23 
24 #include "utils/config.h"
25 
26 #define _GNU_SOURCE /* strcasestr needs this for string.h */
27 
28 #include <assert.h>
29 #include <ctype.h>
30 #include <stdint.h>
31 #include <string.h>
32 #include <strings.h>
33 #include <stdlib.h>
34 
35 #include "utils/nsoption.h"
36 #include "utils/corestrings.h"
37 #include "utils/log.h"
38 #include "netsurf/misc.h"
39 #include "netsurf/content.h"
40 #include "content/hlcache.h"
41 #include "css/css.h"
42 #include "desktop/gui_internal.h"
43 
44 #include "html/html.h"
45 #include "html/html_internal.h"
46 
51 
52 static nserror css_error_to_nserror(css_error error)
53 {
54  switch (error) {
55  case CSS_OK:
56  return NSERROR_OK;
57 
58  case CSS_NOMEM:
59  return NSERROR_NOMEM;
60 
61  case CSS_BADPARM:
62  return NSERROR_BAD_PARAMETER;
63 
64  case CSS_INVALID:
65  return NSERROR_INVALID;
66 
67  case CSS_FILENOTFOUND:
68  return NSERROR_NOT_FOUND;
69 
70  case CSS_NEEDDATA:
71  return NSERROR_NEED_DATA;
72 
73  case CSS_BADCHARSET:
74  return NSERROR_BAD_ENCODING;
75 
76  case CSS_EOF:
77  case CSS_IMPORTS_PENDING:
78  case CSS_PROPERTY_NOT_SET:
79  default:
80  break;
81  }
82  return NSERROR_CSS;
83 }
84 
85 /**
86  * Callback for fetchcache() for stylesheets.
87  */
88 
89 static nserror
91  const hlcache_event *event,
92  void *pw)
93 {
94  html_content *parent = pw;
95  unsigned int i;
96  struct html_stylesheet *s;
97 
98  /* Find sheet */
99  for (i = 0, s = parent->stylesheets;
100  i != parent->stylesheet_count;
101  i++, s++) {
102  if (s->sheet == css)
103  break;
104  }
105 
106  assert(i != parent->stylesheet_count);
107 
108  switch (event->type) {
109 
110  case CONTENT_MSG_DONE:
111  NSLOG(netsurf, INFO, "done stylesheet slot %d '%s'", i,
113  parent->base.active--;
114  NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
115  break;
116 
117  case CONTENT_MSG_ERROR:
118  NSLOG(netsurf, INFO, "stylesheet %s failed: %s",
120  event->data.errordata.errormsg);
121 
123  s->sheet = NULL;
124  parent->base.active--;
125  NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
126  content_add_error(&parent->base, "?", 0);
127  break;
128 
129  case CONTENT_MSG_POINTER:
130  /* Really don't want this to continue after the switch */
131  return NSERROR_OK;
132 
133  default:
134  break;
135  }
136 
137  if (html_can_begin_conversion(parent)) {
138  html_begin_conversion(parent);
139  }
140 
141  return NSERROR_OK;
142 }
143 
144 static nserror
146  dom_node *node,
148 {
149  hlcache_child_context child;
150  dom_string *style;
151  nsurl *url;
152  dom_exception exc;
153  nserror error;
154  uint32_t key;
155  char urlbuf[64];
156 
157  child.charset = c->encoding;
158  child.quirks = c->base.quirks;
159 
160  exc = dom_node_get_text_content(node, &style);
161  if ((exc != DOM_NO_ERR) || (style == NULL)) {
162  NSLOG(netsurf, INFO, "No text content");
163  return NSERROR_OK;
164  }
165 
166  error = html_css_fetcher_add_item(style, c->base_url, &key);
167  if (error != NSERROR_OK) {
168  dom_string_unref(style);
169  return error;
170  }
171 
172  dom_string_unref(style);
173 
174  snprintf(urlbuf, sizeof(urlbuf), "x-ns-css:%u", key);
175 
176  error = nsurl_create(urlbuf, &url);
177  if (error != NSERROR_OK) {
178  return error;
179  }
180 
181  error = hlcache_handle_retrieve(url, 0,
182  content_get_url(&c->base), NULL,
184  sheet);
185  if (error != NSERROR_OK) {
186  nsurl_unref(url);
187  return error;
188  }
189 
190  nsurl_unref(url);
191 
192  c->base.active++;
193  NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
194 
195  return NSERROR_OK;
196 }
197 
198 /**
199  * Process an inline stylesheet in the document.
200  *
201  * \param c content structure
202  * \param style xml node of style element
203  * \return true on success, false if an error occurred
204  */
205 
206 static struct html_stylesheet *
208 {
209  dom_string *val;
210  dom_exception exc;
211  struct html_stylesheet *stylesheets;
212 
213  /* type='text/css', or not present (invalid but common) */
214  exc = dom_element_get_attribute(style, corestring_dom_type, &val);
215  if (exc == DOM_NO_ERR && val != NULL) {
216  if (!dom_string_caseless_lwc_isequal(val,
217  corestring_lwc_text_css)) {
218  dom_string_unref(val);
219  return NULL;
220  }
221  dom_string_unref(val);
222  }
223 
224  /* media contains 'screen' or 'all' or not present */
225  exc = dom_element_get_attribute(style, corestring_dom_media, &val);
226  if (exc == DOM_NO_ERR && val != NULL) {
227  if (strcasestr(dom_string_data(val), "screen") == NULL &&
228  strcasestr(dom_string_data(val),
229  "all") == NULL) {
230  dom_string_unref(val);
231  return NULL;
232  }
233  dom_string_unref(val);
234  }
235 
236  /* Extend array */
237  stylesheets = realloc(c->stylesheets,
238  sizeof(struct html_stylesheet) *
239  (c->stylesheet_count + 1));
240  if (stylesheets == NULL) {
241 
243  return false;
244 
245  }
246  c->stylesheets = stylesheets;
247 
248  c->stylesheets[c->stylesheet_count].node = dom_node_ref(style);
249  c->stylesheets[c->stylesheet_count].sheet = NULL;
250  c->stylesheets[c->stylesheet_count].modified = false;
251  c->stylesheets[c->stylesheet_count].unused = false;
252  c->stylesheet_count++;
253 
254  return c->stylesheets + (c->stylesheet_count - 1);
255 }
256 
258  struct html_stylesheet *s)
259 {
260  hlcache_handle *sheet = NULL;
261  nserror error;
262 
263  error = html_stylesheet_from_domnode(c, s->node, &sheet);
264  if (error != NSERROR_OK) {
265  NSLOG(netsurf, INFO, "Failed to update sheet");
266  content_broadcast_error(&c->base, error, NULL);
267  return false;
268  }
269 
270  if (sheet != NULL) {
271  NSLOG(netsurf, INFO, "Updating sheet %p with %p", s->sheet,
272  sheet);
273 
274  if (s->sheet != NULL) {
275  switch (content_get_status(s->sheet)) {
276  case CONTENT_STATUS_DONE:
277  break;
278  default:
280  c->base.active--;
281  NSLOG(netsurf, INFO, "%d fetches active",
282  c->base.active);
283  }
285  }
286  s->sheet = sheet;
287  }
288 
289  s->modified = false;
290 
291  return true;
292 }
293 
294 static void html_css_process_modified_styles(void *pw)
295 {
296  html_content *c = pw;
297  struct html_stylesheet *s;
298  unsigned int i;
299  bool all_done = true;
300 
301  for (i = 0, s = c->stylesheets; i != c->stylesheet_count; i++, s++) {
302  if (c->stylesheets[i].modified) {
303  all_done &= html_css_process_modified_style(c, s);
304  }
305  }
306 
307  /* If we failed to process any sheet, schedule a retry */
308  if (all_done == false) {
310  }
311 }
312 
313 bool html_css_update_style(html_content *c, dom_node *style)
314 {
315  unsigned int i;
316  struct html_stylesheet *s;
317 
318  /* Find sheet */
319  for (i = 0, s = c->stylesheets; i != c->stylesheet_count; i++, s++) {
320  if (s->node == style)
321  break;
322  }
323  if (i == c->stylesheet_count) {
324  s = html_create_style_element(c, style);
325  }
326  if (s == NULL) {
327  NSLOG(netsurf, INFO,
328  "Could not find or create inline stylesheet for %p",
329  style);
330  return false;
331  }
332 
333  s->modified = true;
334 
336 
337  return true;
338 }
339 
341 {
342  unsigned int i;
343  dom_string *val;
344  dom_exception exc;
345  struct html_stylesheet *s;
346 
347  /* Find sheet */
348  for (i = 0, s = c->stylesheets; i != c->stylesheet_count; i++, s++) {
349  if (s->node == node)
350  break;
351  }
352 
353  /* Should already exist */
354  if (i == c->stylesheet_count) {
355  return false;
356  }
357 
358  exc = dom_element_get_attribute(node, corestring_dom_media, &val);
359  if (exc == DOM_NO_ERR && val != NULL) {
360  if (strcasestr(dom_string_data(val), "screen") == NULL &&
361  strcasestr(dom_string_data(val),
362  "all") == NULL) {
363  s->unused = true;
364  }
365  dom_string_unref(val);
366  }
367 
368  return true;
369 }
370 
371 bool html_css_process_link(html_content *htmlc, dom_node *node)
372 {
373  dom_string *rel, *type_attr, *media, *href;
374  struct html_stylesheet *stylesheets;
375  nsurl *joined;
376  dom_exception exc;
377  nserror ns_error;
378  hlcache_child_context child;
379 
380  /* rel=<space separated list, including 'stylesheet'> */
381  exc = dom_element_get_attribute(node, corestring_dom_rel, &rel);
382  if (exc != DOM_NO_ERR || rel == NULL)
383  return true;
384 
385  if (strcasestr(dom_string_data(rel), "stylesheet") == 0) {
386  dom_string_unref(rel);
387  return true;
388  } else if (strcasestr(dom_string_data(rel), "alternate") != 0) {
389  /* Ignore alternate stylesheets */
390  dom_string_unref(rel);
391  return true;
392  }
393  dom_string_unref(rel);
394 
395  /* type='text/css' or not present */
396  exc = dom_element_get_attribute(node, corestring_dom_type, &type_attr);
397  if (exc == DOM_NO_ERR && type_attr != NULL) {
398  if (!dom_string_caseless_lwc_isequal(type_attr,
399  corestring_lwc_text_css)) {
400  dom_string_unref(type_attr);
401  return true;
402  }
403  dom_string_unref(type_attr);
404  }
405 
406  /* media contains 'screen' or 'all' or not present */
407  exc = dom_element_get_attribute(node, corestring_dom_media, &media);
408  if (exc == DOM_NO_ERR && media != NULL) {
409  if (strcasestr(dom_string_data(media), "screen") == NULL &&
410  strcasestr(dom_string_data(media), "all") == NULL) {
411  dom_string_unref(media);
412  return true;
413  }
414  dom_string_unref(media);
415  }
416 
417  /* href='...' */
418  exc = dom_element_get_attribute(node, corestring_dom_href, &href);
419  if (exc != DOM_NO_ERR || href == NULL)
420  return true;
421 
422  /* TODO: only the first preferred stylesheets (ie.
423  * those with a title attribute) should be loaded
424  * (see HTML4 14.3) */
425 
426  ns_error = nsurl_join(htmlc->base_url, dom_string_data(href), &joined);
427  if (ns_error != NSERROR_OK) {
428  dom_string_unref(href);
429  goto no_memory;
430  }
431  dom_string_unref(href);
432 
433  NSLOG(netsurf, INFO, "linked stylesheet %i '%s'",
434  htmlc->stylesheet_count, nsurl_access(joined));
435 
436  /* extend stylesheets array to allow for new sheet */
437  stylesheets = realloc(htmlc->stylesheets,
438  sizeof(struct html_stylesheet) *
439  (htmlc->stylesheet_count + 1));
440  if (stylesheets == NULL) {
441  nsurl_unref(joined);
442  ns_error = NSERROR_NOMEM;
443  goto no_memory;
444  }
445 
446  htmlc->stylesheets = stylesheets;
447  htmlc->stylesheets[htmlc->stylesheet_count].node = NULL;
448  htmlc->stylesheets[htmlc->stylesheet_count].modified = false;
449  htmlc->stylesheets[htmlc->stylesheet_count].unused = false;
450 
451  /* start fetch */
452  child.charset = htmlc->encoding;
453  child.quirks = htmlc->base.quirks;
454 
455  ns_error = hlcache_handle_retrieve(joined, 0,
456  content_get_url(&htmlc->base),
458  htmlc, &child, CONTENT_CSS,
459  &htmlc->stylesheets[htmlc->stylesheet_count].sheet);
460 
461  nsurl_unref(joined);
462 
463  if (ns_error != NSERROR_OK)
464  goto no_memory;
465 
466  htmlc->stylesheet_count++;
467 
468  htmlc->base.active++;
469  NSLOG(netsurf, INFO, "%d fetches active", htmlc->base.active);
470 
471  return true;
472 
473 no_memory:
474  content_broadcast_error(&htmlc->base, ns_error, NULL);
475  return false;
476 }
477 
478 /* exported interface documented in html/html.h */
480 {
482 
483  assert(c != NULL);
484  assert(n != NULL);
485 
486  *n = c->stylesheet_count;
487 
488  return c->stylesheets;
489 }
490 
491 /* exported interface documented in html/html_internal.h */
493 {
494  struct html_stylesheet *s;
495  unsigned int i;
496 
497  for (i = 0, s = html->stylesheets; i < html->stylesheet_count;
498  i++, s++) {
499  if (s->sheet != NULL) {
501  return true;
502  }
503  }
504  }
505 
506  return false;
507 }
508 
509 /* exported interface documented in html/html_internal.h */
511 {
512  unsigned int i;
513 
515 
516  for (i = 0; i != html->stylesheet_count; i++) {
517  if (html->stylesheets[i].sheet != NULL) {
519  }
520  if (html->stylesheets[i].node != NULL) {
521  dom_node_unref(html->stylesheets[i].node);
522  }
523  }
524  free(html->stylesheets);
525 
526  return NSERROR_OK;
527 }
528 
529 /* exported interface documented in html/html_internal.h */
531 {
532  nserror ns_error = NSERROR_OK;
533  hlcache_child_context child;
534 
535  assert(c->stylesheets != NULL);
536 
537  if (c->quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL) {
538  child.charset = c->encoding;
539  child.quirks = c->base.quirks;
540 
542  0, content_get_url(&c->base), NULL,
543  html_convert_css_callback, c, &child,
544  CONTENT_CSS,
546  if (ns_error != NSERROR_OK) {
547  return ns_error;
548  }
549 
550  c->base.active++;
551  NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
552  }
553 
554  return ns_error;
555 }
556 
557 /* exported interface documented in html/html_internal.h */
559 {
560  nserror ns_error;
561  hlcache_child_context child;
562 
563  if (c->stylesheets != NULL) {
564  return NSERROR_OK; /* already initialised */
565  }
566 
567  /* stylesheet 0 is the base style sheet,
568  * stylesheet 1 is the quirks mode style sheet,
569  * stylesheet 2 is the adblocking stylesheet,
570  * stylesheet 3 is the user stylesheet */
571  c->stylesheets = calloc(STYLESHEET_START,
572  sizeof(struct html_stylesheet));
573  if (c->stylesheets == NULL) {
574  return NSERROR_NOMEM;
575  }
576 
577  c->stylesheets[STYLESHEET_BASE].sheet = NULL;
580  c->stylesheets[STYLESHEET_USER].sheet = NULL;
582 
583  child.charset = c->encoding;
584  child.quirks = c->base.quirks;
585 
587  content_get_url(&c->base), NULL,
590  if (ns_error != NSERROR_OK) {
591  return ns_error;
592  }
593 
594  c->base.active++;
595  NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
596 
597 
598  if (nsoption_bool(block_advertisements)) {
600  0, content_get_url(&c->base), NULL,
602  c, &child, CONTENT_CSS,
604  if (ns_error != NSERROR_OK) {
605  return ns_error;
606  }
607 
608  c->base.active++;
609  NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
610 
611  }
612 
614  content_get_url(&c->base), NULL,
617  if (ns_error != NSERROR_OK) {
618  return ns_error;
619  }
620 
621  c->base.active++;
622  NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
623 
624  return ns_error;
625 }
626 
627 nserror
628 html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx)
629 {
630  uint32_t i;
631  css_error css_ret;
632  css_select_ctx *select_ctx;
633 
634  /* check that the base stylesheet loaded; layout fails without it */
635  if (c->stylesheets[STYLESHEET_BASE].sheet == NULL) {
636  return NSERROR_CSS_BASE;
637  }
638 
639  /* Create selection context */
640  css_ret = css_select_ctx_create(&select_ctx);
641  if (css_ret != CSS_OK) {
642  return css_error_to_nserror(css_ret);
643  }
644 
645  /* Add sheets to it */
646  for (i = STYLESHEET_BASE; i != c->stylesheet_count; i++) {
647  const struct html_stylesheet *hsheet = &c->stylesheets[i];
648  css_stylesheet *sheet = NULL;
649  css_origin origin = CSS_ORIGIN_AUTHOR;
650 
651  /* Filter out stylesheets for non-screen media. */
652  /* TODO: We should probably pass the sheet in anyway, and let
653  * libcss handle the filtering.
654  */
655  if (hsheet->unused) {
656  continue;
657  }
658 
659  if (i < STYLESHEET_USER) {
660  origin = CSS_ORIGIN_UA;
661  } else if (i < STYLESHEET_START) {
662  origin = CSS_ORIGIN_USER;
663  }
664 
665  if (hsheet->sheet != NULL) {
666  sheet = nscss_get_stylesheet(hsheet->sheet);
667  }
668 
669  if (sheet != NULL) {
670  /* TODO: Pass the sheet's full media query, instead of
671  * "screen".
672  */
673  css_ret = css_select_ctx_append_sheet(select_ctx,
674  sheet,
675  origin,
676  "screen");
677  if (css_ret != CSS_OK) {
678  css_select_ctx_destroy(select_ctx);
679  return css_error_to_nserror(css_ret);
680  }
681  }
682  }
683 
684  /* return new selection context to caller */
685  *ret_select_ctx = select_ctx;
686  return NSERROR_OK;
687 }
688 
690 {
691  nserror error;
692 
693  error = html_css_fetcher_register();
694  if (error != NSERROR_OK)
695  return error;
696 
697  error = nsurl_create("resource:default.css",
699  if (error != NSERROR_OK)
700  return error;
701 
702  error = nsurl_create("resource:adblock.css",
704  if (error != NSERROR_OK)
705  return error;
706 
707  error = nsurl_create("resource:quirks.css",
709  if (error != NSERROR_OK)
710  return error;
711 
712  error = nsurl_create("resource:user.css",
714 
715  return error;
716 }
717 
718 void html_css_fini(void)
719 {
720  if (html_user_stylesheet_url != NULL) {
723  }
724 
725  if (html_quirks_stylesheet_url != NULL) {
728  }
729 
730  if (html_adblock_stylesheet_url != NULL) {
733  }
734 
735  if (html_default_stylesheet_url != NULL) {
738  }
739 }
bool quirks
Whether parent is quirky.
Definition: hlcache.h:39
High-level cache event.
Definition: hlcache.h:43
bool unused
Definition: html.h:62
struct content base
Definition: html_internal.h:94
nserror html_css_fetcher_register(void)
Register the fetcher for the pseudo x-ns-css scheme.
struct content_msg_data::@104 errordata
CONTENT_MSG_ERROR - Error from content or underlying fetch.
Interface to utility string handling.
union content_msg_data data
Event data.
Definition: hlcache.h:45
content_msg type
Event type.
Definition: hlcache.h:44
Public content interface.
Interface to text/html content handler.
Memory exhaustion.
Definition: errors.h:32
struct html_stylesheet * stylesheets
Stylesheets.
bool quirks
Content is in quirks mode.
Context for retrieving a child object.
Definition: hlcache.h:37
bool html_begin_conversion(html_content *htmlc)
Begin conversion of an HTML document.
Definition: html.c:1460
static void html_css_process_modified_styles(void *pw)
Definition: html_css.c:294
Interface to platform-specific miscellaneous browser operation table.
static bool html_css_process_modified_style(html_content *c, struct html_stylesheet *s)
Definition: html_css.c:257
nserror html_css_init(void)
Definition: html_css.c:689
nserror html_css_free_stylesheets(html_content *html)
Definition: html_css.c:510
void content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
Send an error message to all users.
Definition: content.c:859
High-level resource cache interface.
bool html_css_process_style(html_content *c, dom_node *node)
Definition: html_css.c:340
static nsurl * html_user_stylesheet_url
Definition: html_css.c:50
The character set is unknown.
Definition: errors.h:45
#define STYLESHEET_ADBLOCK
Definition: html.h:150
Option reading and saving interface.
Invalid data.
Definition: errors.h:49
nserror
Enumeration of error codes.
Definition: errors.h:29
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
Definition: content.c:1172
struct gui_misc_table * misc
Browser table.
Definition: gui_table.h:57
static nserror css_error_to_nserror(css_error error)
Definition: html_css.c:52
High-level cache handle.
Definition: hlcache.c:64
nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
Join a base url to a relative link part, creating a new NetSurf URL object.
CSS base sheet failed.
Definition: errors.h:54
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
Useful interned string pointers (interface).
#define STYLESHEET_QUIRKS
Definition: html.h:149
Private data for text/html content.
const char * charset
Charset of parent.
Definition: hlcache.h:38
CSS call returned error.
Definition: errors.h:53
No error.
Definition: errors.h:30
All finished.
Definition: content.h:55
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:115
Requested item not found.
Definition: errors.h:34
const char * errormsg
The message.
Definition: content.h:137
struct nsurl * hlcache_handle_get_url(const struct hlcache_handle *handle)
Retrieve the URL associated with a high level cache handle.
struct hlcache_handle * sheet
Definition: html.h:60
nserror html_css_quirks_stylesheets(html_content *c)
Definition: html_css.c:530
unsigned int active
Number of child fetches or conversions currently in progress.
content_status content_get_status(hlcache_handle *h)
Retrieve status of content.
Definition: content.c:1243
bool content_saw_insecure_objects(struct hlcache_handle *h)
Determine if the content referred to any insecure objects.
Definition: content.c:569
wimp_w parent
Definition: dialog.c:87
struct content * hlcache_handle_get_content(const hlcache_handle *handle)
Retrieve a content object from a cache handle.
Definition: hlcache.c:769
static nserror html_stylesheet_from_domnode(html_content *c, dom_node *node, hlcache_handle **sheet)
Definition: html_css.c:145
static nsurl * html_adblock_stylesheet_url
Definition: html_css.c:48
struct html_stylesheet * html_get_stylesheets(hlcache_handle *h, unsigned int *n)
Retrieve stylesheets used by HTML document.
Definition: html_css.c:479
static nsurl * html_quirks_stylesheet_url
Definition: html_css.c:49
#define STYLESHEET_USER
Definition: html.h:151
Bad Parameter.
Definition: errors.h:48
finished
Definition: content.h:66
nserror(* schedule)(int t, void(*callback)(void *p), void *p)
Schedule a callback.
Definition: misc.h:58
void html_css_fini(void)
Definition: html_css.c:718
#define STYLESHEET_START
Definition: html.h:152
static nserror html_convert_css_callback(hlcache_handle *css, const hlcache_event *event, void *pw)
Callback for fetchcache() for stylesheets.
Definition: html_css.c:90
static struct html_stylesheet * html_create_style_element(html_content *c, dom_node *style)
Process an inline stylesheet in the document.
Definition: html_css.c:207
static nsurl * html_default_stylesheet_url
Definition: html_css.c:47
Container for stylesheets used by an HTML document.
Definition: html.h:58
char * strcasestr(const char *haystack, const char *needle)
Case insensitive strstr implementation.
Definition: utils.c:310
error occurred
Definition: content.h:67
nsurl * base_url
Base URL (may be a copy of content->url).
nserror hlcache_handle_abort(hlcache_handle *handle)
Abort a high-level cache fetch.
Definition: hlcache.c:779
nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url, uint32_t *key)
bool html_css_process_link(html_content *htmlc, dom_node *node)
Definition: html_css.c:371
unsigned int stylesheet_count
Number of entries in stylesheet_content.
bool html_css_update_style(html_content *c, dom_node *style)
Definition: html_css.c:313
nserror html_css_new_stylesheets(html_content *c)
Initialise core stylesheets for a content.
Definition: html_css.c:558
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
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
nserror html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx)
Definition: html_css.c:628
char * encoding
Encoding of source, NULL if unknown.
content is CSS
Definition: content_type.h:54
Wants a specific mouse pointer set.
Definition: content.h:80
void content_add_error(struct content *c, const char *token, unsigned int line)
Definition: content.c:1071
Data specific to CONTENT_HTML.
Definition: html_internal.h:93
More data needed.
Definition: errors.h:46
Interface to core interface table.
dom_document_quirks_mode quirks
Quirkyness of document.
#define STYLESHEET_BASE
Definition: html.h:148
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 dom_node * node
dom node associated with sheet
Definition: html.h:59
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
bool html_can_begin_conversion(html_content *htmlc)
Test if an HTML content conversion can begin.
Definition: html.c:1441
bool html_saw_insecure_stylesheets(html_content *html)
Return if any of the stylesheets were loaded insecurely.
Definition: html_css.c:492
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Definition: nsoption.h:270
bool modified
Definition: html.h:61
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
css_stylesheet * nscss_get_stylesheet(struct hlcache_handle *h)
Retrieve the stylesheet object associated with a CSS content.
Definition: css.c:431