r10035 jmb - in /branches/jmb/new-cache: content/content.c
content/content.h
content/content_protected.h css/css.c desktop/browser.c desktop/print.c
gtk/gtk_theme.c render/favicon.c render/html.c
netsurf at semichrome.net
netsurf at semichrome.net
Sat Feb 13 15:39:40 GMT 2010
Author: jmb
Date: Sat Feb 13 09:39:40 2010
New Revision: 10035
URL: http://source.netsurf-browser.org?rev=10035&view=rev
Log:
Modify content callback API so hlcache.c compiles.
Modified:
branches/jmb/new-cache/content/content.c
branches/jmb/new-cache/content/content.h
branches/jmb/new-cache/content/content_protected.h
branches/jmb/new-cache/css/css.c
branches/jmb/new-cache/desktop/browser.c
branches/jmb/new-cache/desktop/print.c
branches/jmb/new-cache/gtk/gtk_theme.c
branches/jmb/new-cache/render/favicon.c
branches/jmb/new-cache/render/html.c
Modified: branches/jmb/new-cache/content/content.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/content.c?rev=10035&r1=10034&r2=10035&view=diff
==============================================================================
--- branches/jmb/new-cache/content/content.c (original)
+++ branches/jmb/new-cache/content/content.c Sat Feb 13 09:39:40 2010
@@ -429,9 +429,9 @@
c->size = 0;
c->title = 0;
c->active = 0;
- user_sentinel->callback = 0;
- user_sentinel->p1 = user_sentinel->p2 = 0;
- user_sentinel->next = 0;
+ user_sentinel->callback = NULL;
+ user_sentinel->pw = NULL;
+ user_sentinel->next = NULL;
c->user_list = user_sentinel;
c->sub_status[0] = 0;
c->locked = false;
@@ -830,30 +830,27 @@
*
* \param c the content to register
* \param callback the callback function
- * \param p1, p2 callback private data
+ * \param pw callback private data
* \return true on success, false otherwise on memory exhaustion
*
- * The callback will be called with p1 and p2 when content_broadcast() is
+ * The callback will be called when content_broadcast() is
* called with the content.
*/
bool content_add_user(struct content *c,
- void (*callback)(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data),
- intptr_t p1, intptr_t p2)
+ void (*callback)(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw),
+ void *pw)
{
struct content_user *user;
- LOG(("content %s (%p), user %p 0x%" PRIxPTR " 0x%" PRIxPTR,
- llcache_handle_get_url(c->llcache), c,
- callback, p1, p2));
+ LOG(("content %s (%p), user %p %p",
+ llcache_handle_get_url(c->llcache), c, callback, pw));
user = talloc(c, struct content_user);
if (!user)
return false;
user->callback = callback;
- user->p1 = p1;
- user->p2 = p2;
- user->stop = false;
+ user->pw = pw;
user->next = c->user_list->next;
c->user_list->next = user;
@@ -862,50 +859,25 @@
/**
- * Search the users of a content for the specified user.
- *
- * \return a content_user struct for the user, or 0 if not found
- */
-
-struct content_user * content_find_user(struct content *c,
- void (*callback)(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data),
- intptr_t p1, intptr_t p2)
-{
- struct content_user *user;
-
- /* user_list starts with a sentinel */
- for (user = c->user_list; user->next &&
- !(user->next->callback == callback &&
- user->next->p1 == p1 &&
- user->next->p2 == p2); user = user->next)
- ;
- return user->next;
-}
-
-
-/**
* Remove a callback user.
*
- * The callback function, p1, and p2 must be identical to those passed to
+ * The callback function and pw must be identical to those passed to
* content_add_user().
*/
void content_remove_user(struct content *c,
- void (*callback)(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data),
- intptr_t p1, intptr_t p2)
+ void (*callback)(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw),
+ void *pw)
{
struct content_user *user, *next;
- LOG(("content %s (%p), user %p 0x%" PRIxPTR " 0x%" PRIxPTR,
- llcache_handle_get_url(c->llcache), c,
- callback, p1, p2));
+ LOG(("content %s (%p), user %p %p",
+ llcache_handle_get_url(c->llcache), c, callback, pw));
/* user_list starts with a sentinel */
for (user = c->user_list; user->next != 0 &&
!(user->next->callback == callback &&
- user->next->p1 == p1 &&
- user->next->p2 == p2); user = user->next)
+ user->next->pw == pw); user = user->next)
;
if (user->next == 0) {
LOG(("user not found in list"));
@@ -931,7 +903,7 @@
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, data);
+ user->callback(c, msg, data, user->pw);
}
}
@@ -944,10 +916,12 @@
*/
void content_stop(struct content *c,
- void (*callback)(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data),
- intptr_t p1, intptr_t p2)
-{
+ void (*callback)(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw),
+ void *pw)
+{
+//newcache
+#if 0
struct content_user *user;
assert(c->status == CONTENT_STATUS_READY);
@@ -963,6 +937,7 @@
c, llcache_handle_get_url(c->llcache),
callback, p1, p2));
user->stop = true;
+#endif
}
Modified: branches/jmb/new-cache/content/content.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/content.h?rev=10035&r1=10034&r2=10035&view=diff
==============================================================================
--- branches/jmb/new-cache/content/content.h (original)
+++ branches/jmb/new-cache/content/content.h Sat Feb 13 09:39:40 2010
@@ -123,23 +123,19 @@
float scale, colour background_colour,
bool repeat_x, bool repeat_y);
bool content_add_user(struct content *c,
- void (*callback)(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data),
- intptr_t p1, intptr_t p2);
-struct content_user * content_find_user(struct content *c,
- void (*callback)(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data),
- intptr_t p1, intptr_t p2);
+ void (*callback)(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw),
+ void *pw);
void content_remove_user(struct content *c,
- void (*callback)(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data),
- intptr_t p1, intptr_t p2);
+ void (*callback)(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw),
+ void *pw);
void content_broadcast(struct content *c, content_msg msg,
union content_msg_data data);
void content_stop(struct content *c,
- void (*callback)(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data),
- intptr_t p1, intptr_t p2);
+ void (*callback)(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw),
+ void *pw);
void content_open(struct content *c, struct browser_window *bw,
struct content *page, unsigned int index, struct box *box,
struct object_params *params);
Modified: branches/jmb/new-cache/content/content_protected.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/content_protected.h?rev=10035&r1=10034&r2=10035&view=diff
==============================================================================
--- branches/jmb/new-cache/content/content_protected.h (original)
+++ branches/jmb/new-cache/content/content_protected.h Sat Feb 13 09:39:40 2010
@@ -83,11 +83,10 @@
/** Linked list of users of a content. */
struct content_user
{
- void (*callback)(content_msg msg, struct content *c, intptr_t p1,
- intptr_t p2, union content_msg_data data);
- intptr_t p1;
- intptr_t p2;
- bool stop;
+ void (*callback)(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw);
+ void *pw;
+
struct content_user *next;
};
Modified: branches/jmb/new-cache/css/css.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/css/css.c?rev=10035&r1=10034&r2=10035&view=diff
==============================================================================
--- branches/jmb/new-cache/css/css.c (original)
+++ branches/jmb/new-cache/css/css.c Sat Feb 13 09:39:40 2010
@@ -29,8 +29,8 @@
#include "render/html.h"
#include "utils/messages.h"
-static void nscss_import(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data);
+static void nscss_import(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw);
/**
* Allocation callback for libcss
@@ -198,7 +198,7 @@
c->size += c->data.css.imports[i].c->size;
content_remove_user(c->data.css.imports[i].c,
- nscss_import, (uintptr_t) c, i);
+ nscss_import, &c->data.css.imports[i]);
}
c->data.css.imports[i].c = NULL;
@@ -337,7 +337,7 @@
for (i = 0; i < c->import_count; i++) {
if (c->imports[i].c != NULL) {
content_remove_user(c->imports[i].c,
- nscss_import, (uintptr_t) c, i);
+ nscss_import, &c->imports[i]);
}
c->imports[i].c = NULL;
}
@@ -370,22 +370,23 @@
/**
* Fetchcache handler for imported stylesheets
*
+ * \param c Content being fetched
* \param msg Message type
- * \param c Content being fetched
- * \param p1 Parent content
- * \param p2 Index into parent's imported stylesheet array
* \param data Message data
- */
-void nscss_import(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data)
-{
+ * \param pw Callback context
+ */
+void nscss_import(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw)
+{
+//newcache
+#if 0
struct content *parent = (struct content *) p1;
uint32_t i = (uint32_t) p2;
switch (msg) {
case CONTENT_MSG_LOADING:
if (c->type != CONTENT_CSS) {
- content_remove_user(c, nscss_import, p1, p2);
+ content_remove_user(c, nscss_import, pw);
if (c->user_list->next == NULL) {
c->status = CONTENT_STATUS_ERROR;
}
@@ -417,5 +418,6 @@
default:
assert(0);
}
-}
-
+#endif
+}
+
Modified: branches/jmb/new-cache/desktop/browser.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/desktop/browser.c?rev=10035&r1=10034&r2=10035&view=diff
==============================================================================
--- branches/jmb/new-cache/desktop/browser.c (original)
+++ branches/jmb/new-cache/desktop/browser.c Sat Feb 13 09:39:40 2010
@@ -77,8 +77,8 @@
struct fetch_multipart_data *post_multipart,
bool add_to_history, const char *referer, bool download,
bool verifiable, struct content *parent);
-static void browser_window_callback(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data);
+static void browser_window_callback(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw);
static void browser_window_refresh(void *p);
static bool browser_window_check_throbber(struct browser_window *bw);
static void browser_window_convert_to_download(struct browser_window *bw);
@@ -403,10 +403,10 @@
* Callback for fetchcache() for browser window fetches.
*/
-void browser_window_callback(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data)
-{
- struct browser_window *bw = (struct browser_window *) p1;
+void browser_window_callback(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw)
+{
+ struct browser_window *bw = pw;
switch (msg) {
case CONTENT_MSG_LOADING:
@@ -418,8 +418,7 @@
else if (content_get_type(c) == CONTENT_THEME) {
theme_install_start(c);
bw->loading_content = 0;
- content_remove_user(c, browser_window_callback,
- (intptr_t) bw, 0);
+ content_remove_user(c, browser_window_callback, bw);
browser_window_stop_throbber(bw);
}
#endif
@@ -441,8 +440,7 @@
status == CONTENT_STATUS_DONE)
content_close(bw->current_content);
content_remove_user(bw->current_content,
- browser_window_callback,
- (intptr_t) bw, 0);
+ browser_window_callback, bw);
}
bw->current_content = c;
bw->loading_content = NULL;
@@ -669,7 +667,7 @@
/* remove content from browser window */
bw->loading_content = 0;
- content_remove_user(c, browser_window_callback, (intptr_t) bw, 0);
+ content_remove_user(c, browser_window_callback, bw);
browser_window_stop_throbber(bw);
}
@@ -848,7 +846,7 @@
if (bw->loading_content) {
content_remove_user(bw->loading_content,
- browser_window_callback, (intptr_t) bw, 0);
+ browser_window_callback, bw);
bw->loading_content = 0;
}
@@ -857,7 +855,7 @@
assert(content_get_status(bw->current_content) ==
CONTENT_STATUS_READY);
content_stop(bw->current_content,
- browser_window_callback, (intptr_t) bw, 0);
+ browser_window_callback, bw);
}
schedule_remove(browser_window_refresh, bw);
@@ -1040,7 +1038,7 @@
browser_window_destroy_children(bw);
if (bw->loading_content) {
content_remove_user(bw->loading_content,
- browser_window_callback, (intptr_t) bw, 0);
+ browser_window_callback, bw);
bw->loading_content = 0;
}
if (bw->current_content) {
@@ -1049,7 +1047,7 @@
status == CONTENT_STATUS_DONE)
content_close(bw->current_content);
content_remove_user(bw->current_content,
- browser_window_callback, (intptr_t) bw, 0);
+ browser_window_callback, bw);
bw->current_content = 0;
}
Modified: branches/jmb/new-cache/desktop/print.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/desktop/print.c?rev=10035&r1=10034&r2=10035&view=diff
==============================================================================
--- branches/jmb/new-cache/desktop/print.c (original)
+++ branches/jmb/new-cache/desktop/print.c Sat Feb 13 09:39:40 2010
@@ -248,12 +248,11 @@
html_redraw_printing = false;
if (printed_content) {
- content_remove_user(printed_content, NULL,
- (intptr_t) print_init, 0);
+ content_remove_user(printed_content, NULL, print_init);
talloc_free(printed_content);
}
- content_remove_user(content, NULL, (intptr_t)print_init, 0);
+ content_remove_user(content, NULL, print_init);
free((void *)settings->output);
free(settings);
Modified: branches/jmb/new-cache/gtk/gtk_theme.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/gtk/gtk_theme.c?rev=10035&r1=10034&r2=10035&view=diff
==============================================================================
--- branches/jmb/new-cache/gtk/gtk_theme.c (original)
+++ branches/jmb/new-cache/gtk/gtk_theme.c Sat Feb 13 09:39:40 2010
@@ -64,8 +64,8 @@
#ifdef WITH_THEME_INSTALL
static struct content *theme_install_content = NULL;
-static void theme_install_callback(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data);
+static void theme_install_callback(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw);
static bool theme_install_read(const char *data, unsigned long len);
#endif
@@ -681,7 +681,7 @@
/* stop theme sitting in memory cache */
content_invalidate_reuse_data(c);
- if (!content_add_user(c, theme_install_callback, 0, 0)) {
+ if (!content_add_user(c, theme_install_callback, NULL)) {
warn_user("NoMemory", 0);
return;
}
@@ -692,8 +692,8 @@
* Callback for fetchcache() for theme install fetches.
*/
-void theme_install_callback(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data)
+void theme_install_callback(struct content *c, content_msg msg,
+ union content_msg_data data, void *pw)
{
switch (msg) {
case CONTENT_MSG_READY:
Modified: branches/jmb/new-cache/render/favicon.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/render/favicon.c?rev=10035&r1=10034&r2=10035&view=diff
==============================================================================
--- branches/jmb/new-cache/render/favicon.c (original)
+++ branches/jmb/new-cache/render/favicon.c Sat Feb 13 09:39:40 2010
@@ -30,8 +30,8 @@
#include "utils/utils.h"
static char *favicon_get_icon_ref(struct content *c, xmlNode *html);
-static void favicon_callback(content_msg msg, struct content *icon,
- intptr_t p1, intptr_t p2, union content_msg_data data);
+static void favicon_callback(struct content *icon, content_msg msg,
+ union content_msg_data data, void *pw);
/**
* retrieve 1 url reference to 1 favicon
@@ -165,8 +165,8 @@
* Callback for fetchcache() for linked favicon
*/
-void favicon_callback(content_msg msg, struct content *icon,
- intptr_t p1, intptr_t p2, union content_msg_data data)
+void favicon_callback(struct content *icon, content_msg msg,
+ union content_msg_data data, void *pw)
{
static const content_type permitted_types[] = {
#ifdef WITH_BMP
@@ -180,8 +180,7 @@
#endif
CONTENT_UNKNOWN
};
- struct content *c = (struct content *) p1;
- unsigned int i = p2;
+ struct content *c = pw;
const content_type *type;
@@ -198,9 +197,7 @@
content_add_error(c, "NotFavIco", 0);
html_set_status(c, messages_get("NotFavIco"));
content_broadcast(c, CONTENT_MSG_STATUS, data);
- content_remove_user(icon,
- favicon_callback,
- (intptr_t) c, i);
+ content_remove_user(icon, favicon_callback, pw);
if (!icon->user_list->next) {
/* we were the only user and we don't want this
* content, so stop it fetching and mark it as
Modified: branches/jmb/new-cache/render/html.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/render/html.c?rev=10035&r1=10034&r2=10035&view=diff
==============================================================================
--- branches/jmb/new-cache/render/html.c (original)
+++ branches/jmb/new-cache/render/html.c Sat Feb 13 09:39:40 2010
@@ -57,15 +57,15 @@
#define ALWAYS_DUMP_FRAMESET 0
#define ALWAYS_DUMP_BOX 0
-static void html_convert_css_callback(content_msg msg, struct content *css,
- intptr_t p1, intptr_t p2, union content_msg_data data);
+static void html_convert_css_callback(struct content *css, content_msg msg,
+ union content_msg_data data, void *pw);
static bool html_meta_refresh(struct content *c, xmlNode *head);
static bool html_head(struct content *c, xmlNode *head);
static bool html_find_stylesheets(struct content *c, xmlNode *html);
static bool html_process_style_element(struct content *c, unsigned int *index,
xmlNode *style);
-static void html_object_callback(content_msg msg, struct content *object,
- intptr_t p1, intptr_t p2, union content_msg_data data);
+static void html_object_callback(struct content *object, content_msg msg,
+ union content_msg_data data, void *pw);
static void html_object_done(struct box *box, struct content *object,
bool background);
static void html_object_failed(struct box *box, struct content *content,
@@ -1164,12 +1164,12 @@
* Callback for fetchcache() for linked stylesheets.
*/
-void html_convert_css_callback(content_msg msg, struct content *css,
- intptr_t p1, intptr_t p2, union content_msg_data data)
-{
- struct content *c = (struct content *) p1;
- unsigned int i = p2;
-
+void html_convert_css_callback(struct content *css, content_msg msg,
+ union content_msg_data data, void *pw)
+{
+ struct html_stylesheet *s = pw;
+//newcache
+#if 0
switch (msg) {
case CONTENT_MSG_LOADING:
/* check that the stylesheet is really CSS */
@@ -1244,6 +1244,7 @@
default:
assert(0);
}
+#endif
}
@@ -1294,8 +1295,7 @@
object = talloc_realloc(c, c->data.html.object,
struct content_html_object, i + 1);
if (!object) {
- content_remove_user(c_fetch, html_object_callback,
- (intptr_t) c, i);
+ content_remove_user(c_fetch, html_object_callback, NULL);
return false;
}
c->data.html.object = object;
@@ -1344,7 +1344,7 @@
CONTENT_STATUS_DONE)
c->active--;
content_remove_user(c->data.html.object[i].content,
- html_object_callback, (intptr_t) c, i);
+ html_object_callback, NULL);
c->data.html.object[i].content = 0;
c->data.html.object[i].box->object = 0;
}
@@ -1388,9 +1388,11 @@
* Callback for fetchcache() for objects.
*/
-void html_object_callback(content_msg msg, struct content *object,
- intptr_t p1, intptr_t p2, union content_msg_data data)
-{
+void html_object_callback(struct content *object, content_msg msg,
+ union content_msg_data data, void *pw)
+{
+//newcache
+#if 0
struct content *c = (struct content *) p1;
unsigned int i = p2;
int x, y;
@@ -1555,6 +1557,7 @@
((time_taken < option_min_reflow_period ?
option_min_reflow_period : time_taken * 1.25));
}
+#endif
}
@@ -1744,11 +1747,10 @@
if (object->status == CONTENT_STATUS_DONE)
; /* already loaded: do nothing */
else if (object->status == CONTENT_STATUS_READY)
- content_stop(object, html_object_callback,
- (intptr_t) c, i);
+ content_stop(object, html_object_callback, NULL);
else {
content_remove_user(c->data.html.object[i].content,
- html_object_callback, (intptr_t) c, i);
+ html_object_callback, NULL);
c->data.html.object[i].content = 0;
}
}
@@ -1847,7 +1849,7 @@
content_remove_user(c->data.html.
stylesheets[i].data.external,
html_convert_css_callback,
- (intptr_t) c, i);
+ &c->data.html.stylesheets[i]);
} else {
nscss_destroy_css_data(c->data.html.
stylesheets[i].data.internal);
@@ -1860,7 +1862,7 @@
LOG(("object %i %p", i, c->data.html.object[i].content));
if (c->data.html.object[i].content) {
content_remove_user(c->data.html.object[i].content,
- html_object_callback, (intptr_t) c, i);
+ html_object_callback, NULL);
if (c->data.html.object[i].content->type == CONTENT_HTML)
schedule_remove(html_object_refresh,
c->data.html.object[i].content);
More information about the netsurf-commits
mailing list