NetSurf
|
#include <string.h>
#include <assert.h>
#include <libwapcaplet/libwapcaplet.h>
#include <dom/dom.h>
#include "utils/errors.h"
#include "utils/corestrings.h"
#include "utils/utils.h"
#include "utils/http.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "content/content_protected.h"
#include "content/content_factory.h"
#include "content/fetch.h"
#include "content/hlcache.h"
#include "desktop/system_colour.h"
#include "css/css.h"
#include "css/hints.h"
#include "css/internal.h"
Go to the source code of this file.
Data Structures | |
struct | content_css_data |
CSS content data. More... | |
struct | nscss_content |
CSS content data. More... | |
struct | nscss_import_ctx |
Context for import fetches. More... | |
Typedefs | |
typedef void(* | nscss_done_callback) (struct content_css_data *css, void *pw) |
Type of callback called when a CSS object has finished. More... | |
typedef struct nscss_content | nscss_content |
CSS content data. More... | |
Functions | |
static bool | nscss_convert (struct content *c) |
Convert a CSS content ready for use. More... | |
static void | nscss_destroy (struct content *c) |
Clean up a CSS content. More... | |
static nserror | nscss_clone (const struct content *old, struct content **newc) |
static bool | nscss_matches_quirks (const struct content *c, bool quirks) |
static content_type | nscss_content_type (void) |
Compute the type of a content. More... | |
static nserror | nscss_create_css_data (struct content_css_data *c, const char *url, const char *charset, bool quirks, nscss_done_callback done, void *pw) |
Create a struct content_css_data, creating a stylesheet object. More... | |
static css_error | nscss_process_css_data (struct content_css_data *c, const char *data, unsigned int size) |
Process CSS data. More... | |
static css_error | nscss_convert_css_data (struct content_css_data *c) |
Convert CSS data ready for use. More... | |
static void | nscss_destroy_css_data (struct content_css_data *c) |
Clean up CSS data. More... | |
static void | nscss_content_done (struct content_css_data *css, void *pw) |
Handle notification that a CSS object is done. More... | |
static css_error | nscss_handle_import (void *pw, css_stylesheet *parent, lwc_string *url) |
Handle notification of the need for an imported stylesheet. More... | |
static nserror | nscss_import (hlcache_handle *handle, const hlcache_event *event, void *pw) |
Handler for imported stylesheet events. More... | |
static css_error | nscss_import_complete (nscss_import_ctx *ctx) |
Handle an imported stylesheet completing. More... | |
static css_error | nscss_register_imports (struct content_css_data *c) |
Register imports with a stylesheet. More... | |
static css_error | nscss_register_import (struct content_css_data *c, const hlcache_handle *import) |
Register an import with a stylesheet. More... | |
static nserror | nscss_create (const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) |
Initialise a CSS content. More... | |
static bool | nscss_process_data (struct content *c, const char *data, unsigned int size) |
Process CSS source data. More... | |
css_stylesheet * | nscss_get_stylesheet (struct hlcache_handle *h) |
Retrieve the stylesheet object associated with a CSS content. More... | |
struct nscss_import * | nscss_get_imports (hlcache_handle *h, uint32_t *n) |
Retrieve imported stylesheets. More... | |
static void | nscss_fini (void) |
Clean up after the CSS content handler. More... | |
nserror | nscss_init (void) |
Initialise the CSS content handler. More... | |
Variables | |
css_fixed | nscss_screen_dpi = F_90 |
Screen DPI in fixed point units: defaults to 90, which RISC OS uses. More... | |
static css_stylesheet * | blank_import |
static const content_handler | css_content_handler |
typedef struct nscss_content nscss_content |
CSS content data.
typedef void(* nscss_done_callback) (struct content_css_data *css, void *pw) |
Definition at line 378 of file css.c.
References nscss_content::base, content_css_data::charset, content__clone(), content__get_source_data(), content_destroy(), content_get_url(), CONTENT_STATUS_DONE, CONTENT_STATUS_READY, nscss_content::data, nscss_content_done(), nscss_convert(), nscss_create_css_data(), nscss_process_data(), NSERROR_CLONE_FAILED, NSERROR_NOMEM, NSERROR_OK, nsurl_access(), content::quirks, content::size, and content::status.
|
static |
Handle notification that a CSS object is done.
css | CSS object |
pw | Private data |
Definition at line 479 of file css.c.
References nscss_import::c, content_broadcast_error(), content_set_done(), content_set_error(), content_set_ready(), hlcache_handle_get_content(), content_css_data::import_count, content_css_data::imports, NSERROR_CSS, content_css_data::sheet, and content::size.
Referenced by nscss_clone(), and nscss_create().
|
static |
Compute the type of a content.
Definition at line 464 of file css.c.
References CONTENT_CSS.
|
static |
Convert a CSS content ready for use.
c | Content to convert |
Definition at line 287 of file css.c.
References content_broadcast_error(), nscss_content::data, nscss_convert_css_data(), and NSERROR_CSS.
Referenced by nscss_clone().
|
static |
Convert CSS data ready for use.
c | CSS data to convert |
Definition at line 307 of file css.c.
References content_css_data::done, content_css_data::next_to_register, nscss_register_imports(), NSLOG, content_css_data::pw, and content_css_data::sheet.
Referenced by nscss_convert().
|
static |
Initialise a CSS content.
handler | content handler |
imime_type | mime-type |
params | Content-Type parameters |
llcache | handle to content |
fallback_charset | The character set to fallback to. |
quirks | allow quirks |
c | Content to initialise |
Definition at line 131 of file css.c.
References content_css_data::charset, content__init(), content_broadcast_error(), content_get_url(), http_parameter_list_find_item(), llcache, llcache_handle_get_header(), nscss_content_done(), nscss_create_css_data(), NSERROR_NOMEM, NSERROR_OK, nsurl_access(), and result.
|
static |
Create a struct content_css_data, creating a stylesheet object.
c | Struct to populate |
url | URL of stylesheet |
charset | Stylesheet charset |
quirks | Stylesheet quirks mode |
done | Callback to call when content has completed |
pw | Client data for done |
Definition at line 203 of file css.c.
References content_css_data::charset, content_css_data::done, content_css_data::import_count, content_css_data::imports, content_css_data::next_to_register, ns_system_colour(), nscss_handle_import(), nscss_resolve_url(), NSERROR_NOMEM, NSERROR_OK, content_css_data::pw, content::quirks, and content_css_data::sheet.
Referenced by nscss_clone(), and nscss_create().
|
static |
Clean up a CSS content.
c | Content to clean up |
Definition at line 345 of file css.c.
References nscss_content::data, and nscss_destroy_css_data().
|
static |
Clean up CSS data.
c | CSS data to clean up |
Definition at line 357 of file css.c.
References nscss_import::c, content_css_data::charset, hlcache_handle_release(), content_css_data::import_count, content_css_data::imports, and content_css_data::sheet.
Referenced by nscss_destroy().
|
static |
Clean up after the CSS content handler.
Definition at line 794 of file css.c.
References blank_import, and css_hint_fini().
Referenced by nscss_init().
struct nscss_import * nscss_get_imports | ( | struct hlcache_handle * | h, |
uint32_t * | n | ||
) |
Retrieve imported stylesheets.
h | Stylesheet containing imports |
n | Pointer to location to receive number of imports |
Definition at line 447 of file css.c.
References nscss_import::c, and hlcache_handle_get_content().
Referenced by save_complete_save_stylesheet().
css_stylesheet * nscss_get_stylesheet | ( | struct hlcache_handle * | h | ) |
Retrieve the stylesheet object associated with a CSS content.
h | Stylesheet content |
Definition at line 437 of file css.c.
References nscss_content::data, hlcache_handle_get_content(), and content_css_data::sheet.
Referenced by html_css_new_selection_context().
|
static |
Handle notification of the need for an imported stylesheet.
pw | CSS object requesting the import |
parent | Stylesheet requesting the import |
url | URL of the imported sheet |
Definition at line 524 of file css.c.
References nscss_import::c, hlcache_child_context::charset, CONTENT_CSS, nscss_import_ctx::css, hlcache_handle_retrieve(), nscss_import_ctx::index, NSERROR_OK, NSLOG, nsurl_compare(), NSURL_COMPLETE, nsurl_create(), nsurl_unref(), parent, content_css_data::pw, and hlcache_child_context::quirks.
Referenced by nscss_create_css_data().
|
static |
Handler for imported stylesheet events.
handle | Handle for stylesheet |
event | Event object |
pw | Callback context |
Definition at line 626 of file css.c.
References nscss_import::c, CONTENT_MSG_DONE, CONTENT_MSG_ERROR, nscss_import_ctx::css, hlcache_handle_release(), content_css_data::imports, nscss_import_ctx::index, nscss_import_complete(), NSERROR_NOMEM, NSERROR_OK, NSLOG, and hlcache_event::type.
|
static |
Handle an imported stylesheet completing.
ctx | Import context |
Definition at line 664 of file css.c.
References nscss_import_ctx::css, nscss_import_ctx::index, content_css_data::next_to_register, nscss_register_imports(), and NSLOG.
Referenced by nscss_import().
nserror nscss_init | ( | void | ) |
Initialise the CSS content handler.
Definition at line 816 of file css.c.
References content_factory_register_handler(), css_content_handler, css_hint_init(), nscss_fini(), and NSERROR_OK.
Referenced by netsurf_init().
|
static |
Definition at line 431 of file css.c.
References content::quirks.
|
static |
Process CSS data.
c | CSS content object |
data | Data to process |
size | Number of bytes to process |
Definition at line 274 of file css.c.
References content_css_data::sheet, and content::size.
Referenced by nscss_process_data().
|
static |
Process CSS source data.
c | Content structure |
data | Data to process |
size | Number of bytes to process |
Definition at line 253 of file css.c.
References content_broadcast_error(), nscss_content::data, nscss_process_css_data(), NSERROR_CSS, and content::size.
Referenced by nscss_clone().
|
static |
Register an import with a stylesheet.
c | CSS object that requested the import |
import | Cache handle of import, or NULL for blank |
Definition at line 737 of file css.c.
References blank_import, nscss_import::c, nscss_content::data, hlcache_handle_get_content(), ns_system_colour(), nscss_resolve_url(), and content_css_data::sheet.
Referenced by nscss_register_imports().
|
static |
Register imports with a stylesheet.
c | CSS object containing the imports |
Definition at line 693 of file css.c.
References nscss_import::c, content_get_status(), CONTENT_STATUS_DONE, nscss_register_import(), and hlcache_handle::pw.
Referenced by nscss_convert_css_data(), and nscss_import_complete().
|
static |
Definition at line 115 of file css.c.
Referenced by nscss_fini(), and nscss_register_import().
|
static |
Definition at line 803 of file css.c.
Referenced by nscss_init().
css_fixed nscss_screen_dpi = F_90 |
Screen DPI in fixed point units: defaults to 90, which RISC OS uses.
DPI of the screen, in fixed point units.
Definition at line 44 of file css.c.
Referenced by browser_get_dpi(), browser_set_dpi(), html_get_dimensions(), page_info__measure_text_entry(), textarea_create(), textarea_setup_text_offsets(), textplain_line_height(), and treeview_init().