NetSurf
Data Structures | Typedefs | Functions | Variables
content_protected.h File Reference

Protected interface to Content handling. More...

#include <stdio.h>
#include <libwapcaplet/libwapcaplet.h>
#include "netsurf/content_type.h"
#include "netsurf/mouse.h"
Include dependency graph for content_protected.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  content_handler
 Content operation function table. More...
 
struct  content_user
 Linked list of users of a content. More...
 
struct  content
 Content which corresponds to a single URL. More...
 

Typedefs

typedef struct content_handler content_handler
 

Functions

nserror content__init (struct content *c, const struct content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, struct llcache_handle *llcache, const char *fallback_charset, bool quirks)
 Initialise a new base content structure. More...
 
nserror content__clone (const struct content *c, struct content *nc)
 Clone a content's data members. More...
 
void content_set_ready (struct content *c)
 Put a content in status CONTENT_STATUS_READY and unlock the content. More...
 
void content_set_done (struct content *c)
 Put a content in status CONTENT_STATUS_DONE. More...
 
void content_set_error (struct content *c)
 Put a content in status CONTENT_STATUS_ERROR and unlock the content. More...
 
void content_set_status (struct content *c, const char *status_message)
 Updates content with new status. More...
 
void content_broadcast (struct content *c, content_msg msg, const union content_msg_data *data)
 Send a message to all users. More...
 
void content_broadcast_error (struct content *c, nserror errorcode, const char *msg)
 Send an error message to all users. More...
 
bool content__add_rfc5988_link (struct content *c, const struct content_rfc5988_link *link)
 associate a metadata link with a content. More...
 
struct content_rfc5988_linkcontent__free_rfc5988_link (struct content_rfc5988_link *link)
 free a rfc5988 link More...
 
void content__reformat (struct content *c, bool background, int width, int height)
 cause a content to be reformatted. More...
 
void content__request_redraw (struct content *c, int x, int y, int width, int height)
 Request a redraw of an area of a content. More...
 
lwc_string * content__get_mime_type (struct content *c)
 Retrieve mime-type of content. More...
 
bool content__set_title (struct content *c, const char *title)
 Set title associated with content. More...
 
const char * content__get_title (struct content *c)
 Retrieve title associated with content. More...
 
const char * content__get_status_message (struct content *c)
 Retrieve status message associated with content. More...
 
int content__get_width (struct content *c)
 Retrieve width of content. More...
 
int content__get_height (struct content *c)
 Retrieve height of content. More...
 
int content__get_available_width (struct content *c)
 Retrieve available width of content. More...
 
const uint8_t * content__get_source_data (struct content *c, size_t *size)
 Retrieve source of content. More...
 
void content__invalidate_reuse_data (struct content *c)
 Invalidate content reuse data. More...
 
struct nsurlcontent__get_refresh_url (struct content *c)
 Retrieve the refresh URL for a content. More...
 
struct bitmapcontent__get_bitmap (struct content *c)
 Retrieve the bitmap contained in an image content. More...
 
bool content__get_opaque (struct content *c)
 Determine if a content is opaque. More...
 
const char * content__get_encoding (struct content *c, enum content_encoding_type op)
 Retrieve the encoding of a content. More...
 
bool content__is_locked (struct content *c)
 Return whether a content is currently locked. More...
 
void content_destroy (struct content *c)
 Destroy and free a content. More...
 
bool content_add_user (struct content *h, void(*callback)(struct content *c, content_msg msg, const union content_msg_data *data, void *pw), void *pw)
 Register a user for callbacks. More...
 
void content_remove_user (struct content *c, void(*callback)(struct content *c, content_msg msg, const union content_msg_data *data, void *pw), void *ctx)
 Remove a callback user. More...
 
uint32_t content_count_users (struct content *c)
 Count users for the content. More...
 
bool content_matches_quirks (struct content *c, bool quirks)
 Determine if quirks mode matches. More...
 
bool content_is_shareable (struct content *c)
 Determine if a content is shareable. More...
 
const struct llcache_handlecontent_get_llcache_handle (struct content *c)
 Retrieve the low-level cache handle for a content. More...
 
struct nsurlcontent_get_url (struct content *c)
 Retrieve URL associated with content. More...
 
struct contentcontent_clone (struct content *c)
 Clone a content object in its current state. More...
 
nserror content_abort (struct content *c)
 Abort a content object. More...
 

Variables

const char *const content_type_name []
 
const char *const content_status_name []
 

