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