From b48e462f0f542f82db95d9b8613339a9b748808e Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 4 Aug 2019 09:36:49 +0100 Subject: content, hlcache: Propagate query events upward Signed-off-by: Daniel Silverstone --- content/content.h | 7 +++++++ content/hlcache.c | 22 +++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/content/content.h b/content/content.h index 2d0646dab..304384b8f 100644 --- a/content/content.h +++ b/content/content.h @@ -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 */ diff --git a/content/hlcache.c b/content/hlcache.c index c07c5a1a1..92bf690ed 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -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; } -- cgit v1.2.3