mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 10:42:36 +03:00
Add content_exec and associated vtable entry
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
parent
ec0028bdb9
commit
f3892c98fd
@ -545,6 +545,27 @@ 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/* exported interface, documented in content/content.h */
|
||||
bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
|
||||
|
@ -387,6 +387,17 @@ bool content_get_quirks(struct hlcache_handle *h);
|
||||
bool content_is_locked(struct hlcache_handle *h);
|
||||
|
||||
|
||||
/**
|
||||
* Execute some JavaScript code inside a content object.
|
||||
*
|
||||
* Runs the passed in JavaScript code in the content object's context.
|
||||
*
|
||||
* \param h The handle to the content
|
||||
* \param src The JavaScript source code
|
||||
* \param srclen The length of the source code
|
||||
* \return Whether the JS function was successfully injected into the content
|
||||
*/
|
||||
bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -81,6 +81,7 @@ struct content_handler {
|
||||
content_type (*type)(void);
|
||||
void (*add_user)(struct content *c);
|
||||
void (*remove_user)(struct content *c);
|
||||
bool (*exec)(struct content *c, const char *src, size_t srclen);
|
||||
|
||||
/** handler dependant content sensitive internal data interface. */
|
||||
void * (*get_internal)(const struct content *c, void *context);
|
||||
|
Loading…
Reference in New Issue
Block a user