NetSurf
|
Protected interface to Content handling. More...
#include <stdio.h>
#include <libwapcaplet/libwapcaplet.h>
#include "netsurf/content_type.h"
#include "netsurf/mouse.h"
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_link * | content__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 nsurl * | content__get_refresh_url (struct content *c) |
Retrieve the refresh URL for a content. More... | |
struct bitmap * | content__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_handle * | content_get_llcache_handle (struct content *c) |
Retrieve the low-level cache handle for a content. More... | |
struct nsurl * | content_get_url (struct content *c) |
Retrieve URL associated with content. More... | |
struct content * | content_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 [] |
Protected interface to Content handling.
The content functions manipulate struct contents, which correspond to URLs.
Definition in file content_protected.h.
typedef struct content_handler content_handler |
Definition at line 52 of file content_protected.h.
bool content__add_rfc5988_link | ( | struct content * | c, |
const struct content_rfc5988_link * | link | ||
) |
associate a metadata link with a content.
c | content to add link to |
link | The 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().
Clone a content's data members.
c | Content to clone |
nc | Content to populate |
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().
struct content_rfc5988_link * content__free_rfc5988_link | ( | struct content_rfc5988_link * | link | ) |
free a rfc5988 link
link | The link to free |
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().
int content__get_available_width | ( | struct content * | c | ) |
Retrieve available width of content.
c | content to get available width of. |
Definition at line 1199 of file content.c.
References content::available_width.
Referenced by content_get_available_width().
Retrieve the bitmap contained in an image content.
c | Content to retrieve opacity from |
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().
const char * content__get_encoding | ( | struct content * | c, |
enum content_encoding_type | op | ||
) |
Retrieve the encoding of a content.
c | the content to examine the encoding of. |
op | encoding operation. |
Definition at line 1329 of file content.c.
References content_handler::get_encoding, and content::handler.
Referenced by content_get_encoding().
int content__get_height | ( | struct content * | c | ) |
Retrieve height of content.
c | Content to retrieve height of |
Definition at line 1182 of file content.c.
References content::height.
Referenced by content_get_height(), and html_object_callback().
lwc_string * content__get_mime_type | ( | struct content * | c | ) |
Retrieve mime-type of content.
c | Content to retrieve mime-type of |
Definition at line 1080 of file content.c.
References content::mime_type.
Referenced by amiga_plugin_hack_redraw(), and content_get_mime_type().
bool content__get_opaque | ( | struct content * | c | ) |
Determine if a content is opaque.
c | Content to retrieve opacity from |
Definition at line 1295 of file content.c.
References content::handler, and content_handler::is_opaque.
Referenced by content_get_opaque().
Retrieve the refresh URL for a content.
c | Content to retrieve refresh URL from |
Definition at line 1254 of file content.c.
References content::refresh.
Referenced by content_get_refresh_url().
const uint8_t * content__get_source_data | ( | struct content * | c, |
size_t * | size | ||
) |
Retrieve source of content.
c | Content to retrieve source of. |
size | Pointer to location to receive byte size of source. |
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().
const char * content__get_status_message | ( | struct content * | c | ) |
Retrieve status message associated with content.
c | Content to retrieve status message from |
Definition at line 1148 of file content.c.
References content::status_message.
Referenced by content_get_status_message().
const char * content__get_title | ( | struct content * | c | ) |
Retrieve title associated with content.
c | Content to retrieve title from |
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().
int content__get_width | ( | struct content * | c | ) |
Retrieve width of content.
c | Content to retrieve width of |
Definition at line 1165 of file content.c.
References content::width.
Referenced by content_get_width(), and html_object_callback().
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.
c | Content to initialise |
handler | Content handler |
imime_type | MIME type of content |
params | HTTP parameters |
llcache | Source data handle |
fallback_charset | Fallback charset |
quirks | Quirkiness of content |
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.
c | Content 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().
bool content__is_locked | ( | struct content * | c | ) |
Return whether a content is currently locked.
c | Content to test |
Definition at line 1351 of file content.c.
References content::locked.
Referenced by content_is_locked().
void content__reformat | ( | struct content * | c, |
bool | background, | ||
int | width, | ||
int | height | ||
) |
cause a content to be reformatted.
c | content to be reformatted |
background | perform reformat in background |
width | The available width to reformat content in |
height | The 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().
void content__request_redraw | ( | struct content * | c, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height | ||
) |
Request a redraw of an area of a content.
c | Content |
x | x co-ord of left edge |
y | y co-ord of top edge |
width | Width of rectangle |
height | Height 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().
bool content__set_title | ( | struct content * | c, |
const char * | title | ||
) |
Set title associated with content.
c | Content to set title on. |
title | The new title to set. |
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().
Abort a content object.
c | The content object to abort |
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().
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.
c | the content to register |
callback | the user callback function |
pw | callback private data |
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().
void content_broadcast | ( | struct content * | c, |
content_msg | msg, | ||
const union content_msg_data * | data | ||
) |
Send a message to all users.
Definition at line 752 of file content.c.
References content_user::callback, content_user::next, NSLOG, content_user::pw, and content::user_list.
Referenced by content__add_rfc5988_link(), content__reformat(), content__request_redraw(), content_llcache_callback(), content_mouse_track(), content_set_done(), content_set_ready(), content_textsearch_step(), default_mouse_action(), dom_default_action_DOMNodeInserted_cb(), gadget_mouse_action(), gif__animate(), html_finish_conversion(), html_get_dimensions(), html_object_callback(), html_overflow_scroll_callback(), html_process_inserted_meta(), html_process_script(), html_set_drag_type(), html_set_focus(), html_set_selection(), jxl_report_fail(), link_mouse_action(), mouse_action_drag_none(), mouse_action_drag_scrollbar(), mouse_action_select_menu(), nsjpeg_convert(), nsjpegxl_convert(), search_text(), textplain_mouse_action(), and textsearch_broadcast().
Send an error message to all users.
c | The content whose users should be informed of an error |
errorcode | The nserror code to send |
msg | The error message to send alongside |
Definition at line 769 of file content.c.
References content_user::callback, CONTENT_MSG_ERROR, content_msg_data::errorcode, content_msg_data::errordata, content_msg_data::errormsg, content_msg_data::msg, content_user::next, content_user::pw, and content::user_list.
Referenced by exec_inline_script(), exec_src_script(), gif_convert(), gif_create_gif_data(), html_begin_conversion(), html_box_convert_done(), html_create(), html_create_style_element(), html_css_process_link(), html_css_process_modified_style(), html_finish_conversion(), html_process_data(), nsbmp_convert(), nsbmp_create_bmp_data(), nscss_content_done(), nscss_convert(), nscss_create(), nscss_process_data(), nsico_convert(), nsico_create_ico_data(), nspng_create_png_data(), nspng_process_data(), nssprite_convert(), rsvg_convert(), rsvg_create_svg_data(), rsvg_process_data(), svg_create_svg_data(), textplain_create_internal(), and textplain_process_data().
Clone a content object in its current state.
c | Content to clone |
Definition at line 1368 of file content.c.
References content_handler::clone, content::handler, and NSERROR_OK.
Referenced by hlcache_handle_abort().
uint32_t content_count_users | ( | struct content * | c | ) |
Count users for the content.
c | Content 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().
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().
const struct llcache_handle * content_get_llcache_handle | ( | struct content * | c | ) |
Retrieve the low-level cache handle for a content.
c | Content to retrieve from |
Definition at line 1358 of file content.c.
References content::llcache.
Referenced by hlcache_find_content().
Retrieve URL associated with content.
c | Content to retrieve URL from |
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().
bool content_is_shareable | ( | struct content * | c | ) |
Determine if a content is shareable.
c | Content to consider |
Definition at line 745 of file content.c.
References content::handler, and content_handler::no_share.
Referenced by hlcache_find_content().
bool content_matches_quirks | ( | struct content * | c, |
bool | quirks | ||
) |
Determine if quirks mode matches.
c | Content to consider |
quirks | Quirks mode to match |
Definition at line 735 of file content.c.
References content::handler, and content_handler::matches_quirks.
Referenced by hlcache_find_content().
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().
c | Content to remove user from |
callback | passed when added |
ctx | Context 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().
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().
void content_set_error | ( | struct content * | c | ) |
Put a content in status CONTENT_STATUS_ERROR and unlock the content.
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().
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().
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.
c | The content to set status in. |
status_message | new 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().
|
extern |