diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-08-10 23:00:32 +0100 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-08-10 23:00:32 +0100 |
commit | 0210ef066b75da6ff2a91b5de9ad6d3f583548f2 (patch) | |
tree | ffd2a51466bc888c242d40ed7ebd2dcf030139a5 | |
parent | 69ad5db2d111b2af153ad63926ae5549c5dadb77 (diff) | |
parent | d6b293001d67e71e751b1d54e4a9dc8529cd29d6 (diff) | |
download | netsurf-0210ef066b75da6ff2a91b5de9ad6d3f583548f2.tar.gz netsurf-0210ef066b75da6ff2a91b5de9ad6d3f583548f2.tar.bz2 |
Merge branch 'master' of git://git.netsurf-browser.org/netsurf into chris/palette-mapped-plotters
36 files changed, 1781 insertions, 1070 deletions
diff --git a/Makefile.sources b/Makefile.sources index 95695f786..f7f05ca3a 100644 --- a/Makefile.sources +++ b/Makefile.sources @@ -31,7 +31,7 @@ S_DESKTOP := cookies.c history_global_core.c hotlist.c knockout.c \ # Javascript sources ifeq ($(NETSURF_USE_JS),YES) -S_JSAPI = window.c document.c navigator.c console.c +S_JSAPI = window.c document.c navigator.c console.c element.c S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI)) else S_JAVASCRIPT += none.c diff --git a/atari/settings.c b/atari/settings.c index 2106eb35c..b2a4bafdf 100644 --- a/atari/settings.c +++ b/atari/settings.c @@ -1,293 +1,295 @@ #include <sys/types.h>
-#include <sys/stat.h> -#include <dirent.h> +#include <sys/stat.h>
+#include <dirent.h>
#include <fcntl.h>
#include <time.h>
#include <limits.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
-#include <windom.h> - -#include "desktop/options.h" -#include "desktop/plot_style.h" -#include "atari/res/netsurf.rsh" -#include "atari/settings.h" -#include "atari/global_evnt.h" -#include "atari/misc.h" -#include "atari/plot/plot.h" -#include "atari/bitmap.h" -#include "atari/findfile.h" - -extern char options[PATH_MAX]; - -static OBJECT * dlgtree; -static WINDOW * dlgwin; - -static float tmp_option_memory_cache_size; -static float tmp_option_minimum_gif_delay; -static unsigned int tmp_option_expire_url; -static unsigned int tmp_option_font_min_size; -static unsigned int tmp_option_font_size; -static unsigned int tmp_option_min_reflow_period; -static unsigned int tmp_option_max_fetchers; -static unsigned int tmp_option_max_fetchers_per_host; -static unsigned int tmp_option_max_cached_fetch_handles; -static colour tmp_option_atari_toolbar_bg; - -/* Tab forms and their buttons: */ -static int frms[] = { - CHOICES_TAB_BROWSER, - CHOICES_TAB_RENDER, - CHOICES_TAB_STYLE, - CHOICES_TAB_NETWORK, - CHOICES_TAB_PATH, - CHOICES_TAB_CACHE -}; - -static int buts[] = { - CHOICES_REG_BROWSER, - CHOICES_REG_RENDER, - CHOICES_REG_STYLE, - CHOICES_REG_NETWORK, - CHOICES_REG_PATH, - CHOICES_REG_CACHE -}; - -#define OBJ_SELECTED(idx) ((dlgtree[idx].ob_state & SELECTED)!=0) -#define OBJ_CHECK(idx) SET_BIT(dlgtree[idx].ob_state, SELECTED, 1); -#define OBJ_UNCHECK(idx) SET_BIT(dlgtree[idx].ob_state, SELECTED, 0); - -#define DISABLE_OBJ(idx) SET_BIT(dlgtree[idx].ob_state, DISABLED, 1); \ - ObjcDraw( OC_FORM, dlgwin, idx, 1 ) - -#define ENABLE_OBJ(idx) SET_BIT(dlgtree[idx].ob_state, DISABLED, 0); \ - ObjcDraw( OC_FORM, dlgwin, idx, 1 ) - -#define FORMEVENT(idx) form_event( NULL, idx, 0, NULL ); - -#define INPUT_HOMEPAGE_URL_MAX_LEN 44 -#define INPUT_LOCALE_MAX_LEN 6 -#define INPUT_PROXY_HOST_MAX_LEN 31 -#define INPUT_PROXY_USERNAME_MAX_LEN 36 -#define INPUT_PROXY_PASSWORD_MAX_LEN 36 -#define INPUT_PROXY_PORT_MAX_LEN 5 -#define INPUT_MIN_REFLOW_PERIOD_MAX_LEN 4 -#define LABEL_FONT_RENDERER_MAX_LEN 8 -#define LABEL_PATH_MAX_LEN 43 -#define LABEL_ICONSET_MAX_LEN 8 -#define INPUT_TOOLBAR_COLOR_MAX_LEN 6 - -static void toggle_objects( void ); -static void display_settings( void ); -static void apply_settings( void ); -static void __CDECL onclose( WINDOW *win, short buff[8] ); -static void __CDECL - closeform( WINDOW *win, int index, int unused, void *unused2); -static void __CDECL - saveform( WINDOW *win, int index, int unused, void *unused2); -static void __CDECL - form_event( WINDOW *win, int index, int unused, void *unused2); -static void __CDECL - clear_history( WINDOW *win, int index, int unused, void *unused2); - - - -WINDOW * open_settings() -{ - - if( dlgtree == NULL){ - dlgtree = get_tree( CHOICES ); - if( dlgtree == NULL ){ - return( NULL ); - } - } - - if( dlgwin == NULL){ - // TODO: localize title +#include <windom.h>
+
+#include "desktop/options.h"
+#include "desktop/plot_style.h"
+#include "atari/res/netsurf.rsh"
+#include "atari/settings.h"
+#include "atari/global_evnt.h"
+#include "atari/misc.h"
+#include "atari/plot/plot.h"
+#include "atari/bitmap.h"
+#include "atari/findfile.h"
+
+extern char options[PATH_MAX];
+
+static OBJECT * dlgtree;
+static WINDOW * dlgwin;
+
+static float tmp_option_memory_cache_size;
+static float tmp_option_minimum_gif_delay;
+static unsigned int tmp_option_expire_url;
+static unsigned int tmp_option_font_min_size;
+static unsigned int tmp_option_font_size;
+static unsigned int tmp_option_min_reflow_period;
+static unsigned int tmp_option_max_fetchers;
+static unsigned int tmp_option_max_fetchers_per_host;
+static unsigned int tmp_option_max_cached_fetch_handles;
+static colour tmp_option_atari_toolbar_bg;
+
+/* Tab forms and their buttons: */
+static int frms[] = {
+ CHOICES_TAB_BROWSER,
+ CHOICES_TAB_RENDER,
+ CHOICES_TAB_STYLE,
+ CHOICES_TAB_NETWORK,
+ CHOICES_TAB_PATH,
+ CHOICES_TAB_CACHE
+};
+
+static int buts[] = {
+ CHOICES_REG_BROWSER,
+ CHOICES_REG_RENDER,
+ CHOICES_REG_STYLE,
+ CHOICES_REG_NETWORK,
+ CHOICES_REG_PATH,
+ CHOICES_REG_CACHE
+};
+
+#define OBJ_SELECTED(idx) ((dlgtree[idx].ob_state & SELECTED)!=0)
+#define OBJ_CHECK(idx) SET_BIT(dlgtree[idx].ob_state, SELECTED, 1);
+#define OBJ_UNCHECK(idx) SET_BIT(dlgtree[idx].ob_state, SELECTED, 0);
+
+#define DISABLE_OBJ(idx) SET_BIT(dlgtree[idx].ob_state, DISABLED, 1); \
+ ObjcDraw( OC_FORM, dlgwin, idx, 1 )
+
+#define ENABLE_OBJ(idx) SET_BIT(dlgtree[idx].ob_state, DISABLED, 0); \
+ ObjcDraw( OC_FORM, dlgwin, idx, 1 )
+
+#define FORMEVENT(idx) form_event( NULL, idx, 0, NULL );
+
+#define INPUT_HOMEPAGE_URL_MAX_LEN 44
+#define INPUT_LOCALE_MAX_LEN 6
+#define INPUT_PROXY_HOST_MAX_LEN 31
+#define INPUT_PROXY_USERNAME_MAX_LEN 36
+#define INPUT_PROXY_PASSWORD_MAX_LEN 36
+#define INPUT_PROXY_PORT_MAX_LEN 5
+#define INPUT_MIN_REFLOW_PERIOD_MAX_LEN 4
+#define LABEL_FONT_RENDERER_MAX_LEN 8
+#define LABEL_PATH_MAX_LEN 43
+#define LABEL_ICONSET_MAX_LEN 8
+#define INPUT_TOOLBAR_COLOR_MAX_LEN 6
+
+static void toggle_objects( void );
+static void display_settings( void );
+static void apply_settings( void );
+static void __CDECL onclose( WINDOW *win, short buff[8] );
+static void __CDECL
+ closeform( WINDOW *win, int index, int unused, void *unused2);
+static void __CDECL
+ saveform( WINDOW *win, int index, int unused, void *unused2);
+static void __CDECL
+ form_event( WINDOW *win, int index, int unused, void *unused2);
+static void __CDECL
+ clear_history( WINDOW *win, int index, int unused, void *unused2);
+
+
+
+WINDOW * open_settings()
+{
+
+ if( dlgtree == NULL){
+ dlgtree = get_tree(CHOICES);
+ if( dlgtree == NULL ){
+ return( NULL );
+ }
+ }
+
+ if( dlgwin == NULL){
+ // TODO: localize title
dlgwin = FormCreate( dlgtree, WAT_FORM, NULL, (char*)"Settings",
- NULL, TRUE, FALSE); - if( !dlgwin ){ - return( NULL ); - } - FormThumb( dlgwin, frms, buts, sizeof(frms) / sizeof(int) ); - - /* Atach events to dialog buttons: */ + NULL, TRUE, 1);
+ if( !dlgwin ){
+ return( NULL );
+ }
+ FormThumb( dlgwin, frms, buts, sizeof(frms) / sizeof(int) );
+
+ /* Atach events to dialog buttons: */
ObjcAttachFormFunc( dlgwin, CHOICES_ABORT, closeform, NULL);
- ObjcAttachFormFunc( dlgwin, CHOICES_OK, saveform, NULL); - - /* Connect interactive dialog elements to generic event handler: */ - ObjcAttachFormFunc( dlgwin, CHOICES_CB_USE_PROXY, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_CB_PROXY_AUTH, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_DOWNLOAD_PATH, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_HOTLIST_FILE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_CA_BUNDLE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_CA_CERTS_PATH, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_EDITOR, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_GIF_DELAY, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_GIF_DELAY, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_INCREMENTAL_REFLOW, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_INCREMENTAL_REFLOW, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_CACHED_CONNECTIONS, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_CACHED_CONNECTIONS, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_MAX_FETCHERS_PER_HOST, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MAX_FETCHERS_PER_HOST, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MAX_FETCHERS, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_MAX_FETCHERS, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_DEF_FONT_SIZE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_DEF_FONT_SIZE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_MIN_FONT_SIZE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MIN_FONT_SIZE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_MEM_CACHE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MEM_CACHE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INC_HISTORY_AGE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_DEC_HISTORY_AGE, form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_BT_SEL_FONT_RENDERER, - form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_BT_SEL_LOCALE, - form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_INPUT_TOOLBAR_BGCOLOR, - form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_BT_TOOLBAR_ICONSET, - form_event, NULL); - ObjcAttachFormFunc( dlgwin, CHOICES_BT_CLEAR_HISTORY, - clear_history, NULL); - - EvntAdd( dlgwin, WM_CLOSED, onclose, EV_TOP ); - display_settings(); - - } else { - WindTop( dlgwin ); - toggle_objects(); - } - return( dlgwin ); -} - -void close_settings(void) -{ - if( dlgwin != NULL ){ - WindClose( dlgwin ); - dlgwin = NULL; - } - -} - -static void set_text( short idx, char * text, int len ) -{ - char spare[255]; - - if( len > 254 ) - len = 254; - if( text != NULL ){ - strncpy( spare, text, 254); - ObjcStrFmt( spare, text, len ); - } else { - strcpy(spare, ""); - } - ObjcStrCpy( dlgtree, idx, spare ); - -} - - -static void __CDECL onclose( WINDOW *win, short buff[8] ) + ObjcAttachFormFunc( dlgwin, CHOICES_OK, saveform, NULL);
+
+ /* Connect interactive dialog elements to generic event handler: */
+ ObjcAttachFormFunc( dlgwin, CHOICES_CB_USE_PROXY, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_CB_PROXY_AUTH, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_DOWNLOAD_PATH, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_HOTLIST_FILE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_CA_BUNDLE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_CA_CERTS_PATH, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_EDIT_EDITOR, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INC_GIF_DELAY, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_DEC_GIF_DELAY, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INC_INCREMENTAL_REFLOW, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_DEC_INCREMENTAL_REFLOW, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INC_CACHED_CONNECTIONS, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_DEC_CACHED_CONNECTIONS, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INC_MAX_FETCHERS_PER_HOST, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MAX_FETCHERS_PER_HOST, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MAX_FETCHERS, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INC_MAX_FETCHERS, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INC_DEF_FONT_SIZE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_DEC_DEF_FONT_SIZE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INC_MIN_FONT_SIZE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MIN_FONT_SIZE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INC_MEM_CACHE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_DEC_MEM_CACHE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INC_HISTORY_AGE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_DEC_HISTORY_AGE, form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_BT_SEL_FONT_RENDERER,
+ form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_BT_SEL_LOCALE,
+ form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_INPUT_TOOLBAR_BGCOLOR,
+ form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_BT_TOOLBAR_ICONSET,
+ form_event, NULL);
+ ObjcAttachFormFunc( dlgwin, CHOICES_BT_CLEAR_HISTORY,
+ clear_history, NULL);
+
+ EvntAdd( dlgwin, WM_CLOSED, onclose, EV_TOP );
+ display_settings();
+
+ } else {
+ WindTop( dlgwin );
+ toggle_objects();
+ }
+ return( dlgwin );
+}
+
+void close_settings(void)
+{
+ if( dlgwin != NULL ){
+ /* Duplicated form tree must be free'd manualy? */
+ ObjcFree(ObjcTree(OC_FORM, dlgwin));
+ WindClose(dlgwin);
+ dlgwin = NULL;
+ }
+
+}
+
+static void set_text( short idx, char * text, int len )
+{
+ char spare[255];
+
+ if( len > 254 )
+ len = 254;
+ if( text != NULL ){
+ strncpy( spare, text, 254);
+ ObjcStrFmt( spare, text, len );
+ } else {
+ strcpy(spare, "");
+ }
+ ObjcStrCpy( dlgtree, idx, spare );
+
+}
+
+
+static void __CDECL onclose( WINDOW *win, short buff[8] )
{
- dlgwin = NULL;
-} - -static void __CDECL -closeform( WINDOW *win, int index, int unused, void *unused2) + close_settings();
+}
+
+static void __CDECL
+closeform( WINDOW *win, int index, int unused, void *unused2)
{
- ObjcChange( OC_FORM, win, index, ~SELECTED, TRUE); + ObjcChange( OC_FORM, win, index, ~SELECTED, TRUE);
close_settings();
-} - -static void __CDECL -saveform( WINDOW *win, int index, int unused, void *unused2) -{ +}
+
+static void __CDECL
+saveform( WINDOW *win, int index, int unused, void *unused2)
+{
apply_settings();
- // Save settings - nsoption_write( (const char*)&options ); - nsoption_read( (const char*)&options ); - close_settings(); - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - form_alert(1, "[1][Some options require an netsurf restart!][OK]"); - main_menu_update(); -} - -static void __CDECL clear_history( WINDOW *win, int index, int unused, - void *unused2) + // Save settings
+ nsoption_write( (const char*)&options );
+ nsoption_read( (const char*)&options );
+ close_settings();
+ ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
+ form_alert(1, "[1][Some options require an netsurf restart!][OK]");
+ main_menu_update();
+}
+
+static void __CDECL clear_history( WINDOW *win, int index, int unused,
+ void *unused2)
{
-} - - -static colour color_popup(int x, int y, colour current) -{ -#define GRID_ROWS 9 -#define GRID_COLS 27 - colour retval = current; - int boxwidth=6, boxheight=8; - struct bitmap *palette_img; - MFDB bg, screen; - GRECT bgarea = {x, y, GRID_COLS*boxwidth+4, GRID_ROWS*boxheight+4}; - short web_std_colors[6] = {0, 51, 102, 153, 204, 255}; - int r,g,b; - int xpos = 0, ypos = 0; - colour palette[216+8]; - int i=0; - - plot_style_t drawcolour = { - .stroke_type = PLOT_OP_TYPE_NONE, - .fill_type = PLOT_OP_TYPE_SOLID, - .fill_colour = 0 - }; - - plot_style_t outline = { - .stroke_type = PLOT_OP_TYPE_SOLID, - .stroke_colour = 0xAAAAAA, - .stroke_width = 2, - .fill_type = PLOT_OP_TYPE_NONE, - .fill_colour = 0 - }; - - /* create a palette array (web colors): */ - for (r=0; r<6; r++) { - for (g=0; g<6; g++) { - for (b=0; b<6; b++) { - palette[i] = ((web_std_colors[b]<<16) - | (web_std_colors[g]<<8) - | web_std_colors[r]); - i++; - } - } - } - - /* setup the gray color values: */ - int z = 0; - colour grays[15] = {0x111111, 0x222222, 0x333333, 0x444444, - 0x555555, 0x666666, 0x777777, 0x888888, - 0x999999, 0x999999, 0xAAAAAA, 0xBBBBBB, - 0xCCCCCC, 0xDDDDDD, 0xEEEEEE}; - for (z=0;i<243;i++) { - if (z<15) - palette[i] = grays[z]; - else - palette[i] = 0x000000; - z++; - } - +}
+
+
+static colour color_popup(int x, int y, colour current)
+{
+#define GRID_ROWS 9
+#define GRID_COLS 27
+ colour retval = current;
+ int boxwidth=6, boxheight=8;
+ struct bitmap *palette_img;
+ MFDB bg, screen;
+ GRECT bgarea = {x, y, GRID_COLS*boxwidth+4, GRID_ROWS*boxheight+4};
+ short web_std_colors[6] = {0, 51, 102, 153, 204, 255};
+ int r,g,b;
+ int xpos = 0, ypos = 0;
+ colour palette[216+8];
+ int i=0;
+
+ plot_style_t drawcolour = {
+ .stroke_type = PLOT_OP_TYPE_NONE,
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = 0
+ };
+
+ plot_style_t outline = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = 0xAAAAAA,
+ .stroke_width = 2,
+ .fill_type = PLOT_OP_TYPE_NONE,
+ .fill_colour = 0
+ };
+
+ /* create a palette array (web colors): */
+ for (r=0; r<6; r++) {
+ for (g=0; g<6; g++) {
+ for (b=0; b<6; b++) {
+ palette[i] = ((web_std_colors[b]<<16)
+ | (web_std_colors[g]<<8)
+ | web_std_colors[r]);
+ i++;
+ }
+ }
+ }
+
+ /* setup the gray color values: */
+ int z = 0;
+ colour grays[15] = {0x111111, 0x222222, 0x333333, 0x444444,
+ 0x555555, 0x666666, 0x777777, 0x888888,
+ 0x999999, 0x999999, 0xAAAAAA, 0xBBBBBB,
+ 0xCCCCCC, 0xDDDDDD, 0xEEEEEE};
+ for (z=0;i<243;i++) {
+ if (z<15)
+ palette[i] = grays[z];
+ else
+ palette[i] = 0x000000;
+ z++;
+ }
+
/* hide the mouse */
- v_hide_c (app.graf.handle); - - plot_set_dimensions(x, y, - (GRID_COLS*boxwidth)+4, (GRID_ROWS*boxheight)+4); - plot_lock(); - - // store background: + v_hide_c (app.graf.handle);
+
+ plot_set_dimensions(x, y,
+ (GRID_COLS*boxwidth)+4, (GRID_ROWS*boxheight)+4);
+ plot_lock();
+
+ // store background:
short pxy[8];
init_mfdb(app.nplanes, bgarea.g_w, bgarea.g_h, 0, &bg);
- init_mfdb(0, bgarea.g_w, bgarea.g_h, 0, &screen); - + init_mfdb(0, bgarea.g_w, bgarea.g_h, 0, &screen);
+
pxy[0] = bgarea.g_x;
pxy[1] = bgarea.g_y;
pxy[2] = bgarea.g_x + bgarea.g_w - 1;
@@ -298,648 +300,648 @@ static colour color_popup(int x, int y, colour current) pxy[7] = bgarea.g_h - 1;
/* copy screen image */
- vro_cpyfm (app.graf.handle, S_ONLY, pxy, &screen, &bg); - - /* - plot_rectangle(x+1, y+1, x+(GRID_COLS*boxwidth)+3, - y+(GRID_ROWS*boxheight)+3, &outline); - - plot_line(x, y, x+(GRID_COLS*boxwidth)+2, y+(GRID_ROWS*boxheight)+2, - &outline); - */ - plot_line(x, y, x+(GRID_COLS*boxwidth)+2, y, - &outline); - - plot_line(x, y+(GRID_ROWS*boxheight)+2, x+(GRID_COLS*boxwidth)+2, - y+(GRID_ROWS*boxheight)+2, - &outline); - - /* draw a 27*8 grid: */ - for (i=0; i<243; i++){ - drawcolour.fill_colour = palette[i]; - plot_rectangle(xpos+2, ypos+2, xpos+boxwidth+2, ypos+boxheight+2, - &drawcolour); - xpos += boxwidth; - if (xpos >= GRID_COLS*boxwidth) { - xpos = 0; - ypos += boxheight; - } - } - + vro_cpyfm (app.graf.handle, S_ONLY, pxy, &screen, &bg);
+
+ /*
+ plot_rectangle(x+1, y+1, x+(GRID_COLS*boxwidth)+3,
+ y+(GRID_ROWS*boxheight)+3, &outline);
+
+ plot_line(x, y, x+(GRID_COLS*boxwidth)+2, y+(GRID_ROWS*boxheight)+2,
+ &outline);
+ */
+ plot_line(x, y, x+(GRID_COLS*boxwidth)+2, y,
+ &outline);
+
+ plot_line(x, y+(GRID_ROWS*boxheight)+2, x+(GRID_COLS*boxwidth)+2,
+ y+(GRID_ROWS*boxheight)+2,
+ &outline);
+
+ /* draw a 27*8 grid: */
+ for (i=0; i<243; i++){
+ drawcolour.fill_colour = palette[i];
+ plot_rectangle(xpos+2, ypos+2, xpos+boxwidth+2, ypos+boxheight+2,
+ &drawcolour);
+ xpos += boxwidth;
+ if (xpos >= GRID_COLS*boxwidth) {
+ xpos = 0;
+ ypos += boxheight;
+ }
+ }
+
/* restore the mouse */
- v_show_c ( app.graf.handle, 1); - - /* fetch mouse event: */ - mt_EvntDisable(&app, dlgwin, WM_XBUTTON); - EvntWindom(MU_BUTTON); - mt_EvntEnable(&app, dlgwin, WM_XBUTTON); - - /* calulate clicked grid coords: */ - int row = ((evnt.my-y)/boxheight); - int col = ((evnt.mx-x)/boxwidth); - - if (row >= 0 && row <= GRID_ROWS-1 && col >= 0 && col <= GRID_COLS-1) { - assert( (GRID_COLS*row)+(col) >= 0 ); - assert( (GRID_COLS*row)+(col) < 243 ); - retval = palette[(GRID_COLS*row)+(col)]; - } - - /* restore background: */ - w_put_bkgr(&app, bgarea.g_x, bgarea.g_y, bgarea.g_w, bgarea.g_h, &bg); - free(bg.fd_addr); - - plot_unlock(); - -#undef GRID_COLS -#undef GRID_ROWS - - return(retval); -} - -/** -* Displays a popup to select available icon sets, - the returned string is no longer than 8 characters. -* \param x x pos of popup -* \param y y pos of popup -* \return the selected string or NULL on failure. -*/ -static char * toolbar_iconset_popup( int x, int y ) -{ - #define MAX_SETS 24 - DIR *dp; - struct dirent *ep; - struct stat statbuf; - char * current = NULL; - char *avail[MAX_SETS]; - int selected = 0, navail = 0, i, choice=-1; - static char toolbar_folder[PATH_MAX]; - char fullpath[PATH_MAX]; - - strncpy( fullpath, nsoption_charp(tree_icons_path), 255 ); - path_add_part( fullpath, 255, "toolbar/" ); - - /* Get current set (for pre-selection): */ - memset( avail, 0, MAX_SETS ); - current = nsoption_charp(atari_image_toolbar_folder); - - /* locate the toolbar folder: */ - atari_find_resource( toolbar_folder, fullpath, fullpath ); - - /* search for iconset folders: */ - dp = opendir (toolbar_folder); - if (dp != NULL){ - while (ep = readdir (dp)) { - if (strlen(ep->d_name) < 3) - continue; - snprintf(fullpath, PATH_MAX-1, "%s/%s", toolbar_folder, ep->d_name ); - if (stat(fullpath, &statbuf) == 0) { - if (S_ISDIR(statbuf.st_mode)) { - if (strcmp(ep->d_name, current) == 0) - selected = navail; - /* store the folder name: */ - avail[navail] = malloc( strlen(ep->d_name)+1 ); - sprintf( avail[navail], "%s", ep->d_name ); - navail++; - if( navail >= MAX_SETS ) - break; - } - } - } - (void) closedir (dp); - } - - - if (navail > 0){ - choice = MenuPopUp( avail, x, y, navail, - -1, selected, P_LIST | P_CHCK ); - if (choice > 0) - snprintf( toolbar_folder, 9, "%s", avail[choice-1] ); - } - - for (i=0;i<navail; i++ ) { - free( avail[i] ); - } - if (choice > 0) - return( toolbar_folder ); - else - return( NULL ); - #undef MAX_SETS -} - -static void __CDECL -form_event( WINDOW *win, int index, int external, void *unused2) -{ - char spare[255]; - bool is_button = false; - bool checked = OBJ_SELECTED( index ); - char * tmp; - - /* For font driver popup: */ - const char *font_driver_items[] = {"freetype", "internal" }; - int num_font_drivers = (sizeof(font_driver_items)/sizeof(char*)); - - /* - Just a small collection of locales, each country has at least one - ATARI-clone user! :) - */ - const char *locales[] = { - "cs", "de", "de-de" , "en", "en-gb", "en-us", "es", - "fr", "it", "nl", "no", "pl", "ru", "sk", "sv" - }; + v_show_c ( app.graf.handle, 1);
+
+ /* fetch mouse event: */
+ mt_EvntDisable(&app, dlgwin, WM_XBUTTON);
+ EvntWindom(MU_BUTTON);
+ mt_EvntEnable(&app, dlgwin, WM_XBUTTON);
+
+ /* calulate clicked grid coords: */
+ int row = ((evnt.my-y)/boxheight);
+ int col = ((evnt.mx-x)/boxwidth);
+
+ if (row >= 0 && row <= GRID_ROWS-1 && col >= 0 && col <= GRID_COLS-1) {
+ assert( (GRID_COLS*row)+(col) >= 0 );
+ assert( (GRID_COLS*row)+(col) < 243 );
+ retval = palette[(GRID_COLS*row)+(col)];
+ }
+
+ /* restore background: */
+ w_put_bkgr(&app, bgarea.g_x, bgarea.g_y, bgarea.g_w, bgarea.g_h, &bg);
+ free(bg.fd_addr);
+
+ plot_unlock();
+
+#undef GRID_COLS
+#undef GRID_ROWS
+
+ return(retval);
+}
+
+/**
+* Displays a popup to select available icon sets,
+ the returned string is no longer than 8 characters.
+* \param x x pos of popup
+* \param y y pos of popup
+* \return the selected string or NULL on failure.
+*/
+static char * toolbar_iconset_popup( int x, int y )
+{
+ #define MAX_SETS 24
+ DIR *dp;
+ struct dirent *ep;
+ struct stat statbuf;
+ char * current = NULL;
+ char *avail[MAX_SETS];
+ int selected = 0, navail = 0, i, choice=-1;
+ static char toolbar_folder[PATH_MAX];
+ char fullpath[PATH_MAX];
+
+ strncpy( fullpath, nsoption_charp(tree_icons_path), 255 );
+ path_add_part( fullpath, 255, "toolbar/" );
+
+ /* Get current set (for pre-selection): */
+ memset( avail, 0, MAX_SETS );
+ current = nsoption_charp(atari_image_toolbar_folder);
+
+ /* locate the toolbar folder: */
+ atari_find_resource( toolbar_folder, fullpath, fullpath );
+
+ /* search for iconset folders: */
+ dp = opendir (toolbar_folder);
+ if (dp != NULL){
+ while (ep = readdir (dp)) {
+ if (strlen(ep->d_name) < 3)
+ continue;
+ snprintf(fullpath, PATH_MAX-1, "%s/%s", toolbar_folder, ep->d_name );
+ if (stat(fullpath, &statbuf) == 0) {
+ if (S_ISDIR(statbuf.st_mode)) {
+ if (strcmp(ep->d_name, current) == 0)
+ selected = navail;
+ /* store the folder name: */
+ avail[navail] = malloc( strlen(ep->d_name)+1 );
+ sprintf( avail[navail], "%s", ep->d_name );
+ navail++;
+ if( navail >= MAX_SETS )
+ break;
+ }
+ }
+ }
+ (void) closedir (dp);
+ }
+
+
+ if (navail > 0){
+ choice = MenuPopUp( avail, x, y, navail,
+ -1, selected, P_LIST | P_CHCK );
+ if (choice > 0)
+ snprintf( toolbar_folder, 9, "%s", avail[choice-1] );
+ }
+
+ for (i=0;i<navail; i++ ) {
+ free( avail[i] );
+ }
+ if (choice > 0)
+ return( toolbar_folder );
+ else
+ return( NULL );
+ #undef MAX_SETS
+}
+
+static void __CDECL
+form_event( WINDOW *win, int index, int external, void *unused2)
+{
+ char spare[255];
+ bool is_button = false;
+ bool checked = OBJ_SELECTED( index );
+ char * tmp;
+
+ /* For font driver popup: */
+ const char *font_driver_items[] = {"freetype", "internal" };
+ int num_font_drivers = (sizeof(font_driver_items)/sizeof(char*));
+
+ /*
+ Just a small collection of locales, each country has at least one
+ ATARI-clone user! :)
+ */
+ const char *locales[] = {
+ "cs", "de", "de-de" , "en", "en-gb", "en-us", "es",
+ "fr", "it", "nl", "no", "pl", "ru", "sk", "sv"
+ };
int num_locales = (sizeof(locales)/sizeof(char*));
short x, y;
- int choice; - - switch( index ){ - - case CHOICES_CB_USE_PROXY: - if( checked ){ - ENABLE_OBJ( CHOICES_EDIT_PROXY_HOST ); - ENABLE_OBJ( CHOICES_CB_PROXY_AUTH ); - } - else { - DISABLE_OBJ( CHOICES_EDIT_PROXY_HOST ); - DISABLE_OBJ( CHOICES_CB_PROXY_AUTH ); - } - FORMEVENT( CHOICES_CB_PROXY_AUTH ); - break; - - case CHOICES_CB_PROXY_AUTH: - if( checked && OBJ_SELECTED( CHOICES_CB_USE_PROXY ) ){ - ENABLE_OBJ(CHOICES_EDIT_PROXY_USERNAME); - ENABLE_OBJ(CHOICES_EDIT_PROXY_PASSWORD); - } - else { - DISABLE_OBJ(CHOICES_EDIT_PROXY_USERNAME); - DISABLE_OBJ(CHOICES_EDIT_PROXY_PASSWORD); - } - break; - - case CHOICES_CB_ENABLE_ANIMATION: - if( checked ){ - ENABLE_OBJ( CHOICES_EDIT_MIN_GIF_DELAY ); - } - else { - DISABLE_OBJ( CHOICES_EDIT_MIN_GIF_DELAY ); - } - break; - - case CHOICES_BT_SEL_FONT_RENDERER: - if( external ){ + int choice;
+
+ switch( index ){
+
+ case CHOICES_CB_USE_PROXY:
+ if( checked ){
+ ENABLE_OBJ( CHOICES_EDIT_PROXY_HOST );
+ ENABLE_OBJ( CHOICES_CB_PROXY_AUTH );
+ }
+ else {
+ DISABLE_OBJ( CHOICES_EDIT_PROXY_HOST );
+ DISABLE_OBJ( CHOICES_CB_PROXY_AUTH );
+ }
+ FORMEVENT( CHOICES_CB_PROXY_AUTH );
+ break;
+
+ case CHOICES_CB_PROXY_AUTH:
+ if( checked && OBJ_SELECTED( CHOICES_CB_USE_PROXY ) ){
+ ENABLE_OBJ(CHOICES_EDIT_PROXY_USERNAME);
+ ENABLE_OBJ(CHOICES_EDIT_PROXY_PASSWORD);
+ }
+ else {
+ DISABLE_OBJ(CHOICES_EDIT_PROXY_USERNAME);
+ DISABLE_OBJ(CHOICES_EDIT_PROXY_PASSWORD);
+ }
+ break;
+
+ case CHOICES_CB_ENABLE_ANIMATION:
+ if( checked ){
+ ENABLE_OBJ( CHOICES_EDIT_MIN_GIF_DELAY );
+ }
+ else {
+ DISABLE_OBJ( CHOICES_EDIT_MIN_GIF_DELAY );
+ }
+ break;
+
+ case CHOICES_BT_SEL_FONT_RENDERER:
+ if( external ){
objc_offset( FORM(win), CHOICES_BT_SEL_FONT_RENDERER, &x, &y);
- choice = MenuPopUp ( font_driver_items, x, y, - num_font_drivers, + choice = MenuPopUp ( font_driver_items, x, y,
+ num_font_drivers,
-1, -1, P_LIST + P_WNDW + P_CHCK );
- if( choice > 0 && - choice <= num_font_drivers ){ - ObjcStrCpy( dlgtree, CHOICES_BT_SEL_FONT_RENDERER, - (char*)font_driver_items[choice-1] ); - } - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - } - tmp = ObjcString( dlgtree, CHOICES_BT_SEL_FONT_RENDERER, NULL); - if( strcmp(tmp, "freetype") == 0 ){ - ENABLE_OBJ( CHOICES_CB_ANTI_ALIASING ); - } else { - DISABLE_OBJ( CHOICES_CB_ANTI_ALIASING ); - } - break; - - case CHOICES_BT_SEL_LOCALE: - objc_offset( FORM(win), CHOICES_BT_SEL_LOCALE, &x, &y); - choice = MenuPopUp ( locales, x, y, - num_locales, + if( choice > 0 &&
+ choice <= num_font_drivers ){
+ ObjcStrCpy( dlgtree, CHOICES_BT_SEL_FONT_RENDERER,
+ (char*)font_driver_items[choice-1] );
+ }
+ ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
+ }
+ tmp = ObjcString( dlgtree, CHOICES_BT_SEL_FONT_RENDERER, NULL);
+ if( strcmp(tmp, "freetype") == 0 ){
+ ENABLE_OBJ( CHOICES_CB_ANTI_ALIASING );
+ } else {
+ DISABLE_OBJ( CHOICES_CB_ANTI_ALIASING );
+ }
+ break;
+
+ case CHOICES_BT_SEL_LOCALE:
+ objc_offset( FORM(win), CHOICES_BT_SEL_LOCALE, &x, &y);
+ choice = MenuPopUp ( locales, x, y,
+ num_locales,
-1, -1, P_LIST + P_WNDW + P_CHCK );
- if( choice > 0 && choice <= num_locales ){ - ObjcStrCpy( dlgtree, CHOICES_BT_SEL_LOCALE, - (char*)locales[choice-1] ); - } - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - break; - - case CHOICES_INPUT_TOOLBAR_BGCOLOR: - objc_offset( FORM(win), CHOICES_INPUT_TOOLBAR_BGCOLOR, &x, &y ); - choice = color_popup(x, y, tmp_option_atari_toolbar_bg); - snprintf( spare, 255, "%06x", choice ); - tmp_option_atari_toolbar_bg = choice; - ObjcStrCpy( dlgtree, CHOICES_INPUT_TOOLBAR_BGCOLOR, - spare ); - is_button = true; - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_INPUT_TOOLBAR_BGCOLOR, 2, 1 ); - break; - - case CHOICES_BT_TOOLBAR_ICONSET: - objc_offset( FORM(win), CHOICES_BT_TOOLBAR_ICONSET, &x, &y ); - tmp = toolbar_iconset_popup(x,y); - if( tmp != NULL ){ - ObjcStrCpy( dlgtree, CHOICES_BT_TOOLBAR_ICONSET, tmp ); - } - is_button = true; - ObjcChange( OC_FORM, win, index, NORMAL, TRUE); - break; - - case CHOICES_INC_MEM_CACHE: - case CHOICES_DEC_MEM_CACHE: - if( index == CHOICES_DEC_MEM_CACHE ) - tmp_option_memory_cache_size -= 0.1; - else - tmp_option_memory_cache_size += 0.1; - - if( tmp_option_memory_cache_size < 0.5 ) - tmp_option_memory_cache_size = 0.5; - if( tmp_option_memory_cache_size > 999.9 ) - tmp_option_memory_cache_size = 999.9; - snprintf( spare, 255, "%03.1f", tmp_option_memory_cache_size ); - set_text( CHOICES_STR_MAX_MEM_CACHE, spare, 5 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_STR_MAX_MEM_CACHE, 2, 1 ); - break; - - case CHOICES_INC_CACHED_CONNECTIONS: - case CHOICES_DEC_CACHED_CONNECTIONS: - if( index == CHOICES_INC_CACHED_CONNECTIONS ) - tmp_option_max_cached_fetch_handles += 1; - else - tmp_option_max_cached_fetch_handles -= 1; - if( tmp_option_max_cached_fetch_handles > 31 ) - tmp_option_max_cached_fetch_handles = 31; - - snprintf( spare, 255, "%02d", tmp_option_max_cached_fetch_handles ); - set_text( CHOICES_EDIT_MAX_CACHED_CONNECTIONS, spare, 2 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MAX_CACHED_CONNECTIONS, - 2, 1 ); - break; - - case CHOICES_INC_MAX_FETCHERS: - case CHOICES_DEC_MAX_FETCHERS: - if( index == CHOICES_INC_MAX_FETCHERS ) - tmp_option_max_fetchers += 1; - else - tmp_option_max_fetchers -= 1; - if( tmp_option_max_fetchers > 31 ) - tmp_option_max_fetchers = 31; - - snprintf( spare, 255, "%02d", tmp_option_max_fetchers ); - set_text( CHOICES_EDIT_MAX_FETCHERS, spare, 2 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MAX_FETCHERS, - 3, 1 ); - break; - - case CHOICES_INC_MAX_FETCHERS_PER_HOST: - case CHOICES_DEC_MAX_FETCHERS_PER_HOST: - if( index == CHOICES_INC_MAX_FETCHERS_PER_HOST ) - tmp_option_max_fetchers_per_host += 1; - else - tmp_option_max_fetchers_per_host -= 1; - if( tmp_option_max_fetchers_per_host > 31 ) - tmp_option_max_fetchers_per_host = 31; - - snprintf( spare, 255, "%02d", tmp_option_max_fetchers_per_host ); - set_text( CHOICES_EDIT_MAX_FETCHERS_PER_HOST, spare, 2 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MAX_FETCHERS_PER_HOST, - 2, 1 ); - break; - - case CHOICES_INC_HISTORY_AGE: - case CHOICES_DEC_HISTORY_AGE: - if( index == CHOICES_INC_HISTORY_AGE ) - tmp_option_expire_url += 1; - else - tmp_option_expire_url -= 1; - - if( tmp_option_expire_url > 99 ) - tmp_option_expire_url = 0; - - snprintf( spare, 255, "%02d", tmp_option_expire_url ); - set_text( CHOICES_EDIT_HISTORY_AGE, spare, 2 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_HISTORY_AGE, - 3, 1 ); - break; - - case CHOICES_INC_GIF_DELAY: - case CHOICES_DEC_GIF_DELAY: - if( index == CHOICES_INC_GIF_DELAY ) - tmp_option_minimum_gif_delay += 0.1; - else - tmp_option_minimum_gif_delay -= 0.1; - - if( tmp_option_minimum_gif_delay < 0.1 ) - tmp_option_minimum_gif_delay = 0.1; - if( tmp_option_minimum_gif_delay > 9.0 ) - tmp_option_minimum_gif_delay = 9.0; - snprintf( spare, 255, "%01.1f", tmp_option_minimum_gif_delay ); - set_text( CHOICES_EDIT_MIN_GIF_DELAY, spare, 3 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MIN_GIF_DELAY, 3, 1 ); - break; - - case CHOICES_INC_MIN_FONT_SIZE: - case CHOICES_DEC_MIN_FONT_SIZE: - if( index == CHOICES_INC_MIN_FONT_SIZE ) - tmp_option_font_min_size += 1; - else - tmp_option_font_min_size -= 1; - - if( tmp_option_font_min_size > 500 ) - tmp_option_font_min_size = 500; - if( tmp_option_font_min_size < 10 ) - tmp_option_font_min_size = 10; - - snprintf( spare, 255, "%03d", tmp_option_font_min_size ); - set_text( CHOICES_EDIT_MIN_FONT_SIZE, spare, 3 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MIN_FONT_SIZE, - 3, 1 ); - break; - - case CHOICES_INC_DEF_FONT_SIZE: - case CHOICES_DEC_DEF_FONT_SIZE: - if( index == CHOICES_INC_DEF_FONT_SIZE ) - tmp_option_font_size += 1; - else - tmp_option_font_size -= 1; - - if( tmp_option_font_size > 999 ) - tmp_option_font_size = 999; - if( tmp_option_font_size < 50 ) - tmp_option_font_size = 50; - - snprintf( spare, 255, "%03d", tmp_option_font_size ); - set_text( CHOICES_EDIT_DEF_FONT_SIZE, spare, 3 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_DEF_FONT_SIZE, - 3, 1 ); - - break; - - case CHOICES_INC_INCREMENTAL_REFLOW: - case CHOICES_DEC_INCREMENTAL_REFLOW: - if( index == CHOICES_INC_INCREMENTAL_REFLOW ) - tmp_option_min_reflow_period += 1; - else - tmp_option_min_reflow_period -= 1; - - if( tmp_option_min_reflow_period > 9999 ) - tmp_option_min_reflow_period = 10; - - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); - set_text( CHOICES_EDIT_MIN_REFLOW_PERIOD, spare, 4 ); - is_button = true; - ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MIN_REFLOW_PERIOD, - 3, 1 ); - break; - - default: break; - } - if( is_button ){ - // remove selection indicator from button element: - OBJ_UNCHECK( index ); - ObjcDraw( OC_FORM, dlgwin, index, 1 ); - } -} - -/** - * Toogle all objects which are directly influenced by other GUI elements - * ( like checkbox ) - */ -static void toggle_objects( void ) -{ - /* enable / disable (refresh) objects depending on radio button values: */ - FORMEVENT(CHOICES_CB_USE_PROXY); - FORMEVENT(CHOICES_CB_PROXY_AUTH); - FORMEVENT(CHOICES_BT_SEL_FONT_RENDERER); -} - - -/* this gets called each time the settings dialog is opened: */ -static void display_settings( void ) -{ - char spare[255]; - // read current settings and display them - - /* "Browser" tab: */ - set_text( CHOICES_EDIT_HOMEPAGE, nsoption_charp(homepage_url), - INPUT_HOMEPAGE_URL_MAX_LEN ); - - if( nsoption_bool(block_ads) ){ - OBJ_CHECK( CHOICES_CB_HIDE_ADVERTISEMENT ); - } else { - OBJ_UNCHECK( CHOICES_CB_HIDE_ADVERTISEMENT ); - } - if( nsoption_bool(target_blank) ){ - OBJ_UNCHECK( CHOICES_CB_DISABLE_POPUP_WINDOWS ); - } else { - OBJ_CHECK( CHOICES_CB_DISABLE_POPUP_WINDOWS ); - } - if( nsoption_bool(send_referer) ){ - OBJ_CHECK( CHOICES_CB_SEND_HTTP_REFERRER ); - } else { - OBJ_UNCHECK( CHOICES_CB_SEND_HTTP_REFERRER ); - } - if( nsoption_bool(do_not_track) ){ - OBJ_CHECK( CHOICES_CB_SEND_DO_NOT_TRACK ); - } else { - OBJ_UNCHECK( CHOICES_CB_SEND_DO_NOT_TRACK ); - } - - set_text( CHOICES_BT_SEL_LOCALE, - nsoption_charp(accept_language) ? nsoption_charp(accept_language) : (char*)"en", - INPUT_LOCALE_MAX_LEN ); - - tmp_option_expire_url = nsoption_int(expire_url); - snprintf( spare, 255, "%02d", nsoption_int(expire_url) ); - set_text( CHOICES_EDIT_HISTORY_AGE, spare, 2 ); - - /* "Cache" tab: */ - tmp_option_memory_cache_size = nsoption_int(memory_cache_size) / 100000; - snprintf( spare, 255, "%03.1f", tmp_option_memory_cache_size ); - set_text( CHOICES_STR_MAX_MEM_CACHE, spare, 5 ); - - /* "Paths" tab: */ - set_text( CHOICES_EDIT_DOWNLOAD_PATH, nsoption_charp(downloads_path), - LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_HOTLIST_FILE, nsoption_charp(hotlist_file), - LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_CA_BUNDLE, nsoption_charp(ca_bundle), - LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_CA_CERTS_PATH, nsoption_charp(ca_path), - LABEL_PATH_MAX_LEN ); - set_text( CHOICES_EDIT_EDITOR, nsoption_charp(atari_editor), - LABEL_PATH_MAX_LEN ); - - /* "Rendering" tab: */ - set_text( CHOICES_BT_SEL_FONT_RENDERER, nsoption_charp(atari_font_driver), - LABEL_FONT_RENDERER_MAX_LEN ); - SET_BIT(dlgtree[CHOICES_CB_TRANSPARENCY].ob_state, - SELECTED, nsoption_int(atari_transparency) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_ENABLE_ANIMATION].ob_state, - SELECTED, nsoption_bool(animate_images) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_INCREMENTAL_REFLOW].ob_state, - SELECTED, nsoption_bool(incremental_reflow) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_ANTI_ALIASING].ob_state, - SELECTED, nsoption_int(atari_font_monochrom) ? 0 : 1 ); - - tmp_option_min_reflow_period = nsoption_int(min_reflow_period); - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); - set_text( CHOICES_EDIT_MIN_REFLOW_PERIOD, spare, - INPUT_MIN_REFLOW_PERIOD_MAX_LEN ); - - tmp_option_minimum_gif_delay = (float)nsoption_int(minimum_gif_delay) / (float)100; - snprintf( spare, 255, "%01.1f", tmp_option_minimum_gif_delay ); - set_text( CHOICES_EDIT_MIN_GIF_DELAY, spare, 3 ); - - /* "Network" tab: */ - set_text( CHOICES_EDIT_PROXY_HOST, nsoption_charp(http_proxy_host), - INPUT_PROXY_HOST_MAX_LEN ); - snprintf( spare, 255, "%5d", nsoption_int(http_proxy_port) ); - set_text( CHOICES_EDIT_PROXY_PORT, spare, - INPUT_PROXY_PORT_MAX_LEN ); - - set_text( CHOICES_EDIT_PROXY_USERNAME, nsoption_charp(http_proxy_auth_user), - INPUT_PROXY_USERNAME_MAX_LEN ); - set_text( CHOICES_EDIT_PROXY_PASSWORD, nsoption_charp(http_proxy_auth_pass), - INPUT_PROXY_PASSWORD_MAX_LEN ); - SET_BIT(dlgtree[CHOICES_CB_USE_PROXY].ob_state, - SELECTED, nsoption_bool(http_proxy) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_PROXY_AUTH].ob_state, - SELECTED, nsoption_int(http_proxy_auth) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_FG_IMAGES].ob_state, - SELECTED, nsoption_bool(foreground_images) ? 1 : 0 ); - SET_BIT(dlgtree[CHOICES_CB_BG_IMAGES].ob_state, - SELECTED, nsoption_bool(background_images) ? 1 : 0 ); - - tmp_option_max_cached_fetch_handles = nsoption_int(max_cached_fetch_handles); - snprintf( spare, 255, "%2d", nsoption_int(max_cached_fetch_handles) ); - set_text( CHOICES_EDIT_MAX_CACHED_CONNECTIONS, spare , 2 ); - - tmp_option_max_fetchers = nsoption_int(max_fetchers); - snprintf( spare, 255, "%2d", nsoption_int(max_fetchers) ); - set_text( CHOICES_EDIT_MAX_FETCHERS, spare , 2 ); - - tmp_option_max_fetchers_per_host = nsoption_int(max_fetchers_per_host); - snprintf( spare, 255, "%2d", nsoption_int(max_fetchers_per_host) ); - set_text( CHOICES_EDIT_MAX_FETCHERS_PER_HOST, spare , 2 ); - - - /* "Style" tab: */ - tmp_option_font_min_size = nsoption_int(font_min_size); - snprintf( spare, 255, "%3d", nsoption_int(font_min_size) ); - set_text( CHOICES_EDIT_MIN_FONT_SIZE, spare , 3 ); - - tmp_option_font_size = nsoption_int(font_size); - snprintf( spare, 255, "%3d", nsoption_int(font_size) ); - set_text( CHOICES_EDIT_DEF_FONT_SIZE, spare , 3 ); - - set_text(CHOICES_BT_TOOLBAR_ICONSET, - nsoption_charp(atari_image_toolbar_folder), LABEL_ICONSET_MAX_LEN); - - tmp_option_atari_toolbar_bg = nsoption_int(atari_toolbar_bg); - snprintf( spare, 255, "%06x", tmp_option_atari_toolbar_bg); - set_text(CHOICES_INPUT_TOOLBAR_BGCOLOR, spare, - INPUT_TOOLBAR_COLOR_MAX_LEN ); - - /* Only first tab is refreshed: */ - ObjcDraw( OC_FORM, dlgwin, CHOICES_TAB_BROWSER, 4 ); - - // update elements (enable/disable) chained to form events: - toggle_objects(); -} - -static void apply_settings( void ) -{ - /* "Network" tab: */ - nsoption_set_bool(http_proxy, OBJ_SELECTED(CHOICES_CB_USE_PROXY)); - if ( OBJ_SELECTED(CHOICES_CB_PROXY_AUTH) ) { - nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC); - } else { - nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); - } - nsoption_set_charp(http_proxy_auth_pass, - ObjcString( dlgtree, CHOICES_EDIT_PROXY_PASSWORD, NULL)); - nsoption_set_charp(http_proxy_auth_user, - ObjcString( dlgtree, CHOICES_EDIT_PROXY_USERNAME, NULL)); - nsoption_set_charp(http_proxy_host, - ObjcString( dlgtree, CHOICES_EDIT_PROXY_HOST, NULL)); - nsoption_set_int(http_proxy_port, - atoi( ObjcString( dlgtree, CHOICES_EDIT_PROXY_PORT, NULL) )); - nsoption_set_int(max_fetchers_per_host, - atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS_PER_HOST, NULL))); - nsoption_set_int(max_cached_fetch_handles, - atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_CACHED_CONNECTIONS, NULL))); - nsoption_set_int(max_fetchers, - atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS, NULL) )); - nsoption_set_bool(foreground_images, - OBJ_SELECTED( CHOICES_CB_FG_IMAGES )); - nsoption_set_bool(background_images, - OBJ_SELECTED( CHOICES_CB_BG_IMAGES )); - - /* "Style" tab: */ - nsoption_set_int(font_min_size, tmp_option_font_min_size); - nsoption_set_int(font_size, tmp_option_font_size); - nsoption_set_colour(atari_toolbar_bg, tmp_option_atari_toolbar_bg); - nsoption_set_charp(atari_image_toolbar_folder, - ObjcString( dlgtree, CHOICES_BT_TOOLBAR_ICONSET, NULL) - ); - - /* "Rendering" tab: */ - nsoption_set_charp(atari_font_driver, - ObjcString( dlgtree, CHOICES_BT_SEL_FONT_RENDERER, NULL)); - nsoption_set_bool(atari_transparency, - OBJ_SELECTED(CHOICES_CB_TRANSPARENCY)); - nsoption_set_bool(animate_images, - OBJ_SELECTED(CHOICES_CB_ENABLE_ANIMATION)); - nsoption_set_int(minimum_gif_delay, - (int)(tmp_option_minimum_gif_delay*100+0.5)); - nsoption_set_bool(incremental_reflow, - OBJ_SELECTED(CHOICES_CB_INCREMENTAL_REFLOW)); - nsoption_set_int(min_reflow_period, tmp_option_min_reflow_period); - nsoption_set_int(atari_font_monochrom, - !OBJ_SELECTED( CHOICES_CB_ANTI_ALIASING )); - - /* "Paths" tabs: */ - nsoption_set_charp(ca_bundle, - ObjcString( dlgtree, CHOICES_EDIT_CA_BUNDLE, NULL)); - nsoption_set_charp(ca_path, - ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL)); - nsoption_set_charp(homepage_url, - ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL)); - nsoption_set_charp(hotlist_file, - ObjcString( dlgtree, CHOICES_EDIT_HOTLIST_FILE, NULL)); - nsoption_set_charp(atari_editor, - ObjcString( dlgtree, CHOICES_EDIT_EDITOR, NULL)); - nsoption_set_charp(downloads_path, - ObjcString( dlgtree, CHOICES_EDIT_DOWNLOAD_PATH, NULL)); - - /* "Cache" tab: */ - nsoption_set_int(memory_cache_size, - tmp_option_memory_cache_size * 100000); - - /* "Browser" tab: */ - nsoption_set_bool(target_blank, - !OBJ_SELECTED(CHOICES_CB_DISABLE_POPUP_WINDOWS)); - nsoption_set_bool(block_ads, - OBJ_SELECTED(CHOICES_CB_HIDE_ADVERTISEMENT)); - nsoption_set_charp(accept_language, - ObjcString( dlgtree, CHOICES_BT_SEL_LOCALE, NULL)); - nsoption_set_int(expire_url, - atoi(ObjcString( dlgtree, CHOICES_EDIT_HISTORY_AGE, NULL))); - nsoption_set_bool(send_referer, - OBJ_SELECTED(CHOICES_CB_SEND_HTTP_REFERRER)); - nsoption_set_bool(do_not_track, - OBJ_SELECTED(CHOICES_CB_SEND_HTTP_REFERRER)); - nsoption_set_charp(homepage_url, - ObjcString( dlgtree, CHOICES_EDIT_HOMEPAGE, NULL)); -} - -#undef OBJ_SELECTED -#undef OBJ_CHECK -#undef OBJ_UNCHECK -#undef DISABLE_OBJ -#undef ENABLE_OBJ -#undef FORMEVENT - + if( choice > 0 && choice <= num_locales ){
+ ObjcStrCpy( dlgtree, CHOICES_BT_SEL_LOCALE,
+ (char*)locales[choice-1] );
+ }
+ ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
+ break;
+
+ case CHOICES_INPUT_TOOLBAR_BGCOLOR:
+ objc_offset( FORM(win), CHOICES_INPUT_TOOLBAR_BGCOLOR, &x, &y );
+ choice = color_popup(x, y, tmp_option_atari_toolbar_bg);
+ snprintf( spare, 255, "%06x", choice );
+ tmp_option_atari_toolbar_bg = choice;
+ ObjcStrCpy( dlgtree, CHOICES_INPUT_TOOLBAR_BGCOLOR,
+ spare );
+ is_button = true;
+ ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_INPUT_TOOLBAR_BGCOLOR, 2, 1 );
+ break;
+
+ case CHOICES_BT_TOOLBAR_ICONSET:
+ objc_offset( FORM(win), CHOICES_BT_TOOLBAR_ICONSET, &x, &y );
+ tmp = toolbar_iconset_popup(x,y);
+ if( tmp != NULL ){
+ ObjcStrCpy( dlgtree, CHOICES_BT_TOOLBAR_ICONSET, tmp );
+ }
+ is_button = true;
+ ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
+ break;
+
+ case CHOICES_INC_MEM_CACHE:
+ case CHOICES_DEC_MEM_CACHE:
+ if( index == CHOICES_DEC_MEM_CACHE )
+ tmp_option_memory_cache_size -= 0.1;
+ else
+ tmp_option_memory_cache_size += 0.1;
+
+ if( tmp_option_memory_cache_size < 0.5 )
+ tmp_option_memory_cache_size = 0.5;
+ if( tmp_option_memory_cache_size > 999.9 )
+ tmp_option_memory_cache_size = 999.9;
+ snprintf( spare, 255, "%03.1f", tmp_option_memory_cache_size );
+ set_text( CHOICES_STR_MAX_MEM_CACHE, spare, 5 );
+ is_button = true;
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_STR_MAX_MEM_CACHE, 2, 1 );
+ break;
+
+ case CHOICES_INC_CACHED_CONNECTIONS:
+ case CHOICES_DEC_CACHED_CONNECTIONS:
+ if( index == CHOICES_INC_CACHED_CONNECTIONS )
+ tmp_option_max_cached_fetch_handles += 1;
+ else
+ tmp_option_max_cached_fetch_handles -= 1;
+ if( tmp_option_max_cached_fetch_handles > 31 )
+ tmp_option_max_cached_fetch_handles = 31;
+
+ snprintf( spare, 255, "%02d", tmp_option_max_cached_fetch_handles );
+ set_text( CHOICES_EDIT_MAX_CACHED_CONNECTIONS, spare, 2 );
+ is_button = true;
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MAX_CACHED_CONNECTIONS,
+ 2, 1 );
+ break;
+
+ case CHOICES_INC_MAX_FETCHERS:
+ case CHOICES_DEC_MAX_FETCHERS:
+ if( index == CHOICES_INC_MAX_FETCHERS )
+ tmp_option_max_fetchers += 1;
+ else
+ tmp_option_max_fetchers -= 1;
+ if( tmp_option_max_fetchers > 31 )
+ tmp_option_max_fetchers = 31;
+
+ snprintf( spare, 255, "%02d", tmp_option_max_fetchers );
+ set_text( CHOICES_EDIT_MAX_FETCHERS, spare, 2 );
+ is_button = true;
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MAX_FETCHERS,
+ 3, 1 );
+ break;
+
+ case CHOICES_INC_MAX_FETCHERS_PER_HOST:
+ case CHOICES_DEC_MAX_FETCHERS_PER_HOST:
+ if( index == CHOICES_INC_MAX_FETCHERS_PER_HOST )
+ tmp_option_max_fetchers_per_host += 1;
+ else
+ tmp_option_max_fetchers_per_host -= 1;
+ if( tmp_option_max_fetchers_per_host > 31 )
+ tmp_option_max_fetchers_per_host = 31;
+
+ snprintf( spare, 255, "%02d", tmp_option_max_fetchers_per_host );
+ set_text( CHOICES_EDIT_MAX_FETCHERS_PER_HOST, spare, 2 );
+ is_button = true;
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MAX_FETCHERS_PER_HOST,
+ 2, 1 );
+ break;
+
+ case CHOICES_INC_HISTORY_AGE:
+ case CHOICES_DEC_HISTORY_AGE:
+ if( index == CHOICES_INC_HISTORY_AGE )
+ tmp_option_expire_url += 1;
+ else
+ tmp_option_expire_url -= 1;
+
+ if( tmp_option_expire_url > 99 )
+ tmp_option_expire_url = 0;
+
+ snprintf( spare, 255, "%02d", tmp_option_expire_url );
+ set_text( CHOICES_EDIT_HISTORY_AGE, spare, 2 );
+ is_button = true;
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_HISTORY_AGE,
+ 3, 1 );
+ break;
+
+ case CHOICES_INC_GIF_DELAY:
+ case CHOICES_DEC_GIF_DELAY:
+ if( index == CHOICES_INC_GIF_DELAY )
+ tmp_option_minimum_gif_delay += 0.1;
+ else
+ tmp_option_minimum_gif_delay -= 0.1;
+
+ if( tmp_option_minimum_gif_delay < 0.1 )
+ tmp_option_minimum_gif_delay = 0.1;
+ if( tmp_option_minimum_gif_delay > 9.0 )
+ tmp_option_minimum_gif_delay = 9.0;
+ snprintf( spare, 255, "%01.1f", tmp_option_minimum_gif_delay );
+ set_text( CHOICES_EDIT_MIN_GIF_DELAY, spare, 3 );
+ is_button = true;
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MIN_GIF_DELAY, 3, 1 );
+ break;
+
+ case CHOICES_INC_MIN_FONT_SIZE:
+ case CHOICES_DEC_MIN_FONT_SIZE:
+ if( index == CHOICES_INC_MIN_FONT_SIZE )
+ tmp_option_font_min_size += 1;
+ else
+ tmp_option_font_min_size -= 1;
+
+ if( tmp_option_font_min_size > 500 )
+ tmp_option_font_min_size = 500;
+ if( tmp_option_font_min_size < 10 )
+ tmp_option_font_min_size = 10;
+
+ snprintf( spare, 255, "%03d", tmp_option_font_min_size );
+ set_text( CHOICES_EDIT_MIN_FONT_SIZE, spare, 3 );
+ is_button = true;
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MIN_FONT_SIZE,
+ 3, 1 );
+ break;
+
+ case CHOICES_INC_DEF_FONT_SIZE:
+ case CHOICES_DEC_DEF_FONT_SIZE:
+ if( index == CHOICES_INC_DEF_FONT_SIZE )
+ tmp_option_font_size += 1;
+ else
+ tmp_option_font_size -= 1;
+
+ if( tmp_option_font_size > 999 )
+ tmp_option_font_size = 999;
+ if( tmp_option_font_size < 50 )
+ tmp_option_font_size = 50;
+
+ snprintf( spare, 255, "%03d", tmp_option_font_size );
+ set_text( CHOICES_EDIT_DEF_FONT_SIZE, spare, 3 );
+ is_button = true;
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_DEF_FONT_SIZE,
+ 3, 1 );
+
+ break;
+
+ case CHOICES_INC_INCREMENTAL_REFLOW:
+ case CHOICES_DEC_INCREMENTAL_REFLOW:
+ if( index == CHOICES_INC_INCREMENTAL_REFLOW )
+ tmp_option_min_reflow_period += 1;
+ else
+ tmp_option_min_reflow_period -= 1;
+
+ if( tmp_option_min_reflow_period > 9999 )
+ tmp_option_min_reflow_period = 10;
+
+ snprintf( spare, 255, "%04d", tmp_option_min_reflow_period );
+ set_text( CHOICES_EDIT_MIN_REFLOW_PERIOD, spare, 4 );
+ is_button = true;
+ ObjcDrawParent(OC_FORM, dlgwin, CHOICES_EDIT_MIN_REFLOW_PERIOD,
+ 3, 1 );
+ break;
+
+ default: break;
+ }
+ if( is_button ){
+ // remove selection indicator from button element:
+ OBJ_UNCHECK( index );
+ ObjcDraw( OC_FORM, dlgwin, index, 1 );
+ }
+}
+
+/**
+ * Toogle all objects which are directly influenced by other GUI elements
+ * ( like checkbox )
+ */
+static void toggle_objects( void )
+{
+ /* enable / disable (refresh) objects depending on radio button values: */
+ FORMEVENT(CHOICES_CB_USE_PROXY);
+ FORMEVENT(CHOICES_CB_PROXY_AUTH);
+ FORMEVENT(CHOICES_BT_SEL_FONT_RENDERER);
+}
+
+
+/* this gets called each time the settings dialog is opened: */
+static void display_settings( void )
+{
+ char spare[255];
+ // read current settings and display them
+
+ /* "Browser" tab: */
+ set_text( CHOICES_EDIT_HOMEPAGE, nsoption_charp(homepage_url),
+ INPUT_HOMEPAGE_URL_MAX_LEN );
+
+ if( nsoption_bool(block_ads) ){
+ OBJ_CHECK( CHOICES_CB_HIDE_ADVERTISEMENT );
+ } else {
+ OBJ_UNCHECK( CHOICES_CB_HIDE_ADVERTISEMENT );
+ }
+ if( nsoption_bool(target_blank) ){
+ OBJ_UNCHECK( CHOICES_CB_DISABLE_POPUP_WINDOWS );
+ } else {
+ OBJ_CHECK( CHOICES_CB_DISABLE_POPUP_WINDOWS );
+ }
+ if( nsoption_bool(send_referer) ){
+ OBJ_CHECK( CHOICES_CB_SEND_HTTP_REFERRER );
+ } else {
+ OBJ_UNCHECK( CHOICES_CB_SEND_HTTP_REFERRER );
+ }
+ if( nsoption_bool(do_not_track) ){
+ OBJ_CHECK( CHOICES_CB_SEND_DO_NOT_TRACK );
+ } else {
+ OBJ_UNCHECK( CHOICES_CB_SEND_DO_NOT_TRACK );
+ }
+
+ set_text( CHOICES_BT_SEL_LOCALE,
+ nsoption_charp(accept_language) ? nsoption_charp(accept_language) : (char*)"en",
+ INPUT_LOCALE_MAX_LEN );
+
+ tmp_option_expire_url = nsoption_int(expire_url);
+ snprintf( spare, 255, "%02d", nsoption_int(expire_url) );
+ set_text( CHOICES_EDIT_HISTORY_AGE, spare, 2 );
+
+ /* "Cache" tab: */
+ tmp_option_memory_cache_size = nsoption_int(memory_cache_size) / 100000;
+ snprintf( spare, 255, "%03.1f", tmp_option_memory_cache_size );
+ set_text( CHOICES_STR_MAX_MEM_CACHE, spare, 5 );
+
+ /* "Paths" tab: */
+ set_text( CHOICES_EDIT_DOWNLOAD_PATH, nsoption_charp(downloads_path),
+ LABEL_PATH_MAX_LEN );
+ set_text( CHOICES_EDIT_HOTLIST_FILE, nsoption_charp(hotlist_file),
+ LABEL_PATH_MAX_LEN );
+ set_text( CHOICES_EDIT_CA_BUNDLE, nsoption_charp(ca_bundle),
+ LABEL_PATH_MAX_LEN );
+ set_text( CHOICES_EDIT_CA_CERTS_PATH, nsoption_charp(ca_path),
+ LABEL_PATH_MAX_LEN );
+ set_text( CHOICES_EDIT_EDITOR, nsoption_charp(atari_editor),
+ LABEL_PATH_MAX_LEN );
+
+ /* "Rendering" tab: */
+ set_text( CHOICES_BT_SEL_FONT_RENDERER, nsoption_charp(atari_font_driver),
+ LABEL_FONT_RENDERER_MAX_LEN );
+ SET_BIT(dlgtree[CHOICES_CB_TRANSPARENCY].ob_state,
+ SELECTED, nsoption_int(atari_transparency) ? 1 : 0 );
+ SET_BIT(dlgtree[CHOICES_CB_ENABLE_ANIMATION].ob_state,
+ SELECTED, nsoption_bool(animate_images) ? 1 : 0 );
+ SET_BIT(dlgtree[CHOICES_CB_INCREMENTAL_REFLOW].ob_state,
+ SELECTED, nsoption_bool(incremental_reflow) ? 1 : 0 );
+ SET_BIT(dlgtree[CHOICES_CB_ANTI_ALIASING].ob_state,
+ SELECTED, nsoption_int(atari_font_monochrom) ? 0 : 1 );
+
+ tmp_option_min_reflow_period = nsoption_int(min_reflow_period);
+ snprintf( spare, 255, "%04d", tmp_option_min_reflow_period );
+ set_text( CHOICES_EDIT_MIN_REFLOW_PERIOD, spare,
+ INPUT_MIN_REFLOW_PERIOD_MAX_LEN );
+
+ tmp_option_minimum_gif_delay = (float)nsoption_int(minimum_gif_delay) / (float)100;
+ snprintf( spare, 255, "%01.1f", tmp_option_minimum_gif_delay );
+ set_text( CHOICES_EDIT_MIN_GIF_DELAY, spare, 3 );
+
+ /* "Network" tab: */
+ set_text( CHOICES_EDIT_PROXY_HOST, nsoption_charp(http_proxy_host),
+ INPUT_PROXY_HOST_MAX_LEN );
+ snprintf( spare, 255, "%5d", nsoption_int(http_proxy_port) );
+ set_text( CHOICES_EDIT_PROXY_PORT, spare,
+ INPUT_PROXY_PORT_MAX_LEN );
+
+ set_text( CHOICES_EDIT_PROXY_USERNAME, nsoption_charp(http_proxy_auth_user),
+ INPUT_PROXY_USERNAME_MAX_LEN );
+ set_text( CHOICES_EDIT_PROXY_PASSWORD, nsoption_charp(http_proxy_auth_pass),
+ INPUT_PROXY_PASSWORD_MAX_LEN );
+ SET_BIT(dlgtree[CHOICES_CB_USE_PROXY].ob_state,
+ SELECTED, nsoption_bool(http_proxy) ? 1 : 0 );
+ SET_BIT(dlgtree[CHOICES_CB_PROXY_AUTH].ob_state,
+ SELECTED, nsoption_int(http_proxy_auth) ? 1 : 0 );
+ SET_BIT(dlgtree[CHOICES_CB_FG_IMAGES].ob_state,
+ SELECTED, nsoption_bool(foreground_images) ? 1 : 0 );
+ SET_BIT(dlgtree[CHOICES_CB_BG_IMAGES].ob_state,
+ SELECTED, nsoption_bool(background_images) ? 1 : 0 );
+
+ tmp_option_max_cached_fetch_handles = nsoption_int(max_cached_fetch_handles);
+ snprintf( spare, 255, "%2d", nsoption_int(max_cached_fetch_handles) );
+ set_text( CHOICES_EDIT_MAX_CACHED_CONNECTIONS, spare , 2 );
+
+ tmp_option_max_fetchers = nsoption_int(max_fetchers);
+ snprintf( spare, 255, "%2d", nsoption_int(max_fetchers) );
+ set_text( CHOICES_EDIT_MAX_FETCHERS, spare , 2 );
+
+ tmp_option_max_fetchers_per_host = nsoption_int(max_fetchers_per_host);
+ snprintf( spare, 255, "%2d", nsoption_int(max_fetchers_per_host) );
+ set_text( CHOICES_EDIT_MAX_FETCHERS_PER_HOST, spare , 2 );
+
+
+ /* "Style" tab: */
+ tmp_option_font_min_size = nsoption_int(font_min_size);
+ snprintf( spare, 255, "%3d", nsoption_int(font_min_size) );
+ set_text( CHOICES_EDIT_MIN_FONT_SIZE, spare , 3 );
+
+ tmp_option_font_size = nsoption_int(font_size);
+ snprintf( spare, 255, "%3d", nsoption_int(font_size) );
+ set_text( CHOICES_EDIT_DEF_FONT_SIZE, spare , 3 );
+
+ set_text(CHOICES_BT_TOOLBAR_ICONSET,
+ nsoption_charp(atari_image_toolbar_folder), LABEL_ICONSET_MAX_LEN);
+
+ tmp_option_atari_toolbar_bg = nsoption_int(atari_toolbar_bg);
+ snprintf( spare, 255, "%06x", tmp_option_atari_toolbar_bg);
+ set_text(CHOICES_INPUT_TOOLBAR_BGCOLOR, spare,
+ INPUT_TOOLBAR_COLOR_MAX_LEN );
+
+ /* Only first tab is refreshed: */
+ ObjcDraw( OC_FORM, dlgwin, CHOICES_TAB_BROWSER, 4 );
+
+ // update elements (enable/disable) chained to form events:
+ toggle_objects();
+}
+
+static void apply_settings( void )
+{
+ /* "Network" tab: */
+ nsoption_set_bool(http_proxy, OBJ_SELECTED(CHOICES_CB_USE_PROXY));
+ if ( OBJ_SELECTED(CHOICES_CB_PROXY_AUTH) ) {
+ nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC);
+ } else {
+ nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE);
+ }
+ nsoption_set_charp(http_proxy_auth_pass,
+ ObjcString( dlgtree, CHOICES_EDIT_PROXY_PASSWORD, NULL));
+ nsoption_set_charp(http_proxy_auth_user,
+ ObjcString( dlgtree, CHOICES_EDIT_PROXY_USERNAME, NULL));
+ nsoption_set_charp(http_proxy_host,
+ ObjcString( dlgtree, CHOICES_EDIT_PROXY_HOST, NULL));
+ nsoption_set_int(http_proxy_port,
+ atoi( ObjcString( dlgtree, CHOICES_EDIT_PROXY_PORT, NULL) ));
+ nsoption_set_int(max_fetchers_per_host,
+ atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS_PER_HOST, NULL)));
+ nsoption_set_int(max_cached_fetch_handles,
+ atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_CACHED_CONNECTIONS, NULL)));
+ nsoption_set_int(max_fetchers,
+ atoi( ObjcString( dlgtree, CHOICES_EDIT_MAX_FETCHERS, NULL) ));
+ nsoption_set_bool(foreground_images,
+ OBJ_SELECTED( CHOICES_CB_FG_IMAGES ));
+ nsoption_set_bool(background_images,
+ OBJ_SELECTED( CHOICES_CB_BG_IMAGES ));
+
+ /* "Style" tab: */
+ nsoption_set_int(font_min_size, tmp_option_font_min_size);
+ nsoption_set_int(font_size, tmp_option_font_size);
+ nsoption_set_colour(atari_toolbar_bg, tmp_option_atari_toolbar_bg);
+ nsoption_set_charp(atari_image_toolbar_folder,
+ ObjcString( dlgtree, CHOICES_BT_TOOLBAR_ICONSET, NULL)
+ );
+
+ /* "Rendering" tab: */
+ nsoption_set_charp(atari_font_driver,
+ ObjcString( dlgtree, CHOICES_BT_SEL_FONT_RENDERER, NULL));
+ nsoption_set_bool(atari_transparency,
+ OBJ_SELECTED(CHOICES_CB_TRANSPARENCY));
+ nsoption_set_bool(animate_images,
+ OBJ_SELECTED(CHOICES_CB_ENABLE_ANIMATION));
+ nsoption_set_int(minimum_gif_delay,
+ (int)(tmp_option_minimum_gif_delay*100+0.5));
+ nsoption_set_bool(incremental_reflow,
+ OBJ_SELECTED(CHOICES_CB_INCREMENTAL_REFLOW));
+ nsoption_set_int(min_reflow_period, tmp_option_min_reflow_period);
+ nsoption_set_int(atari_font_monochrom,
+ !OBJ_SELECTED( CHOICES_CB_ANTI_ALIASING ));
+
+ /* "Paths" tabs: */
+ nsoption_set_charp(ca_bundle,
+ ObjcString( dlgtree, CHOICES_EDIT_CA_BUNDLE, NULL));
+ nsoption_set_charp(ca_path,
+ ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL));
+ nsoption_set_charp(homepage_url,
+ ObjcString( dlgtree, CHOICES_EDIT_CA_CERTS_PATH, NULL));
+ nsoption_set_charp(hotlist_file,
+ ObjcString( dlgtree, CHOICES_EDIT_HOTLIST_FILE, NULL));
+ nsoption_set_charp(atari_editor,
+ ObjcString( dlgtree, CHOICES_EDIT_EDITOR, NULL));
+ nsoption_set_charp(downloads_path,
+ ObjcString( dlgtree, CHOICES_EDIT_DOWNLOAD_PATH, NULL));
+
+ /* "Cache" tab: */
+ nsoption_set_int(memory_cache_size,
+ tmp_option_memory_cache_size * 100000);
+
+ /* "Browser" tab: */
+ nsoption_set_bool(target_blank,
+ !OBJ_SELECTED(CHOICES_CB_DISABLE_POPUP_WINDOWS));
+ nsoption_set_bool(block_ads,
+ OBJ_SELECTED(CHOICES_CB_HIDE_ADVERTISEMENT));
+ nsoption_set_charp(accept_language,
+ ObjcString( dlgtree, CHOICES_BT_SEL_LOCALE, NULL));
+ nsoption_set_int(expire_url,
+ atoi(ObjcString( dlgtree, CHOICES_EDIT_HISTORY_AGE, NULL)));
+ nsoption_set_bool(send_referer,
+ OBJ_SELECTED(CHOICES_CB_SEND_HTTP_REFERRER));
+ nsoption_set_bool(do_not_track,
+ OBJ_SELECTED(CHOICES_CB_SEND_HTTP_REFERRER));
+ nsoption_set_charp(homepage_url,
+ ObjcString( dlgtree, CHOICES_EDIT_HOMEPAGE, NULL));
+}
+
+#undef OBJ_SELECTED
+#undef OBJ_CHECK
+#undef OBJ_UNCHECK
+#undef DISABLE_OBJ
+#undef ENABLE_OBJ
+#undef FORMEVENT
+
diff --git a/content/content.c b/content/content.c index f39ba91d4..b80626cdf 100644 --- a/content/content.c +++ b/content/content.c @@ -788,8 +788,8 @@ content_find_rfc5988_link(hlcache_handle *h, lwc_string *rel) bool rel_match = false; while (link != NULL) { - lwc_string_caseless_isequal(link->rel, rel, &rel_match); - if (rel_match) { + if (lwc_string_caseless_isequal(link->rel, rel, + &rel_match) == lwc_error_ok && rel_match) { break; } link = link->next; diff --git a/content/fetch.c b/content/fetch.c index 8c725af0e..2b16512fa 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -291,9 +291,15 @@ struct fetch * fetch_start(nsurl *url, nsurl *referer, */ bool match1; bool match2; - lwc_string_isequal(scheme, ref_scheme, &match); - lwc_string_isequal(scheme, fetch_https_lwc, &match1); - lwc_string_isequal(ref_scheme, fetch_http_lwc, &match2); + if (lwc_string_isequal(scheme, ref_scheme, &match) != lwc_error_ok) { + match = false; + } + if (lwc_string_isequal(scheme, fetch_https_lwc, &match1) != lwc_error_ok) { + match1 = false; + } + if (lwc_string_isequal(ref_scheme, fetch_http_lwc, &match2) != lwc_error_ok) { + match2= false; + } if (match == true || (match1 == true && match2 == true)) fetch->send_referer = true; } @@ -306,8 +312,7 @@ struct fetch * fetch_start(nsurl *url, nsurl *referer, /* Pick the scheme ops */ while (fetcher) { - lwc_string_isequal(fetcher->scheme_name, scheme, &match); - if (match == true) { + if ((lwc_string_isequal(fetcher->scheme_name, scheme, &match) == lwc_error_ok) && (match == true)) { fetch->ops = fetcher; break; } @@ -542,9 +547,9 @@ bool fetch_can_fetch(const nsurl *url) lwc_string *scheme = nsurl_get_component(url, NSURL_SCHEME); while (fetcher != NULL) { - lwc_string_isequal(fetcher->scheme_name, scheme, &match); - if (match == true) + if (lwc_string_isequal(fetcher->scheme_name, scheme, &match) == lwc_error_ok && match == true) { break; + } fetcher = fetcher->next_fetcher; } diff --git a/css/select.c b/css/select.c index 59f2641cc..84b8550ac 100644 --- a/css/select.c +++ b/css/select.c @@ -801,8 +801,7 @@ css_error node_has_name(void *pw, void *node, nscss_select_ctx *ctx = pw; dom_node *n = node; - lwc_string_isequal(qname->name, ctx->universal, match); - if (*match == false) { + if (lwc_string_isequal(qname->name, ctx->universal, match) == lwc_error_ok && *match == false) { dom_string *name; dom_exception err; @@ -1058,8 +1057,9 @@ css_error node_has_attribute_includes(void *pw, void *node, const char *start; const char *end; + *match = false; + if (vlen == 0) { - *match = false; return CSS_OK; } diff --git a/desktop/browser.c b/desktop/browser.c index bd819b412..3b2fa4e1d 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1372,18 +1372,22 @@ nserror browser_window_callback(hlcache_handle *c, if (lwc_intern_string("icon", SLEN("icon"), &icon_str) == lwc_error_ok) { - lwc_string_caseless_isequal( + if (lwc_string_caseless_isequal( event->data.rfc5988_link->rel, - icon_str, &icon_match); + icon_str, &icon_match) != lwc_error_ok) { + icon_match = false; + } lwc_string_unref(icon_str); } if (lwc_intern_string("shortcut icon", SLEN("shortcut icon"), &shortcut_icon_str) == lwc_error_ok) { - lwc_string_caseless_isequal( + if (lwc_string_caseless_isequal( event->data.rfc5988_link->rel, shortcut_icon_str, - &shortcut_icon_match); + &shortcut_icon_match) != lwc_error_ok) { + shortcut_icon_match = false; + } lwc_string_unref(shortcut_icon_str); } diff --git a/framebuffer/fbtk/event.c b/framebuffer/fbtk/event.c index 67f930622..3ace28aaf 100644 --- a/framebuffer/fbtk/event.c +++ b/framebuffer/fbtk/event.c @@ -218,8 +218,8 @@ fbtk_event(fbtk_widget_t *root, nsfb_event_t *event, int timeout) switch (event->type) { case NSFB_EVENT_KEY_DOWN: case NSFB_EVENT_KEY_UP: - if ((event->value.controlcode >= NSFB_KEY_MOUSE_1) && - (event->value.controlcode <= NSFB_KEY_MOUSE_5)) { + if ((event->value.keycode >= NSFB_KEY_MOUSE_1) && + (event->value.keycode <= NSFB_KEY_MOUSE_5)) { fbtk_click(root, event); } else { fbtk_input(root, event); diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c index 936f3d213..4749991bb 100644 --- a/framebuffer/fbtk/text.c +++ b/framebuffer/fbtk/text.c @@ -129,7 +129,12 @@ fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi ) if (widget->u.text.text != NULL) { int x = bbox.x0 + padding; - int y = bbox.y0 + ((fh * 3) / 4) + padding; + int y = bbox.y0 + ((fh * 3 + 2) / 4) + padding; + +#ifdef FB_USE_FREETYPE + /* Freetype renders text higher */ + y += 1; +#endif if (caret && widget->width - padding - padding < caret_x) { scroll = (widget->width - padding - padding) - caret_x; diff --git a/framebuffer/font_freetype.c b/framebuffer/font_freetype.c index 581fd9a3d..c2279a116 100644 --- a/framebuffer/font_freetype.c +++ b/framebuffer/font_freetype.c @@ -396,7 +396,8 @@ FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4) fb_face = (fb_faceid_t *)srec.face_id; - glyph_index = FTC_CMapCache_Lookup(ft_cmap_cache, srec.face_id, fb_face->cidx, ucs4); + glyph_index = FTC_CMapCache_Lookup(ft_cmap_cache, srec.face_id, + fb_face->cidx, ucs4); error = FTC_ImageCache_LookupScaler(ft_image_cache, &srec, @@ -406,6 +407,8 @@ FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4) glyph_index, &glyph, NULL); + if (error != 0) + return NULL; return glyph; } diff --git a/image/jpeg.c b/image/jpeg.c index 92443bd0e..27d79bb11 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -245,14 +245,16 @@ jpeg_cache_convert(struct content *c) rowstride = bitmap_get_rowstride(bitmap); do { JSAMPROW scanlines[1]; -#if RGB_RED != 0 || RGB_GREEN != 1 || RGB_BLUE != 2 || RGB_PIXELSIZE != 4 - int i; scanlines[0] = (JSAMPROW) (pixels + rowstride * cinfo.output_scanline); jpeg_read_scanlines(&cinfo, scanlines, 1); - /* expand to RGBA */ +#if RGB_RED != 0 || RGB_GREEN != 1 || RGB_BLUE != 2 || RGB_PIXELSIZE != 4 +{ + /* Missmatch between configured libjpeg pixel format and + * NetSurf pixel format. Convert to RGBA */ + int i; for (i = width - 1; 0 <= i; i--) { int r = scanlines[0][i * RGB_PIXELSIZE + RGB_RED]; int g = scanlines[0][i * RGB_PIXELSIZE + RGB_GREEN]; @@ -262,11 +264,7 @@ jpeg_cache_convert(struct content *c) scanlines[0][i * 4 + 2] = b; scanlines[0][i * 4 + 3] = 0xff; } -#else - scanlines[0] = (JSAMPROW) (pixels + - rowstride * cinfo.output_scanline); - jpeg_read_scanlines(&cinfo, scanlines, 1); - +} #endif } while (cinfo.output_scanline != cinfo.output_height); bitmap_modified(bitmap); diff --git a/javascript/content.c b/javascript/content.c index 8bf3b88ba..879c2190d 100644 --- a/javascript/content.c +++ b/javascript/content.c @@ -111,8 +111,11 @@ static const content_handler javascript_content_handler = { }; static const char *javascript_types[] = { - "application/javascript", - "text/javascript" + "application/javascript", /* RFC 4329 */ + "application/ecmascript", /* RFC 4329 */ + "application/x-javascript", /* common usage */ + "text/javascript", /* common usage */ + "text/ecmascript", /* common usage */ }; CONTENT_FACTORY_REGISTER_TYPES(javascript, javascript_types, javascript_content_handler); diff --git a/javascript/jsapi.h b/javascript/jsapi.h index a44323f77..2c10d02ce 100644 --- a/javascript/jsapi.h +++ b/javascript/jsapi.h @@ -29,6 +29,8 @@ #include "mozjs/jsapi.h" #endif +#include "render/html_internal.h" + #if JS_VERSION <= 180 #include <string.h> @@ -152,7 +154,7 @@ JSObject *jsapi_new_window(JSContext *cx, JSObject *parent, void *win_priv); * @param doc_priv The private context to set on the object * @return new javascript object or NULL on error */ -JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, void *doc_priv); +JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, struct html_content *htmlc); /** Create a new javascript console object * @@ -170,4 +172,13 @@ JSObject *jsapi_new_console(JSContext *cx, JSObject *parent); */ JSObject *jsapi_new_navigator(JSContext *cx, JSObject *parent); +/** Create a new javascript element object + * + * @param cx The javascript context. + * @param parent The parent object, usually a global window object + * @param doc_priv The private context to set on the object + * @return new javascript object or NULL on error + */ +JSObject *jsapi_new_element(JSContext *cx, JSObject *parent, struct html_content *htmlc, struct dom_element *domelement); + #endif diff --git a/javascript/jsapi/console.c b/javascript/jsapi/console.c index 6a3cc1801..6a6d7d3c3 100644 --- a/javascript/jsapi/console.c +++ b/javascript/jsapi/console.c @@ -16,10 +16,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "javascript/jsapi.h" #include "utils/log.h" +#include "javascript/jsapi.h" + static JSBool JSAPI_NATIVE(debug, JSContext *cx, uintN argc, jsval *vp) { JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); diff --git a/javascript/jsapi/document.c b/javascript/jsapi/document.c index 49144c4a9..a40ce2011 100644 --- a/javascript/jsapi/document.c +++ b/javascript/jsapi/document.c @@ -18,85 +18,63 @@ #include <dom/dom.h> - -#include "javascript/jsapi.h" #include "utils/config.h" -#include "render/html_internal.h" #include "utils/log.h" -/* IDL from http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html +#include "javascript/jsapi.h" + +/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-document +CAUTION - write, writeln are not part of the DOM they come from: +http://www.w3.org/TR/html5/apis-in-html-documents.html#document.write interface Document : Node { - // Modified in DOM Level 3: - readonly attribute DocumentType doctype; readonly attribute DOMImplementation implementation; - readonly attribute Element documentElement; - Element createElement(in DOMString tagName) - raises(DOMException); - DocumentFragment createDocumentFragment(); - Text createTextNode(in DOMString data); - Comment createComment(in DOMString data); - CDATASection createCDATASection(in DOMString data) - raises(DOMException); - ProcessingInstruction createProcessingInstruction(in DOMString target, - in DOMString data) - raises(DOMException); - Attr createAttribute(in DOMString name) - raises(DOMException); - EntityReference createEntityReference(in DOMString name) - raises(DOMException); - NodeList getElementsByTagName(in DOMString tagname); - // Introduced in DOM Level 2: - Node importNode(in Node importedNode, - in boolean deep) - raises(DOMException); - // Introduced in DOM Level 2: - Element createElementNS(in DOMString namespaceURI, - in DOMString qualifiedName) - raises(DOMException); - // Introduced in DOM Level 2: - Attr createAttributeNS(in DOMString namespaceURI, - in DOMString qualifiedName) - raises(DOMException); - // Introduced in DOM Level 2: - NodeList getElementsByTagNameNS(in DOMString namespaceURI, - in DOMString localName); - // Introduced in DOM Level 2: - Element getElementById(in DOMString elementId); - // Introduced in DOM Level 3: - readonly attribute DOMString inputEncoding; - // Introduced in DOM Level 3: - readonly attribute DOMString xmlEncoding; - // Introduced in DOM Level 3: - attribute boolean xmlStandalone; - // raises(DOMException) on setting - - // Introduced in DOM Level 3: - attribute DOMString xmlVersion; - // raises(DOMException) on setting - - // Introduced in DOM Level 3: - attribute boolean strictErrorChecking; - // Introduced in DOM Level 3: - attribute DOMString documentURI; - // Introduced in DOM Level 3: - Node adoptNode(in Node source) - raises(DOMException); - // Introduced in DOM Level 3: - readonly attribute DOMConfiguration domConfig; - // Introduced in DOM Level 3: - void normalizeDocument(); - // Introduced in DOM Level 3: - Node renameNode(in Node n, - in DOMString namespaceURI, - in DOMString qualifiedName) - raises(DOMException); + readonly attribute DOMString URL; + readonly attribute DOMString documentURI; + readonly attribute DOMString compatMode; + readonly attribute DOMString characterSet; + readonly attribute DOMString contentType; + + readonly attribute DocumentType? doctype; + readonly attribute Element? documentElement; + HTMLCollection getElementsByTagName(DOMString localName); + HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); + HTMLCollection getElementsByClassName(DOMString classNames); + Element? getElementById(DOMString elementId); + + Element createElement(DOMString localName); + Element createElementNS(DOMString? namespace, DOMString qualifiedName); + DocumentFragment createDocumentFragment(); + Text createTextNode(DOMString data); + Comment createComment(DOMString data); + ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); + + Node importNode(Node node, optional boolean deep = true); + Node adoptNode(Node node); + + Event createEvent(DOMString interface); + + Range createRange(); + + // NodeFilter.SHOW_ALL = 0xFFFFFFFF + NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); + TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); + + // NEW + void prepend((Node or DOMString)... nodes); + void append((Node or DOMString)... nodes); }; */ +static void jsfinalize_document(JSContext *cx, JSObject *obj); + +struct jsclass_document_priv { + struct html_content *htmlc; + dom_document *node; +}; static JSClass jsclass_document = { @@ -109,24 +87,29 @@ static JSClass jsclass_document = JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, - JS_FinalizeStub, + jsfinalize_document, JSCLASS_NO_OPTIONAL_MEMBERS }; +#define JSCLASS_NAME document + +#include "node.c" + static JSBool JSAPI_NATIVE(getElementById, JSContext *cx, uintN argc, jsval *vp) { JSString* u16_txt; char *txt; unsigned long txtlen; - struct html_content *htmlc; dom_string *idstr; dom_element *idelement; + struct jsclass_document_priv *document; - htmlc = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL); - if (htmlc == NULL) + document = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL); + if (document == NULL) { return JS_FALSE; + } - if (htmlc->document == NULL) { + if (document->node == NULL) { /* no document available, this is obviously a problem * for finding elements */ @@ -142,13 +125,9 @@ static JSBool JSAPI_NATIVE(getElementById, JSContext *cx, uintN argc, jsval *vp) dom_string_create((unsigned char*)txt, txtlen, &idstr); - dom_document_get_element_by_id(htmlc->document, idstr, &idelement); + dom_document_get_element_by_id(document->node, idstr, &idelement); - if (idelement==NULL) { - JSAPI_SET_RVAL(cx, vp, JSVAL_NULL); - } else { - /* create element object and return it*/ - } + JSAPI_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsapi_new_element(cx, JS_GetGlobalObject(cx), document->htmlc, idelement))); return JS_TRUE; } @@ -158,20 +137,23 @@ static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp) JSString* u16_txt; char *txt; unsigned long length; - struct html_content *htmlc; + struct jsclass_document_priv *document; - htmlc = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL); - if (htmlc == NULL) + document = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &jsclass_document, NULL); + if (document == NULL) { return JS_FALSE; + } - if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt)) + if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt)) { return JS_FALSE; + } JSString_to_char(u16_txt, txt, length); - LOG(("content %p parser %p writing %s",htmlc, htmlc->parser, txt)); - if (htmlc->parser != NULL) { - dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)txt, length); + LOG(("content %p parser %p writing %s", + document->htmlc, document->htmlc->parser, txt)); + if (document->htmlc->parser != NULL) { + dom_hubbub_parser_insert_chunk(document->htmlc->parser, (uint8_t *)txt, length); } JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); @@ -179,6 +161,7 @@ static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp) } static JSFunctionSpec jsfunctions_document[] = { + JSAPI_FS_NODE, JSAPI_FS(write, 1, 0), JSAPI_FS(getElementById, 1, 0), JSAPI_FS_END @@ -186,11 +169,30 @@ static JSFunctionSpec jsfunctions_document[] = { +static void jsfinalize_document(JSContext *cx, JSObject *obj) +{ + struct jsclass_document_priv *document; + + document = JS_GetInstancePrivate(cx, obj, &jsclass_document, NULL); + if (document != NULL) { + free(document); + } +} -JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, void *doc_priv) +JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, struct html_content *htmlc) { - JSObject *doc; - doc = JS_InitClass(cx, + /* create document object and return it */ + JSObject *jsdocument; + struct jsclass_document_priv *document; + + document = malloc(sizeof(document)); + if (document == NULL) { + return NULL; + } + document->htmlc = htmlc; + document->node = htmlc->document; + + jsdocument = JS_InitClass(cx, parent, NULL, &jsclass_document, @@ -200,16 +202,18 @@ JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, void *doc_priv) jsfunctions_document, NULL, NULL); - if (doc == NULL) { + if (jsdocument == NULL) { + free(document); return NULL; } - LOG(("setting content to %p",doc_priv)); + LOG(("setting document private to %p", document)); /* private pointer to browsing context */ - if (JS_SetPrivate(cx, doc, doc_priv) != JS_TRUE) { - LOG(("failed to set content")); + if (JS_SetPrivate(cx, jsdocument, document) != JS_TRUE) { + LOG(("failed to set document private")); + free(document); return NULL; } - return doc; + return jsdocument; } diff --git a/javascript/jsapi/domexception.c b/javascript/jsapi/domexception.c new file mode 100644 index 000000000..b7c61cf45 --- /dev/null +++ b/javascript/jsapi/domexception.c @@ -0,0 +1,106 @@ +/* + * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <dom/dom.h> + + +#include "javascript/jsapi.h" +#include "utils/config.h" +#include "render/html_internal.h" +#include "utils/log.h" + +/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#exception-domexception +exception DOMException { + const unsigned short INDEX_SIZE_ERR = 1; + const unsigned short DOMSTRING_SIZE_ERR = 2; // historical + const unsigned short HIERARCHY_REQUEST_ERR = 3; + const unsigned short WRONG_DOCUMENT_ERR = 4; + const unsigned short INVALID_CHARACTER_ERR = 5; + const unsigned short NO_DATA_ALLOWED_ERR = 6; // historical + const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; + const unsigned short NOT_FOUND_ERR = 8; + const unsigned short NOT_SUPPORTED_ERR = 9; + const unsigned short INUSE_ATTRIBUTE_ERR = 10; // historical + const unsigned short INVALID_STATE_ERR = 11; + const unsigned short SYNTAX_ERR = 12; + const unsigned short INVALID_MODIFICATION_ERR = 13; + const unsigned short NAMESPACE_ERR = 14; + const unsigned short INVALID_ACCESS_ERR = 15; + const unsigned short VALIDATION_ERR = 16; // historical + const unsigned short TYPE_MISMATCH_ERR = 17; + const unsigned short SECURITY_ERR = 18; + const unsigned short NETWORK_ERR = 19; + const unsigned short ABORT_ERR = 20; + const unsigned short URL_MISMATCH_ERR = 21; + const unsigned short QUOTA_EXCEEDED_ERR = 22; + const unsigned short TIMEOUT_ERR = 23; + const unsigned short INVALID_NODE_TYPE_ERR = 24; + const unsigned short DATA_CLONE_ERR = 25; + unsigned short code; +}; + +*/ + +static JSClass jsclass_domexception = +{ + "DOMException", + JSCLASS_HAS_PRIVATE, + JS_PropertyStub, + JS_PropertyStub, + JS_PropertyStub, + JS_StrictPropertyStub, + JS_EnumerateStub, + JS_ResolveStub, + JS_ConvertStub, + JS_FinalizeStub, + JSCLASS_NO_OPTIONAL_MEMBERS +}; + + + +JSObject * +jsapi_new_domexception(JSContext *cx, + JSObject *parent, + int code) +{ + /* create element object and return it*/ + JSObject *jsdomexception; + + jssomexception = JS_InitClass(cx, + parent, + NULL, + &jsclass_domexception, + NULL, + 0, + NULL, + NULL, + NULL, + NULL); + if (jsdomexecption == NULL) { + return NULL; + } + + LOG(("setting element private to %d", code)); + /* private pointer to browsing context */ + if (JS_SetPrivate(cx, jsdomexception, code) != JS_TRUE) { + LOG(("failed to set content")); + return NULL; + } + + return jsdomexception; +} diff --git a/javascript/jsapi/element.c b/javascript/jsapi/element.c new file mode 100644 index 000000000..8ea7017d5 --- /dev/null +++ b/javascript/jsapi/element.c @@ -0,0 +1,157 @@ +/* + * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <dom/dom.h> + +#include "utils/config.h" +#include "utils/log.h" +#include "render/html_internal.h" + +#include "javascript/jsapi.h" + +/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-element + +CAUTION - innerHTML etc. are not part of the DOM they come from: +http://html5.org/specs/dom-parsing.html#extensions-to-the-element-interface + +interface Element : Node { + readonly attribute DOMString? namespaceURI; + readonly attribute DOMString? prefix; + readonly attribute DOMString localName; + readonly attribute DOMString tagName; + + attribute DOMString id; + attribute DOMString className; + readonly attribute DOMTokenList classList; + + readonly attribute Attr[] attributes; + DOMString? getAttribute(DOMString name); + DOMString? getAttributeNS(DOMString? namespace, DOMString localName); + void setAttribute(DOMString name, DOMString value); + void setAttributeNS(DOMString? namespace, DOMString name, DOMString value); + void removeAttribute(DOMString name); + void removeAttributeNS(DOMString? namespace, DOMString localName); + boolean hasAttribute(DOMString name); + boolean hasAttributeNS(DOMString? namespace, DOMString localName); + + HTMLCollection getElementsByTagName(DOMString localName); + HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); + HTMLCollection getElementsByClassName(DOMString classNames); + + readonly attribute HTMLCollection children; + readonly attribute Element? firstElementChild; + readonly attribute Element? lastElementChild; + readonly attribute Element? previousElementSibling; + readonly attribute Element? nextElementSibling; + readonly attribute unsigned long childElementCount; + + // NEW + void prepend((Node or DOMString)... nodes); + void append((Node or DOMString)... nodes); + void before((Node or DOMString)... nodes); + void after((Node or DOMString)... nodes); + void replace((Node or DOMString)... nodes); + void remove(); +}; +*/ + +static void jsfinalize_element(JSContext *cx, JSObject *obj); + +struct jsclass_document_priv { + struct html_content *htmlc; + dom_element *node; +}; + +static JSClass jsclass_element = +{ + "Element", + JSCLASS_HAS_PRIVATE, + JS_PropertyStub, + JS_PropertyStub, + JS_PropertyStub, + JS_StrictPropertyStub, + JS_EnumerateStub, + JS_ResolveStub, + JS_ConvertStub, + jsfinalize_element, + JSCLASS_NO_OPTIONAL_MEMBERS +}; + +#define JSCLASS_NAME element + +#include "node.c" + +static void jsfinalize_element(JSContext *cx, JSObject *obj) +{ + struct jsclass_document_priv *element; + element = JS_GetInstancePrivate(cx, obj, &jsclass_element, NULL); + if (element != NULL) { + free(element); + } +} + + + +static JSFunctionSpec jsfunctions_element[] = { + JSAPI_FS_NODE, + JSAPI_FS_END +}; + + +JSObject * +jsapi_new_element(JSContext *cx, + JSObject *parent, + struct html_content *htmlc, + dom_element *domelement) +{ + /* create element object and return it */ + JSObject *jselement; + struct jsclass_document_priv *element; + + element = malloc(sizeof(element)); + if (element == NULL) { + return NULL; + } + element->htmlc = htmlc; + element->node = domelement; + + jselement = JS_InitClass(cx, + parent, + NULL, + &jsclass_element, + NULL, + 0, + NULL, + jsfunctions_element, + NULL, + NULL); + if (jselement == NULL) { + free(element); + return NULL; + } + + LOG(("setting private to %p", element)); + /* private pointer to browsing context */ + if (JS_SetPrivate(cx, jselement, element) != JS_TRUE) { + LOG(("failed to set private")); + free(element); + return NULL; + } + + return jselement; +} diff --git a/javascript/jsapi/eventtarget.c b/javascript/jsapi/eventtarget.c new file mode 100644 index 000000000..fc6f6f657 --- /dev/null +++ b/javascript/jsapi/eventtarget.c @@ -0,0 +1,88 @@ +/* + * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventtarget + +interface EventTarget { + void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false); + void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false); + boolean dispatchEvent(Event event); +}; +*/ + + +#ifndef JSCLASS_NAME +#error "The class name must be defined" +#endif + +#ifndef JSCLASS_TYPE +#define CLASS jsclass +#define PRIVATE priv +#define EXPAND(a,b) PASTE(a,b) +#define PASTE(x,y) x##_##y +#define JSCLASS_OBJECT EXPAND(CLASS,JSCLASS_NAME) +#define JSCLASS_TYPE EXPAND(JSCLASS_OBJECT,PRIVATE) +#endif + +static JSBool JSAPI_NATIVE(addEventListener, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(removeEventListener, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(dispatchEvent, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +#define JSAPI_FS_EVENTTARGET \ + JSAPI_FS(addEventListener, 0, 0), \ + JSAPI_FS(removeEventListener, 0, 0), \ + JSAPI_FS(dispatchEvent, 0, 0) diff --git a/javascript/jsapi/navigator.c b/javascript/jsapi/navigator.c index daddc1d45..88fc5351a 100644 --- a/javascript/jsapi/navigator.c +++ b/javascript/jsapi/navigator.c @@ -17,8 +17,7 @@ */ #include <assert.h> - -#include "javascript/jsapi.h" +#include <stdlib.h> #include "desktop/netsurf.h" #include "desktop/options.h" @@ -28,6 +27,8 @@ #include "utils/log.h" #include "utils/utsname.h" +#include "javascript/jsapi.h" + /* * navigator properties for netsurf * diff --git a/javascript/jsapi/node.c b/javascript/jsapi/node.c new file mode 100644 index 000000000..ecb32004a --- /dev/null +++ b/javascript/jsapi/node.c @@ -0,0 +1,288 @@ +/* + * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-node +interface Node : EventTarget { + const unsigned short ELEMENT_NODE = 1; + const unsigned short ATTRIBUTE_NODE = 2; // historical + const unsigned short TEXT_NODE = 3; + const unsigned short CDATA_SECTION_NODE = 4; // historical + const unsigned short ENTITY_REFERENCE_NODE = 5; // historical + const unsigned short ENTITY_NODE = 6; // historical + const unsigned short PROCESSING_INSTRUCTION_NODE = 7; + const unsigned short COMMENT_NODE = 8; + const unsigned short DOCUMENT_NODE = 9; + const unsigned short DOCUMENT_TYPE_NODE = 10; + const unsigned short DOCUMENT_FRAGMENT_NODE = 11; + const unsigned short NOTATION_NODE = 12; // historical + readonly attribute unsigned short nodeType; + readonly attribute DOMString nodeName; + + readonly attribute DOMString? baseURI; + + readonly attribute Document? ownerDocument; + readonly attribute Node? parentNode; + readonly attribute Element? parentElement; + boolean hasChildNodes(); + readonly attribute NodeList childNodes; + readonly attribute Node? firstChild; + readonly attribute Node? lastChild; + readonly attribute Node? previousSibling; + readonly attribute Node? nextSibling; + + const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; + const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; + const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; + const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; + const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; + const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; // historical + unsigned short compareDocumentPosition(Node other); + boolean contains(Node? other); + + attribute DOMString? nodeValue; + attribute DOMString? textContent; + Node insertBefore(Node node, Node? child); + Node appendChild(Node node); + Node replaceChild(Node node, Node child); + Node removeChild(Node child); + void normalize(); + + + Node cloneNode(optional boolean deep = true); + boolean isEqualNode(Node? node); + + DOMString lookupPrefix(DOMString? namespace); + DOMString lookupNamespaceURI(DOMString? prefix); + boolean isDefaultNamespace(DOMString? namespace); +}; +*/ + +#include "eventtarget.c" + +#ifndef JSCLASS_NAME +#error "The class name must be defined" +#endif + +#ifndef JSCLASS_TYPE +#define CLASS jsclass +#define PRIVATE priv +#define EXPAND(a,b) PASTE(a,b) +#define PASTE(x,y) x##_##y +#define JSCLASS_OBJECT EXPAND(CLASS,JSCLASS_NAME) +#define JSCLASS_TYPE EXPAND(JSCLASS_OBJECT,PRIVATE) +#endif + +static JSBool JSAPI_NATIVE(hasChildNodes, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(compareDocumentPosition, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(contains, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(insertBefore, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(appendChild, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(replaceChild, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(removeChild, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(normalize, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(cloneNode, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(isEqualNode, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(lookupPrefix, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(lookupNamespaceURI, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + +static JSBool JSAPI_NATIVE(isDefaultNamespace, JSContext *cx, uintN argc, jsval *vp) +{ + struct JSCLASS_TYPE *priv; + + priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); + if (priv == NULL) + return JS_FALSE; + + + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + + return JS_TRUE; +} + + +#define JSAPI_FS_NODE \ + JSAPI_FS_EVENTTARGET, \ + JSAPI_FS(hasChildNodes, 0, 0), \ + JSAPI_FS(compareDocumentPosition, 0, 0), \ + JSAPI_FS(contains, 0, 0), \ + JSAPI_FS(insertBefore, 0, 0), \ + JSAPI_FS(appendChild, 0, 0), \ + JSAPI_FS(replaceChild, 0, 0), \ + JSAPI_FS(removeChild, 0, 0), \ + JSAPI_FS(normalize, 0, 0), \ + JSAPI_FS(cloneNode, 0, 0), \ + JSAPI_FS(isEqualNode, 0, 0), \ + JSAPI_FS(lookupPrefix, 0, 0), \ + JSAPI_FS(lookupNamespaceURI, 0, 0), \ + JSAPI_FS(isDefaultNamespace, 0, 0) diff --git a/javascript/jsapi/window.c b/javascript/jsapi/window.c index 0b7673be3..4f7e75109 100644 --- a/javascript/jsapi/window.c +++ b/javascript/jsapi/window.c @@ -16,11 +16,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "javascript/jsapi.h" - -#include "content/content.h" #include "utils/log.h" +#include "javascript/jsapi.h" + /* IDL [NamedPropertiesObject] diff --git a/render/html.c b/render/html.c index 8526ca001..3ee85b419 100644 --- a/render/html.c +++ b/render/html.c @@ -335,10 +335,10 @@ html_create_html_data(html_content *c, const http_parameter *params) c->parser = dom_hubbub_parser_create(c->encoding, true, nsoption_bool(enable_javascript), - &c->document, NULL, html_process_script, - c); + c, + &c->document); if ((c->parser == NULL) && (c->encoding != NULL)) { /* Ok, we don't support the declared encoding. Bailing out * isn't exactly user-friendly, so fall back to autodetect */ @@ -348,12 +348,10 @@ html_create_html_data(html_content *c, const http_parameter *params) c->parser = dom_hubbub_parser_create(c->encoding, true, nsoption_bool(enable_javascript), - &c->document, NULL, html_process_script, - c); - - + c, + &c->document); } if (c->parser == NULL) { @@ -451,10 +449,10 @@ html_process_encoding_change(struct content *c, html->parser = dom_hubbub_parser_create(html->encoding, true, nsoption_bool(enable_javascript), - &html->document, NULL, html_process_script, - html); + html, + &html->document); if (html->parser == NULL) { /* Ok, we don't support the declared encoding. Bailing out * isn't exactly user-friendly, so fall back to Windows-1252 */ @@ -471,11 +469,10 @@ html_process_encoding_change(struct content *c, html->parser = dom_hubbub_parser_create(html->encoding, true, nsoption_bool(enable_javascript), - &html->document, - NULL, html_process_script, - html); + html, + &html->document); if (html->parser == NULL) { union content_msg_data msg_data; diff --git a/render/html_forms.c b/render/html_forms.c index 9ae8138d6..fc2bcaf8a 100644 --- a/render/html_forms.c +++ b/render/html_forms.c @@ -468,9 +468,6 @@ struct form_control *html_forms_get_control_for_node(struct form *forms, dom_nod dom_exception err; dom_string *ds_name = NULL; - if (forms == NULL) - return NULL; - /* Step one, see if we already have a control */ for (f = forms; f != NULL; f = f->prev) { for (ctl = f->controls; ctl != NULL; ctl = ctl->next) { diff --git a/utils/nsurl.c b/utils/nsurl.c index 2e73866b2..1107d67f9 100644 --- a/utils/nsurl.c +++ b/utils/nsurl.c @@ -227,11 +227,13 @@ enum url_sections { #define nsurl__component_copy(c) (c == NULL) ? NULL : lwc_string_ref(c) -#define nsurl__component_compare(c1, c2, match) \ - if (c1 && c2) \ - lwc_string_isequal(c1, c2, match); \ - else if (c1 || c2) \ - *match = false; +#define nsurl__component_compare(c1, c2, match) \ + if (c1 && c2 && lwc_error_ok == \ + lwc_string_isequal(c1, c2, match)) { \ + /* do nothing */ \ + } else if (c1 || c2) { \ + *match = false; \ + } /** diff --git a/windows/about.c b/windows/about.c index 164ee9381..74bca0ed9 100644 --- a/windows/about.c +++ b/windows/about.c @@ -16,9 +16,12 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <windows.h> #include <stdio.h> +#include "utils/config.h" + +#include <windows.h> + #include "utils/utils.h" #include "utils/messages.h" #include "desktop/netsurf.h" diff --git a/windows/bitmap.c b/windows/bitmap.c index aaa5633bc..378dc8bb9 100644 --- a/windows/bitmap.c +++ b/windows/bitmap.c @@ -20,6 +20,9 @@ #include <inttypes.h> #include <sys/types.h> #include <string.h> + +#include "utils/config.h" + #include <windows.h> #include "image/bitmap.h" diff --git a/windows/download.c b/windows/download.c index e9ab28b97..635e3b604 100644 --- a/windows/download.c +++ b/windows/download.c @@ -17,10 +17,13 @@ */ #include <limits.h> -#include <windows.h> -#include <shlobj.h> #include <sys/time.h> +#include "utils/config.h" + +#include <shlobj.h> +#include <windows.h> + #include "content/fetch.h" #include "desktop/gui.h" #include "utils/schedule.h" diff --git a/windows/drawable.c b/windows/drawable.c index 883931e32..1688fc8d1 100644 --- a/windows/drawable.c +++ b/windows/drawable.c @@ -18,6 +18,8 @@ #include <stdbool.h> +#include "utils/config.h" + #include <windows.h> #include <windowsx.h> diff --git a/windows/findfile.c b/windows/findfile.c index 8a3cb44a6..a91125c59 100644 --- a/windows/findfile.c +++ b/windows/findfile.c @@ -17,7 +17,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <winsock2.h> #include <windows.h> + #include <limits.h> #include <unistd.h> #include <stdbool.h> @@ -25,6 +27,7 @@ #include <stdlib.h> #include <string.h> + #include <curl/curl.h> #include "utils/url.h" diff --git a/windows/font.c b/windows/font.c index f97e366f6..9a5d9ebc6 100644 --- a/windows/font.c +++ b/windows/font.c @@ -21,7 +21,11 @@ #include <inttypes.h> #include <assert.h> + +#include "utils/config.h" + #include <windows.h> + #include "css/css.h" #include "render/font.h" #include "desktop/options.h" diff --git a/windows/gui.c b/windows/gui.c index 21e9d1743..27f55c860 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -23,6 +23,8 @@ #include <unistd.h> #include <string.h> +#include "utils/config.h" + #include <windows.h> #include <windowsx.h> #include <commctrl.h> diff --git a/windows/localhistory.c b/windows/localhistory.c index d1d533f4e..aad1aa402 100644 --- a/windows/localhistory.c +++ b/windows/localhistory.c @@ -16,6 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "utils/config.h" + #include <windows.h> #include <windowsx.h> #include <commctrl.h> diff --git a/windows/main.c b/windows/main.c index 8213ca8c7..6d2179a9e 100644 --- a/windows/main.c +++ b/windows/main.c @@ -18,6 +18,9 @@ #include <limits.h> #include <stdbool.h> + +#include "utils/config.h" + #include <windows.h> #include "desktop/gui.h" diff --git a/windows/misc.c b/windows/misc.c index 513a2bd1d..5132e612b 100644 --- a/windows/misc.c +++ b/windows/misc.c @@ -20,6 +20,9 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> + +#include "utils/config.h" + #include <windows.h> #include "desktop/cookies.h" diff --git a/windows/plot.c b/windows/plot.c index 2898fae27..b3c3e5892 100644 --- a/windows/plot.c +++ b/windows/plot.c @@ -22,6 +22,9 @@ #include <string.h> #include <limits.h> #include <math.h> + +#include "utils/config.h" + #include <windows.h> #include "utils/log.h" @@ -94,12 +97,13 @@ static bool line(int x0, int y0, int x1, int y1, const plot_style_t *style) DeleteObject(clipregion); return false; } +/* RECT r; r.left = x0; r.top = y0; r.right = x1; r.bottom = y1; - +*/ SelectClipRgn(plot_hdc, clipregion); MoveToEx(plot_hdc, x0, y0, (LPPOINT) NULL); @@ -276,15 +280,16 @@ static bool text(int x, int y, const char *text, size_t length, int wlen; SIZE s; LPWSTR wstring; - RECT r; fontbak = (HFONT) SelectObject(plot_hdc, font); GetTextExtentPoint(plot_hdc, text, length, &s); +/* + RECT r; r.left = x; r.top = y - (3 * s.cy) / 4; r.right = x + s.cx; r.bottom = y + s.cy / 4; - +*/ SelectClipRgn(plot_hdc, clipregion); SetTextAlign(plot_hdc, TA_BASELINE | TA_LEFT); @@ -354,12 +359,13 @@ static bool disc(int x, int y, int radius, const plot_style_t *style) DeleteObject(brush); return false; } +/* RECT r; r.left = x - radius; r.top = y - radius; r.right = x + radius; r.bottom = y + radius; - +*/ SelectClipRgn(plot_hdc, clipregion); if (style->fill_type == PLOT_OP_TYPE_NONE) @@ -408,7 +414,7 @@ static bool arc(int x, int y, int radius, int angle1, int angle2, DeleteObject(pen); return false; } - RECT r; + int q1, q2; double a1=1.0, a2=1.0, b1=1.0, b2=1.0; q1 = (int) ((angle1 + 45) / 90) - 45; @@ -462,11 +468,13 @@ static bool arc(int x, int y, int radius, int angle1, int angle2, break; } +/* + RECT r; r.left = x - radius; r.top = y - radius; r.right = x + radius; r.bottom = y + radius; - +*/ SelectClipRgn(plot_hdc, clipregion); Arc(plot_hdc, x - radius, y - radius, x + radius, y + radius, diff --git a/windows/prefs.c b/windows/prefs.c index b3cdca3ae..577c2a509 100644 --- a/windows/prefs.c +++ b/windows/prefs.c @@ -16,6 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "utils/config.h" + #include <windows.h> #include <commctrl.h> diff --git a/windows/thumbnail.c b/windows/thumbnail.c index e2d85fc64..4ce0aba1c 100644 --- a/windows/thumbnail.c +++ b/windows/thumbnail.c @@ -16,6 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "utils/config.h" + #include <windows.h> #include "content/urldb.h" |