summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2012-10-22 20:01:51 +0100
committerChris Young <chris@unsatisfactorysoftware.co.uk>2012-10-22 20:01:51 +0100
commitbcd43d3f5989b236f696773ab523f56cac54cd8a (patch)
treedc1d00799cc93d9c7e3f7298b3fdcabb92bd28e7
parent094b866388f504bbbecec6290c286f8b6cb008fb (diff)
parent9629e428a55961106fcd15fd9e0ad9de0649f314 (diff)
downloadnetsurf-bcd43d3f5989b236f696773ab523f56cac54cd8a.tar.gz
netsurf-bcd43d3f5989b236f696773ab523f56cac54cd8a.tar.bz2
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
-rw-r--r--!NetSurf/Resources/Icons/directory.pngbin259 -> 294 bytes
-rw-r--r--!NetSurf/Resources/de/welcome.html,faf6
-rw-r--r--!NetSurf/Resources/it/welcome.html,faf8
-rw-r--r--!NetSurf/Resources/ja/welcome.html,faf6
-rw-r--r--amiga/Makefile.target2
-rw-r--r--amiga/font_scan.c33
-rwxr-xr-xamiga/gui.c10
-rwxr-xr-xatari/browser_win.c29
-rwxr-xr-xatari/findfile.c5
-rwxr-xr-xatari/gui.c24
-rwxr-xr-xatari/statusbar.c44
-rwxr-xr-xatari/statusbar.h12
-rw-r--r--beos/gui.cpp6
-rw-r--r--cocoa/Makefile.target21
-rw-r--r--cocoa/NetsurfApp.m12
-rw-r--r--content/content.h5
-rw-r--r--desktop/browser.c125
-rw-r--r--desktop/history_global_core.c3
-rw-r--r--desktop/netsurf.c1
-rw-r--r--desktop/options.h12
-rw-r--r--framebuffer/Makefile.target4
-rw-r--r--framebuffer/gui.c27
-rw-r--r--gtk/gui.c86
-rw-r--r--monkey/Makefile.target44
-rw-r--r--monkey/main.c6
-rw-r--r--render/form.c9
-rw-r--r--render/html.c158
-rw-r--r--render/imagemap.c19
-rw-r--r--render/imagemap.h2
-rw-r--r--riscos/font.c2
-rw-r--r--riscos/gui.c85
-rw-r--r--utils/errors.h16
-rw-r--r--utils/libdom.c2
-rw-r--r--windows/main.c12
34 files changed, 573 insertions, 263 deletions
diff --git a/!NetSurf/Resources/Icons/directory.png b/!NetSurf/Resources/Icons/directory.png
index de3d7687f..1d683bf1e 100644
--- a/!NetSurf/Resources/Icons/directory.png
+++ b/!NetSurf/Resources/Icons/directory.png
Binary files differ
diff --git a/!NetSurf/Resources/de/welcome.html,faf b/!NetSurf/Resources/de/welcome.html,faf
index fbbed0399..8cbcbd8c5 100644
--- a/!NetSurf/Resources/de/welcome.html,faf
+++ b/!NetSurf/Resources/de/welcome.html,faf
@@ -10,9 +10,9 @@
<ul class="nslinks">
<li><a href="http://www.netsurf-browser.org/">NetSurf Website</a></li>
-<li><a href="/documentation/">Dokumentation</a></li>
-<li><a href="/downloads/">Download neustes NetSurf</a></li>
-<li><a href="/contact/">Kontakt zu den Entwicklern</a></li>
+<li><a href="http://www.netsurf-browser.org/documentation/">Dokumentation</a></li>
+<li><a href="http://www.netsurf-browser.org/downloads/">Download neustes NetSurf</a></li>
+<li><a href="http://www.netsurf-browser.org/contact/">Kontakt zu den Entwicklern</a></li>
</ul>
<div class="onlycontent">
diff --git a/!NetSurf/Resources/it/welcome.html,faf b/!NetSurf/Resources/it/welcome.html,faf
index 2d44436de..dd9c63e1b 100644
--- a/!NetSurf/Resources/it/welcome.html,faf
+++ b/!NetSurf/Resources/it/welcome.html,faf
@@ -10,9 +10,9 @@
<ul class="nslinks">
<li><a href="http://www.netsurf-browser.org/">Pagina principale</a></li>
-<li><a href="/documentation/">Documentazione</a></li>
-<li><a href="/downloads/">Scarica NetSurf</a></li>
-<li><a href="/contact/">Contatta gli sviluppatori</a></li>
+<li><a href="http://www.netsurf-browser.org/documentation/">Documentazione</a></li>
+<li><a href="http://www.netsurf-browser.org/downloads/">Scarica NetSurf</a></li>
+<li><a href="http://www.netsurf-browser.org/contact/">Contatta gli sviluppatori</a></li>
</ul>
<div class="onlycontent">
@@ -61,4 +61,4 @@
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/!NetSurf/Resources/ja/welcome.html,faf b/!NetSurf/Resources/ja/welcome.html,faf
index 152847443..ce7b36343 100644
--- a/!NetSurf/Resources/ja/welcome.html,faf
+++ b/!NetSurf/Resources/ja/welcome.html,faf
@@ -11,9 +11,9 @@
<ul class="nslinks">
<li><a href="http://www.netsurf-browser.org/">NetSurfウェブサイト</a></li>
-<li><a href="/documentation/">ドキュメンテーション</a></li>
-<li><a href="/downloads/">最新のNetSurfをダウンロード</a></li>
-<li><a href="/contact/">開発者とコンタクト</a></li>
+<li><a href="http://www.netsurf-browser.org/documentation/">ドキュメンテーション</a></li>
+<li><a href="http://www.netsurf-browser.org/downloads/">最新のNetSurfをダウンロード</a></li>
+<li><a href="http://www.netsurf-browser.org/contact/">開発者とコンタクト</a></li>
</ul>
<div class="onlycontent">
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index f0eabf86e..61de77b36 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -64,7 +64,7 @@ else
ifeq ($(SUBTARGET),os3)
LDFLAGS += -liconv
else
- LDFLAGS += -lauto -lpbl
+ LDFLAGS += -lauto -lpbl -liconv
endif
ifeq ($(NETSURF_AMIGA_CAIRO_AVAILABLE),yes)
diff --git a/amiga/font_scan.c b/amiga/font_scan.c
index 549ea5064..a58acf01b 100644
--- a/amiga/font_scan.c
+++ b/amiga/font_scan.c
@@ -259,10 +259,10 @@ ULONG ami_font_scan_fonts(struct MinList *list,
do {
nnode = (struct nsObject *)GetSucc((struct Node *)node);
ami_font_scan_gui_update(win, node->dtz_Node.ln_Name, font_num, total);
- LOG(("Scanning %s\n", node->dtz_Node.ln_Name));
+ LOG(("Scanning %s", node->dtz_Node.ln_Name));
found = ami_font_scan_font(node->dtz_Node.ln_Name, glypharray);
total += found;
- LOG(("Found %ld new glyphs (total = %ld)\n", found, total));
+ LOG(("Found %ld new glyphs (total = %ld)", found, total));
font_num++;
} while(node = nnode);
@@ -308,7 +308,7 @@ ULONG ami_font_scan_list(struct MinList *list)
if(node) {
node->dtz_Node.ln_Name = strdup(af[i].af_Attr.ta_Name);
found++;
- LOG(("Added %s\n", af[i].af_Attr.ta_Name));
+ LOG(("Added %s", af[i].af_Attr.ta_Name));
}
}
}
@@ -493,31 +493,4 @@ void ami_font_scan_init(const char *filename, bool force_scan, bool save,
LOG(("Initialised with %ld glyphs", found));
}
-#ifdef AMI_FONT_SCAN_STANDALONE
-/* This can be compiled as standalone using:
-* gcc -o font_scan font_scan.c object.c -lwapcaplet -lauto -I .. -D__USE_INLINE__ -DAMI_FONT_SCAN_STANDALONE
-*/
-int main(int argc, char** argv)
-{
- lwc_string *glypharray[0xffff + 1];
- ULONG found = 0;
- BPTR fh;
- struct MinList *list;
-
- if(argc < 2) return 5;
-
- printf("%s\n",argv[1]);
-
- list = NewObjList();
- ami_font_scan_init(argv[1], list, glypharray);
- FreeObjList(list);
-
- ami_font_scan_fini(glypharray);
-
- return 0;
-}
-
-void ami_font_close(APTR discard) { }
-void ami_mime_entry_free(APTR discard) { }
-#endif
diff --git a/amiga/gui.c b/amiga/gui.c
index 01f149c31..15ac1f553 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -158,6 +158,7 @@ static char *current_user_dir;
const char tree_directory_icon_name[] = "def_drawer.info";
const char tree_content_icon_name[] = "def_project.info";
+static const __attribute__((used)) char *stack_cookie = "\0$STACK:131072\0";
static struct DrawInfo *dri;
@@ -540,6 +541,13 @@ nsurl *gui_get_resource_url(const char *path)
return url;
}
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+ ami_set_options(); /* check options and set defaults where required */
+}
+
void gui_init(int argc, char** argv)
{
BPTR lock = 0;
@@ -549,8 +557,6 @@ void gui_init(int argc, char** argv)
ami_clipboard_init();
ami_openurl_open();
- ami_set_options(); /* check options and set defaults where required */
-
win_destroyed = false;
nsscreentitle = ASPrintf("NetSurf %s",netsurf_version);
diff --git a/atari/browser_win.c b/atari/browser_win.c
index 8beb39645..f6daf37c4 100755
--- a/atari/browser_win.c
+++ b/atari/browser_win.c
@@ -103,6 +103,9 @@ int window_create( struct gui_window * gw,
}
if( inflags & WIDGET_RESIZE ){
flags |= ( SIZER );
+ }
+ if( inflags & WIDGET_STATUSBAR ){
+ flags |= ( INFO );
}
gw->root = malloc( sizeof(struct s_gui_win_root) );
@@ -141,8 +144,10 @@ int window_create( struct gui_window * gw,
/* create statusbar component: */
if( sb ) {
- gw->root->statusbar = sb_create( gw );
- mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
+ gw->root->statusbar = sb_create( gw );
+#ifdef WITH_COMOPONENT_STATUSBAR
+ mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
+#endif
} else {
gw->root->statusbar = NULL;
}
@@ -231,7 +236,7 @@ void window_open( struct gui_window * gw, GRECT pos )
plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h);
gw->browser->attached = true;
if( gw->root->statusbar != NULL ){
- gw->root->statusbar->attached = true;
+ sb_attach(gw->root->statusbar, gw);
}
tb_adjust_size( gw );
/*TBD: get already present content and set size? */
@@ -247,7 +252,7 @@ void window_update_back_forward( struct gui_window * gw)
tb_update_buttons( gw, -1 );
}
-void window_set_stauts( struct gui_window * gw , char * text )
+void window_set_stauts(struct gui_window * gw , char * text )
{
if( gw->root == NULL )
return;
@@ -428,13 +433,11 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
if( !strncmp( ext, "ARGS", 4) && dd_msg > 0)
{
ddreply(dd_hdl, DD_OK);
- buff = (char*)alloca(sizeof(char)*(size+1));
- if( buff != NULL )
+ buff = (char*)malloc(sizeof(char)*(size+1));
+ if (buff != NULL)
{
- if( Fread(dd_hdl, size, buff ) == size)
- {
+ if (Fread(dd_hdl, size, buff ) == size)
buff[size] = 0;
- }
LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
(char*)buff, (char*)&ext,
size, mx, my
@@ -451,8 +454,9 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
utf8_convert_ret ret;
char *utf8_fn;
- ret = utf8_from_local_encoding( buff, 0, &utf8_fn);
- if (ret != UTF8_CONVERT_OK) {
+ ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
+ if (ret != UTF8_CONVERT_OK) {
+ free(buff);
/* A bad encoding should never happen */
LOG(("utf8_from_local_encoding failed"));
assert(ret != UTF8_CONVERT_BADENC);
@@ -463,7 +467,8 @@ static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
mx+gw->browser->scroll.current.x,
my+gw->browser->scroll.current.y,
utf8_fn );
- free( utf8_fn );
+ free(utf8_fn);
+ free(buff);
}
}
}
diff --git a/atari/findfile.c b/atari/findfile.c
index 3a06f61e9..93bf4638e 100755
--- a/atari/findfile.c
+++ b/atari/findfile.c
@@ -41,7 +41,7 @@ char * local_file_to_url( const char * filename )
return( NULL );
}
- char * fname_local = alloca( strlen(filename)+1 );
+ char * fname_local = malloc( strlen(filename)+1 );
char * start = (char*)fname_local;
strcpy( start, filename );
@@ -72,6 +72,9 @@ char * local_file_to_url( const char * filename )
url = malloc( strlen(start) + FILE_SCHEME_PREFIX_LEN + 1);
strcpy( url, FILE_SCHEME_PREFIX );
strcat( url, start );
+
+ free(fname_local);
+
return( url );
#undef BACKSLASH
}
diff --git a/atari/gui.c b/atari/gui.c
index a2dac21d3..c2158e05e 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -553,12 +553,12 @@ gui_window_remove_caret(struct gui_window *w)
void
gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
-{
- struct bitmap *bmp_icon;
+{
+ struct bitmap *bmp_icon;
+
+ bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
- bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
-
- window_set_icon(g, bmp_icon);
+ window_set_icon(g, bmp_icon);
}
void
@@ -911,6 +911,17 @@ nsurl *gui_get_resource_url(const char *path)
return url;
}
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+ nsoption_setnull_charp(cookie_file, strdup("cookies"));
+
+ if (nsoption_charp(cookie_file) == NULL) {
+ die("Failed initialising string options");
+ }
+}
+
static void gui_init(int argc, char** argv)
{
char buf[PATH_MAX];
@@ -961,9 +972,6 @@ static void gui_init(int argc, char** argv)
urldb_load(nsoption_charp(url_file));
}
- if (nsoption_charp(cookie_file) == NULL ){
- nsoption_set_charp(cookie_file, (char*)"cookies");
- }
LOG(("Loading cookies from: %s", nsoption_charp(cookie_file) ));
if( strlen(nsoption_charp(cookie_file)) ){
urldb_load_cookies(nsoption_charp(cookie_file));
diff --git a/atari/statusbar.c b/atari/statusbar.c
index f4dbbe578..08a62c55d 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -44,7 +44,8 @@
#include "atari/res/netsurf.rsh"
#include "atari/plot/plot.h"
#include "atari/osspec.h"
-
+
+#ifdef WITH_CUSTOM_STATUSBAR
extern int atari_plot_vdi_handle;
static
@@ -182,7 +183,8 @@ void sb_destroy( CMP_STATUSBAR s )
}
void sb_set_text( CMP_STATUSBAR sb , char * text )
-{
+{
+
LGRECT work;
assert( sb != NULL );
assert( sb->comp != NULL );
@@ -197,4 +199,42 @@ void sb_set_text( CMP_STATUSBAR sb , char * text )
work.g_x, work.g_y, work.g_w, work.g_h );
}
}
+}
+
+#else
+
+CMP_STATUSBAR sb_create( struct gui_window * gw )
+{
+ CMP_STATUSBAR s = malloc( sizeof(struct s_statusbar) );
+ s->attached = false;
+ sb_set_text( s, (char*)"" );
+ return( s );
}
+
+void sb_destroy( CMP_STATUSBAR s )
+{
+ LOG(("%s\n", __FUNCTION__ ));
+ if( s ) {
+ free( s );
+ }
+}
+
+void sb_attach(CMP_STATUSBAR sb, struct gui_window * gw)
+{
+ sb->aes_win = gw->root->handle->handle;
+ sb->attached = true;
+}
+
+void sb_set_text(CMP_STATUSBAR sb, char * text )
+{
+ LGRECT work;
+ assert( sb != NULL );
+ strncpy(sb->text, text, STATUSBAR_MAX_SLEN);
+ sb->text[STATUSBAR_MAX_SLEN]=0;
+ sb->textlen = strlen(sb->text);
+ if(sb->attached){
+ wind_set_str(sb->aes_win, WF_INFO, sb->text);
+ }
+}
+
+#endif
diff --git a/atari/statusbar.h b/atari/statusbar.h
index fd01a0c79..fc6749e91 100755
--- a/atari/statusbar.h
+++ b/atari/statusbar.h
@@ -23,15 +23,19 @@
#define STATUSBAR_MAX_SLEN 255
struct s_statusbar
-{
- COMPONENT * comp;
+{
+#ifdef WITH_COMPONENT_STATUSBAR
+ COMPONENT * comp;
+#endif
char text[STATUSBAR_MAX_SLEN+1];
size_t textlen;
- bool attached;
+ bool attached;
+ short aes_win;
};
CMP_STATUSBAR sb_create( struct gui_window * gw );
void sb_destroy( CMP_STATUSBAR s );
-void sb_set_text( CMP_STATUSBAR sb , char * text );
+void sb_set_text( CMP_STATUSBAR sb , char * text );
+void sb_attach(CMP_STATUSBAR sb, struct gui_window * gw);
#endif
diff --git a/beos/gui.cpp b/beos/gui.cpp
index dc3c33538..b275616f5 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -475,6 +475,12 @@ int main(int argc, char** argv)
return 0;
}
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+}
+
void gui_init(int argc, char** argv)
{
diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target
index 635790a61..82900b6b0 100644
--- a/cocoa/Makefile.target
+++ b/cocoa/Makefile.target
@@ -41,7 +41,9 @@ endif
CFLAGS += -I/usr/include/libxml2
CFLAGS += -include cocoa/Prefix.pch
- VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c)
+# VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c)
+# TODO: this needs fixing properly everywhere
+ VERSION_FULL := "3.0 (Dev)"
VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
@@ -218,12 +220,27 @@ NetSurf.app/Contents/Info.plist: cocoa/res/NetSurf-Info.plist cocoa/Makefile.tar
package-cocoa: NetSurf.dmg
+.INTERMEDIATE: NetSurf.tmp.dmg
+
NetSurf.tmp.dmg: NetSurf.app
hdiutil create -size 8m -fs HFS+ -volname "NetSurf" $@
+ sleep 2
hdiutil attach $@
- cp -a $^ /Volumes/NetSurf/
+ sleep 2
+ cp -pPR $^ /Volumes/NetSurf/
hdiutil detach $$(echo $$(hdiutil attach $@ | cut -f 1) | cut -f 1 -d ' ')
+ sleep 2
NetSurf.dmg: NetSurf.tmp.dmg
hdiutil convert $^ -format UDZO -o $@
+CLEANS += clean-package-cocoa
+
+clean-package-cocoa:
+ $(VQ)echo " CLEAN: NetSurf.tmp.dmg"
+ $(Q)$(RM) NetSurf.tmp.dmg
+ $(VQ)echo " CLEAN: NetSurf.dmg"
+ $(Q)$(RM) NetSurf.dmg
+ $(VQ)echo " CLEAN: NetSurf.app"
+ $(Q)$(RM) -r NetSurf.app
+
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 65c9f8cd1..4c2dfc185 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -164,15 +164,21 @@ void cocoa_autorelease( void )
pool = [[NSAutoreleasePool alloc] init];
}
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+ const char * const ca_bundle = [[[NSBundle mainBundle] pathForResource: @"ca-bundle" ofType: @""] UTF8String];
+
+ nsoption_setnull_charp(ca_bundle, strdup(ca_bundle));
+}
+
int main( int argc, char **argv )
{
cocoa_autorelease();
const char * const messages = [[[NSBundle mainBundle] pathForResource: @"Messages" ofType: @""] UTF8String];
const char * const options = cocoa_get_options_file();
- const char * const ca_bundle = [[[NSBundle mainBundle] pathForResource: @"ca-bundle" ofType: @""] UTF8String];
-
- nsoption_setnull_charp(ca_bundle, strdup(ca_bundle));
netsurf_init(&argc, &argv, options, messages);
diff --git a/content/content.h b/content/content.h
index b07af4fe1..649f54dfa 100644
--- a/content/content.h
+++ b/content/content.h
@@ -67,6 +67,7 @@ typedef enum {
CONTENT_MSG_READY, /**< may be displayed */
CONTENT_MSG_DONE, /**< finished */
CONTENT_MSG_ERROR, /**< error occurred */
+ CONTENT_MSG_ERRORCODE, /**< error occurred return nserror */
CONTENT_MSG_STATUS, /**< new status string */
CONTENT_MSG_REFORMAT, /**< content_reformat done */
CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */
@@ -96,7 +97,9 @@ struct content_rfc5988_link {
/** Extra data for some content_msg messages. */
union content_msg_data {
/** CONTENT_MSG_ERROR - Error message */
- const char *error;
+ const char *error;
+ /** CONTENT_MSG_ERRORCODE - Error code */
+ nserror errorcode;
/** CONTENT_MSG_REDRAW - Area of content which needs redrawing */
struct {
int x, y, width, height;
diff --git a/desktop/browser.c b/desktop/browser.c
index d3237f5ef..89484609e 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1187,6 +1187,127 @@ static void browser_window_update_favicon(hlcache_handle *c,
nsurl_unref(nsurl);
}
+/** window callback errorcode handling */
+static void
+browser_window_callback_errorcode(hlcache_handle *c,
+ struct browser_window *bw,
+ nserror code)
+{
+ const char* message;
+
+ switch (code) {
+ case NSERROR_OK:
+ /**< No error */
+ message = messages_get("OK");
+ break;
+
+ case NSERROR_NOMEM:
+ /**< Memory exhaustion */
+ message = messages_get("NoMemory");
+ break;
+
+ case NSERROR_NO_FETCH_HANDLER:
+ /**< No fetch handler for URL scheme */
+ message = messages_get("NoHandler");
+ break;
+
+ case NSERROR_NOT_FOUND:
+ /**< Requested item not found */
+ message = messages_get("NotFound");
+ break;
+
+ case NSERROR_SAVE_FAILED:
+ /**< Failed to save data */
+ message = messages_get("SaveFailed");
+ break;
+
+ case NSERROR_CLONE_FAILED:
+ /**< Failed to clone handle */
+ message = messages_get("CloneFailed");
+ break;
+
+ case NSERROR_INIT_FAILED:
+ /**< Initialisation failed */
+ message = messages_get("InitFailed");
+ break;
+
+ case NSERROR_MNG_ERROR:
+ /**< An MNG error occurred */
+ message = messages_get("MNGError");
+ break;
+
+ case NSERROR_BAD_ENCODING:
+ /**< The character set is unknown */
+ message = messages_get("BadEncoding");
+ break;
+
+ case NSERROR_NEED_DATA:
+ /**< More data needed */
+ message = messages_get("NeedData");
+ break;
+
+ case NSERROR_ENCODING_CHANGE:
+ /**< The character set encoding change was unhandled */
+ message = messages_get("EncodingChanged");
+ break;
+
+ case NSERROR_BAD_PARAMETER:
+ /**< Bad Parameter */
+ message = messages_get("BadParameter");
+ break;
+
+ case NSERROR_INVALID:
+ /**< Invalid data */
+ message = messages_get("Invalid");
+ break;
+
+ case NSERROR_BOX_CONVERT:
+ /**< Box conversion failed */
+ message = messages_get("BoxConvert");
+ break;
+
+ case NSERROR_STOPPED:
+ /**< Content conversion stopped */
+ message = messages_get("Stopped");
+ break;
+
+ case NSERROR_DOM:
+ /**< DOM call returned error */
+ message = messages_get("ParsingFail");
+ break;
+
+ case NSERROR_BAD_URL:
+ /**< Bad URL */
+ message = messages_get("BadURL");
+ break;
+
+ default:
+ case NSERROR_UNKNOWN:
+ /**< Unknown error */
+ message = messages_get("Unknown");
+ break;
+
+ }
+
+ browser_window_set_status(bw, message);
+
+ /* Only warn the user about errors in top-level windows */
+ if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
+ warn_user(message, 0);
+ }
+
+ if (c == bw->loading_content) {
+ bw->loading_content = NULL;
+ } else if (c == bw->current_content) {
+ bw->current_content = NULL;
+ browser_window_remove_caret(bw);
+ }
+
+ hlcache_handle_release(c);
+
+ browser_window_stop_throbber(bw);
+}
+
/**
* Callback for fetchcache() for browser window fetches.
*/
@@ -1320,6 +1441,10 @@ nserror browser_window_callback(hlcache_handle *c,
browser_window_refresh, bw);
break;
+ case CONTENT_MSG_ERRORCODE:
+ browser_window_callback_errorcode(c, bw, event->data.errorcode);
+ break;
+
case CONTENT_MSG_ERROR:
browser_window_set_status(bw, event->data.error);
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
index 50c326684..3222dc7b8 100644
--- a/desktop/history_global_core.c
+++ b/desktop/history_global_core.c
@@ -287,11 +287,14 @@ bool history_global_initialise(struct tree *tree, const char* folder_icon_name)
if (!history_global_initialise_nodes())
return false;
+ LOG(("Building history tree"));
+
global_history_initialised = true;
urldb_iterate_entries(global_history_add_internal);
global_history_initialised = false;
tree_set_node_expanded(global_history_tree, global_history_tree_root,
false, true, true);
+ LOG(("History tree built"));
return true;
}
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 65765fae4..0b1cffe0a 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -166,6 +166,7 @@ nserror netsurf_init(int *pargc,
LOG(("Using '%s' for Options file", options));
nsoption_read(options);
+ gui_options_init_defaults();
messages_load(messages);
diff --git a/desktop/options.h b/desktop/options.h
index b96aaec52..53c025c18 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -114,13 +114,16 @@ extern struct ns_options nsoptions;
} \
} while (0)
-#define nsoption_setnull_charp(OPTION, VALUE) do { \
- if (nsoptions.OPTION == NULL) { \
+#define nsoption_setnull_charp(OPTION, VALUE) \
+ do { \
+ if (nsoptions.OPTION == NULL) { \
nsoptions.OPTION = VALUE; \
if (*nsoptions.OPTION == 0) { \
free(nsoptions.OPTION); \
nsoptions.OPTION = NULL; \
} \
+ } else { \
+ free(VALUE); \
} \
} while (0)
@@ -175,5 +178,10 @@ int nsoption_snoptionf(char *string, size_t size, unsigned int option,
*/
void nsoption_commandline(int *pargc, char **argv);
+/**
+ * Set default values for unset front-end specific options
+ */
+void gui_options_init_defaults(void);
+
#endif
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index 3ca054069..2a41f4128 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -17,6 +17,8 @@ NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+NETSURF_FEATURE_JS_CFLAGS := -DWITH_JS -DJS_HAS_FILE_OBJECT=0
+NETSURF_FEATURE_MOZJS_CFLAGS := -DWITH_MOZJS -DJS_HAS_FILE_OBJECT=0
CFLAGS += -Dnsframebuffer
@@ -39,6 +41,8 @@ CFLAGS += '-DNETSURF_FB_FONT_FANTASY="$(NETSURF_FB_FONT_FANTASY)"'
$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,Sprite))
$(eval $(call pkg_config_find_and_add,BMP,libnsbmp,BMP))
$(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF))
+$(eval $(call pkg_config_find_and_add,MOZJS,mozjs185,JavaScript))
+$(eval $(call pkg_config_find_and_add,JS,mozilla-js,JavaScript))
CFLAGS += -std=c99 -g -I. -Dsmall $(WARNFLAGS) \
-D_BSD_SOURCE \
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index b8bb5cede..0f3f7b921 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -476,26 +476,27 @@ process_cmdline(int argc, char** argv)
return true;
}
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+ nsoption_setnull_charp(cookie_file, strdup("~/.netsurf/Cookies"));
+ nsoption_setnull_charp(cookie_jar, strdup("~/.netsurf/Cookies"));
+
+ if (nsoption_charp(cookie_file) == NULL ||
+ nsoption_charp(cookie_jar == NULL)) {
+ die("Failed initialising cookie options");
+ }
+}
+
static void
gui_init(int argc, char** argv)
{
nsfb_t *nsfb;
+ /* Override, since we have no support for non-core SELECT menu */
nsoption_set_bool(core_select_menu, true);
- if (nsoption_charp(cookie_file) == NULL) {
- nsoption_set_charp(cookie_file, strdup("~/.netsurf/Cookies"));
- LOG(("Using '%s' as Cookies file", nsoption_charp(cookie_file)));
- }
-
- if (nsoption_charp(cookie_jar) == NULL) {
- nsoption_set_charp(cookie_jar, strdup("~/.netsurf/Cookies"));
- LOG(("Using '%s' as Cookie Jar file", nsoption_charp(cookie_jar)));
- }
-
- if (nsoption_charp(cookie_file) == NULL || nsoption_charp(cookie_jar == NULL))
- die("Failed initialising cookie options");
-
if (process_cmdline(argc,argv) != true)
die("unable to process command line.\n");
diff --git a/gtk/gui.c b/gtk/gui.c
index b24fecfb8..891910407 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -241,11 +241,49 @@ nsgtk_init_glade(char **respath)
widWarning = GTK_WIDGET(gtk_builder_get_object(gladeWarning, "labelWarning"));
}
-static void check_options(char **respath)
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
{
char *hdir = getenv("HOME");
char buf[PATH_MAX];
+ /* Set defaults for absent option strings */
+ snprintf(buf, PATH_MAX, "%s/.netsurf/Cookies", hdir);
+ nsoption_setnull_charp(cookie_file, strdup(buf));
+ nsoption_setnull_charp(cookie_jar, strdup(buf));
+ if (nsoption_charp(cookie_file) == NULL ||
+ nsoption_charp(cookie_jar) == NULL)
+ die("Failed initialising cookie options");
+
+ if (nsoption_charp(downloads_directory) == NULL) {
+ snprintf(buf, PATH_MAX, "%s/", hdir);
+ nsoption_set_charp(downloads_directory, strdup(buf));
+ }
+
+ if (nsoption_charp(url_file) == NULL) {
+ snprintf(buf, PATH_MAX, "%s/.netsurf/URLs", hdir);
+ nsoption_set_charp(url_file, strdup(buf));
+ }
+
+ if (nsoption_charp(hotlist_path) == NULL) {
+ snprintf(buf, PATH_MAX, "%s/.netsurf/Hotlist", hdir);
+ nsoption_set_charp(hotlist_path, strdup(buf));
+ }
+
+ nsoption_setnull_charp(ca_path, strdup("/etc/ssl/certs"));
+
+ if (nsoption_charp(url_file) == NULL ||
+ nsoption_charp(ca_path) == NULL ||
+ nsoption_charp(downloads_directory) == NULL ||
+ nsoption_charp(hotlist_path) == NULL) {
+ die("Failed initialising string options");
+ }
+}
+
+static void check_options(char **respath)
+{
+ char *hdir = getenv("HOME");
+ char buf[PATH_MAX];
nsoption_set_bool(core_select_menu, true);
/* Attempt to handle nonsense status bar widths. These may exist
@@ -259,57 +297,13 @@ static void check_options(char **respath)
}
/* user options should be stored in the users home directory */
- snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir);
+ snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir);
options_file_location = strdup(buf);
-
- /* VRS - I do not beleive these setting should search the
- * resource path, they should just be set to the default
- * values!
- */
- if (nsoption_charp(cookie_file) == NULL) {
- filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/");
- LOG(("Using '%s' as Cookies file", buf));
- nsoption_set_charp(cookie_file, strdup(buf));
- }
- if (nsoption_charp(cookie_jar) == NULL) {
- filepath_sfinddef(respath, buf, "Cookies", "~/.netsurf/");
- LOG(("Using '%s' as Cookie Jar file", buf));
- nsoption_set_charp(cookie_jar, strdup(buf));
- }
- if (nsoption_charp(cookie_file) == NULL ||
- nsoption_charp(cookie_jar) == NULL)
- die("Failed initialising cookie options");
-
- if (nsoption_charp(url_file) == NULL) {
- filepath_sfinddef(respath, buf, "URLs", "~/.netsurf/");
- LOG(("Using '%s' as URL file", buf));
- nsoption_set_charp(url_file, strdup(buf));
- }
-
- if (nsoption_charp(ca_path) == NULL) {
- filepath_sfinddef(respath, buf, "certs", "/etc/ssl/");
- LOG(("Using '%s' as certificate path", buf));
- nsoption_set_charp(ca_path, strdup(buf));
- }
-
- if (nsoption_charp(downloads_directory) == NULL) {
- LOG(("Using '%s' as download directory", hdir));
- nsoption_set_charp(downloads_directory, strdup(hdir));
- }
filepath_sfinddef(respath, buf, "icons/", "~/.netsurf/");
LOG(("Using '%s' as Tree icons dir", buf));
tree_set_icon_dir(strdup(buf));
- if (nsoption_charp(hotlist_path) == NULL) {
- filepath_sfinddef(respath, buf, "Hotlist", "~/.netsurf/");
- LOG(("Using '%s' as Hotlist file", buf));
- nsoption_set_charp(hotlist_path, strdup(buf));
- }
- if (nsoption_charp(hotlist_path) == NULL)
- die("Failed initialising hotlist option");
-
-
filepath_sfinddef(respath, buf, "Print", "~/.netsurf/");
LOG(("Using '%s' as Print Settings file", buf));
print_options_file_location = strdup(buf);
diff --git a/monkey/Makefile.target b/monkey/Makefile.target
index b72734fe3..569837bac 100644
--- a/monkey/Makefile.target
+++ b/monkey/Makefile.target
@@ -8,26 +8,30 @@
# ----------------------------------------------------------------------------
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libdom libcss)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
-
- # define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
- NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
- NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
- NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
- NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
- NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
- NETSURF_FEATURE_WEBP_CFLAGS := -DWITH_WEBP
-
- # add a line similar to below for each optional pkg-configed lib here
- $(eval $(call pkg_config_find_and_add,NSSVG,libsvgtiny,SVG))
- $(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,Sprite))
- $(eval $(call pkg_config_find_and_add,BMP,libnsbmp,BMP))
- $(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF))
- $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG ))
-
- # no pkg-config for this library
- $(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp -lvpx,WebP (libwebp)))
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl libdom libcss)
+LDFLAGS += $(shell $(PKG_CONFIG) --libs openssl)
+
+# define additional CFLAGS and LDFLAGS requirements for pkg-configed libs here
+NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
+NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
+NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
+NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
+NETSURF_FEATURE_WEBP_CFLAGS := -DWITH_WEBP
+NETSURF_FEATURE_JS_CFLAGS := -DWITH_JS -DJS_HAS_FILE_OBJECT=0
+NETSURF_FEATURE_MOZJS_CFLAGS := -DWITH_MOZJS -DJS_HAS_FILE_OBJECT=0
+
+# add a line similar to below for each optional pkg-configed lib here
+$(eval $(call pkg_config_find_and_add,NSSVG,libsvgtiny,SVG))
+$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,Sprite))
+$(eval $(call pkg_config_find_and_add,BMP,libnsbmp,BMP))
+$(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF))
+$(eval $(call pkg_config_find_and_add,PNG,libpng,PNG ))
+$(eval $(call pkg_config_find_and_add,MOZJS,mozjs185,JavaScript))
+$(eval $(call pkg_config_find_and_add,JS,mozilla-js,JavaScript))
+
+# no pkg-config for this library
+$(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp -lvpx,WebP (libwebp)))
MONKEYCFLAGS := -std=c99 -Dmonkey -Dnsmonkey \
-D_BSD_SOURCE \
diff --git a/monkey/main.c b/monkey/main.c
index 45be754e1..03421ef03 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -91,6 +91,12 @@ static void quit_handler(int argc, char **argv)
netsurf_quit = true;
}
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+}
+
int
main(int argc, char **argv)
{
diff --git a/render/form.c b/render/form.c
index f60a2bad3..42e76e1f2 100644
--- a/render/form.c
+++ b/render/form.c
@@ -684,7 +684,7 @@ static char *form_url_encode(struct form *form,
{
char *name, *value;
char *s, *s2;
- unsigned int len, len1;
+ unsigned int len, len1, len_init;
url_func_result url_err;
if (query_string)
@@ -698,10 +698,10 @@ static char *form_url_encode(struct form *form,
if (query_string) {
s[0] = '?';
s[1] = '\0';
- len = 1;
+ len_init = len = 1;
} else {
s[0] = '\0';
- len = 0;
+ len_init = len = 0;
}
for (; control; control = control->next) {
@@ -737,7 +737,8 @@ static char *form_url_encode(struct form *form,
free(value);
}
- if (len)
+ if (len > len_init)
+ /* Replace trailing '&' */
s[len - 1] = '\0';
return s;
}
diff --git a/render/html.c b/render/html.c
index 09256a6fa..4e79e085e 100644
--- a/render/html.c
+++ b/render/html.c
@@ -113,13 +113,14 @@ static void html_box_convert_done(html_content *c, bool success)
LOG(("Done XML to box (%p)", c));
/* Clean up and report error if unsuccessful or aborted */
- if ((success == false) || c->aborted) {
+ if ((success == false) || (c->aborted)) {
+ if (success == false) {
+ msg_data.errorcode = NSERROR_BOX_CONVERT;
+ } else {
+ msg_data.errorcode = NSERROR_STOPPED;
+ }
html_destroy_objects(c);
- if (success == false)
- msg_data.error = messages_get("NoMemory");
- else
- msg_data.error = messages_get("Stopped");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data);
content_set_error(&c->base);
return;
}
@@ -134,19 +135,22 @@ static void html_box_convert_done(html_content *c, bool success)
exc = dom_document_get_document_element(c->document, (void *) &html);
if ((exc != DOM_NO_ERR) || (html == NULL)) {
+ /** @todo should this call html_destroy_objects(c);
+ * like the other error paths
+ */
LOG(("error retrieving html element from dom"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ msg_data.errorcode = NSERROR_DOM;
+ content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data);
content_set_error(&c->base);
return;
}
/* extract image maps - can't do this sensibly in xml_to_box */
- if (imagemap_extract(c) == false) {
+ msg_data.errorcode = imagemap_extract(c);
+ if (msg_data.errorcode != NSERROR_OK) {
LOG(("imagemap extraction failed"));
html_destroy_objects(c);
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data);
content_set_error(&c->base);
dom_node_unref(html);
return;
@@ -159,8 +163,9 @@ static void html_box_convert_done(html_content *c, bool success)
content_set_ready(&c->base);
- if (c->base.active == 0)
+ if (c->base.active == 0) {
content_set_done(&c->base);
+ }
html_set_status(c, "");
dom_node_unref(html);
@@ -413,9 +418,62 @@ html_create(const content_handler *handler,
return NSERROR_OK;
}
+static nserror
+parse_chunk_to_nserror(dom_hubbub_error error)
+{
+ switch (error) {
+ /* HUBBUB_REPROCESS is not handled here because it can
+ * never occur outside the hubbub treebuilder
+ */
-static bool
+ case DOM_HUBBUB_OK:
+ /* parsed ok */
+ return NSERROR_OK;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED):
+ /* hubbub input paused */
+ return NSERROR_OK;
+
+ case DOM_HUBBUB_NOMEM:
+ /* out of memory error from DOM */
+ return NSERROR_NOMEM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE):
+ /* encoding changed */
+ return NSERROR_ENCODING_CHANGE;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM):
+ /* out of memory error from parser */
+ return NSERROR_NOMEM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM):
+ return NSERROR_BAD_PARAMETER;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID):
+ return NSERROR_INVALID;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND):
+ return NSERROR_NOT_FOUND;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA):
+ return NSERROR_NEED_DATA;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING):
+ return NSERROR_BAD_ENCODING;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN):
+ /* currently only generated by the libdom hubbub binding */
+ default:
+ /* unknown error */
+ /** @todo better error handling and reporting */
+ return NSERROR_UNKNOWN;
+ }
+ return NSERROR_UNKNOWN;
+}
+
+
+static nserror
html_process_encoding_change(struct content *c,
const char *data,
unsigned int size)
@@ -425,34 +483,30 @@ html_process_encoding_change(struct content *c,
const char *encoding;
const char *source_data;
unsigned long source_size;
- union content_msg_data msg_data;
/* Retrieve new encoding */
encoding = dom_hubbub_parser_get_encoding(html->parser,
&html->encoding_source);
-
if (encoding == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
+ return NSERROR_NOMEM;
}
- if (html->encoding != NULL)
+ if (html->encoding != NULL) {
free(html->encoding);
+ }
html->encoding = strdup(encoding);
if (html->encoding == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
+ return NSERROR_NOMEM;
}
/* Destroy binding */
dom_hubbub_parser_destroy(html->parser);
html->parser = NULL;
- if (html->document != NULL)
+ if (html->document != NULL) {
dom_node_unref(html->document);
+ }
/* Create new binding, using the new encoding */
html->parser = dom_hubbub_parser_create(html->encoding,
@@ -468,9 +522,7 @@ html_process_encoding_change(struct content *c,
free(html->encoding);
html->encoding = strdup("Windows-1252");
if (html->encoding == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
+ return NSERROR_NOMEM;
}
html->parser = dom_hubbub_parser_create(html->encoding,
@@ -486,10 +538,7 @@ html_process_encoding_change(struct content *c,
* parser errors back instead of everything being
* OOM
*/
-
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
+ return NSERROR_NOMEM;
}
}
@@ -498,21 +547,16 @@ html_process_encoding_change(struct content *c,
/* Reprocess all the data. This is safe because
* the encoding is now specified at parser start which means
- * it cannot be changed again. */
- error = dom_hubbub_parser_parse_chunk(html->parser, (const uint8_t *)source_data, source_size);
-
- if ((error == DOM_HUBBUB_OK) ||
- (error == (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED))) {
- return true;
- }
-
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
-
- return false;
+ * it cannot be changed again.
+ */
+ error = dom_hubbub_parser_parse_chunk(html->parser,
+ (const uint8_t *)source_data,
+ source_size);
+ return parse_chunk_to_nserror(error);
}
+
/**
* Process data for CONTENT_HTML.
*/
@@ -524,21 +568,27 @@ html_process_data(struct content *c, const char *data, unsigned int size)
dom_hubbub_error error;
union content_msg_data msg_data;
- error = dom_hubbub_parser_parse_chunk(html->parser, (const uint8_t *) data, size);
+ msg_data.errorcode = NSERROR_OK; /* assume its all going to be ok */
- if ((error == DOM_HUBBUB_OK) ||
- (error == (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED))) {
- return true;
- } else if (error == (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE)) {
- return html_process_encoding_change(c, data, size);
- }
+ error = dom_hubbub_parser_parse_chunk(html->parser,
+ (const uint8_t *) data,
+ size);
- /** @todo better error handling and reporting */
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
-
+ msg_data.errorcode = parse_chunk_to_nserror(error);
+
+ /* deal with encoding change */
+ if (msg_data.errorcode == NSERROR_ENCODING_CHANGE) {
+ msg_data.errorcode = html_process_encoding_change(c, data, size);
+ }
+
+ /* broadcast the error if necessary */
+ if (msg_data.errorcode != NSERROR_OK) {
+ content_broadcast(c, CONTENT_MSG_ERRORCODE, msg_data);
+ return false;
+ }
+
+ return true;
}
diff --git a/render/imagemap.c b/render/imagemap.c
index bf90443c4..c41b86d0b 100644
--- a/render/imagemap.c
+++ b/render/imagemap.c
@@ -251,23 +251,25 @@ void imagemap_dump(html_content *c)
* \param map_str A dom_string which is "map"
* \return false on memory exhaustion, true otherwise
*/
-bool
+nserror
imagemap_extract(html_content *c)
{
dom_nodelist *nlist;
dom_exception exc;
unsigned long mapnr;
uint32_t maybe_maps;
-
+ nserror ret = NSERROR_OK;
+
exc = dom_document_get_elements_by_tag_name(c->document,
corestring_dom_map,
&nlist);
if (exc != DOM_NO_ERR) {
- return false;
+ return NSERROR_DOM;
}
exc = dom_nodelist_get_length(nlist, &maybe_maps);
if (exc != DOM_NO_ERR) {
+ ret = NSERROR_DOM;
goto out_nlist;
}
@@ -276,6 +278,7 @@ imagemap_extract(html_content *c)
dom_string *name;
exc = dom_nodelist_item(nlist, mapnr, &node);
if (exc != DOM_NO_ERR) {
+ ret = NSERROR_DOM;
goto out_nlist;
}
@@ -283,6 +286,7 @@ imagemap_extract(html_content *c)
&name);
if (exc != DOM_NO_ERR) {
dom_node_unref(node);
+ ret = NSERROR_DOM;
goto out_nlist;
}
@@ -292,6 +296,7 @@ imagemap_extract(html_content *c)
&name);
if (exc != DOM_NO_ERR) {
dom_node_unref(node);
+ ret = NSERROR_DOM;
goto out_nlist;
}
}
@@ -301,6 +306,7 @@ imagemap_extract(html_content *c)
if (imagemap_extract_map(node, c, &entry) == false) {
dom_string_unref(name);
dom_node_unref(node);
+ ret = NSERROR_NOMEM; /** @todo check this */
goto out_nlist;
}
@@ -313,6 +319,7 @@ imagemap_extract(html_content *c)
(imagemap_add(c, name, entry) == false)) {
dom_string_unref(name);
dom_node_unref(node);
+ ret = NSERROR_NOMEM; /** @todo check this */
goto out_nlist;
}
}
@@ -321,14 +328,12 @@ imagemap_extract(html_content *c)
dom_node_unref(node);
}
- dom_nodelist_unref(nlist);
-
- return true;
out_nlist:
dom_nodelist_unref(nlist);
- return false;
+
+ return ret;
}
/**
diff --git a/render/imagemap.h b/render/imagemap.h
index edbfea08f..d450cda86 100644
--- a/render/imagemap.h
+++ b/render/imagemap.h
@@ -28,7 +28,7 @@ struct hlcache_handle;
void imagemap_destroy(struct html_content *c);
void imagemap_dump(struct html_content *c);
-bool imagemap_extract(struct html_content *c);
+nserror imagemap_extract(struct html_content *c);
nsurl *imagemap_get(struct html_content *c, const char *key,
unsigned long x, unsigned long y,
diff --git a/riscos/font.c b/riscos/font.c
index ff9127c0b..717b9606c 100644
--- a/riscos/font.c
+++ b/riscos/font.c
@@ -76,6 +76,7 @@ void nsfont_init(void)
nsfont_check_fonts();
+ LOG(("Initialise RUfl"));
code = rufl_init();
if (code != rufl_OK) {
if (code == rufl_FONT_MANAGER_ERROR)
@@ -87,6 +88,7 @@ void nsfont_init(void)
die("The Unicode font library could not be initialized. "
"Please report this to the developers.");
}
+ LOG(("RUfl initialised"));
if (rufl_family_list_entries == 0)
die("No fonts could be found. At least one font must be "
diff --git a/riscos/gui.c b/riscos/gui.c
index 2926f63aa..93fc3db65 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -328,6 +328,47 @@ nsurl *gui_get_resource_url(const char *path)
return url;
}
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+ nsoption_setnull_charp(theme, strdup("Aletheia"));
+ nsoption_setnull_charp(toolbar_browser, strdup("0123|58|9"));
+ nsoption_setnull_charp(toolbar_hotlist, strdup("40|12|3"));
+ nsoption_setnull_charp(toolbar_history, strdup("0|12|3"));
+ nsoption_setnull_charp(toolbar_cookies, strdup("0|12"));
+ nsoption_setnull_charp(ca_bundle, strdup("NetSurf:Resources.ca-bundle"));
+ nsoption_setnull_charp(cookie_file, strdup("NetSurf:Cookies"));
+ nsoption_setnull_charp(cookie_jar, strdup(CHOICES_PREFIX "Cookies"));
+ nsoption_setnull_charp(url_path, strdup("NetSurf:URL"));
+ nsoption_setnull_charp(url_save, strdup(CHOICES_PREFIX "URL"));
+ nsoption_setnull_charp(hotlist_path, strdup("NetSurf:Hotlist"));
+ nsoption_setnull_charp(hotlist_save, strdup(CHOICES_PREFIX "Hotlist"));
+ nsoption_setnull_charp(recent_path, strdup("NetSurf:Recent"));
+ nsoption_setnull_charp(recent_save, strdup(CHOICES_PREFIX "Recent"));
+ nsoption_setnull_charp(theme_path, strdup("NetSurf:Themes"));
+ nsoption_setnull_charp(theme_save, strdup(CHOICES_PREFIX "Themes"));
+
+ if (nsoption_charp(theme) == NULL ||
+ nsoption_charp(toolbar_browser) == NULL ||
+ nsoption_charp(toolbar_hotlist) == NULL ||
+ nsoption_charp(toolbar_history) == NULL ||
+ nsoption_charp(toolbar_cookies) == NULL ||
+ nsoption_charp(ca_bundle) == NULL ||
+ nsoption_charp(cookie_file) == NULL ||
+ nsoption_charp(cookie_jar) == NULL ||
+ nsoption_charp(url_path) == NULL ||
+ nsoption_charp(url_save) == NULL ||
+ nsoption_charp(hotlist_path) == NULL ||
+ nsoption_charp(hotlist_save) == NULL ||
+ nsoption_charp(recent_path) == NULL ||
+ nsoption_charp(recent_save) == NULL ||
+ nsoption_charp(theme_path) == NULL ||
+ nsoption_charp(theme_save) == NULL) {
+ die("Failed initialising string options");
+ }
+}
+
/**
* Initialise the gui (RISC OS specific part).
*/
@@ -347,6 +388,7 @@ static void gui_init(int argc, char** argv)
int length;
char *nsdir_temp;
byte *base;
+ char *tree_icons_dir;
/* re-enable all FPU exceptions/traps except inexact operations,
* which we're not interested in, and underflow which is incorrectly
@@ -375,42 +417,11 @@ static void gui_init(int argc, char** argv)
ro_plot_patterned_lines = false;
}
- /* Set defaults for absent option strings */
- nsoption_setnull_charp(theme, strdup("Aletheia"));
- nsoption_setnull_charp(toolbar_browser, strdup("0123|58|9"));
- nsoption_setnull_charp(toolbar_hotlist, strdup("40|12|3"));
- nsoption_setnull_charp(toolbar_history, strdup("0|12|3"));
- nsoption_setnull_charp(toolbar_cookies, strdup("0|12"));
- nsoption_setnull_charp(ca_bundle, strdup("NetSurf:Resources.ca-bundle"));
- nsoption_setnull_charp(cookie_file, strdup("NetSurf:Cookies"));
- nsoption_setnull_charp(cookie_jar, strdup(CHOICES_PREFIX "Cookies"));
- nsoption_setnull_charp(url_path, strdup("NetSurf:URL"));
- nsoption_setnull_charp(url_save, strdup(CHOICES_PREFIX "URL"));
- nsoption_setnull_charp(hotlist_path, strdup("NetSurf:Hotlist"));
- nsoption_setnull_charp(hotlist_save, strdup(CHOICES_PREFIX "Hotlist"));
- nsoption_setnull_charp(recent_path, strdup("NetSurf:Recent"));
- nsoption_setnull_charp(recent_save, strdup(CHOICES_PREFIX "Recent"));
- nsoption_setnull_charp(theme_path, strdup("NetSurf:Themes"));
- nsoption_setnull_charp(theme_save, strdup(CHOICES_PREFIX "Themes"));
-
- tree_set_icon_dir(strdup("NetSurf:Resources.Icons"));
-
- if (nsoption_charp(theme) == NULL ||
- nsoption_charp(toolbar_browser) == NULL ||
- nsoption_charp(toolbar_hotlist) == NULL ||
- nsoption_charp(toolbar_history) == NULL ||
- nsoption_charp(ca_bundle) == NULL ||
- nsoption_charp(cookie_file) == NULL ||
- nsoption_charp(cookie_jar) == NULL ||
- nsoption_charp(url_path) == NULL ||
- nsoption_charp(url_save) == NULL ||
- nsoption_charp(hotlist_path) == NULL ||
- nsoption_charp(hotlist_save) == NULL ||
- nsoption_charp(recent_path) == NULL ||
- nsoption_charp(recent_save) == NULL ||
- nsoption_charp(theme_path) == NULL ||
- nsoption_charp(theme_save) == NULL)
+ tree_icons_dir = strdup("NetSurf:Resources.Icons");
+ if (tree_icons_dir == NULL)
die("Failed initialising string options");
+ tree_set_icon_dir(tree_icons_dir);
+
/* Create our choices directories */
ro_gui_create_dirs();
@@ -780,6 +791,8 @@ int main(int argc, char** argv)
setbuf(stderr, NULL);
+ /* Pass a NULL pointer for Messages path, because until the Choices
+ * are loaded in netsurf_init, we don't know the Messages path. */
netsurf_init(&argc, &argv, "NetSurf:Choices", NULL);
artworks_init();
@@ -794,7 +807,9 @@ int main(int argc, char** argv)
"NetSurf:Resources.%s.Messages",
nsoption_charp(language))) < 0 || length >= (int)sizeof(path))
die("Failed to locate Messages resource.");
+ /* We disabled core Messages load, so have to load them here */
messages_load(path);
+ /* Also load some extra RISC OS specific Messages */
messages_load("NetSurf:Resources.LangNames");
gui_init(argc, argv);
diff --git a/utils/errors.h b/utils/errors.h
index 546709703..9ad613da6 100644
--- a/utils/errors.h
+++ b/utils/errors.h
@@ -29,6 +29,8 @@
typedef enum {
NSERROR_OK, /**< No error */
+ NSERROR_UNKNOWN, /**< Unknown error - DO *NOT* USE */
+
NSERROR_NOMEM, /**< Memory exhaustion */
NSERROR_NO_FETCH_HANDLER, /**< No fetch handler for URL scheme */
@@ -47,7 +49,19 @@ typedef enum {
NSERROR_NEED_DATA, /**< More data needed */
- NSERROR_BAD_URL /**< More data needed */
+ NSERROR_ENCODING_CHANGE, /**< The character changed */
+
+ NSERROR_BAD_PARAMETER, /**< Bad Parameter */
+
+ NSERROR_INVALID, /**< Invalid data */
+
+ NSERROR_BOX_CONVERT, /**< Box conversion failed */
+
+ NSERROR_STOPPED, /**< Content conversion stopped */
+
+ NSERROR_DOM, /**< DOM call returned error */
+
+ NSERROR_BAD_URL /**< Bad URL */
} nserror;
#endif
diff --git a/utils/libdom.c b/utils/libdom.c
index 430a7e227..95f7254f9 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -31,7 +31,7 @@ bool libdom_treewalk(dom_node *root,
void *ctx)
{
dom_node *node;
- bool result = true;;
+ bool result = true;
node = dom_node_ref(root); /* tree root */
diff --git a/windows/main.c b/windows/main.c
index 6fbf40174..7d158660a 100644
--- a/windows/main.c
+++ b/windows/main.c
@@ -79,6 +79,15 @@ bool nslog_ensure(FILE *fptr)
return true;
}
+/* Documented in desktop/options.h */
+void gui_options_init_defaults(void)
+{
+ /* Set defaults for absent option strings */
+
+ /* ensure homepage option has a default */
+ nsoption_setnull_charp(homepage_url, strdup(NETSURF_HOMEPAGE));
+}
+
/**
* Entry point from operating system
**/
@@ -138,9 +147,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
nsws_window_init_pointers(hInstance);
- /* ensure homepage option has a default */
- nsoption_setnull_charp(homepage_url, strdup(NETSURF_HOMEPAGE));
-
/* If there is a url specified on the command line use it */
if (argc > 1) {
addr = argv[1];