67 case CSS_FILENOTFOUND:
77 case CSS_IMPORTS_PENDING:
78 case CSS_PROPERTY_NOT_SET:
108 switch (event->
type) {
111 NSLOG(netsurf, INFO,
"done stylesheet slot %d '%s'", i,
118 NSLOG(netsurf, INFO,
"stylesheet %s failed: %s",
160 exc = dom_node_get_text_content(node, &style);
161 if ((exc != DOM_NO_ERR) || (style == NULL)) {
162 NSLOG(netsurf, INFO,
"No text content");
168 dom_string_unref(style);
172 dom_string_unref(style);
174 snprintf(urlbuf,
sizeof(urlbuf),
"x-ns-css:%u", key);
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);
221 dom_string_unref(val);
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 &&
230 dom_string_unref(val);
233 dom_string_unref(val);
240 if (stylesheets == NULL) {
265 NSLOG(netsurf, INFO,
"Failed to update sheet");
271 NSLOG(netsurf, INFO,
"Updating sheet %p with %p", s->
sheet,
274 if (s->
sheet != NULL) {
281 NSLOG(netsurf, INFO,
"%d fetches active",
299 bool all_done =
true;
308 if (all_done ==
false) {
320 if (s->
node == style)
328 "Could not find or create inline stylesheet for %p",
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 &&
365 dom_string_unref(val);
373 dom_string *rel, *type_attr, *media, *href;
381 exc = dom_element_get_attribute(node, corestring_dom_rel, &rel);
382 if (exc != DOM_NO_ERR || rel == NULL)
385 if (
strcasestr(dom_string_data(rel),
"stylesheet") == 0) {
386 dom_string_unref(rel);
388 }
else if (
strcasestr(dom_string_data(rel),
"alternate") != 0) {
390 dom_string_unref(rel);
393 dom_string_unref(rel);
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);
403 dom_string_unref(type_attr);
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);
414 dom_string_unref(media);
418 exc = dom_element_get_attribute(node, corestring_dom_href, &href);
419 if (exc != DOM_NO_ERR || href == NULL)
428 dom_string_unref(href);
431 dom_string_unref(href);
433 NSLOG(netsurf, INFO,
"linked stylesheet %i '%s'",
440 if (stylesheets == NULL) {
497 for (i = 0, s = html->
stylesheets; i < html->stylesheet_count;
499 if (s->
sheet != NULL) {
537 if (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL) {
632 css_select_ctx *select_ctx;
640 css_ret = css_select_ctx_create(&select_ctx);
641 if (css_ret != CSS_OK) {
648 css_stylesheet *
sheet = NULL;
649 css_origin origin = CSS_ORIGIN_AUTHOR;
660 origin = CSS_ORIGIN_UA;
662 origin = CSS_ORIGIN_USER;
665 if (hsheet->
sheet != NULL) {
673 css_ret = css_select_ctx_append_sheet(select_ctx,
677 if (css_ret != CSS_OK) {
678 css_select_ctx_destroy(select_ctx);
685 *ret_select_ctx = select_ctx;
bool quirks
Whether parent is quirky.
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.
content_msg type
Event type.
Public content interface.
Interface to text/html content handler.
struct html_stylesheet * stylesheets
Stylesheets.
bool quirks
Content is in quirks mode.
Context for retrieving a child object.
bool html_begin_conversion(html_content *htmlc)
Begin conversion of an HTML document.
static void html_css_process_modified_styles(void *pw)
Interface to platform-specific miscellaneous browser operation table.
static bool html_css_process_modified_style(html_content *c, struct html_stylesheet *s)
nserror html_css_init(void)
nserror html_css_free_stylesheets(html_content *html)
void content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
Send an error message to all users.
High-level resource cache interface.
bool html_css_process_style(html_content *c, dom_node *node)
static nsurl * html_user_stylesheet_url
The character set is unknown.
#define STYLESHEET_ADBLOCK
Option reading and saving interface.
nserror
Enumeration of error codes.
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
struct gui_misc_table * misc
Browser table.
static nserror css_error_to_nserror(css_error error)
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.
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
Private data for text/html content.
const char * charset
Charset of parent.
#define NSLOG(catname, level, logmsg, args...)
Requested item not found.
const char * errormsg
The message.
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
nserror html_css_quirks_stylesheets(html_content *c)
unsigned int active
Number of child fetches or conversions currently in progress.
content_status content_get_status(hlcache_handle *h)
Retrieve status of content.
bool content_saw_insecure_objects(struct hlcache_handle *h)
Determine if the content referred to any insecure objects.
struct content * hlcache_handle_get_content(const hlcache_handle *handle)
Retrieve a content object from a cache handle.
static nserror html_stylesheet_from_domnode(html_content *c, dom_node *node, hlcache_handle **sheet)
static nsurl * html_adblock_stylesheet_url
struct html_stylesheet * html_get_stylesheets(hlcache_handle *h, unsigned int *n)
Retrieve stylesheets used by HTML document.
static nsurl * html_quirks_stylesheet_url
nserror(* schedule)(int t, void(*callback)(void *p), void *p)
Schedule a callback.
static nserror html_convert_css_callback(hlcache_handle *css, const hlcache_event *event, void *pw)
Callback for fetchcache() for stylesheets.
static struct html_stylesheet * html_create_style_element(html_content *c, dom_node *style)
Process an inline stylesheet in the document.
static nsurl * html_default_stylesheet_url
Container for stylesheets used by an HTML document.
char * strcasestr(const char *haystack, const char *needle)
Case insensitive strstr implementation.
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.
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)
unsigned int stylesheet_count
Number of entries in stylesheet_content.
bool html_css_update_style(html_content *c, dom_node *style)
nserror html_css_new_stylesheets(html_content *c)
Initialise core stylesheets for a content.
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.
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)
char * encoding
Encoding of source, NULL if unknown.
Wants a specific mouse pointer set.
void content_add_error(struct content *c, const char *token, unsigned int line)
Data specific to CONTENT_HTML.
Interface to core interface table.
dom_document_quirks_mode quirks
Quirkyness of document.
nserror hlcache_handle_release(hlcache_handle *handle)
Release a high-level cache handle.
struct netsurf_table * guit
The global interface table.
struct dom_node * node
dom node associated with sheet
struct nsurl nsurl
NetSurf URL object.
bool html_can_begin_conversion(html_content *htmlc)
Test if an HTML content conversion can begin.
bool html_saw_insecure_stylesheets(html_content *html)
Return if any of the stylesheets were loaded insecurely.
#define nsoption_bool(OPTION)
Get the value of a boolean option.
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.