Detailed Description

Protected interface to Content handling.

The content functions manipulate struct contents, which correspond to URLs.

Definition in file content_protected.h.

Typedef Documentation

◆ content_handler

Definition at line 52 of file content_protected.h.

Function Documentation

◆ content__add_rfc5988_link()

bool content__add_rfc5988_link ( struct content c,
const struct content_rfc5988_link link 
)

associate a metadata link with a content.

Parameters
ccontent to add link to
linkThe rfc5988 link to add

Definition at line 1001 of file content.c.

References content_broadcast(), CONTENT_MSG_LINK, content_rfc5988_link::href, content_rfc5988_link::hreflang, content::links, content_rfc5988_link::media, content_rfc5988_link::next, nsurl_ref(), content_rfc5988_link::rel, content_msg_data::rfc5988_link, content_rfc5988_link::sizes, and content_rfc5988_link::type.

Referenced by html_process_inserted_link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content__clone()

nserror content__clone ( const struct content c,
struct content nc 
)

Clone a content's data members.

Parameters
cContent to clone
ncContent to populate
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1382 of file content.c.

References content::active, content::available_width, content_llcache_callback(), content::fallback_charset, content::handler, content::height, content::http_code, content::llcache, llcache_handle_change_callback(), llcache_handle_clone(), content::locked, content::mime_type, NSERROR_NOMEM, NSERROR_OK, nsurl_ref(), content::quirks, content::reformat_time, content::refresh, content::size, content::status, content::status_message, content::sub_status, content::time, content::title, content::total_size, content::user_list, and content::width.

Referenced by amiga_plugin_hack_clone(), gif_clone(), javascript_clone(), nsbmp_clone(), nscss_clone(), nsico_clone(), nsjpeg_clone(), nsjpegxl_clone(), nspng_clone(), nssprite_clone(), rsvg_clone(), svg_clone(), textplain_clone(), and webp_clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content__free_rfc5988_link()

struct content_rfc5988_link * content__free_rfc5988_link ( struct content_rfc5988_link link)

free a rfc5988 link

Parameters
linkThe link to free
Returns
The next link in the chain

Definition at line 973 of file content.c.

References content_rfc5988_link::href, content_rfc5988_link::hreflang, content_rfc5988_link::media, content_rfc5988_link::next, nsurl_unref(), content_rfc5988_link::rel, content_rfc5988_link::sizes, and content_rfc5988_link::type.

Referenced by content_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content__get_available_width()

int content__get_available_width ( struct content c)

Retrieve available width of content.

Parameters
ccontent to get available width of.
Returns
Available width of content.

Definition at line 1199 of file content.c.

References content::available_width.

Referenced by content_get_available_width().

Here is the caller graph for this function:

◆ content__get_bitmap()

struct bitmap * content__get_bitmap ( struct content c)

Retrieve the bitmap contained in an image content.

Parameters
cContent to retrieve opacity from
Returns
Pointer to bitmap or NULL if none.

Definition at line 1271 of file content.c.

References bitmap(), CONTENT_IMAGE, content_handler::get_internal, content::handler, and content_handler::type.

Referenced by content_get_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content__get_encoding()

const char * content__get_encoding ( struct content c,
enum content_encoding_type  op 
)

Retrieve the encoding of a content.

Parameters
cthe content to examine the encoding of.
opencoding operation.
Returns
Pointer to content info or NULL if none.

Definition at line 1329 of file content.c.

References content_handler::get_encoding, and content::handler.

Referenced by content_get_encoding().

Here is the caller graph for this function:

◆ content__get_height()

int content__get_height ( struct content c)

Retrieve height of content.

Parameters
cContent to retrieve height of
Returns
Content height

Definition at line 1182 of file content.c.

References content::height.

Referenced by content_get_height(), and html_object_callback().

Here is the caller graph for this function:

◆ content__get_mime_type()

lwc_string * content__get_mime_type ( struct content c)

Retrieve mime-type of content.

Parameters
cContent to retrieve mime-type of
Returns
Pointer to referenced mime-type, or NULL if not found.

Definition at line 1080 of file content.c.

References content::mime_type.

Referenced by amiga_plugin_hack_redraw(), and content_get_mime_type().

Here is the caller graph for this function:

◆ content__get_opaque()

bool content__get_opaque ( struct content c)

Determine if a content is opaque.

Parameters
cContent to retrieve opacity from
Returns
false if the content is not opaque or information is not known else true.

Definition at line 1295 of file content.c.

