content, hlcache: Propagate query events upward

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2019-08-04 09:36:49 +01:00
parent f59a726f68
commit b48e462f0f
2 changed files with 22 additions and 7 deletions

View File

@ -43,6 +43,7 @@ struct hlcache_handle;
struct object_params;
struct rect;
struct redraw_context;
struct llcache_query_msg;
/** Status of a content */
typedef enum {
@ -58,6 +59,8 @@ typedef enum {
/** Used in callbacks to indicate what has occurred. */
typedef enum {
CONTENT_MSG_LOG, /**< Content wishes to log something */
CONTENT_MSG_QUERY, /**< Something under the content has a query */
CONTENT_MSG_QUERY_FINISHED, /**< Something under the content finished its query */
CONTENT_MSG_LOADING, /**< fetching or converting */
CONTENT_MSG_READY, /**< may be displayed */
CONTENT_MSG_DONE, /**< finished */
@ -105,6 +108,10 @@ union content_msg_data {
size_t msglen; /**< The length of that message */
browser_window_console_flags flags; /**< The flags of the logging */
} log;
/** CONTENT_MSG_QUERY - Query from underlying object somewhere */
const struct llcache_query_msg *query_msg;
/** CONTENT_MSG_QUERY_FINISHED - Query from underlying object finished */
void *query_finished_pw;
/** CONTENT_MSG_ERROR - Error message */
const char *error;
/** CONTENT_MSG_ERRORCODE - Error code */

View File

@ -519,18 +519,26 @@ static nserror hlcache_llcache_callback(llcache_handle *handle,
}
break;
case LLCACHE_EVENT_QUERY:
if (hlcache->params.llcache.cb != NULL) {
return hlcache->params.llcache.cb(
event->data.query.query,
hlcache->params.llcache.cb_ctx,
event->data.query.cb,
event->data.query.cb_pw);
if (ctx->handle->cb != NULL) {
hlcache_event hlevent;
hlevent.type = CONTENT_MSG_QUERY;
hlevent.data.query_msg = &event->data.query;
ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
} else {
return NSERROR_NOT_IMPLEMENTED;
}
break;
case LLCACHE_EVENT_QUERY_FINISHED:
/* Currently nothing to do */
if (ctx->handle->cb != NULL) {
hlcache_event hlevent;
hlevent.type = CONTENT_MSG_QUERY_FINISHED;
hlevent.data.query_finished_pw = event->data.query.cb_pw;
ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
}
break;
}