mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 20:16:54 +03:00
[project @ 2006-01-25 06:52:38 by jmb]
Meta refresh support svn path=/import/netsurf/; revision=2039
This commit is contained in:
parent
655eaf25ae
commit
0f77b057a1
@ -295,6 +295,7 @@ struct content * content_create(const char *url)
|
|||||||
c->width = 0;
|
c->width = 0;
|
||||||
c->height = 0;
|
c->height = 0;
|
||||||
c->available_width = 0;
|
c->available_width = 0;
|
||||||
|
c->refresh = 0;
|
||||||
c->bitmap = 0;
|
c->bitmap = 0;
|
||||||
c->fresh = false;
|
c->fresh = false;
|
||||||
c->size = sizeof(struct content);
|
c->size = sizeof(struct content);
|
||||||
|
@ -150,6 +150,7 @@ typedef enum {
|
|||||||
CONTENT_MSG_REFORMAT, /**< content_reformat done */
|
CONTENT_MSG_REFORMAT, /**< content_reformat done */
|
||||||
CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */
|
CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */
|
||||||
CONTENT_MSG_NEWPTR, /**< address of structure has changed */
|
CONTENT_MSG_NEWPTR, /**< address of structure has changed */
|
||||||
|
CONTENT_MSG_REFRESH, /**< wants refresh */
|
||||||
#ifdef WITH_AUTH
|
#ifdef WITH_AUTH
|
||||||
CONTENT_MSG_AUTH /**< authentication required */
|
CONTENT_MSG_AUTH /**< authentication required */
|
||||||
#endif
|
#endif
|
||||||
@ -173,6 +174,7 @@ union content_msg_data {
|
|||||||
float object_width, object_height;
|
float object_width, object_height;
|
||||||
} redraw;
|
} redraw;
|
||||||
char *auth_realm; /**< Realm, for CONTENT_MSG_AUTH. */
|
char *auth_realm; /**< Realm, for CONTENT_MSG_AUTH. */
|
||||||
|
int delay; /**< Minimum delay, for CONTENT_MSG_REFRESH */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Linked list of users of a content. */
|
/** Linked list of users of a content. */
|
||||||
@ -233,6 +235,9 @@ struct content {
|
|||||||
#endif
|
#endif
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
|
/**< URL for refresh request, in standard form as from url_join. */
|
||||||
|
char *refresh;
|
||||||
|
|
||||||
/** Bitmap, for various image contents. */
|
/** Bitmap, for various image contents. */
|
||||||
struct bitmap *bitmap;
|
struct bitmap *bitmap;
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ struct browser_window *current_redraw_browser;
|
|||||||
|
|
||||||
static void browser_window_callback(content_msg msg, struct content *c,
|
static void browser_window_callback(content_msg msg, struct content *c,
|
||||||
intptr_t p1, intptr_t p2, union content_msg_data data);
|
intptr_t p1, intptr_t p2, union content_msg_data data);
|
||||||
|
static void browser_window_refresh(void *p);
|
||||||
static void browser_window_convert_to_download(struct browser_window *bw);
|
static void browser_window_convert_to_download(struct browser_window *bw);
|
||||||
static void browser_window_start_throbber(struct browser_window *bw);
|
static void browser_window_start_throbber(struct browser_window *bw);
|
||||||
static void browser_window_stop_throbber(struct browser_window *bw);
|
static void browser_window_stop_throbber(struct browser_window *bw);
|
||||||
@ -414,12 +415,37 @@ void browser_window_callback(content_msg msg, struct content *c,
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
case CONTENT_MSG_REFRESH:
|
||||||
|
schedule(data.delay * 100,
|
||||||
|
browser_window_refresh, bw);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh browser window
|
||||||
|
*
|
||||||
|
* \param p Browser window to refresh
|
||||||
|
*/
|
||||||
|
|
||||||
|
void browser_window_refresh(void *p)
|
||||||
|
{
|
||||||
|
struct browser_window *bw = p;
|
||||||
|
|
||||||
|
assert(bw->current_content->status == CONTENT_STATUS_READY ||
|
||||||
|
bw->current_content->status == CONTENT_STATUS_DONE);
|
||||||
|
|
||||||
|
/* mark this content as invalid so it gets flushed from the cache */
|
||||||
|
bw->current_content->fresh = false;
|
||||||
|
|
||||||
|
browser_window_go(bw, bw->current_content->refresh,
|
||||||
|
bw->current_content->url);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfer the loading_content to a new download window.
|
* Transfer the loading_content to a new download window.
|
||||||
*/
|
*/
|
||||||
|
116
render/html.c
116
render/html.c
@ -20,6 +20,7 @@
|
|||||||
#include "netsurf/content/content.h"
|
#include "netsurf/content/content.h"
|
||||||
#include "netsurf/content/fetch.h"
|
#include "netsurf/content/fetch.h"
|
||||||
#include "netsurf/content/fetchcache.h"
|
#include "netsurf/content/fetchcache.h"
|
||||||
|
#include "netsurf/desktop/browser.h"
|
||||||
#include "netsurf/desktop/gui.h"
|
#include "netsurf/desktop/gui.h"
|
||||||
#include "netsurf/desktop/options.h"
|
#include "netsurf/desktop/options.h"
|
||||||
#include "netsurf/render/box.h"
|
#include "netsurf/render/box.h"
|
||||||
@ -40,6 +41,7 @@ static bool html_set_parser_encoding(struct content *c, const char *encoding);
|
|||||||
static const char *html_detect_encoding(const char *data, unsigned int size);
|
static const char *html_detect_encoding(const char *data, unsigned int size);
|
||||||
static void html_convert_css_callback(content_msg msg, struct content *css,
|
static void html_convert_css_callback(content_msg msg, struct content *css,
|
||||||
intptr_t p1, intptr_t p2, union content_msg_data data);
|
intptr_t p1, intptr_t p2, union content_msg_data data);
|
||||||
|
static bool html_meta_refresh(struct content *c, xmlNode *head);
|
||||||
static bool html_head(struct content *c, xmlNode *head);
|
static bool html_head(struct content *c, xmlNode *head);
|
||||||
static bool html_find_stylesheets(struct content *c, xmlNode *head);
|
static bool html_find_stylesheets(struct content *c, xmlNode *head);
|
||||||
static void html_object_callback(content_msg msg, struct content *object,
|
static void html_object_callback(content_msg msg, struct content *object,
|
||||||
@ -50,6 +52,7 @@ static void html_object_failed(struct box *box, struct content *content,
|
|||||||
bool background);
|
bool background);
|
||||||
static bool html_object_type_permitted(const content_type type,
|
static bool html_object_type_permitted(const content_type type,
|
||||||
const content_type *permitted_types);
|
const content_type *permitted_types);
|
||||||
|
static void html_object_refresh(void *p);
|
||||||
static bool html_find_frame(struct content *c, const char *frame,
|
static bool html_find_frame(struct content *c, const char *frame,
|
||||||
struct content **page, unsigned int *i);
|
struct content **page, unsigned int *i);
|
||||||
|
|
||||||
@ -308,6 +311,10 @@ bool html_convert(struct content *c, int width, int height)
|
|||||||
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* handle meta refresh */
|
||||||
|
if (!html_meta_refresh(c, head))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get stylesheets */
|
/* get stylesheets */
|
||||||
@ -362,6 +369,90 @@ bool html_convert(struct content *c, int width, int height)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for meta refresh
|
||||||
|
*
|
||||||
|
* \param c content structure
|
||||||
|
* \param head xml node of head element
|
||||||
|
* \return true on success, false otherwise (error reported)
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool html_meta_refresh(struct content *c, xmlNode *head)
|
||||||
|
{
|
||||||
|
xmlNode *n;
|
||||||
|
xmlChar *equiv, *content;
|
||||||
|
union content_msg_data msg_data;
|
||||||
|
char *url, *end, *refresh;
|
||||||
|
url_func_result res;
|
||||||
|
|
||||||
|
for (n = head == 0 ? 0 : head->children; n; n = n->next) {
|
||||||
|
if (n->type != XML_ELEMENT_NODE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp((const char *)n->name, "meta"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
equiv = xmlGetProp(n, (const xmlChar *)"http-equiv");
|
||||||
|
if (!equiv)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcasecmp((const char *)equiv, "refresh")) {
|
||||||
|
xmlFree(equiv);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlFree(equiv);
|
||||||
|
|
||||||
|
content = xmlGetProp(n, (const xmlChar *)"content");
|
||||||
|
if (!content)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
end = (char *)content + strlen(content);
|
||||||
|
|
||||||
|
msg_data.delay = (int)strtol((char *) content, &url, 10);
|
||||||
|
|
||||||
|
for ( ; url <= end - 4; url++) {
|
||||||
|
if (!strncasecmp(url, "url=", 4))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url <= end - 4) {
|
||||||
|
res = url_join(url + 4, c->data.html.base_url,
|
||||||
|
&refresh);
|
||||||
|
|
||||||
|
xmlFree(content);
|
||||||
|
|
||||||
|
if (res == URL_FUNC_NOMEM) {
|
||||||
|
msg_data.error = messages_get("NoMemory");
|
||||||
|
content_broadcast(c,
|
||||||
|
CONTENT_MSG_ERROR, msg_data);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (res == URL_FUNC_FAILED) {
|
||||||
|
/* This isn't fatal so carry on looking */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
c->refresh = talloc_strdup(c, refresh);
|
||||||
|
|
||||||
|
free(refresh);
|
||||||
|
|
||||||
|
if (!c->refresh) {
|
||||||
|
msg_data.error = messages_get("NoMemory");
|
||||||
|
content_broadcast(c,
|
||||||
|
CONTENT_MSG_ERROR, msg_data);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
content_broadcast(c, CONTENT_MSG_REFRESH, msg_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlFree(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process elements in <head>.
|
* Process elements in <head>.
|
||||||
@ -1018,6 +1109,13 @@ void html_object_callback(content_msg msg, struct content *object,
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
case CONTENT_MSG_REFRESH:
|
||||||
|
if (object->type == CONTENT_HTML)
|
||||||
|
/* only for HTML objects */
|
||||||
|
schedule(data.delay * 100,
|
||||||
|
html_object_refresh, object);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -1177,6 +1275,24 @@ bool html_object_type_permitted(const content_type type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* schedule() callback for object refresh
|
||||||
|
*/
|
||||||
|
|
||||||
|
void html_object_refresh(void *p)
|
||||||
|
{
|
||||||
|
struct content *c = (struct content *)p;
|
||||||
|
|
||||||
|
assert(c->type == CONTENT_HTML && c->refresh);
|
||||||
|
|
||||||
|
c->fresh = false;
|
||||||
|
|
||||||
|
if (!html_replace_object(c->data.html.page, c->data.html.index,
|
||||||
|
c->refresh, 0, 0)) {
|
||||||
|
/** \todo handle memory exhaustion */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop loading a CONTENT_HTML in state READY.
|
* Stop loading a CONTENT_HTML in state READY.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user