References content::handler, and content_handler::is_opaque.

Referenced by content_get_opaque().

Here is the caller graph for this function:

◆ content__get_refresh_url()

struct nsurl * content__get_refresh_url ( struct content c)

Retrieve the refresh URL for a content.

Parameters
cContent to retrieve refresh URL from
Returns
Pointer to URL or NULL if none

Definition at line 1254 of file content.c.

References content::refresh.

Referenced by content_get_refresh_url().

Here is the caller graph for this function:

◆ content__get_source_data()

const uint8_t * content__get_source_data ( struct content c,
size_t *  size 
)

Retrieve source of content.

Parameters
cContent to retrieve source of.
sizePointer to location to receive byte size of source.
Returns
Pointer to source data.
Todo:
check if the content check should be an assert

Definition at line 1216 of file content.c.

References content::llcache, llcache_handle_get_source_data(), and content::size.

Referenced by content_get_source_data(), gif_convert(), html_process_encoding_change(), jpeg_cache_convert(), jpegxl_cache_convert(), nsbmp_convert(), nscss_clone(), nsico_convert(), nsjpeg_convert(), nsjpegxl_convert(), nspng_clone(), nssprite_convert(), png_cache_convert(), rsvg_clone(), rsvg_convert(), svg_reformat(), textplain_clone(), webp_cache_convert(), and webp_convert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content__get_status_message()

const char * content__get_status_message ( struct content c)

Retrieve status message associated with content.

Parameters
cContent to retrieve status message from
Returns
Pointer to status message, or NULL if not found.

Definition at line 1148 of file content.c.

References content::status_message.

Referenced by content_get_status_message().

Here is the caller graph for this function:

◆ content__get_title()

const char * content__get_title ( struct content c)

Retrieve title associated with content.

Parameters
cContent to retrieve title from
Returns
Pointer to title, or NULL if not found.

Definition at line 1113 of file content.c.

References content::llcache, llcache_handle_get_url(), nsurl_access(), and content::title.

Referenced by content_get_title().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content__get_width()

int content__get_width ( struct content c)

Retrieve width of content.

Parameters
cContent to retrieve width of
Returns
Content width

Definition at line 1165 of file content.c.

References content::width.

Referenced by content_get_width(), and html_object_callback().

Here is the caller graph for this function:

◆ content__init()

nserror content__init ( struct content c,
const struct content_handler handler,
lwc_string *  imime_type,
const struct http_parameter params,
struct llcache_handle llcache,
const char *  fallback_charset,
bool  quirks 
)

Initialise a new base content structure.

Parameters
cContent to initialise
handlerContent handler
imime_typeMIME type of content
paramsHTTP parameters
llcacheSource data handle
fallback_charsetFallback charset
quirksQuirkiness of content
Returns
NSERROR_OK on success, appropriate error otherwise

◆ content__invalidate_reuse_data()

void content__invalidate_reuse_data ( struct content c)

Invalidate content reuse data.

causes subsequent requests for content URL to query server to determine if content can be reused. This is required behaviour for forced reloads etc.

Parameters
cContent to invalidate.

Definition at line 1236 of file content.c.

References content::llcache, and llcache_handle_invalidate_cache_data().

Referenced by content_invalidate_reuse_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content__is_locked()

bool content__is_locked ( struct content c)

Return whether a content is currently locked.

Parameters
cContent to test
Returns
true iff locked, else false

Definition at line 1351 of file content.c.

References content::locked.

Referenced by content_is_locked().

Here is the caller graph for this function:

◆ content__reformat()

void content__reformat ( struct content c,
bool  background,
int  width,
int  height 
)

cause a content to be reformatted.

Parameters
ccontent to be reformatted
backgroundperform reformat in background
widthThe available width to reformat content in
heightThe available height to reformat content in

Definition at line 331 of file content.c.

References content::available_height, content::available_width, content_msg_data::background, content_broadcast(), CONTENT_MSG_REFORMAT, CONTENT_STATUS_DONE, CONTENT_STATUS_READY, content::handler, height, content::locked, content_handler::reformat, content::status, and width.

Referenced by content_reformat(), and html_object_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content__request_redraw()

void content__request_redraw ( struct content c,
int  x,
int  y,
int  width,
int  height 
)

Request a redraw of an area of a content.

Parameters
cContent
xx co-ord of left edge
yy co-ord of top edge
widthWidth of rectangle
heightHeight of rectangle

Definition at line 459 of file content.c.

