r3140 bursa - in /trunk/netsurf: !NetSurf/Resources/en/Messages content/content.c content/content.h content/fetchcache.c desktop/browser.c desktop/browser.h render/html.c
by netsurf@semichrome.net
Author: bursa
Date: Sat Jan 13 00:21:15 2007
New Revision: 3140
URL: http://svn.semichrome.net?rev=3140&view=rev
Log:
Fix parsing error when an empty HTML data is returned. Add HTTP status and other information to status bar.
Modified:
trunk/netsurf/!NetSurf/Resources/en/Messages
trunk/netsurf/content/content.c
trunk/netsurf/content/content.h
trunk/netsurf/content/fetchcache.c
trunk/netsurf/desktop/browser.c
trunk/netsurf/desktop/browser.h
trunk/netsurf/render/html.c
Modified: trunk/netsurf/!NetSurf/Resources/en/Messages
URL: http://svn.semichrome.net/trunk/netsurf/%21NetSurf/Resources/en/Messages?...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/en/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/en/Messages Sat Jan 13 00:21:15 2007
@@ -450,11 +450,7 @@
Redirecting:Redirecting...
Processing:Processing document
Formatting:Formatting document
-FetchObjs:Loading %u %s
-FetchObjs2:Loading %u %s: %s
Done:Document done
-FetchStyle:Loading %u %s
-FetchStyle2:Loading %u %s: %s
# Fetch warning/error messages - displayed in status bar
#
@@ -471,6 +467,47 @@
MNGError:MNG library error.
BadSprite:Invalid or corrupt Sprite data.
+# HTTP status codes
+#
+HTTP0:OK
+HTTP200:OK
+HTTP201:Created
+HTTP202:Accepted
+HTTP203:Non-authoritative information
+HTTP204:No content
+HTTP205:Reset content
+HTTP206:Partial content
+HTTP300:Multiple choices
+HTTP301:Moved permanently
+HTTP302:Found
+HTTP303:See other
+HTTP304:Not modified
+HTTP305:Use proxy
+HTTP307:Temporary redirect
+HTTP400:Bad request
+HTTP401:Unauthorized
+HTTP402:Payment required
+HTTP403:Forbidden
+HTTP404:Not found
+HTTP405:Method not allowed
+HTTP406:Not acceptable
+HTTP407:Proxy authentication required
+HTTP408:Request timeout
+HTTP409:Conflict
+HTTP410:Gone
+HTTP411:Length required
+HTTP412:Precondition failed
+HTTP413:Request entity too large
+HTTP414:Request-URI too long
+HTTP415:Unsupported media type
+HTTP416:Requested range not satisfiable
+HTTP417:Expectation failed
+HTTP500:Internal server error
+HTTP501:Not implemented
+HTTP502:Bad gateway
+HTTP503:Service unavailable
+HTTP504:Gateway timeout
+HTTP505:HTTP version not supported
# User interface
# ==============
Modified: trunk/netsurf/content/content.c
URL: http://svn.semichrome.net/trunk/netsurf/content/content.c?rev=3140&r1=313...
==============================================================================
--- trunk/netsurf/content/content.c (original)
+++ trunk/netsurf/content/content.c Sat Jan 13 00:21:15 2007
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2005 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2005-2007 James Bursa <bursa(a)users.sourceforge.net>
*/
/** \file
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
#include "netsurf/content/fetch.h"
@@ -304,6 +305,7 @@
#define HANDLER_MAP_COUNT (sizeof(handler_map) / sizeof(handler_map[0]))
+static void content_update_status(struct content *c);
static void content_destroy(struct content *c);
static void content_stop_check(struct content *c);
@@ -373,6 +375,7 @@
c->refresh = 0;
c->bitmap = 0;
c->fresh = false;
+ c->time = clock();
c->size = 0;
c->title = 0;
c->active = 0;
@@ -380,13 +383,14 @@
user_sentinel->p1 = user_sentinel->p2 = 0;
user_sentinel->next = 0;
c->user_list = user_sentinel;
- content_set_status(c, messages_get("Loading"));
+ c->sub_status[0] = 0;
c->locked = false;
c->fetch = 0;
c->source_data = 0;
c->source_size = 0;
c->source_allocated = 0;
c->total_size = 0;
+ c->http_code = 0;
c->no_error_pages = false;
c->download = false;
c->error_count = 0;
@@ -399,6 +403,8 @@
c->cache_data->no_cache = false;
c->cache_data->etag = 0;
c->cache_data->last_modified = 0;
+
+ content_set_status(c, messages_get("Loading"));
c->prev = 0;
c->next = content_list;
@@ -592,11 +598,38 @@
int len;
va_start(ap, status_message);
- if ((len = vsnprintf(c->status_message, sizeof (c->status_message),
+ if ((len = vsnprintf(c->sub_status, sizeof (c->sub_status),
status_message, ap)) < 0 ||
- (int)sizeof (c->status_message) <= len)
- c->status_message[sizeof (c->status_message) - 1] = '\0';
+ (int)sizeof (c->sub_status) <= len)
+ c->sub_status[sizeof (c->sub_status) - 1] = '\0';
va_end(ap);
+
+ content_update_status(c);
+}
+
+
+void content_update_status(struct content *c)
+{
+ char token[20];
+ const char *status;
+ clock_t time;
+
+ snprintf(token, sizeof token, "HTTP%li", c->http_code);
+ status = messages_get(token);
+ if (status == token)
+ status = token + 4;
+
+ if (c->status == CONTENT_STATUS_TYPE_UNKNOWN ||
+ c->status == CONTENT_STATUS_LOADING ||
+ c->status == CONTENT_STATUS_READY)
+ time = clock() - c->time;
+ else
+ time = c->time;
+
+ snprintf(c->status_message, sizeof (c->status_message),
+ "%s (%.1fs) %s", status,
+ (float) time / CLOCKS_PER_SEC, c->sub_status);
+ /* LOG(("%s", c->status_message)); */
}
@@ -704,7 +737,22 @@
c->status == CONTENT_STATUS_DONE);
content_broadcast(c, CONTENT_MSG_READY, msg_data);
if (c->status == CONTENT_STATUS_DONE)
- content_broadcast(c, CONTENT_MSG_DONE, msg_data);
+ content_set_done(c);
+}
+
+
+/**
+ * Put a content in status CONTENT_STATUS_DONE.
+ */
+
+void content_set_done(struct content *c)
+{
+ union content_msg_data msg_data;
+
+ c->status = CONTENT_STATUS_DONE;
+ c->time = clock() - c->time;
+ content_update_status(c);
+ content_broadcast(c, CONTENT_MSG_DONE, msg_data);
}
Modified: trunk/netsurf/content/content.h
URL: http://svn.semichrome.net/trunk/netsurf/content/content.h?rev=3140&r1=313...
==============================================================================
--- trunk/netsurf/content/content.h (original)
+++ trunk/netsurf/content/content.h Sat Jan 13 00:21:15 2007
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2005 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2005-2007 James Bursa <bursa(a)users.sourceforge.net>
* Copyright 2003 Philip Pemberton <philpem(a)users.sourceforge.net>
*/
@@ -16,6 +16,7 @@
#define _NETSURF_DESKTOP_CONTENT_H_
#include <stdint.h>
+#include <time.h>
#include "netsurf/utils/config.h"
#include "netsurf/content/content_type.h"
#include "netsurf/css/css.h"
@@ -178,6 +179,9 @@
* shared between users. */
bool fresh;
struct cache_data *cache_data; /**< Cache control data */
+ clock_t time; /**< Creation time, if TYPE_UNKNOWN,
+ LOADING or READY,
+ otherwise total time. */
unsigned int size; /**< Estimated size of all data
associated with this content, except
@@ -186,7 +190,8 @@
unsigned int active; /**< Number of child fetches or
conversions currently in progress. */
struct content_user *user_list; /**< List of users. */
- char status_message[80]; /**< Text for status bar. */
+ char status_message[120]; /**< Full text for status bar. */
+ char sub_status[80]; /**< Status of content. */
/** Content is being processed: data structures may be inconsistent
* and content must not be redrawn or modified. */
bool locked;
@@ -196,6 +201,7 @@
unsigned long source_size; /**< Amount of data fetched so far. */
unsigned long source_allocated; /**< Amount of space allocated so far. */
unsigned long total_size; /**< Total data size, 0 if unknown. */
+ long http_code; /**< HTTP status code, 0 if not HTTP. */
bool no_error_pages; /**< Used by fetchcache(). */
bool download; /**< Used by fetchcache(). */
@@ -226,6 +232,7 @@
bool content_process_data(struct content *c, const char *data,
unsigned int size);
void content_convert(struct content *c, int width, int height);
+void content_set_done(struct content *c);
void content_reformat(struct content *c, int width, int height);
void content_clean(void);
void content_reset(struct content *c);
Modified: trunk/netsurf/content/fetchcache.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetchcache.c?rev=3140&r1=...
==============================================================================
--- trunk/netsurf/content/fetchcache.c (original)
+++ trunk/netsurf/content/fetchcache.c Sat Jan 13 00:21:15 2007
@@ -376,6 +376,7 @@
switch (msg) {
case FETCH_TYPE:
c->total_size = size;
+ c->http_code = fetch_http_code(c->fetch);
mime_type = fetchcache_parse_type(data, ¶ms);
if (!mime_type) {
msg_data.error = messages_get("NoMemory");
Modified: trunk/netsurf/desktop/browser.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/browser.c?rev=3140&r1=313...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Sat Jan 13 00:21:15 2007
@@ -20,7 +20,6 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
#include "curl/curl.h"
#include "netsurf/utils/config.h"
#include "netsurf/content/fetch.h"
@@ -286,7 +285,6 @@
browser_window_set_status(bw, messages_get("Loading"));
bw->history_add = history_add;
- bw->time0 = clock();
c = fetchcache(url2, browser_window_callback, (intptr_t) bw, 0,
width, height, false,
post_urlenc, post_multipart, true, download);
@@ -347,6 +345,7 @@
url[sizeof url - 1] = 0;
gui_window_set_url(bw->window, url);
bw->refresh_interval = -1;
+ browser_window_set_status(bw, c->status_message);
}
break;
@@ -414,10 +413,7 @@
assert(bw->current_content == c);
browser_window_update(bw, false);
- sprintf(status, messages_get("Complete"),
- ((float) (clock() - bw->time0)) /
- CLOCKS_PER_SEC);
- browser_window_set_status(bw, status);
+ browser_window_set_status(bw, c->status_message);
browser_window_stop_throbber(bw);
history_update(bw->history, c);
hotlist_visited(c);
Modified: trunk/netsurf/desktop/browser.h
URL: http://svn.semichrome.net/trunk/netsurf/desktop/browser.h?rev=3140&r1=313...
==============================================================================
--- trunk/netsurf/desktop/browser.h (original)
+++ trunk/netsurf/desktop/browser.h Sat Jan 13 00:21:15 2007
@@ -74,8 +74,6 @@
bool throbbing;
/** Add loading_content to the window history when it loads. */
bool history_add;
- /** Start time of fetching loading_content. */
- clock_t time0;
/** Fragment identifier for current_content. */
char *frag_id;
Modified: trunk/netsurf/render/html.c
URL: http://svn.semichrome.net/trunk/netsurf/render/html.c?rev=3140&r1=3139&r2...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Sat Jan 13 00:21:15 2007
@@ -55,6 +55,20 @@
static void html_object_refresh(void *p);
static void html_destroy_frameset(struct content_html_frames *frameset);
static void html_destroy_iframe(struct content_html_iframe *iframe);
+static void html_set_status(struct content *c, const char *extra);
+
+static const char empty_document[] =
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\""
+ " \"http://www.w3.org/TR/html4/strict.dtd\">"
+ "<html>"
+ "<head>"
+ "<title>Empty document</title>"
+ "</head>"
+ "<body>"
+ "<h1>Empty document</h1>"
+ "<p>The document sent by the server is empty.</p>"
+ "</body>"
+ "</html>";
/**
@@ -264,11 +278,15 @@
union content_msg_data msg_data;
/* finish parsing */
+ if (c->source_size == 0)
+ htmlParseChunk(c->data.html.parser, empty_document,
+ sizeof empty_document, 0);
htmlParseChunk(c->data.html.parser, "", 0, 1);
document = c->data.html.parser->myDoc;
/*xmlDebugDumpDocument(stderr, c->data.html.parser->myDoc);*/
htmlFreeParserCtxt(c->data.html.parser);
c->data.html.parser = 0;
+
if (!document) {
LOG(("Parsing failed"));
msg_data.error = messages_get("ParsingFail");
@@ -353,135 +371,21 @@
xmlFreeDoc(document);
/* layout the box tree */
- content_set_status(c, messages_get("Formatting"));
+ html_set_status(c, messages_get("Formatting"));
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
LOG(("Layout document"));
html_reformat(c, width, height);
/*box_dump(c->data.html.layout->children, 0);*/
- if (c->active == 0) {
+ if (c->active == 0)
c->status = CONTENT_STATUS_DONE;
- content_set_status(c, messages_get("Done"));
- } else {
+ else
c->status = CONTENT_STATUS_READY;
- content_set_status(c, messages_get("FetchObjs"), c->active,
- messages_get((c->active == 1) ? "obj" : "objs"));
- }
+ html_set_status(c, "");
return true;
}
-/**
- * Search for meta refresh
- *
- * http://wp.netscape.com/assist/net_sites/pushpull.html
- *
- * \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);
-
- if (url == end) {
- /* Just delay specified, so refresh current page */
- xmlFree(content);
-
- c->refresh = talloc_strdup(c, c->url);
- 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;
- }
-
- for ( ; url <= end - 4; url++) {
- if (!strncasecmp(url, "url=", 4))
- break;
- }
-
- /* mail.google.com sends out the broken format "<n>, url='<url>'", so
- * special case this */
- if (url <= end - 4) {
- if ((url[4] == '\'') && (end[-1] == '\'')) {
- *--end = '\0';
- url++;
- }
- }
-
- 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>.
@@ -549,6 +453,119 @@
}
}
}
+ return true;
+}
+
+
+/**
+ * Search for meta refresh
+ *
+ * http://wp.netscape.com/assist/net_sites/pushpull.html
+ *
+ * \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);
+
+ if (url == end) {
+ /* Just delay specified, so refresh current page */
+ xmlFree(content);
+
+ c->refresh = talloc_strdup(c, c->url);
+ 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;
+ }
+
+ for ( ; url <= end - 4; url++) {
+ if (!strncasecmp(url, "url=", 4))
+ break;
+ }
+
+ /* mail.google.com sends out the broken format "<n>, url='<url>'", so
+ * special case this */
+ if (url <= end - 4) {
+ if ((url[4] == '\'') && (end[-1] == '\'')) {
+ *--end = '\0';
+ url++;
+ }
+ }
+
+ 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;
}
@@ -762,9 +779,7 @@
/* complete the fetches */
while (c->active != 0) {
if (c->active != last_active) {
- content_set_status(c, messages_get("FetchStyle"),
- c->active,
- messages_get((c->active == 1) ? "styl" : "styls"));
+ html_set_status(c, "");
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
last_active = c->active;
}
@@ -820,7 +835,7 @@
c->data.html.stylesheet_content[i] = 0;
c->active--;
content_add_error(c, "NotCSS", 0);
- content_set_status(c, messages_get("NotCSS"));
+ html_set_status(c, messages_get("NotCSS"));
content_broadcast(c, CONTENT_MSG_STATUS, data);
content_remove_user(css,
html_convert_css_callback,
@@ -854,10 +869,7 @@
break;
case CONTENT_MSG_STATUS:
- content_set_status(c, messages_get("FetchStyle2"),
- c->active,
- messages_get((c->active == 1) ? "styl" : "styls"),
- css->status_message);
+ html_set_status(c, css->status_message);
content_broadcast(c, CONTENT_MSG_STATUS, data);
break;
@@ -1063,7 +1075,7 @@
c->data.html.object[i].content = 0;
c->active--;
content_add_error(c, "?", 0);
- content_set_status(c, messages_get("BadObject"));
+ html_set_status(c, messages_get("BadObject"));
content_broadcast(c, CONTENT_MSG_STATUS, data);
content_remove_user(object, html_object_callback,
(intptr_t) c, i);
@@ -1094,18 +1106,14 @@
c->data.html.object[i].content = 0;
c->active--;
content_add_error(c, "?", 0);
- content_set_status(c, messages_get("ObjError"),
- data.error);
+ html_set_status(c, data.error);
content_broadcast(c, CONTENT_MSG_STATUS, data);
html_object_failed(box, c,
c->data.html.object[i].background);
break;
case CONTENT_MSG_STATUS:
- content_set_status(c, messages_get("FetchObjs2"),
- c->active,
- messages_get((c->active == 1) ? "obj" : "objs"),
- object->status_message);
+ html_set_status(c, object->status_message);
/* content_broadcast(c, CONTENT_MSG_STATUS, 0); */
break;
@@ -1202,13 +1210,11 @@
msg == CONTENT_MSG_AUTH)) {
/* all objects have arrived */
content_reformat(c, c->available_width, c->height);
- c->status = CONTENT_STATUS_DONE;
- content_set_status(c, messages_get("Done"));
- content_broadcast(c, CONTENT_MSG_DONE, data);
+ html_set_status(c, "");
+ content_set_done(c);
}
if (c->status == CONTENT_STATUS_READY)
- content_set_status(c, messages_get("FetchObjs"), c->active,
- messages_get((c->active == 1) ? "obj" : "objs"));
+ html_set_status(c, "");
}
@@ -1537,6 +1543,30 @@
/**
+ * Set the content status.
+ */
+
+void html_set_status(struct content *c, const char *extra)
+{
+ unsigned int stylesheets = 0, objects = 0;
+ if (c->data.html.object_count == 0)
+ stylesheets = c->data.html.stylesheet_count - c->active;
+ else {
+ stylesheets = c->data.html.stylesheet_count;
+ objects = c->data.html.object_count - c->active;
+ }
+ content_set_status(c, "%u/%u %s %u/%u %s %s",
+ stylesheets, c->data.html.stylesheet_count,
+ messages_get((c->data.html.stylesheet_count == 1) ?
+ "styl" : "styls"),
+ objects, c->data.html.object_count,
+ messages_get((c->data.html.object_count == 1) ?
+ "obj" : "objs"),
+ extra);
+}
+
+
+/**
* Handle a window containing a CONTENT_HTML being opened.
*/
16 years, 4 months
r3139 bursa - in /trunk/netsurf/content: fetch.c fetch.h
by netsurf@semichrome.net
Author: bursa
Date: Sat Jan 13 00:19:02 2007
New Revision: 3139
URL: http://svn.semichrome.net?rev=3139&view=rev
Log:
Add fetch_http_code() to retrieve the HTTP status code of a fetch.
Modified:
trunk/netsurf/content/fetch.c
trunk/netsurf/content/fetch.h
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3139&r1=3138&...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Sat Jan 13 00:19:02 2007
@@ -1,7 +1,7 @@
/*
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
- * http://www.opensource.org/licenses/gpl-license
+ * http://www.opensource.org/licenses/gpl-license
* Copyright 2006 Daniel Silverstone <dsilvers(a)digital-scurf.org>
* Copyright 2004 James Bursa <bursa(a)users.sourceforge.net>
* Copyright 2003 Phil Mellor <monkeyson(a)users.sourceforge.net>
@@ -72,9 +72,9 @@
char *host; /**< Host part of URL. */
char *location; /**< Response Location header, or 0. */
unsigned long content_length; /**< Response Content-Length, or 0. */
- long http_code; /**< HTTP response code, or 0. */
+ long http_code; /**< HTTP response code, or 0. */
char *cookie_string; /**< Cookie string for this fetch */
- char *realm; /**< HTTP Auth Realm */
+ char *realm; /**< HTTP Auth Realm */
char *post_urlenc; /**< Url encoded POST string, or 0. */
struct curl_httppost *post_multipart; /**< Multipart post data, or 0. */
struct cache_data cachedata; /**< Cache control data */
@@ -90,7 +90,7 @@
struct cache_handle {
CURL *handle; /**< The cached cURL handle */
- char *host; /**< The host for which this handle is cached */
+ char *host; /**< The host for which this handle is cached */
struct cache_handle *r_prev; /**< Previous cached handle in ring. */
struct cache_handle *r_next; /**< Next cached handle in ring. */
@@ -101,7 +101,7 @@
/** Curl handle with default options set; not used for transfers. */
static CURL *fetch_blank_curl;
static struct fetch *fetch_ring = 0; /**< Ring of active fetches. */
-static struct fetch *queue_ring = 0; /**< Ring of queued fetches */
+static struct fetch *queue_ring = 0; /**< Ring of queued fetches */
static struct cache_handle *handle_ring = 0; /**< Ring of cached handles */
static char fetch_error_buffer[CURL_ERROR_SIZE]; /**< Error buffer for cURL. */
@@ -134,12 +134,12 @@
*/
#define RING_INSERT(ring,element) \
LOG(("RING_INSERT(%s, %p(%s))", #ring, element, element->host)); \
- if (ring) { \
+ if (ring) { \
element->r_next = ring; \
element->r_prev = ring->r_prev; \
ring->r_prev = element; \
element->r_prev->r_next = element; \
- } else \
+ } else \
ring = element->r_prev = element->r_next = element
/** Remove the given element from the specified ring.
@@ -1046,22 +1046,23 @@
size_t fetch_curl_data(void *data, size_t size, size_t nmemb,
struct fetch *f)
{
- /* ensure we only have to get this information once */
- if (!f->http_code)
- {
- CURLcode code;
- code = curl_easy_getinfo(f->curl_handle, CURLINFO_HTTP_CODE,
- &f->http_code);
- assert(code == CURLE_OK);
- }
-
- /* ignore body if this is a 401 reply by skipping it and reset
- the HTTP response code to enable follow up fetches */
- if (f->http_code == 401)
- {
- f->http_code = 0;
- return size * nmemb;
- }
+ CURLcode code;
+
+ /* ensure we only have to get this information once */
+ if (!f->http_code)
+ {
+ code = curl_easy_getinfo(f->curl_handle, CURLINFO_HTTP_CODE,
+ &f->http_code);
+ assert(code == CURLE_OK);
+ }
+
+ /* ignore body if this is a 401 reply by skipping it and reset
+ the HTTP response code to enable follow up fetches */
+ if (f->http_code == 401)
+ {
+ f->http_code = 0;
+ return size * nmemb;
+ }
LOG(("fetch %p, size %u", f, size * nmemb));
@@ -1247,8 +1248,13 @@
if (f->cachedata.res_time == 0)
f->cachedata.res_time = time(0);
- code = curl_easy_getinfo(f->curl_handle, CURLINFO_HTTP_CODE, &http_code);
- assert(code == CURLE_OK);
+ if (!f->http_code)
+ {
+ code = curl_easy_getinfo(f->curl_handle, CURLINFO_HTTP_CODE,
+ &f->http_code);
+ assert(code == CURLE_OK);
+ }
+ http_code = f->http_code;
LOG(("HTTP status code %li", http_code));
if (http_code == 304 && !f->post_urlenc && !f->post_multipart) {
@@ -1265,7 +1271,7 @@
return true;
}
- /* handle HTTP 401 (Authentication errors) */
+ /* handle HTTP 401 (Authentication errors) */
#ifdef WITH_AUTH
if (http_code == 401) {
f->callback(FETCH_AUTH, f->p, f->realm,0);
@@ -1439,6 +1445,16 @@
assert(fetch);
fetch->callback = callback;
fetch->p = p;
+}
+
+
+/**
+ * Get the HTTP response code.
+ */
+
+long fetch_http_code(struct fetch *fetch)
+{
+ return fetch->http_code;
}
Modified: trunk/netsurf/content/fetch.h
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.h?rev=3139&r1=3138&...
==============================================================================
--- trunk/netsurf/content/fetch.h (original)
+++ trunk/netsurf/content/fetch.h Sat Jan 13 00:19:02 2007
@@ -82,5 +82,6 @@
void (*callback)(fetch_msg msg, void *p, const void *data,
unsigned long size),
void *p);
+long fetch_http_code(struct fetch *fetch);
#endif
16 years, 4 months
r3138 bursa - /trunk/netsurf/!NetSurf/Resources/CSS,f79
by netsurf@semichrome.net
Author: bursa
Date: Tue Jan 9 19:43:52 2007
New Revision: 3138
URL: http://svn.semichrome.net?rev=3138&view=rev
Log:
Remove form margin (broke centered forms and not needed).
Modified:
trunk/netsurf/!NetSurf/Resources/CSS,f79
Modified: trunk/netsurf/!NetSurf/Resources/CSS,f79
URL: http://svn.semichrome.net/trunk/netsurf/%21NetSurf/Resources/CSS%2Cf79?re...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/CSS,f79 (original)
+++ trunk/netsurf/!NetSurf/Resources/CSS,f79 Tue Jan 9 19:43:52 2007
@@ -148,7 +148,7 @@
iframe[align=left] { float: left; }
iframe[align=right] { float: right; }
-form { display: block; margin: 1.12em 0; }
+form { display: block; }
form > * { margin-left: inherit; margin-right: inherit; }
input { background-color: #fff; color: #000; width: 10em;
16 years, 4 months
r3137 tlsa - /trunk/netsurf/!NetSurf/Resources/CSS,f79
by netsurf@semichrome.net
Author: tlsa
Date: Tue Jan 9 18:14:22 2007
New Revision: 3137
URL: http://svn.semichrome.net?rev=3137&view=rev
Log:
Change nested list style.
Modified:
trunk/netsurf/!NetSurf/Resources/CSS,f79
Modified: trunk/netsurf/!NetSurf/Resources/CSS,f79
URL: http://svn.semichrome.net/trunk/netsurf/%21NetSurf/Resources/CSS%2Cf79?re...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/CSS,f79 (original)
+++ trunk/netsurf/!NetSurf/Resources/CSS,f79 Tue Jan 9 18:14:22 2007
@@ -62,7 +62,7 @@
ul ul { list-style-type: circle; }
ul ul ul { list-style-type: square; }
-ol ul, ul ol, ul ul, ol ol { margin-top: 0; margin: 1.12em 0; }
+ol ul, ul ol, ul ul, ol ol { margin-top: 0; margin-bottom: 0; }
dl { display: block; padding-left: 1.5em; margin: 1em; }
dt { display: block; font-weight: bold; }
16 years, 4 months
r3136 rjw - /trunk/netsurf/!NetSurf/Resources/CSS,f79
by netsurf@semichrome.net
Author: rjw
Date: Sat Jan 6 16:11:51 2007
New Revision: 3136
URL: http://svn.semichrome.net?rev=3136&view=rev
Log:
Make default CSS rules closer to the w3c suggestions.
Modified:
trunk/netsurf/!NetSurf/Resources/CSS,f79
Modified: trunk/netsurf/!NetSurf/Resources/CSS,f79
URL: http://svn.semichrome.net/trunk/netsurf/%21NetSurf/Resources/CSS%2Cf79?re...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/CSS,f79 (original)
+++ trunk/netsurf/!NetSurf/Resources/CSS,f79 Sat Jan 6 16:11:51 2007
@@ -8,19 +8,19 @@
head { display: none; }
-body { display: block; padding: 5px; }
+body { display: block; padding: 8px; }
div { display: block; }
div[align=left] > * { margin-right: auto; }
div[align=center] > * { margin-left: auto; margin-right: auto; }
div[align=right] > * { margin-left: auto; }
-h1 { display: block; font-size: xx-large; font-weight: bold; margin: 0.58em 0; }
-h2 { display: block; font-size: x-large; margin: 0.69em 0; }
-h3 { display: block; font-size: large; font-weight: bold; margin: 0.83em 0; }
-h4 { display: block; font-size: medium; font-weight: bold; margin: 1em 0; }
-h5 { display: block; font-size: medium; font-style: italic; margin: 1em 0; }
-h6 { display: block; font-size: medium; font-style: italic; margin: 1em 0; }
+h1 { display: block; font-size: 2em; font-weight: bold; margin: .67em 0; }
+h2 { display: block; font-size: 1.5em; font-weight: bold; margin: .69em 0; }
+h3 { display: block; font-size: 1.17em; font-weight: bold; margin: .83em 0; }
+h4 { display: block; font-weight: bold; margin: 1.12em 0; }
+h5 { display: block; font-size: .83em; font-weight: bold; margin: 1.5em 0; }
+h6 { display: block; font-size: .75em; font-weight: bold; margin: 1.67em 0; }
address { display: block; font-style: italic; }
@@ -31,18 +31,18 @@
samp { font-family: monospace; }
kbd { font-family: monospace; font-weight: bold; }
var { font-style: italic; }
-cite { font-weight: bold; }
+cite { font-style: italic; }
abbr { font-variant: small-caps; }
acronym { font-variant: small-caps; }
-blockquote { display: block; margin: 1em; }
+blockquote { display: block; margin: 1.12em 40px;}
q { font-style: italic; }
-sub { vertical-align: sub; font-size: 0.8em; }
-sup { vertical-align: super; font-size: 0.8em; }
+sub { vertical-align: sub; font-size: .83em; }
+sup { vertical-align: super; font-size: .83em; }
-p { display: block; margin-top: 1em; margin-bottom: 1em; }
+p { display: block; margin: 1.12em 0; }
br[clear=left] { clear: left; }
br[clear=right] { clear: right; }
@@ -53,28 +53,30 @@
ins { color: green; text-decoration: underline; }
del { color: red; text-decoration: line-through; }
-ul { display: block; padding-left: 1.5em; margin-bottom: 1em;
+ul { display: block; padding-left: 1.5em; margin: 1.12em 0;
list-style-type: disc; }
-ol { display: block; padding-left: 1.5em; margin-bottom: 1em;
+ol { display: block; padding-left: 1.5em; margin: 1.12em 0;
list-style-type: decimal; }
-li { display: list-item; margin-bottom: 0.3em; }
+li { display: list-item; }
ul ul { list-style-type: circle; }
ul ul ul { list-style-type: square; }
-dl { display: block; padding-left: 0.5em; margin-bottom: 1em; }
+ol ul, ul ol, ul ul, ol ol { margin-top: 0; margin: 1.12em 0; }
+
+dl { display: block; padding-left: 1.5em; margin: 1em; }
dt { display: block; font-weight: bold; }
dd { display: block; padding-left: 1em; margin-bottom: 0.3em; }
-dir { display: block; padding-left: 0.5em; }
-menu { display: block; padding-left: 0.5em; }
+dir { display: block; padding-left: 1.5em; margin: 1.12em 0; }
+menu { display: block; padding-left: 1.5em; margin: 1.12em 0; }
table { display: table; border-spacing: 2px; }
table[align=left] { float: left; }
table[align=center] { margin-left: auto; margin-right: auto; text-align: left; }
table[align=right] { float: right; text-align: left; }
-caption { display: table-caption; }
+caption { display: table-caption; text-align: center; }
thead { display: table-header-group; vertical-align: middle; }
tfoot { display: table-footer-group; vertical-align: middle; }
@@ -120,8 +122,8 @@
tt { font-family: monospace; }
i { font-style: italic; }
b { font-weight: bold; }
-big { font-size: larger; }
-small { font-size: smaller; }
+big { font-size: 1.17em; }
+small { font-size: .83em; }
strike, s { text-decoration: line-through; }
u { text-decoration: underline; }
@@ -136,19 +138,17 @@
font[size="+1"] { font-size: larger; }
hr { display: block; background-color: #000; height: 1px;
- margin: 4px auto; border-top: medium #d9d9d9 ridge; }
+ margin: 4px auto; border: 1px #d9d9d9 inset; }
hr[align=left] { margin-left: 0; }
hr[align=right] { margin-right: 0; }
hr[noshade] { background-color: #888; height: 2px; border: none; }
-
-frameset { border: thin solid gray; border-collapse: collapse }
noframes { display: none; }
iframe[align=left] { float: left; }
iframe[align=right] { float: right; }
-form { display: block; }
+form { display: block; margin: 1.12em 0; }
form > * { margin-left: inherit; margin-right: inherit; }
input { background-color: #fff; color: #000; width: 10em;
@@ -179,7 +179,7 @@
border-width: 1px; border-color: #000; border-style: solid;
overflow: scroll; padding: 0 2px; }
-fieldset { display: block; border: thin solid #888; }
+fieldset { display: block; border: thin solid #888; margin: 1.12em 0; }
[align=left] { text-align: left; }
[align=center] { text-align: center; }
16 years, 5 months
r3135 rjw - /trunk/netsurf/render/box_construct.c
by netsurf@semichrome.net
Author: rjw
Date: Wed Jan 3 20:11:09 2007
New Revision: 3135
URL: http://svn.semichrome.net?rev=3135&view=rev
Log:
Don't require frames to specify a URL (fixes frame names not being recognised)
Modified:
trunk/netsurf/render/box_construct.c
Modified: trunk/netsurf/render/box_construct.c
URL: http://svn.semichrome.net/trunk/netsurf/render/box_construct.c?rev=3135&r...
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Wed Jan 3 20:11:09 2007
@@ -1745,32 +1745,24 @@
continue;
}
- /* get frame URL */
- if (!(s = (char *) xmlGetProp(c,
+ /* get frame URL (not required) */
+ url = NULL;
+ if ((s = (char *) xmlGetProp(c,
(const xmlChar *) "src"))) {
- c = c->next;
- continue;
- }
- if (!box_extract_link(s, content->data.html.base_url, &url)) {
+ box_extract_link(s, content->data.html.base_url, &url);
xmlFree(s);
- c = c->next;
- continue;
- }
- xmlFree(s);
- if (!url) {
- c = c->next;
- continue;
- }
-
- /* don't include ourself */
- if (strcmp(content->data.html.base_url, url) == 0) {
+ }
+
+ /* copy url */
+ if (url) {
+ /* no self-references */
+ if (strcmp(content->data.html.base_url, url))
+ frame->url = talloc_strdup(content, url);
free(url);
- c = c->next;
- continue;
- }
-
+ url = NULL;
+ }
+
/* fill in specified values */
- frame->url = talloc_strdup(content, url);
if ((s = (char *) xmlGetProp(c,
(const xmlChar *) "name"))) {
frame->name = talloc_strdup(content, s);
@@ -1811,8 +1803,7 @@
xmlFree(s);
}
- /* release temporary memory */
- free(url);
+ /* advance */
c = c->next;
}
}
16 years, 5 months
r3134 rjw - in /trunk/netsurf: desktop/browser.c desktop/frames.c riscos/gui.h riscos/window.c
by netsurf@semichrome.net
Author: rjw
Date: Wed Jan 3 15:15:54 2007
New Revision: 3134
URL: http://svn.semichrome.net?rev=3134&view=rev
Log:
Format frame content to correct initial size. Scale iframe co-ordinates.
Modified:
trunk/netsurf/desktop/browser.c
trunk/netsurf/desktop/frames.c
trunk/netsurf/riscos/gui.h
trunk/netsurf/riscos/window.c
Modified: trunk/netsurf/desktop/browser.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/browser.c?rev=3134&r1=313...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Wed Jan 3 15:15:54 2007
@@ -282,6 +282,7 @@
browser_window_destroy_children(bw);
gui_window_get_dimensions(bw->window, &width, &height, true);
+ LOG(("Loading '%s' width %i, height %i", url2, width, height));
browser_window_set_status(bw, messages_get("Loading"));
bw->history_add = history_add;
@@ -462,6 +463,9 @@
case CONTENT_MSG_REFORMAT:
if (c == bw->current_content &&
c->type == CONTENT_HTML) {
+ /* reposition frames */
+ if (c->data.html.frameset)
+ browser_window_recalculate_frameset(bw);
/* reflow iframe positions */
if (c->data.html.iframe)
browser_window_recalculate_iframes(bw);
@@ -922,8 +926,8 @@
content_reformat(c, width, height);
- if (c->type == CONTENT_HTML && c->data.html.frameset)
- browser_window_recalculate_frameset(bw);
+// if (c->type == CONTENT_HTML && c->data.html.frameset)
+// browser_window_recalculate_frameset(bw);
/* CONTENT_MSG_REFORMAT handles the repositioning of iframes */
// if (c->type == CONTENT_HTML && c->data.html.iframe)
Modified: trunk/netsurf/desktop/frames.c
URL: http://svn.semichrome.net/trunk/netsurf/desktop/frames.c?rev=3134&r1=3133...
==============================================================================
--- trunk/netsurf/desktop/frames.c (original)
+++ trunk/netsurf/desktop/frames.c Wed Jan 3 15:15:54 2007
@@ -149,11 +149,9 @@
struct content_html_frames *frame;
struct browser_window *window;
- /* we use a 3 stage approach such that the content is initially formatted to the
- * correct frameset dimensions */
assert(bw && frameset);
- /* create children */
+ /* 1. Create children */
assert(bw->children == NULL);
assert(frameset->cols + frameset->rows != 0);
@@ -195,16 +193,26 @@
/* gui window */
window->window = gui_create_browser_window(window, bw);
+ }
+ }
+
+ /* 2. Calculate dimensions */
+ gui_window_update_extent(bw->window);
+ browser_window_recalculate_frameset(bw);
+
+ /* 3. Recurse for grandchildren */
+ for (row = 0; row < bw->rows; row++) {
+ for (col = 0; col < bw->cols; col++) {
+ index = (row * bw->cols) + col;
+ frame = &frameset->children[index];
+ window = &bw->children[index];
+
if (frame->children)
browser_window_create_frameset(window, frame);
}
}
- /* calculate dimensions */
- gui_window_update_extent(bw->window);
- browser_window_recalculate_frameset(bw);
-
- /* launch content */
+ /* 4. Launch content */
for (row = 0; row < bw->rows; row++) {
for (col = 0; col < bw->cols; col++) {
index = (row * bw->cols) + col;
@@ -457,20 +465,20 @@
/* extend/shrink the box to the pointer */
if (width) {
- if (bw->drag_resize_left)
- bw_dimension = bw->x1 - x;
- else
- bw_dimension = x - bw->x0;
+ if (bw->drag_resize_left)
+ bw_dimension = bw->x1 - x;
+ else
+ bw_dimension = x - bw->x0;
bw_pixels = (bw->x1 - bw->x0);
sibling_pixels = (sibling->x1 - sibling->x0);
bw_d = &bw->frame_width;
sibling_d = &sibling->frame_width;
frame_size = bw->parent->x1 - bw->parent->x0;
} else {
- if (bw->drag_resize_up)
- bw_dimension = bw->y1 - y;
- else
- bw_dimension = y - bw->y0;
+ if (bw->drag_resize_up)
+ bw_dimension = bw->y1 - y;
+ else
+ bw_dimension = y - bw->y0;
bw_pixels = (bw->y1 - bw->y0);
sibling_pixels = (sibling->y1 - sibling->y0);
bw_d = &bw->frame_height;
@@ -489,11 +497,11 @@
/* our frame dimensions are now known to be:
*
- * <-- frame_size --> [VISIBLE PIXELS]
+ * <-- frame_size --> [VISIBLE PIXELS]
* |<-- bw_pixels -->|<-- sibling_pixels -->| [VISIBLE PIXELS, BEFORE RESIZE]
* |<-- bw_d->value-->|<-- sibling_d->value-->| [SPECIFIED UNITS, BEFORE RESIZE]
* |<--bw_dimension-->|<--sibling_dimension-->| [VISIBLE PIXELS, AFTER RESIZE]
- * |<-- total_new -->| [VISIBLE PIXELS, AFTER RESIZE]
+ * |<-- total_new -->| [VISIBLE PIXELS, AFTER RESIZE]
*
* when we resize, we must retain the original unit specification such that any
* subsequent resizing of the parent window will recalculate the page as the
@@ -515,27 +523,27 @@
* dimension.
*/
if (bw_d->unit == FRAME_DIMENSION_RELATIVE) {
- if ((sibling_pixels == 0) && (bw_dimension == 0))
- return false;
- if (sibling_d->value == 0)
- bw_d->value = 1;
- if (sibling_pixels == 0)
- sibling_d->value = (sibling_d->value * bw_pixels) / bw_dimension;
- else
- sibling_d->value =
- (sibling_d->value * sibling_dimension) / sibling_pixels;
+ if ((sibling_pixels == 0) && (bw_dimension == 0))
+ return false;
+ if (sibling_d->value == 0)
+ bw_d->value = 1;
+ if (sibling_pixels == 0)
+ sibling_d->value = (sibling_d->value * bw_pixels) / bw_dimension;
+ else
+ sibling_d->value =
+ (sibling_d->value * sibling_dimension) / sibling_pixels;
/* todo: the availble resize may have changed, update the drag box */
return true;
} else if (sibling_d->unit == FRAME_DIMENSION_RELATIVE) {
- if ((bw_pixels == 0) && (sibling_dimension == 0))
- return false;
- if (bw_d->value == 0)
- bw_d->value = 1;
- if (bw_pixels == 0)
- bw_d->value = (bw_d->value * sibling_pixels) / sibling_dimension;
- else
- bw_d->value = (bw_d->value * bw_dimension) / bw_pixels;
+ if ((bw_pixels == 0) && (sibling_dimension == 0))
+ return false;
+ if (bw_d->value == 0)
+ bw_d->value = 1;
+ if (bw_pixels == 0)
+ bw_d->value = (bw_d->value * sibling_pixels) / sibling_dimension;
+ else
+ bw_d->value = (bw_d->value * bw_dimension) / bw_pixels;
/* todo: the availble resize may have changed, update the drag box */
return true;
@@ -557,7 +565,7 @@
return true;
}
assert(!"Invalid frame dimension unit");
- return false;
+ return false;
}
@@ -609,7 +617,7 @@
right &= (col < parent->cols - 1);
up &= (row > 0);
down &= (row < parent->rows - 1);
-
+
/* check the sibling frames can be resized */
if (left)
left &= !parent->children[row * parent->cols + (col - 1)].no_resize;
Modified: trunk/netsurf/riscos/gui.h
URL: http://svn.semichrome.net/trunk/netsurf/riscos/gui.h?rev=3134&r1=3133&r2=...
==============================================================================
--- trunk/netsurf/riscos/gui.h (original)
+++ trunk/netsurf/riscos/gui.h Wed Jan 3 15:15:54 2007
@@ -83,6 +83,7 @@
bool reformat_pending;
int old_width; /**< Width when last opened / os units. */
int old_height; /**< Height when last opened / os units. */
+ bool update_extent; /**< Update the extent on next opening */
char title[256]; /**< Buffer for window title. */
Modified: trunk/netsurf/riscos/window.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/window.c?rev=3134&r1=3133&...
==============================================================================
--- trunk/netsurf/riscos/window.c (original)
+++ trunk/netsurf/riscos/window.c Wed Jan 3 15:15:54 2007
@@ -176,6 +176,7 @@
g->reformat_pending = false;
g->old_width = 0;
g->old_height = 0;
+ g->update_extent = true;
strcpy(g->title, "NetSurf");
g->throbber = 0;
g->throbtime = 0;
@@ -183,14 +184,6 @@
/* Set the window position */
if (bw->parent) {
- /* Open as a small window until we are reformatted */
- state.w = clone->window->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- }
window.visible.x0 = 0;
window.visible.x1 = 64;
window.visible.y0 = 0;
@@ -270,7 +263,7 @@
window.highlight_bg = wimp_COLOUR_CREAM;
window.extra_flags = 0;
window.extent.x0 = 0;
- window.extent.y0 = window.visible.y1 - window.visible.y0;
+ window.extent.y0 = -(window.visible.y1 - window.visible.y0);
window.extent.x1 = window.visible.x1 - window.visible.x0;
window.extent.y1 = 0;
window.title_flags = wimp_ICON_TEXT |
@@ -299,6 +292,8 @@
if (bw->scrolling == SCROLLING_NO)
window.flags &= ~(wimp_WINDOW_VSCROLL |
wimp_WINDOW_HSCROLL);
+ if (bw->scrolling == SCROLLING_AUTO)
+ window.flags &= ~wimp_WINDOW_HSCROLL;
if (!bw->border)
window.title_fg = 0xff;
else {
@@ -375,6 +370,7 @@
warn_user("WimpError", error->errmess);
return g;
}
+
state.next = wimp_TOP;
if (bw->parent) {
top = browser_window_owner(bw);
@@ -384,6 +380,7 @@
wimp_CHILD_LINKS_PARENT_WORK_AREA
<< wimp_CHILD_YORIGIN_SHIFT);
}
+
ro_gui_window_open((wimp_open*)&state);
/* Claim the caret for top-level windows */
@@ -666,7 +663,7 @@
state.yscroll = -sy * 2 * g->option.scale;
if (g->toolbar)
state.yscroll += ro_gui_theme_toolbar_full_height(g->toolbar);
- ro_gui_window_open((wimp_open *) &state);
+ ro_gui_window_open((wimp_open *)&state);
}
@@ -771,6 +768,7 @@
struct browser_window *bw;
struct browser_window *parent;
struct browser_window *top;
+ float scale = 1.0;
assert(g);
bw = g->bw;
@@ -791,6 +789,10 @@
bw->x1 = x1 = parent->x0 + x1;
bw->y1 = y1 = parent->y0 + y1;
}
+
+ /* only scale iframe locations */
+ if (bw->browser_window_type == BROWSER_WINDOW_IFRAME)
+ scale = g->option.scale;
/* get the position of the top level window */
state.w = top->window->window;
@@ -820,8 +822,8 @@
y1 += 1;
}
- x1 *= 2;
- y1 *= 2;
+ x1 = x1 * 2 * scale;
+ y1 = y1 * 2 * scale;
/* scrollbars must go inside */
if (state.flags & wimp_WINDOW_HSCROLL) {
@@ -834,10 +836,11 @@
if (g->bw->border)
x1 += 2;
}
- state.visible.x0 = px0 + x0 * 2;
+ state.visible.x0 = px0 + x0 * 2 * scale;
state.visible.y0 = py1 - y1;
state.visible.x1 = px0 + x1;
- state.visible.y1 = py1 - y0 * 2;
+ state.visible.y1 = py1 - y0 * 2 * scale;
+ g->update_extent = true;
ro_gui_window_open((wimp_open *)&state);
}
@@ -853,24 +856,9 @@
void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled)
{
- wimp_window_state state;
- os_error *error;
-
- /* get the dimensions */
- state.w = g->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG(("xwimp_get_window_state: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- *width = 0;
- *height = 0;
- return;
- }
-
- *width = (state.visible.x1 - state.visible.x0) / 2;
- *height = ((state.visible.y1 - state.visible.y0) -
- (g->toolbar ? ro_gui_theme_toolbar_full_height(g->toolbar) : 0)) / 2;
+ /* use the cached window sizes */
+ *width = g->old_width / 2;
+ *height = g->old_height / 2;
if (scaled) {
*width /= g->option.scale;
*height /= g->option.scale;
@@ -894,10 +882,6 @@
assert(g);
- /* update the extent (this is only done by _open on a window
- * dimension change) */
- gui_window_set_extent(g, -1, -1);
-
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
@@ -906,15 +890,17 @@
warn_user("WimpError", error->errmess);
return;
}
- g->old_height = -1;
/* scroll on toolbar height change */
- if (g->toolbar)
- state.yscroll -= ro_gui_theme_height_change(g->toolbar);
+ if (g->toolbar) {
+ scroll = ro_gui_theme_height_change(g->toolbar);
+ state.yscroll -= scroll;
+ }
/* only allow a further reformat if we've gained/lost scrollbars */
flags = state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL);
update = g->reformat_pending;
+ g->update_extent = true;
ro_gui_window_open((wimp_open *)&state);
state.w = g->window;
@@ -927,7 +913,6 @@
}
if (flags == (state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL)))
g->reformat_pending = update;
-
if ((scroll != 0) && (g->bw->children))
browser_window_recalculate_frameset(g->bw);
}
@@ -1733,7 +1718,7 @@
toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar);
/* get the current state */
- if ((height != -1) || (width != -1)) {
+ if ((height == -1) || (width == -1)) {
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
@@ -1812,17 +1797,10 @@
height -= toolbar_height;
/* work with the state from now on so we can modify flags */
- state.visible.x0 = open->visible.x0;
- state.visible.y0 = open->visible.y0;
- state.visible.x1 = open->visible.x1;
- state.visible.y1 = open->visible.y1;
+ state.visible = open->visible;
state.xscroll = open->xscroll;
state.yscroll = open->yscroll;
state.next = open->next;
-
- /* frameset windows shouldn't be shown */
- if ((g->bw->parent) && (g->bw->children))
- state.next = wimp_HIDDEN;
/* handle 'auto' scroll bars' and non-fitting scrollbar removal */
if ((g->bw->scrolling == SCROLLING_AUTO) || (g->bw->scrolling == SCROLLING_YES)) {
@@ -1898,19 +1876,19 @@
}
}
- /* change extent if necessary */
- if (g->old_width != width || g->old_height != height) {
- if (content) {
- /* Ctrl-resize of a top-level window scales the content size */
- if ((g->old_width > 0) && (g->old_width != width) && (!g->bw->parent) &&
- (ro_gui_ctrl_pressed()))
- new_scale = (g->option.scale * width) / g->old_width;
- g->reformat_pending = true;
- gui_reformat_pending = true;
- }
+ /* reformat or change extent if necessary */
+ if ((content) && (g->old_width != width || g->old_height != height)) {
+ /* Ctrl-resize of a top-level window scales the content size */
+ if ((g->old_width > 0) && (g->old_width != width) && (!g->bw->parent) &&
+ (ro_gui_ctrl_pressed()))
+ new_scale = (g->option.scale * width) / g->old_width;
+ g->reformat_pending = true;
+ gui_reformat_pending = true;
+ }
+ if (g->update_extent || g->old_width != width || g->old_height != height) {
g->old_width = width;
g->old_height = height;
-
+ g->update_extent = false;
gui_window_set_extent(g, width, height);
}
16 years, 5 months
r3133 dsilvers - /trunk/netsurf/content/fetch.c
by netsurf@semichrome.net
Author: dsilvers
Date: Tue Jan 2 13:07:28 2007
New Revision: 3133
URL: http://svn.semichrome.net?rev=3133&view=rev
Log:
Update the file comment for fetch.c as requested.
Modified:
trunk/netsurf/content/fetch.c
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3133&r1=3132&...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Tue Jan 2 13:07:28 2007
@@ -12,9 +12,11 @@
*
* This implementation uses libcurl's 'multi' interface.
*
- * Active fetches are held in the linked list fetch_list. There may be at most
- * one fetch in progress from each host. Any further fetches are queued until
- * the previous one ends.
+ * Active fetches are held in the circular linked list ::fetch_ring. There may
+ * be at most ::option_max_fetchers_per_host active requests per Host: header.
+ * There may be at most ::option_max_fetchers active requests overall. Inactive
+ * fetchers are stored in the ::queue_ring and there are at most
+ * ::option_max_cached_fetch_handles kept in there at any one time.
*/
#include <assert.h>
16 years, 5 months
r3132 jmb - /trunk/netsurf/riscos/gui.c
by netsurf@semichrome.net
Author: jmb
Date: Tue Jan 2 00:13:02 2007
New Revision: 3132
URL: http://svn.semichrome.net?rev=3132&view=rev
Log:
Improve signal handling. This should put an end to silent exits.
Modified:
trunk/netsurf/riscos/gui.c
Modified: trunk/netsurf/riscos/gui.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/gui.c?rev=3132&r1=3131&r2=...
==============================================================================
--- trunk/netsurf/riscos/gui.c (original)
+++ trunk/netsurf/riscos/gui.c Tue Jan 2 00:13:02 2007
@@ -20,6 +20,7 @@
#include <time.h>
#include <features.h>
#include <unixlib/local.h>
+#include <unixlib/sigstate.h>
#include "curl/curl.h"
#include "oslib/font.h"
#include "oslib/help.h"
@@ -775,7 +776,44 @@
"error and must exit. Please submit a bug report, "
"attaching the browser log file." };
- if (sig == SIGFPE || sig == SIGABRT) {
+ ro_gui_cleanup();
+
+ /* Get previous handler of this signal */
+ switch (sig) {
+ case SIGABRT:
+ prev_handler = prev_sigs.sigabrt;
+ break;
+ case SIGFPE:
+ prev_handler = prev_sigs.sigfpe;
+ break;
+ case SIGILL:
+ prev_handler = prev_sigs.sigill;
+ break;
+ case SIGINT:
+ prev_handler = prev_sigs.sigint;
+ break;
+ case SIGSEGV:
+ prev_handler = prev_sigs.sigsegv;
+ break;
+ case SIGTERM:
+ prev_handler = prev_sigs.sigterm;
+ break;
+ default:
+ /* Unexpected signal - force to default so we exit
+ * cleanly */
+ prev_handler = SIG_DFL;
+ break;
+ }
+
+ if (prev_handler != SIG_IGN && prev_handler != SIG_DFL) {
+ /* User-registered handler, so call it direct */
+ prev_handler(sig);
+ } else if (prev_handler == SIG_DFL) {
+ /* Previous handler would be the default. However, if we
+ * get here, it's going to be fatal, anyway, so bail,
+ * after writing context to the log and informing the
+ * user */
+
os_colour old_sand, old_glass;
xwimp_report_error_by_category(&error,
@@ -797,42 +835,10 @@
/*rufl_dump_state();*/
xhourglass_colours(old_sand, old_glass, 0, 0);
xhourglass_off();
- }
- ro_gui_cleanup();
-
- /* Get previous handler of this signal */
- switch (sig) {
- case SIGABRT:
- prev_handler = prev_sigs.sigabrt;
- break;
- case SIGFPE:
- prev_handler = prev_sigs.sigfpe;
- break;
- case SIGILL:
- prev_handler = prev_sigs.sigill;
- break;
- case SIGINT:
- prev_handler = prev_sigs.sigint;
- break;
- case SIGSEGV:
- prev_handler = prev_sigs.sigsegv;
- break;
- case SIGTERM:
- prev_handler = prev_sigs.sigterm;
- break;
- default:
- abort();
- }
-
- if (prev_handler != SIG_IGN && prev_handler != SIG_DFL) {
- /* User-registered handler, so call it direct */
- prev_handler(sig);
- } else if (prev_handler == SIG_DFL) {
- /* Default handler so set handler to that and raise() */
- prev_handler = signal(sig, SIG_DFL);
- if (prev_handler == SIG_ERR)
- abort();
- raise(sig);
+
+ __write_backtrace(sig);
+
+ abort();
}
/* If we reach here, previous handler was either SIG_IGN or
* the user-defined handler returned. In either case, we have
16 years, 5 months
r3131 bursa - /trunk/netsurf/Docs/05-memory
by netsurf@semichrome.net
Author: bursa
Date: Mon Jan 1 20:39:27 2007
New Revision: 3131
URL: http://svn.semichrome.net?rev=3131&view=rev
Log:
How to use dmalloc to find leaks.
Added:
trunk/netsurf/Docs/05-memory
Added: trunk/netsurf/Docs/05-memory
URL: http://svn.semichrome.net/trunk/netsurf/Docs/05-memory?rev=3131&view=auto
==============================================================================
--- trunk/netsurf/Docs/05-memory (added)
+++ trunk/netsurf/Docs/05-memory Mon Jan 1 20:39:27 2007
@@ -1,0 +1,19 @@
+Memory management
+=================
+
+This section describes memory management. See Error handling for how memory
+exhaustion is handled.
+
+Finding leaks on RISC OS
+------------------------
+Memory allocation can be traced and leaks can be found using dmalloc.
+
+Install dmalloc from the riscos.info autobuilder. Set the environment variable
+TLINK_MEMCHECK=dmalloc and re-link !RunImage.
+
+On RISC OS,
+
+ *Set DMALLOC_OPTIONS debug=0x2,log=dmalloc_log
+
+set the working directory to a RAM disc, and run NetSurf. When it quits,
+dmalloc_log will contain a list of unfreed blocks.
16 years, 5 months