70 case CSS_FILENOTFOUND:
80 case CSS_IMPORTS_PENDING:
81 case CSS_PROPERTY_NOT_SET:
102 for (i = 0, s =
parent->stylesheets;
103 i !=
parent->stylesheet_count;
109 assert(i !=
parent->stylesheet_count);
111 switch (event->
type) {
114 NSLOG(netsurf, INFO,
"done stylesheet slot %d '%s'", i,
117 NSLOG(netsurf, INFO,
"%d fetches active",
parent->base.active);
121 NSLOG(netsurf, INFO,
"stylesheet %s failed: %s",
128 NSLOG(netsurf, INFO,
"%d fetches active",
parent->base.active);
163 exc = dom_node_get_text_content(
node, &style);
164 if ((exc != DOM_NO_ERR) || (style == NULL)) {
165 NSLOG(netsurf, INFO,
"No text content");
171 dom_string_unref(style);
175 dom_string_unref(style);
177 snprintf(urlbuf,
sizeof(urlbuf),
"x-ns-css:%"PRIu32
"", key);
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);
224 dom_string_unref(val);
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 &&
233 dom_string_unref(val);
236 dom_string_unref(val);
243 if (stylesheets == NULL) {
269 NSLOG(netsurf, INFO,
"Failed to update sheet");
275 NSLOG(netsurf, INFO,
"Updating sheet %p with %p", s->
sheet,
278 if (s->
sheet != NULL) {
285 NSLOG(netsurf, INFO,
"%d fetches active",
307 bool all_done =
true;
316 if (all_done ==
false) {
330 if (s->
node == style)
338 "Could not find or create inline stylesheet for %p",
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 &&
377 dom_string_unref(val);
387 dom_string *rel, *type_attr, *media, *href;
395 exc = dom_element_get_attribute(
node, corestring_dom_rel, &rel);
396 if (exc != DOM_NO_ERR || rel == NULL)
399 if (
strcasestr(dom_string_data(rel),
"stylesheet") == NULL) {
400 dom_string_unref(rel);
402 }
else if (
strcasestr(dom_string_data(rel),
"alternate") != NULL) {
404 dom_string_unref(rel);
407 dom_string_unref(rel);
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);
421 dom_string_unref(type_attr);
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);
432 dom_string_unref(media);
436 exc = dom_element_get_attribute(
node, corestring_dom_href, &href);
437 if (exc != DOM_NO_ERR || href == NULL)
446 dom_string_unref(href);
449 dom_string_unref(href);
451 NSLOG(netsurf, INFO,
"linked stylesheet %i '%s'",
458 if (stylesheets == NULL) {
517 for (i = 0, s = html->
stylesheets; i < html->stylesheet_count;
519 if (s->
sheet != NULL) {
559 if (c->
quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL) {
657 css_select_ctx *select_ctx;
665 css_ret = css_select_ctx_create(&select_ctx);
666 if (css_ret != CSS_OK) {
673 css_stylesheet *
sheet = NULL;
674 css_origin origin = CSS_ORIGIN_AUTHOR;
685 origin = CSS_ORIGIN_UA;
687 origin = CSS_ORIGIN_USER;
690 if (hsheet->
sheet != NULL) {
698 css_ret = css_select_ctx_append_sheet(select_ctx,
702 if (css_ret != CSS_OK) {
703 css_select_ctx_destroy(select_ctx);
710 *ret_select_ctx = select_ctx;
char * strcasestr(const char *haystack, const char *needle)
Case insensitive strstr implementation.
HTML content handler CSS interface.
bool content_saw_insecure_objects(struct hlcache_handle *h)
Determine if the content referred to any insecure objects.
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
content_status content_get_status(hlcache_handle *h)
Retrieve status of content.
void content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
Send an error message to all users.
@ CONTENT_STATUS_DONE
Content has completed all processing.
@ CONTENT_CSS
content is CSS
@ CONTENT_MSG_DONE
content has finished processing
@ CONTENT_MSG_ERROR
error occurred
@ CONTENT_MSG_POINTER
Wants a specific mouse pointer set.
Useful interned string pointers (interface).
css_stylesheet * nscss_get_stylesheet(struct hlcache_handle *h)
Retrieve the stylesheet object associated with a CSS content.
nserror html_css_fetcher_register(void)
Register the fetcher for the pseudo x-ns-css scheme.
nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url, uint32_t *key)
nserror
Enumeration of error codes.
@ NSERROR_CSS_BASE
CSS base sheet failed.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_BAD_ENCODING
The character set is unknown.
@ NSERROR_BAD_PARAMETER
Bad Parameter.
@ NSERROR_NEED_DATA
More data needed.
@ NSERROR_CSS
CSS call returned error.
@ NSERROR_INVALID
Invalid data.
@ NSERROR_NOMEM
Memory exhaustion.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
struct content * hlcache_handle_get_content(const hlcache_handle *handle)
Retrieve a content object from a cache handle.
nserror hlcache_handle_abort(hlcache_handle *handle)
Abort a high-level cache fetch.
nserror hlcache_handle_release(hlcache_handle *handle)
Release a high-level cache handle.
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.
High-level resource cache interface.
nserror html_css_init(void)
Initialise html content css handling.
static void html_css_process_modified_styles(void *pw)
process a stylesheet that has been modified.
static bool html_css_process_modified_style(html_content *c, struct html_stylesheet *s)
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.
static nsurl * html_user_stylesheet_url
void html_css_fini(void)
Finalise html content css handling.
bool html_css_saw_insecure_stylesheets(html_content *html)
determine if any of the stylesheets were loaded insecurely
static nsurl * html_default_stylesheet_url
static nsurl * html_quirks_stylesheet_url
static nserror html_convert_css_callback(hlcache_handle *css, const hlcache_event *event, void *pw)
Callback for fetchcache() for stylesheets.
nserror html_css_free_stylesheets(html_content *html)
Free all css stylesheets associated with an HTML content.
bool html_css_process_style(html_content *c, dom_node *node)
process a css style dom node
nserror html_css_new_stylesheets(html_content *c)
Initialise core stylesheets for a content.
bool html_css_process_link(html_content *htmlc, dom_node *node)
process a css stylesheet dom LINK node
bool html_css_update_style(html_content *c, dom_node *style)
process a css style dom node update
static nsurl * html_adblock_stylesheet_url
nserror html_css_quirks_stylesheets(html_content *c)
Initialise quirk stylesheets for a content.
struct html_stylesheet * html_get_stylesheets(hlcache_handle *h, unsigned int *n)
Retrieve stylesheets used by HTML document.
static nserror css_error_to_nserror(css_error error)
Convert css error to netsurf error.
static struct html_stylesheet * html_create_style_element(html_content *c, dom_node *style)
Process an inline stylesheet in the document.
static nserror html_stylesheet_from_domnode(html_content *c, dom_node *node, hlcache_handle **sheet)
bool html_begin_conversion(html_content *htmlc)
Begin conversion of an HTML document.
bool html_can_begin_conversion(html_content *htmlc)
Test if an HTML content conversion can begin.
Interface to text/html content handler.
#define STYLESHEET_QUIRKS
#define STYLESHEET_ADBLOCK
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...)
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.
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.
Context for retrieving a child object.
bool quirks
Whether parent is quirky.
const char * charset
Charset of parent.
content_msg type
Event type.
union content_msg_data data
Event data.
Data specific to CONTENT_HTML.
dom_document_quirks_mode quirks
Quirkyness of document.
char * encoding
Encoding of source, NULL if unknown.
struct nsurl * base_url
Base URL (may be a copy of content->url).
struct html_stylesheet * stylesheets
Stylesheets.
unsigned int stylesheet_count
Number of entries in stylesheet_content.
Container for stylesheets used by an HTML document.
struct dom_node * node
dom node associated with sheet
struct hlcache_handle * sheet
struct gui_misc_table * misc
Browser table.
struct content_msg_data::@99 errordata
CONTENT_MSG_ERROR - Error from content or underlying fetch.
const char * errormsg
The message.
Option reading and saving interface.
#define nsoption_bool(OPTION)
Get the value of a boolean option.