Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/5f8b1497e1489e2b3c11e8a49f01770433115ee2
...commit
http://git.netsurf-browser.org/netsurf.git/commit/5f8b1497e1489e2b3c11e8a49f01770433115ee2
...tree
http://git.netsurf-browser.org/netsurf.git/tree/5f8b1497e1489e2b3c11e8a49f01770433115ee2
The branch, master has been updated
via 5f8b1497e1489e2b3c11e8a49f01770433115ee2 (commit)
via c2f9bcac19d53eff2e01152c190d3727b224660c (commit)
via b832bfaea8099217ee58cae21ee0807cd9a475db (commit)
from ad4cdc62b8cffd7d22b33623287a1679eb90c4b7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=5f8b1497e1489e2b3c11e8a49f01770433115ee2
commit 5f8b1497e1489e2b3c11e8a49f01770433115ee2
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
clean up content headers and documentation comments
pure formatting and documentation changes, no code difference
diff --git a/content/content.c b/content/content.c
index d33780f..6532587 100644
--- a/content/content.c
+++ b/content/content.c
@@ -49,84 +49,48 @@ const char * const content_status_name[] = {
"ERROR"
};
-static nserror content_llcache_callback(llcache_handle *llcache,
- const llcache_event *event, void *pw);
-static void content_convert(struct content *c);
-
/**
- * Initialise a new content structure.
+ * All data has arrived, convert for display.
*
- * \param c Content to initialise
- * \param handler Content handler
- * \param imime_type MIME type of content
- * \param params HTTP parameters
- * \param llcache Source data handle
- * \param fallback_charset Fallback charset
- * \param quirks Quirkiness of content
- * \return NSERROR_OK on success, appropriate error otherwise
+ * Calls the convert function for the content.
+ *
+ * - If the conversion succeeds, but there is still some processing required
+ * (eg. loading images), the content gets status CONTENT_STATUS_READY, and a
+ * CONTENT_MSG_READY is sent to all users.
+ * - If the conversion succeeds and is complete, the content gets status
+ * CONTENT_STATUS_DONE, and CONTENT_MSG_READY then CONTENT_MSG_DONE are sent.
+ * - If the conversion fails, CONTENT_MSG_ERROR is sent. The content will soon
+ * be destroyed and must no longer be used.
*/
-
-nserror content__init(struct content *c, const content_handler *handler,
- lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
- bool quirks)
+static void content_convert(struct content *c)
{
- struct content_user *user_sentinel;
- nserror error;
-
- NSLOG(netsurf, INFO, "url "URL_FMT_SPC" -> %p",
- nsurl_access_log(llcache_handle_get_url(llcache)), c);
-
- user_sentinel = calloc(1, sizeof(struct content_user));
- if (user_sentinel == NULL) {
- return NSERROR_NOMEM;
- }
+ assert(c);
+ assert(c->status == CONTENT_STATUS_LOADING ||
+ c->status == CONTENT_STATUS_ERROR);
- if (fallback_charset != NULL) {
- c->fallback_charset = strdup(fallback_charset);
- if (c->fallback_charset == NULL) {
- free(user_sentinel);
- return NSERROR_NOMEM;
- }
- }
+ if (c->status != CONTENT_STATUS_LOADING)
+ return;
- c->llcache = llcache;
- c->mime_type = lwc_string_ref(imime_type);
- c->handler = handler;
- c->status = CONTENT_STATUS_LOADING;
- c->width = 0;
- c->height = 0;
- c->available_width = 0;
- c->available_height = 0;
- c->quirks = quirks;
- c->refresh = 0;
- nsu_getmonotonic_ms(&c->time);
- c->size = 0;
- c->title = NULL;
- c->active = 0;
- user_sentinel->callback = NULL;
- user_sentinel->pw = NULL;
- user_sentinel->next = NULL;
- c->user_list = user_sentinel;
- c->sub_status[0] = 0;
- c->locked = false;
- c->total_size = 0;
- c->http_code = 0;
+ if (c->locked == true)
+ return;
- content_set_status(c, messages_get("Loading"));
+ NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p)",
+ nsurl_access_log(llcache_handle_get_url(c->llcache)), c);
- /* Finally, claim low-level cache events */
- error = llcache_handle_change_callback(llcache,
- content_llcache_callback, c);
- if (error != NSERROR_OK) {
- lwc_string_unref(c->mime_type);
- return error;
+ if (c->handler->data_complete != NULL) {
+ c->locked = true;
+ if (c->handler->data_complete(c) == false) {
+ content_set_error(c);
+ }
+ /* Conversion to the READY state will unlock the content */
+ } else {
+ content_set_ready(c);
+ content_set_done(c);
}
-
- return NSERROR_OK;
}
+
/**
* Handler for low-level cache events
*
@@ -135,8 +99,9 @@ nserror content__init(struct content *c, const
content_handler *handler,
* \param pw Pointer to our context
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror content_llcache_callback(llcache_handle *llcache,
- const llcache_event *event, void *pw)
+static nserror
+content_llcache_callback(llcache_handle *llcache,
+ const llcache_event *event, void *pw)
{
struct content *c = pw;
union content_msg_data msg_data;
@@ -152,8 +117,8 @@ nserror content_llcache_callback(llcache_handle *llcache,
case LLCACHE_EVENT_HAD_DATA:
if (c->handler->process_data != NULL) {
if (c->handler->process_data(c,
- (const char *) event->data.data.buf,
- event->data.data.len) == false) {
+ (const char *)
event->data.data.buf,
+ event->data.data.len) ==
false) {
llcache_handle_abort(c->llcache);
c->status = CONTENT_STATUS_ERROR;
/** \todo It's not clear what error this is */
@@ -162,17 +127,17 @@ nserror content_llcache_callback(llcache_handle *llcache,
}
break;
case LLCACHE_EVENT_DONE:
- {
- size_t source_size;
+ {
+ size_t source_size;
- (void) llcache_handle_get_source_data(llcache, &source_size);
+ (void) llcache_handle_get_source_data(llcache,
&source_size);
- content_set_status(c, messages_get("Processing"));
- msg_data.explicit_status_text = NULL;
- content_broadcast(c, CONTENT_MSG_STATUS, &msg_data);
+ content_set_status(c, messages_get("Processing"));
+ msg_data.explicit_status_text = NULL;
+ content_broadcast(c, CONTENT_MSG_STATUS, &msg_data);
- content_convert(c);
- }
+ content_convert(c);
+ }
break;
case LLCACHE_EVENT_ERROR:
/** \todo Error page? */
@@ -196,108 +161,123 @@ nserror content_llcache_callback(llcache_handle
*llcache,
return error;
}
+
/**
- * Get whether a content can reformat
+ * update content status message
*
- * \param h content to check
- * \return whether the content can reformat
+ * \param c the content to update.
*/
-bool content_can_reformat(hlcache_handle *h)
-{
- struct content *c = hlcache_handle_get_content(h);
-
- if (c == NULL)
- return false;
-
- return (c->handler->reformat != NULL);
-}
-
-
static void content_update_status(struct content *c)
{
if (c->status == CONTENT_STATUS_LOADING ||
- c->status == CONTENT_STATUS_READY) {
+ c->status == CONTENT_STATUS_READY) {
/* Not done yet */
snprintf(c->status_message, sizeof (c->status_message),
- "%s%s%s", messages_get("Fetching"),
- c->sub_status[0] != '\0' ? ", " : " ",
- c->sub_status);
+ "%s%s%s", messages_get("Fetching"),
+ c->sub_status[0] != '\0' ? ", " : " ",
+ c->sub_status);
} else {
snprintf(c->status_message, sizeof (c->status_message),
- "%s (%.1fs)", messages_get("Done"),
- (float) c->time / 1000);
+ "%s (%.1fs)", messages_get("Done"),
+ (float) c->time / 1000);
}
}
-/**
- * Updates content with new status.
- *
- * The textual status contained in the content is updated with given string.
- *
- * \param c The content to set status in.
- * \param status_message new textual status
- */
-
-void content_set_status(struct content *c, const char *status_message)
+/* exported interface documented in content/protected.h */
+nserror
+content__init(struct content *c,
+ const content_handler *handler,
+ lwc_string *imime_type,
+ const struct http_parameter *params,
+ llcache_handle *llcache,
+ const char *fallback_charset,
+ bool quirks)
{
- size_t len = strlen(status_message);
+ struct content_user *user_sentinel;
+ nserror error;
- if (len >= sizeof(c->sub_status)) {
- len = sizeof(c->sub_status) - 1;
+ NSLOG(netsurf, INFO, "url "URL_FMT_SPC" -> %p",
+ nsurl_access_log(llcache_handle_get_url(llcache)), c);
+
+ user_sentinel = calloc(1, sizeof(struct content_user));
+ if (user_sentinel == NULL) {
+ return NSERROR_NOMEM;
}
- memcpy(c->sub_status, status_message, len);
- c->sub_status[len] = '\0';
- content_update_status(c);
-}
+ if (fallback_charset != NULL) {
+ c->fallback_charset = strdup(fallback_charset);
+ if (c->fallback_charset == NULL) {
+ free(user_sentinel);
+ return NSERROR_NOMEM;
+ }
+ }
+ c->llcache = llcache;
+ c->mime_type = lwc_string_ref(imime_type);
+ c->handler = handler;
+ c->status = CONTENT_STATUS_LOADING;
+ c->width = 0;
+ c->height = 0;
+ c->available_width = 0;
+ c->available_height = 0;
+ c->quirks = quirks;
+ c->refresh = 0;
+ nsu_getmonotonic_ms(&c->time);
+ c->size = 0;
+ c->title = NULL;
+ c->active = 0;
+ user_sentinel->callback = NULL;
+ user_sentinel->pw = NULL;
+ user_sentinel->next = NULL;
+ c->user_list = user_sentinel;
+ c->sub_status[0] = 0;
+ c->locked = false;
+ c->total_size = 0;
+ c->http_code = 0;
-/**
- * All data has arrived, convert for display.
- *
- * Calls the convert function for the content.
- *
- * - If the conversion succeeds, but there is still some processing required
- * (eg. loading images), the content gets status CONTENT_STATUS_READY, and a
- * CONTENT_MSG_READY is sent to all users.
- * - If the conversion succeeds and is complete, the content gets status
- * CONTENT_STATUS_DONE, and CONTENT_MSG_READY then CONTENT_MSG_DONE are sent.
- * - If the conversion fails, CONTENT_MSG_ERROR is sent. The content will soon
- * be destroyed and must no longer be used.
- */
+ content_set_status(c, messages_get("Loading"));
+
+ /* Finally, claim low-level cache events */
+ error = llcache_handle_change_callback(llcache,
+ content_llcache_callback, c);
+ if (error != NSERROR_OK) {
+ lwc_string_unref(c->mime_type);
+ return error;
+ }
+
+ return NSERROR_OK;
+}
-void content_convert(struct content *c)
+
+/* exported interface documented in content/content.h */
+bool content_can_reformat(hlcache_handle *h)
{
- assert(c);
- assert(c->status == CONTENT_STATUS_LOADING ||
- c->status == CONTENT_STATUS_ERROR);
+ struct content *c = hlcache_handle_get_content(h);
- if (c->status != CONTENT_STATUS_LOADING)
- return;
+ if (c == NULL)
+ return false;
- if (c->locked == true)
- return;
+ return (c->handler->reformat != NULL);
+}
- NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p)",
- nsurl_access_log(llcache_handle_get_url(c->llcache)), c);
- if (c->handler->data_complete != NULL) {
- c->locked = true;
- if (c->handler->data_complete(c) == false) {
- content_set_error(c);
- }
- /* Conversion to the READY state will unlock the content */
- } else {
- content_set_ready(c);
- content_set_done(c);
+/* exported interface documented in content/protected.h */
+void content_set_status(struct content *c, const char *status_message)
+{
+ size_t len = strlen(status_message);
+
+ if (len >= sizeof(c->sub_status)) {
+ len = sizeof(c->sub_status) - 1;
}
+ memcpy(c->sub_status, status_message, len);
+ c->sub_status[len] = '\0';
+
+ content_update_status(c);
}
-/**
- * Put a content in status CONTENT_STATUS_READY and unlock the content.
- */
+/* exported interface documented in content/protected.h */
void content_set_ready(struct content *c)
{
/* The content must be locked at this point, as it can only
@@ -310,10 +290,8 @@ void content_set_ready(struct content *c)
content_broadcast(c, CONTENT_MSG_READY, NULL);
}
-/**
- * Put a content in status CONTENT_STATUS_DONE.
- */
+/* exported interface documented in content/protected.h */
void content_set_done(struct content *c)
{
uint64_t now_ms;
@@ -326,38 +304,32 @@ void content_set_done(struct content *c)
content_broadcast(c, CONTENT_MSG_DONE, NULL);
}
-/**
- * Put a content in status CONTENT_STATUS_ERROR and unlock the content.
- *
- * \note We expect the caller to broadcast an error report if needed.
- */
+/* exported interface documented in content/protected.h */
void content_set_error(struct content *c)
{
c->locked = false;
c->status = CONTENT_STATUS_ERROR;
}
-/**
- * Reformat to new size.
- *
- * Calls the reformat function for the content.
- */
+/* exported interface documented in content/content.h */
void content_reformat(hlcache_handle *h, bool background,
- int width, int height)
+ int width, int height)
{
content__reformat(hlcache_handle_get_content(h), background,
- width, height);
+ width, height);
}
-void content__reformat(struct content *c, bool background,
- int width, int height)
+
+/* exported interface documented in content/protected.h */
+void
+content__reformat(struct content *c, bool background, int width, int height)
{
union content_msg_data data;
assert(c != 0);
assert(c->status == CONTENT_STATUS_READY ||
- c->status == CONTENT_STATUS_DONE);
+ c->status == CONTENT_STATUS_DONE);
assert(c->locked == false);
c->available_width = width;
@@ -374,19 +346,14 @@ void content__reformat(struct content *c, bool background,
}
-/**
- * Destroy and free a content.
- *
- * Calls the destroy function for the content, and frees the structure.
- */
-
+/* exported interface documented in content/content.h */
void content_destroy(struct content *c)
{
struct content_rfc5988_link *link;
assert(c);
NSLOG(netsurf, INFO, "content %p %s", c,
- nsurl_access_log(llcache_handle_get_url(c->llcache)));
+ nsurl_access_log(llcache_handle_get_url(c->llcache)));
assert(c->locked == false);
if (c->handler->destroy != NULL)
@@ -422,18 +389,12 @@ void content_destroy(struct content *c)
}
-/**
- * Handle mouse movements in a content window.
- *
- * \param h Content handle
- * \param bw browser window
- * \param mouse state of mouse buttons and modifier keys
- * \param x coordinate of mouse
- * \param y coordinate of mouse
- */
-
-void content_mouse_track(hlcache_handle *h, struct browser_window *bw,
- browser_mouse_state mouse, int x, int y)
+/* exported interface documented in content/content.h */
+void
+content_mouse_track(hlcache_handle *h,
+ struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != NULL);
@@ -451,24 +412,12 @@ void content_mouse_track(hlcache_handle *h, struct
browser_window *bw,
}
-/**
- * Handle mouse clicks and movements in a content window.
- *
- * \param h Content handle
- * \param bw browser window
- * \param mouse state of mouse buttons and modifier keys
- * \param x coordinate of mouse
- * \param y coordinate of mouse
- *
- * This function handles both hovering and clicking. It is important that the
- * code path is identical (except that hovering doesn't carry out the action),
- * so that the status bar reflects exactly what will happen. Having separate
- * code paths opens the possibility that an attacker will make the status bar
- * show some harmless action where clicking will be harmful.
- */
-
-void content_mouse_action(hlcache_handle *h, struct browser_window *bw,
- browser_mouse_state mouse, int x, int y)
+/* exported interface documented in content/content.h */
+void
+content_mouse_action(hlcache_handle *h,
+ struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != NULL);
@@ -480,14 +429,7 @@ void content_mouse_action(hlcache_handle *h, struct
browser_window *bw,
}
-/**
- * Handle keypresses.
- *
- * \param h Content handle
- * \param key The UCS4 character codepoint
- * \return true if key handled, false otherwise
- */
-
+/* exported interface documented in content/content.h */
bool content_keypress(struct hlcache_handle *h, uint32_t key)
{
struct content *c = hlcache_handle_get_content(h);
@@ -500,34 +442,18 @@ bool content_keypress(struct hlcache_handle *h, uint32_t
key)
}
-/**
- * Request a redraw of an area of a content
- *
- * \param h high-level cache handle
- * \param x x co-ord of left edge
- * \param y y co-ord of top edge
- * \param width Width of rectangle
- * \param height Height of rectangle
- */
+/* exported interface documented in content/content.h */
void content_request_redraw(struct hlcache_handle *h,
- int x, int y, int width, int height)
+ int x, int y, int width, int height)
{
content__request_redraw(hlcache_handle_get_content(h),
- x, y, width, height);
+ x, y, width, height);
}
-/**
- * Request a redraw of an area of a content
- *
- * \param c Content
- * \param x x co-ord of left edge
- * \param y y co-ord of top edge
- * \param width Width of rectangle
- * \param height Height of rectangle
- */
+/* exported interface, documented in content/protected.h */
void content__request_redraw(struct content *c,
- int x, int y, int width, int height)
+ int x, int y, int width, int height)
{
union content_msg_data data;
@@ -542,6 +468,7 @@ void content__request_redraw(struct content *c,
content_broadcast(c, CONTENT_MSG_REDRAW, &data);
}
+
/* exported interface, documented in content/content.h */
bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen)
{
@@ -564,6 +491,7 @@ bool content_exec(struct hlcache_handle *h, const char
*src, size_t srclen)
return c->handler->exec(c, src, srclen);
}
+
/* exported interface, documented in content/content.h */
bool content_saw_insecure_objects(struct hlcache_handle *h)
{
@@ -620,9 +548,13 @@ bool content_saw_insecure_objects(struct hlcache_handle *h)
return false;
}
+
/* exported interface, documented in content/content.h */
-bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
- const struct rect *clip, const struct redraw_context *ctx)
+bool
+content_redraw(hlcache_handle *h,
+ struct content_redraw_data *data,
+ const struct rect *clip,
+ const struct redraw_context *ctx)
{
struct content *c = hlcache_handle_get_content(h);
@@ -643,8 +575,10 @@ bool content_redraw(hlcache_handle *h, struct
content_redraw_data *data,
/* exported interface, documented in content/content.h */
-bool content_scaled_redraw(struct hlcache_handle *h,
- int width, int height, const struct redraw_context *ctx)
+bool
+content_scaled_redraw(struct hlcache_handle *h,
+ int width, int height,
+ const struct redraw_context *ctx)
{
struct content *c = hlcache_handle_get_content(h);
struct redraw_context new_ctx = *ctx;
@@ -710,32 +644,22 @@ bool content_scaled_redraw(struct hlcache_handle *h,
return plot_ok;
}
-/**
- * Register a user for callbacks.
- *
- * \param c the content to register
- * \param callback the callback function
- * \param pw callback private data
- * \return true on success, false otherwise on memory exhaustion
- *
- * The callback will be called when content_broadcast() is
- * called with the content.
- */
-bool content_add_user(
- struct content *c,
- void (*callback)(
- struct content *c,
- content_msg msg,
- const union content_msg_data *data,
- void *pw),
- void *pw)
+/* exported interface documented in content/content.h */
+bool
+content_add_user(struct content *c,
+ void (*callback)(
+ struct content *c,
+ content_msg msg,
+ const union content_msg_data *data,
+ void *pw),
+ void *pw)
{
struct content_user *user;
NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p), user %p %p",
- nsurl_access_log(llcache_handle_get_url(c->llcache)),
- c, callback, pw);
+ nsurl_access_log(llcache_handle_get_url(c->llcache)),
+ c, callback, pw);
user = malloc(sizeof(struct content_user));
if (!user)
return false;
@@ -751,31 +675,25 @@ bool content_add_user(
}
-/**
- * Remove a callback user.
- *
- * The callback function and pw must be identical to those passed to
- * content_add_user().
- */
-
-void content_remove_user(
- struct content *c,
- void (*callback)(
- struct content *c,
- content_msg msg,
- const union content_msg_data *data,
- void *pw),
- void *pw)
+/* exported interface documented in content/content.h */
+void
+content_remove_user(struct content *c,
+ void (*callback)(
+ struct content *c,
+ content_msg msg,
+ const union content_msg_data *data,
+ void *pw),
+ void *pw)
{
struct content_user *user, *next;
NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p), user %p %p",
- nsurl_access_log(llcache_handle_get_url(c->llcache)),
- c, callback, pw);
+ nsurl_access_log(llcache_handle_get_url(c->llcache)),
+ c, callback, pw);
/* user_list starts with a sentinel */
for (user = c->user_list; user->next != 0 &&
- !(user->next->callback == callback &&
- user->next->pw == pw); user = user->next)
+ !(user->next->callback == callback &&
+ user->next->pw == pw); user = user->next)
;
if (user->next == 0) {
NSLOG(netsurf, INFO, "user not found in list");
@@ -791,10 +709,8 @@ void content_remove_user(
free(next);
}
-/**
- * Count users for the content.
- */
+/* exported interface documented in content/content.h */
uint32_t content_count_users(struct content *c)
{
struct content_user *user;
@@ -810,13 +726,8 @@ uint32_t content_count_users(struct content *c)
return counter - 1; /* Subtract 1 for the sentinel */
}
-/**
- * Determine if quirks mode matches
- *
- * \param c Content to consider
- * \param quirks Quirks mode to match
- * \return True if quirks match, false otherwise
- */
+
+/* exported interface documented in content/content.h */
bool content_matches_quirks(struct content *c, bool quirks)
{
if (c->handler->matches_quirks == NULL)
@@ -825,23 +736,17 @@ bool content_matches_quirks(struct content *c, bool
quirks)
return c->handler->matches_quirks(c, quirks);
}
-/**
- * Determine if a content is shareable
- *
- * \param c Content to consider
- * \return True if content is shareable, false otherwise
- */
+
+/* exported interface documented in content/content.h */
bool content_is_shareable(struct content *c)
{
return c->handler->no_share == false;
}
-/**
- * Send a message to all users.
- */
+/* exported interface documented in content/protected.h */
void content_broadcast(struct content *c, content_msg msg,
- const union content_msg_data *data)
+ const union content_msg_data *data)
{
struct content_user *user, *next;
assert(c);
@@ -854,8 +759,10 @@ void content_broadcast(struct content *c, content_msg msg,
}
}
+
/* exported interface documented in content_protected.h */
-void content_broadcast_error(struct content *c, nserror errorcode, const char
*msg)
+void
+content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
{
struct content_user *user, *next;
union content_msg_data data;
@@ -869,24 +776,13 @@ void content_broadcast_error(struct content *c, nserror
errorcode, const char *m
next = user->next; /* user may be destroyed during callback */
if (user->callback != 0) {
user->callback(c, CONTENT_MSG_ERROR,
- &data, user->pw);
+ &data, user->pw);
}
}
}
-/**
- * A window containing the content has been opened.
- *
- * \param h handle to content that has been opened
- * \param bw browser window containing the content
- * \param page content of type CONTENT_HTML containing h, or NULL if not an
- * object within a page
- * \param params object parameters, or NULL if not an object
- *
- * Calls the open function for the content.
- */
-
+/* exported interface, documented in content/content.h */
nserror
content_open(hlcache_handle *h,
struct browser_window *bw,
@@ -899,7 +795,7 @@ content_open(hlcache_handle *h,
c = hlcache_handle_get_content(h);
assert(c != 0);
NSLOG(netsurf, INFO, "content %p %s", c,
- nsurl_access_log(llcache_handle_get_url(c->llcache)));
+ nsurl_access_log(llcache_handle_get_url(c->llcache)));
if (c->handler->open != NULL) {
res = c->handler->open(c, bw, page, params);
} else {
@@ -909,12 +805,7 @@ content_open(hlcache_handle *h,
}
-/**
- * The window containing the content has been closed.
- *
- * Calls the close function for the content.
- */
-
+/* exported interface, documented in content/content.h */
nserror content_close(hlcache_handle *h)
{
struct content *c;
@@ -932,7 +823,7 @@ nserror content_close(hlcache_handle *h)
}
NSLOG(netsurf, INFO, "content %p %s", c,
- nsurl_access_log(llcache_handle_get_url(c->llcache)));
+ nsurl_access_log(llcache_handle_get_url(c->llcache)));
if (c->handler->close != NULL) {
res = c->handler->close(c);
} else {
@@ -942,11 +833,7 @@ nserror content_close(hlcache_handle *h)
}
-/**
- * Tell a content that any selection it has, or one of its objects has, must be
- * cleared.
- */
-
+/* exported interface, documented in content/content.h */
void content_clear_selection(hlcache_handle *h)
{
struct content *c = hlcache_handle_get_content(h);
@@ -957,11 +844,7 @@ void content_clear_selection(hlcache_handle *h)
}
-/**
- * Get a text selection from a content. Ownership is passed to the caller,
- * who must free() it.
- */
-
+/* exported interface, documented in content/content.h */
char * content_get_selection(hlcache_handle *h)
{
struct content *c = hlcache_handle_get_content(h);
@@ -973,9 +856,12 @@ char * content_get_selection(hlcache_handle *h)
return NULL;
}
+
/* exported interface documented in content/content.h */
-nserror content_get_contextual_content(struct hlcache_handle *h,
- int x, int y, struct browser_window_features *data)
+nserror
+content_get_contextual_content(struct hlcache_handle *h,
+ int x, int y,
+ struct browser_window_features *data)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -989,8 +875,11 @@ nserror content_get_contextual_content(struct
hlcache_handle *h,
}
-bool content_scroll_at_point(struct hlcache_handle *h,
- int x, int y, int scrx, int scry)
+/* exported interface, documented in content/content.h */
+bool
+content_scroll_at_point(struct hlcache_handle *h,
+ int x, int y,
+ int scrx, int scry)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -1002,8 +891,11 @@ bool content_scroll_at_point(struct hlcache_handle *h,
}
-bool content_drop_file_at_point(struct hlcache_handle *h,
- int x, int y, char *file)
+/* exported interface, documented in content/content.h */
+bool
+content_drop_file_at_point(struct hlcache_handle *h,
+ int x, int y,
+ char *file)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -1015,8 +907,12 @@ bool content_drop_file_at_point(struct hlcache_handle *h,
}
-void content_search(struct hlcache_handle *h, void *context,
- search_flags_t flags, const char *string)
+/* exported interface, documented in content/content.h */
+void
+content_search(struct hlcache_handle *h,
+ void *context,
+ search_flags_t flags,
+ const char *string)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -1027,6 +923,7 @@ void content_search(struct hlcache_handle *h, void
*context,
}
+/* exported interface, documented in content/content.h */
void content_search_clear(struct hlcache_handle *h)
{
struct content *c = hlcache_handle_get_content(h);
@@ -1037,8 +934,10 @@ void content_search_clear(struct hlcache_handle *h)
}
}
+
/* exported interface documented in content/content.h */
-nserror content_debug_dump(struct hlcache_handle *h, FILE *f, enum
content_debug op)
+nserror
+content_debug_dump(struct hlcache_handle *h, FILE *f, enum content_debug op)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -1050,6 +949,7 @@ nserror content_debug_dump(struct hlcache_handle *h, FILE
*f, enum content_debug
return c->handler->debug_dump(c, f, op);
}
+
/* exported interface documented in content/content.h */
nserror content_debug(struct hlcache_handle *h, enum content_debug op)
{
@@ -1077,7 +977,7 @@ content_find_rfc5988_link(hlcache_handle *h, lwc_string
*rel)
while (link != NULL) {
if (lwc_string_caseless_isequal(link->rel, rel,
- &rel_match) == lwc_error_ok && rel_match) {
+ &rel_match) == lwc_error_ok &&
rel_match) {
break;
}
link = link->next;
@@ -1085,6 +985,8 @@ content_find_rfc5988_link(hlcache_handle *h, lwc_string
*rel)
return link;
}
+
+/* exported interface documented in content/protected.h */
struct content_rfc5988_link *
content__free_rfc5988_link(struct content_rfc5988_link *link)
{
@@ -1111,8 +1013,11 @@ content__free_rfc5988_link(struct content_rfc5988_link
*link)
return next;
}
-bool content__add_rfc5988_link(struct content *c,
- const struct content_rfc5988_link *link)
+
+/* exported interface documented in content/protected.h */
+bool
+content__add_rfc5988_link(struct content *c,
+ const struct content_rfc5988_link *link)
{
struct content_rfc5988_link *newlink;
union content_msg_data msg_data;
@@ -1160,7 +1065,6 @@ bool content__add_rfc5988_link(struct content *c,
}
-
/* exported interface documented in content/content.h */
nsurl *content_get_url(struct content *c)
{
@@ -1189,6 +1093,7 @@ lwc_string *content_get_mime_type(hlcache_handle *h)
return content__get_mime_type(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
lwc_string *content__get_mime_type(struct content *c)
{
@@ -1221,6 +1126,7 @@ const char *content_get_title(hlcache_handle *h)
return content__get_title(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
const char *content__get_title(struct content *c)
{
@@ -1228,7 +1134,7 @@ const char *content__get_title(struct content *c)
return NULL;
return c->title != NULL ? c->title :
- nsurl_access(llcache_handle_get_url(c->llcache));
+ nsurl_access(llcache_handle_get_url(c->llcache));
}
@@ -1238,6 +1144,7 @@ content_status content_get_status(hlcache_handle *h)
return content__get_status(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
content_status content__get_status(struct content *c)
{
@@ -1254,6 +1161,7 @@ const char *content_get_status_message(hlcache_handle *h)
return content__get_status_message(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
const char *content__get_status_message(struct content *c)
{
@@ -1270,6 +1178,7 @@ int content_get_width(hlcache_handle *h)
return content__get_width(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
int content__get_width(struct content *c)
{
@@ -1286,6 +1195,7 @@ int content_get_height(hlcache_handle *h)
return content__get_height(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
int content__get_height(struct content *c)
{
@@ -1302,6 +1212,7 @@ int content_get_available_width(hlcache_handle *h)
return content__get_available_width(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
int content__get_available_width(struct content *c)
{
@@ -1318,6 +1229,7 @@ const uint8_t *content_get_source_data(hlcache_handle *h,
size_t *size)
return content__get_source_data(hlcache_handle_get_content(h), size);
}
+
/* exported interface documented in content/content_protected.h */
const uint8_t *content__get_source_data(struct content *c, size_t *size)
{
@@ -1330,12 +1242,14 @@ const uint8_t *content__get_source_data(struct content
*c, size_t *size)
return llcache_handle_get_source_data(c->llcache, size);
}
+
/* exported interface documented in content/content.h */
void content_invalidate_reuse_data(hlcache_handle *h)
{
content__invalidate_reuse_data(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
void content__invalidate_reuse_data(struct content *c)
{
@@ -1346,12 +1260,14 @@ void content__invalidate_reuse_data(struct content *c)
llcache_handle_invalidate_cache_data(c->llcache);
}
+
/* exported interface documented in content/content.h */
nsurl *content_get_refresh_url(hlcache_handle *h)
{
return content__get_refresh_url(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
nsurl *content__get_refresh_url(struct content *c)
{
@@ -1427,14 +1343,16 @@ bool content_get_quirks(hlcache_handle *h)
/* exported interface documented in content/content.h */
-const char *content_get_encoding(hlcache_handle *h, enum content_encoding_type
op)
+const char *
+content_get_encoding(hlcache_handle *h, enum content_encoding_type op)
{
return content__get_encoding(hlcache_handle_get_content(h), op);
}
/* exported interface documented in content/content_protected.h */
-const char *content__get_encoding(struct content *c, enum
content_encoding_type op)
+const char *
+content__get_encoding(struct content *c, enum content_encoding_type op)
{
const char *encoding = NULL;
@@ -1461,12 +1379,8 @@ bool content__is_locked(struct content *c)
return c->locked;
}
-/**
- * Retrieve the low-level cache handle for a content
- *
- * \param c Content to retrieve from
- * \return Low-level cache handle
- */
+
+/* exported interface documented in content/content.h */
const llcache_handle *content_get_llcache_handle(struct content *c)
{
if (c == NULL)
@@ -1475,12 +1389,8 @@ const llcache_handle *content_get_llcache_handle(struct
content *c)
return c->llcache;
}
-/**
- * Clone a content object in its current state.
- *
- * \param c Content to clone
- * \return Clone of \a c
- */
+
+/* exported interface documented in content/protected.h */
struct content *content_clone(struct content *c)
{
struct content *nc;
@@ -1493,13 +1403,8 @@ struct content *content_clone(struct content *c)
return nc;
};
-/**
- * Clone a content's data members
- *
- * \param c Content to clone
- * \param nc Content to populate
- * \return NSERROR_OK on success, appropriate error otherwise
- */
+
+/* exported interface documented in content/protected.h */
nserror content__clone(const struct content *c, struct content *nc)
{
nserror error;
@@ -1564,12 +1469,8 @@ nserror content__clone(const struct content *c, struct
content *nc)
return NSERROR_OK;
}
-/**
- * Abort a content object
- *
- * \param c The content object to abort
- * \return NSERROR_OK on success, otherwise appropriate error
- */
+
+/* exported interface documented in content/content.h */
nserror content_abort(struct content *c)
{
NSLOG(netsurf, INFO, "Aborting %p", c);
diff --git a/content/content.h b/content/content.h
index c2605a7..169fd5a 100644
--- a/content/content.h
+++ b/content/content.h
@@ -287,41 +287,87 @@ union content_msg_data {
/* The following are for hlcache */
-void content_destroy(struct content *c);
-
-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);
+/**
+ * Destroy and free a content.
+ *
+ * Calls the destroy function for the content, and frees the structure.
+ */
+void content_destroy(struct content *c);
+/**
+ * Register a user for callbacks.
+ *
+ * \param c the content to register
+ * \param callback the user callback function
+ * \param pw callback private data
+ * \return true on success, false otherwise on memory exhaustion
+ *
+ * The callback will be called when content_broadcast() is
+ * called with the content.
+ */
+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);
-void content_remove_user(
- struct content *c,
- void (*callback)(
- struct content *c,
- content_msg msg,
- const union content_msg_data *data,
- void *pw),
- void *pw);
+/**
+ * Remove a callback user.
+ *
+ * The callback function and pw must be identical to those passed to
+ * content_add_user().
+ *
+ * \param c Content to remove user from
+ * \param callback passed when added
+ * \param ctx Context passed when added
+ */
+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);
+/**
+ * Count users for the content.
+ *
+ * \param c Content to consider
+ */
uint32_t content_count_users(struct content *c);
+/**
+ * Determine if quirks mode matches
+ *
+ * \param c Content to consider
+ * \param quirks Quirks mode to match
+ * \return True if quirks match, false otherwise
+ */
bool content_matches_quirks(struct content *c, bool quirks);
-
+/**
+ * Determine if a content is shareable
+ *
+ * \param c Content to consider
+ * \return True if content is shareable, false otherwise
+ */
bool content_is_shareable(struct content *c);
-/* only used by cocoa apple image handling and for getting nsurl of content */
+/**
+ * Retrieve the low-level cache handle for a content
+ *
+ * \note only used by hlcache
+ *
+ * \param c Content to retrieve from
+ * \return Low-level cache handle
+ */
const struct llcache_handle *content_get_llcache_handle(struct content *c);
-
/**
* Retrieve URL associated with content
*
@@ -330,35 +376,123 @@ const struct llcache_handle
*content_get_llcache_handle(struct content *c);
*/
struct nsurl *content_get_url(struct content *c);
+/**
+ * Clone a content object in its current state.
+ *
+ * \param c Content to clone
+ * \return Clone of \a c
+ */
struct content *content_clone(struct content *c);
+/**
+ * Abort a content object
+ *
+ * \param c The content object to abort
+ * \return NSERROR_OK on success, otherwise appropriate error
+ */
nserror content_abort(struct content *c);
/* Client functions */
+
+/**
+ * Get whether a content can reformat
+ *
+ * \param h content to check
+ * \return whether the content can reformat
+ */
bool content_can_reformat(struct hlcache_handle *h);
+/**
+ * Reformat to new size.
+ *
+ * Calls the reformat function for the content.
+ */
void content_reformat(struct hlcache_handle *h, bool background,
int width, int height);
+/**
+ * Request a redraw of an area of a content
+ *
+ * \param h high-level cache handle
+ * \param x x co-ord of left edge
+ * \param y y co-ord of top edge
+ * \param width Width of rectangle
+ * \param height Height of rectangle
+ */
void content_request_redraw(struct hlcache_handle *h,
int x, int y, int width, int height);
+/**
+ * Handle mouse movements in a content window.
+ *
+ * \param h Content handle
+ * \param bw browser window
+ * \param mouse state of mouse buttons and modifier keys
+ * \param x coordinate of mouse
+ * \param y coordinate of mouse
+ */
void content_mouse_track(struct hlcache_handle *h, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
+/**
+ * Handle mouse clicks and movements in a content window.
+ *
+ * \param h Content handle
+ * \param bw browser window
+ * \param mouse state of mouse buttons and modifier keys
+ * \param x coordinate of mouse
+ * \param y coordinate of mouse
+ *
+ * This function handles both hovering and clicking. It is important that the
+ * code path is identical (except that hovering doesn't carry out the action),
+ * so that the status bar reflects exactly what will happen. Having separate
+ * code paths opens the possibility that an attacker will make the status bar
+ * show some harmless action where clicking will be harmful.
+ */
void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
+/**
+ * Handle keypresses.
+ *
+ * \param h Content handle
+ * \param key The UCS4 character codepoint
+ * \return true if key handled, false otherwise
+ */
bool content_keypress(struct hlcache_handle *h, uint32_t key);
+/**
+ * A window containing the content has been opened.
+ *
+ * \param h handle to content that has been opened
+ * \param bw browser window containing the content
+ * \param page content of type CONTENT_HTML containing h, or NULL if not an
+ * object within a page
+ * \param params object parameters, or NULL if not an object
+ *
+ * Calls the open function for the content.
+ */
nserror content_open(struct hlcache_handle *h, struct browser_window *bw,
struct content *page, struct object_params *params);
+/**
+ * The window containing the content has been closed.
+ *
+ * Calls the close function for the content.
+ */
nserror content_close(struct hlcache_handle *h);
+/**
+ * Tell a content that any selection it has, or one of its objects
+ * has, must be cleared.
+ */
void content_clear_selection(struct hlcache_handle *h);
+/**
+ * Get a text selection from a content. Ownership is passed to the caller,
+ * who must free() it.
+ */
char * content_get_selection(struct hlcache_handle *h);
/**
@@ -372,15 +506,39 @@ char * content_get_selection(struct hlcache_handle *h);
nserror content_get_contextual_content(struct hlcache_handle *h,
int x, int y, struct browser_window_features *data);
+/**
+ * scroll content at coordnate
+ *
+ * \param[in] h Handle to content to examine.
+ * \param[in] x The x coordinate to examine.
+ * \param[in] y The y coordinate to examine.
+ */
bool content_scroll_at_point(struct hlcache_handle *h,
int x, int y, int scrx, int scry);
+/**
+ * Drag and drop a file at coordinate
+ *
+ * \param[in] h Handle to content to examine.
+ * \param[in] x The x coordinate to examine.
+ * \param[in] y The y coordinate to examine.
+ */
bool content_drop_file_at_point(struct hlcache_handle *h,
int x, int y, char *file);
+/**
+ * Search a content
+ *
+ * \param[in] h Handle to content to search.
+ */
void content_search(struct hlcache_handle *h, void *context,
search_flags_t flags, const char *string);
+/**
+ * Clear a search
+ *
+ * \param[in] h Handle to content to clear search from.
+ */
void content_search_clear(struct hlcache_handle *h);
diff --git a/content/content_protected.h b/content/content_protected.h
index a879352..3b6d1f7 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -24,18 +24,25 @@
* The content functions manipulate struct contents, which correspond to URLs.
*/
-#ifndef _NETSURF_CONTENT_CONTENT_PROTECTED_H_
-#define _NETSURF_CONTENT_CONTENT_PROTECTED_H_
+#ifndef NETSURF_CONTENT_CONTENT_PROTECTED_H_
+#define NETSURF_CONTENT_CONTENT_PROTECTED_H_
#include <stdio.h>
-#include "utils/nsurl.h"
#include "netsurf/content_type.h"
#include "content/content.h"
+struct nsurl;
struct content_redraw_data;
struct http_parameter;
+struct llcache_handle;
+struct object_params;
+/**
+ * Content operation function table
+ *
+ * function table implementing a content type.
+ */
struct content_handler {
void (*fini)(void);
@@ -46,7 +53,7 @@ struct content_handler {
const char *fallback_charset, bool quirks,
struct content **c);
- bool (*process_data)(struct content *c,
+ bool (*process_data)(struct content *c,
const char *data, unsigned int size);
bool (*data_complete)(struct content *c);
void (*reformat)(struct content *c, int width, int height);
@@ -85,14 +92,20 @@ struct content_handler {
bool (*exec)(struct content *c, const char *src, size_t srclen);
bool (*saw_insecure_objects)(struct content *c);
- /** handler dependant content sensitive internal data interface. */
+ /**
+ * handler dependant content sensitive internal data interface.
+ */
void * (*get_internal)(const struct content *c, void *context);
- /** There must be one content per user for this type. */
+ /**
+ * There must be one content per user for this type.
+ */
bool no_share;
};
-/** Linked list of users of a content. */
+/**
+ * Linked list of users of a content.
+ */
struct content_user
{
void (*callback)(
@@ -105,68 +118,180 @@ struct content_user
struct content_user *next;
};
-/** Corresponds to a single URL. */
+/**
+ * Content which corresponds to a single URL.
+ */
struct content {
- struct llcache_handle *llcache; /**< Low-level cache object */
+ /**
+ * Low-level cache object
+ */
+ struct llcache_handle *llcache;
- lwc_string *mime_type; /**< Original MIME type of data */
+ /**
+ * Original MIME type of data
+ */
+ lwc_string *mime_type;
- const struct content_handler *handler; /**< Handler for content */
+ /**
+ * Handler for content
+ */
+ const struct content_handler *handler;
- content_status status; /**< Current status. */
+ /**
+ * Current status.
+ */
+ content_status status;
- int width, height; /**< Dimensions, if applicable. */
- int available_width; /**< Viewport width. */
- int available_height; /**< Viewport height. */
+ /**
+ * Width dimension, if applicable.
+ */
+ int width;
+ /**
+ * Height dimension, if applicable.
+ */
+ int height;
+ /**
+ * Viewport width.
+ */
+ int available_width;
+ /**
+ * Viewport height.
+ */
+ int available_height;
- bool quirks; /**< Content is in quirks mode */
- char *fallback_charset; /**< Fallback charset, or NULL */
+ /**
+ * Content is in quirks mode
+ */
+ bool quirks;
+ /**
+ * Fallback charset, or NULL
+ */
+ char *fallback_charset;
- nsurl *refresh; /**< URL for refresh request */
+ /**
+ * URL for refresh request
+ */
+ struct nsurl *refresh;
- struct content_rfc5988_link *links; /**< list of metadata links */
+ /**
+ * list of metadata links
+ */
+ struct content_rfc5988_link *links;
- /** Creation timestamp when LOADING or READY.
- * Total time in ms when DONE.
+ /**
+ * Creation timestamp when LOADING or READY. Total time in ms
+ * when DONE.
*/
uint64_t time;
- uint64_t reformat_time; /**< Earliest time to attempt a period
- * reflow while fetching a page's objects.
- */
-
- unsigned int size; /**< Estimated size of all data
- associated with this content */
- char *title; /**< Title for browser window. */
- unsigned int active; /**< Number of child fetches or
- conversions currently in progress. */
- struct content_user *user_list; /**< List of users. */
- char status_message[120]; /**< Full text for status bar. */
- char sub_status[80]; /**< Status of content. */
- /** Content is being processed: data structures may be inconsistent
- * and content must not be redrawn or modified. */
+ /**
+ * Earliest time to attempt a period reflow while fetching a
+ * page's objects.
+ */
+ uint64_t reformat_time;
+
+ /**
+ * Estimated size of all data associated with this content
+ */
+ unsigned int size;
+ /**
+ * Title for browser window.
+ */
+ char *title;
+ /**
+ * Number of child fetches or conversions currently in progress.
+ */
+ unsigned int active;
+ /**
+ * List of users.
+ */
+ struct content_user *user_list;
+ /**
+ * Full text for status bar.
+ */
+ char status_message[120];
+ /**
+ * Status of content.
+ */
+ char sub_status[80];
+ /**
+ * Content is being processed: data structures may be
+ * inconsistent and content must not be redrawn or modified.
+ */
bool locked;
- unsigned long total_size; /**< Total data size, 0 if unknown. */
- long http_code; /**< HTTP status code, 0 if not HTTP. */
+ /**
+ * Total data size, 0 if unknown.
+ */
+ unsigned long total_size;
+ /**
+ * HTTP status code, 0 if not HTTP.
+ */
+ long http_code;
};
extern const char * const content_type_name[];
extern const char * const content_status_name[];
+
+/**
+ * Initialise a new base content structure.
+ *
+ * \param c Content to initialise
+ * \param handler Content handler
+ * \param imime_type MIME type of content
+ * \param params HTTP parameters
+ * \param llcache Source data handle
+ * \param fallback_charset Fallback charset
+ * \param quirks Quirkiness of content
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
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);
+
+/**
+ * Clone a content's data members
+ *
+ * \param c Content to clone
+ * \param nc Content to populate
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
nserror content__clone(const struct content *c, struct content *nc);
+/**
+ * Put a content in status CONTENT_STATUS_READY and unlock the content.
+ */
void content_set_ready(struct content *c);
+
+/**
+ * Put a content in status CONTENT_STATUS_DONE.
+ */
void content_set_done(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.
+ */
void content_set_error(struct content *c);
+/**
+ * Updates content with new status.
+ *
+ * The textual status contained in the content is updated with given string.
+ *
+ * \param c The content to set status in.
+ * \param status_message new textual status
+ */
void content_set_status(struct content *c, const char *status_message);
-void content_broadcast(struct content *c, content_msg msg,
- const union content_msg_data *data);
+
+/**
+ * Send a message to all users.
+ */
+void content_broadcast(struct content *c, content_msg msg, const union
content_msg_data *data);
+
/**
* Send an error message to all users.
*
@@ -176,16 +301,42 @@ void content_broadcast(struct content *c, content_msg msg,
*/
void content_broadcast_error(struct content *c, nserror errorcode, const char
*msg);
-bool content__add_rfc5988_link(struct content *c,
- const struct content_rfc5988_link *link);
-struct content_rfc5988_link *content__free_rfc5988_link(
- struct content_rfc5988_link *link);
+/**
+ * associate a metadata link with a content.
+ *
+ * \param c content to add link to
+ * \param link The rfc5988 link to add
+ */
+bool content__add_rfc5988_link(struct content *c, const struct
content_rfc5988_link *link);
-void content__reformat(struct content *c, bool background,
- int width, int height);
-void content__request_redraw(struct content *c,
- int x, int y, int width, int height);
+/**
+ * free a rfc5988 link
+ *
+ * \param link The link to free
+ * \return The next link in the chain
+ */
+struct content_rfc5988_link *content__free_rfc5988_link(struct
content_rfc5988_link *link);
+
+/**
+ * cause a content to be reformatted.
+ *
+ * \param c content to be reformatted
+ * \param background perform reformat in background
+ * \param width The available width to reformat content in
+ * \param height The available height to reformat content in
+ */
+void content__reformat(struct content *c, bool background, int width, int
height);
+/**
+ * Request a redraw of an area of a content
+ *
+ * \param c Content
+ * \param x x co-ord of left edge
+ * \param y y co-ord of top edge
+ * \param width Width of rectangle
+ * \param height Height of rectangle
+ */
+void content__request_redraw(struct content *c, int x, int y, int width, int
height);
/**
* Retrieve mime-type of content
@@ -270,7 +421,7 @@ void content__invalidate_reuse_data(struct content *c);
* \param c Content to retrieve refresh URL from
* \return Pointer to URL or NULL if none
*/
-nsurl *content__get_refresh_url(struct content *c);
+struct nsurl *content__get_refresh_url(struct content *c);
/**
* Retrieve the bitmap contained in an image content
diff --git a/content/handlers/html/box_construct.c
b/content/handlers/html/box_construct.c
index 3d10017..5ae7552 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -33,6 +33,7 @@
#include "utils/talloc.h"
#include "utils/string.h"
#include "utils/ascii.h"
+#include "utils/nsurl.h"
#include "netsurf/misc.h"
#include "css/select.h"
#include "desktop/gui_internal.h"
@@ -68,7 +69,7 @@ struct box_construct_props {
/** Style from which to inherit, or NULL if none */
const css_computed_style *parent_style;
/** Current link target, or NULL if none */
- nsurl *href;
+ struct nsurl *href;
/** Current frame target, or NULL if none */
const char *target;
/** Current title attribute, or NULL if none */
diff --git a/content/handlers/html/box_manipulate.c
b/content/handlers/html/box_manipulate.c
index d88e360..d23091b 100644
--- a/content/handlers/html/box_manipulate.c
+++ b/content/handlers/html/box_manipulate.c
@@ -28,6 +28,7 @@
#include "utils/errors.h"
#include "utils/talloc.h"
+#include "utils/nsurl.h"
#include "netsurf/types.h"
#include "netsurf/mouse.h"
#include "desktop/scrollbar.h"
diff --git a/content/handlers/html/box_special.c
b/content/handlers/html/box_special.c
index 06f2f91..a369ec8 100644
--- a/content/handlers/html/box_special.c
+++ b/content/handlers/html/box_special.c
@@ -36,6 +36,7 @@
#include "utils/talloc.h"
#include "utils/string.h"
#include "utils/ascii.h"
+#include "utils/nsurl.h"
#include "netsurf/plot_style.h"
#include "css/hints.h"
#include "desktop/frame_types.h"
diff --git a/content/handlers/html/dom_event.c
b/content/handlers/html/dom_event.c
index 4468e82..08a1e45 100644
--- a/content/handlers/html/dom_event.c
+++ b/content/handlers/html/dom_event.c
@@ -27,6 +27,7 @@
#include "utils/log.h"
#include "utils/ascii.h"
#include "utils/string.h"
+#include "utils/nsurl.h"
#include "javascript/js.h"
#include "html/private.h"
diff --git a/content/handlers/html/layout.c b/content/handlers/html/layout.c
index 3d022ab..b87fd16 100644
--- a/content/handlers/html/layout.c
+++ b/content/handlers/html/layout.c
@@ -47,6 +47,7 @@
#include "utils/talloc.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
+#include "utils/nsurl.h"
#include "netsurf/inttypes.h"
#include "netsurf/content.h"
#include "netsurf/browser_window.h"
diff --git a/content/handlers/html/object.h b/content/handlers/html/object.h
index 85734fd..67d770c 100644
--- a/content/handlers/html/object.h
+++ b/content/handlers/html/object.h
@@ -27,6 +27,7 @@
struct html_content;
struct browser_window;
struct box;
+struct nsurl;
/**
* Start a fetch for an object required by a page.
@@ -42,7 +43,7 @@ struct box;
* \param background this is a background image
* \return true on success, false on memory exhaustion
*/
-bool html_fetch_object(struct html_content *c, nsurl *url, struct box *box,
content_type permitted_types, bool background);
+bool html_fetch_object(struct html_content *c, struct nsurl *url, struct box
*box, content_type permitted_types, bool background);
/**
* release memory of content objects associated with a HTML content
diff --git a/content/handlers/html/private.h b/content/handlers/html/private.h
index 3d6d706..dff0b78 100644
--- a/content/handlers/html/private.h
+++ b/content/handlers/html/private.h
@@ -107,7 +107,7 @@ typedef struct html_content {
dom_hubbub_encoding_source encoding_source;
/** Base URL (may be a copy of content->url). */
- nsurl *base_url;
+ struct nsurl *base_url;
/** Base target */
char *base_target;
@@ -341,7 +341,7 @@ struct form_control *html_forms_get_control_for_node(struct
form *forms,
* \return NSERROR_OK on successful registration or error code on failure.
*/
nserror html_css_fetcher_register(void);
-nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url,
+nserror html_css_fetcher_add_item(dom_string *data, struct nsurl *base_url,
uint32_t *key);
diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c
index 5124360..6194389 100644
--- a/content/handlers/image/svg.c
+++ b/content/handlers/image/svg.c
@@ -30,6 +30,7 @@
#include "utils/messages.h"
#include "utils/utils.h"
+#include "utils/nsurl.h"
#include "netsurf/plotters.h"
#include "netsurf/content.h"
#include "content/content_protected.h"
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c2f9bcac19d53eff2e01152c190d3727b224660c
commit c2f9bcac19d53eff2e01152c190d3727b224660c
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
remove junk content_add_error api
diff --git a/content/content.c b/content/content.c
index 6ffaebf..d33780f 100644
--- a/content/content.c
+++ b/content/content.c
@@ -1067,12 +1067,6 @@ nserror content_debug(struct hlcache_handle *h, enum
content_debug op)
}
-void content_add_error(struct content *c, const char *token,
- unsigned int line)
-{
-}
-
-
/* exported interface documented in content/content.h */
struct content_rfc5988_link *
content_find_rfc5988_link(hlcache_handle *h, lwc_string *rel)
diff --git a/content/content_protected.h b/content/content_protected.h
index 343a3f5..a879352 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -176,9 +176,6 @@ void content_broadcast(struct content *c, content_msg msg,
*/
void content_broadcast_error(struct content *c, nserror errorcode, const char
*msg);
-void content_add_error(struct content *c, const char *token,
- unsigned int line);
-
bool content__add_rfc5988_link(struct content *c,
const struct content_rfc5988_link *link);
struct content_rfc5988_link *content__free_rfc5988_link(
diff --git a/content/handlers/html/css.c b/content/handlers/html/css.c
index 5758981..d7c9b3c 100644
--- a/content/handlers/html/css.c
+++ b/content/handlers/html/css.c
@@ -127,7 +127,6 @@ html_convert_css_callback(hlcache_handle *css,
s->sheet = NULL;
parent->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
- content_add_error(&parent->base, "?", 0);
break;
case CONTENT_MSG_POINTER:
diff --git a/content/handlers/html/object.c b/content/handlers/html/object.c
index 36726f1..e6edf84 100644
--- a/content/handlers/html/object.c
+++ b/content/handlers/html/object.c
@@ -229,7 +229,6 @@ html_object_callback(hlcache_handle *object,
c->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
- content_add_error(&c->base, "?", 0);
html_object_failed(box, c, o->background);
break;
diff --git a/content/handlers/html/script.c b/content/handlers/html/script.c
index 99275c0..faab08b 100644
--- a/content/handlers/html/script.c
+++ b/content/handlers/html/script.c
@@ -195,7 +195,6 @@ convert_script_async_cb(hlcache_handle *script,
s->data.handle = NULL;
parent->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
- content_add_error(&parent->base, "?", 0);
break;
@@ -259,7 +258,6 @@ convert_script_defer_cb(hlcache_handle *script,
s->data.handle = NULL;
parent->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
- content_add_error(&parent->base, "?", 0);
break;
@@ -348,7 +346,6 @@ convert_script_sync_cb(hlcache_handle *script,
parent->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
- content_add_error(&parent->base, "?", 0);
s->already_started = true;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=b832bfaea8099217ee58cae21ee0807cd9a475db
commit b832bfaea8099217ee58cae21ee0807cd9a475db
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
remove unused junk error values from content struct
saves over half a kilobyte for every content
diff --git a/content/content.c b/content/content.c
index 552ee07..6ffaebf 100644
--- a/content/content.c
+++ b/content/content.c
@@ -113,7 +113,6 @@ nserror content__init(struct content *c, const
content_handler *handler,
c->locked = false;
c->total_size = 0;
c->http_code = 0;
- c->error_count = 0;
content_set_status(c, messages_get("Loading"));
diff --git a/content/content_protected.h b/content/content_protected.h
index af0ee72..343a3f5 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -149,13 +149,6 @@ struct content {
unsigned long total_size; /**< Total data size, 0 if unknown. */
long http_code; /**< HTTP status code, 0 if not HTTP. */
-
- /** Array of first n rendering errors or warnings. */
- struct {
- const char *token;
- unsigned int line; /**< Line no, 0 if not applicable. */
- } error_list[40];
- unsigned int error_count; /**< Number of valid error entries. */
};
extern const char * const content_type_name[];
-----------------------------------------------------------------------
Summary of changes:
content/content.c | 650 +++++++++++++-------------------
content/content.h | 200 ++++++++--
content/content_protected.h | 255 ++++++++++---
content/handlers/html/box_construct.c | 3 +-
content/handlers/html/box_manipulate.c | 1 +
content/handlers/html/box_special.c | 1 +
content/handlers/html/css.c | 1 -
content/handlers/html/dom_event.c | 1 +
content/handlers/html/layout.c | 1 +
content/handlers/html/object.c | 1 -
content/handlers/html/object.h | 3 +-
content/handlers/html/private.h | 4 +-
content/handlers/html/script.c | 3 -
content/handlers/image/svg.c | 1 +
14 files changed, 660 insertions(+), 465 deletions(-)
diff --git a/content/content.c b/content/content.c
index 552ee07..6532587 100644
--- a/content/content.c
+++ b/content/content.c
@@ -49,85 +49,48 @@ const char * const content_status_name[] = {
"ERROR"
};
-static nserror content_llcache_callback(llcache_handle *llcache,
- const llcache_event *event, void *pw);
-static void content_convert(struct content *c);
-
/**
- * Initialise a new content structure.
+ * All data has arrived, convert for display.
*
- * \param c Content to initialise
- * \param handler Content handler
- * \param imime_type MIME type of content
- * \param params HTTP parameters
- * \param llcache Source data handle
- * \param fallback_charset Fallback charset
- * \param quirks Quirkiness of content
- * \return NSERROR_OK on success, appropriate error otherwise
+ * Calls the convert function for the content.
+ *
+ * - If the conversion succeeds, but there is still some processing required
+ * (eg. loading images), the content gets status CONTENT_STATUS_READY, and a
+ * CONTENT_MSG_READY is sent to all users.
+ * - If the conversion succeeds and is complete, the content gets status
+ * CONTENT_STATUS_DONE, and CONTENT_MSG_READY then CONTENT_MSG_DONE are sent.
+ * - If the conversion fails, CONTENT_MSG_ERROR is sent. The content will soon
+ * be destroyed and must no longer be used.
*/
-
-nserror content__init(struct content *c, const content_handler *handler,
- lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
- bool quirks)
+static void content_convert(struct content *c)
{
- struct content_user *user_sentinel;
- nserror error;
-
- NSLOG(netsurf, INFO, "url "URL_FMT_SPC" -> %p",
- nsurl_access_log(llcache_handle_get_url(llcache)), c);
-
- user_sentinel = calloc(1, sizeof(struct content_user));
- if (user_sentinel == NULL) {
- return NSERROR_NOMEM;
- }
+ assert(c);
+ assert(c->status == CONTENT_STATUS_LOADING ||
+ c->status == CONTENT_STATUS_ERROR);
- if (fallback_charset != NULL) {
- c->fallback_charset = strdup(fallback_charset);
- if (c->fallback_charset == NULL) {
- free(user_sentinel);
- return NSERROR_NOMEM;
- }
- }
+ if (c->status != CONTENT_STATUS_LOADING)
+ return;
- c->llcache = llcache;
- c->mime_type = lwc_string_ref(imime_type);
- c->handler = handler;
- c->status = CONTENT_STATUS_LOADING;
- c->width = 0;
- c->height = 0;
- c->available_width = 0;
- c->available_height = 0;
- c->quirks = quirks;
- c->refresh = 0;
- nsu_getmonotonic_ms(&c->time);
- c->size = 0;
- c->title = NULL;
- c->active = 0;
- user_sentinel->callback = NULL;
- user_sentinel->pw = NULL;
- user_sentinel->next = NULL;
- c->user_list = user_sentinel;
- c->sub_status[0] = 0;
- c->locked = false;
- c->total_size = 0;
- c->http_code = 0;
- c->error_count = 0;
+ if (c->locked == true)
+ return;
- content_set_status(c, messages_get("Loading"));
+ NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p)",
+ nsurl_access_log(llcache_handle_get_url(c->llcache)), c);
- /* Finally, claim low-level cache events */
- error = llcache_handle_change_callback(llcache,
- content_llcache_callback, c);
- if (error != NSERROR_OK) {
- lwc_string_unref(c->mime_type);
- return error;
+ if (c->handler->data_complete != NULL) {
+ c->locked = true;
+ if (c->handler->data_complete(c) == false) {
+ content_set_error(c);
+ }
+ /* Conversion to the READY state will unlock the content */
+ } else {
+ content_set_ready(c);
+ content_set_done(c);
}
-
- return NSERROR_OK;
}
+
/**
* Handler for low-level cache events
*
@@ -136,8 +99,9 @@ nserror content__init(struct content *c, const
content_handler *handler,
* \param pw Pointer to our context
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror content_llcache_callback(llcache_handle *llcache,
- const llcache_event *event, void *pw)
+static nserror
+content_llcache_callback(llcache_handle *llcache,
+ const llcache_event *event, void *pw)
{
struct content *c = pw;
union content_msg_data msg_data;
@@ -153,8 +117,8 @@ nserror content_llcache_callback(llcache_handle *llcache,
case LLCACHE_EVENT_HAD_DATA:
if (c->handler->process_data != NULL) {
if (c->handler->process_data(c,
- (const char *) event->data.data.buf,
- event->data.data.len) == false) {
+ (const char *)
event->data.data.buf,
+ event->data.data.len) ==
false) {
llcache_handle_abort(c->llcache);
c->status = CONTENT_STATUS_ERROR;
/** \todo It's not clear what error this is */
@@ -163,17 +127,17 @@ nserror content_llcache_callback(llcache_handle *llcache,
}
break;
case LLCACHE_EVENT_DONE:
- {
- size_t source_size;
+ {
+ size_t source_size;
- (void) llcache_handle_get_source_data(llcache, &source_size);
+ (void) llcache_handle_get_source_data(llcache,
&source_size);
- content_set_status(c, messages_get("Processing"));
- msg_data.explicit_status_text = NULL;
- content_broadcast(c, CONTENT_MSG_STATUS, &msg_data);
+ content_set_status(c, messages_get("Processing"));
+ msg_data.explicit_status_text = NULL;
+ content_broadcast(c, CONTENT_MSG_STATUS, &msg_data);
- content_convert(c);
- }
+ content_convert(c);
+ }
break;
case LLCACHE_EVENT_ERROR:
/** \todo Error page? */
@@ -197,108 +161,123 @@ nserror content_llcache_callback(llcache_handle
*llcache,
return error;
}
+
/**
- * Get whether a content can reformat
+ * update content status message
*
- * \param h content to check
- * \return whether the content can reformat
+ * \param c the content to update.
*/
-bool content_can_reformat(hlcache_handle *h)
-{
- struct content *c = hlcache_handle_get_content(h);
-
- if (c == NULL)
- return false;
-
- return (c->handler->reformat != NULL);
-}
-
-
static void content_update_status(struct content *c)
{
if (c->status == CONTENT_STATUS_LOADING ||
- c->status == CONTENT_STATUS_READY) {
+ c->status == CONTENT_STATUS_READY) {
/* Not done yet */
snprintf(c->status_message, sizeof (c->status_message),
- "%s%s%s", messages_get("Fetching"),
- c->sub_status[0] != '\0' ? ", " : " ",
- c->sub_status);
+ "%s%s%s", messages_get("Fetching"),
+ c->sub_status[0] != '\0' ? ", " : " ",
+ c->sub_status);
} else {
snprintf(c->status_message, sizeof (c->status_message),
- "%s (%.1fs)", messages_get("Done"),
- (float) c->time / 1000);
+ "%s (%.1fs)", messages_get("Done"),
+ (float) c->time / 1000);
}
}
-/**
- * Updates content with new status.
- *
- * The textual status contained in the content is updated with given string.
- *
- * \param c The content to set status in.
- * \param status_message new textual status
- */
-
-void content_set_status(struct content *c, const char *status_message)
+/* exported interface documented in content/protected.h */
+nserror
+content__init(struct content *c,
+ const content_handler *handler,
+ lwc_string *imime_type,
+ const struct http_parameter *params,
+ llcache_handle *llcache,
+ const char *fallback_charset,
+ bool quirks)
{
- size_t len = strlen(status_message);
+ struct content_user *user_sentinel;
+ nserror error;
- if (len >= sizeof(c->sub_status)) {
- len = sizeof(c->sub_status) - 1;
+ NSLOG(netsurf, INFO, "url "URL_FMT_SPC" -> %p",
+ nsurl_access_log(llcache_handle_get_url(llcache)), c);
+
+ user_sentinel = calloc(1, sizeof(struct content_user));
+ if (user_sentinel == NULL) {
+ return NSERROR_NOMEM;
}
- memcpy(c->sub_status, status_message, len);
- c->sub_status[len] = '\0';
- content_update_status(c);
-}
+ if (fallback_charset != NULL) {
+ c->fallback_charset = strdup(fallback_charset);
+ if (c->fallback_charset == NULL) {
+ free(user_sentinel);
+ return NSERROR_NOMEM;
+ }
+ }
+
+ c->llcache = llcache;
+ c->mime_type = lwc_string_ref(imime_type);
+ c->handler = handler;
+ c->status = CONTENT_STATUS_LOADING;
+ c->width = 0;
+ c->height = 0;
+ c->available_width = 0;
+ c->available_height = 0;
+ c->quirks = quirks;
+ c->refresh = 0;
+ nsu_getmonotonic_ms(&c->time);
+ c->size = 0;
+ c->title = NULL;
+ c->active = 0;
+ user_sentinel->callback = NULL;
+ user_sentinel->pw = NULL;
+ user_sentinel->next = NULL;
+ c->user_list = user_sentinel;
+ c->sub_status[0] = 0;
+ c->locked = false;
+ c->total_size = 0;
+ c->http_code = 0;
+ content_set_status(c, messages_get("Loading"));
-/**
- * All data has arrived, convert for display.
- *
- * Calls the convert function for the content.
- *
- * - If the conversion succeeds, but there is still some processing required
- * (eg. loading images), the content gets status CONTENT_STATUS_READY, and a
- * CONTENT_MSG_READY is sent to all users.
- * - If the conversion succeeds and is complete, the content gets status
- * CONTENT_STATUS_DONE, and CONTENT_MSG_READY then CONTENT_MSG_DONE are sent.
- * - If the conversion fails, CONTENT_MSG_ERROR is sent. The content will soon
- * be destroyed and must no longer be used.
- */
+ /* Finally, claim low-level cache events */
+ error = llcache_handle_change_callback(llcache,
+ content_llcache_callback, c);
+ if (error != NSERROR_OK) {
+ lwc_string_unref(c->mime_type);
+ return error;
+ }
-void content_convert(struct content *c)
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in content/content.h */
+bool content_can_reformat(hlcache_handle *h)
{
- assert(c);
- assert(c->status == CONTENT_STATUS_LOADING ||
- c->status == CONTENT_STATUS_ERROR);
+ struct content *c = hlcache_handle_get_content(h);
- if (c->status != CONTENT_STATUS_LOADING)
- return;
+ if (c == NULL)
+ return false;
- if (c->locked == true)
- return;
+ return (c->handler->reformat != NULL);
+}
- NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p)",
- nsurl_access_log(llcache_handle_get_url(c->llcache)), c);
- if (c->handler->data_complete != NULL) {
- c->locked = true;
- if (c->handler->data_complete(c) == false) {
- content_set_error(c);
- }
- /* Conversion to the READY state will unlock the content */
- } else {
- content_set_ready(c);
- content_set_done(c);
+/* exported interface documented in content/protected.h */
+void content_set_status(struct content *c, const char *status_message)
+{
+ size_t len = strlen(status_message);
+
+ if (len >= sizeof(c->sub_status)) {
+ len = sizeof(c->sub_status) - 1;
}
+ memcpy(c->sub_status, status_message, len);
+ c->sub_status[len] = '\0';
+
+ content_update_status(c);
}
-/**
- * Put a content in status CONTENT_STATUS_READY and unlock the content.
- */
+/* exported interface documented in content/protected.h */
void content_set_ready(struct content *c)
{
/* The content must be locked at this point, as it can only
@@ -311,10 +290,8 @@ void content_set_ready(struct content *c)
content_broadcast(c, CONTENT_MSG_READY, NULL);
}
-/**
- * Put a content in status CONTENT_STATUS_DONE.
- */
+/* exported interface documented in content/protected.h */
void content_set_done(struct content *c)
{
uint64_t now_ms;
@@ -327,38 +304,32 @@ void content_set_done(struct content *c)
content_broadcast(c, CONTENT_MSG_DONE, NULL);
}
-/**
- * Put a content in status CONTENT_STATUS_ERROR and unlock the content.
- *
- * \note We expect the caller to broadcast an error report if needed.
- */
+/* exported interface documented in content/protected.h */
void content_set_error(struct content *c)
{
c->locked = false;
c->status = CONTENT_STATUS_ERROR;
}
-/**
- * Reformat to new size.
- *
- * Calls the reformat function for the content.
- */
+/* exported interface documented in content/content.h */
void content_reformat(hlcache_handle *h, bool background,
- int width, int height)
+ int width, int height)
{
content__reformat(hlcache_handle_get_content(h), background,
- width, height);
+ width, height);
}
-void content__reformat(struct content *c, bool background,
- int width, int height)
+
+/* exported interface documented in content/protected.h */
+void
+content__reformat(struct content *c, bool background, int width, int height)
{
union content_msg_data data;
assert(c != 0);
assert(c->status == CONTENT_STATUS_READY ||
- c->status == CONTENT_STATUS_DONE);
+ c->status == CONTENT_STATUS_DONE);
assert(c->locked == false);
c->available_width = width;
@@ -375,19 +346,14 @@ void content__reformat(struct content *c, bool background,
}
-/**
- * Destroy and free a content.
- *
- * Calls the destroy function for the content, and frees the structure.
- */
-
+/* exported interface documented in content/content.h */
void content_destroy(struct content *c)
{
struct content_rfc5988_link *link;
assert(c);
NSLOG(netsurf, INFO, "content %p %s", c,
- nsurl_access_log(llcache_handle_get_url(c->llcache)));
+ nsurl_access_log(llcache_handle_get_url(c->llcache)));
assert(c->locked == false);
if (c->handler->destroy != NULL)
@@ -423,18 +389,12 @@ void content_destroy(struct content *c)
}
-/**
- * Handle mouse movements in a content window.
- *
- * \param h Content handle
- * \param bw browser window
- * \param mouse state of mouse buttons and modifier keys
- * \param x coordinate of mouse
- * \param y coordinate of mouse
- */
-
-void content_mouse_track(hlcache_handle *h, struct browser_window *bw,
- browser_mouse_state mouse, int x, int y)
+/* exported interface documented in content/content.h */
+void
+content_mouse_track(hlcache_handle *h,
+ struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != NULL);
@@ -452,24 +412,12 @@ void content_mouse_track(hlcache_handle *h, struct
browser_window *bw,
}
-/**
- * Handle mouse clicks and movements in a content window.
- *
- * \param h Content handle
- * \param bw browser window
- * \param mouse state of mouse buttons and modifier keys
- * \param x coordinate of mouse
- * \param y coordinate of mouse
- *
- * This function handles both hovering and clicking. It is important that the
- * code path is identical (except that hovering doesn't carry out the action),
- * so that the status bar reflects exactly what will happen. Having separate
- * code paths opens the possibility that an attacker will make the status bar
- * show some harmless action where clicking will be harmful.
- */
-
-void content_mouse_action(hlcache_handle *h, struct browser_window *bw,
- browser_mouse_state mouse, int x, int y)
+/* exported interface documented in content/content.h */
+void
+content_mouse_action(hlcache_handle *h,
+ struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != NULL);
@@ -481,14 +429,7 @@ void content_mouse_action(hlcache_handle *h, struct
browser_window *bw,
}
-/**
- * Handle keypresses.
- *
- * \param h Content handle
- * \param key The UCS4 character codepoint
- * \return true if key handled, false otherwise
- */
-
+/* exported interface documented in content/content.h */
bool content_keypress(struct hlcache_handle *h, uint32_t key)
{
struct content *c = hlcache_handle_get_content(h);
@@ -501,34 +442,18 @@ bool content_keypress(struct hlcache_handle *h, uint32_t
key)
}
-/**
- * Request a redraw of an area of a content
- *
- * \param h high-level cache handle
- * \param x x co-ord of left edge
- * \param y y co-ord of top edge
- * \param width Width of rectangle
- * \param height Height of rectangle
- */
+/* exported interface documented in content/content.h */
void content_request_redraw(struct hlcache_handle *h,
- int x, int y, int width, int height)
+ int x, int y, int width, int height)
{
content__request_redraw(hlcache_handle_get_content(h),
- x, y, width, height);
+ x, y, width, height);
}
-/**
- * Request a redraw of an area of a content
- *
- * \param c Content
- * \param x x co-ord of left edge
- * \param y y co-ord of top edge
- * \param width Width of rectangle
- * \param height Height of rectangle
- */
+/* exported interface, documented in content/protected.h */
void content__request_redraw(struct content *c,
- int x, int y, int width, int height)
+ int x, int y, int width, int height)
{
union content_msg_data data;
@@ -543,6 +468,7 @@ void content__request_redraw(struct content *c,
content_broadcast(c, CONTENT_MSG_REDRAW, &data);
}
+
/* exported interface, documented in content/content.h */
bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen)
{
@@ -565,6 +491,7 @@ bool content_exec(struct hlcache_handle *h, const char
*src, size_t srclen)
return c->handler->exec(c, src, srclen);
}
+
/* exported interface, documented in content/content.h */
bool content_saw_insecure_objects(struct hlcache_handle *h)
{
@@ -621,9 +548,13 @@ bool content_saw_insecure_objects(struct hlcache_handle *h)
return false;
}
+
/* exported interface, documented in content/content.h */
-bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
- const struct rect *clip, const struct redraw_context *ctx)
+bool
+content_redraw(hlcache_handle *h,
+ struct content_redraw_data *data,
+ const struct rect *clip,
+ const struct redraw_context *ctx)
{
struct content *c = hlcache_handle_get_content(h);
@@ -644,8 +575,10 @@ bool content_redraw(hlcache_handle *h, struct
content_redraw_data *data,
/* exported interface, documented in content/content.h */
-bool content_scaled_redraw(struct hlcache_handle *h,
- int width, int height, const struct redraw_context *ctx)
+bool
+content_scaled_redraw(struct hlcache_handle *h,
+ int width, int height,
+ const struct redraw_context *ctx)
{
struct content *c = hlcache_handle_get_content(h);
struct redraw_context new_ctx = *ctx;
@@ -711,32 +644,22 @@ bool content_scaled_redraw(struct hlcache_handle *h,
return plot_ok;
}
-/**
- * Register a user for callbacks.
- *
- * \param c the content to register
- * \param callback the callback function
- * \param pw callback private data
- * \return true on success, false otherwise on memory exhaustion
- *
- * The callback will be called when content_broadcast() is
- * called with the content.
- */
-bool content_add_user(
- struct content *c,
- void (*callback)(
- struct content *c,
- content_msg msg,
- const union content_msg_data *data,
- void *pw),
- void *pw)
+/* exported interface documented in content/content.h */
+bool
+content_add_user(struct content *c,
+ void (*callback)(
+ struct content *c,
+ content_msg msg,
+ const union content_msg_data *data,
+ void *pw),
+ void *pw)
{
struct content_user *user;
NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p), user %p %p",
- nsurl_access_log(llcache_handle_get_url(c->llcache)),
- c, callback, pw);
+ nsurl_access_log(llcache_handle_get_url(c->llcache)),
+ c, callback, pw);
user = malloc(sizeof(struct content_user));
if (!user)
return false;
@@ -752,31 +675,25 @@ bool content_add_user(
}
-/**
- * Remove a callback user.
- *
- * The callback function and pw must be identical to those passed to
- * content_add_user().
- */
-
-void content_remove_user(
- struct content *c,
- void (*callback)(
- struct content *c,
- content_msg msg,
- const union content_msg_data *data,
- void *pw),
- void *pw)
+/* exported interface documented in content/content.h */
+void
+content_remove_user(struct content *c,
+ void (*callback)(
+ struct content *c,
+ content_msg msg,
+ const union content_msg_data *data,
+ void *pw),
+ void *pw)
{
struct content_user *user, *next;
NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p), user %p %p",
- nsurl_access_log(llcache_handle_get_url(c->llcache)),
- c, callback, pw);
+ nsurl_access_log(llcache_handle_get_url(c->llcache)),
+ c, callback, pw);
/* user_list starts with a sentinel */
for (user = c->user_list; user->next != 0 &&
- !(user->next->callback == callback &&
- user->next->pw == pw); user = user->next)
+ !(user->next->callback == callback &&
+ user->next->pw == pw); user = user->next)
;
if (user->next == 0) {
NSLOG(netsurf, INFO, "user not found in list");
@@ -792,10 +709,8 @@ void content_remove_user(
free(next);
}
-/**
- * Count users for the content.
- */
+/* exported interface documented in content/content.h */
uint32_t content_count_users(struct content *c)
{
struct content_user *user;
@@ -811,13 +726,8 @@ uint32_t content_count_users(struct content *c)
return counter - 1; /* Subtract 1 for the sentinel */
}
-/**
- * Determine if quirks mode matches
- *
- * \param c Content to consider
- * \param quirks Quirks mode to match
- * \return True if quirks match, false otherwise
- */
+
+/* exported interface documented in content/content.h */
bool content_matches_quirks(struct content *c, bool quirks)
{
if (c->handler->matches_quirks == NULL)
@@ -826,23 +736,17 @@ bool content_matches_quirks(struct content *c, bool
quirks)
return c->handler->matches_quirks(c, quirks);
}
-/**
- * Determine if a content is shareable
- *
- * \param c Content to consider
- * \return True if content is shareable, false otherwise
- */
+
+/* exported interface documented in content/content.h */
bool content_is_shareable(struct content *c)
{
return c->handler->no_share == false;
}
-/**
- * Send a message to all users.
- */
+/* exported interface documented in content/protected.h */
void content_broadcast(struct content *c, content_msg msg,
- const union content_msg_data *data)
+ const union content_msg_data *data)
{
struct content_user *user, *next;
assert(c);
@@ -855,8 +759,10 @@ void content_broadcast(struct content *c, content_msg msg,
}
}
+
/* exported interface documented in content_protected.h */
-void content_broadcast_error(struct content *c, nserror errorcode, const char
*msg)
+void
+content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
{
struct content_user *user, *next;
union content_msg_data data;
@@ -870,24 +776,13 @@ void content_broadcast_error(struct content *c, nserror
errorcode, const char *m
next = user->next; /* user may be destroyed during callback */
if (user->callback != 0) {
user->callback(c, CONTENT_MSG_ERROR,
- &data, user->pw);
+ &data, user->pw);
}
}
}
-/**
- * A window containing the content has been opened.
- *
- * \param h handle to content that has been opened
- * \param bw browser window containing the content
- * \param page content of type CONTENT_HTML containing h, or NULL if not an
- * object within a page
- * \param params object parameters, or NULL if not an object
- *
- * Calls the open function for the content.
- */
-
+/* exported interface, documented in content/content.h */
nserror
content_open(hlcache_handle *h,
struct browser_window *bw,
@@ -900,7 +795,7 @@ content_open(hlcache_handle *h,
c = hlcache_handle_get_content(h);
assert(c != 0);
NSLOG(netsurf, INFO, "content %p %s", c,
- nsurl_access_log(llcache_handle_get_url(c->llcache)));
+ nsurl_access_log(llcache_handle_get_url(c->llcache)));
if (c->handler->open != NULL) {
res = c->handler->open(c, bw, page, params);
} else {
@@ -910,12 +805,7 @@ content_open(hlcache_handle *h,
}
-/**
- * The window containing the content has been closed.
- *
- * Calls the close function for the content.
- */
-
+/* exported interface, documented in content/content.h */
nserror content_close(hlcache_handle *h)
{
struct content *c;
@@ -933,7 +823,7 @@ nserror content_close(hlcache_handle *h)
}
NSLOG(netsurf, INFO, "content %p %s", c,
- nsurl_access_log(llcache_handle_get_url(c->llcache)));
+ nsurl_access_log(llcache_handle_get_url(c->llcache)));
if (c->handler->close != NULL) {
res = c->handler->close(c);
} else {
@@ -943,11 +833,7 @@ nserror content_close(hlcache_handle *h)
}
-/**
- * Tell a content that any selection it has, or one of its objects has, must be
- * cleared.
- */
-
+/* exported interface, documented in content/content.h */
void content_clear_selection(hlcache_handle *h)
{
struct content *c = hlcache_handle_get_content(h);
@@ -958,11 +844,7 @@ void content_clear_selection(hlcache_handle *h)
}
-/**
- * Get a text selection from a content. Ownership is passed to the caller,
- * who must free() it.
- */
-
+/* exported interface, documented in content/content.h */
char * content_get_selection(hlcache_handle *h)
{
struct content *c = hlcache_handle_get_content(h);
@@ -974,9 +856,12 @@ char * content_get_selection(hlcache_handle *h)
return NULL;
}
+
/* exported interface documented in content/content.h */
-nserror content_get_contextual_content(struct hlcache_handle *h,
- int x, int y, struct browser_window_features *data)
+nserror
+content_get_contextual_content(struct hlcache_handle *h,
+ int x, int y,
+ struct browser_window_features *data)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -990,8 +875,11 @@ nserror content_get_contextual_content(struct
hlcache_handle *h,
}
-bool content_scroll_at_point(struct hlcache_handle *h,
- int x, int y, int scrx, int scry)
+/* exported interface, documented in content/content.h */
+bool
+content_scroll_at_point(struct hlcache_handle *h,
+ int x, int y,
+ int scrx, int scry)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -1003,8 +891,11 @@ bool content_scroll_at_point(struct hlcache_handle *h,
}
-bool content_drop_file_at_point(struct hlcache_handle *h,
- int x, int y, char *file)
+/* exported interface, documented in content/content.h */
+bool
+content_drop_file_at_point(struct hlcache_handle *h,
+ int x, int y,
+ char *file)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -1016,8 +907,12 @@ bool content_drop_file_at_point(struct hlcache_handle *h,
}
-void content_search(struct hlcache_handle *h, void *context,
- search_flags_t flags, const char *string)
+/* exported interface, documented in content/content.h */
+void
+content_search(struct hlcache_handle *h,
+ void *context,
+ search_flags_t flags,
+ const char *string)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -1028,6 +923,7 @@ void content_search(struct hlcache_handle *h, void
*context,
}
+/* exported interface, documented in content/content.h */
void content_search_clear(struct hlcache_handle *h)
{
struct content *c = hlcache_handle_get_content(h);
@@ -1038,8 +934,10 @@ void content_search_clear(struct hlcache_handle *h)
}
}
+
/* exported interface documented in content/content.h */
-nserror content_debug_dump(struct hlcache_handle *h, FILE *f, enum
content_debug op)
+nserror
+content_debug_dump(struct hlcache_handle *h, FILE *f, enum content_debug op)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
@@ -1051,6 +949,7 @@ nserror content_debug_dump(struct hlcache_handle *h, FILE
*f, enum content_debug
return c->handler->debug_dump(c, f, op);
}
+
/* exported interface documented in content/content.h */
nserror content_debug(struct hlcache_handle *h, enum content_debug op)
{
@@ -1068,12 +967,6 @@ nserror content_debug(struct hlcache_handle *h, enum
content_debug op)
}
-void content_add_error(struct content *c, const char *token,
- unsigned int line)
-{
-}
-
-
/* exported interface documented in content/content.h */
struct content_rfc5988_link *
content_find_rfc5988_link(hlcache_handle *h, lwc_string *rel)
@@ -1084,7 +977,7 @@ content_find_rfc5988_link(hlcache_handle *h, lwc_string
*rel)
while (link != NULL) {
if (lwc_string_caseless_isequal(link->rel, rel,
- &rel_match) == lwc_error_ok && rel_match) {
+ &rel_match) == lwc_error_ok &&
rel_match) {
break;
}
link = link->next;
@@ -1092,6 +985,8 @@ content_find_rfc5988_link(hlcache_handle *h, lwc_string
*rel)
return link;
}
+
+/* exported interface documented in content/protected.h */
struct content_rfc5988_link *
content__free_rfc5988_link(struct content_rfc5988_link *link)
{
@@ -1118,8 +1013,11 @@ content__free_rfc5988_link(struct content_rfc5988_link
*link)
return next;
}
-bool content__add_rfc5988_link(struct content *c,
- const struct content_rfc5988_link *link)
+
+/* exported interface documented in content/protected.h */
+bool
+content__add_rfc5988_link(struct content *c,
+ const struct content_rfc5988_link *link)
{
struct content_rfc5988_link *newlink;
union content_msg_data msg_data;
@@ -1167,7 +1065,6 @@ bool content__add_rfc5988_link(struct content *c,
}
-
/* exported interface documented in content/content.h */
nsurl *content_get_url(struct content *c)
{
@@ -1196,6 +1093,7 @@ lwc_string *content_get_mime_type(hlcache_handle *h)
return content__get_mime_type(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
lwc_string *content__get_mime_type(struct content *c)
{
@@ -1228,6 +1126,7 @@ const char *content_get_title(hlcache_handle *h)
return content__get_title(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
const char *content__get_title(struct content *c)
{
@@ -1235,7 +1134,7 @@ const char *content__get_title(struct content *c)
return NULL;
return c->title != NULL ? c->title :
- nsurl_access(llcache_handle_get_url(c->llcache));
+ nsurl_access(llcache_handle_get_url(c->llcache));
}
@@ -1245,6 +1144,7 @@ content_status content_get_status(hlcache_handle *h)
return content__get_status(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
content_status content__get_status(struct content *c)
{
@@ -1261,6 +1161,7 @@ const char *content_get_status_message(hlcache_handle *h)
return content__get_status_message(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
const char *content__get_status_message(struct content *c)
{
@@ -1277,6 +1178,7 @@ int content_get_width(hlcache_handle *h)
return content__get_width(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
int content__get_width(struct content *c)
{
@@ -1293,6 +1195,7 @@ int content_get_height(hlcache_handle *h)
return content__get_height(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
int content__get_height(struct content *c)
{
@@ -1309,6 +1212,7 @@ int content_get_available_width(hlcache_handle *h)
return content__get_available_width(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
int content__get_available_width(struct content *c)
{
@@ -1325,6 +1229,7 @@ const uint8_t *content_get_source_data(hlcache_handle *h,
size_t *size)
return content__get_source_data(hlcache_handle_get_content(h), size);
}
+
/* exported interface documented in content/content_protected.h */
const uint8_t *content__get_source_data(struct content *c, size_t *size)
{
@@ -1337,12 +1242,14 @@ const uint8_t *content__get_source_data(struct content
*c, size_t *size)
return llcache_handle_get_source_data(c->llcache, size);
}
+
/* exported interface documented in content/content.h */
void content_invalidate_reuse_data(hlcache_handle *h)
{
content__invalidate_reuse_data(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
void content__invalidate_reuse_data(struct content *c)
{
@@ -1353,12 +1260,14 @@ void content__invalidate_reuse_data(struct content *c)
llcache_handle_invalidate_cache_data(c->llcache);
}
+
/* exported interface documented in content/content.h */
nsurl *content_get_refresh_url(hlcache_handle *h)
{
return content__get_refresh_url(hlcache_handle_get_content(h));
}
+
/* exported interface documented in content/content_protected.h */
nsurl *content__get_refresh_url(struct content *c)
{
@@ -1434,14 +1343,16 @@ bool content_get_quirks(hlcache_handle *h)
/* exported interface documented in content/content.h */
-const char *content_get_encoding(hlcache_handle *h, enum content_encoding_type
op)
+const char *
+content_get_encoding(hlcache_handle *h, enum content_encoding_type op)
{
return content__get_encoding(hlcache_handle_get_content(h), op);
}
/* exported interface documented in content/content_protected.h */
-const char *content__get_encoding(struct content *c, enum
content_encoding_type op)
+const char *
+content__get_encoding(struct content *c, enum content_encoding_type op)
{
const char *encoding = NULL;
@@ -1468,12 +1379,8 @@ bool content__is_locked(struct content *c)
return c->locked;
}
-/**
- * Retrieve the low-level cache handle for a content
- *
- * \param c Content to retrieve from
- * \return Low-level cache handle
- */
+
+/* exported interface documented in content/content.h */
const llcache_handle *content_get_llcache_handle(struct content *c)
{
if (c == NULL)
@@ -1482,12 +1389,8 @@ const llcache_handle *content_get_llcache_handle(struct
content *c)
return c->llcache;
}
-/**
- * Clone a content object in its current state.
- *
- * \param c Content to clone
- * \return Clone of \a c
- */
+
+/* exported interface documented in content/protected.h */
struct content *content_clone(struct content *c)
{
struct content *nc;
@@ -1500,13 +1403,8 @@ struct content *content_clone(struct content *c)
return nc;
};
-/**
- * Clone a content's data members
- *
- * \param c Content to clone
- * \param nc Content to populate
- * \return NSERROR_OK on success, appropriate error otherwise
- */
+
+/* exported interface documented in content/protected.h */
nserror content__clone(const struct content *c, struct content *nc)
{
nserror error;
@@ -1571,12 +1469,8 @@ nserror content__clone(const struct content *c, struct
content *nc)
return NSERROR_OK;
}
-/**
- * Abort a content object
- *
- * \param c The content object to abort
- * \return NSERROR_OK on success, otherwise appropriate error
- */
+
+/* exported interface documented in content/content.h */
nserror content_abort(struct content *c)
{
NSLOG(netsurf, INFO, "Aborting %p", c);
diff --git a/content/content.h b/content/content.h
index c2605a7..169fd5a 100644
--- a/content/content.h
+++ b/content/content.h
@@ -287,41 +287,87 @@ union content_msg_data {
/* The following are for hlcache */
-void content_destroy(struct content *c);
-
-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);
+/**
+ * Destroy and free a content.
+ *
+ * Calls the destroy function for the content, and frees the structure.
+ */
+void content_destroy(struct content *c);
+/**
+ * Register a user for callbacks.
+ *
+ * \param c the content to register
+ * \param callback the user callback function
+ * \param pw callback private data
+ * \return true on success, false otherwise on memory exhaustion
+ *
+ * The callback will be called when content_broadcast() is
+ * called with the content.
+ */
+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);
-void content_remove_user(
- struct content *c,
- void (*callback)(
- struct content *c,
- content_msg msg,
- const union content_msg_data *data,
- void *pw),
- void *pw);
+/**
+ * Remove a callback user.
+ *
+ * The callback function and pw must be identical to those passed to
+ * content_add_user().
+ *
+ * \param c Content to remove user from
+ * \param callback passed when added
+ * \param ctx Context passed when added
+ */
+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);
+/**
+ * Count users for the content.
+ *
+ * \param c Content to consider
+ */
uint32_t content_count_users(struct content *c);
+/**
+ * Determine if quirks mode matches
+ *
+ * \param c Content to consider
+ * \param quirks Quirks mode to match
+ * \return True if quirks match, false otherwise
+ */
bool content_matches_quirks(struct content *c, bool quirks);
-
+/**
+ * Determine if a content is shareable
+ *
+ * \param c Content to consider
+ * \return True if content is shareable, false otherwise
+ */
bool content_is_shareable(struct content *c);
-/* only used by cocoa apple image handling and for getting nsurl of content */
+/**
+ * Retrieve the low-level cache handle for a content
+ *
+ * \note only used by hlcache
+ *
+ * \param c Content to retrieve from
+ * \return Low-level cache handle
+ */
const struct llcache_handle *content_get_llcache_handle(struct content *c);
-
/**
* Retrieve URL associated with content
*
@@ -330,35 +376,123 @@ const struct llcache_handle
*content_get_llcache_handle(struct content *c);
*/
struct nsurl *content_get_url(struct content *c);
+/**
+ * Clone a content object in its current state.
+ *
+ * \param c Content to clone
+ * \return Clone of \a c
+ */
struct content *content_clone(struct content *c);
+/**
+ * Abort a content object
+ *
+ * \param c The content object to abort
+ * \return NSERROR_OK on success, otherwise appropriate error
+ */
nserror content_abort(struct content *c);
/* Client functions */
+
+/**
+ * Get whether a content can reformat
+ *
+ * \param h content to check
+ * \return whether the content can reformat
+ */
bool content_can_reformat(struct hlcache_handle *h);
+/**
+ * Reformat to new size.
+ *
+ * Calls the reformat function for the content.
+ */
void content_reformat(struct hlcache_handle *h, bool background,
int width, int height);
+/**
+ * Request a redraw of an area of a content
+ *
+ * \param h high-level cache handle
+ * \param x x co-ord of left edge
+ * \param y y co-ord of top edge
+ * \param width Width of rectangle
+ * \param height Height of rectangle
+ */
void content_request_redraw(struct hlcache_handle *h,
int x, int y, int width, int height);
+/**
+ * Handle mouse movements in a content window.
+ *
+ * \param h Content handle
+ * \param bw browser window
+ * \param mouse state of mouse buttons and modifier keys
+ * \param x coordinate of mouse
+ * \param y coordinate of mouse
+ */
void content_mouse_track(struct hlcache_handle *h, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
+/**
+ * Handle mouse clicks and movements in a content window.
+ *
+ * \param h Content handle
+ * \param bw browser window
+ * \param mouse state of mouse buttons and modifier keys
+ * \param x coordinate of mouse
+ * \param y coordinate of mouse
+ *
+ * This function handles both hovering and clicking. It is important that the
+ * code path is identical (except that hovering doesn't carry out the action),
+ * so that the status bar reflects exactly what will happen. Having separate
+ * code paths opens the possibility that an attacker will make the status bar
+ * show some harmless action where clicking will be harmful.
+ */
void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
+/**
+ * Handle keypresses.
+ *
+ * \param h Content handle
+ * \param key The UCS4 character codepoint
+ * \return true if key handled, false otherwise
+ */
bool content_keypress(struct hlcache_handle *h, uint32_t key);
+/**
+ * A window containing the content has been opened.
+ *
+ * \param h handle to content that has been opened
+ * \param bw browser window containing the content
+ * \param page content of type CONTENT_HTML containing h, or NULL if not an
+ * object within a page
+ * \param params object parameters, or NULL if not an object
+ *
+ * Calls the open function for the content.
+ */
nserror content_open(struct hlcache_handle *h, struct browser_window *bw,
struct content *page, struct object_params *params);
+/**
+ * The window containing the content has been closed.
+ *
+ * Calls the close function for the content.
+ */
nserror content_close(struct hlcache_handle *h);
+/**
+ * Tell a content that any selection it has, or one of its objects
+ * has, must be cleared.
+ */
void content_clear_selection(struct hlcache_handle *h);
+/**
+ * Get a text selection from a content. Ownership is passed to the caller,
+ * who must free() it.
+ */
char * content_get_selection(struct hlcache_handle *h);
/**
@@ -372,15 +506,39 @@ char * content_get_selection(struct hlcache_handle *h);
nserror content_get_contextual_content(struct hlcache_handle *h,
int x, int y, struct browser_window_features *data);
+/**
+ * scroll content at coordnate
+ *
+ * \param[in] h Handle to content to examine.
+ * \param[in] x The x coordinate to examine.
+ * \param[in] y The y coordinate to examine.
+ */
bool content_scroll_at_point(struct hlcache_handle *h,
int x, int y, int scrx, int scry);
+/**
+ * Drag and drop a file at coordinate
+ *
+ * \param[in] h Handle to content to examine.
+ * \param[in] x The x coordinate to examine.
+ * \param[in] y The y coordinate to examine.
+ */
bool content_drop_file_at_point(struct hlcache_handle *h,
int x, int y, char *file);
+/**
+ * Search a content
+ *
+ * \param[in] h Handle to content to search.
+ */
void content_search(struct hlcache_handle *h, void *context,
search_flags_t flags, const char *string);
+/**
+ * Clear a search
+ *
+ * \param[in] h Handle to content to clear search from.
+ */
void content_search_clear(struct hlcache_handle *h);
diff --git a/content/content_protected.h b/content/content_protected.h
index af0ee72..3b6d1f7 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -24,18 +24,25 @@
* The content functions manipulate struct contents, which correspond to URLs.
*/
-#ifndef _NETSURF_CONTENT_CONTENT_PROTECTED_H_
-#define _NETSURF_CONTENT_CONTENT_PROTECTED_H_
+#ifndef NETSURF_CONTENT_CONTENT_PROTECTED_H_
+#define NETSURF_CONTENT_CONTENT_PROTECTED_H_
#include <stdio.h>
-#include "utils/nsurl.h"
#include "netsurf/content_type.h"
#include "content/content.h"
+struct nsurl;
struct content_redraw_data;
struct http_parameter;
+struct llcache_handle;
+struct object_params;
+/**
+ * Content operation function table
+ *
+ * function table implementing a content type.
+ */
struct content_handler {
void (*fini)(void);
@@ -46,7 +53,7 @@ struct content_handler {
const char *fallback_charset, bool quirks,
struct content **c);
- bool (*process_data)(struct content *c,
+ bool (*process_data)(struct content *c,
const char *data, unsigned int size);
bool (*data_complete)(struct content *c);
void (*reformat)(struct content *c, int width, int height);
@@ -85,14 +92,20 @@ struct content_handler {
bool (*exec)(struct content *c, const char *src, size_t srclen);
bool (*saw_insecure_objects)(struct content *c);
- /** handler dependant content sensitive internal data interface. */
+ /**
+ * handler dependant content sensitive internal data interface.
+ */
void * (*get_internal)(const struct content *c, void *context);
- /** There must be one content per user for this type. */
+ /**
+ * There must be one content per user for this type.
+ */
bool no_share;
};
-/** Linked list of users of a content. */
+/**
+ * Linked list of users of a content.
+ */
struct content_user
{
void (*callback)(
@@ -105,75 +118,180 @@ struct content_user
struct content_user *next;
};
-/** Corresponds to a single URL. */
+/**
+ * Content which corresponds to a single URL.
+ */
struct content {
- struct llcache_handle *llcache; /**< Low-level cache object */
+ /**
+ * Low-level cache object
+ */
+ struct llcache_handle *llcache;
- lwc_string *mime_type; /**< Original MIME type of data */
+ /**
+ * Original MIME type of data
+ */
+ lwc_string *mime_type;
- const struct content_handler *handler; /**< Handler for content */
+ /**
+ * Handler for content
+ */
+ const struct content_handler *handler;
- content_status status; /**< Current status. */
+ /**
+ * Current status.
+ */
+ content_status status;
- int width, height; /**< Dimensions, if applicable. */
- int available_width; /**< Viewport width. */
- int available_height; /**< Viewport height. */
+ /**
+ * Width dimension, if applicable.
+ */
+ int width;
+ /**
+ * Height dimension, if applicable.
+ */
+ int height;
+ /**
+ * Viewport width.
+ */
+ int available_width;
+ /**
+ * Viewport height.
+ */
+ int available_height;
- bool quirks; /**< Content is in quirks mode */
- char *fallback_charset; /**< Fallback charset, or NULL */
+ /**
+ * Content is in quirks mode
+ */
+ bool quirks;
+ /**
+ * Fallback charset, or NULL
+ */
+ char *fallback_charset;
- nsurl *refresh; /**< URL for refresh request */
+ /**
+ * URL for refresh request
+ */
+ struct nsurl *refresh;
- struct content_rfc5988_link *links; /**< list of metadata links */
+ /**
+ * list of metadata links
+ */
+ struct content_rfc5988_link *links;
- /** Creation timestamp when LOADING or READY.
- * Total time in ms when DONE.
+ /**
+ * Creation timestamp when LOADING or READY. Total time in ms
+ * when DONE.
*/
uint64_t time;
- uint64_t reformat_time; /**< Earliest time to attempt a period
- * reflow while fetching a page's objects.
- */
-
- unsigned int size; /**< Estimated size of all data
- associated with this content */
- char *title; /**< Title for browser window. */
- unsigned int active; /**< Number of child fetches or
- conversions currently in progress. */
- struct content_user *user_list; /**< List of users. */
- char status_message[120]; /**< Full text for status bar. */
- char sub_status[80]; /**< Status of content. */
- /** Content is being processed: data structures may be inconsistent
- * and content must not be redrawn or modified. */
- bool locked;
+ /**
+ * Earliest time to attempt a period reflow while fetching a
+ * page's objects.
+ */
+ uint64_t reformat_time;
- unsigned long total_size; /**< Total data size, 0 if unknown. */
- long http_code; /**< HTTP status code, 0 if not HTTP. */
+ /**
+ * Estimated size of all data associated with this content
+ */
+ unsigned int size;
+ /**
+ * Title for browser window.
+ */
+ char *title;
+ /**
+ * Number of child fetches or conversions currently in progress.
+ */
+ unsigned int active;
+ /**
+ * List of users.
+ */
+ struct content_user *user_list;
+ /**
+ * Full text for status bar.
+ */
+ char status_message[120];
+ /**
+ * Status of content.
+ */
+ char sub_status[80];
+ /**
+ * Content is being processed: data structures may be
+ * inconsistent and content must not be redrawn or modified.
+ */
+ bool locked;
- /** Array of first n rendering errors or warnings. */
- struct {
- const char *token;
- unsigned int line; /**< Line no, 0 if not applicable. */
- } error_list[40];
- unsigned int error_count; /**< Number of valid error entries. */
+ /**
+ * Total data size, 0 if unknown.
+ */
+ unsigned long total_size;
+ /**
+ * HTTP status code, 0 if not HTTP.
+ */
+ long http_code;
};
extern const char * const content_type_name[];
extern const char * const content_status_name[];
+
+/**
+ * Initialise a new base content structure.
+ *
+ * \param c Content to initialise
+ * \param handler Content handler
+ * \param imime_type MIME type of content
+ * \param params HTTP parameters
+ * \param llcache Source data handle
+ * \param fallback_charset Fallback charset
+ * \param quirks Quirkiness of content
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
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);
+
+/**
+ * Clone a content's data members
+ *
+ * \param c Content to clone
+ * \param nc Content to populate
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
nserror content__clone(const struct content *c, struct content *nc);
+/**
+ * Put a content in status CONTENT_STATUS_READY and unlock the content.
+ */
void content_set_ready(struct content *c);
+
+/**
+ * Put a content in status CONTENT_STATUS_DONE.
+ */
void content_set_done(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.
+ */
void content_set_error(struct content *c);
+/**
+ * Updates content with new status.
+ *
+ * The textual status contained in the content is updated with given string.
+ *
+ * \param c The content to set status in.
+ * \param status_message new textual status
+ */
void content_set_status(struct content *c, const char *status_message);
-void content_broadcast(struct content *c, content_msg msg,
- const union content_msg_data *data);
+
+/**
+ * Send a message to all users.
+ */
+void content_broadcast(struct content *c, content_msg msg, const union
content_msg_data *data);
+
/**
* Send an error message to all users.
*
@@ -183,19 +301,42 @@ void content_broadcast(struct content *c, content_msg msg,
*/
void content_broadcast_error(struct content *c, nserror errorcode, const char
*msg);
-void content_add_error(struct content *c, const char *token,
- unsigned int line);
+/**
+ * associate a metadata link with a content.
+ *
+ * \param c content to add link to
+ * \param link The rfc5988 link to add
+ */
+bool content__add_rfc5988_link(struct content *c, const struct
content_rfc5988_link *link);
-bool content__add_rfc5988_link(struct content *c,
- const struct content_rfc5988_link *link);
-struct content_rfc5988_link *content__free_rfc5988_link(
- struct content_rfc5988_link *link);
+/**
+ * free a rfc5988 link
+ *
+ * \param link The link to free
+ * \return The next link in the chain
+ */
+struct content_rfc5988_link *content__free_rfc5988_link(struct
content_rfc5988_link *link);
-void content__reformat(struct content *c, bool background,
- int width, int height);
-void content__request_redraw(struct content *c,
- int x, int y, int width, int height);
+/**
+ * cause a content to be reformatted.
+ *
+ * \param c content to be reformatted
+ * \param background perform reformat in background
+ * \param width The available width to reformat content in
+ * \param height The available height to reformat content in
+ */
+void content__reformat(struct content *c, bool background, int width, int
height);
+/**
+ * Request a redraw of an area of a content
+ *
+ * \param c Content
+ * \param x x co-ord of left edge
+ * \param y y co-ord of top edge
+ * \param width Width of rectangle
+ * \param height Height of rectangle
+ */
+void content__request_redraw(struct content *c, int x, int y, int width, int
height);
/**
* Retrieve mime-type of content
@@ -280,7 +421,7 @@ void content__invalidate_reuse_data(struct content *c);
* \param c Content to retrieve refresh URL from
* \return Pointer to URL or NULL if none
*/
-nsurl *content__get_refresh_url(struct content *c);
+struct nsurl *content__get_refresh_url(struct content *c);
/**
* Retrieve the bitmap contained in an image content
diff --git a/content/handlers/html/box_construct.c
b/content/handlers/html/box_construct.c
index 3d10017..5ae7552 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -33,6 +33,7 @@
#include "utils/talloc.h"
#include "utils/string.h"
#include "utils/ascii.h"
+#include "utils/nsurl.h"
#include "netsurf/misc.h"
#include "css/select.h"
#include "desktop/gui_internal.h"
@@ -68,7 +69,7 @@ struct box_construct_props {
/** Style from which to inherit, or NULL if none */
const css_computed_style *parent_style;
/** Current link target, or NULL if none */
- nsurl *href;
+ struct nsurl *href;
/** Current frame target, or NULL if none */
const char *target;
/** Current title attribute, or NULL if none */
diff --git a/content/handlers/html/box_manipulate.c
b/content/handlers/html/box_manipulate.c
index d88e360..d23091b 100644
--- a/content/handlers/html/box_manipulate.c
+++ b/content/handlers/html/box_manipulate.c
@@ -28,6 +28,7 @@
#include "utils/errors.h"
#include "utils/talloc.h"
+#include "utils/nsurl.h"
#include "netsurf/types.h"
#include "netsurf/mouse.h"
#include "desktop/scrollbar.h"
diff --git a/content/handlers/html/box_special.c
b/content/handlers/html/box_special.c
index 06f2f91..a369ec8 100644
--- a/content/handlers/html/box_special.c
+++ b/content/handlers/html/box_special.c
@@ -36,6 +36,7 @@
#include "utils/talloc.h"
#include "utils/string.h"
#include "utils/ascii.h"
+#include "utils/nsurl.h"
#include "netsurf/plot_style.h"
#include "css/hints.h"
#include "desktop/frame_types.h"
diff --git a/content/handlers/html/css.c b/content/handlers/html/css.c
index 5758981..d7c9b3c 100644
--- a/content/handlers/html/css.c
+++ b/content/handlers/html/css.c
@@ -127,7 +127,6 @@ html_convert_css_callback(hlcache_handle *css,
s->sheet = NULL;
parent->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
- content_add_error(&parent->base, "?", 0);
break;
case CONTENT_MSG_POINTER:
diff --git a/content/handlers/html/dom_event.c
b/content/handlers/html/dom_event.c
index 4468e82..08a1e45 100644
--- a/content/handlers/html/dom_event.c
+++ b/content/handlers/html/dom_event.c
@@ -27,6 +27,7 @@
#include "utils/log.h"
#include "utils/ascii.h"
#include "utils/string.h"
+#include "utils/nsurl.h"
#include "javascript/js.h"
#include "html/private.h"
diff --git a/content/handlers/html/layout.c b/content/handlers/html/layout.c
index 3d022ab..b87fd16 100644
--- a/content/handlers/html/layout.c
+++ b/content/handlers/html/layout.c
@@ -47,6 +47,7 @@
#include "utils/talloc.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
+#include "utils/nsurl.h"
#include "netsurf/inttypes.h"
#include "netsurf/content.h"
#include "netsurf/browser_window.h"
diff --git a/content/handlers/html/object.c b/content/handlers/html/object.c
index 36726f1..e6edf84 100644
--- a/content/handlers/html/object.c
+++ b/content/handlers/html/object.c
@@ -229,7 +229,6 @@ html_object_callback(hlcache_handle *object,
c->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", c->base.active);
- content_add_error(&c->base, "?", 0);
html_object_failed(box, c, o->background);
break;
diff --git a/content/handlers/html/object.h b/content/handlers/html/object.h
index 85734fd..67d770c 100644
--- a/content/handlers/html/object.h
+++ b/content/handlers/html/object.h
@@ -27,6 +27,7 @@
struct html_content;
struct browser_window;
struct box;
+struct nsurl;
/**
* Start a fetch for an object required by a page.
@@ -42,7 +43,7 @@ struct box;
* \param background this is a background image
* \return true on success, false on memory exhaustion
*/
-bool html_fetch_object(struct html_content *c, nsurl *url, struct box *box,
content_type permitted_types, bool background);
+bool html_fetch_object(struct html_content *c, struct nsurl *url, struct box
*box, content_type permitted_types, bool background);
/**
* release memory of content objects associated with a HTML content
diff --git a/content/handlers/html/private.h b/content/handlers/html/private.h
index 3d6d706..dff0b78 100644
--- a/content/handlers/html/private.h
+++ b/content/handlers/html/private.h
@@ -107,7 +107,7 @@ typedef struct html_content {
dom_hubbub_encoding_source encoding_source;
/** Base URL (may be a copy of content->url). */
- nsurl *base_url;
+ struct nsurl *base_url;
/** Base target */
char *base_target;
@@ -341,7 +341,7 @@ struct form_control *html_forms_get_control_for_node(struct
form *forms,
* \return NSERROR_OK on successful registration or error code on failure.
*/
nserror html_css_fetcher_register(void);
-nserror html_css_fetcher_add_item(dom_string *data, nsurl *base_url,
+nserror html_css_fetcher_add_item(dom_string *data, struct nsurl *base_url,
uint32_t *key);
diff --git a/content/handlers/html/script.c b/content/handlers/html/script.c
index 99275c0..faab08b 100644
--- a/content/handlers/html/script.c
+++ b/content/handlers/html/script.c
@@ -195,7 +195,6 @@ convert_script_async_cb(hlcache_handle *script,
s->data.handle = NULL;
parent->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
- content_add_error(&parent->base, "?", 0);
break;
@@ -259,7 +258,6 @@ convert_script_defer_cb(hlcache_handle *script,
s->data.handle = NULL;
parent->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
- content_add_error(&parent->base, "?", 0);
break;
@@ -348,7 +346,6 @@ convert_script_sync_cb(hlcache_handle *script,
parent->base.active--;
NSLOG(netsurf, INFO, "%d fetches active", parent->base.active);
- content_add_error(&parent->base, "?", 0);
s->already_started = true;
diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c
index 5124360..6194389 100644
--- a/content/handlers/image/svg.c
+++ b/content/handlers/image/svg.c
@@ -30,6 +30,7 @@
#include "utils/messages.h"
#include "utils/utils.h"
+#include "utils/nsurl.h"
#include "netsurf/plotters.h"
#include "netsurf/content.h"
#include "content/content_protected.h"
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]