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 object_params;
struct rect; struct rect;
struct redraw_context; struct redraw_context;
struct llcache_query_msg;
/** Status of a content */ /** Status of a content */
typedef enum { typedef enum {
@ -58,6 +59,8 @@ typedef enum {
/** Used in callbacks to indicate what has occurred. */ /** Used in callbacks to indicate what has occurred. */
typedef enum { typedef enum {
CONTENT_MSG_LOG, /**< Content wishes to log something */ 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_LOADING, /**< fetching or converting */
CONTENT_MSG_READY, /**< may be displayed */ CONTENT_MSG_READY, /**< may be displayed */
CONTENT_MSG_DONE, /**< finished */ CONTENT_MSG_DONE, /**< finished */
@ -105,6 +108,10 @@ union content_msg_data {
size_t msglen; /**< The length of that message */ size_t msglen; /**< The length of that message */
browser_window_console_flags flags; /**< The flags of the logging */ browser_window_console_flags flags; /**< The flags of the logging */
} log; } 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 */ /** CONTENT_MSG_ERROR - Error message */
const char *error; const char *error;
/** CONTENT_MSG_ERRORCODE - Error code */ /** CONTENT_MSG_ERRORCODE - Error code */

View File

@ -519,18 +519,26 @@ static nserror hlcache_llcache_callback(llcache_handle *handle,
} }
break; break;
case LLCACHE_EVENT_QUERY: case LLCACHE_EVENT_QUERY:
if (hlcache->params.llcache.cb != NULL) { if (ctx->handle->cb != NULL) {
return hlcache->params.llcache.cb( hlcache_event hlevent;
event->data.query.query,
hlcache->params.llcache.cb_ctx, hlevent.type = CONTENT_MSG_QUERY;
event->data.query.cb, hlevent.data.query_msg = &event->data.query;
event->data.query.cb_pw);
ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
} else { } else {
return NSERROR_NOT_IMPLEMENTED; return NSERROR_NOT_IMPLEMENTED;
} }
break; break;
case LLCACHE_EVENT_QUERY_FINISHED: 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; break;
} }