References content_broadcast(), CONTENT_MSG_REDRAW, content_msg_data::height, height, content_msg_data::redraw, content_msg_data::width, width, content_msg_data::x, and content_msg_data::y.

Referenced by box_textarea_callback(), content_request_redraw(), form_select_menu_callback(), html__redraw_a_box(), html_textselection_redraw(), and textplain_textselection_redraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content__set_title()

bool content__set_title ( struct content c,
const char *  title 
)

Set title associated with content.

Parameters
cContent to set title on.
titleThe new title to set.
Returns
true on sucess else false.

Definition at line 1090 of file content.c.

References content::title.

Referenced by gif_convert(), html_process_title(), nsbmp_convert(), nsico_convert(), nsjpeg_convert(), nsjpegxl_convert(), nspng_convert(), and nssprite_convert().

Here is the caller graph for this function:

◆ content_abort()

nserror content_abort ( struct content c)

Abort a content object.

Parameters
cThe content object to abort
Returns
NSERROR_OK on success, otherwise appropriate error

Definition at line 1448 of file content.c.

References content::handler, content::llcache, llcache_handle_abort(), NSLOG, and content_handler::stop.

Referenced by hlcache_clean(), and hlcache_handle_abort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_add_user()

bool content_add_user ( struct content h,
void(*)(struct content *c, content_msg msg, const union content_msg_data *data, void *pw)  callback,
void *  pw 
)

Register a user for callbacks.

Parameters
cthe content to register
callbackthe user callback function
pwcallback private data
Returns
true on success, false otherwise on memory exhaustion

The callback will be called when content_broadcast() is called with the content.

Definition at line 654 of file content.c.

References content_handler::add_user, content_user::callback, content::handler, content::llcache, llcache_handle_get_url(), content_user::next, NSLOG, nsurl_access_log(), content_user::pw, URL_FMT_SPC, and content::user_list.

Referenced by hlcache_find_content(), and hlcache_handle_abort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_broadcast()

void content_broadcast ( struct content c,
content_msg  msg,
const union content_msg_data data 
)

◆ content_broadcast_error()

void content_broadcast_error ( struct content c,
nserror  errorcode,
const char *  msg 
)

◆ content_clone()

struct content * content_clone ( struct content c)

Clone a content object in its current state.

Parameters
cContent to clone
Returns
Clone of c

Definition at line 1368 of file content.c.

References content_handler::clone, content::handler, and NSERROR_OK.

Referenced by hlcache_handle_abort().

Here is the caller graph for this function:

◆ content_count_users()

uint32_t content_count_users ( struct content c)

Count users for the content.

Parameters
cContent to consider

Definition at line 718 of file content.c.

References content_user::next, and content::user_list.

Referenced by gif_add_user(), gif_remove_user(), hlcache_clean(), hlcache_finalise(), and hlcache_handle_abort().

Here is the caller graph for this function:

◆ content_destroy()

void content_destroy ( struct content c)

Destroy and free a content.

Calls the destroy function for the content, and frees the structure.

Definition at line 354 of file content.c.

References content__free_rfc5988_link(), content_handler::destroy, content::fallback_charset, content::handler, content::links, content::llcache, llcache_handle_get_url(), llcache_handle_release(), content::locked, content::mime_type, NSLOG, nsurl_access_log(), content::title, and content::user_list.

Referenced by amiga_plugin_hack_clone(), gif_clone(), hlcache_clean(), hlcache_handle_abort(), javascript_clone(), nsbmp_clone(), nscss_clone(), nsico_clone(), nsjpeg_clone(), nsjpegxl_clone(), nspng_clone(), nssprite_clone(), rsvg_clone(), svg_clone(), textplain_clone(), and webp_clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_get_llcache_handle()

const struct llcache_handle * content_get_llcache_handle ( struct content c)

Retrieve the low-level cache handle for a content.

Note
only used by hlcache
Parameters
cContent to retrieve from
Returns
Low-level cache handle

Definition at line 1358 of file content.c.

References content::llcache.

Referenced by hlcache_find_content().

Here is the caller graph for this function:

◆ content_get_url()

struct nsurl * content_get_url ( struct content c)

Retrieve URL associated with content.

Parameters
cContent to retrieve URL from
Returns
Pointer to URL, or NULL if not found.

Definition at line 1051 of file content.c.

References content::llcache, and llcache_handle_get_url().

