summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-04-24 23:42:32 +0000
committerJames Bursa <james@netsurf-browser.org>2004-04-24 23:42:32 +0000
commit1f07fc6de5ae4e9999efb1fc1cd0f25a27f1bd64 (patch)
treed1f926d45423a1b68a82e40d2a876542110a3f16 /content
parentbfb0116bea8078950c905b5872849d763beea728 (diff)
downloadnetsurf-1f07fc6de5ae4e9999efb1fc1cd0f25a27f1bd64.tar.gz
netsurf-1f07fc6de5ae4e9999efb1fc1cd0f25a27f1bd64.tar.bz2
[project @ 2004-04-24 23:42:31 by bursa]
Replace void pointer in content callbacks with union content_msg_data. Fix animated gif flickering (except for scaled or masked gifs). Add gif to the debug builds. svn path=/import/netsurf/; revision=801
Diffstat (limited to 'content')
-rw-r--r--content/content.c34
-rw-r--r--content/content.h35
-rw-r--r--content/content_type.h6
-rw-r--r--content/fetchcache.c22
-rw-r--r--content/fetchcache.h2
5 files changed, 63 insertions, 36 deletions
diff --git a/content/content.c b/content/content.c
index db4fcb406..e8cfade5d 100644
--- a/content/content.c
+++ b/content/content.c
@@ -58,10 +58,10 @@ static const struct mime_entry mime_map[] = {
{"application/x-drawfile", CONTENT_DRAW},
{"image/drawfile", CONTENT_DRAW},
#endif
+#endif
#ifdef WITH_GIF
{"image/gif", CONTENT_GIF},
#endif
-#endif
#ifdef WITH_JPEG
{"image/jpeg", CONTENT_JPEG},
{"image/pjpeg", CONTENT_JPEG},
@@ -118,15 +118,15 @@ static const struct handler_entry handler_map[] = {
{nsjpeg_create, 0, nsjpeg_convert, 0,
0, nsjpeg_destroy, nsjpeg_redraw, 0, 0, 0},
#endif
+#ifdef WITH_GIF
+ {nsgif_create, 0, nsgif_convert, 0,
+ 0, nsgif_destroy, nsgif_redraw, 0, 0, 0},
+#endif
#ifdef riscos
#ifdef WITH_PNG
{nspng_create, nspng_process_data, nspng_convert, 0,
0, nspng_destroy, nspng_redraw, 0, 0, 0},
#endif
-#ifdef WITH_GIF
- {nsgif_create, 0, nsgif_convert, 0,
- 0, nsgif_destroy, nsgif_redraw, 0, 0, 0},
-#endif
#ifdef WITH_SPRITE
{sprite_create, sprite_process_data, sprite_convert, sprite_revive,
sprite_reformat, sprite_destroy, sprite_redraw, 0, 0, 0},
@@ -222,6 +222,7 @@ struct content * content_create(char *url)
void content_set_type(struct content *c, content_type type, char* mime_type,
const char *params[])
{
+ union content_msg_data data;
assert(c != 0);
assert(c->status == CONTENT_STATUS_TYPE_UNKNOWN);
assert(type < CONTENT_UNKNOWN);
@@ -232,7 +233,7 @@ void content_set_type(struct content *c, content_type type, char* mime_type,
c->source_data = xcalloc(0, 1);
if (handler_map[type].create)
handler_map[type].create(c, params);
- content_broadcast(c, CONTENT_MSG_LOADING, 0);
+ content_broadcast(c, CONTENT_MSG_LOADING, data);
/* c may be destroyed at this point as a result of
* CONTENT_MSG_LOADING, so must not be accessed */
}
@@ -274,6 +275,7 @@ void content_process_data(struct content *c, char *data, unsigned long size)
void content_convert(struct content *c, unsigned long width, unsigned long height)
{
+ union content_msg_data data;
assert(c != 0);
assert(c->type < HANDLER_MAP_COUNT);
assert(c->status == CONTENT_STATUS_LOADING);
@@ -282,8 +284,8 @@ void content_convert(struct content *c, unsigned long width, unsigned long heigh
if (handler_map[c->type].convert) {
if (handler_map[c->type].convert(c, width, height)) {
/* convert failed, destroy content */
- content_broadcast(c, CONTENT_MSG_ERROR,
- "Conversion failed");
+ data.error = "Conversion failed";
+ content_broadcast(c, CONTENT_MSG_ERROR, data);
if (c->cache)
cache_destroy(c);
content_destroy(c);
@@ -294,9 +296,9 @@ void content_convert(struct content *c, unsigned long width, unsigned long heigh
}
assert(c->status == CONTENT_STATUS_READY ||
c->status == CONTENT_STATUS_DONE);
- content_broadcast(c, CONTENT_MSG_READY, 0);
+ content_broadcast(c, CONTENT_MSG_READY, data);
if (c->status == CONTENT_STATUS_DONE)
- content_broadcast(c, CONTENT_MSG_DONE, 0);
+ content_broadcast(c, CONTENT_MSG_DONE, data);
}
@@ -326,13 +328,14 @@ void content_revive(struct content *c, unsigned long width, unsigned long height
void content_reformat(struct content *c, unsigned long width, unsigned long height)
{
+ union content_msg_data data;
assert(c != 0);
assert(c->status == CONTENT_STATUS_READY ||
c->status == CONTENT_STATUS_DONE);
c->available_width = width;
if (handler_map[c->type].reformat) {
handler_map[c->type].reformat(c, width, height);
- content_broadcast(c, CONTENT_MSG_REFORMAT, 0);
+ content_broadcast(c, CONTENT_MSG_REFORMAT, data);
}
}
@@ -417,7 +420,7 @@ void content_redraw(struct content *c, long x, long y,
void content_add_user(struct content *c,
void (*callback)(content_msg msg, struct content *c, void *p1,
- void *p2, const char *error),
+ void *p2, union content_msg_data data),
void *p1, void *p2)
{
struct content_user *user;
@@ -440,7 +443,7 @@ void content_add_user(struct content *c,
void content_remove_user(struct content *c,
void (*callback)(content_msg msg, struct content *c, void *p1,
- void *p2, const char *error),
+ void *p2, union content_msg_data data),
void *p1, void *p2)
{
struct content_user *user, *next;
@@ -487,14 +490,15 @@ void content_remove_user(struct content *c,
* Send a message to all users.
*/
-void content_broadcast(struct content *c, content_msg msg, char *error)
+void content_broadcast(struct content *c, content_msg msg,
+ union content_msg_data data)
{
struct content_user *user, *next;
c->lock++;
for (user = c->user_list->next; user != 0; user = next) {
next = user->next; /* user may be destroyed during callback */
if (user->callback != 0)
- user->callback(msg, c, user->p1, user->p2, error);
+ user->callback(msg, c, user->p1, user->p2, data);
}
if (--(c->lock) == 0 && c->destroy_pending)
content_destroy(c);
diff --git a/content/content.h b/content/content.h
index b865e6b4c..ff7742868 100644
--- a/content/content.h
+++ b/content/content.h
@@ -37,10 +37,10 @@
#ifdef WITH_JPEG
#include "netsurf/riscos/jpeg.h"
#endif
-#ifdef riscos
#ifdef WITH_GIF
#include "netsurf/riscos/gif.h"
#endif
+#ifdef riscos
#ifdef WITH_PLUGIN
#include "netsurf/riscos/plugin.h"
#endif
@@ -71,11 +71,29 @@ typedef enum {
#endif
} content_msg;
+/** Extra data for some content_msg messages. */
+union content_msg_data {
+ const char *error; /**< Error message, for CONTENT_MSG_ERROR. */
+ char *redirect; /**< Redirect URL, for CONTENT_MSG_REDIRECT. */
+ /** Area of content which needs redrawing, for CONTENT_MSG_REDRAW. */
+ struct {
+ int x, y, width, height;
+ /** Redraw the area fully. If false, object must be set,
+ * and only the object will be redrawn. */
+ bool full_redraw;
+ /** Object to redraw if full_redraw is false. */
+ struct content *object;
+ /** Coordinates to plot object at. */
+ int object_x, object_y;
+ } redraw;
+ char *auth_realm; /**< Realm, for CONTENT_MSG_AUTH. */
+};
+
/** Linked list of users of a content. */
struct content_user
{
void (*callback)(content_msg msg, struct content *c, void *p1,
- void *p2, const char *error);
+ void *p2, union content_msg_data data);
void *p1;
void *p2;
struct content_user *next;
@@ -106,13 +124,13 @@ struct content {
#ifdef WITH_JPEG
struct content_jpeg_data jpeg;
#endif
+#ifdef WITH_GIF
+ struct content_gif_data gif;
+#endif
#ifdef riscos
#ifdef WITH_PNG
struct content_png_data png;
#endif
-#ifdef WITH_GIF
- struct content_gif_data gif;
-#endif
#ifdef WITH_SPRITE
struct content_sprite_data sprite;
#endif
@@ -165,13 +183,14 @@ void content_redraw(struct content *c, long x, long y,
float scale);
void content_add_user(struct content *c,
void (*callback)(content_msg msg, struct content *c, void *p1,
- void *p2, const char *error),
+ void *p2, union content_msg_data data),
void *p1, void *p2);
void content_remove_user(struct content *c,
void (*callback)(content_msg msg, struct content *c, void *p1,
- void *p2, const char *error),
+ void *p2, union content_msg_data data),
void *p1, void *p2);
-void content_broadcast(struct content *c, content_msg msg, char *error);
+void content_broadcast(struct content *c, content_msg msg,
+ union content_msg_data data);
void content_add_instance(struct content *c, struct browser_window *bw,
struct content *page, struct box *box,
struct object_params *params, void **state);
diff --git a/content/content_type.h b/content/content_type.h
index 96fa70575..66d2faad1 100644
--- a/content/content_type.h
+++ b/content/content_type.h
@@ -25,13 +25,13 @@ typedef enum {
#ifdef WITH_JPEG
CONTENT_JPEG,
#endif
+#ifdef WITH_GIF
+ CONTENT_GIF,
+#endif
#ifdef riscos
#ifdef WITH_PNG
CONTENT_PNG,
#endif
-#ifdef WITH_GIF
- CONTENT_GIF,
-#endif
#ifdef WITH_SPRITE
CONTENT_SPRITE,
#endif
diff --git a/content/fetchcache.c b/content/fetchcache.c
index b87df6a36..c8c10db01 100644
--- a/content/fetchcache.c
+++ b/content/fetchcache.c
@@ -64,7 +64,7 @@ static void fetchcache_error_page(struct content *c, const char *error);
struct content * fetchcache(const char *url, char *referer,
void (*callback)(content_msg msg, struct content *c, void *p1,
- void *p2, const char *error),
+ void *p2, union content_msg_data data),
void *p1, void *p2, unsigned long width, unsigned long height,
bool no_error_pages
#ifdef WITH_POST
@@ -150,6 +150,7 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size)
char *mime_type, *url;
char **params;
unsigned int i;
+ union content_msg_data msg_data;
c->lock++;
@@ -180,7 +181,7 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size)
sprintf(c->status_message,
messages_get("Received"),
c->source_size + size);
- content_broadcast(c, CONTENT_MSG_STATUS, 0);
+ content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
content_process_data(c, data, size);
break;
@@ -189,7 +190,7 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size)
sprintf(c->status_message, messages_get("Converting"),
c->source_size);
c->fetch = 0;
- content_broadcast(c, CONTENT_MSG_STATUS, 0);
+ content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
content_convert(c, c->width, c->height);
break;
@@ -199,7 +200,8 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size)
if (c->cache)
cache_destroy(c);
if (c->no_error_pages) {
- content_broadcast(c, CONTENT_MSG_ERROR, data);
+ msg_data.error = data;
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
content_destroy(c);
} else {
content_reset(c);
@@ -214,11 +216,12 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size)
* relative ones: treat them as relative to requested URL */
url = url_join(data, c->url);
if (url) {
- content_broadcast(c, CONTENT_MSG_REDIRECT, url);
- xfree(url);
+ msg_data.redirect = url;
+ content_broadcast(c, CONTENT_MSG_REDIRECT, msg_data);
+ free(url);
} else {
- content_broadcast(c, CONTENT_MSG_ERROR,
- messages_get("BadRedirect"));
+ msg_data.error = messages_get("BadRedirect");
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
}
if (c->cache)
cache_destroy(c);
@@ -229,7 +232,8 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size)
/* data -> string containing the Realm */
LOG(("FETCH_AUTH, '%s'", data));
c->fetch = 0;
- content_broadcast(c, CONTENT_MSG_AUTH, data);
+ msg_data.auth_realm = data;
+ content_broadcast(c, CONTENT_MSG_AUTH, msg_data);
cache_destroy(c);
break;
#endif
diff --git a/content/fetchcache.h b/content/fetchcache.h
index 37d3e1f18..3fadc3459 100644
--- a/content/fetchcache.h
+++ b/content/fetchcache.h
@@ -25,7 +25,7 @@ struct form_successful_control;
struct content * fetchcache(const char *url, char *referer,
void (*callback)(content_msg msg, struct content *c, void *p1,
- void *p2, const char *error),
+ void *p2, union content_msg_data data),
void *p1, void *p2, unsigned long width, unsigned long height,
bool no_error_pages
#ifdef WITH_POST