summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/content.c103
-rw-r--r--content/content.h4
-rw-r--r--content/content_factory.c5
-rw-r--r--content/content_protected.h4
-rw-r--r--content/handlers/css/utils.c4
-rw-r--r--content/handlers/html/html.c12
-rw-r--r--content/handlers/javascript/content.c5
-rw-r--r--content/handlers/javascript/duktape/Window.bnd56
-rw-r--r--content/handlers/javascript/duktape/dukky.c80
-rw-r--r--content/handlers/javascript/js.h47
-rw-r--r--content/handlers/text/textplain.c8
-rw-r--r--content/hlcache.h5
12 files changed, 219 insertions, 114 deletions
diff --git a/content/content.c b/content/content.c
index 3a5628096..f5303400d 100644
--- a/content/content.c
+++ b/content/content.c
@@ -67,12 +67,12 @@ static void content_convert(struct content *c);
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,
+ llcache_handle *llcache, const char *fallback_charset,
bool quirks)
{
struct content_user *user_sentinel;
nserror error;
-
+
NSLOG(netsurf, INFO, "url "URL_FMT_SPC" -> %p",
nsurl_access_log(llcache_handle_get_url(llcache)), c);
@@ -116,7 +116,7 @@ nserror content__init(struct content *c, const content_handler *handler,
content_set_status(c, messages_get("Loading"));
/* Finally, claim low-level cache events */
- error = llcache_handle_change_callback(llcache,
+ error = llcache_handle_change_callback(llcache,
content_llcache_callback, c);
if (error != NSERROR_OK) {
lwc_string_unref(c->mime_type);
@@ -147,8 +147,8 @@ nserror content_llcache_callback(llcache_handle *llcache,
break;
case LLCACHE_EVENT_HAD_DATA:
if (c->handler->process_data != NULL) {
- if (c->handler->process_data(c,
- (const char *) event->data.data.buf,
+ if (c->handler->process_data(c,
+ (const char *) event->data.data.buf,
event->data.data.len) == false) {
llcache_handle_abort(c->llcache);
c->status = CONTENT_STATUS_ERROR;
@@ -273,7 +273,7 @@ void content_convert(struct content *c)
if (c->locked == true)
return;
-
+
NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p)",
nsurl_access_log(llcache_handle_get_url(c->llcache)), c);
@@ -295,7 +295,7 @@ void content_convert(struct content *c)
void content_set_ready(struct content *c)
{
- /* The content must be locked at this point, as it can only
+ /* The content must be locked at this point, as it can only
* become READY after conversion. */
assert(c->locked);
c->locked = false;
@@ -549,21 +549,21 @@ void content__request_redraw(struct content *c,
bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen)
{
struct content *c = hlcache_handle_get_content(h);
-
+
assert(c != NULL);
-
+
if (c->locked) {
/* Not safe to do stuff */
NSLOG(netsurf, DEEPDEBUG, "Unable to exec, content locked");
return false;
}
-
+
if (c->handler->exec == NULL) {
/* Can't exec something on this content */
NSLOG(netsurf, DEEPDEBUG, "Unable to exec, no exec function");
return false;
}
-
+
return c->handler->exec(c, src, srclen);
}
@@ -748,7 +748,7 @@ uint32_t content_count_users(struct content *c)
uint32_t counter = 0;
assert(c != NULL);
-
+
for (user = c->user_list; user != NULL; user = user->next)
counter += 1;
@@ -826,22 +826,32 @@ void content_broadcast_errorcode(struct content *c, nserror errorcode)
*
* \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 0 if not an
+ * \param page content of type CONTENT_HTML containing h, or NULL if not an
* object within a page
- * \param params object parameters, or 0 if not an object
+ * \param params object parameters, or NULL if not an object
*
* Calls the open function for the content.
*/
-void content_open(hlcache_handle *h, struct browser_window *bw,
- struct content *page, struct object_params *params)
+nserror
+content_open(hlcache_handle *h,
+ struct browser_window *bw,
+ struct content *page,
+ struct object_params *params)
{
- struct content *c = hlcache_handle_get_content(h);
+ struct content *c;
+ nserror res;
+
+ 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)));
- if (c->handler->open != NULL)
- c->handler->open(c, bw, page, params);
+ if (c->handler->open != NULL) {
+ res = c->handler->open(c, bw, page, params);
+ } else {
+ res = NSERROR_OK;
+ }
+ return res;
}
@@ -851,14 +861,30 @@ void content_open(hlcache_handle *h, struct browser_window *bw,
* Calls the close function for the content.
*/
-void content_close(hlcache_handle *h)
+nserror content_close(hlcache_handle *h)
{
- struct content *c = hlcache_handle_get_content(h);
- assert(c != 0);
+ struct content *c;
+ nserror res;
+
+ c = hlcache_handle_get_content(h);
+ if (c == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if ((c->status != CONTENT_STATUS_READY) &&
+ (c->status != CONTENT_STATUS_DONE)) {
+ /* status is not read or done so nothing to do */
+ return NSERROR_INVALID;
+ }
+
NSLOG(netsurf, INFO, "content %p %s", c,
nsurl_access_log(llcache_handle_get_url(c->llcache)));
- if (c->handler->close != NULL)
- c->handler->close(c);
+ if (c->handler->close != NULL) {
+ res = c->handler->close(c);
+ } else {
+ res = NSERROR_OK;
+ }
+ return res;
}
@@ -1012,7 +1038,7 @@ content_find_rfc5988_link(hlcache_handle *h, lwc_string *rel)
}
struct content_rfc5988_link *
-content__free_rfc5988_link(struct content_rfc5988_link *link)
+content__free_rfc5988_link(struct content_rfc5988_link *link)
{
struct content_rfc5988_link *next;
@@ -1037,10 +1063,10 @@ content__free_rfc5988_link(struct content_rfc5988_link *link)
return next;
}
-bool content__add_rfc5988_link(struct content *c,
+bool content__add_rfc5988_link(struct content *c,
const struct content_rfc5988_link *link)
{
- struct content_rfc5988_link *newlink;
+ struct content_rfc5988_link *newlink;
union content_msg_data msg_data;
/* a link relation must be present for it to be a link */
@@ -1055,7 +1081,7 @@ bool content__add_rfc5988_link(struct content *c,
newlink = calloc(1, sizeof(struct content_rfc5988_link));
if (newlink == NULL) {
- return false;
+ return false;
}
/* copy values */
@@ -1300,9 +1326,9 @@ struct bitmap *content__get_bitmap(struct content *c)
{
struct bitmap *bitmap = NULL;
- if ((c != NULL) &&
- (c->handler != NULL) &&
- (c->handler->type != NULL) &&
+ if ((c != NULL) &&
+ (c->handler != NULL) &&
+ (c->handler->type != NULL) &&
(c->handler->type() == CONTENT_IMAGE) &&
(c->handler->get_internal != NULL) ) {
bitmap = c->handler->get_internal(c, NULL);
@@ -1324,14 +1350,14 @@ bool content__get_opaque(struct content *c)
{
bool opaque = false;
- if ((c != NULL) &&
- (c->handler != NULL) &&
- (c->handler->type != NULL) &&
+ if ((c != NULL) &&
+ (c->handler != NULL) &&
+ (c->handler->type != NULL) &&
(c->handler->type() == CONTENT_IMAGE) &&
(c->handler->get_internal != NULL) ) {
struct bitmap *bitmap = NULL;
bitmap = c->handler->get_internal(c, NULL);
- if (bitmap != NULL) {
+ if (bitmap != NULL) {
opaque = guit->bitmap->get_opaque(bitmap);
}
}
@@ -1486,7 +1512,7 @@ nserror content__clone(const struct content *c, struct content *nc)
nc->locked = c->locked;
nc->total_size = c->total_size;
nc->http_code = c->http_code;
-
+
return NSERROR_OK;
}
@@ -1499,11 +1525,10 @@ nserror content__clone(const struct content *c, struct content *nc)
nserror content_abort(struct content *c)
{
NSLOG(netsurf, INFO, "Aborting %p", c);
-
+
if (c->handler->stop != NULL)
c->handler->stop(c);
-
+
/* And for now, abort our llcache object */
return llcache_handle_abort(c->llcache);
}
-
diff --git a/content/content.h b/content/content.h
index 2cbc9e3dd..2d0646dab 100644
--- a/content/content.h
+++ b/content/content.h
@@ -278,10 +278,10 @@ void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw,
bool content_keypress(struct hlcache_handle *h, uint32_t key);
-void content_open(struct hlcache_handle *h, struct browser_window *bw,
+nserror content_open(struct hlcache_handle *h, struct browser_window *bw,
struct content *page, struct object_params *params);
-void content_close(struct hlcache_handle *h);
+nserror content_close(struct hlcache_handle *h);
void content_clear_selection(struct hlcache_handle *h);
diff --git a/content/content_factory.c b/content/content_factory.c
index 935354a5d..44fc333c8 100644
--- a/content/content_factory.c
+++ b/content/content_factory.c
@@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Content factory (implementation)
+/**
+ * \file
+ * Content factory implementation
*/
#include <assert.h>
diff --git a/content/content_protected.h b/content/content_protected.h
index 0101790d1..0358269f2 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -60,9 +60,9 @@ struct content_handler {
bool (*redraw)(struct content *c, struct content_redraw_data *data,
const struct rect *clip,
const struct redraw_context *ctx);
- void (*open)(struct content *c, struct browser_window *bw,
+ nserror (*open)(struct content *c, struct browser_window *bw,
struct content *page, struct object_params *params);
- void (*close)(struct content *c);
+ nserror (*close)(struct content *c);
void (*clear_selection)(struct content *c);
char * (*get_selection)(struct content *c);
nserror (*get_contextual_content)(struct content *c, int x, int y,
diff --git a/content/handlers/css/utils.c b/content/handlers/css/utils.c
index cac777c1f..cf48e8919 100644
--- a/content/handlers/css/utils.c
+++ b/content/handlers/css/utils.c
@@ -117,8 +117,8 @@ css_fixed nscss_len2pt(
case CSS_UNIT_PT: return length;
/* 1pc = 12pt */
case CSS_UNIT_PC: return FMUL(length, INTTOFIX(12));
- case CSS_UNIT_VH: return FDIV(FMUL(FDIV((length * ctx->vh), F_100), F_72), F_96);
- case CSS_UNIT_VW: return FDIV(FMUL(FDIV((length * ctx->vw), F_100), F_72), F_96);
+ case CSS_UNIT_VH: return FDIV(FMUL(FDIV(FMUL(length, ctx->vh), F_100), F_72), F_96);
+ case CSS_UNIT_VW: return FDIV(FMUL(FDIV(FMUL(length,ctx->vw), F_100), F_72), F_96);
default: break;
}
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index ba80ad12e..a27ebd79a 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -1536,8 +1536,8 @@ static void html_reformat(struct content *c, int width, int height)
htmlc->reflowing = true;
- htmlc->len_ctx.vw = nscss_pixels_physical_to_css(width);
- htmlc->len_ctx.vh = nscss_pixels_physical_to_css(height);
+ htmlc->len_ctx.vw = nscss_pixels_physical_to_css(INTTOFIX(width));
+ htmlc->len_ctx.vh = nscss_pixels_physical_to_css(INTTOFIX(height));
htmlc->len_ctx.root_style = htmlc->layout->style;
layout_document(htmlc, width, height);
@@ -1774,7 +1774,7 @@ static nserror html_clone(const struct content *old, struct content **newc)
* Handle a window containing a CONTENT_HTML being opened.
*/
-static void
+static nserror
html_open(struct content *c,
struct browser_window *bw,
struct content *page,
@@ -1794,6 +1794,8 @@ html_open(struct content *c,
html->selection_owner.none = true;
html_object_open_objects(html, bw);
+
+ return NSERROR_OK;
}
@@ -1801,7 +1803,7 @@ html_open(struct content *c,
* Handle a window containing a CONTENT_HTML being closed.
*/
-static void html_close(struct content *c)
+static nserror html_close(struct content *c)
{
html_content *htmlc = (html_content *) c;
@@ -1822,6 +1824,8 @@ static void html_close(struct content *c)
/* remove all object references from the html content */
html_object_close_objects(htmlc);
+
+ return NSERROR_OK;
}
diff --git a/content/handlers/javascript/content.c b/content/handlers/javascript/content.c
index ef5614094..2cb5ecd6f 100644
--- a/content/handlers/javascript/content.c
+++ b/content/handlers/javascript/content.c
@@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Content for javascript (implementation)
+/**
+ * \file
+ * javascript content implementation
*/
#include <assert.h>
diff --git a/content/handlers/javascript/duktape/Window.bnd b/content/handlers/javascript/duktape/Window.bnd
index 39c58c41d..1a7686250 100644
--- a/content/handlers/javascript/duktape/Window.bnd
+++ b/content/handlers/javascript/duktape/Window.bnd
@@ -52,7 +52,9 @@ static void window_remove_callback_bits(duk_context *ctx, size_t handle) {
/* ... */
}
-static void window_call_callback(duk_context *ctx, size_t handle, bool clear_entry) {
+static void
+window_call_callback(duk_context *ctx, size_t handle, bool clear_entry)
+{
NSLOG(dukky, DEEPDEBUG, "ctx=%p, handle=%"PRIsizet, ctx, handle);
/* Stack is ... */
duk_push_global_object(ctx);
@@ -96,21 +98,32 @@ static void window_call_callback(duk_context *ctx, size_t handle, bool clear_ent
//dukky_log_stack_frame(ctx, "On leaving callback");
}
-static void window_schedule_callback(void *p) {
+
+static void
+window_schedule_callback(void *p)
+{
window_schedule_t *priv = (window_schedule_t *)p;
- NSLOG(dukky, DEEPDEBUG, "Entered window scheduler callback: %"PRIsizet, priv->handle);
+ NSLOG(dukky, DEEPDEBUG,
+ "Entered window scheduler callback: %"PRIsizet, priv->handle);
priv->running = true;
- window_call_callback(priv->ctx, priv->handle, priv->repeat_timeout == 0);
+ window_call_callback(priv->ctx,
+ priv->handle,
+ priv->repeat_timeout == 0);
priv->running = false;
if (priv->repeat_timeout > 0) {
/* Reschedule */
- NSLOG(dukky, DEEPDEBUG, "Rescheduling repeating callback %"PRIsizet, priv->handle);
- guit->misc->schedule(priv->repeat_timeout, window_schedule_callback, priv);
+ NSLOG(dukky, DEEPDEBUG,
+ "Rescheduling repeating callback %"PRIsizet,
+ priv->handle);
+ guit->misc->schedule(priv->repeat_timeout,
+ window_schedule_callback,
+ priv);
} else {
- NSLOG(dukky, DEEPDEBUG, "Removing completed callback %"PRIsizet, priv->handle);
+ NSLOG(dukky, DEEPDEBUG,
+ "Removing completed callback %"PRIsizet, priv->handle);
/* Remove this from the ring */
RING_REMOVE(priv->owner->schedule_ring, priv);
window_remove_callback_bits(priv->ctx, priv->handle);
@@ -118,8 +131,12 @@ static void window_schedule_callback(void *p) {
}
}
-static size_t window_alloc_new_callback(duk_context *ctx, window_private_t *window,
- bool repeating, int timeout) {
+static size_t
+window_alloc_new_callback(duk_context *ctx,
+ window_private_t *window,
+ bool repeating,
+ int timeout)
+{
size_t new_handle = next_handle++;
window_schedule_t *sched = calloc(sizeof *sched, 1);
if (sched == NULL) {
@@ -168,18 +185,24 @@ static size_t window_alloc_new_callback(duk_context *ctx, window_private_t *wind
return new_handle;
}
-static void window_remove_callback_by_handle(duk_context *ctx,
- window_private_t *window,
- size_t handle) {
+static void
+window_remove_callback_by_handle(duk_context *ctx,
+ window_private_t *window,
+ size_t handle)
+{
int res;
RING_ITERATE_START(window_schedule_t, window->schedule_ring, sched) {
if (sched->handle == handle) {
if (sched->running) {
- NSLOG(dukky, DEEPDEBUG, "Cancelling in-train callback %"PRIsizet, sched->handle);
+ NSLOG(dukky, DEEPDEBUG,
+ "Cancelling in-train callback %"PRIsizet,
+ sched->handle);
sched->repeat_timeout = 0;
} else {
- NSLOG(dukky, DEEPDEBUG, "Cancelled callback %"PRIsizet, sched->handle);
+ NSLOG(dukky, DEEPDEBUG,
+ "Cancelled callback %"PRIsizet,
+ sched->handle);
res = guit->misc->schedule(-1,
window_schedule_callback,
sched);
@@ -209,7 +232,9 @@ static duk_ret_t dukky_window_closedown_compartment(duk_context *ctx)
NSLOG(dukky, DEEPDEBUG, "Closing down compartment");
while (priv->schedule_ring != NULL) {
- window_remove_callback_by_handle(ctx, priv, priv->schedule_ring->handle);
+ window_remove_callback_by_handle(ctx,
+ priv,
+ priv->schedule_ring->handle);
}
return 0;
@@ -265,6 +290,7 @@ prototype Window()
EXPOSE(encodeURIComponent);
EXPOSE(NaN);
EXPOSE(isNaN);
+ EXPOSE(isFinite);
#undef EXPOSE
/* Add s3kr1t method to close the compartment */
duk_dup(ctx, 0);
diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c
index a828667ef..538a15b03 100644
--- a/content/handlers/javascript/duktape/dukky.c
+++ b/content/handlers/javascript/duktape/dukky.c
@@ -19,7 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
+/**
+ * \file
* Duktapeish implementation of javascript engine functions.
*/
@@ -50,6 +51,15 @@
#define EVENT_LISTENER_JS_MAGIC MAGIC(EVENT_LISTENER_JS_MAP)
#define GENERICS_MAGIC MAGIC(GENERICS_TABLE)
+/**
+ * dukky javascript context
+ */
+struct jscontext {
+ duk_context *ctx; /**< duktape base context */
+ duk_context *thread; /**< duktape compartment */
+ uint64_t exec_start_time;
+};
+
static duk_ret_t dukky_populate_object(duk_context *ctx, void *udata)
{
/* ... obj args protoname nargs */
@@ -535,6 +545,7 @@ static void *dukky_realloc_function(void *udata, void *ptr, duk_size_t size)
return realloc(ptr, size);
}
+
static void dukky_free_function(void *udata, void *ptr)
{
if (ptr != NULL)
@@ -542,15 +553,36 @@ static void dukky_free_function(void *udata, void *ptr)
}
-/**************************************** js.h ******************************/
-struct jscontext {
- duk_context *ctx;
- duk_context *thread;
- uint64_t exec_start_time;
-};
-
#define CTX (ctx->thread)
+/**
+ * close current compartment
+ *
+ * \param ctx javascript context
+ * \return NSERROR_OK on sucess.
+ */
+static nserror dukky_closecompartment(jscontext *ctx)
+{
+ /* ensure there is an active compartment */
+ if (ctx->thread == NULL) {
+ return NSERROR_OK;
+ }
+
+ /* Closing down the extant compartment */
+ NSLOG(dukky, DEEPDEBUG, "Closing down extant compartment...");
+ duk_get_global_string(ctx->thread, MAGIC(closedownCompartment));
+ dukky_pcall(CTX, 0, true);
+ NSLOG(dukky, DEEPDEBUG, "Popping the thread off the stack");
+ duk_set_top(ctx->ctx, 0);
+ duk_gc(ctx->ctx, 0);
+ duk_gc(ctx->ctx, DUK_GC_COMPACT);
+
+ ctx->thread = NULL;
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in js.h */
void js_initialise(void)
{
/** TODO: Forces JS on for our testing, needs changing before a release
@@ -562,16 +594,17 @@ void js_initialise(void)
javascript_init();
}
+
+/* exported interface documented in js.h */
void js_finalise(void)
{
/* NADA for now */
}
-#define DUKKY_NEW_PROTOTYPE(klass, uklass, klass_name) \
- dukky_create_prototype(ctx, dukky_##klass##___proto, PROTO_NAME(uklass), klass_name)
-nserror js_newcontext(int timeout, jscallback *cb, void *cbctx,
- jscontext **jsctx)
+/* exported interface documented in js.h */
+nserror
+js_newcontext(int timeout, jscallback *cb, void *cbctx, jscontext **jsctx)
{
duk_context *ctx;
jscontext *ret = calloc(1, sizeof(*ret));
@@ -597,30 +630,29 @@ nserror js_newcontext(int timeout, jscallback *cb, void *cbctx,
return NSERROR_OK;
}
+
+/* exported interface documented in js.h */
void js_destroycontext(jscontext *ctx)
{
NSLOG(dukky, DEBUG, "Destroying duktape javascript context");
+ dukky_closecompartment(ctx);
duk_destroy_heap(ctx->ctx);
free(ctx);
}
+
+/* exported interface documented in js.h */
jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
{
assert(ctx != NULL);
NSLOG(dukky, DEBUG,
- "New javascript/duktape compartment, win_priv=%p, doc_priv=%p", win_priv,
- doc_priv);
+ "New javascript/duktape compartment, win_priv=%p, doc_priv=%p",
+ win_priv, doc_priv);
+
/* Pop any active thread off */
- if (CTX != NULL) {
- /* Closing down the extant compartment */
- NSLOG(dukky, DEEPDEBUG, "Closing down extant compartment...");
- duk_get_global_string(CTX, MAGIC(closedownCompartment));
- dukky_pcall(CTX, 0, true);
- NSLOG(dukky, DEEPDEBUG, "Popping the thread off the stack");
- duk_set_top(ctx->ctx, 0);
- duk_gc(ctx->ctx, 0);
- duk_gc(ctx->ctx, DUK_GC_COMPACT);
- }
+ dukky_closecompartment(ctx);
+
+ /* create new compartment thread */
duk_push_thread(ctx->ctx);
ctx->thread = duk_require_context(ctx->ctx, -1);
duk_push_int(CTX, 0);
diff --git a/content/handlers/javascript/js.h b/content/handlers/javascript/js.h
index 31ab8f766..d5af7211a 100644
--- a/content/handlers/javascript/js.h
+++ b/content/handlers/javascript/js.h
@@ -20,12 +20,11 @@
* Interface to javascript engine functions.
*/
-#ifndef _NETSURF_JAVASCRIPT_JS_H_
-#define _NETSURF_JAVASCRIPT_JS_H_
+#ifndef NETSURF_JAVASCRIPT_JS_H_
+#define NETSURF_JAVASCRIPT_JS_H_
#include "utils/errors.h"
-
typedef struct jscontext jscontext;
typedef struct jsobject jsobject;
@@ -37,40 +36,50 @@ struct dom_node;
struct dom_element;
struct dom_string;
-/** Initialise javascript interpreter */
+/**
+ * Initialise javascript interpreter
+ */
void js_initialise(void);
-/** finalise javascript interpreter */
+/**
+ * finalise javascript interpreter
+ */
void js_finalise(void);
-/** Create a new javascript context.
+/**
+ * Create a new javascript context.
*
- * There is usually one context per browser context
+ * There is usually one context per browsing context (browser window)
*
- * \param timeout elapsed wallclock time (in seconds) before \a callback is called
+ * \param timeout elapsed wallclock time (in seconds) before \a callback is called
* \param cb the callback when the runtime exceeds the timeout
* \param cbctx The context to pass to the callback
* \param jsctx Updated to the created JS context
* \return NSERROR_OK on success, appropriate error otherwise.
*/
-nserror js_newcontext(int timeout, jscallback *cb, void *cbctx,
- jscontext **jsctx);
+nserror js_newcontext(int timeout, jscallback *cb, void *cbctx, jscontext **jsctx);
-/** Destroy a previously created context */
+/**
+ * Destroy a previously created context
+ */
void js_destroycontext(jscontext *ctx);
-/** Create a new javascript compartment
+/**
+ * Create a new javascript compartment
*
* This is called once for a page with javascript script tags on
* it. It constructs a fresh global window object.
*/
jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv);
-/* execute some javascript in a context */
+/**
+ * execute some javascript in a context
+ */
bool js_exec(jscontext *ctx, const uint8_t *txt, size_t txtlen, const char *name);
-
-/* fire an event at a dom node */
+/**
+ * fire an event at a dom node
+ */
bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, struct dom_node *target);
bool
@@ -82,7 +91,8 @@ js_dom_event_add_listener(jscontext *ctx,
/*** New Events ***/
-/** Handle a new element being created.
+/**
+ * Handle a new element being created.
*
* This is called once an element is inserted into the DOM document handled
* by the context provided. The JS implementation must then scan the element
@@ -90,7 +100,8 @@ js_dom_event_add_listener(jscontext *ctx,
*/
void js_handle_new_element(jscontext *ctx, struct dom_element *node);
-/** Handle an event propagation finished callback.
+/**
+ * Handle an event propagation finished callback.
*
* This is called once an event finishes propagating, no matter how it
* finishes. The intent here is that the JS context can perform any cleanups
@@ -99,4 +110,4 @@ void js_handle_new_element(jscontext *ctx, struct dom_element *node);
*/
void js_event_cleanup(jscontext *ctx, struct dom_event *evt);
-#endif /* _NETSURF_JAVASCRIPT_JS_H_ */
+#endif /* NETSURF_JAVASCRIPT_JS_H_ */
diff --git a/content/handlers/text/textplain.c b/content/handlers/text/textplain.c
index 9e9e3e9e0..546301ffd 100644
--- a/content/handlers/text/textplain.c
+++ b/content/handlers/text/textplain.c
@@ -1204,7 +1204,7 @@ textplain_redraw(struct content *c,
/**
* Handle a window containing a CONTENT_TEXTPLAIN being opened.
*/
-static void
+static nserror
textplain_open(struct content *c,
struct browser_window *bw,
struct content *page,
@@ -1216,13 +1216,15 @@ textplain_open(struct content *c,
/* text selection */
selection_init(&text->sel, NULL, NULL);
+
+ return NSERROR_OK;
}
/**
* Handle a window containing a CONTENT_TEXTPLAIN being closed.
*/
-static void textplain_close(struct content *c)
+static nserror textplain_close(struct content *c)
{
textplain_content *text = (textplain_content *) c;
@@ -1231,6 +1233,8 @@ static void textplain_close(struct content *c)
}
text->bw = NULL;
+
+ return NSERROR_OK;
}
diff --git a/content/hlcache.h b/content/hlcache.h
index 3d9f41cdb..986bdd3f4 100644
--- a/content/hlcache.h
+++ b/content/hlcache.h
@@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * High-level resource cache (interface)
+/**
+ * \file
+ * High-level resource cache interface
*/
#ifndef NETSURF_CONTENT_HLCACHE_H_