summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--!NetSurf/!Run,feb1
-rw-r--r--!NetSurf/Resources/CSS,f79 (renamed from !NetSurf/Resources/CSS,0cc)0
-rw-r--r--content/content.h13
-rw-r--r--content/fetch.c31
-rw-r--r--content/fetchcache.c28
-rw-r--r--content/fetchcache.h4
-rw-r--r--css/css.c30
-rw-r--r--desktop/browser.c6
-rw-r--r--render/html.c7
-rw-r--r--render/layout.c58
-rw-r--r--riscos/filetype.c4
11 files changed, 127 insertions, 55 deletions
diff --git a/!NetSurf/!Run,feb b/!NetSurf/!Run,feb
index 70cb6b180..294c3ffd8 100644
--- a/!NetSurf/!Run,feb
+++ b/!NetSurf/!Run,feb
@@ -3,6 +3,7 @@
Set NetSurf$Dir <Obey$Dir>
IconSprites <NetSurf$Dir>.!Sprites
+Set File$Type_F79 CSS
RMensure WindowManager 3.80 Error 0 NetSurf requires the Nested Window Manager.
RMEnsure UtilityModule 3.70 RMensure CallASWI 0.00 RMload <NetSurf$Dir>.CallASWI
diff --git a/!NetSurf/Resources/CSS,0cc b/!NetSurf/Resources/CSS,f79
index 9bdc141d8..9bdc141d8 100644
--- a/!NetSurf/Resources/CSS,0cc
+++ b/!NetSurf/Resources/CSS,f79
diff --git a/content/content.h b/content/content.h
index ff0dbc6dd..e65f62fb1 100644
--- a/content/content.h
+++ b/content/content.h
@@ -1,5 +1,5 @@
/**
- * $Id: content.h,v 1.5 2003/04/06 18:09:34 bursa Exp $
+ * $Id: content.h,v 1.6 2003/04/09 21:57:09 bursa Exp $
*/
#ifndef _NETSURF_DESKTOP_CONTENT_H_
@@ -26,8 +26,14 @@
* the content may be removed from the memory cache.
*/
-typedef enum {CONTENT_HTML, CONTENT_TEXTPLAIN, CONTENT_JPEG, CONTENT_CSS,
- CONTENT_PNG, CONTENT_OTHER} content_type;
+typedef enum {
+ CONTENT_HTML,
+ CONTENT_TEXTPLAIN,
+ CONTENT_JPEG,
+ CONTENT_CSS,
+ CONTENT_PNG,
+ CONTENT_OTHER
+} content_type;
struct box_position
{
@@ -72,6 +78,7 @@ struct content
{
struct css_stylesheet *css;
unsigned int import_count;
+ char **import_url;
struct content **import_content;
} css;
diff --git a/content/fetch.c b/content/fetch.c
index 9314bedeb..d1c3f0e07 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -1,5 +1,5 @@
/**
- * $Id: fetch.c,v 1.3 2003/03/15 15:53:20 bursa Exp $
+ * $Id: fetch.c,v 1.4 2003/04/09 21:57:09 bursa Exp $
*/
#include <assert.h>
@@ -21,12 +21,14 @@ struct fetch
char *url;
char error_buffer[CURL_ERROR_SIZE];
void *p;
+ struct curl_slist *headers;
};
static const char * const user_agent = "NetSurf";
static CURLM * curl_multi;
static size_t fetch_curl_data(void * data, size_t size, size_t nmemb, struct fetch *f);
+static size_t fetch_curl_header(void *data, size_t size, size_t nmemb, struct fetch *f);
/**
@@ -102,12 +104,24 @@ struct fetch * fetch_start(char *url, char *referer,
assert(code == CURLE_OK);
code = curl_easy_setopt(fetch->curl_handle, CURLOPT_WRITEDATA, fetch);
assert(code == CURLE_OK);
+/* code = curl_easy_setopt(fetch->curl_handle, CURLOPT_HEADERFUNCTION, fetch_curl_header);
+ assert(code == CURLE_OK);
+ code = curl_easy_setopt(fetch->curl_handle, CURLOPT_WRITEHEADER, fetch);
+ assert(code == CURLE_OK);*/
code = curl_easy_setopt(fetch->curl_handle, CURLOPT_USERAGENT, user_agent);
assert(code == CURLE_OK);
if (referer != 0) {
code = curl_easy_setopt(fetch->curl_handle, CURLOPT_REFERER, referer);
assert(code == CURLE_OK);
- }
+ }
+
+ /* custom request headers */
+ fetch->headers = 0;
+ /* remove curl default headers */
+ fetch->headers = curl_slist_append(fetch->headers, "Accept:");
+ fetch->headers = curl_slist_append(fetch->headers, "Pragma:");
+ code = curl_easy_setopt(fetch->curl_handle, CURLOPT_HTTPHEADER, fetch->headers);
+ assert(code == CURLE_OK);
/* add to the global curl multi handle */
codem = curl_multi_add_handle(curl_multi, fetch->curl_handle);
@@ -138,6 +152,7 @@ void fetch_abort(struct fetch *f)
codem = curl_multi_remove_handle(curl_multi, f->curl_handle);
assert(codem == CURLM_OK);
curl_easy_cleanup(f->curl_handle);
+ curl_slist_free_all(f->headers);
xfree(f->url);
xfree(f);
@@ -242,6 +257,18 @@ size_t fetch_curl_data(void * data, size_t size, size_t nmemb, struct fetch *f)
/**
+ * fetch_curl_header -- callback function for headers
+ */
+
+size_t fetch_curl_header(void *data, size_t size, size_t nmemb, struct fetch *f)
+{
+ LOG(("header '%*s'", size * nmemb, data));
+ return size * nmemb;
+}
+
+
+
+/**
* testing framework
*/
diff --git a/content/fetchcache.c b/content/fetchcache.c
index 9adaee544..8aa81f66f 100644
--- a/content/fetchcache.c
+++ b/content/fetchcache.c
@@ -1,5 +1,5 @@
/**
- * $Id: fetchcache.c,v 1.6 2003/04/06 18:09:34 bursa Exp $
+ * $Id: fetchcache.c,v 1.7 2003/04/09 21:57:09 bursa Exp $
*/
#include <assert.h>
@@ -19,6 +19,7 @@ struct fetchcache {
struct content *c;
unsigned long width, height;
unsigned long size;
+ content_type allowed;
};
@@ -29,16 +30,22 @@ static void status_callback(void *p, const char *status);
void fetchcache(const char *url, char *referer,
void (*callback)(fetchcache_msg msg, struct content *c, void *p, const char *error),
- void *p, unsigned long width, unsigned long height)
+ void *p, unsigned long width, unsigned long height, content_type allowed)
{
struct content *c;
struct fetchcache *fc;
c = cache_get(url);
if (c != 0) {
- callback(FETCHCACHE_STATUS, c, p, "Found in cache");
- content_revive(c, width, height);
- callback(FETCHCACHE_OK, c, p, 0);
+ /* check type is allowed */
+ if ((1 << c->type) & allowed) {
+ callback(FETCHCACHE_STATUS, c, p, "Found in cache");
+ content_revive(c, width, height);
+ callback(FETCHCACHE_OK, c, p, 0);
+ } else {
+ callback(FETCHCACHE_BADTYPE, 0, p, "");
+ cache_free(c);
+ }
return;
}
@@ -51,6 +58,7 @@ void fetchcache(const char *url, char *referer,
fc->width = width;
fc->height = height;
fc->size = 0;
+ fc->allowed = allowed;
fc->f = fetch_start(fc->url, referer, fetchcache_callback, fc);
}
@@ -76,14 +84,14 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size)
*semic = 0; /* remove "; charset=..." */
type = content_lookup(mime_type);
LOG(("FETCH_TYPE, type %u", type));
- if (type == CONTENT_OTHER) {
- fetch_abort(fc->f);
- fc->callback(FETCHCACHE_BADTYPE, 0, fc->p, mime_type);
- free(fc);
- } else {
+ if ((1 << type) & fc->allowed) {
fc->c = content_create(type, fc->url);
fc->c->status_callback = status_callback;
fc->c->status_p = fc;
+ } else {
+ fetch_abort(fc->f);
+ fc->callback(FETCHCACHE_BADTYPE, 0, fc->p, mime_type);
+ free(fc);
}
free(mime_type);
break;
diff --git a/content/fetchcache.h b/content/fetchcache.h
index d8986002a..9241ddf0f 100644
--- a/content/fetchcache.h
+++ b/content/fetchcache.h
@@ -1,5 +1,5 @@
/**
- * $Id: fetchcache.h,v 1.3 2003/03/04 11:59:35 bursa Exp $
+ * $Id: fetchcache.h,v 1.4 2003/04/09 21:57:09 bursa Exp $
*/
#ifndef _NETSURF_DESKTOP_FETCHCACHE_H_
@@ -11,6 +11,6 @@ typedef enum {FETCHCACHE_OK, FETCHCACHE_BADTYPE, FETCHCACHE_ERROR, FETCHCACHE_ST
void fetchcache(const char *url, char *referer,
void (*callback)(fetchcache_msg msg, struct content *c, void *p, const char *error),
- void *p, unsigned long width, unsigned long height);
+ void *p, unsigned long width, unsigned long height, content_type allowed);
#endif
diff --git a/css/css.c b/css/css.c
index 490add5b7..d348ad0f3 100644
--- a/css/css.c
+++ b/css/css.c
@@ -1,5 +1,5 @@
/**
- * $Id: css.c,v 1.5 2003/04/06 18:09:34 bursa Exp $
+ * $Id: css.c,v 1.6 2003/04/09 21:57:09 bursa Exp $
*/
#include <assert.h>
@@ -94,6 +94,7 @@ void css_create(struct content *c)
for (i = 0; i != HASH_SIZE; i++)
c->data.css.css->rule[i] = 0;
c->data.css.import_count = 0;
+ c->data.css.import_url = xcalloc(0, sizeof(*c->data.css.import_url));
c->data.css.import_content = xcalloc(0, sizeof(*c->data.css.import_content));
c->active = 0;
}
@@ -140,6 +141,21 @@ int css_convert(struct content *c, unsigned int width, unsigned int height)
void css_revive(struct content *c, unsigned int width, unsigned int height)
{
+ unsigned int i;
+ struct fetch_data *fetch_data;
+ /* imported stylesheets */
+ for (i = 0; i != c->data.css.import_count; i++) {
+ fetch_data = xcalloc(1, sizeof(*fetch_data));
+ fetch_data->c = c;
+ fetch_data->i = i;
+ c->active++;
+ fetchcache(c->data.css.import_url[i], c->url, css_atimport_callback,
+ fetch_data, c->width, c->height, 1 << CONTENT_CSS);
+ }
+ while (c->active != 0) {
+ fetch_poll();
+ gui_multitask();
+ }
}
@@ -162,8 +178,11 @@ void css_destroy(struct content *c)
/* imported stylesheets */
for (i = 0; i != c->data.css.import_count; i++)
- if (c->data.css.import_content[i] != 0)
+ if (c->data.css.import_content[i] != 0) {
+ free(c->data.css.import_url[i]);
cache_free(c->data.css.import_content[i]);
+ }
+ xfree(c->data.css.import_url);
xfree(c->data.css.import_content);
}
@@ -268,15 +287,18 @@ void css_atimport(struct content *c, struct node *node)
/* start the fetch */
c->data.css.import_count++;
+ c->data.css.import_url = xrealloc(c->data.css.import_url,
+ c->data.css.import_count * sizeof(*c->data.css.import_url));
c->data.css.import_content = xrealloc(c->data.css.import_content,
c->data.css.import_count * sizeof(*c->data.css.import_content));
fetch_data = xcalloc(1, sizeof(*fetch_data));
fetch_data->c = c;
fetch_data->i = c->data.css.import_count - 1;
+ c->data.css.import_url[fetch_data->i] = url_join(url, c->url);
c->active++;
- fetchcache(url_join(url, c->url), c->url, css_atimport_callback,
- fetch_data, c->width, c->height);
+ fetchcache(c->data.css.import_url[fetch_data->i], c->url, css_atimport_callback,
+ fetch_data, c->width, c->height, 1 << CONTENT_CSS);
free(url);
}
diff --git a/desktop/browser.c b/desktop/browser.c
index fdfdb3eae..583949fc0 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1,5 +1,5 @@
/**
- * $Id: browser.c,v 1.31 2003/04/05 21:38:06 bursa Exp $
+ * $Id: browser.c,v 1.32 2003/04/09 21:57:09 bursa Exp $
*/
#include "netsurf/content/cache.h"
@@ -215,7 +215,9 @@ void browser_window_open_location_historical(struct browser_window* bw, const ch
browser_window_set_status(bw, "Opening page...");
bw->time0 = clock();
- fetchcache(url, 0, browser_window_callback, bw, gui_window_get_width(bw->window), 0);
+ fetchcache(url, 0, browser_window_callback, bw,
+ gui_window_get_width(bw->window), 0,
+ (1 << CONTENT_HTML) | (1 << CONTENT_TEXTPLAIN) | (1 << CONTENT_JPEG));
LOG(("end"));
}
diff --git a/render/html.c b/render/html.c
index 05af7af70..5105089be 100644
--- a/render/html.c
+++ b/render/html.c
@@ -1,5 +1,5 @@
/**
- * $Id: html.c,v 1.10 2003/04/06 20:56:40 bursa Exp $
+ * $Id: html.c,v 1.11 2003/04/09 21:57:09 bursa Exp $
*/
#include <assert.h>
@@ -96,8 +96,9 @@ int html_convert(struct content *c, unsigned int width, unsigned int height)
fetch_data->c = c;
fetch_data->i = i;
c->active++;
- fetchcache(c->data.html.stylesheet_url[i], c->url, html_convert_css_callback,
- fetch_data, width, height);
+ fetchcache(c->data.html.stylesheet_url[i], c->url,
+ html_convert_css_callback,
+ fetch_data, width, height, 1 << CONTENT_CSS);
}
while (c->active != 0) {
diff --git a/render/layout.c b/render/layout.c
index 8db380344..891d54f1f 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1,5 +1,5 @@
/**
- * $Id: layout.c,v 1.37 2003/04/04 15:19:31 bursa Exp $
+ * $Id: layout.c,v 1.38 2003/04/09 21:57:09 bursa Exp $
*/
#include <assert.h>
@@ -845,9 +845,37 @@ void calculate_table_widths(struct box *table)
for (j = 0; j != cell->columns; j++) {
min += col[i + j].min;
max += col[i + j].max;
+ }
+
+ /* use specified width if colspan == 1 */
+ if (col[i].type != COLUMN_WIDTH_FIXED &&
+ cell->style->width.width == CSS_WIDTH_LENGTH &&
+ cell->columns == 1) {
+ width = len(&cell->style->width.value.length,
+ cell->style);
+ col[i].type = COLUMN_WIDTH_FIXED;
+ if (min < width)
+ /* specified width greater than min => use it */
+ col[i].width = col[i].max = max = col[i].min = min = width;
+ else
+ /* specified width not big enough => use min */
+ col[i].width = col[i].max = max = min;
+ }
+
+ else if (col[i].type == COLUMN_WIDTH_UNKNOWN) {
+ if (cell->style->width.width == CSS_WIDTH_PERCENT) {
+ col[i].type = COLUMN_WIDTH_PERCENT;
+ col[i].width = cell->style->width.value.percent;
+ } else if (cell->style->width.width == CSS_WIDTH_AUTO) {
+ col[i].type = COLUMN_WIDTH_AUTO;
+ }
+ }
+
+ for (j = 0; j != cell->columns; j++) {
if (col[i + j].type != COLUMN_WIDTH_FIXED)
flexible_columns++;
}
+
/* distribute extra width to spanned columns */
if (min < cell->min_width) {
if (flexible_columns == 0) {
@@ -888,40 +916,16 @@ void calculate_table_widths(struct box *table)
col[i + j].max += extra;
}
}
-
- /* use specified width if colspan == 1 */
- if (col[i].type != COLUMN_WIDTH_FIXED &&
- cell->style->width.width == CSS_WIDTH_LENGTH &&
- cell->columns == 1) {
- width = len(&cell->style->width.value.length,
- cell->style);
- col[i].type = COLUMN_WIDTH_FIXED;
- if (min < width)
- /* specified width greater than min => use it */
- col[i].width = col[i].max = col[i].min = width;
- else
- /* specified width not big enough => use min */
- col[i].width = col[i].max = min;
- }
-
- else if (col[i].type == COLUMN_WIDTH_UNKNOWN) {
- if (cell->style->width.width == CSS_WIDTH_PERCENT) {
- col[i].type = COLUMN_WIDTH_PERCENT;
- col[i].width = cell->style->width.value.percent;
- } else if (cell->style->width.width == CSS_WIDTH_AUTO) {
- col[i].type = COLUMN_WIDTH_AUTO;
- }
- }
}
}
}
for (i = 0; i < table->columns; i++) {
+ LOG(("col %u, type %i, min %lu, max %lu, width %lu",
+ i, col[i].type, col[i].min, col[i].max, col[i].width));
assert(col[i].min <= col[i].max);
min_width += col[i].min;
max_width += col[i].max;
- LOG(("col %u, type %i, min %lu, max %lu, width %lu",
- i, col[i].type, col[i].min, col[i].max, col[i].width));
}
table->min_width = min_width;
table->max_width = max_width;
diff --git a/riscos/filetype.c b/riscos/filetype.c
index c69e5163c..81b0920e5 100644
--- a/riscos/filetype.c
+++ b/riscos/filetype.c
@@ -1,5 +1,5 @@
/**
- * $Id: filetype.c,v 1.2 2003/04/04 15:19:31 bursa Exp $
+ * $Id: filetype.c,v 1.3 2003/04/09 21:57:09 bursa Exp $
*/
#include <stdlib.h>
@@ -15,8 +15,8 @@ struct type_entry {
char mime_type[16];
};
static const struct type_entry type_map[] = {
- {0x0cc, "text/css"},
{0xc85, "image/jpeg"},
+ {0xf79, "text/css"},
{0xfaf, "text/html"},
{0xfff, "text/plain"},
};