Referenced by amiga_plugin_hack_open(), box_textarea_keypress(), exec_src_script(), hlcache_handle_get_url(), html_begin_conversion(), html_create_html_data(), html_css_new_stylesheets(), html_css_process_link(), html_css_quirks_stylesheets(), html_fetch_object(), html_process_inserted_meta(), html_replace_object(), html_stylesheet_from_domnode(), layout_document(), link_mouse_action(), mouse_action_drag_none(), nscss_clone(), nscss_create(), and svg_reformat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_is_shareable()

bool content_is_shareable ( struct content c)

Determine if a content is shareable.

Parameters
cContent to consider
Returns
True if content is shareable, false otherwise

Definition at line 745 of file content.c.

References content::handler, and content_handler::no_share.

Referenced by hlcache_find_content().

Here is the caller graph for this function:

◆ content_matches_quirks()

bool content_matches_quirks ( struct content c,
bool  quirks 
)

Determine if quirks mode matches.

Parameters
cContent to consider
quirksQuirks mode to match
Returns
True if quirks match, false otherwise

Definition at line 735 of file content.c.

References content::handler, and content_handler::matches_quirks.

Referenced by hlcache_find_content().

Here is the caller graph for this function:

◆ content_remove_user()

void content_remove_user ( struct content c,
void(*)(struct content *c, content_msg msg, const union content_msg_data *data, void *pw)  callback,
void *  ctx 
)

Remove a callback user.

The callback function and pw must be identical to those passed to content_add_user().

Parameters
cContent to remove user from
callbackpassed when added
ctxContext passed when added

Definition at line 684 of file content.c.

References content_user::callback, content::handler, content::llcache, llcache_handle_get_url(), content_user::next, NSLOG, nsurl_access_log(), content_user::pw, content_handler::remove_user, URL_FMT_SPC, and content::user_list.

Referenced by hlcache_handle_abort(), and hlcache_handle_release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_set_done()

void content_set_done ( struct content c)

Put a content in status CONTENT_STATUS_DONE.

Definition at line 299 of file content.c.

References content_broadcast(), CONTENT_MSG_DONE, CONTENT_STATUS_DONE, content_update_status(), content::status, and content::time.

Referenced by amiga_plugin_hack_convert(), content_convert(), gif_convert(), html_object_callback(), html_proceed_to_done(), html_stop(), javascript_convert(), nsbmp_convert(), nscss_content_done(), nsico_convert(), nsjpeg_convert(), nsjpegxl_convert(), nspng_convert(), nssprite_convert(), rsvg_convert(), svg_convert(), textplain_convert(), and webp_convert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_set_error()

void content_set_error ( struct content c)

Put a content in status CONTENT_STATUS_ERROR and unlock the content.

Note
We expect the caller to broadcast an error report if needed.

Definition at line 313 of file content.c.

References CONTENT_STATUS_ERROR, content::locked, and content::status.

Referenced by content_convert(), hlcache_clean(), html_begin_conversion(), html_box_convert_done(), html_finish_conversion(), and nscss_content_done().

Here is the caller graph for this function:

◆ content_set_ready()

void content_set_ready ( struct content c)

Put a content in status CONTENT_STATUS_READY and unlock the content.

Definition at line 285 of file content.c.

References content_broadcast(), CONTENT_MSG_READY, CONTENT_STATUS_READY, content_update_status(), content::locked, and content::status.

Referenced by amiga_plugin_hack_convert(), content_convert(), gif_convert(), html_box_convert_done(), javascript_convert(), nsbmp_convert(), nscss_content_done(), nsico_convert(), nsjpeg_convert(), nsjpegxl_convert(), nspng_convert(), nssprite_convert(), rsvg_convert(), svg_convert(), textplain_convert(), and webp_convert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_set_status()

void content_set_status ( struct content c,
const char *  status_message 
)

Updates content with new status.

The textual status contained in the content is updated with given string.

Parameters
cThe content to set status in.
status_messagenew textual status

Definition at line 270 of file content.c.

References content_update_status(), content::status_message, and content::sub_status.

Referenced by amiga_plugin_hack_convert(), content__init(), content_llcache_callback(), gif_convert(), html_finish_conversion(), nsbmp_convert(), nsico_convert(), nsjpeg_convert(), nsjpegxl_convert(), nspng_convert(), nssprite_convert(), rsvg_convert(), svg_convert(), and textplain_convert().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ content_status_name

const char* const content_status_name[]
extern

Definition at line 46 of file content.c.

◆ content_type_name

const char* const content_type_name[]
extern