From d00c5b0cd5a0f44a0107faf1190e1923487ba736 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 7 Jan 2011 13:10:20 +0000 Subject: Add CONTENT_MSG_FAVICON_REFRESH and emit and handle it appropriately. Animated favicons now work svn path=/trunk/netsurf/; revision=11242 --- content/content.h | 3 ++- desktop/browser.c | 5 +++++ render/favicon.c | 21 ++++++++++++++------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/content/content.h b/content/content.h index f6d293ea2..ed5bca041 100644 --- a/content/content.h +++ b/content/content.h @@ -63,7 +63,8 @@ typedef enum { CONTENT_MSG_REFORMAT, /**< content_reformat done */ CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */ CONTENT_MSG_REFRESH, /**< wants refresh */ - CONTENT_MSG_DOWNLOAD /**< download, not for display */ + CONTENT_MSG_DOWNLOAD, /**< download, not for display */ + CONTENT_MSG_FAVICON_REFRESH, /**< favicon has been refreshed (eg. new animation frame) */ } content_msg; /** Extra data for some content_msg messages. */ diff --git a/desktop/browser.c b/desktop/browser.c index b301b5fa3..2343cea85 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -581,6 +581,11 @@ nserror browser_window_callback(hlcache_handle *c, case CONTENT_MSG_REFRESH: bw->refresh_interval = event->data.delay * 100; break; + + case CONTENT_MSG_FAVICON_REFRESH: + /* Cause the GUI to update */ + gui_window_set_icon(bw->window, html_get_favicon(bw->current_content)); + break; default: assert(0); diff --git a/render/favicon.c b/render/favicon.c index a7670dfa4..842924ae5 100644 --- a/render/favicon.c +++ b/render/favicon.c @@ -166,9 +166,9 @@ bool favicon_get_icon(struct content *c, xmlNode *html) url = favicon_get_icon_ref(c, html); if (url == NULL) return false; - - LOG(("WOOP WOOP, SUMMON DA POLICE. FAVICON URL IS %s", url)); - + + LOG(("WOOP WOOP, SUMMON DA POLICE. FAVICON URL IS %s", url)); + error = hlcache_handle_retrieve(url, LLCACHE_RETRIEVE_NO_ERROR_PAGES, content__get_url(c), NULL, favicon_callback, c, NULL, permitted_types, &c->data.html.favicon); @@ -190,7 +190,7 @@ nserror favicon_callback(hlcache_handle *icon, const hlcache_event *event, void *pw) { struct content *c = pw; - bool consider_done = false; + bool consider_done = false, consider_redraw = false; switch (event->type) { case CONTENT_MSG_LOADING: @@ -241,20 +241,27 @@ nserror favicon_callback(hlcache_handle *icon, case CONTENT_MSG_REFRESH: /* Fall through */ case CONTENT_MSG_REFORMAT: + consider_redraw = true; break; default: assert(0); } + if (consider_redraw && (c->data.html.favicon != NULL) && (content_get_type(c->data.html.favicon) == CONTENT_GIF)) { + union content_msg_data msg_data; + /* This is needed in order to cause animated GIFs to update their bitmap */ + content_redraw(c->data.html.favicon, 0, 0, -1, -1, 0, 0, 0, 0, 1.0, 0); + content_broadcast(c, CONTENT_MSG_FAVICON_REFRESH, msg_data); + } + if (consider_done && (c->active == 0)) { /* all objects have arrived */ content__reformat(c, c->available_width, c->height); html_set_status(c, ""); content_set_done(c); - } else if (c->active == 0) { - content__reformat(c, c->available_width, c->height); - } + } + return NSERROR_OK; } -- cgit v1.2.3