nsgenjsbind: branch master updated. b29ff13b599730bf3eaec8f142e584f23e78c1fb
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/b29ff13b599730bf3...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/b29ff13b599730bf3ea...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/b29ff13b599730bf3eaec...
The branch, master has been updated
via b29ff13b599730bf3eaec8f142e584f23e78c1fb (commit)
from 6f54ba5f6a2008191c2bb3435f8015ae70bcf156 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/b29ff13b599730b...
commit b29ff13b599730bf3eaec8f142e584f23e78c1fb
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
add type suffix annotations to webidl AST
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index ba9d44f..7957f02 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -317,6 +317,12 @@ static const char *webidl_node_type_to_str(enum webidl_node_type type)
case WEBIDL_NODE_TYPE_TYPE_BASE:
return "Base";
+ case WEBIDL_NODE_TYPE_TYPE_NULLABLE:
+ return "Nullable";
+
+ case WEBIDL_NODE_TYPE_TYPE_ARRAY:
+ return "Array";
+
case WEBIDL_NODE_TYPE_MODIFIER:
return "Modifier";
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index 5d7c615..aa791ca 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -32,6 +32,9 @@ enum webidl_node_type {
WEBIDL_NODE_TYPE_ELLIPSIS,
WEBIDL_NODE_TYPE_TYPE,
WEBIDL_NODE_TYPE_TYPE_BASE,
+ WEBIDL_NODE_TYPE_TYPE_NULLABLE,
+ WEBIDL_NODE_TYPE_TYPE_ARRAY,
+
WEBIDL_NODE_TYPE_LITERAL_NULL,
WEBIDL_NODE_TYPE_LITERAL_INT,
WEBIDL_NODE_TYPE_LITERAL_BOOL,
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index f719110..bf79e8f 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -163,6 +163,9 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str)
%type <node> UnsignedIntegerType
%type <node> IntegerType
+%type <node> TypeSuffix
+%type <node> TypeSuffixStartingWithArray
+
%type <node> FloatLiteral
%type <node> BooleanLiteral
%type <node> ConstValue
@@ -1099,16 +1102,19 @@ UnionMemberTypes:
/* [62] */
NonAnyType:
PrimitiveType TypeSuffix
+ {
+ $$ = webidl_node_prepend($1, $2);
+ }
|
TOK_STRING TypeSuffix
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, NULL, (void *)WEBIDL_TYPE_STRING);
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, $2, (void *)WEBIDL_TYPE_STRING);
}
|
TOK_IDENTIFIER TypeSuffix
{
struct webidl_node *type;
- type = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, NULL, (void *)WEBIDL_TYPE_USER);
+ type = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, $2, (void *)WEBIDL_TYPE_USER);
$$ = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, type, $1);
}
|
@@ -1119,12 +1125,12 @@ NonAnyType:
|
TOK_OBJECT TypeSuffix
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, NULL, (void *)WEBIDL_TYPE_OBJECT);
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, $2, (void *)WEBIDL_TYPE_OBJECT);
}
|
TOK_DATE TypeSuffix
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, NULL, (void *)WEBIDL_TYPE_DATE);
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, $2, (void *)WEBIDL_TYPE_DATE);
}
;
@@ -1237,17 +1243,32 @@ OptionalLong:
/* [70] */
TypeSuffix:
/* empty */
+ {
+ $$ = NULL;
+ }
|
'[' ']' TypeSuffix
+ {
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_ARRAY, $3, NULL);
+ }
|
'?' TypeSuffixStartingWithArray
+ {
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_NULLABLE, $2, NULL);
+ }
;
/* [71] */
TypeSuffixStartingWithArray:
/* empty */
+ {
+ $$ = NULL;
+ }
|
'[' ']' TypeSuffix
+ {
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_ARRAY, $3, NULL);
+ }
;
/* [72] */
-----------------------------------------------------------------------
Summary of changes:
src/webidl-ast.c | 6 ++++++
src/webidl-ast.h | 3 +++
src/webidl-parser.y | 29 +++++++++++++++++++++++++----
3 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index ba9d44f..7957f02 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -317,6 +317,12 @@ static const char *webidl_node_type_to_str(enum webidl_node_type type)
case WEBIDL_NODE_TYPE_TYPE_BASE:
return "Base";
+ case WEBIDL_NODE_TYPE_TYPE_NULLABLE:
+ return "Nullable";
+
+ case WEBIDL_NODE_TYPE_TYPE_ARRAY:
+ return "Array";
+
case WEBIDL_NODE_TYPE_MODIFIER:
return "Modifier";
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index 5d7c615..aa791ca 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -32,6 +32,9 @@ enum webidl_node_type {
WEBIDL_NODE_TYPE_ELLIPSIS,
WEBIDL_NODE_TYPE_TYPE,
WEBIDL_NODE_TYPE_TYPE_BASE,
+ WEBIDL_NODE_TYPE_TYPE_NULLABLE,
+ WEBIDL_NODE_TYPE_TYPE_ARRAY,
+
WEBIDL_NODE_TYPE_LITERAL_NULL,
WEBIDL_NODE_TYPE_LITERAL_INT,
WEBIDL_NODE_TYPE_LITERAL_BOOL,
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index f719110..bf79e8f 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -163,6 +163,9 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str)
%type <node> UnsignedIntegerType
%type <node> IntegerType
+%type <node> TypeSuffix
+%type <node> TypeSuffixStartingWithArray
+
%type <node> FloatLiteral
%type <node> BooleanLiteral
%type <node> ConstValue
@@ -1099,16 +1102,19 @@ UnionMemberTypes:
/* [62] */
NonAnyType:
PrimitiveType TypeSuffix
+ {
+ $$ = webidl_node_prepend($1, $2);
+ }
|
TOK_STRING TypeSuffix
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, NULL, (void *)WEBIDL_TYPE_STRING);
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, $2, (void *)WEBIDL_TYPE_STRING);
}
|
TOK_IDENTIFIER TypeSuffix
{
struct webidl_node *type;
- type = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, NULL, (void *)WEBIDL_TYPE_USER);
+ type = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, $2, (void *)WEBIDL_TYPE_USER);
$$ = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, type, $1);
}
|
@@ -1119,12 +1125,12 @@ NonAnyType:
|
TOK_OBJECT TypeSuffix
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, NULL, (void *)WEBIDL_TYPE_OBJECT);
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, $2, (void *)WEBIDL_TYPE_OBJECT);
}
|
TOK_DATE TypeSuffix
{
- $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, NULL, (void *)WEBIDL_TYPE_DATE);
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_BASE, $2, (void *)WEBIDL_TYPE_DATE);
}
;
@@ -1237,17 +1243,32 @@ OptionalLong:
/* [70] */
TypeSuffix:
/* empty */
+ {
+ $$ = NULL;
+ }
|
'[' ']' TypeSuffix
+ {
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_ARRAY, $3, NULL);
+ }
|
'?' TypeSuffixStartingWithArray
+ {
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_NULLABLE, $2, NULL);
+ }
;
/* [71] */
TypeSuffixStartingWithArray:
/* empty */
+ {
+ $$ = NULL;
+ }
|
'[' ']' TypeSuffix
+ {
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_TYPE_ARRAY, $3, NULL);
+ }
;
/* [72] */
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
netsurf: branch mono/removing-windom-dependency updated. fe0e2508e62323955df415b45e2ea9b1b7d6373f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/fe0e2508e62323955df41...
...commit http://git.netsurf-browser.org/netsurf.git/commit/fe0e2508e62323955df415b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/fe0e2508e62323955df415b45...
The branch, mono/removing-windom-dependency has been updated
via fe0e2508e62323955df415b45e2ea9b1b7d6373f (commit)
from 6ea22068aa50dfa15807e80277b1ad843146a76c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/fe0e2508e62323955df...
commit fe0e2508e62323955df415b45e2ea9b1b7d6373f
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Refactored a lot of browser window code,... still totally WIP.
...but it compiles...
diff --git a/atari/browser.c b/atari/browser.c
index 1b3661e..1904722 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -62,14 +62,14 @@ extern struct gui_window *input_window;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
-static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect );
+static void browser_process_scroll( struct gui_window * gw, GRECT bwrect );
static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff,
struct rect * area );
-static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8],
+static void __CDECL browser_evnt_destroy( COMPONENT * c, short buff[8],
void * data);
-static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8],
+static void __CDECL browser_evnt_redraw( COMPONENT * c, short buff[8],
void * data);
-static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8],
+static void __CDECL browser_evnt_mbutton( COMPONENT * c, short buff[8],
void * data);
@@ -104,7 +104,9 @@ struct s_browser * browser_create
return(NULL);
}
- /* Attach events to the component: */
+ /* Attach events to the component: */
+ // TODO: implement event chaining in rootwin
+ /*
mt_CompEvntDataAdd( &app, bnew->comp, WM_XBUTTON,
browser_evnt_mbutton, (void*)gw, EV_BOT
);
@@ -113,7 +115,8 @@ struct s_browser * browser_create
);
mt_CompEvntDataAttach( &app, bnew->comp, WM_DESTROY,
browser_evnt_destroy, (void*)bnew
- );
+ );
+ */
/* Set the gui_window owner. */
/* it is an link to the netsurf window system */
@@ -135,76 +138,69 @@ bool browser_destroy( struct s_browser * b )
LOG(("%s\n", b->bw->name ));
assert( b != NULL );
- assert( b->comp != NULL );
assert( b->bw != NULL );
+
+ struct gui_window * gw = b->bw->window;
+ LOG(("%s\n",gw->browser->bw->name));
+
+ assert( b != NULL );
+ assert( gw != NULL );
+ free( b );
+ gw->browser = NULL;
- if( b->comp != NULL ){
- mt_CompDelete(&app, b->comp );
- }
return( true );
}
/*
Query the browser component for widget rectangles.
*/
-void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT * out)
+void browser_get_rect( struct gui_window * gw, enum browser_rect type, GRECT * out)
{
- LGRECT cur;
-
+ GRECT cur;
+
+ // TODO: update browser get grect
/* Query component for it's current size: */
- mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &cur);
-
/* And extract the different widget dimensions: */
- if( type == BR_CONTENT ){
- out->g_w = cur.g_w;
- out->g_h = cur.g_h;
- out->g_x = cur.g_x;
- out->g_y = cur.g_y;
- }
+ if (type == BR_CONTENT ) {
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, out);
+ }
+ else if (type==BR_URL_INPUT) {
+ // TODO: calculate url input area somehow
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_TOOLBAR, out);
+ }
+ else if (type==BR_THROBBER) {
+ // TODO: calculate throbber area somehow
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_TOOLBAR, out);
+ }
- return;
-}
-/* Report an resize to the COMPONENT interface */
-void browser_update_rects(struct gui_window * gw )
-{
- short buff[8];
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&buff[4]);
- buff[0] = CM_REFLOW;
- buff[1] = _AESapid;
- buff[2] = 0;
- EvntExec(gw->root->handle, buff);
+ return;
}
void browser_set_content_size(struct gui_window * gw, int w, int h)
{
CMP_BROWSER b = gw->browser;
- LGRECT work;
+ GRECT work;
browser_get_rect( gw, BR_CONTENT, &work );
-
- gw->root->handle->xpos_max = w;
- gw->root->handle->ypos_max = h;
-
- if( w < work.g_w + b->scroll.current.x || w < work.g_h + b->scroll.current.y ) {
- /* let the scroll routine detect invalid scroll values... */
- browser_scroll(gw, WA_LFLINE, b->scroll.current.x, true );
- browser_scroll(gw, WA_UPLINE, b->scroll.current.y, true );
- /* force update of scrollbars: */
- b->scroll.required = true;
- }
+
+ // TODO: implement new content size setter
+ //gw->root->handle->xpos_max = w;
+ //gw->root->handle->ypos_max = h;
+
+// if( w < work.g_w + b->scroll.current.x || w < work.g_h + b->scroll.current.y ) {
+// /* let the scroll routine detect invalid scroll values... */
+// browser_scroll(gw, WA_LFLINE, b->scroll.current.x, true );
+// browser_scroll(gw, WA_UPLINE, b->scroll.current.y, true );
+// /* force update of scrollbars: */
+// b->scroll.required = true;
+// }
}
-static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * data)
+static void __CDECL browser_evnt_destroy( COMPONENT * c, short buff[8], void * data)
{
struct s_browser * b = (struct s_browser*)data;
- struct gui_window * gw = b->bw->window;
- LOG(("%s\n",gw->browser->bw->name));
- assert( b != NULL );
- assert( gw != NULL );
- free( b );
- gw->browser = NULL;
LOG(("evnt_destroy done!"));
}
@@ -212,10 +208,10 @@ static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * da
Mouse Button handler for browser component.
*/
-static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * data)
+static void __CDECL browser_evnt_mbutton( COMPONENT * c, short buff[8], void * data)
{
short mx, my, dummy, mbut;
- LGRECT cwork;
+ GRECT cwork;
browser_mouse_state bmstate = 0;
struct gui_window * gw = data;
@@ -223,8 +219,8 @@ static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * da
input_window = gw;
}
- window_set_focus( gw, BROWSER, (void*)gw->browser );
- browser_get_rect( gw, BR_CONTENT, &cwork );
+ window_set_focus(gw->root, BROWSER, (void*)gw->browser );
+ browser_get_rect(gw, BR_CONTENT, &cwork );
/* convert screen coords to component coords: */
mx = evnt.mx - cwork.g_x;
@@ -309,7 +305,7 @@ static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * da
*/
void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
{
- LGRECT work;
+ GRECT work;
int max_y_scroll;
int max_x_scroll;
int oldx = gw->browser->scroll.current.x;
@@ -399,7 +395,7 @@ void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
bwrect -> the dimensions of the browser, so that this function
doesn't need to get it.
*/
-static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
+static void browser_process_scroll( struct gui_window * gw, GRECT bwrect )
{
struct s_browser * b = gw->browser;
GRECT src;
@@ -486,11 +482,12 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
if( b->caret.requested.g_w > 0 ){
b->caret.redraw = true;
}
+
+ // TODO: implement new sliding
+ //gw->root->handle->xpos = b->scroll.current.x;
+ //gw->root->handle->ypos = b->scroll.current.y;
- gw->root->handle->xpos = b->scroll.current.x;
- gw->root->handle->ypos = b->scroll.current.y;
-
- mt_WindSlider( &app, gw->root->handle, HSLIDER|VSLIDER );
+ //mt_WindSlider( &app, gw->root->handle, HSLIDER|VSLIDER );
}
/*
@@ -502,7 +499,7 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
*/
bool browser_input( struct gui_window * gw, unsigned short nkc )
{
- LGRECT work;
+ GRECT work;
bool r = false;
unsigned char ascii = (nkc & 0xFF);
long ucs4;
@@ -604,7 +601,7 @@ void browser_schedule_redraw(struct gui_window * gw, short x0, short y0, short x
{
assert( gw != NULL );
CMP_BROWSER b = gw->browser;
- LGRECT work;
+ GRECT work;
if( y1 < 0 || x1 < 0 )
return;
@@ -644,10 +641,10 @@ static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff,
/*
area: the browser canvas
*/
-void browser_restore_caret_background( struct gui_window * gw, LGRECT * area)
+void browser_restore_caret_background( struct gui_window * gw, GRECT * area)
{
CMP_BROWSER b = gw->browser;
- LGRECT rect;
+ GRECT rect;
if( area == NULL ){
browser_get_rect( gw, BR_CONTENT, &rect );
area = ▭
@@ -668,7 +665,7 @@ void browser_restore_caret_background( struct gui_window * gw, LGRECT * area)
/*
area: the browser canvas
*/
-void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
+void browser_redraw_caret( struct gui_window * gw, GRECT * area )
{
if( gw->browser->caret.redraw && gw->browser->caret.requested.g_w > 0 ){
@@ -677,12 +674,12 @@ void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
/* Only redraw caret when window is topped. */
wind_get( 0, WF_TOP, &wind_info[0], &wind_info[1], &wind_info[2], &wind_info[3]);
- if (gw->root->handle->handle != wind_info[0]) {
+ if (guiwin_get_handle(gw->root->win) != wind_info[0]) {
return;
}
- LGRECT caret;
+ GRECT caret;
struct s_browser * b = gw->browser;
struct rect old_clip;
struct rect clip;
@@ -695,7 +692,7 @@ void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
caret.g_x -= b->scroll.current.x - area->g_x;
caret.g_y -= b->scroll.current.y - area->g_y;
- if( !rc_lintersect( area, &caret ) ) {
+ if( !rc_intersect( area, &caret ) ) {
return;
}
@@ -745,7 +742,7 @@ void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
void browser_redraw( struct gui_window * gw )
{
- LGRECT bwrect;
+ GRECT bwrect;
struct s_browser * b = gw->browser;
short todo[4];
struct rect clip;
@@ -788,7 +785,7 @@ void browser_redraw( struct gui_window * gw )
wind_get( 0, WF_TOP, &wf_top[0], &wf_top[1],
&wf_top[2], &wf_top[3] );
- if( wf_top[0] == gw->root->handle->handle
+ if( wf_top[0] == guiwin_get_handle(gw->root->win)
&& wf_top[1] == _AESapid ){
/* The window is on top, so there is no need to walk the */
/* AES rectangle list. */
@@ -824,8 +821,9 @@ void browser_redraw( struct gui_window * gw )
}
}
} else {
- /* walk the AES rectangle list: */
- if( wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
+ /* walk the AES rectangle list: */
+ short aes_handle = guiwin_get_handle(gw->root->win);
+ if( wind_get(aes_handle, WF_FIRSTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
while (todo[2] && todo[3]) {
/* convert screen to framebuffer coords: */
@@ -862,7 +860,7 @@ void browser_redraw( struct gui_window * gw )
}
}
- if (wind_get(gw->root->handle->handle, WF_NEXTXYWH,
+ if (wind_get(aes_handle, WF_NEXTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3])==0) {
break;
}
@@ -894,7 +892,7 @@ void browser_redraw( struct gui_window * gw )
b->redraw.areas_used = 0;
}
if( b->caret.redraw == true && b->bw->current_content != NULL ) {
- LGRECT area;
+ GRECT area;
todo[0] = bwrect.g_x;
todo[1] = bwrect.g_y;
todo[2] = todo[0] + bwrect.g_w;
@@ -912,27 +910,18 @@ void browser_redraw( struct gui_window * gw )
/* TODO: if we use offscreen bitmap, trigger content redraw here */
}
-static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * data)
+static void __CDECL browser_evnt_redraw( COMPONENT * c, short buff[8], void * data)
{
struct gui_window * gw = (struct gui_window *) data;
CMP_BROWSER b = gw->browser;
- LGRECT work, lclip;
+ GRECT work, lclip;
browser_get_rect( gw, BR_CONTENT, &work );
lclip = work;
- if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) return;
-
- if( b->bw->current_content == NULL ){
- short pxy[4];
- pxy[0] = lclip.g_x;
- pxy[1] = lclip.g_y;
- pxy[2] = lclip.g_x + lclip.g_w - 1;
- pxy[3] = lclip.g_y + lclip.g_h - 1;
- vsf_color( gw->root->handle->graf->handle, WHITE );
- vsf_perimeter( gw->root->handle->graf->handle, 0);
- vsf_interior( gw->root->handle->graf->handle, FIS_SOLID );
- vsf_style( gw->root->handle->graf->handle, 1);
- v_bar( gw->root->handle->graf->handle, (short*)&pxy );
+ if ( !rc_intersect( (GRECT*)&buff[4], &lclip ) ) return;
+
+ if( b->bw->current_content == NULL ){
+ guiwin_clear(gw->root->win);
return;
}
@@ -953,13 +942,15 @@ static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * dat
if( lclip.g_h > 0 && lclip.g_w > 0 ) {
if( gw->browser->reformat_pending == true ){
- LGRECT newsize;
+ GRECT newsize;
gw->browser->reformat_pending = false;
browser_get_rect(gw, BR_CONTENT, &newsize);
/* this call will also schedule an redraw for the complete */
/* area. */
/* Resize must be handled here, because otherwise */
- /* a redraw is scheduled twice (1. by the frontend, 2. by AES) */
+ /* a redraw is scheduled twice (1. by the frontend, 2. by AES) */
+ // TODO: this was introduced because
+ // of bad knowledge about the AES system...
browser_window_reformat(b->bw, false, newsize.g_w, newsize.g_h );
} else {
browser_schedule_redraw( gw, lclip.g_x, lclip.g_y,
diff --git a/atari/browser.h b/atari/browser.h
index 3eb9437..e855e59 100755
--- a/atari/browser.h
+++ b/atari/browser.h
@@ -35,10 +35,9 @@
enum browser_rect
{
- BR_CONTENT = 1,
- BR_FULL = 2,
- BR_HSLIDER = 3,
- BR_VSLIDER = 4
+ BR_CONTENT = 1,
+ BR_URL_INPUT,
+ BR_THROBBER
};
@@ -60,8 +59,8 @@ struct s_scroll_info
*/
struct s_caret
{
- LGRECT requested;
- LGRECT current;
+ GRECT requested;
+ GRECT current;
bool redraw;
MFDB background;
};
@@ -89,17 +88,21 @@ struct s_browser
bool reformat_pending;
};
-struct s_browser * browser_create( struct gui_window * gw, struct browser_window * clone, struct browser_window *bw, int lt, int w, int flex );
+struct s_browser * browser_create( struct gui_window * gw,
+ struct browser_window * clone,
+ struct browser_window *bw, int lt, int w,
+ int flex );
bool browser_destroy( struct s_browser * b );
-void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT * out);
+void browser_get_rect( struct gui_window * gw, enum browser_rect type,
+ GRECT * out);
bool browser_input( struct gui_window * gw, unsigned short nkc ) ;
void browser_redraw( struct gui_window * gw );
void browser_set_content_size(struct gui_window * gw, int w, int h);
void browser_scroll( struct gui_window * gw, short MODE, int value, bool abs );
struct gui_window * browser_find_root( struct gui_window * gw );
bool browser_redraw_required( struct gui_window * gw);
-void browser_redraw_caret( struct gui_window * gw, LGRECT * area);
-void browser_restore_caret_background(struct gui_window * gw, LGRECT * area);
+void browser_redraw_caret( struct gui_window * gw, GRECT * area);
+void browser_restore_caret_background(struct gui_window * gw, GRECT * area);
/* update loc / size of the browser widgets: */
void browser_update_rects(struct gui_window * gw );
/*
diff --git a/atari/clipboard.h b/atari/clipboard.h
index e505d9f..aa032b7 100755
--- a/atari/clipboard.h
+++ b/atari/clipboard.h
@@ -17,9 +17,11 @@
*/
#ifndef NS_ATARI_CLIPBOARD_H
-#define NS_ATARI_CLIPBOARD_H
+#define NS_ATARI_CLIPBOARD_H
+
+#include <windom.h>
int scrap_txt_write( APPvar app, char *str);
char *scrap_txt_read( APPvar app );
-#endif
\ No newline at end of file
+#endif
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index 6239f21..66c4b7f 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -68,7 +68,7 @@ struct s_context_info ctxinfo;
static struct s_context_info * get_context_info( struct gui_window * gw, short mx, short my )
{
hlcache_handle *h;
- LGRECT bwrect;
+ GRECT bwrect;
struct contextual_content ccdata;
struct browser_window * bw = gw->browser->bw;
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index d486803..2502184 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -254,16 +254,15 @@ static void __CDECL menu_open_url(short item, short title, void *data)
if( gw == NULL ) {
bw = browser_window_create("", 0, 0, true, false);
gw = bw->window;
-
}
/* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
+ window_set_focus(gw->root, WIDGET_NONE, NULL );
/* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
+ window_set_focus(gw->root, URL_WIDGET, NULL);
/* delete selection: */
- tb_url_input( gw, NK_DEL );
+ toolbar_key_input(gw->root->toolbar, NK_DEL);
}
static void __CDECL menu_open_file(short item, short title, void *data)
@@ -273,7 +272,7 @@ static void __CDECL menu_open_file(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
- const char * filename = file_select( messages_get("OpenFile"), "" );
+ const char * filename = file_select(messages_get("OpenFile"), "");
if( filename != NULL ){
char * url = local_file_to_url( filename );
if( url ){
@@ -365,16 +364,18 @@ static void __CDECL menu_stop(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
- return;
- tb_stop_click( input_window );
+ return;
+
+ assert(input_window->root);
+ toolbar_stop_click(input_window->root->toolbar);
}
static void __CDECL menu_reload(short item, short title, void *data)
{
- if( input_window == NULL)
+ if(input_window == NULL)
return;
- tb_reload_click( input_window );
+ toolbar_reload_click(input_window->root->toolbar);
LOG(("%s", __FUNCTION__));
}
@@ -384,7 +385,8 @@ static void __CDECL menu_toolbars(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window != null && input_window->root->toolbar != null ){
state = !state;
- tb_hide( input_window, state );
+ // TODO: implement toolbar hide
+ //toolbar_hide(input_window->root->toolbar, state );
}
}
@@ -393,7 +395,8 @@ static void __CDECL menu_savewin(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if (input_window && input_window->browser) {
GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
+ wind_get_grect(guiwin_get_handle(input_window->root->win), WF_CURRXYWH,
+ &rect);
option_window_width = rect.g_w;
option_window_height = rect.g_h;
option_window_x = rect.g_x;
@@ -414,7 +417,7 @@ static void __CDECL menu_debug_render(short item, short title, void *data)
if( input_window != NULL ) {
if ( input_window->browser != NULL
&& input_window->browser->bw != NULL) {
- LGRECT rect;
+ GRECT rect;
browser_get_rect( input_window, BR_CONTENT, &rect );
browser_window_reformat(input_window->browser->bw, false,
rect.g_w, rect.g_h );
@@ -443,7 +446,7 @@ static void __CDECL menu_back(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
- tb_back_click( input_window );
+ toolbar_back_click(input_window->root->toolbar);
}
static void __CDECL menu_forward(short item, short title, void *data)
@@ -451,7 +454,7 @@ static void __CDECL menu_forward(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
- tb_forward_click( input_window );
+ toolbar_forward_click(input_window->root->toolbar);
}
static void __CDECL menu_home(short item, short title, void *data)
@@ -459,7 +462,7 @@ static void __CDECL menu_home(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
- tb_home_click( input_window );
+ toolbar_home_click(input_window->root->toolbar);
}
static void __CDECL menu_lhistory(short item, short title, void *data)
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index 6c590b5..ddcad78 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -60,9 +60,11 @@ short msg_box_show(short type, const char * msg);
#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
-#define GW_FLAG_CUSTOM_SCROLLING 0x10 // no internal scroller handling
+#define GW_FLAG_TOOLBAR_REDRAW 0x10 // enable internal toolbar redraw
+#define GW_FLAG_CUSTOM_SCROLLING 0x20 // no internal scroller handling
-#define GW_FLAG_DEFAULTS (GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM)
+#define GW_FLAG_DEFAULTS (GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM \
+ | GW_FLAG_TOOLBAR_REDRAW)
#define GW_STATUS_ICONIFIED 0x01
#define GW_STATUS_SHADED 0x02
@@ -112,7 +114,8 @@ bool guiwin_update_slider(GUIWIN *win, short mode);
void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
bool guiwin_has_intersection(GUIWIN *win, GRECT *work);
-void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip);
+void guiwin_toolbar_redraw(GUIWIN *win, GRECT *clip);
+void guiwin_clear(GUIWIN *win);
/*
@@ -124,6 +127,14 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip);
&& (_y >= r.g_y) && (_y <= r.g_y + r.g_h))
#endif
+#ifndef RC_WITHIN
+#define RC_WITHIN(a,b) \
+ (((a)->g_x >= (b)->g_x) \
+ && (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \
+ && (((a)->g_y >= (b)->g_y) \
+ && (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h)))
+#endif
+
#ifndef MAX
#define MAX(_a,_b) ((_a>_b) ? _a : _b)
#endif
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index cf47c46..7f06c91 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -5,6 +5,8 @@
#include <assert.h>
#include <cflib.h>
+
+#include <gem.h>
#include <mt_gem.h>
#include "gemtk.h"
@@ -27,13 +29,15 @@ static GUIWIN * winlist;
static VdiHdl v_vdi_h = -1;
static short work_out[57];
-static void move_rect(GRECT *rect, int dx, int dy)
+static void move_rect(GUIWIN * win, GRECT *rect, int dx, int dy)
{
INT16 xy[ 8];
long dum = 0L;
GRECT g;
- while( !wind_update(BEG_UPDATE));
+ VdiHdl vh = guiwin_get_vdi_handle(win);
+
+ while(!wind_update(BEG_UPDATE));
graf_mouse(M_OFF, 0L);
/* get intersection with screen area */
@@ -47,7 +51,7 @@ static void move_rect(GRECT *rect, int dx, int dy)
xy[5] = xy[1] + dy;
xy[6] = xy[2] + dx;
xy[7] = xy[3] + dy;
- vro_cpyfm(v_vdi_h, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
+ vro_cpyfm(vh, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
graf_mouse(M_ON, 0L);
wind_update(END_UPDATE);
@@ -81,7 +85,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
if(pix < 0 ) {
// blit screen area:
g.g_h -= abs_pix;
- move_rect(&g, 0, abs_pix);
+ move_rect(gw, &g, 0, abs_pix);
g.g_y = g_ro.g_y;
g.g_h = abs_pix;
redraw = &g;
@@ -89,7 +93,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
// blit screen area:
g.g_y += abs_pix;
g.g_h -= abs_pix;
- move_rect(&g, 0, -abs_pix);
+ move_rect(gw, &g, 0, -abs_pix);
g.g_y = g_ro.g_y + g_ro.g_h - abs_pix;
g.g_h = abs_pix;
redraw = &g;
@@ -112,7 +116,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
if(pix < 0 ) {
// blit screen area:
g.g_w -= abs_pix;
- move_rect(&g, abs_pix, 0);
+ move_rect(gw, &g, abs_pix, 0);
g.g_x = g_ro.g_x;
g.g_w = abs_pix;
redraw = &g;
@@ -120,7 +124,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
// blit screen area:
g.g_x += abs_pix;
g.g_w -= abs_pix;
- move_rect(&g, -abs_pix, 0);
+ move_rect(gw, &g, -abs_pix, 0);
g.g_x = g_ro.g_x + g_ro.g_w - abs_pix;
g.g_w = abs_pix;
redraw = &g;
@@ -292,7 +296,8 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_REDRAW:
- if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
+ if ((gw->flags & GW_FLAG_TOOLBAR_REDRAW)
+ && (gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
g.g_x = msg[4];
g.g_y = msg[5];
g.g_w = msg[6];
@@ -375,8 +380,8 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
// toolbar handling:
- if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 &&
- dest->toolbar != NULL) {
+ if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0
+ && dest->toolbar != NULL) {
GRECT tb_area;
guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
if (POINT_WITHIN(ev_out->emo_mouse.p_x,
@@ -394,10 +399,12 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
if (((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0)
&& obj_idx > 0) {
dest->toolbar[obj_idx].ob_state |= OS_SELECTED;
+ // TODO: optimize redraw by setting the object clip:
guiwin_toolbar_redraw(dest, NULL);
}
short oldevents = ev_out->emo_events;
ev_out->emo_events = MU_MESAG;
+ // notify the window about toolbar click:
dest->handler_func(dest, ev_out, msg_out);
handler_called=true;
ev_out->emo_events = oldevents;
@@ -590,6 +597,11 @@ short guiwin_get_handle(GUIWIN *win)
return(win->handle);
}
+VdiHdl guiwin_get_vdi_handle(GUIWIN *win)
+{
+ return(v_vdi_h);
+}
+
uint32_t guiwin_get_state(GUIWIN *win)
{
return(win->state);
@@ -649,13 +661,6 @@ void guiwin_send_redraw(GUIWIN *win, GRECT *area)
bool guiwin_has_intersection(GUIWIN *win, GRECT *work)
{
-
-#define RC_WITHIN(a,b) \
- (((a)->g_x >= (b)->g_x) \
- && (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \
- && (((a)->g_y >= (b)->g_y) \
- && (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h)))
-
GRECT area, mywork;
bool retval = true;
@@ -674,9 +679,6 @@ bool guiwin_has_intersection(GUIWIN *win, GRECT *work)
}
return(retval);
-
-#undef RC_WITHIN
-
}
void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
@@ -684,9 +686,6 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
GRECT tb_area, tb_area_ro, g;
guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
- if(tb_area_ro.g_h <= 0 || tb_area_ro.g_w <= 0) {
- return;
- }
if(clip == NULL) {
clip = &tb_area_ro;
@@ -695,6 +694,7 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
tb_area = tb_area_ro;
if(rc_intersect(clip, &tb_area)) {
+
// Update object position:
gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
@@ -712,11 +712,37 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
}
}
}
-/*
-void guiwin_exec_redraw(){
+void guiwin_clear(GUIWIN *win)
+{
+ GRECT area, g;
+ short pxy[4];
+ VdiHdl vh;
+
+ vh = guiwin_get_vdi_handle(win);
+
+ if(win->state & GW_STATUS_ICONIFIED){
+ // also clear the toolbar area when iconified:
+ guiwin_get_grect(win, GUIWIN_AREA_WORK, &area);
+ } else {
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &area);
+ }
+
+ vsf_interior(vh, FIS_SOLID);
+ vsf_color(vh, 0);
+ vswr_mode(vh, MD_REPLACE);
+ wind_get_grect(win->handle, WF_FIRSTXYWH, &g);
+ while (g.g_h > 0 || g.g_w > 0) {
+ if(rc_intersect(&area, &g)) {
+ pxy[0] = g.g_x;
+ pxy[1] = g.g_y;
+ pxy[2] = g.g_x+g.g_w-1;
+ pxy[3] = g.g_y+g.g_h-1;
+ v_bar(vh, pxy);
+ }
+ wind_get_grect(win->handle, WF_NEXTXYWH, &g);
+ }
}
-*/
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index 40b8859..dfee0dd 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -65,7 +65,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
static short prev_x=0;
static short prev_y=0;
bool within = false;
- LGRECT urlbox, bwbox, sbbox;
+ GRECT urlbox, bwbox, sbbox;
int nx, ny;
if (gw == NULL)
@@ -76,15 +76,13 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if (input_window->root->handle->handle == ghandle) {
+ if (guiwin_get_handle(input_window->root->win)==ghandle) {
// The window found at x,y is an gui_window
// and it's the input window.
- browser_get_rect( gw, BR_CONTENT, &bwbox );
-
- if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
+ browser_get_rect(gw, BR_CONTENT, &bwbox);
+ if (POINT_WITHIN(evnt.mx, evnt.my, bwbox)) {
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -95,9 +93,8 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
}
if (gw->root->toolbar && within == false) {
- mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
- if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
- (evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
+ browser_get_rect(gw, BR_URL_INPUT, &urlbox);
+ if(POINT_WITHIN(evnt.mx, evnt.my, urlbox)) {
gem_set_cursor( &gem_cursors.ibeam );
prev_url = true;
} else {
@@ -116,7 +113,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
prev_y = evnt.my;
}
-void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
+void __CDECL global_evnt_keybd(WINDOW * win, short buff[8], void * data)
{
long kstate = 0;
long kcode = 0;
@@ -134,18 +131,19 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
nkc= gem_to_norm( (short)kstate, (short)kcode );
nks = (nkc & 0xFF00);
if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
- if( window_url_widget_has_focus( gw ) ) {
+ kstate |= K_LSHIFT|K_RSHIFT;
+
+ if(window_url_widget_has_focus((void*)gw->root)) {
/* make sure we report for the root window and report...: */
- done = tb_url_input( gw, nkc );
+ done = toolbar_key_input(gw->root->toolbar, nkc);
} else {
gw_tmp = window_list;
/* search for active browser component: */
while( gw_tmp != NULL && done == false ) {
/* todo: only handle when input_window == ontop */
- if( window_widget_has_focus( (struct gui_window *)input_window,
- BROWSER,(void*)gw_tmp->browser)) {
- done = browser_input( gw_tmp, nkc );
+ if( window_widget_has_focus(input_window->root, BROWSER,
+ (void*)gw_tmp->browser)) {
+ done = browser_input(gw_tmp, nkc);
break;
} else {
gw_tmp = gw_tmp->next;
diff --git a/atari/gui.c b/atari/gui.c
index 889e4f2..0d85eef 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -116,47 +116,6 @@ EVMULT_IN aes_event_in = {
EVMULT_OUT aes_event_out;
short aes_msg_out[8];
-
-void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
-{
- long kstate = 0;
- long kcode = 0;
- unsigned short nkc = 0;
- unsigned short nks = 0;
-
- int i=0;
- bool done = false;
- struct gui_window * gw = input_window;
- struct gui_window * gw_tmp;
- if( gw == NULL )
- return;
- kstate = evnt.mkstate;
- kcode = evnt.keybd;
- nkc= gem_to_norm( (short)kstate, (short)kcode);
- nks = (nkc & 0xFF00);
- if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
- if( window_url_widget_has_focus( gw ) ) {
- /* make sure we report for the root window and report...: */
- done = tb_url_input( gw, nkc );
- } else {
- gw_tmp = window_list;
- /* search for active browser component: */
- while( gw_tmp != NULL && done == false ) {
- /* todo: only handle when input_window == ontop */
- if( window_widget_has_focus( (struct gui_window *)input_window,
- BROWSER,(void*)gw_tmp->browser)) {
- done = browser_input( gw_tmp, nkc );
- break;
- } else {
- gw_tmp = gw_tmp->next;
- }
- }
- }
- if(!done)
- deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
-}
-
void gui_poll(bool active)
{
int flags = MU_MESAG | MU_KEYBD | MU_BUTTON;
@@ -167,11 +126,30 @@ void gui_poll(bool active)
aes_event_in.emi_tlow = schedule_run();
- //printf("time: ");
-
if(active || rendering)
aes_event_in.emi_tlow = 0;
+ struct gui_window * g;
+
+ for( g = window_list; g != NULL; g=g->next ) {
+ if( browser_redraw_required( g ) ) {
+ browser_redraw(g);
+ }
+ if(g->root->toolbar) {
+ //if(g->root->toolbar->url.redraw ) {
+ // TODO: implement toolbar redraw mechanism
+ //tb_url_redraw( g );
+ //}
+ }
+ }
+
+ if( !active ) {
+ /* this suits for stuff with lower priority */
+ /* TBD: really be spare on redraws??? */
+ hotlist_redraw();
+ global_history_redraw();
+ }
+
// Handle events until there are no more messages pending or
// until the engine indicates activity:
do {
@@ -201,66 +179,8 @@ void gui_poll(bool active)
}
} while ( gui_poll_repeat && !(active||rendering));
- if( !active ) {
- /* this suits for stuff with lower priority */
- /* TBD: really be spare on redraws??? */
- hotlist_redraw();
- global_history_redraw();
- }
}
-void gui_poll_old(bool active)
-{
- short winloc[4];
- // int timeout; /* timeout in milliseconds */
- int flags = MU_MESAG | MU_KEYBD | MU_BUTTON ;
- short mx, my, dummy;
-
- evnt.timer = schedule_run();
-
- if( active || rendering ) {
- if( clock() >= next_poll ) {
- evnt.timer = 0;
- flags |= MU_TIMER;
- EvntWindom( flags );
- next_poll = clock() + (CLOCKS_PER_SEC>>3);
- }
- } else {
- if (input_window != NULL) {
- wind_get( 0, WF_TOP, &winloc[0], &winloc[1], &winloc[2], &winloc[3]);
- if (winloc[1] == _AESapid) {
- /* only check for mouse move when netsurf is on top: */
- // move that into m1 event handler
- graf_mkstate( &mx, &my, &dummy, &dummy );
- flags |= MU_M1;
- evnt.m1_flag = MO_LEAVE;
- evnt.m1_w = evnt.m1_h = 1;
- evnt.m1_x = mx;
- evnt.m1_y = my;
- }
- }
- flags |= MU_TIMER;
- EvntWindom( flags );
- }
-
- struct gui_window * g;
- for( g = window_list; g != NULL; g=g->next ) {
- if( browser_redraw_required( g ) ) {
- browser_redraw( g );
- }
- if( g->root->toolbar ) {
- if(g->root->toolbar->url.redraw ) {
- tb_url_redraw( g );
- }
- }
- }
- if( evnt.timer != 0 && !active ) {
- /* this suits for stuff with lower priority */
- /* TBD: really be spare on redraws??? */
- hotlist_redraw();
- global_history_redraw();
- }
-}
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
@@ -271,22 +191,24 @@ gui_create_browser_window(struct browser_window *bw,
(int)new_tab
));
- gw = malloc( sizeof(struct gui_window) );
+ gw = calloc( sizeof(struct gui_window), 1);
if (gw == NULL)
return NULL;
- memset( gw, 0, sizeof(struct gui_window) );
LOG(("new window: %p, bw: %p\n", gw, bw));
- window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
- if( gw->root->handle ) {
+ window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\
+ |WIDGET_SCROLL);
+ if (gw->root->win) {
GRECT pos = {
option_window_x, option_window_y,
option_window_width, option_window_height
};
- window_open( gw , pos );
+ gui_window_set_url(gw, "");
+ gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT);
+ window_set_active_gui_window(gw->root, gw);
+ window_open(gw->root, pos );
/* Recalculate windows browser area now */
- browser_update_rects( gw );
- tb_update_buttons( gw, -1 );
+ toolbar_update_buttons(gw->root->toolbar, gw->browser->bw, -1);
input_window = gw;
/* TODO:... this line: placeholder to create a local history widget ... */
}
@@ -319,7 +241,11 @@ void gui_window_destroy(struct gui_window *w)
input_window = NULL;
- window_destroy(w);
+ search_destroy(w);
+ browser_destroy(w->browser);
+ free(w->status);
+ free(w->title);
+ free(w->url);
/* unlink the window: */
if(w->prev != NULL ) {
@@ -330,16 +256,21 @@ void gui_window_destroy(struct gui_window *w)
if( w->next != NULL ) {
w->next->prev = w->prev;
}
+
+ window_unref_gui_window(w->root, w);
+
free(w);
w = NULL;
- w = window_list;
- while( w != NULL ) {
- if( w->root ) {
- input_window = w;
- break;
+ if(input_window == NULL){
+ w = window_list;
+ while( w != NULL ) {
+ if(w->root) {
+ input_window = w;
+ break;
+ }
+ w = w->next;
}
- w = w->next;
}
}
@@ -348,7 +279,7 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
{
if (w == NULL)
return;
- LGRECT rect;
+ GRECT rect;
browser_get_rect( w, BR_CONTENT, &rect );
*width = rect.g_w;
*height = rect.g_h;
@@ -356,21 +287,34 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
void gui_window_set_title(struct gui_window *gw, const char *title)
{
- int l;
- char * conv;
if (gw == NULL)
return;
- if( gw->root ) {
- l = strlen(title);
- if( utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ) {
- strncpy(gw->root->title, conv, atari_sysinfo.aes_max_win_title_len);
+
+ if (gw->root) {
+
+ int l;
+ char * conv;
+ l = strlen(title)+1;
+ if (utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ) {
+ l = MIN((uint32_t)atari_sysinfo.aes_max_win_title_len, strlen(conv));
+ if(gw->title == NULL)
+ gw->title = malloc(l);
+ else
+ gw->title = realloc(gw->title, l);
+
+ strncpy(gw->title, conv, l);
free( conv );
} else {
- strncpy(gw->root->title, title, atari_sysinfo.aes_max_win_title_len);
+ l = MIN((size_t)atari_sysinfo.aes_max_win_title_len, strlen(title));
+ if(gw->title == NULL)
+ gw->title = malloc(l);
+ else
+ gw->title = realloc(gw->title, l);
+ strncpy(gw->title, title, l);
}
- gw->root->title[atari_sysinfo.aes_max_win_title_len] = 0;
- WindSetStr( gw->root->handle, WF_NAME, gw->root->title );
+ if(input_window == gw)
+ window_set_title(gw->root, gw->title);
}
}
@@ -379,20 +323,34 @@ void gui_window_set_title(struct gui_window *gw, const char *title)
*/
void gui_window_set_status(struct gui_window *w, const char *text)
{
- if (w == NULL || text == NULL )
+ int l;
+ if (w == NULL || text == NULL)
return;
- window_set_stauts(w, (char*)text );
+
+ assert(w->root);
+
+ l = strlen(text)+1;
+ if(w->status == NULL)
+ w->status = malloc(l);
+ else
+ w->status = realloc(w->status, l);
+
+ strncpy(w->status, text, l);
+ w->status[l-1] = 0;
+
+ if(input_window == w)
+ window_set_stauts(w->root, (char*)text);
}
void gui_window_redraw_window(struct gui_window *gw)
{
CMP_BROWSER b;
- LGRECT rect;
+ GRECT rect;
if (gw == NULL)
return;
b = gw->browser;
- browser_get_rect( gw, BR_CONTENT, &rect );
- browser_schedule_redraw( gw, 0, 0, rect.g_w, rect.g_h );
+ browser_get_rect(gw, BR_CONTENT, &rect);
+ browser_schedule_redraw(gw, 0, 0, rect.g_w, rect.g_h );
}
void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
@@ -479,75 +437,80 @@ void gui_clear_selection(struct gui_window *g)
/**
* set the pointer shape
*/
-void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
+void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape)
{
- if (w == NULL)
+ if (gw == NULL)
return;
+
switch (shape) {
case GUI_POINTER_POINT: /* link */
- gem_set_cursor(&gem_cursors.hand);
+ gw->cursor = &gem_cursors.hand;
break;
case GUI_POINTER_MENU:
- gem_set_cursor(&gem_cursors.menu);
+ gw->cursor = &gem_cursors.menu;
break;
case GUI_POINTER_CARET: /* input */
- gem_set_cursor(&gem_cursors.ibeam);
+ gw->cursor = &gem_cursors.ibeam;
break;
case GUI_POINTER_CROSS:
- gem_set_cursor(&gem_cursors.cross);
+ gw->cursor = &gem_cursors.cross;
break;
case GUI_POINTER_MOVE:
- gem_set_cursor(&gem_cursors.sizeall);
+ gw->cursor = &gem_cursors.sizeall;
break;
case GUI_POINTER_RIGHT:
case GUI_POINTER_LEFT:
- gem_set_cursor(&gem_cursors.sizewe);
+ gw->cursor = &gem_cursors.sizewe;
break;
case GUI_POINTER_UP:
case GUI_POINTER_DOWN:
- gem_set_cursor(&gem_cursors.sizens);
+ gw->cursor = &gem_cursors.sizens;
break;
case GUI_POINTER_RU:
case GUI_POINTER_LD:
- gem_set_cursor(&gem_cursors.sizenesw);
+ gw->cursor = &gem_cursors.sizenesw;
break;
case GUI_POINTER_RD:
case GUI_POINTER_LU:
- gem_set_cursor(&gem_cursors.sizenwse);
+ gw->cursor = &gem_cursors.sizenwse;
break;
case GUI_POINTER_WAIT:
- gem_set_cursor(&gem_cursors.wait);
+ gw->cursor = &gem_cursors.wait;
break;
case GUI_POINTER_PROGRESS:
- gem_set_cursor(&gem_cursors.appstarting);
+ gw->cursor = &gem_cursors.appstarting;
break;
case GUI_POINTER_NO_DROP:
- gem_set_cursor(&gem_cursors.nodrop);
+ gw->cursor = &gem_cursors.nodrop;
break;
case GUI_POINTER_NOT_ALLOWED:
- gem_set_cursor(&gem_cursors.deny);
+ gw->cursor = &gem_cursors.deny;
break;
case GUI_POINTER_HELP:
- gem_set_cursor(&gem_cursors.help);
+ gw->cursor = &gem_cursors.help;
break;
default:
- gem_set_cursor(&gem_cursors.arrow);
+ gw->cursor = &gem_cursors.arrow;
break;
}
+
+ if (input_window == gw) {
+ gem_set_cursor(gw->cursor);
+ }
}
void gui_window_hide_pointer(struct gui_window *w)
@@ -558,9 +521,23 @@ void gui_window_hide_pointer(struct gui_window *w)
void gui_window_set_url(struct gui_window *w, const char *url)
{
+ int l;
+
if (w == NULL)
return;
- tb_url_set(w, (char*)url );
+
+ l = strlen(url)+1;
+
+ if (w->url == NULL) {
+ w->url = malloc(l);
+ } else {
+ w->url = realloc(w->url, l);
+ }
+ strncpy(w->url, url, l);
+
+ if(input_window == w->root->active_gui_window){
+ toolbar_set_url(w->root->toolbar, url);
+ }
}
static void throbber_advance( void * data )
@@ -571,32 +548,33 @@ static void throbber_advance( void * data )
return;
if( gw->root->toolbar == NULL )
return;
- if( gw->root->toolbar->throbber.running == false )
- return;
- mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- gw->root->toolbar->throbber.index++;
- if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
- gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
+ // TODO: implement access to throbber
+ //if( gw->root->toolbar->throbber.running == false)
+ // return;
+// mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
+// WF_WORKXYWH, &work);
+// gw->root->toolbar->throbber.index++;
+// if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
+// gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
+// ApplWrite(_AESapid, WM_REDRAW, guiwin_get_handle(gw->root->win),
+// work.g_x, work.g_y, work.g_w, work.g_h);
schedule(100, throbber_advance, gw );
}
void gui_window_start_throbber(struct gui_window *w)
{
- LGRECT work;
+ GRECT work;
if (w == NULL)
return;
- if( w->root->toolbar->throbber.running == true )
- return;
- mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- w->root->toolbar->throbber.running = true;
- w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
+ // TODO: implement throbber acess
+ //if( w->root->toolbar->throbber.running == true )
+ // return;
+// browser_get_rect(w, BR_THROBBER, &work);
+// w->root->toolbar->throbber.running = true;
+// w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
schedule(100, throbber_advance, w );
- ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
+// ApplWrite( _AESapid, WM_REDRAW, guiwin_get_handle(w->root->win),
+// work.g_x, work.g_y, work.g_w, work.g_h );
rendering = true;
}
@@ -606,20 +584,22 @@ void gui_window_stop_throbber(struct gui_window *w)
LGRECT work;
if (w == NULL)
return;
- if( w->root->toolbar->throbber.running == false )
- return;
+ // TODO: implement something like throbber_is_running();
+ //if( w->root->toolbar->throbber.running == false )
+ // return;
schedule_remove(throbber_advance, w);
/* refresh toolbar buttons: */
- tb_update_buttons( w, -1 );
+ toolbar_update_buttons(w->root->toolbar, w->browser->bw, -1);
/* redraw throbber: */
- mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- w->root->toolbar->throbber.running = false;
- ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
+// mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
+// WF_WORKXYWH, &work);
+// w->root->toolbar->throbber.running = false;
+// ApplWrite( _AESapid, WM_REDRAW, guiwin_get_handle(w->root->win),
+// work.g_x, work.g_y, work.g_w, work.g_h );
+ // TODO: send throbber redraw
rendering = false;
}
@@ -663,8 +643,11 @@ gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
struct bitmap *bmp_icon;
bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
+ g->icon = bmp_icon;
- window_set_icon(g, bmp_icon);
+ if(input_window == g){
+ window_set_icon(g->root, bmp_icon);
+ }
}
void
diff --git a/atari/gui.h b/atari/gui.h
index 76de07f..c2f6b44 100755
--- a/atari/gui.h
+++ b/atari/gui.h
@@ -19,7 +19,7 @@
#ifndef NS_ATARI_GUI_H_
#define NS_ATARI_GUI_H_
-#include <windom.h>
+#include "atari/gemtk/gemtk.h"
struct point_s {
int x;
@@ -96,17 +96,18 @@ typedef struct s_browser * CMP_BROWSER;
*/
struct s_gui_win_root
{
- WINDOW * handle;
+ GUIWIN *win;
CMP_TOOLBAR toolbar;
CMP_STATUSBAR statusbar;
- COMPONENT * cmproot;
- MFORM_EX cursor;
struct s_focus_info focus;
float scale;
char * title;
+ struct bitmap * icon;
+ struct gui_window *active_gui_window;
/* current size of window on screen: */
GRECT loc;
};
+typedef struct s_gui_win_root ROOTWIN;
/*
This is the part of the gui which is known by netsurf core.
@@ -117,7 +118,11 @@ struct s_gui_win_root
struct gui_window {
struct s_gui_win_root * root;
CMP_BROWSER browser;
+ MFORM_EX *cursor;
/* icon to be drawn when iconified, or NULL for default resource. */
+ char * status;
+ char * title;
+ char * url;
struct bitmap * icon;
struct gui_window *next, *prev;
};
diff --git a/atari/misc.c b/atari/misc.c
index 575e964..22f820e 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -121,8 +121,8 @@ struct gui_window * find_guiwin_by_aes_handle(short handle){
}
while(gw != NULL) {
- if( gw->root->handle != NULL
- && gw->root->handle->handle == handle ) {
+ if( gw->root->win != NULL
+ && guiwin_get_handle(gw->root->win) == handle ) {
return(gw);
}
else
@@ -133,21 +133,6 @@ struct gui_window * find_guiwin_by_aes_handle(short handle){
}
-struct gui_window * find_cmp_window( COMPONENT * c )
-{
- struct gui_window * gw;
- gw = window_list;
- while( gw != NULL ) {
- assert( gw->browser != NULL );
- if( gw->browser->comp == c ) {
- return( gw );
- }
- else
- gw = gw->next;
- }
- return( NULL );
-}
-
static int scan_process_list(scan_process_callback cb, void *data)
{
int pid, count = 0;
diff --git a/atari/misc.h b/atari/misc.h
index 5359d72..cab2a8c 100755
--- a/atari/misc.h
+++ b/atari/misc.h
@@ -19,6 +19,7 @@
#ifndef NS_ATARI_MISC_H
#define NS_ATARI_MISC_H
+#include <windom.h>
#include "cflib.h"
#include "content/content.h"
#include "content/hlcache.h"
@@ -43,7 +44,6 @@
typedef int (*scan_process_callback)(int pid, void *data);
struct gui_window * find_guiwin_by_aes_handle(short handle);
-struct gui_window * find_cmp_window( COMPONENT * c );
bool is_process_running(const char * name);
void gem_set_cursor( MFORM_EX * cursor );
hlcache_handle *load_icon( const char *name, hlcache_handle_callback cb,
diff --git a/atari/res/netsurf.rsc b/atari/res/netsurf.rsc
index 5a9327f..803cb2b 100755
Binary files a/atari/res/netsurf.rsc and b/atari/res/netsurf.rsc differ
diff --git a/atari/res/netsurf.rsh b/atari/res/netsurf.rsh
index b0c800d..8245526 100755
--- a/atari/res/netsurf.rsh
+++ b/atari/res/netsurf.rsh
@@ -41,11 +41,14 @@
#define MAINMENU_M_HELP_CONTENT 61 /* STRING in tree MAINMENU */
#define TOOLBAR 1 /* form/dial */
+#define TOOLBAR_NAVIGATION_AREA 1 /* BOX in tree TOOLBAR */
#define TOOLBAR_BT_BACK 2 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_HOME 3 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_FORWARD 4 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_STOP 5 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_RELOAD 6 /* CICON in tree TOOLBAR */
+#define TOOLBAR_URL_AREA 7 /* BOX in tree TOOLBAR */
+#define TOOLBAR_THROBBER_AREA 8 /* BOX in tree TOOLBAR */
#define ICONIFY 2 /* form/dial */
#define ICONIFY_GLOBE 1 /* CICON in tree ICONIFY */
diff --git a/atari/res/netsurf.rsm b/atari/res/netsurf.rsm
index ade2b1c..587fefa 100755
--- a/atari/res/netsurf.rsm
+++ b/atari/res/netsurf.rsm
@@ -3,7 +3,7 @@ ResourceMaster v3.65
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
-#M 20010100@0@7728@610@
+#M 20010100@0@7728@618@
#T 0@1@MAINMENU@@62@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@@ -43,12 +43,15 @@ ResourceMaster v3.65
#O 58@28@M_CHOICES@@
#O 59@28@M_VLOG@@
#O 61@28@M_HELP_CONTENT@@
-#T 1@2@TOOLBAR@@7@@
+#T 1@2@TOOLBAR@@9@@
+#O 1@20@NAVIGATION_AREA@@
#O 2@33@BT_BACK@@
#O 3@33@BT_HOME@@
#O 4@33@BT_FORWARD@@
#O 5@33@BT_STOP@@
#O 6@33@BT_RELOAD@@
+#O 7@20@URL_AREA@@
+#O 8@20@THROBBER_AREA@@
#T 2@2@ICONIFY@@3@@
#O 1@33@GLOBE@@
#T 3@2@FAVICON@@2@@
@@ -195,4 +198,4 @@ ResourceMaster v3.65
#O 5@33@BT_DOWN_PIC@@
#O 6@25@BT_UP@@
#O 4@33@BT_UP_PIC@@
-#c 2361@
+#c 770@
diff --git a/atari/rootwin.c b/atari/rootwin.c
index aff910c..68f1bc0 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -61,23 +61,19 @@
extern struct gui_window *input_window;
+struct rootwin_data_s {
+ struct s_gui_win_root *rootwin;
+};
+
/* -------------------------------------------------------------------------- */
-/* Static module methods follow here: */
+/* Static module methods: */
/* -------------------------------------------------------------------------- */
-//static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void *data );
-//static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data );
-//void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data );
-//static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * date );
static void redraw(GUIWIN *win, short msg[8]);
static void resized(GUIWIN *win);
static void file_dropped(GUIWIN *win, short msg[8]);
-//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data );
-//static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) ;
-static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data );
+
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
-//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data );
-//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data );
#define FIND_NS_GUI_WINDOW(w) \
find_guiwin_by_aes_handle(guiwin_get_handle(w));
@@ -90,6 +86,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
struct gui_window * gw;
+ struct rootwin_data_s * data = guiwin_get_user_data(win);
+
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
// handle message
printf("root win msg: %d\n", msg[0]);
@@ -107,8 +105,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_ICONIFY:
- gw = FIND_NS_GUI_WINDOW(win);
- if( input_window == gw) {
+ data = guiwin_get_user_data(win);
+ if( input_window->root == data->rootwin) {
input_window = NULL;
}
break;
@@ -116,13 +114,17 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
case WM_TOPPED:
case WM_NEWTOP:
case WM_UNICONIFY:
- input_window = FIND_NS_GUI_WINDOW(win);
+ data = guiwin_get_user_data(win);
+ input_window = data->rootwin->active_gui_window;
break;
case WM_CLOSED:
- gw = FIND_NS_GUI_WINDOW(win);
+ // TODO: this needs to iterate through all gui windows and
+ // check if the rootwin is this window...
+ data = guiwin_get_user_data(win);
+ gw = data->rootwin->active_gui_window;
if( gw != NULL ) {
- browser_window_destroy(gw->browser->bw );
+ browser_window_destroy(gw->browser->bw);
}
break;
@@ -185,176 +187,177 @@ int window_create(struct gui_window * gw,
return( -1 );
memset( gw->root, 0, sizeof(struct s_gui_win_root) );
gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
- gw->root->handle = WindCreate(flags, 40, 40, app.w, app.h);
- if( gw->root->handle == NULL ) {
+ // TODO: use desk size
+ short aes_handle = wind_create(flags, 40, 40, app.w, app.h);
+ if(aes_handle<0) {
free( gw->root->title );
free( gw->root );
return( -1 );
}
-
- /* set scroll / content granularity ( 1 unit ) */
- gw->root->handle->w_u = 1;
- gw->root->handle->h_u = 1;
-
- /* Create Root component: */
- gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
- WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
+ gw->root->win = guiwin_add(aes_handle,
+ GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
/* create toolbar component: */
if( tb ) {
- gw->root->toolbar = tb_create( gw );
- assert( gw->root->toolbar );
- mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp );
-
+ gw->root->toolbar = toolbar_create(gw->root);
+ assert(gw->root->toolbar);
} else {
gw->root->toolbar = NULL;
}
/* create browser component: */
gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
- mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
/* create statusbar component: */
if( sb ) {
gw->root->statusbar = sb_create( gw );
-#ifdef WITH_COMOPONENT_STATUSBAR
- mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
-#endif
} else {
gw->root->statusbar = NULL;
}
- WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf");
-
- /* Event Handlers: */
-// EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
- /* capture resize/move events so we can handle that manually */
-// EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT );
-// EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
-// EvntDataAdd( gw->root->handle, WM_FULLED, evnt_window_rt_resize, gw, EV_BOT );
- EvntDataAdd(gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP );
- EvntDataAdd(gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP );
-// EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
-// EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
-// EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT);
-// EvntDataAdd( gw->root->handle, WM_UNICONIFY, evnt_window_uniconify, gw, EV_BOT);
-// EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw );
-// EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
- EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw );
+ wind_set_str(aes_handle, WF_ICONTITLE, (char*)"NetSurf");
+ wind_set(aes_handle, WF_OPTS, 1, WO0_FULLREDRAW, 0, 0);
+ wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITW, 0, 0);
+ wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITH, 0, 0);
+
+ guiwin_set_toolbar(gw->root->win, get_tree(TOOLBAR), 0, 0);
+ struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s));
+ data->rootwin = gw->root;
+ guiwin_set_user_data(gw->root->win, (void*)data);
if (inflags & WIN_TOP) {
- window_set_focus( gw, BROWSER, gw->browser);
+ window_set_focus(gw->root, BROWSER, gw->browser);
}
- GUIWIN * guiwin = guiwin_add(gw->root->handle->handle,
- GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
- guiwin_set_toolbar(guiwin, get_tree(TOOLBAR), 0, 0);
return (err);
}
-int window_destroy(struct gui_window * gw)
+void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
+{
+ struct gui_window *w;
+ input_window = NULL;
+
+ LOG(("window: %p, gui_window: %p", rootwin, gw));
+
+ w = window_list;
+ // find the next active tab:
+ while( w != NULL ) {
+ if(w->root == rootwin && w != gw) {
+ input_window = w;
+ break;
+ }
+ w = w->next;
+ }
+ if(input_window == NULL){
+ // the last gui window for this rootwin was removed:
+ window_destroy(rootwin);
+ }
+}
+
+int window_destroy(ROOTWIN *rootwin)
{
int err = 0;
+ struct gui_window *w;
- search_destroy( gw );
- if( input_window == gw )
- input_window = NULL;
+ assert(rootwin != NULL);
- if( gw->root ) {
- if( gw->root->toolbar )
- tb_destroy( gw->root->toolbar );
+ LOG(("%p", rootwin));
- if( gw->root->statusbar )
- sb_destroy( gw->root->statusbar );
+ if (guiwin_get_user_data(rootwin->win) != NULL) {
+ free(guiwin_get_user_data(rootwin->win));
}
- search_destroy( gw );
-
- guiwin_remove(guiwin_find(gw->root->handle->handle));
-
- if( gw->browser )
- browser_destroy( gw->browser );
-
- /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
- if( gw->root ) {
- /* TODO: check if no other browser is bound to this root window! */
- /* only needed for tabs */
- if( gw->root->title )
- free( gw->root->title );
- if( gw->root->cmproot )
- mt_CompDelete( &app, gw->root->cmproot );
- ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
- EvntWindom( MU_MESAG );
- gw->root->handle = NULL;
- free(gw->root);
- gw->root = NULL;
+ // make sure we do not destroy windows which have gui_windows attached:
+ w = window_list;
+ while( w != NULL ) {
+ if(w->root == rootwin) {
+ assert(rootwin == NULL);
+ }
+ w = w->next;
}
+
+ if (rootwin->toolbar)
+ toolbar_destroy(rootwin->toolbar);
+
+ if(rootwin->statusbar)
+ sb_destroy(rootwin->statusbar);
+
+ if(rootwin->title)
+ free(rootwin->title);
+
+ guiwin_remove(rootwin->win);
+ free(rootwin);
return(err);
}
-void window_open( struct gui_window * gw, GRECT pos )
+void window_open(ROOTWIN *rootwin, GRECT pos)
{
- LGRECT br;
-
- WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
- WindClear( gw->root->handle );
- WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
-
- /* apply focus to the root frame: */
- long lfbuff[8] = { CM_GETFOCUS };
- mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
-
- /* recompute the nested component sizes and positions: */
- browser_update_rects( gw );
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
- browser_get_rect( gw, BR_CONTENT, &br );
- plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h);
- gw->browser->attached = true;
- if( gw->root->statusbar != NULL ) {
- sb_attach(gw->root->statusbar, gw);
+ GRECT br;
+
+ short aes_handle = guiwin_get_handle(rootwin->win);
+ wind_open(aes_handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
+ wind_set_str(aes_handle, WF_NAME, (char *)"");
+
+ rootwin->active_gui_window->browser->attached = true;
+ if(rootwin->statusbar != NULL) {
+ sb_attach(rootwin->statusbar, rootwin->active_gui_window);
}
- tb_adjust_size( gw );
/*TBD: get already present content and set size? */
- input_window = gw;
- window_set_focus( gw, BROWSER, gw->browser );
+ input_window = rootwin->active_gui_window;
+ window_set_focus(rootwin, BROWSER, rootwin->active_gui_window->browser);
}
/* update back forward buttons (see tb_update_buttons (bug) ) */
-void window_update_back_forward( struct gui_window * gw)
+void window_update_back_forward(struct s_gui_win_root *rootwin)
{
- tb_update_buttons( gw, -1 );
+ struct gui_window * active_gw = rootwin->active_gui_window;
+ toolbar_update_buttons(rootwin->toolbar, active_gw->browser->bw, -1);
}
-void window_set_stauts(struct gui_window * gw , char * text )
+void window_set_stauts(struct s_gui_win_root *rootwin, char * text)
{
- if( gw->root == NULL )
- return;
+ assert(rootwin != NULL);
- CMP_STATUSBAR sb = gw->root->statusbar;
+ CMP_STATUSBAR sb = rootwin->statusbar;
- if( sb == NULL || gw->browser->attached == false )
+ if( sb == NULL)
return;
- sb_set_text( sb, text );
+ if(text != NULL)
+ sb_set_text(sb, text);
+ else
+ sb_set_text(sb, "");
+}
+
+void window_set_title(struct s_gui_win_root * rootwin, char *title)
+{
+ wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title);
}
/* set focus to an arbitary element */
-void window_set_focus(struct gui_window * gw, enum focus_element_type type, void * element)
+void window_set_focus(struct s_gui_win_root *rootwin,
+ enum focus_element_type type, void * element)
{
- if( gw->root->focus.type != type || gw->root->focus.element != element ) {
+ struct text_area * ta;
+
+ assert(rootwin != NULL);
+
+ if (rootwin->focus.type != type || rootwin->focus.element != element) {
LOG(("Set focus: %p (%d)\n", element, type));
- gw->root->focus.type = type;
- gw->root->focus.element = element;
+ rootwin->focus.type = type;
+ rootwin->focus.element = element;
if( element != NULL ) {
switch( type ) {
case URL_WIDGET:
- textarea_keypress(((struct s_url_widget*)(element))->textarea,
- KEY_SELECT_ALL );
+ // TODO: make something like: toolbar_text_select_all();
+ ta = toolbar_get_textarea(rootwin->toolbar,
+ URL_INPUT_TEXT_AREA);
+ textarea_keypress(ta, KEY_SELECT_ALL);
break;
default:
@@ -366,63 +369,82 @@ void window_set_focus(struct gui_window * gw, enum focus_element_type type, void
}
/* check if the url widget has focus */
-bool window_url_widget_has_focus( struct gui_window * gw )
+bool window_url_widget_has_focus(struct s_gui_win_root *rootwin)
{
- assert( gw );
- assert( gw->root );
- if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) {
- assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) );
- assert( GUIWIN_VISIBLE(gw) );
+ assert(rootwin != NULL);
+ if (rootwin->focus.type == URL_WIDGET) {
return true;
}
return false;
}
/* check if an arbitary window widget / or frame has the focus */
-bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element )
+bool window_widget_has_focus(struct s_gui_win_root *rootwin,
+ enum focus_element_type t, void * element)
{
- if( gw == NULL )
- return( false );
+ assert(rootwin != NULL);
if( element == NULL ) {
- assert( 1 != 0 );
- return( (gw->root->focus.type == t ) );
+ return((rootwin->focus.type == t));
}
- assert( gw->root != NULL );
- return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
+
+ return((element == rootwin->focus.element && t == rootwin->focus.type));
}
-void window_set_icon(struct gui_window *gw, struct bitmap * bmp )
+void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp )
{
- gw->icon = bmp;
+ rootwin->icon = bmp;
/* redraw window when it is iconyfied: */
- if (gw->icon != NULL) {
+ if (rootwin->icon != NULL) {
short info, dummy;
- WindGet(gw->root->handle, WF_ICONIFY, &info, &dummy, &dummy, &dummy);
- if (info == 1) {
- window_redraw_favicon(gw, NULL);
+ if (guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED) {
+ window_redraw_favicon(rootwin, NULL);
+ }
+ }
+}
+
+void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
+{
+ if (rootwin->active_gui_window != NULL) {
+ if(rootwin->active_gui_window == gw){
+ return;
}
}
+ rootwin->active_gui_window = gw;
+ window_set_icon(rootwin, gw->icon);
+ window_set_stauts(rootwin, gw->status);
+ window_set_title(rootwin, gw->title);
+ toolbar_set_url(rootwin->toolbar, gw->url);
+ // TODO: implement window_restore_browser()
+ // window_restore_browser(gw->browser);
+}
+
+struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin)
+{
+ return(rootwin->active_gui_window);
}
/**
* Redraw the favicon
*/
-void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
+void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
{
GRECT work;
- assert(gw->root);
+ assert(rootwin);
- WINDOW * bw = gw->root->handle;
+ guiwin_clear(rootwin->win);
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
- WindClear(bw);
- WindGet(bw, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h);
if (clip == NULL) {
clip = &work;
+ } else {
+ if(!rc_intersect(&work, clip)){
+ return;
+ }
}
- if (gw->icon == NULL) {
+ if (rootwin->icon == NULL) {
OBJECT * tree = get_tree(ICONIFY);
tree->ob_x = work.g_x;
tree->ob_y = work.g_y;
@@ -439,7 +461,7 @@ void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
}
plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, work.g_h);
plot_clip(&work_clip);
- atari_plotters.bitmap(0, 0, work.g_w, work.g_h, gw->icon, 0xffffff, 0);
+ atari_plotters.bitmap(0, 0, work.g_w, work.g_h, rootwin->icon, 0xffffff, 0);
}
}
@@ -448,16 +470,16 @@ void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
/* Event Handlers: */
/* -------------------------------------------------------------------------- */
-static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
+static void __CDECL evnt_window_arrowed(WINDOW *win, short buff[8], void *data)
{
bool abs = false;
- LGRECT cwork;
+ GRECT cwork;
struct gui_window * gw = data;
int value = BROWSER_SCROLL_SVAL;
assert( gw != NULL );
- browser_get_rect( gw, BR_CONTENT, &cwork );
+ browser_get_rect(gw, BR_CONTENT, &cwork );
switch( buff[4] ) {
case WA_UPPAGE:
@@ -602,31 +624,56 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data
static void redraw(GUIWIN *win, short msg[8])
{
short handle;
- struct gui_window *gw;
-
- handle = guiwin_get_handle(win);
- gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
-
- assert(gw != NULL);
+ struct rootwin_data_s *data = guiwin_get_user_data(win);
+ ROOTWIN *rootwin = data->rootwin;
+ GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
if(guiwin_get_state(win) & GW_STATUS_ICONIFIED) {
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
- window_redraw_favicon(gw, &clip);
+ window_redraw_favicon(rootwin, &clip);
} else {
GRECT content_area, tb_area;
short pxy[8];
guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &content_area);
guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
- struct rect clip = {0,0,content_area.g_w,content_area.g_h};
- plot_set_dimensions(content_area.g_x, content_area.g_y,
- content_area.g_w,content_area.g_h);
- //plot_clip(&clip);
- plot_rectangle(0, 0, content_area.g_w,
- content_area.g_h, plot_style_broken_object);
+ if (rc_intersect(&tb_area, &clip)) {
+ toolbar_set_dimensions(rootwin->toolbar, &tb_area);
+ toolbar_redraw(rootwin->toolbar, clip);
+ }
+
+ CMP_BROWSER browser = rootwin->active_gui_window->browser;
+ if (browser->reformat_pending == true) {
+ browser_window_reformat(browser->bw, false, content_area.g_w,
+ content_area.g_h );
+ } else {
+ if(rc_intersect(&content_area, &clip)){
+
+ GRECT lclip = content_area;
+
+ /* convert redraw coords to framebuffer coords: */
+ lclip.g_x -= content_area.g_x;
+ lclip.g_y -= content_area.g_y;
+
+ if( lclip.g_x < 0 ) {
+ lclip.g_w = content_area.g_w + lclip.g_x;
+ lclip.g_x = 0;
+ }
+
+ if( lclip.g_y < 0 ) {
+ lclip.g_h = content_area.g_h + lclip.g_y;
+ lclip.g_y = 0;
+ }
+
+ browser_schedule_redraw(rootwin->active_gui_window,
+ lclip.g_x, lclip.g_y,
+ lclip.g_x + lclip.g_w,
+ lclip.g_y + lclip.g_h);
+ }
+ }
- //WindClear(gw->root->handle);
+ //guiwin_clear(win);
}
}
@@ -635,37 +682,40 @@ static void resized(GUIWIN *win)
short x,y,w,h;
short handle;
struct gui_window *gw;
+ struct rootwin_data_s *data = guiwin_get_user_data(win);
+ ROOTWIN *rootwin = data->rootwin;
+
+ printf("resized win: %p\n", win);
handle = guiwin_get_handle(win);
- gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
- assert( gw != NULL );
+ printf("resized handle: %d\n", handle);
+ gw = data->rootwin->active_gui_window;
+
+ assert(gw != NULL);
+
+ printf("resized gw: %p\n", gw);
+
+ if(gw == NULL)
+ return;
+ //assert( gw != NULL );
wind_get(handle, WF_CURRXYWH, &x, &y, &w, &h);
- if (gw->root->loc.g_w != w || gw->root->loc.g_h != h) {
- // resized
- tb_adjust_size( gw );
+ if (rootwin->loc.g_w != w || rootwin->loc.g_h != h) {
if ( gw->browser->bw->current_content != NULL ) {
- /* Reformat will happen when next redraw message arrives: */
- gw->browser->reformat_pending = true;
- /* but on xaaes an resize doesn't trigger an redraw, */
- /* when the window is shrinked, deal with it: */
- if( sys_XAAES() ) {
- if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ) {
- ApplWrite(_AESapid, WM_REDRAW, gw->root->handle->handle,
- x, y, w, h);
- }
- }
+ /* Reformat will happen when redraw is processed: */
+ rootwin->active_gui_window->browser->reformat_pending = true;
}
}
- if (gw->root->loc.g_x != x || gw->root->loc.g_y != y) {
+ if (rootwin->loc.g_x != x || rootwin->loc.g_y != y) {
// moved
}
- gw->root->loc.g_x = x;
- gw->root->loc.g_y = y;
- gw->root->loc.g_w = w;
- gw->root->loc.g_h = h;
+
+ rootwin->loc.g_x = x;
+ rootwin->loc.g_y = y;
+ rootwin->loc.g_w = w;
+ rootwin->loc.g_h = h;
}
static void __CDECL file_dropped(GUIWIN *win, short msg[8])
@@ -712,7 +762,7 @@ static void __CDECL file_dropped(GUIWIN *win, short msg[8])
size, mx, my
));
{
- LGRECT bwrect;
+ GRECT bwrect;
struct browser_window * bw = gw->browser->bw;
browser_get_rect( gw, BR_CONTENT, &bwrect );
mx = mx - bwrect.g_x;
diff --git a/atari/rootwin.h b/atari/rootwin.h
index 28001ba..f7aa7c4 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -17,7 +17,9 @@
*/
#ifndef NS_ATARI_BROWSER_WIN_H
-#define NS_ATARI_BROWSER_WIN_H
+#define NS_ATARI_BROWSER_WIN_H
+
+#include <atari/gui.h>
#define GUIWIN_VISIBLE(gw) (gw->root->handle->status & WS_OPEN)
#define GEMWIN_VISIBLE(win) (win->status & WS_OPEN)
@@ -36,31 +38,39 @@
/* -------------------------------------------------------------------------- */
/* Creates an normal Browser window with [toolbar], [statusbar] */
-int window_create( struct gui_window * gw,
+int window_create(struct gui_window * gw,
struct browser_window * bw, unsigned long flags );
/* Destroys WinDom part of gui_window */
-int window_destroy( struct gui_window * gw );
+int window_destroy(struct s_gui_win_root * rootwin);
/* show the window */
-void window_open( struct gui_window * gw, GRECT pos);
+void window_open(struct s_gui_win_root * rootwin, GRECT pos);
-void window_snd_redraw(struct gui_window * gw, short x, short y, short w, short h );
+void window_snd_redraw(struct s_gui_win_root * rootwin, short x, short y,
+ short w, short h );
/* Update Shade / Unshade state of the fwd/back buttons*/
-void window_update_back_forward(struct gui_window * gw);
+void window_update_back_forward(struct s_gui_win_root * rootwin);
/* set root browser component: */
-void window_attach_browser( struct gui_window * gw, CMP_BROWSER b);
+void window_attach_browser(struct s_gui_win_root * rootwin, CMP_BROWSER b);
/* set focus element */
-void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element );
+void window_set_focus(struct s_gui_win_root * rootwin,
+ enum focus_element_type type, void * element );
/* adjust scroll settings */
-void window_set_scroll_info(struct gui_window *gw, int content_h, int content_w);
+void window_set_scroll_info(struct s_gui_win_root * rootwin, int content_h,
+ int content_w);
/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/
-bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element);
-bool window_url_widget_has_focus( struct gui_window * gw );
-void window_set_url( struct gui_window * gw, const char * text);
-void window_set_stauts( struct gui_window * gw , char * text );
-void window_set_icon(struct gui_window * gw, struct bitmap * bmp );
-void window_redraw_favicon(struct gui_window *gw, GRECT *clip);
+bool window_widget_has_focus(struct s_gui_win_root * rootwin,
+ enum focus_element_type t, void * element);
+bool window_url_widget_has_focus(struct s_gui_win_root * rootwin);
+void window_set_url(struct s_gui_win_root * rootwin, const char * text);
+void window_set_stauts(struct s_gui_win_root * rootwin, char * text);
+void window_set_title(struct s_gui_win_root * rootwin, char * text);
+void window_set_icon(struct s_gui_win_root * rootwin, struct bitmap * bmp );
+void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
+struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
+void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
+void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
/* -------------------------------------------------------------------------- */
diff --git a/atari/toolbar.c b/atari/toolbar.c
old mode 100755
new mode 100644
index 396cccb..3902569
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
+ * Copyright 2012 Ole Loots <ole(a)monochrom.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -24,7 +24,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
-#include <windom.h>
#include <assert.h>
#include <math.h>
@@ -50,16 +49,83 @@
#include "atari/global_evnt.h"
#include "atari/plot/plot.h"
#include "cflib.h"
-#include "atari/res/netsurf.rsh"
+#include "atari/res/netsurf.rsh"
+
+#include "desktop/textarea.h"
+#include "desktop/textinput.h"
+#include "content/hlcache.h"
+#include "atari/browser.h"
+
+#define TB_BUTTON_WIDTH 32
+#define THROBBER_WIDTH 32
+#define THROBBER_MIN_INDEX 1
+#define THROBBER_MAX_INDEX 12
+#define THROBBER_INACTIVE_INDEX 13
+
+#define TOOLBAR_URL_MARGIN_LEFT 2
+#define TOOLBAR_URL_MARGIN_RIGHT 2
+#define TOOLBAR_URL_MARGIN_TOP 2
+#define TOOLBAR_URL_MARGIN_BOTTOM 2
+
+enum e_toolbar_button_states {
+ button_on = 0,
+ button_off = 1
+};
+#define TOOLBAR_BUTTON_NUM_STATES 2
+
+struct s_toolbar;
+
+struct s_tb_button
+{
+ short rsc_id;
+ void (*cb_click)(struct s_toolbar *tb);
+ hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
+ struct s_toolbar *owner;
+ short state;
+ short index;
+ GRECT area;
+};
+struct s_url_widget
+{
+ /* widget is only redrawn when this flag is set */
+ bool redraw;
+ struct text_area *textarea;
+ GRECT rdw_area;
+ GRECT area;
+};
+
+struct s_throbber_widget
+{
+ short index;
+ short max_index;
+ bool running;
+ GRECT area;
+};
+
+struct s_toolbar
+{
+ struct s_gui_win_root *owner;
+ struct s_url_widget url;
+ struct s_throbber_widget throbber;
+ GRECT btdim;
+ GRECT area;
+ /* size & location of buttons: */
+ struct s_tb_button * buttons;
+ bool hidden;
+ int btcnt;
+ int style;
+ bool redraw;
+};
+
extern char * option_homepage_url;
extern void * h_gem_rsrc;
extern struct gui_window * input_window;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
-static OBJECT * toolbar_buttons = NULL;
+static OBJECT * aes_toolbar = NULL;
static OBJECT * throbber_form = NULL;
static bool img_toolbar = false;
static char * toolbar_image_folder = (char *)"default";
@@ -68,7 +134,7 @@ static hlcache_handle * toolbar_image;
static hlcache_handle * throbber_image;
static bool toolbar_image_ready = false;
static bool throbber_image_ready = false;
-
+static bool init = false;
static plot_font_style_t font_style_url = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
@@ -77,46 +143,45 @@ static plot_font_style_t font_style_url = {
.flags = FONTF_NONE,
.background = 0xffffff,
.foreground = 0x0
- };
+ };
+
/* prototypes & order for button widgets: */
+
static struct s_tb_button tb_buttons[] =
{
{
TOOLBAR_BT_BACK,
- tb_back_click,
- 0,
+ toolbar_back_click,
{0,0},
- 0, 0, 0
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_HOME,
- tb_home_click,
- 0, {0,0}, 0, 0, 0
+ toolbar_home_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_FORWARD,
- tb_forward_click,
- 0,
- {0,0},
- 0, 0, 0
+ toolbar_forward_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_STOP,
- tb_stop_click,
- 0,
- {0,0},
- 0, 0, 0
+ toolbar_stop_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_RELOAD,
- tb_reload_click,
- 0,
- {0,0},
- 0, 0, 0
+ toolbar_reload_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
- { 0, 0, 0, {0,0}, 0, 0, -1 }
+ { 0, 0, {0,0}, 0, -1, 0, {0,0,0,0}}
};
struct s_toolbar_style {
@@ -142,10 +207,93 @@ static struct s_toolbar_style toolbar_styles[] =
{18, 34, 64, 64, 2, 0, 0 }
};
-static void tb_txt_request_redraw( void *data, int x, int y, int w, int h );
+static void tb_txt_request_redraw(void *data, int x, int y, int w, int h );
static nserror toolbar_icon_callback( hlcache_handle *handle,
const hlcache_event *event, void *pw );
+/**
+* Callback for textarea redraw
+*/
+static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
+{
+ LGRECT work;
+ if( data == NULL )
+ return;
+ CMP_TOOLBAR t = data;
+ if( t->url.redraw == false ){
+ t->url.redraw = true;
+ //t->redraw = true;
+ t->url.rdw_area.g_x = x;
+ t->url.rdw_area.g_y = y;
+ t->url.rdw_area.g_w = w;
+ t->url.rdw_area.g_h = h;
+ } else {
+ /* merge the redraw area to the new area.: */
+ int newx1 = x+w;
+ int newy1 = y+h;
+ int oldx1 = t->url.rdw_area.g_x + t->url.rdw_area.g_w;
+ int oldy1 = t->url.rdw_area.g_y + t->url.rdw_area.g_h;
+ t->url.rdw_area.g_x = MIN(t->url.rdw_area.g_x, x);
+ t->url.rdw_area.g_y = MIN(t->url.rdw_area.g_y, y);
+ t->url.rdw_area.g_w = ( oldx1 > newx1 ) ?
+ oldx1 - t->url.rdw_area.g_x : newx1 - t->url.rdw_area.g_x;
+ t->url.rdw_area.g_h = ( oldy1 > newy1 ) ?
+ oldy1 - t->url.rdw_area.g_y : newy1 - t->url.rdw_area.g_y;
+ }
+}
+
+/**
+ * Callback for load_icon(). Should be removed once bitmaps get loaded directly
+ * from disc
+ */
+static nserror toolbar_icon_callback(hlcache_handle *handle,
+ const hlcache_event *event, void *pw)
+{
+ if( event->type == CONTENT_MSG_READY ){
+ if( handle == toolbar_image ){
+ toolbar_image_ready = true;
+ if(input_window != NULL )
+ toolbar_update_buttons(input_window->root->toolbar,
+ input_window->browser->bw, 0);
+ }
+ else if(handle == throbber_image ){
+ throbber_image_ready = true;
+ }
+ }
+
+ return NSERROR_OK;
+}
+
+static struct s_tb_button *button_init(struct s_toolbar *tb, OBJECT * tree, int index,
+ struct s_tb_button * instance)
+{
+ *instance = tb_buttons[index];
+ instance->owner = tb;
+
+ instance->area.g_w = toolbar_styles[tb->style].icon_width + \
+ ( toolbar_styles[tb->style].button_vmargin * 2);
+
+ return(instance);
+}
+
+
+static void toolbar_reflow(struct s_toolbar *tb)
+{
+ LOG((""));
+/*
+ int i=0, x=0;
+
+ x = 2;
+ while (tb->buttons[i].rsc_id > 0) {
+ tb->buttons[i].area.g_x = x;
+ x += tb->buttons[i].area.g_w;
+ x += 2;
+ i++;
+ }
+ tb->url.area.g_x = x;
+*/
+}
+
void toolbar_init( void )
{
@@ -155,7 +303,7 @@ void toolbar_init( void )
toolbar_image_folder = nsoption_charp(atari_image_toolbar_folder);
toolbar_bg_color = (nsoption_colour(atari_toolbar_bg));
- img_toolbar = (nsoption_int( atari_image_toolbar ) > 0 ) ? true : false;
+ img_toolbar = (nsoption_int(atari_image_toolbar) > 0 ) ? true : false;
if( img_toolbar ){
char imgfile[PATH_MAX];
@@ -175,13 +323,8 @@ void toolbar_init( void )
toolbar_icon_callback, NULL );
} else {
- RsrcGaddr( h_gem_rsrc, R_TREE, TOOLBAR, &toolbar_buttons );
- //toolbar_buttons->ob_x = 0;
- //toolbar_buttons->ob_y = 0;
-
- RsrcGaddr( h_gem_rsrc, R_TREE, THROBBER , &throbber_form );
- throbber_form->ob_x = 0;
- throbber_form->ob_y = 0;
+ aes_toolbar = get_tree(TOOLBAR);
+ throbber_form = get_tree(THROBBER);
}
n = (sizeof( toolbar_styles ) / sizeof( struct s_toolbar_style ));
for (i=0; i<n; i++) {
@@ -189,579 +332,42 @@ void toolbar_init( void )
}
}
-void toolbar_exit( void )
-{
- if( toolbar_image )
- hlcache_handle_release( toolbar_image );
- if( throbber_image )
- hlcache_handle_release( throbber_image );
-}
-/**
- * Callback for load_icon(). Should be removed once bitmaps get loaded directly
- * from disc
- */
-static nserror toolbar_icon_callback(hlcache_handle *handle,
- const hlcache_event *event, void *pw)
+void toolbar_exit(void)
{
- if( event->type == CONTENT_MSG_READY ){
- if( handle == toolbar_image ){
- toolbar_image_ready = true;
- if( input_window != NULL )
- tb_update_buttons( input_window, 0 );
- }
- else if( handle == throbber_image ){
- throbber_image_ready = true;
- }
- }
-
- return NSERROR_OK;
+ if (toolbar_image)
+ hlcache_handle_release(toolbar_image);
+ if (throbber_image)
+ hlcache_handle_release(throbber_image);
}
-
-
-static void __CDECL button_redraw( COMPONENT *c, long buff[8], void * data )
-{
-
- OBJECT *tree=NULL;
- LGRECT work,clip;
- GRECT todo,crect;
- struct s_tb_button *bt = (struct s_tb_button*)data;
- struct gui_window * gw = bt->gw;
- struct s_toolbar * tb = gw->root->toolbar;
-
- short pxy[4];
- int bmpx=0, bmpy=0, bmpw=0, bmph = 0, drawstate=0;
- struct bitmap * icon = NULL;
- struct rect icon_clip;
- GRECT icon_dim = {0,0,0,0};
- plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
-
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- work.g_h = work.g_h - 1;
- clip = work;
-
- /* return if component and redraw region does not intersect: */
- if (!rc_lintersect( (LGRECT*)&buff[4], &clip)) {
- return;
- }
-
- drawstate = bt->state;
- if( img_toolbar ){
-
- if( toolbar_image_ready == false ){
- return;
- }
- icon = content_get_bitmap( toolbar_image );
- if( icon == NULL ){
- return;
- }
- bmpw = bitmap_get_width(icon);
- bmph = bitmap_get_height(icon);
- bmpx = 0;
- bmpy = 0;
- icon_clip.x0 = bmpx+(toolbar_styles[tb->style].icon_width*bt->index);
- icon_clip.y0 = bmpy+(toolbar_styles[tb->style].icon_height*drawstate);
- icon_clip.x1 = icon_clip.x0+toolbar_styles[tb->style].icon_width;
- icon_clip.y1 = icon_clip.y0+toolbar_styles[tb->style].icon_height;
- icon_dim.g_x = work.g_x-(toolbar_styles[tb->style].icon_width * bt->index)+toolbar_styles[tb->style].button_vmargin;
- icon_dim.g_y = work.g_y-(toolbar_styles[tb->style].icon_height * drawstate)+toolbar_styles[tb->style].button_hmargin;
- icon_dim.g_w = toolbar_styles[tb->style].icon_width*(bt->index+1);
- icon_dim.g_h = toolbar_styles[tb->style].icon_height*(drawstate+1);
- } else {
- /* Place the CICON into workarea: */
- tree = &toolbar_buttons[bt->rsc_id];
- if( tree == NULL )
- return;
- //tree->ob_x = work.g_x;
- //tree->ob_y = work.g_y + (work.g_h - tree->ob_height) / 2;
- if( drawstate == button_off ) {
- tree->ob_state |= OS_DISABLED;
- } else {
- tree->ob_state &= ~OS_DISABLED;
- }
- }
-
- /* Setup draw mode: */
- vsf_interior(atari_plot_vdi_handle , 1 );
- vswr_mode(atari_plot_vdi_handle, MD_REPLACE);
-
- /* go through the rectangle list, using classic AES methods. */
- /* Windom ComGetLGrect is buggy for WF_FIRST/NEXTXYWH */
- crect.g_x = clip.g_x;
- crect.g_y = clip.g_y;
- crect.g_w = clip.g_w;
- crect.g_h = clip.g_h;
- wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
- &todo.g_x, &todo.g_y, &todo.g_w, &todo.g_h );
- while( (todo.g_w > 0) && (todo.g_h > 0) ){
-
- if (rc_intersect(&crect, &todo )) {
-
- struct rect bgclip = {0,0,todo.g_w, todo.g_h};
- pxy[0] = todo.g_x;
- pxy[1] = todo.g_y;
- pxy[2] = todo.g_w + todo.g_x-1;
- pxy[3] = todo.g_h + todo.g_y-1;
-
- vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy );
- plot_set_dimensions(todo.g_x, todo.g_y, todo.g_w, todo.g_h);
- plot_rectangle(0, 0, crect.g_w, crect.g_h, &plot_style_background);
-
- if( img_toolbar == true ){
- plot_set_dimensions(icon_dim.g_x, icon_dim.g_y,
- icon_dim.g_w, icon_dim.g_h);
- plot_clip( &icon_clip );
- atari_plotters.bitmap( bmpx, bmpy, bmpw, bmph, icon,
- toolbar_styles[tb->style].icon_bgcolor,
- BITMAPF_BUFFER_NATIVE );
- } else {
- objc_draw( tree, 0, 0, todo.g_x, todo.g_y, todo.g_w, todo.g_h );
- }
- vs_clip(atari_plot_vdi_handle, 0, (short*)&clip );
- }
- wind_get(gw->root->handle->handle, WF_NEXTXYWH,
- &todo.g_x, &todo.g_y, &todo.g_w, &todo.g_h );
- }
-}
-
-
-static void __CDECL button_click( COMPONENT *c, long buff[8], void * data )
-{
- struct s_tb_button * bt = (struct s_tb_button *)data;
- int i = 0;
- struct gui_window * gw = bt->gw;
- assert( gw );
- gw->root->toolbar->buttons[bt->index].cb_click( gw );
-}
-
-
-static struct s_tb_button * find_button( struct gui_window * gw, int rsc_id )
+struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
{
- int i = 0;
- while( i < gw->root->toolbar->btcnt ) {
- if( gw->root->toolbar->buttons[i].rsc_id == rsc_id ) {
- return( &gw->root->toolbar->buttons[i] );
- }
- i++;
- }
-}
-
-
-static COMPONENT *button_init( CMP_TOOLBAR t, OBJECT * tree, int index,
- struct s_tb_button * instance )
-{
- int comp_width;
-
- *instance = tb_buttons[index];
- instance->gw = t->owner;
-
- comp_width = toolbar_styles[t->style].icon_width + \
- ( toolbar_styles[t->style].button_vmargin * 2 );
-
- instance->comp = mt_CompCreate( &app, CLT_VERTICAL, comp_width, 0 );
- assert( instance->comp );
+ int i;
- instance->comp->bounds.max_width = comp_width;
- mt_CompEvntDataAttach( &app, instance->comp, WM_REDRAW, button_redraw,
- instance );
- mt_CompEvntDataAttach( &app, instance->comp, WM_XBUTTON, button_click,
- instance );
- return instance->comp;
-}
-
+ LOG((""));
-static
-void __CDECL evnt_throbber_redraw( COMPONENT *c, long buff[8])
-{
- LGRECT work, clip;
- int idx;
- short pxy[4];
- struct s_toolbar * tb;
- struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app,
- c,
- CDT_OWNER );
- plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
- tb = gw->root->toolbar;
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- clip = work;
- if ( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return;
-
- vsf_interior(atari_plot_vdi_handle , 1 );
- pxy[0] = (short)buff[4];
- pxy[1] = (short)buff[5];
- pxy[2] = (short)buff[4] + buff[6]-1;
- pxy[3] = (short)buff[5] + buff[7]-2;
- vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy );
-
- if (app.nplanes > 2 ) {
- plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h);
- plot_rectangle( 0, 0, work.g_w, work.g_h, &plot_style_background);
- }
- else {
- vsf_color(atari_plot_vdi_handle, WHITE );
- v_bar(atari_plot_vdi_handle, (short*)&pxy );
- }
-
- if( img_toolbar ){
-
- int bmpx=0, bmpy=0, bmpw=0, bmph = 0, drawstate=0;
- struct rect icon_clip;
- struct bitmap * icon = NULL;
-
- if( throbber_image_ready == false ){
- return;
- }
- icon = content_get_bitmap( throbber_image );
- if( icon == NULL ){
- return;
- }
+ struct s_toolbar *t = calloc(sizeof(struct s_toolbar), 1);
- if( tb->throbber.running == false ) {
- idx = 0;
- }
- else {
- idx = tb->throbber.index;
- if( idx > tb->throbber.max_index ) {
- idx = tb->throbber.index = 1;
- }
- }
- bmpw = bitmap_get_width(icon);
- bmph = bitmap_get_height(icon);
- bmpx = 0;
- bmpy = 0;
-
- /*
- for some reason, adding
- toolbar_styles[tb->style].button_vmargin to the x pos of
- the plotter shifts the icon a bit to much.
- Maybe that's becasue the icon is inside an padded form.
- */
- plot_set_dimensions(
- work.g_x-(toolbar_styles[tb->style].icon_width * idx),
- work.g_y+toolbar_styles[tb->style].button_hmargin,
- toolbar_styles[tb->style].icon_width*(idx+1),
- toolbar_styles[tb->style].icon_height
- );
- icon_clip.x0 = bmpx+(toolbar_styles[tb->style].icon_width*idx);
- icon_clip.y0 = bmpy;
- icon_clip.x1 = icon_clip.x0+toolbar_styles[tb->style].icon_width;
- icon_clip.y1 = icon_clip.y0+toolbar_styles[tb->style].icon_height;
- plot_clip( &icon_clip );
- atari_plotters.bitmap( bmpx, bmpy, bmpw, bmph, icon,
- toolbar_styles[tb->style].icon_bgcolor,
- BITMAPF_BUFFER_NATIVE );
- }
- else {
- if( throbber_form != NULL ) {
- if( gw->root->toolbar->throbber.running == false ) {
- idx = THROBBER_INACTIVE_INDEX;
- } else {
- idx = gw->root->toolbar->throbber.index;
- if( idx > THROBBER_MAX_INDEX || idx < THROBBER_MIN_INDEX ) {
- idx = THROBBER_MIN_INDEX;
- }
- }
- throbber_form[idx].ob_x = work.g_x+1;
- throbber_form[idx].ob_y = work.g_y+4;
- mt_objc_draw( throbber_form, idx, 8, clip.g_x, clip.g_y, clip.g_w, clip.g_h, app.aes_global );
- }
- }
-
-}
-
-static
-void __CDECL evnt_url_redraw( COMPONENT *c, long buff[8], void * data)
-{
- LGRECT work, clip;
- struct gui_window * gw;
- short pxy[10];
- plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
- CMP_TOOLBAR tb = (CMP_TOOLBAR)data;
- mt_CompGetLGrect(&app, tb->url.comp, WF_WORKXYWH, &work);
-
- // this last pixel is drawn by the root component of the toolbar:
- // it's the black border, so we leave it out:
- work.g_h--;
- clip = work;
- if ( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return;
-
- plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h);
-
- //left margin:
- plot_rectangle(0, 0, TOOLBAR_URL_MARGIN_LEFT, work.g_h,
- &plot_style_background);
- // right margin:
- plot_rectangle(work.g_w-TOOLBAR_URL_MARGIN_RIGHT, 0, work.g_w, work.g_h,
- &plot_style_background);
-
- // top margin:
- plot_rectangle(0, 0, work.g_w, TOOLBAR_URL_MARGIN_TOP,
- &plot_style_background);
-
- // bottom margin:
- plot_rectangle(0, work.g_h-TOOLBAR_URL_MARGIN_BOTTOM, work.g_w, work.g_h,
- &plot_style_background);
-
- // TBD: request redraw of textarea for specific region.
- clip.g_x -= work.g_x+TOOLBAR_URL_MARGIN_LEFT;
- clip.g_y -= work.g_y+TOOLBAR_URL_MARGIN_TOP;
- tb_txt_request_redraw( tb, clip.g_x, clip.g_y, clip.g_w, clip.g_h );
-}
-
-static
-void __CDECL evnt_url_click( COMPONENT *c, long buff[8] )
-{
- LGRECT work;
- short pxy[4];
- short mx, my, mb, kstat;
- int old;
- graf_mkstate( &mx, &my, &mb, &kstat );
- struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app, c, CDT_OWNER);
- assert( gw != NULL );
- CMP_TOOLBAR tb = gw->root->toolbar;
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- mx = evnt.mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
- my = evnt.my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
-
- /* TODO: reset mouse state of browser window? */
- /* select whole text when newly focused, otherwise set caret to end of text */
- if( !window_url_widget_has_focus(gw) ) {
- window_set_focus( gw, URL_WIDGET, (void*)&tb->url );
- } else {
- if( mb & 1 ) {
- textarea_mouse_action( tb->url.textarea, BROWSER_MOUSE_DRAG_1,
- mx, my );
- short prev_x = mx;
- short prev_y = my;
- do{
- if( abs(prev_x-mx) > 5 || abs(prev_y-my) > 5 ){
- textarea_mouse_action( tb->url.textarea,
- BROWSER_MOUSE_HOLDING_1, mx, my );
- prev_x = mx;
- prev_y = my;
- if( tb->url.redraw ){
- tb_url_redraw( gw );
- }
- }
- graf_mkstate( &mx, &my, &mb, &kstat );
- mx = mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
- my = my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
- }while( mb & 1 );
- textarea_drag_end( tb->url.textarea, 0, mx, my );
- } else {
- /* TODO: recognize click + shift key */
- int mstate = BROWSER_MOUSE_PRESS_1;
- if( (kstat & (K_LSHIFT|K_RSHIFT)) != 0 )
- mstate = BROWSER_MOUSE_MOD_1;
- if( evnt.nb_click == 2 ){
- textarea_mouse_action( tb->url.textarea,
- BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1,
- mx, my );
- } else {
- textarea_mouse_action( tb->url.textarea,
- BROWSER_MOUSE_PRESS_1, mx, my );
- }
- }
- }
- // TODO: do not send an complete redraw!
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
-}
-
-
-void tb_adjust_size( struct gui_window * gw )
-{
- LGRECT work;
- CMP_TOOLBAR t = gw->root->toolbar;
-
- mt_CompGetLGrect( &app, t->url.comp, WF_WORKXYWH, &work);
- work.g_w -= (TOOLBAR_URL_MARGIN_LEFT + TOOLBAR_URL_MARGIN_RIGHT);
- /* do not overwrite the black border, because of that, add 1 */
- work.g_h -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM+1);
- textarea_set_dimensions( t->url.textarea, work.g_w, work.g_h );
- tb_txt_request_redraw( t, 0,0, work.g_w-1, work.g_h-1);
-}
-
-static void __CDECL evnt_toolbar_redraw( COMPONENT *c, long buff[8], void *data )
-{
- LGRECT work, clip;
- short pxy[4];
- const plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- clip = work;
- if( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return;
- if( work.g_y + work.g_h != clip.g_y + clip.g_h ) return;
-
- vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
- vsl_color(atari_plot_vdi_handle, BLACK );
- vsl_type(atari_plot_vdi_handle, 1 );
- vsl_width(atari_plot_vdi_handle, 1 );
- pxy[0] = clip.g_x;
- pxy[1] = pxy[3] = work.g_y + work.g_h-1 ;
- pxy[2] = clip.g_x + clip.g_w;
- v_pline(atari_plot_vdi_handle, 2, (short*)&pxy );
-}
-
-
-static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
-{
- LGRECT work;
- if( data == NULL )
- return;
- CMP_TOOLBAR t = data;
- if( t->url.redraw == false ){
- t->url.redraw = true;
- //t->redraw = true;
- t->url.rdw_area.g_x = x;
- t->url.rdw_area.g_y = y;
- t->url.rdw_area.g_w = w;
- t->url.rdw_area.g_h = h;
- } else {
- /* merge the redraw area to the new area.: */
- int newx1 = x+w;
- int newy1 = y+h;
- int oldx1 = t->url.rdw_area.g_x + t->url.rdw_area.g_w;
- int oldy1 = t->url.rdw_area.g_y + t->url.rdw_area.g_h;
- t->url.rdw_area.g_x = MIN(t->url.rdw_area.g_x, x);
- t->url.rdw_area.g_y = MIN(t->url.rdw_area.g_y, y);
- t->url.rdw_area.g_w = ( oldx1 > newx1 ) ?
- oldx1 - t->url.rdw_area.g_x : newx1 - t->url.rdw_area.g_x;
- t->url.rdw_area.g_h = ( oldy1 > newy1 ) ?
- oldy1 - t->url.rdw_area.g_y : newy1 - t->url.rdw_area.g_y;
- }
-}
-
-void tb_url_redraw( struct gui_window * gw )
-{
-
- CMP_TOOLBAR t = gw->root->toolbar;
- if (t != NULL) {
- if( t->url.redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
-
- const struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &atari_plotters
- };
- short todo[4];
- LGRECT work;
-
- mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &work);
- work.g_x += TOOLBAR_URL_MARGIN_RIGHT;
- work.g_y += TOOLBAR_URL_MARGIN_LEFT;
- work.g_w -= TOOLBAR_URL_MARGIN_RIGHT;
- work.g_h -= TOOLBAR_URL_MARGIN_BOTTOM;
-
- plot_set_dimensions( work.g_x, work.g_y, work.g_w, work.g_h );
- if(plot_lock() == false)
- return;
+ assert(t);
- todo[0] = work.g_x;
- todo[1] = work.g_y;
- todo[2] = todo[0] + work.g_w-1;
- todo[3] = todo[1] + work.g_h-1;
- vs_clip(atari_plot_vdi_handle, 1, (short*)&todo );
-
- if( wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
- &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
- while (todo[2] && todo[3]) {
-
- /* convert screen to relative coords: */
- todo[0] = todo[0] - work.g_x;
- todo[1] = todo[1] - work.g_y;
- if( todo[0] < 0 ){
- todo[2] = todo[2] + todo[0];
- todo[0] = 0;
- }
- if( todo[1] < 0 ){
- todo[3] = todo[3] + todo[1];
- todo[1] = 0;
- }
-
- if (rc_intersect(&t->url.rdw_area,(GRECT *)&todo)) {
- struct rect clip = {
- .x0 = todo[0],
- .y0 = todo[1],
- .x1 = todo[0]+todo[2],
- .y1 = todo[1]+todo[3]
- };
- textarea_redraw( t->url.textarea, 0, 0, &clip, &ctx );
- }
- if (wind_get(gw->root->handle->handle, WF_NEXTXYWH,
- &todo[0], &todo[1], &todo[2], &todo[3])==0) {
- break;
- }
- }
- } else {
- plot_unlock();
- return;
- }
- plot_unlock();
- vs_clip(atari_plot_vdi_handle, 0, (short*)&todo);
- t->url.redraw = false;
- t->url.rdw_area.g_x = 65000;
- t->url.rdw_area.g_y = 65000;
- t->url.rdw_area.g_w = -1;
- t->url.rdw_area.g_h = -1;
- } else {
- /* just copy stuff from the offscreen buffer */
- }
- }
-}
-
-CMP_TOOLBAR tb_create( struct gui_window * gw )
-{
- int i;
-
-
- CMP_TOOLBAR t = malloc( sizeof(struct s_toolbar) );
- if( t == NULL )
- return( NULL );
-
- t->owner = gw;
+ t->owner = owner;
t->style = 1;
/* create the root component: */
- t->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
- toolbar_styles[t->style].height, 0 );
- t->comp->rect.g_h = toolbar_styles[t->style].height;
- t->comp->bounds.max_height = toolbar_styles[t->style].height;
- mt_CompEvntDataAdd(&app, t->comp, WM_REDRAW, evnt_toolbar_redraw,
- gw, EV_BOT);
+ t->area.g_h = toolbar_styles[t->style].height;
/* count buttons and add them as components: */
i = 0;
- while( tb_buttons[i].rsc_id > 0 ) {
+ while(tb_buttons[i].rsc_id > 0) {
i++;
}
t->btcnt = i;
- t->buttons = malloc( t->btcnt * sizeof(struct s_tb_button) );
- memset( t->buttons, 0, t->btcnt * sizeof(struct s_tb_button) );
- for( i=0; i < t->btcnt; i++ ) {
- button_init( t, toolbar_buttons, i, &t->buttons[i] );
- mt_CompAttach( &app, t->comp, t->buttons[i].comp );
+ t->buttons = malloc(t->btcnt * sizeof(struct s_tb_button));
+ memset( t->buttons, 0, t->btcnt * sizeof(struct s_tb_button));
+ for (i=0; i < t->btcnt; i++ ) {
+ button_init(t, aes_toolbar, i, &t->buttons[i]);
}
/* create the url widget: */
@@ -770,30 +376,16 @@ CMP_TOOLBAR tb_create( struct gui_window * gw )
int ta_height = toolbar_styles[t->style].height;
ta_height -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM);
- t->url.textarea = textarea_create( 300,
- ta_height,
- 0,
- &font_style_url, tb_txt_request_redraw,
- t );
+ t->url.textarea = textarea_create(300, ta_height, 0, &font_style_url,
+ tb_txt_request_redraw, t);
if( t->url.textarea != NULL ){
textarea_set_text(t->url.textarea, "http://");
}
-
- t->url.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
- toolbar_styles[t->style].height, 1);
- mt_CompEvntDataAttach( &app, t->url.comp, WM_REDRAW, evnt_url_redraw, t);
- mt_CompEvntAttach( &app, t->url.comp, WM_XBUTTON, evnt_url_click );
- mt_CompDataAttach( &app, t->url.comp, CDT_OWNER, gw );
- mt_CompAttach( &app, t->comp, t->url.comp );
/* create the throbber widget: */
- t->throbber.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
- toolbar_styles[t->style].height, 0);
- t->throbber.comp->rect.g_h = toolbar_styles[t->style].height;
- t->throbber.comp->rect.g_w = t->throbber.comp->bounds.max_width = \
- toolbar_styles[t->style].icon_width + \
+ t->throbber.area.g_h = toolbar_styles[t->style].height;
+ t->throbber.area.g_w = toolbar_styles[t->style].icon_width + \
(2*toolbar_styles[t->style].button_vmargin );
- t->throbber.comp->bounds.max_height = toolbar_styles[t->style].height;
if( img_toolbar == true ){
t->throbber.index = 0;
t->throbber.max_index = 8;
@@ -801,251 +393,163 @@ CMP_TOOLBAR tb_create( struct gui_window * gw )
t->throbber.index = THROBBER_MIN_INDEX;
t->throbber.max_index = THROBBER_MAX_INDEX;
}
- t->throbber.running = false;
- mt_CompEvntAttach( &app, t->throbber.comp, WM_REDRAW, evnt_throbber_redraw );
- mt_CompDataAttach( &app, t->throbber.comp, CDT_OWNER, gw );
- mt_CompAttach( &app, t->comp, t->throbber.comp );
+ t->throbber.running = false;
+
+ LOG(("created toolbar: %p, root: %p, textarea: %p, throbber: %p", t,
+ owner, t->url.textarea, t->throbber));
return( t );
-}
-
-
-void tb_destroy( CMP_TOOLBAR tb )
+}
+
+
+void toolbar_destroy(struct s_toolbar *tb)
{
- free( tb->buttons );
+ free(tb->buttons);
textarea_destroy( tb->url.textarea );
- mt_CompDelete( &app, tb->comp);
- free( tb );
-}
-
-
-struct gui_window * tb_gui_window( CMP_TOOLBAR tb )
-{
- struct gui_window * gw;
- gw = window_list;
- while( gw != NULL ) {
- if( gw->root->toolbar == tb ) {
- LOG(("found tb gw: %p (tb: %p) for tb: %p", gw, gw->root->toolbar, tb ));
- return( gw );
- }
- else
- gw = gw->next;
- }
- return( NULL );
-}
-
-
-void tb_update_buttons( struct gui_window * gw, short button )
+ free(tb);
+}
+
+static void toolbar_objc_reflow(struct s_toolbar *tb)
{
-
-#define FIRST_BUTTON TOOLBAR_BT_BACK
-
- struct s_tb_button * bt;
- bool enable = false;
- if( button == TOOLBAR_BT_BACK || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_BACK-FIRST_BUTTON];
- enable = browser_window_back_available(gw->browser->bw);
- if( enable ){
- bt->state = button_on;
- } else {
- bt->state = button_off;
- }
- mt_CompEvntRedraw( &app, bt->comp );
- }
+ aes_toolbar->ob_x = tb->area.g_x;
+ aes_toolbar->ob_y = tb->area.g_y;
+ aes_toolbar->ob_width = tb->area.g_w;
+ aes_toolbar->ob_height = tb->area.g_h;
- if( button == TOOLBAR_BT_HOME || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_HOME-FIRST_BUTTON];
- mt_CompEvntRedraw( &app, bt->comp );
- }
+ aes_toolbar[TOOLBAR_THROBBER_AREA].ob_x = tb->area.g_w
+ - aes_toolbar[TOOLBAR_THROBBER_AREA].ob_width;
- if( button == TOOLBAR_BT_FORWARD || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_FORWARD-FIRST_BUTTON];
- enable = browser_window_forward_available(gw->browser->bw);
- if( enable ){
- bt->state = button_on;
- } else {
- bt->state = button_off;
- }
- mt_CompEvntRedraw( &app, bt->comp );
- }
+ aes_toolbar[TOOLBAR_URL_AREA].ob_width = tb->area.g_w
+ - (aes_toolbar[TOOLBAR_NAVIGATION_AREA].ob_width
+ + aes_toolbar[TOOLBAR_THROBBER_AREA].ob_width);
+}
- if( button == TOOLBAR_BT_RELOAD || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_RELOAD-FIRST_BUTTON];
- enable = browser_window_reload_available(gw->browser->bw);
- if( enable ){
- bt->state = button_on;
- } else {
- bt->state = button_off;
- }
- mt_CompEvntRedraw( &app, bt->comp );
- }
+void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
+{
+ // position toolbar areas:
+ toolbar_objc_reflow(tb);
+ objc_draw_grect(aes_toolbar,0,8,clip);
- if( button == TOOLBAR_BT_STOP || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_STOP-FIRST_BUTTON];
- enable = browser_window_stop_available(gw->browser->bw);
- if( enable ){
- bt->state = button_on;
- } else {
- bt->state = button_off;
- }
- mt_CompEvntRedraw( &app, bt->comp );
- }
+ // position throbber image:
+ throbber_form[tb->throbber.index].ob_x = tb->area.g_x +
+ aes_toolbar[TOOLBAR_THROBBER_AREA].ob_x;
-#undef FIRST_BUTON
-}
-
-
-
-void tb_url_set( struct gui_window * gw, char * text )
-{
- LGRECT work;
- int len = strlen(text);
- char * newtext;
- int newsize;
-
- if( gw->root->toolbar == NULL )
- return;
-
- if( gw->browser->attached == false )
- return;
-
- struct s_url_widget * url = &gw->root->toolbar->url;
-
- assert( gw != NULL );
- assert( gw->browser != NULL );
- assert( gw->root != NULL );
- assert( gw->browser->bw != NULL );
-
- textarea_set_text(url->textarea, text);
-
- mt_CompGetLGrect( &app, gw->root->toolbar->url.comp, WF_WORKXYWH, &work);
- work.g_w -= (TOOLBAR_URL_MARGIN_LEFT + TOOLBAR_URL_MARGIN_RIGHT);
- /* do not overwrite the black border, because of that, add 1 */
- work.g_h -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM+1);
- tb_txt_request_redraw( gw->root->toolbar, 0,0,work.g_w,work.g_h );
- tb_update_buttons( gw, TOOLBAR_BT_STOP );
- return;
-}
-
-
-/* -------------------------------------------------------------------------- */
-/* Public Module event handlers: */
-/* -------------------------------------------------------------------------- */
-
-bool tb_url_input( struct gui_window * gw, short nkc )
-{
- CMP_TOOLBAR tb = gw->root->toolbar;
- assert(tb!=NULL);
- LGRECT work;
- bool ret = false;
-
- assert( gw != NULL );
-
- long ucs4;
- long ik = nkc_to_input_key( nkc, &ucs4 );
-
- if( ik == 0 ){
- if ( (nkc&0xFF) >= 9 ) {
- ret = textarea_keypress( tb->url.textarea, ucs4 );
- }
- }
- else if( ik == KEY_CR || ik == KEY_NL ){
- char tmp_url[PATH_MAX];
- if( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
- window_set_focus( gw, BROWSER, gw->browser);
- browser_window_go(gw->browser->bw, (const char*)&tmp_url, 0, true);
- ret = true;
- }
- }
- else if( ik == KEY_COPY_SELECTION ){
- // copy whole text
- char * text;
- int len;
- len = textarea_get_text( tb->url.textarea, NULL, 0 );
- text = malloc( len+1 );
- if( text ){
- textarea_get_text( tb->url.textarea, text, len+1 );
- scrap_txt_write( &app, text );
- free( text );
- }
- }
- else if( ik == KEY_PASTE ){
- char * clip = scrap_txt_read( &app );
- if( clip != NULL ){
- int clip_length = strlen( clip );
- if ( clip_length > 0 ) {
- char *utf8;
- utf8_convert_ret res;
- /* Clipboard is in local encoding so
- * convert to UTF8 */
- res = utf8_from_local_encoding( clip, clip_length, &utf8 );
- if ( res == UTF8_CONVERT_OK ) {
- tb_url_set( gw, utf8 );
- free(utf8);
- ret = true;
- }
- free( clip );
- }
- }
- }
- else if( ik == KEY_ESCAPE ) {
- textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
- textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
- }
- else {
- ret = textarea_keypress( tb->url.textarea, ik );
- }
-
- return( ret );
-}
+ throbber_form[tb->throbber.index].ob_x = tb->area.g_x
+ + aes_toolbar[TOOLBAR_THROBBER_AREA].ob_x +
+ ((aes_toolbar[TOOLBAR_THROBBER_AREA].ob_width
+ - throbber_form[tb->throbber.index].ob_width) >> 1);
+
+ throbber_form[tb->throbber.index].ob_y = tb->area.g_y +
+ ((aes_toolbar[TOOLBAR_THROBBER_AREA].ob_height
+ - throbber_form[tb->throbber.index].ob_height) >> 1);
+
+ printf("x pos: %d, y pos: %d\n", throbber_form[tb->throbber.index].ob_x,
+ throbber_form[tb->throbber.index].ob_y);
+ objc_draw_grect(&throbber_form[tb->throbber.index], 0, 1, clip);
+
+}
+
+
+void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
+ short button)
+{
+ LOG((""));
+}
+
+
+void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area)
+{
+ tb->area = *area;
+ if (img_toolbar != 0) {
+ toolbar_reflow(tb);
+ }
+}
+
+
+void toolbar_set_url(struct s_toolbar *tb, const char * text)
+{
+ LOG((""));
+}
+
+
+bool toolbar_text_input(struct s_toolbar *tb, char *text)
+{
+ bool handled = true;
+
+ LOG((""));
+
+ return(handled);
+}
+
+bool toolbar_key_input(struct s_toolbar *tb, short nkc)
+{
+ bool handled = true;
+
+ LOG((""));
+
+ return(handled);
+}
+
+
+void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my)
+{
+ LOG((""));
+}
+
+
+
+void toolbar_get_grect(struct s_toolbar *tb, short which, short opt, GRECT *dst)
+{
+
+}
+
+
+struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
+ enum toolbar_textarea which)
+{
+ return(tb->url.textarea);
+}
+
+
+/* public event handler */
+void toolbar_back_click(struct s_toolbar *tb)
+{
+ assert(input_window != NULL);
-void tb_back_click( struct gui_window * gw )
-{
- struct browser_window *bw = gw->browser->bw;
+ struct browser_window *bw = input_window->browser->bw;
if( history_back_available(bw->history) )
history_back(bw, bw->history);
}
-void tb_reload_click( struct gui_window * gw )
+void toolbar_reload_click(struct s_toolbar *tb)
{
- browser_window_reload( gw->browser->bw, true );
+ assert(input_window != NULL);
+ browser_window_reload(input_window->browser->bw, true);
}
-void tb_forward_click( struct gui_window * gw )
-{
- struct browser_window *bw = gw->browser->bw;
+void toolbar_forward_click(struct s_toolbar *tb)
+{
+ assert(input_window != NULL);
+ struct browser_window *bw = input_window->browser->bw;
if (history_forward_available(bw->history))
history_forward(bw, bw->history);
}
-void tb_home_click( struct gui_window * gw )
+void toolbar_home_click(struct s_toolbar *tb)
{
- browser_window_go(gw->browser->bw, option_homepage_url, 0, true);
+ assert(input_window != NULL);
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ bw = gw->browser->bw;
+ browser_window_go(bw, option_homepage_url, 0, true);
}
-void tb_stop_click( struct gui_window * gw )
+void toolbar_stop_click(struct s_toolbar *tb)
{
- browser_window_stop(gw->browser->bw);
+ assert(input_window != NULL);
+ browser_window_stop(input_window->browser->bw);
}
-
-void tb_hide( struct gui_window * gw, short mode )
-{
- CMP_TOOLBAR tb = gw->root->toolbar;
- assert( tb != NULL );
- if( mode == 1 ){
- tb->hidden = true;
- tb->comp->rect.g_h = 0;
- tb->comp->bounds.max_height = 0;
-
- } else {
- tb->hidden = false;
- tb->comp->rect.g_h = toolbar_styles[tb->style].height;
- tb->comp->bounds.max_height = toolbar_styles[tb->style].height;
- }
- gw->browser->reformat_pending = true;
- browser_update_rects( gw );
- snd_rdw( gw->root->handle );
-}
-
diff --git a/atari/toolbar.h b/atari/toolbar.h
old mode 100755
new mode 100644
index 7f86408..7cc7b92
--- a/atari/toolbar.h
+++ b/atari/toolbar.h
@@ -1,118 +1,38 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * 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/>.
- */
-
-#ifndef NS_ATARI_TOOLBAR_H
+#ifndef NS_ATARI_TOOLBAR_H
#define NS_ATARI_TOOLBAR_H
+#include <stdbool.h>
+#include <stdint.h>
+
#include "desktop/textarea.h"
-#include "desktop/textinput.h"
-#include "content/hlcache.h"
-#include "atari/browser.h"
-
-#define TB_BUTTON_WIDTH 32
-#define THROBBER_WIDTH 32
-#define THROBBER_MIN_INDEX 1
-#define THROBBER_MAX_INDEX 12
-#define THROBBER_INACTIVE_INDEX 13
+#include "desktop/browser.h"
-#define TOOLBAR_URL_MARGIN_LEFT 2
-#define TOOLBAR_URL_MARGIN_RIGHT 2
-#define TOOLBAR_URL_MARGIN_TOP 2
-#define TOOLBAR_URL_MARGIN_BOTTOM 2
-
-enum e_toolbar_button_states {
- button_on = 0,
- button_off = 1
-};
-#define TOOLBAR_BUTTON_NUM_STATES 2
-
-struct s_tb_button
-{
- short rsc_id;
- void (*cb_click)(struct gui_window * gw);
- COMPONENT * comp;
- hlcache_handle * icon[TOOLBAR_BUTTON_NUM_STATES];
- struct gui_window * gw;
- short state;
- short index;
-};
-
-
-struct s_url_widget
-{
- bool redraw; /* widget is only redrawn when this flag is set */
- struct text_area *textarea;
- COMPONENT * comp;
- GRECT rdw_area;
-};
-
-struct s_throbber_widget
-{
- COMPONENT * comp;
- short index;
- short max_index;
- bool running;
-};
+struct s_toolbar;
-struct s_toolbar
-{
- COMPONENT * comp;
- struct gui_window * owner;
- struct s_url_widget url;
- struct s_throbber_widget throbber;
- GRECT btdim;
- /* size & location of buttons: */
- struct s_tb_button * buttons;
- bool hidden;
- int btcnt;
- int style;
- bool redraw;
-};
+enum toolbar_textarea {
+ URL_INPUT_TEXT_AREA = 1
+};
-/* interface to the toolbar */
-
-/* Must be called before any other toolbar function is called: */
-void toolbar_init( void );
-/*Must be called when netsurf exits to free toolbar resources: */
+void toolbar_init(void);
+struct s_toolbar *toolbar_create(struct s_gui_win_root *owner);
+void toolbar_destroy(struct s_toolbar * tb);
void toolbar_exit( void );
-CMP_TOOLBAR tb_create( struct gui_window * gw );
-void tb_destroy( CMP_TOOLBAR tb );
-/* recalculate size/position of nested controls within the toolbar: */
-void tb_adjust_size( struct gui_window * gw );
-/* report click to toolbar, relative coords : */
-void tb_click( struct gui_window * gw, short mx, short my, short mb, short kstat );
-void tb_back_click( struct gui_window * gw );
-void tb_reload_click( struct gui_window * gw );
-void tb_forward_click( struct gui_window * gw );
-void tb_home_click( struct gui_window * gw );
-void tb_stop_click( struct gui_window * gw );
-/* enable / disable buttons etc. */
-void tb_update_buttons( struct gui_window * gw, short buttonid );
-/* handles clicks on url widget: */
-void tb_url_click( struct gui_window * gw, short mx, short my, short mb, short kstat );
-/* handle keybd event while url widget has focus:*/
-bool tb_url_input( struct gui_window * gw, short keycode );
-/* set the url: */
-void tb_url_set( struct gui_window * gw, char * text );
-/* perform redraw of invalidated url textinput areas: */
-void tb_url_redraw( struct gui_window * gw );
-struct gui_window * tb_gui_window( CMP_TOOLBAR tb );
-/* hide toolbar, mode = 1: hide, mode = 0: show */
-void tb_hide( struct gui_window * gw, short mode );
-
-#endif
+void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area);
+void toolbar_set_url(struct s_toolbar *tb, const char *text);
+bool toolbar_text_input(struct s_toolbar *tb, char *text);
+bool toolbar_key_input(struct s_toolbar *tb, short nkc);
+void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my);
+void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
+ short idx);
+void toolbar_get_grect(struct s_toolbar *tb, short which, short opt, GRECT *g);
+struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
+ enum toolbar_textarea which);
+/* public events handlers: */
+void toolbar_back_click(struct s_toolbar *tb);
+void toolbar_reload_click(struct s_toolbar *tb);
+void toolbar_forward_click(struct s_toolbar *tb);
+void toolbar_home_click(struct s_toolbar *tb);
+void toolbar_stop_click(struct s_toolbar *tb);
+
+
+#endif
-----------------------------------------------------------------------
Summary of changes:
atari/browser.c | 175 ++++----
atari/browser.h | 23 +-
atari/clipboard.h | 6 +-
atari/ctxmenu.c | 2 +-
atari/deskmenu.c | 33 +-
atari/gemtk/gemtk.h | 17 +-
atari/gemtk/guiwin.c | 78 +++--
atari/global_evnt.c | 30 +-
atari/gui.c | 333 +++++++--------
atari/gui.h | 13 +-
atari/misc.c | 19 +-
atari/misc.h | 2 +-
atari/res/netsurf.rsc | Bin 35740 -> 35788 bytes
atari/res/netsurf.rsh | 3 +
atari/res/netsurf.rsm | 9 +-
atari/rootwin.c | 416 ++++++++++--------
atari/rootwin.h | 40 ++-
atari/toolbar.c | 1152 ++++++++++++++-----------------------------------
atari/toolbar.h | 142 ++-----
19 files changed, 995 insertions(+), 1498 deletions(-)
mode change 100755 => 100644 atari/toolbar.c
mode change 100755 => 100644 atari/toolbar.h
diff --git a/atari/browser.c b/atari/browser.c
index 1b3661e..1904722 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -62,14 +62,14 @@ extern struct gui_window *input_window;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
-static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect );
+static void browser_process_scroll( struct gui_window * gw, GRECT bwrect );
static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff,
struct rect * area );
-static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8],
+static void __CDECL browser_evnt_destroy( COMPONENT * c, short buff[8],
void * data);
-static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8],
+static void __CDECL browser_evnt_redraw( COMPONENT * c, short buff[8],
void * data);
-static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8],
+static void __CDECL browser_evnt_mbutton( COMPONENT * c, short buff[8],
void * data);
@@ -104,7 +104,9 @@ struct s_browser * browser_create
return(NULL);
}
- /* Attach events to the component: */
+ /* Attach events to the component: */
+ // TODO: implement event chaining in rootwin
+ /*
mt_CompEvntDataAdd( &app, bnew->comp, WM_XBUTTON,
browser_evnt_mbutton, (void*)gw, EV_BOT
);
@@ -113,7 +115,8 @@ struct s_browser * browser_create
);
mt_CompEvntDataAttach( &app, bnew->comp, WM_DESTROY,
browser_evnt_destroy, (void*)bnew
- );
+ );
+ */
/* Set the gui_window owner. */
/* it is an link to the netsurf window system */
@@ -135,76 +138,69 @@ bool browser_destroy( struct s_browser * b )
LOG(("%s\n", b->bw->name ));
assert( b != NULL );
- assert( b->comp != NULL );
assert( b->bw != NULL );
+
+ struct gui_window * gw = b->bw->window;
+ LOG(("%s\n",gw->browser->bw->name));
+
+ assert( b != NULL );
+ assert( gw != NULL );
+ free( b );
+ gw->browser = NULL;
- if( b->comp != NULL ){
- mt_CompDelete(&app, b->comp );
- }
return( true );
}
/*
Query the browser component for widget rectangles.
*/
-void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT * out)
+void browser_get_rect( struct gui_window * gw, enum browser_rect type, GRECT * out)
{
- LGRECT cur;
-
+ GRECT cur;
+
+ // TODO: update browser get grect
/* Query component for it's current size: */
- mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &cur);
-
/* And extract the different widget dimensions: */
- if( type == BR_CONTENT ){
- out->g_w = cur.g_w;
- out->g_h = cur.g_h;
- out->g_x = cur.g_x;
- out->g_y = cur.g_y;
- }
+ if (type == BR_CONTENT ) {
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, out);
+ }
+ else if (type==BR_URL_INPUT) {
+ // TODO: calculate url input area somehow
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_TOOLBAR, out);
+ }
+ else if (type==BR_THROBBER) {
+ // TODO: calculate throbber area somehow
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_TOOLBAR, out);
+ }
- return;
-}
-/* Report an resize to the COMPONENT interface */
-void browser_update_rects(struct gui_window * gw )
-{
- short buff[8];
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&buff[4]);
- buff[0] = CM_REFLOW;
- buff[1] = _AESapid;
- buff[2] = 0;
- EvntExec(gw->root->handle, buff);
+ return;
}
void browser_set_content_size(struct gui_window * gw, int w, int h)
{
CMP_BROWSER b = gw->browser;
- LGRECT work;
+ GRECT work;
browser_get_rect( gw, BR_CONTENT, &work );
-
- gw->root->handle->xpos_max = w;
- gw->root->handle->ypos_max = h;
-
- if( w < work.g_w + b->scroll.current.x || w < work.g_h + b->scroll.current.y ) {
- /* let the scroll routine detect invalid scroll values... */
- browser_scroll(gw, WA_LFLINE, b->scroll.current.x, true );
- browser_scroll(gw, WA_UPLINE, b->scroll.current.y, true );
- /* force update of scrollbars: */
- b->scroll.required = true;
- }
+
+ // TODO: implement new content size setter
+ //gw->root->handle->xpos_max = w;
+ //gw->root->handle->ypos_max = h;
+
+// if( w < work.g_w + b->scroll.current.x || w < work.g_h + b->scroll.current.y ) {
+// /* let the scroll routine detect invalid scroll values... */
+// browser_scroll(gw, WA_LFLINE, b->scroll.current.x, true );
+// browser_scroll(gw, WA_UPLINE, b->scroll.current.y, true );
+// /* force update of scrollbars: */
+// b->scroll.required = true;
+// }
}
-static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * data)
+static void __CDECL browser_evnt_destroy( COMPONENT * c, short buff[8], void * data)
{
struct s_browser * b = (struct s_browser*)data;
- struct gui_window * gw = b->bw->window;
- LOG(("%s\n",gw->browser->bw->name));
- assert( b != NULL );
- assert( gw != NULL );
- free( b );
- gw->browser = NULL;
LOG(("evnt_destroy done!"));
}
@@ -212,10 +208,10 @@ static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * da
Mouse Button handler for browser component.
*/
-static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * data)
+static void __CDECL browser_evnt_mbutton( COMPONENT * c, short buff[8], void * data)
{
short mx, my, dummy, mbut;
- LGRECT cwork;
+ GRECT cwork;
browser_mouse_state bmstate = 0;
struct gui_window * gw = data;
@@ -223,8 +219,8 @@ static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * da
input_window = gw;
}
- window_set_focus( gw, BROWSER, (void*)gw->browser );
- browser_get_rect( gw, BR_CONTENT, &cwork );
+ window_set_focus(gw->root, BROWSER, (void*)gw->browser );
+ browser_get_rect(gw, BR_CONTENT, &cwork );
/* convert screen coords to component coords: */
mx = evnt.mx - cwork.g_x;
@@ -309,7 +305,7 @@ static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * da
*/
void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
{
- LGRECT work;
+ GRECT work;
int max_y_scroll;
int max_x_scroll;
int oldx = gw->browser->scroll.current.x;
@@ -399,7 +395,7 @@ void browser_scroll( struct gui_window * gw, short mode, int value, bool abs )
bwrect -> the dimensions of the browser, so that this function
doesn't need to get it.
*/
-static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
+static void browser_process_scroll( struct gui_window * gw, GRECT bwrect )
{
struct s_browser * b = gw->browser;
GRECT src;
@@ -486,11 +482,12 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
if( b->caret.requested.g_w > 0 ){
b->caret.redraw = true;
}
+
+ // TODO: implement new sliding
+ //gw->root->handle->xpos = b->scroll.current.x;
+ //gw->root->handle->ypos = b->scroll.current.y;
- gw->root->handle->xpos = b->scroll.current.x;
- gw->root->handle->ypos = b->scroll.current.y;
-
- mt_WindSlider( &app, gw->root->handle, HSLIDER|VSLIDER );
+ //mt_WindSlider( &app, gw->root->handle, HSLIDER|VSLIDER );
}
/*
@@ -502,7 +499,7 @@ static void browser_process_scroll( struct gui_window * gw, LGRECT bwrect )
*/
bool browser_input( struct gui_window * gw, unsigned short nkc )
{
- LGRECT work;
+ GRECT work;
bool r = false;
unsigned char ascii = (nkc & 0xFF);
long ucs4;
@@ -604,7 +601,7 @@ void browser_schedule_redraw(struct gui_window * gw, short x0, short y0, short x
{
assert( gw != NULL );
CMP_BROWSER b = gw->browser;
- LGRECT work;
+ GRECT work;
if( y1 < 0 || x1 < 0 )
return;
@@ -644,10 +641,10 @@ static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff,
/*
area: the browser canvas
*/
-void browser_restore_caret_background( struct gui_window * gw, LGRECT * area)
+void browser_restore_caret_background( struct gui_window * gw, GRECT * area)
{
CMP_BROWSER b = gw->browser;
- LGRECT rect;
+ GRECT rect;
if( area == NULL ){
browser_get_rect( gw, BR_CONTENT, &rect );
area = ▭
@@ -668,7 +665,7 @@ void browser_restore_caret_background( struct gui_window * gw, LGRECT * area)
/*
area: the browser canvas
*/
-void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
+void browser_redraw_caret( struct gui_window * gw, GRECT * area )
{
if( gw->browser->caret.redraw && gw->browser->caret.requested.g_w > 0 ){
@@ -677,12 +674,12 @@ void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
/* Only redraw caret when window is topped. */
wind_get( 0, WF_TOP, &wind_info[0], &wind_info[1], &wind_info[2], &wind_info[3]);
- if (gw->root->handle->handle != wind_info[0]) {
+ if (guiwin_get_handle(gw->root->win) != wind_info[0]) {
return;
}
- LGRECT caret;
+ GRECT caret;
struct s_browser * b = gw->browser;
struct rect old_clip;
struct rect clip;
@@ -695,7 +692,7 @@ void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
caret.g_x -= b->scroll.current.x - area->g_x;
caret.g_y -= b->scroll.current.y - area->g_y;
- if( !rc_lintersect( area, &caret ) ) {
+ if( !rc_intersect( area, &caret ) ) {
return;
}
@@ -745,7 +742,7 @@ void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
void browser_redraw( struct gui_window * gw )
{
- LGRECT bwrect;
+ GRECT bwrect;
struct s_browser * b = gw->browser;
short todo[4];
struct rect clip;
@@ -788,7 +785,7 @@ void browser_redraw( struct gui_window * gw )
wind_get( 0, WF_TOP, &wf_top[0], &wf_top[1],
&wf_top[2], &wf_top[3] );
- if( wf_top[0] == gw->root->handle->handle
+ if( wf_top[0] == guiwin_get_handle(gw->root->win)
&& wf_top[1] == _AESapid ){
/* The window is on top, so there is no need to walk the */
/* AES rectangle list. */
@@ -824,8 +821,9 @@ void browser_redraw( struct gui_window * gw )
}
}
} else {
- /* walk the AES rectangle list: */
- if( wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
+ /* walk the AES rectangle list: */
+ short aes_handle = guiwin_get_handle(gw->root->win);
+ if( wind_get(aes_handle, WF_FIRSTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
while (todo[2] && todo[3]) {
/* convert screen to framebuffer coords: */
@@ -862,7 +860,7 @@ void browser_redraw( struct gui_window * gw )
}
}
- if (wind_get(gw->root->handle->handle, WF_NEXTXYWH,
+ if (wind_get(aes_handle, WF_NEXTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3])==0) {
break;
}
@@ -894,7 +892,7 @@ void browser_redraw( struct gui_window * gw )
b->redraw.areas_used = 0;
}
if( b->caret.redraw == true && b->bw->current_content != NULL ) {
- LGRECT area;
+ GRECT area;
todo[0] = bwrect.g_x;
todo[1] = bwrect.g_y;
todo[2] = todo[0] + bwrect.g_w;
@@ -912,27 +910,18 @@ void browser_redraw( struct gui_window * gw )
/* TODO: if we use offscreen bitmap, trigger content redraw here */
}
-static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * data)
+static void __CDECL browser_evnt_redraw( COMPONENT * c, short buff[8], void * data)
{
struct gui_window * gw = (struct gui_window *) data;
CMP_BROWSER b = gw->browser;
- LGRECT work, lclip;
+ GRECT work, lclip;
browser_get_rect( gw, BR_CONTENT, &work );
lclip = work;
- if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) return;
-
- if( b->bw->current_content == NULL ){
- short pxy[4];
- pxy[0] = lclip.g_x;
- pxy[1] = lclip.g_y;
- pxy[2] = lclip.g_x + lclip.g_w - 1;
- pxy[3] = lclip.g_y + lclip.g_h - 1;
- vsf_color( gw->root->handle->graf->handle, WHITE );
- vsf_perimeter( gw->root->handle->graf->handle, 0);
- vsf_interior( gw->root->handle->graf->handle, FIS_SOLID );
- vsf_style( gw->root->handle->graf->handle, 1);
- v_bar( gw->root->handle->graf->handle, (short*)&pxy );
+ if ( !rc_intersect( (GRECT*)&buff[4], &lclip ) ) return;
+
+ if( b->bw->current_content == NULL ){
+ guiwin_clear(gw->root->win);
return;
}
@@ -953,13 +942,15 @@ static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * dat
if( lclip.g_h > 0 && lclip.g_w > 0 ) {
if( gw->browser->reformat_pending == true ){
- LGRECT newsize;
+ GRECT newsize;
gw->browser->reformat_pending = false;
browser_get_rect(gw, BR_CONTENT, &newsize);
/* this call will also schedule an redraw for the complete */
/* area. */
/* Resize must be handled here, because otherwise */
- /* a redraw is scheduled twice (1. by the frontend, 2. by AES) */
+ /* a redraw is scheduled twice (1. by the frontend, 2. by AES) */
+ // TODO: this was introduced because
+ // of bad knowledge about the AES system...
browser_window_reformat(b->bw, false, newsize.g_w, newsize.g_h );
} else {
browser_schedule_redraw( gw, lclip.g_x, lclip.g_y,
diff --git a/atari/browser.h b/atari/browser.h
index 3eb9437..e855e59 100755
--- a/atari/browser.h
+++ b/atari/browser.h
@@ -35,10 +35,9 @@
enum browser_rect
{
- BR_CONTENT = 1,
- BR_FULL = 2,
- BR_HSLIDER = 3,
- BR_VSLIDER = 4
+ BR_CONTENT = 1,
+ BR_URL_INPUT,
+ BR_THROBBER
};
@@ -60,8 +59,8 @@ struct s_scroll_info
*/
struct s_caret
{
- LGRECT requested;
- LGRECT current;
+ GRECT requested;
+ GRECT current;
bool redraw;
MFDB background;
};
@@ -89,17 +88,21 @@ struct s_browser
bool reformat_pending;
};
-struct s_browser * browser_create( struct gui_window * gw, struct browser_window * clone, struct browser_window *bw, int lt, int w, int flex );
+struct s_browser * browser_create( struct gui_window * gw,
+ struct browser_window * clone,
+ struct browser_window *bw, int lt, int w,
+ int flex );
bool browser_destroy( struct s_browser * b );
-void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT * out);
+void browser_get_rect( struct gui_window * gw, enum browser_rect type,
+ GRECT * out);
bool browser_input( struct gui_window * gw, unsigned short nkc ) ;
void browser_redraw( struct gui_window * gw );
void browser_set_content_size(struct gui_window * gw, int w, int h);
void browser_scroll( struct gui_window * gw, short MODE, int value, bool abs );
struct gui_window * browser_find_root( struct gui_window * gw );
bool browser_redraw_required( struct gui_window * gw);
-void browser_redraw_caret( struct gui_window * gw, LGRECT * area);
-void browser_restore_caret_background(struct gui_window * gw, LGRECT * area);
+void browser_redraw_caret( struct gui_window * gw, GRECT * area);
+void browser_restore_caret_background(struct gui_window * gw, GRECT * area);
/* update loc / size of the browser widgets: */
void browser_update_rects(struct gui_window * gw );
/*
diff --git a/atari/clipboard.h b/atari/clipboard.h
index e505d9f..aa032b7 100755
--- a/atari/clipboard.h
+++ b/atari/clipboard.h
@@ -17,9 +17,11 @@
*/
#ifndef NS_ATARI_CLIPBOARD_H
-#define NS_ATARI_CLIPBOARD_H
+#define NS_ATARI_CLIPBOARD_H
+
+#include <windom.h>
int scrap_txt_write( APPvar app, char *str);
char *scrap_txt_read( APPvar app );
-#endif
\ No newline at end of file
+#endif
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index 6239f21..66c4b7f 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -68,7 +68,7 @@ struct s_context_info ctxinfo;
static struct s_context_info * get_context_info( struct gui_window * gw, short mx, short my )
{
hlcache_handle *h;
- LGRECT bwrect;
+ GRECT bwrect;
struct contextual_content ccdata;
struct browser_window * bw = gw->browser->bw;
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index d486803..2502184 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -254,16 +254,15 @@ static void __CDECL menu_open_url(short item, short title, void *data)
if( gw == NULL ) {
bw = browser_window_create("", 0, 0, true, false);
gw = bw->window;
-
}
/* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
+ window_set_focus(gw->root, WIDGET_NONE, NULL );
/* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
+ window_set_focus(gw->root, URL_WIDGET, NULL);
/* delete selection: */
- tb_url_input( gw, NK_DEL );
+ toolbar_key_input(gw->root->toolbar, NK_DEL);
}
static void __CDECL menu_open_file(short item, short title, void *data)
@@ -273,7 +272,7 @@ static void __CDECL menu_open_file(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
- const char * filename = file_select( messages_get("OpenFile"), "" );
+ const char * filename = file_select(messages_get("OpenFile"), "");
if( filename != NULL ){
char * url = local_file_to_url( filename );
if( url ){
@@ -365,16 +364,18 @@ static void __CDECL menu_stop(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
- return;
- tb_stop_click( input_window );
+ return;
+
+ assert(input_window->root);
+ toolbar_stop_click(input_window->root->toolbar);
}
static void __CDECL menu_reload(short item, short title, void *data)
{
- if( input_window == NULL)
+ if(input_window == NULL)
return;
- tb_reload_click( input_window );
+ toolbar_reload_click(input_window->root->toolbar);
LOG(("%s", __FUNCTION__));
}
@@ -384,7 +385,8 @@ static void __CDECL menu_toolbars(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window != null && input_window->root->toolbar != null ){
state = !state;
- tb_hide( input_window, state );
+ // TODO: implement toolbar hide
+ //toolbar_hide(input_window->root->toolbar, state );
}
}
@@ -393,7 +395,8 @@ static void __CDECL menu_savewin(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if (input_window && input_window->browser) {
GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
+ wind_get_grect(guiwin_get_handle(input_window->root->win), WF_CURRXYWH,
+ &rect);
option_window_width = rect.g_w;
option_window_height = rect.g_h;
option_window_x = rect.g_x;
@@ -414,7 +417,7 @@ static void __CDECL menu_debug_render(short item, short title, void *data)
if( input_window != NULL ) {
if ( input_window->browser != NULL
&& input_window->browser->bw != NULL) {
- LGRECT rect;
+ GRECT rect;
browser_get_rect( input_window, BR_CONTENT, &rect );
browser_window_reformat(input_window->browser->bw, false,
rect.g_w, rect.g_h );
@@ -443,7 +446,7 @@ static void __CDECL menu_back(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
- tb_back_click( input_window );
+ toolbar_back_click(input_window->root->toolbar);
}
static void __CDECL menu_forward(short item, short title, void *data)
@@ -451,7 +454,7 @@ static void __CDECL menu_forward(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
- tb_forward_click( input_window );
+ toolbar_forward_click(input_window->root->toolbar);
}
static void __CDECL menu_home(short item, short title, void *data)
@@ -459,7 +462,7 @@ static void __CDECL menu_home(short item, short title, void *data)
LOG(("%s", __FUNCTION__));
if( input_window == NULL )
return;
- tb_home_click( input_window );
+ toolbar_home_click(input_window->root->toolbar);
}
static void __CDECL menu_lhistory(short item, short title, void *data)
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index 6c590b5..ddcad78 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -60,9 +60,11 @@ short msg_box_show(short type, const char * msg);
#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
-#define GW_FLAG_CUSTOM_SCROLLING 0x10 // no internal scroller handling
+#define GW_FLAG_TOOLBAR_REDRAW 0x10 // enable internal toolbar redraw
+#define GW_FLAG_CUSTOM_SCROLLING 0x20 // no internal scroller handling
-#define GW_FLAG_DEFAULTS (GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM)
+#define GW_FLAG_DEFAULTS (GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM \
+ | GW_FLAG_TOOLBAR_REDRAW)
#define GW_STATUS_ICONIFIED 0x01
#define GW_STATUS_SHADED 0x02
@@ -112,7 +114,8 @@ bool guiwin_update_slider(GUIWIN *win, short mode);
void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
bool guiwin_has_intersection(GUIWIN *win, GRECT *work);
-void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip);
+void guiwin_toolbar_redraw(GUIWIN *win, GRECT *clip);
+void guiwin_clear(GUIWIN *win);
/*
@@ -124,6 +127,14 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip);
&& (_y >= r.g_y) && (_y <= r.g_y + r.g_h))
#endif
+#ifndef RC_WITHIN
+#define RC_WITHIN(a,b) \
+ (((a)->g_x >= (b)->g_x) \
+ && (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \
+ && (((a)->g_y >= (b)->g_y) \
+ && (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h)))
+#endif
+
#ifndef MAX
#define MAX(_a,_b) ((_a>_b) ? _a : _b)
#endif
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index cf47c46..7f06c91 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -5,6 +5,8 @@
#include <assert.h>
#include <cflib.h>
+
+#include <gem.h>
#include <mt_gem.h>
#include "gemtk.h"
@@ -27,13 +29,15 @@ static GUIWIN * winlist;
static VdiHdl v_vdi_h = -1;
static short work_out[57];
-static void move_rect(GRECT *rect, int dx, int dy)
+static void move_rect(GUIWIN * win, GRECT *rect, int dx, int dy)
{
INT16 xy[ 8];
long dum = 0L;
GRECT g;
- while( !wind_update(BEG_UPDATE));
+ VdiHdl vh = guiwin_get_vdi_handle(win);
+
+ while(!wind_update(BEG_UPDATE));
graf_mouse(M_OFF, 0L);
/* get intersection with screen area */
@@ -47,7 +51,7 @@ static void move_rect(GRECT *rect, int dx, int dy)
xy[5] = xy[1] + dy;
xy[6] = xy[2] + dx;
xy[7] = xy[3] + dy;
- vro_cpyfm(v_vdi_h, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
+ vro_cpyfm(vh, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
graf_mouse(M_ON, 0L);
wind_update(END_UPDATE);
@@ -81,7 +85,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
if(pix < 0 ) {
// blit screen area:
g.g_h -= abs_pix;
- move_rect(&g, 0, abs_pix);
+ move_rect(gw, &g, 0, abs_pix);
g.g_y = g_ro.g_y;
g.g_h = abs_pix;
redraw = &g;
@@ -89,7 +93,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
// blit screen area:
g.g_y += abs_pix;
g.g_h -= abs_pix;
- move_rect(&g, 0, -abs_pix);
+ move_rect(gw, &g, 0, -abs_pix);
g.g_y = g_ro.g_y + g_ro.g_h - abs_pix;
g.g_h = abs_pix;
redraw = &g;
@@ -112,7 +116,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
if(pix < 0 ) {
// blit screen area:
g.g_w -= abs_pix;
- move_rect(&g, abs_pix, 0);
+ move_rect(gw, &g, abs_pix, 0);
g.g_x = g_ro.g_x;
g.g_w = abs_pix;
redraw = &g;
@@ -120,7 +124,7 @@ static void preproc_scroll(GUIWIN *gw, short orientation, int units,
// blit screen area:
g.g_x += abs_pix;
g.g_w -= abs_pix;
- move_rect(&g, -abs_pix, 0);
+ move_rect(gw, &g, -abs_pix, 0);
g.g_x = g_ro.g_x + g_ro.g_w - abs_pix;
g.g_w = abs_pix;
redraw = &g;
@@ -292,7 +296,8 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_REDRAW:
- if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
+ if ((gw->flags & GW_FLAG_TOOLBAR_REDRAW)
+ && (gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
g.g_x = msg[4];
g.g_y = msg[5];
g.g_w = msg[6];
@@ -375,8 +380,8 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
// toolbar handling:
- if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 &&
- dest->toolbar != NULL) {
+ if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0
+ && dest->toolbar != NULL) {
GRECT tb_area;
guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
if (POINT_WITHIN(ev_out->emo_mouse.p_x,
@@ -394,10 +399,12 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
if (((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0)
&& obj_idx > 0) {
dest->toolbar[obj_idx].ob_state |= OS_SELECTED;
+ // TODO: optimize redraw by setting the object clip:
guiwin_toolbar_redraw(dest, NULL);
}
short oldevents = ev_out->emo_events;
ev_out->emo_events = MU_MESAG;
+ // notify the window about toolbar click:
dest->handler_func(dest, ev_out, msg_out);
handler_called=true;
ev_out->emo_events = oldevents;
@@ -590,6 +597,11 @@ short guiwin_get_handle(GUIWIN *win)
return(win->handle);
}
+VdiHdl guiwin_get_vdi_handle(GUIWIN *win)
+{
+ return(v_vdi_h);
+}
+
uint32_t guiwin_get_state(GUIWIN *win)
{
return(win->state);
@@ -649,13 +661,6 @@ void guiwin_send_redraw(GUIWIN *win, GRECT *area)
bool guiwin_has_intersection(GUIWIN *win, GRECT *work)
{
-
-#define RC_WITHIN(a,b) \
- (((a)->g_x >= (b)->g_x) \
- && (((a)->g_x + (a)->g_w) <= ((b)->g_x + (b)->g_w))) \
- && (((a)->g_y >= (b)->g_y) \
- && (((a)->g_y + (a)->g_h) <= ((b)->g_y + (b)->g_h)))
-
GRECT area, mywork;
bool retval = true;
@@ -674,9 +679,6 @@ bool guiwin_has_intersection(GUIWIN *win, GRECT *work)
}
return(retval);
-
-#undef RC_WITHIN
-
}
void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
@@ -684,9 +686,6 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
GRECT tb_area, tb_area_ro, g;
guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
- if(tb_area_ro.g_h <= 0 || tb_area_ro.g_w <= 0) {
- return;
- }
if(clip == NULL) {
clip = &tb_area_ro;
@@ -695,6 +694,7 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
tb_area = tb_area_ro;
if(rc_intersect(clip, &tb_area)) {
+
// Update object position:
gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
@@ -712,11 +712,37 @@ void guiwin_toolbar_redraw(GUIWIN *gw, GRECT *clip)
}
}
}
-/*
-void guiwin_exec_redraw(){
+void guiwin_clear(GUIWIN *win)
+{
+ GRECT area, g;
+ short pxy[4];
+ VdiHdl vh;
+
+ vh = guiwin_get_vdi_handle(win);
+
+ if(win->state & GW_STATUS_ICONIFIED){
+ // also clear the toolbar area when iconified:
+ guiwin_get_grect(win, GUIWIN_AREA_WORK, &area);
+ } else {
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &area);
+ }
+
+ vsf_interior(vh, FIS_SOLID);
+ vsf_color(vh, 0);
+ vswr_mode(vh, MD_REPLACE);
+ wind_get_grect(win->handle, WF_FIRSTXYWH, &g);
+ while (g.g_h > 0 || g.g_w > 0) {
+ if(rc_intersect(&area, &g)) {
+ pxy[0] = g.g_x;
+ pxy[1] = g.g_y;
+ pxy[2] = g.g_x+g.g_w-1;
+ pxy[3] = g.g_y+g.g_h-1;
+ v_bar(vh, pxy);
+ }
+ wind_get_grect(win->handle, WF_NEXTXYWH, &g);
+ }
}
-*/
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index 40b8859..dfee0dd 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -65,7 +65,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
static short prev_x=0;
static short prev_y=0;
bool within = false;
- LGRECT urlbox, bwbox, sbbox;
+ GRECT urlbox, bwbox, sbbox;
int nx, ny;
if (gw == NULL)
@@ -76,15 +76,13 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if (input_window->root->handle->handle == ghandle) {
+ if (guiwin_get_handle(input_window->root->win)==ghandle) {
// The window found at x,y is an gui_window
// and it's the input window.
- browser_get_rect( gw, BR_CONTENT, &bwbox );
-
- if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
+ browser_get_rect(gw, BR_CONTENT, &bwbox);
+ if (POINT_WITHIN(evnt.mx, evnt.my, bwbox)) {
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -95,9 +93,8 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
}
if (gw->root->toolbar && within == false) {
- mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
- if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
- (evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
+ browser_get_rect(gw, BR_URL_INPUT, &urlbox);
+ if(POINT_WITHIN(evnt.mx, evnt.my, urlbox)) {
gem_set_cursor( &gem_cursors.ibeam );
prev_url = true;
} else {
@@ -116,7 +113,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
prev_y = evnt.my;
}
-void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
+void __CDECL global_evnt_keybd(WINDOW * win, short buff[8], void * data)
{
long kstate = 0;
long kcode = 0;
@@ -134,18 +131,19 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
nkc= gem_to_norm( (short)kstate, (short)kcode );
nks = (nkc & 0xFF00);
if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
- if( window_url_widget_has_focus( gw ) ) {
+ kstate |= K_LSHIFT|K_RSHIFT;
+
+ if(window_url_widget_has_focus((void*)gw->root)) {
/* make sure we report for the root window and report...: */
- done = tb_url_input( gw, nkc );
+ done = toolbar_key_input(gw->root->toolbar, nkc);
} else {
gw_tmp = window_list;
/* search for active browser component: */
while( gw_tmp != NULL && done == false ) {
/* todo: only handle when input_window == ontop */
- if( window_widget_has_focus( (struct gui_window *)input_window,
- BROWSER,(void*)gw_tmp->browser)) {
- done = browser_input( gw_tmp, nkc );
+ if( window_widget_has_focus(input_window->root, BROWSER,
+ (void*)gw_tmp->browser)) {
+ done = browser_input(gw_tmp, nkc);
break;
} else {
gw_tmp = gw_tmp->next;
diff --git a/atari/gui.c b/atari/gui.c
index 889e4f2..0d85eef 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -116,47 +116,6 @@ EVMULT_IN aes_event_in = {
EVMULT_OUT aes_event_out;
short aes_msg_out[8];
-
-void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
-{
- long kstate = 0;
- long kcode = 0;
- unsigned short nkc = 0;
- unsigned short nks = 0;
-
- int i=0;
- bool done = false;
- struct gui_window * gw = input_window;
- struct gui_window * gw_tmp;
- if( gw == NULL )
- return;
- kstate = evnt.mkstate;
- kcode = evnt.keybd;
- nkc= gem_to_norm( (short)kstate, (short)kcode);
- nks = (nkc & 0xFF00);
- if( kstate & (K_LSHIFT|K_RSHIFT))
- kstate |= K_LSHIFT|K_RSHIFT;
- if( window_url_widget_has_focus( gw ) ) {
- /* make sure we report for the root window and report...: */
- done = tb_url_input( gw, nkc );
- } else {
- gw_tmp = window_list;
- /* search for active browser component: */
- while( gw_tmp != NULL && done == false ) {
- /* todo: only handle when input_window == ontop */
- if( window_widget_has_focus( (struct gui_window *)input_window,
- BROWSER,(void*)gw_tmp->browser)) {
- done = browser_input( gw_tmp, nkc );
- break;
- } else {
- gw_tmp = gw_tmp->next;
- }
- }
- }
- if(!done)
- deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
-}
-
void gui_poll(bool active)
{
int flags = MU_MESAG | MU_KEYBD | MU_BUTTON;
@@ -167,11 +126,30 @@ void gui_poll(bool active)
aes_event_in.emi_tlow = schedule_run();
- //printf("time: ");
-
if(active || rendering)
aes_event_in.emi_tlow = 0;
+ struct gui_window * g;
+
+ for( g = window_list; g != NULL; g=g->next ) {
+ if( browser_redraw_required( g ) ) {
+ browser_redraw(g);
+ }
+ if(g->root->toolbar) {
+ //if(g->root->toolbar->url.redraw ) {
+ // TODO: implement toolbar redraw mechanism
+ //tb_url_redraw( g );
+ //}
+ }
+ }
+
+ if( !active ) {
+ /* this suits for stuff with lower priority */
+ /* TBD: really be spare on redraws??? */
+ hotlist_redraw();
+ global_history_redraw();
+ }
+
// Handle events until there are no more messages pending or
// until the engine indicates activity:
do {
@@ -201,66 +179,8 @@ void gui_poll(bool active)
}
} while ( gui_poll_repeat && !(active||rendering));
- if( !active ) {
- /* this suits for stuff with lower priority */
- /* TBD: really be spare on redraws??? */
- hotlist_redraw();
- global_history_redraw();
- }
}
-void gui_poll_old(bool active)
-{
- short winloc[4];
- // int timeout; /* timeout in milliseconds */
- int flags = MU_MESAG | MU_KEYBD | MU_BUTTON ;
- short mx, my, dummy;
-
- evnt.timer = schedule_run();
-
- if( active || rendering ) {
- if( clock() >= next_poll ) {
- evnt.timer = 0;
- flags |= MU_TIMER;
- EvntWindom( flags );
- next_poll = clock() + (CLOCKS_PER_SEC>>3);
- }
- } else {
- if (input_window != NULL) {
- wind_get( 0, WF_TOP, &winloc[0], &winloc[1], &winloc[2], &winloc[3]);
- if (winloc[1] == _AESapid) {
- /* only check for mouse move when netsurf is on top: */
- // move that into m1 event handler
- graf_mkstate( &mx, &my, &dummy, &dummy );
- flags |= MU_M1;
- evnt.m1_flag = MO_LEAVE;
- evnt.m1_w = evnt.m1_h = 1;
- evnt.m1_x = mx;
- evnt.m1_y = my;
- }
- }
- flags |= MU_TIMER;
- EvntWindom( flags );
- }
-
- struct gui_window * g;
- for( g = window_list; g != NULL; g=g->next ) {
- if( browser_redraw_required( g ) ) {
- browser_redraw( g );
- }
- if( g->root->toolbar ) {
- if(g->root->toolbar->url.redraw ) {
- tb_url_redraw( g );
- }
- }
- }
- if( evnt.timer != 0 && !active ) {
- /* this suits for stuff with lower priority */
- /* TBD: really be spare on redraws??? */
- hotlist_redraw();
- global_history_redraw();
- }
-}
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
@@ -271,22 +191,24 @@ gui_create_browser_window(struct browser_window *bw,
(int)new_tab
));
- gw = malloc( sizeof(struct gui_window) );
+ gw = calloc( sizeof(struct gui_window), 1);
if (gw == NULL)
return NULL;
- memset( gw, 0, sizeof(struct gui_window) );
LOG(("new window: %p, bw: %p\n", gw, bw));
- window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
- if( gw->root->handle ) {
+ window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\
+ |WIDGET_SCROLL);
+ if (gw->root->win) {
GRECT pos = {
option_window_x, option_window_y,
option_window_width, option_window_height
};
- window_open( gw , pos );
+ gui_window_set_url(gw, "");
+ gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT);
+ window_set_active_gui_window(gw->root, gw);
+ window_open(gw->root, pos );
/* Recalculate windows browser area now */
- browser_update_rects( gw );
- tb_update_buttons( gw, -1 );
+ toolbar_update_buttons(gw->root->toolbar, gw->browser->bw, -1);
input_window = gw;
/* TODO:... this line: placeholder to create a local history widget ... */
}
@@ -319,7 +241,11 @@ void gui_window_destroy(struct gui_window *w)
input_window = NULL;
- window_destroy(w);
+ search_destroy(w);
+ browser_destroy(w->browser);
+ free(w->status);
+ free(w->title);
+ free(w->url);
/* unlink the window: */
if(w->prev != NULL ) {
@@ -330,16 +256,21 @@ void gui_window_destroy(struct gui_window *w)
if( w->next != NULL ) {
w->next->prev = w->prev;
}
+
+ window_unref_gui_window(w->root, w);
+
free(w);
w = NULL;
- w = window_list;
- while( w != NULL ) {
- if( w->root ) {
- input_window = w;
- break;
+ if(input_window == NULL){
+ w = window_list;
+ while( w != NULL ) {
+ if(w->root) {
+ input_window = w;
+ break;
+ }
+ w = w->next;
}
- w = w->next;
}
}
@@ -348,7 +279,7 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
{
if (w == NULL)
return;
- LGRECT rect;
+ GRECT rect;
browser_get_rect( w, BR_CONTENT, &rect );
*width = rect.g_w;
*height = rect.g_h;
@@ -356,21 +287,34 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
void gui_window_set_title(struct gui_window *gw, const char *title)
{
- int l;
- char * conv;
if (gw == NULL)
return;
- if( gw->root ) {
- l = strlen(title);
- if( utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ) {
- strncpy(gw->root->title, conv, atari_sysinfo.aes_max_win_title_len);
+
+ if (gw->root) {
+
+ int l;
+ char * conv;
+ l = strlen(title)+1;
+ if (utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ) {
+ l = MIN((uint32_t)atari_sysinfo.aes_max_win_title_len, strlen(conv));
+ if(gw->title == NULL)
+ gw->title = malloc(l);
+ else
+ gw->title = realloc(gw->title, l);
+
+ strncpy(gw->title, conv, l);
free( conv );
} else {
- strncpy(gw->root->title, title, atari_sysinfo.aes_max_win_title_len);
+ l = MIN((size_t)atari_sysinfo.aes_max_win_title_len, strlen(title));
+ if(gw->title == NULL)
+ gw->title = malloc(l);
+ else
+ gw->title = realloc(gw->title, l);
+ strncpy(gw->title, title, l);
}
- gw->root->title[atari_sysinfo.aes_max_win_title_len] = 0;
- WindSetStr( gw->root->handle, WF_NAME, gw->root->title );
+ if(input_window == gw)
+ window_set_title(gw->root, gw->title);
}
}
@@ -379,20 +323,34 @@ void gui_window_set_title(struct gui_window *gw, const char *title)
*/
void gui_window_set_status(struct gui_window *w, const char *text)
{
- if (w == NULL || text == NULL )
+ int l;
+ if (w == NULL || text == NULL)
return;
- window_set_stauts(w, (char*)text );
+
+ assert(w->root);
+
+ l = strlen(text)+1;
+ if(w->status == NULL)
+ w->status = malloc(l);
+ else
+ w->status = realloc(w->status, l);
+
+ strncpy(w->status, text, l);
+ w->status[l-1] = 0;
+
+ if(input_window == w)
+ window_set_stauts(w->root, (char*)text);
}
void gui_window_redraw_window(struct gui_window *gw)
{
CMP_BROWSER b;
- LGRECT rect;
+ GRECT rect;
if (gw == NULL)
return;
b = gw->browser;
- browser_get_rect( gw, BR_CONTENT, &rect );
- browser_schedule_redraw( gw, 0, 0, rect.g_w, rect.g_h );
+ browser_get_rect(gw, BR_CONTENT, &rect);
+ browser_schedule_redraw(gw, 0, 0, rect.g_w, rect.g_h );
}
void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
@@ -479,75 +437,80 @@ void gui_clear_selection(struct gui_window *g)
/**
* set the pointer shape
*/
-void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
+void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape)
{
- if (w == NULL)
+ if (gw == NULL)
return;
+
switch (shape) {
case GUI_POINTER_POINT: /* link */
- gem_set_cursor(&gem_cursors.hand);
+ gw->cursor = &gem_cursors.hand;
break;
case GUI_POINTER_MENU:
- gem_set_cursor(&gem_cursors.menu);
+ gw->cursor = &gem_cursors.menu;
break;
case GUI_POINTER_CARET: /* input */
- gem_set_cursor(&gem_cursors.ibeam);
+ gw->cursor = &gem_cursors.ibeam;
break;
case GUI_POINTER_CROSS:
- gem_set_cursor(&gem_cursors.cross);
+ gw->cursor = &gem_cursors.cross;
break;
case GUI_POINTER_MOVE:
- gem_set_cursor(&gem_cursors.sizeall);
+ gw->cursor = &gem_cursors.sizeall;
break;
case GUI_POINTER_RIGHT:
case GUI_POINTER_LEFT:
- gem_set_cursor(&gem_cursors.sizewe);
+ gw->cursor = &gem_cursors.sizewe;
break;
case GUI_POINTER_UP:
case GUI_POINTER_DOWN:
- gem_set_cursor(&gem_cursors.sizens);
+ gw->cursor = &gem_cursors.sizens;
break;
case GUI_POINTER_RU:
case GUI_POINTER_LD:
- gem_set_cursor(&gem_cursors.sizenesw);
+ gw->cursor = &gem_cursors.sizenesw;
break;
case GUI_POINTER_RD:
case GUI_POINTER_LU:
- gem_set_cursor(&gem_cursors.sizenwse);
+ gw->cursor = &gem_cursors.sizenwse;
break;
case GUI_POINTER_WAIT:
- gem_set_cursor(&gem_cursors.wait);
+ gw->cursor = &gem_cursors.wait;
break;
case GUI_POINTER_PROGRESS:
- gem_set_cursor(&gem_cursors.appstarting);
+ gw->cursor = &gem_cursors.appstarting;
break;
case GUI_POINTER_NO_DROP:
- gem_set_cursor(&gem_cursors.nodrop);
+ gw->cursor = &gem_cursors.nodrop;
break;
case GUI_POINTER_NOT_ALLOWED:
- gem_set_cursor(&gem_cursors.deny);
+ gw->cursor = &gem_cursors.deny;
break;
case GUI_POINTER_HELP:
- gem_set_cursor(&gem_cursors.help);
+ gw->cursor = &gem_cursors.help;
break;
default:
- gem_set_cursor(&gem_cursors.arrow);
+ gw->cursor = &gem_cursors.arrow;
break;
}
+
+ if (input_window == gw) {
+ gem_set_cursor(gw->cursor);
+ }
}
void gui_window_hide_pointer(struct gui_window *w)
@@ -558,9 +521,23 @@ void gui_window_hide_pointer(struct gui_window *w)
void gui_window_set_url(struct gui_window *w, const char *url)
{
+ int l;
+
if (w == NULL)
return;
- tb_url_set(w, (char*)url );
+
+ l = strlen(url)+1;
+
+ if (w->url == NULL) {
+ w->url = malloc(l);
+ } else {
+ w->url = realloc(w->url, l);
+ }
+ strncpy(w->url, url, l);
+
+ if(input_window == w->root->active_gui_window){
+ toolbar_set_url(w->root->toolbar, url);
+ }
}
static void throbber_advance( void * data )
@@ -571,32 +548,33 @@ static void throbber_advance( void * data )
return;
if( gw->root->toolbar == NULL )
return;
- if( gw->root->toolbar->throbber.running == false )
- return;
- mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- gw->root->toolbar->throbber.index++;
- if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
- gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
+ // TODO: implement access to throbber
+ //if( gw->root->toolbar->throbber.running == false)
+ // return;
+// mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
+// WF_WORKXYWH, &work);
+// gw->root->toolbar->throbber.index++;
+// if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
+// gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
+// ApplWrite(_AESapid, WM_REDRAW, guiwin_get_handle(gw->root->win),
+// work.g_x, work.g_y, work.g_w, work.g_h);
schedule(100, throbber_advance, gw );
}
void gui_window_start_throbber(struct gui_window *w)
{
- LGRECT work;
+ GRECT work;
if (w == NULL)
return;
- if( w->root->toolbar->throbber.running == true )
- return;
- mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- w->root->toolbar->throbber.running = true;
- w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
+ // TODO: implement throbber acess
+ //if( w->root->toolbar->throbber.running == true )
+ // return;
+// browser_get_rect(w, BR_THROBBER, &work);
+// w->root->toolbar->throbber.running = true;
+// w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
schedule(100, throbber_advance, w );
- ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
+// ApplWrite( _AESapid, WM_REDRAW, guiwin_get_handle(w->root->win),
+// work.g_x, work.g_y, work.g_w, work.g_h );
rendering = true;
}
@@ -606,20 +584,22 @@ void gui_window_stop_throbber(struct gui_window *w)
LGRECT work;
if (w == NULL)
return;
- if( w->root->toolbar->throbber.running == false )
- return;
+ // TODO: implement something like throbber_is_running();
+ //if( w->root->toolbar->throbber.running == false )
+ // return;
schedule_remove(throbber_advance, w);
/* refresh toolbar buttons: */
- tb_update_buttons( w, -1 );
+ toolbar_update_buttons(w->root->toolbar, w->browser->bw, -1);
/* redraw throbber: */
- mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
- WF_WORKXYWH, &work);
- w->root->toolbar->throbber.running = false;
- ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
+// mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
+// WF_WORKXYWH, &work);
+// w->root->toolbar->throbber.running = false;
+// ApplWrite( _AESapid, WM_REDRAW, guiwin_get_handle(w->root->win),
+// work.g_x, work.g_y, work.g_w, work.g_h );
+ // TODO: send throbber redraw
rendering = false;
}
@@ -663,8 +643,11 @@ gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
struct bitmap *bmp_icon;
bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
+ g->icon = bmp_icon;
- window_set_icon(g, bmp_icon);
+ if(input_window == g){
+ window_set_icon(g->root, bmp_icon);
+ }
}
void
diff --git a/atari/gui.h b/atari/gui.h
index 76de07f..c2f6b44 100755
--- a/atari/gui.h
+++ b/atari/gui.h
@@ -19,7 +19,7 @@
#ifndef NS_ATARI_GUI_H_
#define NS_ATARI_GUI_H_
-#include <windom.h>
+#include "atari/gemtk/gemtk.h"
struct point_s {
int x;
@@ -96,17 +96,18 @@ typedef struct s_browser * CMP_BROWSER;
*/
struct s_gui_win_root
{
- WINDOW * handle;
+ GUIWIN *win;
CMP_TOOLBAR toolbar;
CMP_STATUSBAR statusbar;
- COMPONENT * cmproot;
- MFORM_EX cursor;
struct s_focus_info focus;
float scale;
char * title;
+ struct bitmap * icon;
+ struct gui_window *active_gui_window;
/* current size of window on screen: */
GRECT loc;
};
+typedef struct s_gui_win_root ROOTWIN;
/*
This is the part of the gui which is known by netsurf core.
@@ -117,7 +118,11 @@ struct s_gui_win_root
struct gui_window {
struct s_gui_win_root * root;
CMP_BROWSER browser;
+ MFORM_EX *cursor;
/* icon to be drawn when iconified, or NULL for default resource. */
+ char * status;
+ char * title;
+ char * url;
struct bitmap * icon;
struct gui_window *next, *prev;
};
diff --git a/atari/misc.c b/atari/misc.c
index 575e964..22f820e 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -121,8 +121,8 @@ struct gui_window * find_guiwin_by_aes_handle(short handle){
}
while(gw != NULL) {
- if( gw->root->handle != NULL
- && gw->root->handle->handle == handle ) {
+ if( gw->root->win != NULL
+ && guiwin_get_handle(gw->root->win) == handle ) {
return(gw);
}
else
@@ -133,21 +133,6 @@ struct gui_window * find_guiwin_by_aes_handle(short handle){
}
-struct gui_window * find_cmp_window( COMPONENT * c )
-{
- struct gui_window * gw;
- gw = window_list;
- while( gw != NULL ) {
- assert( gw->browser != NULL );
- if( gw->browser->comp == c ) {
- return( gw );
- }
- else
- gw = gw->next;
- }
- return( NULL );
-}
-
static int scan_process_list(scan_process_callback cb, void *data)
{
int pid, count = 0;
diff --git a/atari/misc.h b/atari/misc.h
index 5359d72..cab2a8c 100755
--- a/atari/misc.h
+++ b/atari/misc.h
@@ -19,6 +19,7 @@
#ifndef NS_ATARI_MISC_H
#define NS_ATARI_MISC_H
+#include <windom.h>
#include "cflib.h"
#include "content/content.h"
#include "content/hlcache.h"
@@ -43,7 +44,6 @@
typedef int (*scan_process_callback)(int pid, void *data);
struct gui_window * find_guiwin_by_aes_handle(short handle);
-struct gui_window * find_cmp_window( COMPONENT * c );
bool is_process_running(const char * name);
void gem_set_cursor( MFORM_EX * cursor );
hlcache_handle *load_icon( const char *name, hlcache_handle_callback cb,
diff --git a/atari/res/netsurf.rsc b/atari/res/netsurf.rsc
index 5a9327f..803cb2b 100755
Binary files a/atari/res/netsurf.rsc and b/atari/res/netsurf.rsc differ
diff --git a/atari/res/netsurf.rsh b/atari/res/netsurf.rsh
index b0c800d..8245526 100755
--- a/atari/res/netsurf.rsh
+++ b/atari/res/netsurf.rsh
@@ -41,11 +41,14 @@
#define MAINMENU_M_HELP_CONTENT 61 /* STRING in tree MAINMENU */
#define TOOLBAR 1 /* form/dial */
+#define TOOLBAR_NAVIGATION_AREA 1 /* BOX in tree TOOLBAR */
#define TOOLBAR_BT_BACK 2 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_HOME 3 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_FORWARD 4 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_STOP 5 /* CICON in tree TOOLBAR */
#define TOOLBAR_BT_RELOAD 6 /* CICON in tree TOOLBAR */
+#define TOOLBAR_URL_AREA 7 /* BOX in tree TOOLBAR */
+#define TOOLBAR_THROBBER_AREA 8 /* BOX in tree TOOLBAR */
#define ICONIFY 2 /* form/dial */
#define ICONIFY_GLOBE 1 /* CICON in tree ICONIFY */
diff --git a/atari/res/netsurf.rsm b/atari/res/netsurf.rsm
index ade2b1c..587fefa 100755
--- a/atari/res/netsurf.rsm
+++ b/atari/res/netsurf.rsm
@@ -3,7 +3,7 @@ ResourceMaster v3.65
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
-#M 20010100@0@7728@610@
+#M 20010100@0@7728@618@
#T 0@1@MAINMENU@@62@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@@ -43,12 +43,15 @@ ResourceMaster v3.65
#O 58@28@M_CHOICES@@
#O 59@28@M_VLOG@@
#O 61@28@M_HELP_CONTENT@@
-#T 1@2@TOOLBAR@@7@@
+#T 1@2@TOOLBAR@@9@@
+#O 1@20@NAVIGATION_AREA@@
#O 2@33@BT_BACK@@
#O 3@33@BT_HOME@@
#O 4@33@BT_FORWARD@@
#O 5@33@BT_STOP@@
#O 6@33@BT_RELOAD@@
+#O 7@20@URL_AREA@@
+#O 8@20@THROBBER_AREA@@
#T 2@2@ICONIFY@@3@@
#O 1@33@GLOBE@@
#T 3@2@FAVICON@@2@@
@@ -195,4 +198,4 @@ ResourceMaster v3.65
#O 5@33@BT_DOWN_PIC@@
#O 6@25@BT_UP@@
#O 4@33@BT_UP_PIC@@
-#c 2361@
+#c 770@
diff --git a/atari/rootwin.c b/atari/rootwin.c
index aff910c..68f1bc0 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -61,23 +61,19 @@
extern struct gui_window *input_window;
+struct rootwin_data_s {
+ struct s_gui_win_root *rootwin;
+};
+
/* -------------------------------------------------------------------------- */
-/* Static module methods follow here: */
+/* Static module methods: */
/* -------------------------------------------------------------------------- */
-//static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void *data );
-//static void __CDECL evnt_window_newtop( WINDOW *win, short buff[8], void *data );
-//void __CDECL evnt_window_resize( WINDOW *win, short buff[8], void * data );
-//static void __CDECL evnt_window_rt_resize( WINDOW *win, short buff[8], void * date );
static void redraw(GUIWIN *win, short msg[8]);
static void resized(GUIWIN *win);
static void file_dropped(GUIWIN *win, short msg[8]);
-//static void __CDECL evnt_window_close( WINDOW *win, short buff[8], void *data );
-//static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data ) ;
-static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data );
+
static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
-//static void __CDECL evnt_window_uniconify( WINDOW *win, short buff[8], void * data );
-//static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data );
#define FIND_NS_GUI_WINDOW(w) \
find_guiwin_by_aes_handle(guiwin_get_handle(w));
@@ -90,6 +86,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
struct gui_window * gw;
+ struct rootwin_data_s * data = guiwin_get_user_data(win);
+
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
// handle message
printf("root win msg: %d\n", msg[0]);
@@ -107,8 +105,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_ICONIFY:
- gw = FIND_NS_GUI_WINDOW(win);
- if( input_window == gw) {
+ data = guiwin_get_user_data(win);
+ if( input_window->root == data->rootwin) {
input_window = NULL;
}
break;
@@ -116,13 +114,17 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
case WM_TOPPED:
case WM_NEWTOP:
case WM_UNICONIFY:
- input_window = FIND_NS_GUI_WINDOW(win);
+ data = guiwin_get_user_data(win);
+ input_window = data->rootwin->active_gui_window;
break;
case WM_CLOSED:
- gw = FIND_NS_GUI_WINDOW(win);
+ // TODO: this needs to iterate through all gui windows and
+ // check if the rootwin is this window...
+ data = guiwin_get_user_data(win);
+ gw = data->rootwin->active_gui_window;
if( gw != NULL ) {
- browser_window_destroy(gw->browser->bw );
+ browser_window_destroy(gw->browser->bw);
}
break;
@@ -185,176 +187,177 @@ int window_create(struct gui_window * gw,
return( -1 );
memset( gw->root, 0, sizeof(struct s_gui_win_root) );
gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
- gw->root->handle = WindCreate(flags, 40, 40, app.w, app.h);
- if( gw->root->handle == NULL ) {
+ // TODO: use desk size
+ short aes_handle = wind_create(flags, 40, 40, app.w, app.h);
+ if(aes_handle<0) {
free( gw->root->title );
free( gw->root );
return( -1 );
}
-
- /* set scroll / content granularity ( 1 unit ) */
- gw->root->handle->w_u = 1;
- gw->root->handle->h_u = 1;
-
- /* Create Root component: */
- gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
- WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
+ gw->root->win = guiwin_add(aes_handle,
+ GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
/* create toolbar component: */
if( tb ) {
- gw->root->toolbar = tb_create( gw );
- assert( gw->root->toolbar );
- mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp );
-
+ gw->root->toolbar = toolbar_create(gw->root);
+ assert(gw->root->toolbar);
} else {
gw->root->toolbar = NULL;
}
/* create browser component: */
gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
- mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
/* create statusbar component: */
if( sb ) {
gw->root->statusbar = sb_create( gw );
-#ifdef WITH_COMOPONENT_STATUSBAR
- mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
-#endif
} else {
gw->root->statusbar = NULL;
}
- WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf");
-
- /* Event Handlers: */
-// EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
- /* capture resize/move events so we can handle that manually */
-// EvntDataAdd( gw->root->handle, WM_SIZED, evnt_window_rt_resize, gw, EV_BOT );
-// EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
-// EvntDataAdd( gw->root->handle, WM_FULLED, evnt_window_rt_resize, gw, EV_BOT );
- EvntDataAdd(gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP );
- EvntDataAdd(gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP );
-// EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
-// EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
-// EvntDataAdd( gw->root->handle, WM_ICONIFY, evnt_window_iconify, gw, EV_BOT);
-// EvntDataAdd( gw->root->handle, WM_UNICONIFY, evnt_window_uniconify, gw, EV_BOT);
-// EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw );
-// EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
- EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw );
+ wind_set_str(aes_handle, WF_ICONTITLE, (char*)"NetSurf");
+ wind_set(aes_handle, WF_OPTS, 1, WO0_FULLREDRAW, 0, 0);
+ wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITW, 0, 0);
+ wind_set(aes_handle, WF_OPTS, 1, WO0_NOBLITH, 0, 0);
+
+ guiwin_set_toolbar(gw->root->win, get_tree(TOOLBAR), 0, 0);
+ struct rootwin_data_s * data = malloc(sizeof(struct rootwin_data_s));
+ data->rootwin = gw->root;
+ guiwin_set_user_data(gw->root->win, (void*)data);
if (inflags & WIN_TOP) {
- window_set_focus( gw, BROWSER, gw->browser);
+ window_set_focus(gw->root, BROWSER, gw->browser);
}
- GUIWIN * guiwin = guiwin_add(gw->root->handle->handle,
- GW_FLAG_PREPROC_WM | GW_FLAG_RECV_PREPROC_WM, handle_event);
- guiwin_set_toolbar(guiwin, get_tree(TOOLBAR), 0, 0);
return (err);
}
-int window_destroy(struct gui_window * gw)
+void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
+{
+ struct gui_window *w;
+ input_window = NULL;
+
+ LOG(("window: %p, gui_window: %p", rootwin, gw));
+
+ w = window_list;
+ // find the next active tab:
+ while( w != NULL ) {
+ if(w->root == rootwin && w != gw) {
+ input_window = w;
+ break;
+ }
+ w = w->next;
+ }
+ if(input_window == NULL){
+ // the last gui window for this rootwin was removed:
+ window_destroy(rootwin);
+ }
+}
+
+int window_destroy(ROOTWIN *rootwin)
{
int err = 0;
+ struct gui_window *w;
- search_destroy( gw );
- if( input_window == gw )
- input_window = NULL;
+ assert(rootwin != NULL);
- if( gw->root ) {
- if( gw->root->toolbar )
- tb_destroy( gw->root->toolbar );
+ LOG(("%p", rootwin));
- if( gw->root->statusbar )
- sb_destroy( gw->root->statusbar );
+ if (guiwin_get_user_data(rootwin->win) != NULL) {
+ free(guiwin_get_user_data(rootwin->win));
}
- search_destroy( gw );
-
- guiwin_remove(guiwin_find(gw->root->handle->handle));
-
- if( gw->browser )
- browser_destroy( gw->browser );
-
- /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
- if( gw->root ) {
- /* TODO: check if no other browser is bound to this root window! */
- /* only needed for tabs */
- if( gw->root->title )
- free( gw->root->title );
- if( gw->root->cmproot )
- mt_CompDelete( &app, gw->root->cmproot );
- ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
- EvntWindom( MU_MESAG );
- gw->root->handle = NULL;
- free(gw->root);
- gw->root = NULL;
+ // make sure we do not destroy windows which have gui_windows attached:
+ w = window_list;
+ while( w != NULL ) {
+ if(w->root == rootwin) {
+ assert(rootwin == NULL);
+ }
+ w = w->next;
}
+
+ if (rootwin->toolbar)
+ toolbar_destroy(rootwin->toolbar);
+
+ if(rootwin->statusbar)
+ sb_destroy(rootwin->statusbar);
+
+ if(rootwin->title)
+ free(rootwin->title);
+
+ guiwin_remove(rootwin->win);
+ free(rootwin);
return(err);
}
-void window_open( struct gui_window * gw, GRECT pos )
+void window_open(ROOTWIN *rootwin, GRECT pos)
{
- LGRECT br;
-
- WindOpen(gw->root->handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
- WindClear( gw->root->handle );
- WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
-
- /* apply focus to the root frame: */
- long lfbuff[8] = { CM_GETFOCUS };
- mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
-
- /* recompute the nested component sizes and positions: */
- browser_update_rects( gw );
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
- browser_get_rect( gw, BR_CONTENT, &br );
- plot_set_dimensions(br.g_x, br.g_y, br.g_w, br.g_h);
- gw->browser->attached = true;
- if( gw->root->statusbar != NULL ) {
- sb_attach(gw->root->statusbar, gw);
+ GRECT br;
+
+ short aes_handle = guiwin_get_handle(rootwin->win);
+ wind_open(aes_handle, pos.g_x, pos.g_y, pos.g_w, pos.g_h );
+ wind_set_str(aes_handle, WF_NAME, (char *)"");
+
+ rootwin->active_gui_window->browser->attached = true;
+ if(rootwin->statusbar != NULL) {
+ sb_attach(rootwin->statusbar, rootwin->active_gui_window);
}
- tb_adjust_size( gw );
/*TBD: get already present content and set size? */
- input_window = gw;
- window_set_focus( gw, BROWSER, gw->browser );
+ input_window = rootwin->active_gui_window;
+ window_set_focus(rootwin, BROWSER, rootwin->active_gui_window->browser);
}
/* update back forward buttons (see tb_update_buttons (bug) ) */
-void window_update_back_forward( struct gui_window * gw)
+void window_update_back_forward(struct s_gui_win_root *rootwin)
{
- tb_update_buttons( gw, -1 );
+ struct gui_window * active_gw = rootwin->active_gui_window;
+ toolbar_update_buttons(rootwin->toolbar, active_gw->browser->bw, -1);
}
-void window_set_stauts(struct gui_window * gw , char * text )
+void window_set_stauts(struct s_gui_win_root *rootwin, char * text)
{
- if( gw->root == NULL )
- return;
+ assert(rootwin != NULL);
- CMP_STATUSBAR sb = gw->root->statusbar;
+ CMP_STATUSBAR sb = rootwin->statusbar;
- if( sb == NULL || gw->browser->attached == false )
+ if( sb == NULL)
return;
- sb_set_text( sb, text );
+ if(text != NULL)
+ sb_set_text(sb, text);
+ else
+ sb_set_text(sb, "");
+}
+
+void window_set_title(struct s_gui_win_root * rootwin, char *title)
+{
+ wind_set_str(guiwin_get_handle(rootwin->win), WF_NAME, title);
}
/* set focus to an arbitary element */
-void window_set_focus(struct gui_window * gw, enum focus_element_type type, void * element)
+void window_set_focus(struct s_gui_win_root *rootwin,
+ enum focus_element_type type, void * element)
{
- if( gw->root->focus.type != type || gw->root->focus.element != element ) {
+ struct text_area * ta;
+
+ assert(rootwin != NULL);
+
+ if (rootwin->focus.type != type || rootwin->focus.element != element) {
LOG(("Set focus: %p (%d)\n", element, type));
- gw->root->focus.type = type;
- gw->root->focus.element = element;
+ rootwin->focus.type = type;
+ rootwin->focus.element = element;
if( element != NULL ) {
switch( type ) {
case URL_WIDGET:
- textarea_keypress(((struct s_url_widget*)(element))->textarea,
- KEY_SELECT_ALL );
+ // TODO: make something like: toolbar_text_select_all();
+ ta = toolbar_get_textarea(rootwin->toolbar,
+ URL_INPUT_TEXT_AREA);
+ textarea_keypress(ta, KEY_SELECT_ALL);
break;
default:
@@ -366,63 +369,82 @@ void window_set_focus(struct gui_window * gw, enum focus_element_type type, void
}
/* check if the url widget has focus */
-bool window_url_widget_has_focus( struct gui_window * gw )
+bool window_url_widget_has_focus(struct s_gui_win_root *rootwin)
{
- assert( gw );
- assert( gw->root );
- if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) {
- assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) );
- assert( GUIWIN_VISIBLE(gw) );
+ assert(rootwin != NULL);
+ if (rootwin->focus.type == URL_WIDGET) {
return true;
}
return false;
}
/* check if an arbitary window widget / or frame has the focus */
-bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element )
+bool window_widget_has_focus(struct s_gui_win_root *rootwin,
+ enum focus_element_type t, void * element)
{
- if( gw == NULL )
- return( false );
+ assert(rootwin != NULL);
if( element == NULL ) {
- assert( 1 != 0 );
- return( (gw->root->focus.type == t ) );
+ return((rootwin->focus.type == t));
}
- assert( gw->root != NULL );
- return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
+
+ return((element == rootwin->focus.element && t == rootwin->focus.type));
}
-void window_set_icon(struct gui_window *gw, struct bitmap * bmp )
+void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp )
{
- gw->icon = bmp;
+ rootwin->icon = bmp;
/* redraw window when it is iconyfied: */
- if (gw->icon != NULL) {
+ if (rootwin->icon != NULL) {
short info, dummy;
- WindGet(gw->root->handle, WF_ICONIFY, &info, &dummy, &dummy, &dummy);
- if (info == 1) {
- window_redraw_favicon(gw, NULL);
+ if (guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED) {
+ window_redraw_favicon(rootwin, NULL);
+ }
+ }
+}
+
+void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw)
+{
+ if (rootwin->active_gui_window != NULL) {
+ if(rootwin->active_gui_window == gw){
+ return;
}
}
+ rootwin->active_gui_window = gw;
+ window_set_icon(rootwin, gw->icon);
+ window_set_stauts(rootwin, gw->status);
+ window_set_title(rootwin, gw->title);
+ toolbar_set_url(rootwin->toolbar, gw->url);
+ // TODO: implement window_restore_browser()
+ // window_restore_browser(gw->browser);
+}
+
+struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin)
+{
+ return(rootwin->active_gui_window);
}
/**
* Redraw the favicon
*/
-void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
+void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
{
GRECT work;
- assert(gw->root);
+ assert(rootwin);
- WINDOW * bw = gw->root->handle;
+ guiwin_clear(rootwin->win);
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
- WindClear(bw);
- WindGet(bw, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h);
if (clip == NULL) {
clip = &work;
+ } else {
+ if(!rc_intersect(&work, clip)){
+ return;
+ }
}
- if (gw->icon == NULL) {
+ if (rootwin->icon == NULL) {
OBJECT * tree = get_tree(ICONIFY);
tree->ob_x = work.g_x;
tree->ob_y = work.g_y;
@@ -439,7 +461,7 @@ void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
}
plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, work.g_h);
plot_clip(&work_clip);
- atari_plotters.bitmap(0, 0, work.g_w, work.g_h, gw->icon, 0xffffff, 0);
+ atari_plotters.bitmap(0, 0, work.g_w, work.g_h, rootwin->icon, 0xffffff, 0);
}
}
@@ -448,16 +470,16 @@ void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
/* Event Handlers: */
/* -------------------------------------------------------------------------- */
-static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
+static void __CDECL evnt_window_arrowed(WINDOW *win, short buff[8], void *data)
{
bool abs = false;
- LGRECT cwork;
+ GRECT cwork;
struct gui_window * gw = data;
int value = BROWSER_SCROLL_SVAL;
assert( gw != NULL );
- browser_get_rect( gw, BR_CONTENT, &cwork );
+ browser_get_rect(gw, BR_CONTENT, &cwork );
switch( buff[4] ) {
case WA_UPPAGE:
@@ -602,31 +624,56 @@ static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data
static void redraw(GUIWIN *win, short msg[8])
{
short handle;
- struct gui_window *gw;
-
- handle = guiwin_get_handle(win);
- gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
-
- assert(gw != NULL);
+ struct rootwin_data_s *data = guiwin_get_user_data(win);
+ ROOTWIN *rootwin = data->rootwin;
+ GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
if(guiwin_get_state(win) & GW_STATUS_ICONIFIED) {
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
- window_redraw_favicon(gw, &clip);
+ window_redraw_favicon(rootwin, &clip);
} else {
GRECT content_area, tb_area;
short pxy[8];
guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &content_area);
guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
- struct rect clip = {0,0,content_area.g_w,content_area.g_h};
- plot_set_dimensions(content_area.g_x, content_area.g_y,
- content_area.g_w,content_area.g_h);
- //plot_clip(&clip);
- plot_rectangle(0, 0, content_area.g_w,
- content_area.g_h, plot_style_broken_object);
+ if (rc_intersect(&tb_area, &clip)) {
+ toolbar_set_dimensions(rootwin->toolbar, &tb_area);
+ toolbar_redraw(rootwin->toolbar, clip);
+ }
+
+ CMP_BROWSER browser = rootwin->active_gui_window->browser;
+ if (browser->reformat_pending == true) {
+ browser_window_reformat(browser->bw, false, content_area.g_w,
+ content_area.g_h );
+ } else {
+ if(rc_intersect(&content_area, &clip)){
+
+ GRECT lclip = content_area;
+
+ /* convert redraw coords to framebuffer coords: */
+ lclip.g_x -= content_area.g_x;
+ lclip.g_y -= content_area.g_y;
+
+ if( lclip.g_x < 0 ) {
+ lclip.g_w = content_area.g_w + lclip.g_x;
+ lclip.g_x = 0;
+ }
+
+ if( lclip.g_y < 0 ) {
+ lclip.g_h = content_area.g_h + lclip.g_y;
+ lclip.g_y = 0;
+ }
+
+ browser_schedule_redraw(rootwin->active_gui_window,
+ lclip.g_x, lclip.g_y,
+ lclip.g_x + lclip.g_w,
+ lclip.g_y + lclip.g_h);
+ }
+ }
- //WindClear(gw->root->handle);
+ //guiwin_clear(win);
}
}
@@ -635,37 +682,40 @@ static void resized(GUIWIN *win)
short x,y,w,h;
short handle;
struct gui_window *gw;
+ struct rootwin_data_s *data = guiwin_get_user_data(win);
+ ROOTWIN *rootwin = data->rootwin;
+
+ printf("resized win: %p\n", win);
handle = guiwin_get_handle(win);
- gw = (struct gui_window*)find_guiwin_by_aes_handle(handle);
- assert( gw != NULL );
+ printf("resized handle: %d\n", handle);
+ gw = data->rootwin->active_gui_window;
+
+ assert(gw != NULL);
+
+ printf("resized gw: %p\n", gw);
+
+ if(gw == NULL)
+ return;
+ //assert( gw != NULL );
wind_get(handle, WF_CURRXYWH, &x, &y, &w, &h);
- if (gw->root->loc.g_w != w || gw->root->loc.g_h != h) {
- // resized
- tb_adjust_size( gw );
+ if (rootwin->loc.g_w != w || rootwin->loc.g_h != h) {
if ( gw->browser->bw->current_content != NULL ) {
- /* Reformat will happen when next redraw message arrives: */
- gw->browser->reformat_pending = true;
- /* but on xaaes an resize doesn't trigger an redraw, */
- /* when the window is shrinked, deal with it: */
- if( sys_XAAES() ) {
- if( gw->root->loc.g_w > w || gw->root->loc.g_h > h ) {
- ApplWrite(_AESapid, WM_REDRAW, gw->root->handle->handle,
- x, y, w, h);
- }
- }
+ /* Reformat will happen when redraw is processed: */
+ rootwin->active_gui_window->browser->reformat_pending = true;
}
}
- if (gw->root->loc.g_x != x || gw->root->loc.g_y != y) {
+ if (rootwin->loc.g_x != x || rootwin->loc.g_y != y) {
// moved
}
- gw->root->loc.g_x = x;
- gw->root->loc.g_y = y;
- gw->root->loc.g_w = w;
- gw->root->loc.g_h = h;
+
+ rootwin->loc.g_x = x;
+ rootwin->loc.g_y = y;
+ rootwin->loc.g_w = w;
+ rootwin->loc.g_h = h;
}
static void __CDECL file_dropped(GUIWIN *win, short msg[8])
@@ -712,7 +762,7 @@ static void __CDECL file_dropped(GUIWIN *win, short msg[8])
size, mx, my
));
{
- LGRECT bwrect;
+ GRECT bwrect;
struct browser_window * bw = gw->browser->bw;
browser_get_rect( gw, BR_CONTENT, &bwrect );
mx = mx - bwrect.g_x;
diff --git a/atari/rootwin.h b/atari/rootwin.h
index 28001ba..f7aa7c4 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -17,7 +17,9 @@
*/
#ifndef NS_ATARI_BROWSER_WIN_H
-#define NS_ATARI_BROWSER_WIN_H
+#define NS_ATARI_BROWSER_WIN_H
+
+#include <atari/gui.h>
#define GUIWIN_VISIBLE(gw) (gw->root->handle->status & WS_OPEN)
#define GEMWIN_VISIBLE(win) (win->status & WS_OPEN)
@@ -36,31 +38,39 @@
/* -------------------------------------------------------------------------- */
/* Creates an normal Browser window with [toolbar], [statusbar] */
-int window_create( struct gui_window * gw,
+int window_create(struct gui_window * gw,
struct browser_window * bw, unsigned long flags );
/* Destroys WinDom part of gui_window */
-int window_destroy( struct gui_window * gw );
+int window_destroy(struct s_gui_win_root * rootwin);
/* show the window */
-void window_open( struct gui_window * gw, GRECT pos);
+void window_open(struct s_gui_win_root * rootwin, GRECT pos);
-void window_snd_redraw(struct gui_window * gw, short x, short y, short w, short h );
+void window_snd_redraw(struct s_gui_win_root * rootwin, short x, short y,
+ short w, short h );
/* Update Shade / Unshade state of the fwd/back buttons*/
-void window_update_back_forward(struct gui_window * gw);
+void window_update_back_forward(struct s_gui_win_root * rootwin);
/* set root browser component: */
-void window_attach_browser( struct gui_window * gw, CMP_BROWSER b);
+void window_attach_browser(struct s_gui_win_root * rootwin, CMP_BROWSER b);
/* set focus element */
-void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element );
+void window_set_focus(struct s_gui_win_root * rootwin,
+ enum focus_element_type type, void * element );
/* adjust scroll settings */
-void window_set_scroll_info(struct gui_window *gw, int content_h, int content_w);
+void window_set_scroll_info(struct s_gui_win_root * rootwin, int content_h,
+ int content_w);
/* Shade / Unshade the forward/back bt. of toolbar, depending on history.*/
-bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element);
-bool window_url_widget_has_focus( struct gui_window * gw );
-void window_set_url( struct gui_window * gw, const char * text);
-void window_set_stauts( struct gui_window * gw , char * text );
-void window_set_icon(struct gui_window * gw, struct bitmap * bmp );
-void window_redraw_favicon(struct gui_window *gw, GRECT *clip);
+bool window_widget_has_focus(struct s_gui_win_root * rootwin,
+ enum focus_element_type t, void * element);
+bool window_url_widget_has_focus(struct s_gui_win_root * rootwin);
+void window_set_url(struct s_gui_win_root * rootwin, const char * text);
+void window_set_stauts(struct s_gui_win_root * rootwin, char * text);
+void window_set_title(struct s_gui_win_root * rootwin, char * text);
+void window_set_icon(struct s_gui_win_root * rootwin, struct bitmap * bmp );
+void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
+struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
+void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
+void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
/* -------------------------------------------------------------------------- */
diff --git a/atari/toolbar.c b/atari/toolbar.c
old mode 100755
new mode 100644
index 396cccb..3902569
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
+ * Copyright 2012 Ole Loots <ole(a)monochrom.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -24,7 +24,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
-#include <windom.h>
#include <assert.h>
#include <math.h>
@@ -50,16 +49,83 @@
#include "atari/global_evnt.h"
#include "atari/plot/plot.h"
#include "cflib.h"
-#include "atari/res/netsurf.rsh"
+#include "atari/res/netsurf.rsh"
+
+#include "desktop/textarea.h"
+#include "desktop/textinput.h"
+#include "content/hlcache.h"
+#include "atari/browser.h"
+
+#define TB_BUTTON_WIDTH 32
+#define THROBBER_WIDTH 32
+#define THROBBER_MIN_INDEX 1
+#define THROBBER_MAX_INDEX 12
+#define THROBBER_INACTIVE_INDEX 13
+
+#define TOOLBAR_URL_MARGIN_LEFT 2
+#define TOOLBAR_URL_MARGIN_RIGHT 2
+#define TOOLBAR_URL_MARGIN_TOP 2
+#define TOOLBAR_URL_MARGIN_BOTTOM 2
+
+enum e_toolbar_button_states {
+ button_on = 0,
+ button_off = 1
+};
+#define TOOLBAR_BUTTON_NUM_STATES 2
+
+struct s_toolbar;
+
+struct s_tb_button
+{
+ short rsc_id;
+ void (*cb_click)(struct s_toolbar *tb);
+ hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
+ struct s_toolbar *owner;
+ short state;
+ short index;
+ GRECT area;
+};
+struct s_url_widget
+{
+ /* widget is only redrawn when this flag is set */
+ bool redraw;
+ struct text_area *textarea;
+ GRECT rdw_area;
+ GRECT area;
+};
+
+struct s_throbber_widget
+{
+ short index;
+ short max_index;
+ bool running;
+ GRECT area;
+};
+
+struct s_toolbar
+{
+ struct s_gui_win_root *owner;
+ struct s_url_widget url;
+ struct s_throbber_widget throbber;
+ GRECT btdim;
+ GRECT area;
+ /* size & location of buttons: */
+ struct s_tb_button * buttons;
+ bool hidden;
+ int btcnt;
+ int style;
+ bool redraw;
+};
+
extern char * option_homepage_url;
extern void * h_gem_rsrc;
extern struct gui_window * input_window;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
-static OBJECT * toolbar_buttons = NULL;
+static OBJECT * aes_toolbar = NULL;
static OBJECT * throbber_form = NULL;
static bool img_toolbar = false;
static char * toolbar_image_folder = (char *)"default";
@@ -68,7 +134,7 @@ static hlcache_handle * toolbar_image;
static hlcache_handle * throbber_image;
static bool toolbar_image_ready = false;
static bool throbber_image_ready = false;
-
+static bool init = false;
static plot_font_style_t font_style_url = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
@@ -77,46 +143,45 @@ static plot_font_style_t font_style_url = {
.flags = FONTF_NONE,
.background = 0xffffff,
.foreground = 0x0
- };
+ };
+
/* prototypes & order for button widgets: */
+
static struct s_tb_button tb_buttons[] =
{
{
TOOLBAR_BT_BACK,
- tb_back_click,
- 0,
+ toolbar_back_click,
{0,0},
- 0, 0, 0
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_HOME,
- tb_home_click,
- 0, {0,0}, 0, 0, 0
+ toolbar_home_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_FORWARD,
- tb_forward_click,
- 0,
- {0,0},
- 0, 0, 0
+ toolbar_forward_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_STOP,
- tb_stop_click,
- 0,
- {0,0},
- 0, 0, 0
+ toolbar_stop_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_RELOAD,
- tb_reload_click,
- 0,
- {0,0},
- 0, 0, 0
+ toolbar_reload_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
- { 0, 0, 0, {0,0}, 0, 0, -1 }
+ { 0, 0, {0,0}, 0, -1, 0, {0,0,0,0}}
};
struct s_toolbar_style {
@@ -142,10 +207,93 @@ static struct s_toolbar_style toolbar_styles[] =
{18, 34, 64, 64, 2, 0, 0 }
};
-static void tb_txt_request_redraw( void *data, int x, int y, int w, int h );
+static void tb_txt_request_redraw(void *data, int x, int y, int w, int h );
static nserror toolbar_icon_callback( hlcache_handle *handle,
const hlcache_event *event, void *pw );
+/**
+* Callback for textarea redraw
+*/
+static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
+{
+ LGRECT work;
+ if( data == NULL )
+ return;
+ CMP_TOOLBAR t = data;
+ if( t->url.redraw == false ){
+ t->url.redraw = true;
+ //t->redraw = true;
+ t->url.rdw_area.g_x = x;
+ t->url.rdw_area.g_y = y;
+ t->url.rdw_area.g_w = w;
+ t->url.rdw_area.g_h = h;
+ } else {
+ /* merge the redraw area to the new area.: */
+ int newx1 = x+w;
+ int newy1 = y+h;
+ int oldx1 = t->url.rdw_area.g_x + t->url.rdw_area.g_w;
+ int oldy1 = t->url.rdw_area.g_y + t->url.rdw_area.g_h;
+ t->url.rdw_area.g_x = MIN(t->url.rdw_area.g_x, x);
+ t->url.rdw_area.g_y = MIN(t->url.rdw_area.g_y, y);
+ t->url.rdw_area.g_w = ( oldx1 > newx1 ) ?
+ oldx1 - t->url.rdw_area.g_x : newx1 - t->url.rdw_area.g_x;
+ t->url.rdw_area.g_h = ( oldy1 > newy1 ) ?
+ oldy1 - t->url.rdw_area.g_y : newy1 - t->url.rdw_area.g_y;
+ }
+}
+
+/**
+ * Callback for load_icon(). Should be removed once bitmaps get loaded directly
+ * from disc
+ */
+static nserror toolbar_icon_callback(hlcache_handle *handle,
+ const hlcache_event *event, void *pw)
+{
+ if( event->type == CONTENT_MSG_READY ){
+ if( handle == toolbar_image ){
+ toolbar_image_ready = true;
+ if(input_window != NULL )
+ toolbar_update_buttons(input_window->root->toolbar,
+ input_window->browser->bw, 0);
+ }
+ else if(handle == throbber_image ){
+ throbber_image_ready = true;
+ }
+ }
+
+ return NSERROR_OK;
+}
+
+static struct s_tb_button *button_init(struct s_toolbar *tb, OBJECT * tree, int index,
+ struct s_tb_button * instance)
+{
+ *instance = tb_buttons[index];
+ instance->owner = tb;
+
+ instance->area.g_w = toolbar_styles[tb->style].icon_width + \
+ ( toolbar_styles[tb->style].button_vmargin * 2);
+
+ return(instance);
+}
+
+
+static void toolbar_reflow(struct s_toolbar *tb)
+{
+ LOG((""));
+/*
+ int i=0, x=0;
+
+ x = 2;
+ while (tb->buttons[i].rsc_id > 0) {
+ tb->buttons[i].area.g_x = x;
+ x += tb->buttons[i].area.g_w;
+ x += 2;
+ i++;
+ }
+ tb->url.area.g_x = x;
+*/
+}
+
void toolbar_init( void )
{
@@ -155,7 +303,7 @@ void toolbar_init( void )
toolbar_image_folder = nsoption_charp(atari_image_toolbar_folder);
toolbar_bg_color = (nsoption_colour(atari_toolbar_bg));
- img_toolbar = (nsoption_int( atari_image_toolbar ) > 0 ) ? true : false;
+ img_toolbar = (nsoption_int(atari_image_toolbar) > 0 ) ? true : false;
if( img_toolbar ){
char imgfile[PATH_MAX];
@@ -175,13 +323,8 @@ void toolbar_init( void )
toolbar_icon_callback, NULL );
} else {
- RsrcGaddr( h_gem_rsrc, R_TREE, TOOLBAR, &toolbar_buttons );
- //toolbar_buttons->ob_x = 0;
- //toolbar_buttons->ob_y = 0;
-
- RsrcGaddr( h_gem_rsrc, R_TREE, THROBBER , &throbber_form );
- throbber_form->ob_x = 0;
- throbber_form->ob_y = 0;
+ aes_toolbar = get_tree(TOOLBAR);
+ throbber_form = get_tree(THROBBER);
}
n = (sizeof( toolbar_styles ) / sizeof( struct s_toolbar_style ));
for (i=0; i<n; i++) {
@@ -189,579 +332,42 @@ void toolbar_init( void )
}
}
-void toolbar_exit( void )
-{
- if( toolbar_image )
- hlcache_handle_release( toolbar_image );
- if( throbber_image )
- hlcache_handle_release( throbber_image );
-}
-/**
- * Callback for load_icon(). Should be removed once bitmaps get loaded directly
- * from disc
- */
-static nserror toolbar_icon_callback(hlcache_handle *handle,
- const hlcache_event *event, void *pw)
+void toolbar_exit(void)
{
- if( event->type == CONTENT_MSG_READY ){
- if( handle == toolbar_image ){
- toolbar_image_ready = true;
- if( input_window != NULL )
- tb_update_buttons( input_window, 0 );
- }
- else if( handle == throbber_image ){
- throbber_image_ready = true;
- }
- }
-
- return NSERROR_OK;
+ if (toolbar_image)
+ hlcache_handle_release(toolbar_image);
+ if (throbber_image)
+ hlcache_handle_release(throbber_image);
}
-
-
-static void __CDECL button_redraw( COMPONENT *c, long buff[8], void * data )
-{
-
- OBJECT *tree=NULL;
- LGRECT work,clip;
- GRECT todo,crect;
- struct s_tb_button *bt = (struct s_tb_button*)data;
- struct gui_window * gw = bt->gw;
- struct s_toolbar * tb = gw->root->toolbar;
-
- short pxy[4];
- int bmpx=0, bmpy=0, bmpw=0, bmph = 0, drawstate=0;
- struct bitmap * icon = NULL;
- struct rect icon_clip;
- GRECT icon_dim = {0,0,0,0};
- plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
-
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- work.g_h = work.g_h - 1;
- clip = work;
-
- /* return if component and redraw region does not intersect: */
- if (!rc_lintersect( (LGRECT*)&buff[4], &clip)) {
- return;
- }
-
- drawstate = bt->state;
- if( img_toolbar ){
-
- if( toolbar_image_ready == false ){
- return;
- }
- icon = content_get_bitmap( toolbar_image );
- if( icon == NULL ){
- return;
- }
- bmpw = bitmap_get_width(icon);
- bmph = bitmap_get_height(icon);
- bmpx = 0;
- bmpy = 0;
- icon_clip.x0 = bmpx+(toolbar_styles[tb->style].icon_width*bt->index);
- icon_clip.y0 = bmpy+(toolbar_styles[tb->style].icon_height*drawstate);
- icon_clip.x1 = icon_clip.x0+toolbar_styles[tb->style].icon_width;
- icon_clip.y1 = icon_clip.y0+toolbar_styles[tb->style].icon_height;
- icon_dim.g_x = work.g_x-(toolbar_styles[tb->style].icon_width * bt->index)+toolbar_styles[tb->style].button_vmargin;
- icon_dim.g_y = work.g_y-(toolbar_styles[tb->style].icon_height * drawstate)+toolbar_styles[tb->style].button_hmargin;
- icon_dim.g_w = toolbar_styles[tb->style].icon_width*(bt->index+1);
- icon_dim.g_h = toolbar_styles[tb->style].icon_height*(drawstate+1);
- } else {
- /* Place the CICON into workarea: */
- tree = &toolbar_buttons[bt->rsc_id];
- if( tree == NULL )
- return;
- //tree->ob_x = work.g_x;
- //tree->ob_y = work.g_y + (work.g_h - tree->ob_height) / 2;
- if( drawstate == button_off ) {
- tree->ob_state |= OS_DISABLED;
- } else {
- tree->ob_state &= ~OS_DISABLED;
- }
- }
-
- /* Setup draw mode: */
- vsf_interior(atari_plot_vdi_handle , 1 );
- vswr_mode(atari_plot_vdi_handle, MD_REPLACE);
-
- /* go through the rectangle list, using classic AES methods. */
- /* Windom ComGetLGrect is buggy for WF_FIRST/NEXTXYWH */
- crect.g_x = clip.g_x;
- crect.g_y = clip.g_y;
- crect.g_w = clip.g_w;
- crect.g_h = clip.g_h;
- wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
- &todo.g_x, &todo.g_y, &todo.g_w, &todo.g_h );
- while( (todo.g_w > 0) && (todo.g_h > 0) ){
-
- if (rc_intersect(&crect, &todo )) {
-
- struct rect bgclip = {0,0,todo.g_w, todo.g_h};
- pxy[0] = todo.g_x;
- pxy[1] = todo.g_y;
- pxy[2] = todo.g_w + todo.g_x-1;
- pxy[3] = todo.g_h + todo.g_y-1;
-
- vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy );
- plot_set_dimensions(todo.g_x, todo.g_y, todo.g_w, todo.g_h);
- plot_rectangle(0, 0, crect.g_w, crect.g_h, &plot_style_background);
-
- if( img_toolbar == true ){
- plot_set_dimensions(icon_dim.g_x, icon_dim.g_y,
- icon_dim.g_w, icon_dim.g_h);
- plot_clip( &icon_clip );
- atari_plotters.bitmap( bmpx, bmpy, bmpw, bmph, icon,
- toolbar_styles[tb->style].icon_bgcolor,
- BITMAPF_BUFFER_NATIVE );
- } else {
- objc_draw( tree, 0, 0, todo.g_x, todo.g_y, todo.g_w, todo.g_h );
- }
- vs_clip(atari_plot_vdi_handle, 0, (short*)&clip );
- }
- wind_get(gw->root->handle->handle, WF_NEXTXYWH,
- &todo.g_x, &todo.g_y, &todo.g_w, &todo.g_h );
- }
-}
-
-
-static void __CDECL button_click( COMPONENT *c, long buff[8], void * data )
-{
- struct s_tb_button * bt = (struct s_tb_button *)data;
- int i = 0;
- struct gui_window * gw = bt->gw;
- assert( gw );
- gw->root->toolbar->buttons[bt->index].cb_click( gw );
-}
-
-
-static struct s_tb_button * find_button( struct gui_window * gw, int rsc_id )
+struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
{
- int i = 0;
- while( i < gw->root->toolbar->btcnt ) {
- if( gw->root->toolbar->buttons[i].rsc_id == rsc_id ) {
- return( &gw->root->toolbar->buttons[i] );
- }
- i++;
- }
-}
-
-
-static COMPONENT *button_init( CMP_TOOLBAR t, OBJECT * tree, int index,
- struct s_tb_button * instance )
-{
- int comp_width;
-
- *instance = tb_buttons[index];
- instance->gw = t->owner;
-
- comp_width = toolbar_styles[t->style].icon_width + \
- ( toolbar_styles[t->style].button_vmargin * 2 );
-
- instance->comp = mt_CompCreate( &app, CLT_VERTICAL, comp_width, 0 );
- assert( instance->comp );
+ int i;
- instance->comp->bounds.max_width = comp_width;
- mt_CompEvntDataAttach( &app, instance->comp, WM_REDRAW, button_redraw,
- instance );
- mt_CompEvntDataAttach( &app, instance->comp, WM_XBUTTON, button_click,
- instance );
- return instance->comp;
-}
-
+ LOG((""));
-static
-void __CDECL evnt_throbber_redraw( COMPONENT *c, long buff[8])
-{
- LGRECT work, clip;
- int idx;
- short pxy[4];
- struct s_toolbar * tb;
- struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app,
- c,
- CDT_OWNER );
- plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
- tb = gw->root->toolbar;
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- clip = work;
- if ( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return;
-
- vsf_interior(atari_plot_vdi_handle , 1 );
- pxy[0] = (short)buff[4];
- pxy[1] = (short)buff[5];
- pxy[2] = (short)buff[4] + buff[6]-1;
- pxy[3] = (short)buff[5] + buff[7]-2;
- vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy );
-
- if (app.nplanes > 2 ) {
- plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h);
- plot_rectangle( 0, 0, work.g_w, work.g_h, &plot_style_background);
- }
- else {
- vsf_color(atari_plot_vdi_handle, WHITE );
- v_bar(atari_plot_vdi_handle, (short*)&pxy );
- }
-
- if( img_toolbar ){
-
- int bmpx=0, bmpy=0, bmpw=0, bmph = 0, drawstate=0;
- struct rect icon_clip;
- struct bitmap * icon = NULL;
-
- if( throbber_image_ready == false ){
- return;
- }
- icon = content_get_bitmap( throbber_image );
- if( icon == NULL ){
- return;
- }
+ struct s_toolbar *t = calloc(sizeof(struct s_toolbar), 1);
- if( tb->throbber.running == false ) {
- idx = 0;
- }
- else {
- idx = tb->throbber.index;
- if( idx > tb->throbber.max_index ) {
- idx = tb->throbber.index = 1;
- }
- }
- bmpw = bitmap_get_width(icon);
- bmph = bitmap_get_height(icon);
- bmpx = 0;
- bmpy = 0;
-
- /*
- for some reason, adding
- toolbar_styles[tb->style].button_vmargin to the x pos of
- the plotter shifts the icon a bit to much.
- Maybe that's becasue the icon is inside an padded form.
- */
- plot_set_dimensions(
- work.g_x-(toolbar_styles[tb->style].icon_width * idx),
- work.g_y+toolbar_styles[tb->style].button_hmargin,
- toolbar_styles[tb->style].icon_width*(idx+1),
- toolbar_styles[tb->style].icon_height
- );
- icon_clip.x0 = bmpx+(toolbar_styles[tb->style].icon_width*idx);
- icon_clip.y0 = bmpy;
- icon_clip.x1 = icon_clip.x0+toolbar_styles[tb->style].icon_width;
- icon_clip.y1 = icon_clip.y0+toolbar_styles[tb->style].icon_height;
- plot_clip( &icon_clip );
- atari_plotters.bitmap( bmpx, bmpy, bmpw, bmph, icon,
- toolbar_styles[tb->style].icon_bgcolor,
- BITMAPF_BUFFER_NATIVE );
- }
- else {
- if( throbber_form != NULL ) {
- if( gw->root->toolbar->throbber.running == false ) {
- idx = THROBBER_INACTIVE_INDEX;
- } else {
- idx = gw->root->toolbar->throbber.index;
- if( idx > THROBBER_MAX_INDEX || idx < THROBBER_MIN_INDEX ) {
- idx = THROBBER_MIN_INDEX;
- }
- }
- throbber_form[idx].ob_x = work.g_x+1;
- throbber_form[idx].ob_y = work.g_y+4;
- mt_objc_draw( throbber_form, idx, 8, clip.g_x, clip.g_y, clip.g_w, clip.g_h, app.aes_global );
- }
- }
-
-}
-
-static
-void __CDECL evnt_url_redraw( COMPONENT *c, long buff[8], void * data)
-{
- LGRECT work, clip;
- struct gui_window * gw;
- short pxy[10];
- plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
- CMP_TOOLBAR tb = (CMP_TOOLBAR)data;
- mt_CompGetLGrect(&app, tb->url.comp, WF_WORKXYWH, &work);
-
- // this last pixel is drawn by the root component of the toolbar:
- // it's the black border, so we leave it out:
- work.g_h--;
- clip = work;
- if ( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return;
-
- plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h);
-
- //left margin:
- plot_rectangle(0, 0, TOOLBAR_URL_MARGIN_LEFT, work.g_h,
- &plot_style_background);
- // right margin:
- plot_rectangle(work.g_w-TOOLBAR_URL_MARGIN_RIGHT, 0, work.g_w, work.g_h,
- &plot_style_background);
-
- // top margin:
- plot_rectangle(0, 0, work.g_w, TOOLBAR_URL_MARGIN_TOP,
- &plot_style_background);
-
- // bottom margin:
- plot_rectangle(0, work.g_h-TOOLBAR_URL_MARGIN_BOTTOM, work.g_w, work.g_h,
- &plot_style_background);
-
- // TBD: request redraw of textarea for specific region.
- clip.g_x -= work.g_x+TOOLBAR_URL_MARGIN_LEFT;
- clip.g_y -= work.g_y+TOOLBAR_URL_MARGIN_TOP;
- tb_txt_request_redraw( tb, clip.g_x, clip.g_y, clip.g_w, clip.g_h );
-}
-
-static
-void __CDECL evnt_url_click( COMPONENT *c, long buff[8] )
-{
- LGRECT work;
- short pxy[4];
- short mx, my, mb, kstat;
- int old;
- graf_mkstate( &mx, &my, &mb, &kstat );
- struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app, c, CDT_OWNER);
- assert( gw != NULL );
- CMP_TOOLBAR tb = gw->root->toolbar;
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- mx = evnt.mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
- my = evnt.my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
-
- /* TODO: reset mouse state of browser window? */
- /* select whole text when newly focused, otherwise set caret to end of text */
- if( !window_url_widget_has_focus(gw) ) {
- window_set_focus( gw, URL_WIDGET, (void*)&tb->url );
- } else {
- if( mb & 1 ) {
- textarea_mouse_action( tb->url.textarea, BROWSER_MOUSE_DRAG_1,
- mx, my );
- short prev_x = mx;
- short prev_y = my;
- do{
- if( abs(prev_x-mx) > 5 || abs(prev_y-my) > 5 ){
- textarea_mouse_action( tb->url.textarea,
- BROWSER_MOUSE_HOLDING_1, mx, my );
- prev_x = mx;
- prev_y = my;
- if( tb->url.redraw ){
- tb_url_redraw( gw );
- }
- }
- graf_mkstate( &mx, &my, &mb, &kstat );
- mx = mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
- my = my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
- }while( mb & 1 );
- textarea_drag_end( tb->url.textarea, 0, mx, my );
- } else {
- /* TODO: recognize click + shift key */
- int mstate = BROWSER_MOUSE_PRESS_1;
- if( (kstat & (K_LSHIFT|K_RSHIFT)) != 0 )
- mstate = BROWSER_MOUSE_MOD_1;
- if( evnt.nb_click == 2 ){
- textarea_mouse_action( tb->url.textarea,
- BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1,
- mx, my );
- } else {
- textarea_mouse_action( tb->url.textarea,
- BROWSER_MOUSE_PRESS_1, mx, my );
- }
- }
- }
- // TODO: do not send an complete redraw!
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
-}
-
-
-void tb_adjust_size( struct gui_window * gw )
-{
- LGRECT work;
- CMP_TOOLBAR t = gw->root->toolbar;
-
- mt_CompGetLGrect( &app, t->url.comp, WF_WORKXYWH, &work);
- work.g_w -= (TOOLBAR_URL_MARGIN_LEFT + TOOLBAR_URL_MARGIN_RIGHT);
- /* do not overwrite the black border, because of that, add 1 */
- work.g_h -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM+1);
- textarea_set_dimensions( t->url.textarea, work.g_w, work.g_h );
- tb_txt_request_redraw( t, 0,0, work.g_w-1, work.g_h-1);
-}
-
-static void __CDECL evnt_toolbar_redraw( COMPONENT *c, long buff[8], void *data )
-{
- LGRECT work, clip;
- short pxy[4];
- const plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- clip = work;
- if( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return;
- if( work.g_y + work.g_h != clip.g_y + clip.g_h ) return;
-
- vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
- vsl_color(atari_plot_vdi_handle, BLACK );
- vsl_type(atari_plot_vdi_handle, 1 );
- vsl_width(atari_plot_vdi_handle, 1 );
- pxy[0] = clip.g_x;
- pxy[1] = pxy[3] = work.g_y + work.g_h-1 ;
- pxy[2] = clip.g_x + clip.g_w;
- v_pline(atari_plot_vdi_handle, 2, (short*)&pxy );
-}
-
-
-static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
-{
- LGRECT work;
- if( data == NULL )
- return;
- CMP_TOOLBAR t = data;
- if( t->url.redraw == false ){
- t->url.redraw = true;
- //t->redraw = true;
- t->url.rdw_area.g_x = x;
- t->url.rdw_area.g_y = y;
- t->url.rdw_area.g_w = w;
- t->url.rdw_area.g_h = h;
- } else {
- /* merge the redraw area to the new area.: */
- int newx1 = x+w;
- int newy1 = y+h;
- int oldx1 = t->url.rdw_area.g_x + t->url.rdw_area.g_w;
- int oldy1 = t->url.rdw_area.g_y + t->url.rdw_area.g_h;
- t->url.rdw_area.g_x = MIN(t->url.rdw_area.g_x, x);
- t->url.rdw_area.g_y = MIN(t->url.rdw_area.g_y, y);
- t->url.rdw_area.g_w = ( oldx1 > newx1 ) ?
- oldx1 - t->url.rdw_area.g_x : newx1 - t->url.rdw_area.g_x;
- t->url.rdw_area.g_h = ( oldy1 > newy1 ) ?
- oldy1 - t->url.rdw_area.g_y : newy1 - t->url.rdw_area.g_y;
- }
-}
-
-void tb_url_redraw( struct gui_window * gw )
-{
-
- CMP_TOOLBAR t = gw->root->toolbar;
- if (t != NULL) {
- if( t->url.redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
-
- const struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &atari_plotters
- };
- short todo[4];
- LGRECT work;
-
- mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &work);
- work.g_x += TOOLBAR_URL_MARGIN_RIGHT;
- work.g_y += TOOLBAR_URL_MARGIN_LEFT;
- work.g_w -= TOOLBAR_URL_MARGIN_RIGHT;
- work.g_h -= TOOLBAR_URL_MARGIN_BOTTOM;
-
- plot_set_dimensions( work.g_x, work.g_y, work.g_w, work.g_h );
- if(plot_lock() == false)
- return;
+ assert(t);
- todo[0] = work.g_x;
- todo[1] = work.g_y;
- todo[2] = todo[0] + work.g_w-1;
- todo[3] = todo[1] + work.g_h-1;
- vs_clip(atari_plot_vdi_handle, 1, (short*)&todo );
-
- if( wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
- &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
- while (todo[2] && todo[3]) {
-
- /* convert screen to relative coords: */
- todo[0] = todo[0] - work.g_x;
- todo[1] = todo[1] - work.g_y;
- if( todo[0] < 0 ){
- todo[2] = todo[2] + todo[0];
- todo[0] = 0;
- }
- if( todo[1] < 0 ){
- todo[3] = todo[3] + todo[1];
- todo[1] = 0;
- }
-
- if (rc_intersect(&t->url.rdw_area,(GRECT *)&todo)) {
- struct rect clip = {
- .x0 = todo[0],
- .y0 = todo[1],
- .x1 = todo[0]+todo[2],
- .y1 = todo[1]+todo[3]
- };
- textarea_redraw( t->url.textarea, 0, 0, &clip, &ctx );
- }
- if (wind_get(gw->root->handle->handle, WF_NEXTXYWH,
- &todo[0], &todo[1], &todo[2], &todo[3])==0) {
- break;
- }
- }
- } else {
- plot_unlock();
- return;
- }
- plot_unlock();
- vs_clip(atari_plot_vdi_handle, 0, (short*)&todo);
- t->url.redraw = false;
- t->url.rdw_area.g_x = 65000;
- t->url.rdw_area.g_y = 65000;
- t->url.rdw_area.g_w = -1;
- t->url.rdw_area.g_h = -1;
- } else {
- /* just copy stuff from the offscreen buffer */
- }
- }
-}
-
-CMP_TOOLBAR tb_create( struct gui_window * gw )
-{
- int i;
-
-
- CMP_TOOLBAR t = malloc( sizeof(struct s_toolbar) );
- if( t == NULL )
- return( NULL );
-
- t->owner = gw;
+ t->owner = owner;
t->style = 1;
/* create the root component: */
- t->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
- toolbar_styles[t->style].height, 0 );
- t->comp->rect.g_h = toolbar_styles[t->style].height;
- t->comp->bounds.max_height = toolbar_styles[t->style].height;
- mt_CompEvntDataAdd(&app, t->comp, WM_REDRAW, evnt_toolbar_redraw,
- gw, EV_BOT);
+ t->area.g_h = toolbar_styles[t->style].height;
/* count buttons and add them as components: */
i = 0;
- while( tb_buttons[i].rsc_id > 0 ) {
+ while(tb_buttons[i].rsc_id > 0) {
i++;
}
t->btcnt = i;
- t->buttons = malloc( t->btcnt * sizeof(struct s_tb_button) );
- memset( t->buttons, 0, t->btcnt * sizeof(struct s_tb_button) );
- for( i=0; i < t->btcnt; i++ ) {
- button_init( t, toolbar_buttons, i, &t->buttons[i] );
- mt_CompAttach( &app, t->comp, t->buttons[i].comp );
+ t->buttons = malloc(t->btcnt * sizeof(struct s_tb_button));
+ memset( t->buttons, 0, t->btcnt * sizeof(struct s_tb_button));
+ for (i=0; i < t->btcnt; i++ ) {
+ button_init(t, aes_toolbar, i, &t->buttons[i]);
}
/* create the url widget: */
@@ -770,30 +376,16 @@ CMP_TOOLBAR tb_create( struct gui_window * gw )
int ta_height = toolbar_styles[t->style].height;
ta_height -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM);
- t->url.textarea = textarea_create( 300,
- ta_height,
- 0,
- &font_style_url, tb_txt_request_redraw,
- t );
+ t->url.textarea = textarea_create(300, ta_height, 0, &font_style_url,
+ tb_txt_request_redraw, t);
if( t->url.textarea != NULL ){
textarea_set_text(t->url.textarea, "http://");
}
-
- t->url.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
- toolbar_styles[t->style].height, 1);
- mt_CompEvntDataAttach( &app, t->url.comp, WM_REDRAW, evnt_url_redraw, t);
- mt_CompEvntAttach( &app, t->url.comp, WM_XBUTTON, evnt_url_click );
- mt_CompDataAttach( &app, t->url.comp, CDT_OWNER, gw );
- mt_CompAttach( &app, t->comp, t->url.comp );
/* create the throbber widget: */
- t->throbber.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
- toolbar_styles[t->style].height, 0);
- t->throbber.comp->rect.g_h = toolbar_styles[t->style].height;
- t->throbber.comp->rect.g_w = t->throbber.comp->bounds.max_width = \
- toolbar_styles[t->style].icon_width + \
+ t->throbber.area.g_h = toolbar_styles[t->style].height;
+ t->throbber.area.g_w = toolbar_styles[t->style].icon_width + \
(2*toolbar_styles[t->style].button_vmargin );
- t->throbber.comp->bounds.max_height = toolbar_styles[t->style].height;
if( img_toolbar == true ){
t->throbber.index = 0;
t->throbber.max_index = 8;
@@ -801,251 +393,163 @@ CMP_TOOLBAR tb_create( struct gui_window * gw )
t->throbber.index = THROBBER_MIN_INDEX;
t->throbber.max_index = THROBBER_MAX_INDEX;
}
- t->throbber.running = false;
- mt_CompEvntAttach( &app, t->throbber.comp, WM_REDRAW, evnt_throbber_redraw );
- mt_CompDataAttach( &app, t->throbber.comp, CDT_OWNER, gw );
- mt_CompAttach( &app, t->comp, t->throbber.comp );
+ t->throbber.running = false;
+
+ LOG(("created toolbar: %p, root: %p, textarea: %p, throbber: %p", t,
+ owner, t->url.textarea, t->throbber));
return( t );
-}
-
-
-void tb_destroy( CMP_TOOLBAR tb )
+}
+
+
+void toolbar_destroy(struct s_toolbar *tb)
{
- free( tb->buttons );
+ free(tb->buttons);
textarea_destroy( tb->url.textarea );
- mt_CompDelete( &app, tb->comp);
- free( tb );
-}
-
-
-struct gui_window * tb_gui_window( CMP_TOOLBAR tb )
-{
- struct gui_window * gw;
- gw = window_list;
- while( gw != NULL ) {
- if( gw->root->toolbar == tb ) {
- LOG(("found tb gw: %p (tb: %p) for tb: %p", gw, gw->root->toolbar, tb ));
- return( gw );
- }
- else
- gw = gw->next;
- }
- return( NULL );
-}
-
-
-void tb_update_buttons( struct gui_window * gw, short button )
+ free(tb);
+}
+
+static void toolbar_objc_reflow(struct s_toolbar *tb)
{
-
-#define FIRST_BUTTON TOOLBAR_BT_BACK
-
- struct s_tb_button * bt;
- bool enable = false;
- if( button == TOOLBAR_BT_BACK || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_BACK-FIRST_BUTTON];
- enable = browser_window_back_available(gw->browser->bw);
- if( enable ){
- bt->state = button_on;
- } else {
- bt->state = button_off;
- }
- mt_CompEvntRedraw( &app, bt->comp );
- }
+ aes_toolbar->ob_x = tb->area.g_x;
+ aes_toolbar->ob_y = tb->area.g_y;
+ aes_toolbar->ob_width = tb->area.g_w;
+ aes_toolbar->ob_height = tb->area.g_h;
- if( button == TOOLBAR_BT_HOME || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_HOME-FIRST_BUTTON];
- mt_CompEvntRedraw( &app, bt->comp );
- }
+ aes_toolbar[TOOLBAR_THROBBER_AREA].ob_x = tb->area.g_w
+ - aes_toolbar[TOOLBAR_THROBBER_AREA].ob_width;
- if( button == TOOLBAR_BT_FORWARD || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_FORWARD-FIRST_BUTTON];
- enable = browser_window_forward_available(gw->browser->bw);
- if( enable ){
- bt->state = button_on;
- } else {
- bt->state = button_off;
- }
- mt_CompEvntRedraw( &app, bt->comp );
- }
+ aes_toolbar[TOOLBAR_URL_AREA].ob_width = tb->area.g_w
+ - (aes_toolbar[TOOLBAR_NAVIGATION_AREA].ob_width
+ + aes_toolbar[TOOLBAR_THROBBER_AREA].ob_width);
+}
- if( button == TOOLBAR_BT_RELOAD || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_RELOAD-FIRST_BUTTON];
- enable = browser_window_reload_available(gw->browser->bw);
- if( enable ){
- bt->state = button_on;
- } else {
- bt->state = button_off;
- }
- mt_CompEvntRedraw( &app, bt->comp );
- }
+void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
+{
+ // position toolbar areas:
+ toolbar_objc_reflow(tb);
+ objc_draw_grect(aes_toolbar,0,8,clip);
- if( button == TOOLBAR_BT_STOP || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_STOP-FIRST_BUTTON];
- enable = browser_window_stop_available(gw->browser->bw);
- if( enable ){
- bt->state = button_on;
- } else {
- bt->state = button_off;
- }
- mt_CompEvntRedraw( &app, bt->comp );
- }
+ // position throbber image:
+ throbber_form[tb->throbber.index].ob_x = tb->area.g_x +
+ aes_toolbar[TOOLBAR_THROBBER_AREA].ob_x;
-#undef FIRST_BUTON
-}
-
-
-
-void tb_url_set( struct gui_window * gw, char * text )
-{
- LGRECT work;
- int len = strlen(text);
- char * newtext;
- int newsize;
-
- if( gw->root->toolbar == NULL )
- return;
-
- if( gw->browser->attached == false )
- return;
-
- struct s_url_widget * url = &gw->root->toolbar->url;
-
- assert( gw != NULL );
- assert( gw->browser != NULL );
- assert( gw->root != NULL );
- assert( gw->browser->bw != NULL );
-
- textarea_set_text(url->textarea, text);
-
- mt_CompGetLGrect( &app, gw->root->toolbar->url.comp, WF_WORKXYWH, &work);
- work.g_w -= (TOOLBAR_URL_MARGIN_LEFT + TOOLBAR_URL_MARGIN_RIGHT);
- /* do not overwrite the black border, because of that, add 1 */
- work.g_h -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM+1);
- tb_txt_request_redraw( gw->root->toolbar, 0,0,work.g_w,work.g_h );
- tb_update_buttons( gw, TOOLBAR_BT_STOP );
- return;
-}
-
-
-/* -------------------------------------------------------------------------- */
-/* Public Module event handlers: */
-/* -------------------------------------------------------------------------- */
-
-bool tb_url_input( struct gui_window * gw, short nkc )
-{
- CMP_TOOLBAR tb = gw->root->toolbar;
- assert(tb!=NULL);
- LGRECT work;
- bool ret = false;
-
- assert( gw != NULL );
-
- long ucs4;
- long ik = nkc_to_input_key( nkc, &ucs4 );
-
- if( ik == 0 ){
- if ( (nkc&0xFF) >= 9 ) {
- ret = textarea_keypress( tb->url.textarea, ucs4 );
- }
- }
- else if( ik == KEY_CR || ik == KEY_NL ){
- char tmp_url[PATH_MAX];
- if( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
- window_set_focus( gw, BROWSER, gw->browser);
- browser_window_go(gw->browser->bw, (const char*)&tmp_url, 0, true);
- ret = true;
- }
- }
- else if( ik == KEY_COPY_SELECTION ){
- // copy whole text
- char * text;
- int len;
- len = textarea_get_text( tb->url.textarea, NULL, 0 );
- text = malloc( len+1 );
- if( text ){
- textarea_get_text( tb->url.textarea, text, len+1 );
- scrap_txt_write( &app, text );
- free( text );
- }
- }
- else if( ik == KEY_PASTE ){
- char * clip = scrap_txt_read( &app );
- if( clip != NULL ){
- int clip_length = strlen( clip );
- if ( clip_length > 0 ) {
- char *utf8;
- utf8_convert_ret res;
- /* Clipboard is in local encoding so
- * convert to UTF8 */
- res = utf8_from_local_encoding( clip, clip_length, &utf8 );
- if ( res == UTF8_CONVERT_OK ) {
- tb_url_set( gw, utf8 );
- free(utf8);
- ret = true;
- }
- free( clip );
- }
- }
- }
- else if( ik == KEY_ESCAPE ) {
- textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
- textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
- }
- else {
- ret = textarea_keypress( tb->url.textarea, ik );
- }
-
- return( ret );
-}
+ throbber_form[tb->throbber.index].ob_x = tb->area.g_x
+ + aes_toolbar[TOOLBAR_THROBBER_AREA].ob_x +
+ ((aes_toolbar[TOOLBAR_THROBBER_AREA].ob_width
+ - throbber_form[tb->throbber.index].ob_width) >> 1);
+
+ throbber_form[tb->throbber.index].ob_y = tb->area.g_y +
+ ((aes_toolbar[TOOLBAR_THROBBER_AREA].ob_height
+ - throbber_form[tb->throbber.index].ob_height) >> 1);
+
+ printf("x pos: %d, y pos: %d\n", throbber_form[tb->throbber.index].ob_x,
+ throbber_form[tb->throbber.index].ob_y);
+ objc_draw_grect(&throbber_form[tb->throbber.index], 0, 1, clip);
+
+}
+
+
+void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
+ short button)
+{
+ LOG((""));
+}
+
+
+void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area)
+{
+ tb->area = *area;
+ if (img_toolbar != 0) {
+ toolbar_reflow(tb);
+ }
+}
+
+
+void toolbar_set_url(struct s_toolbar *tb, const char * text)
+{
+ LOG((""));
+}
+
+
+bool toolbar_text_input(struct s_toolbar *tb, char *text)
+{
+ bool handled = true;
+
+ LOG((""));
+
+ return(handled);
+}
+
+bool toolbar_key_input(struct s_toolbar *tb, short nkc)
+{
+ bool handled = true;
+
+ LOG((""));
+
+ return(handled);
+}
+
+
+void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my)
+{
+ LOG((""));
+}
+
+
+
+void toolbar_get_grect(struct s_toolbar *tb, short which, short opt, GRECT *dst)
+{
+
+}
+
+
+struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
+ enum toolbar_textarea which)
+{
+ return(tb->url.textarea);
+}
+
+
+/* public event handler */
+void toolbar_back_click(struct s_toolbar *tb)
+{
+ assert(input_window != NULL);
-void tb_back_click( struct gui_window * gw )
-{
- struct browser_window *bw = gw->browser->bw;
+ struct browser_window *bw = input_window->browser->bw;
if( history_back_available(bw->history) )
history_back(bw, bw->history);
}
-void tb_reload_click( struct gui_window * gw )
+void toolbar_reload_click(struct s_toolbar *tb)
{
- browser_window_reload( gw->browser->bw, true );
+ assert(input_window != NULL);
+ browser_window_reload(input_window->browser->bw, true);
}
-void tb_forward_click( struct gui_window * gw )
-{
- struct browser_window *bw = gw->browser->bw;
+void toolbar_forward_click(struct s_toolbar *tb)
+{
+ assert(input_window != NULL);
+ struct browser_window *bw = input_window->browser->bw;
if (history_forward_available(bw->history))
history_forward(bw, bw->history);
}
-void tb_home_click( struct gui_window * gw )
+void toolbar_home_click(struct s_toolbar *tb)
{
- browser_window_go(gw->browser->bw, option_homepage_url, 0, true);
+ assert(input_window != NULL);
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ bw = gw->browser->bw;
+ browser_window_go(bw, option_homepage_url, 0, true);
}
-void tb_stop_click( struct gui_window * gw )
+void toolbar_stop_click(struct s_toolbar *tb)
{
- browser_window_stop(gw->browser->bw);
+ assert(input_window != NULL);
+ browser_window_stop(input_window->browser->bw);
}
-
-void tb_hide( struct gui_window * gw, short mode )
-{
- CMP_TOOLBAR tb = gw->root->toolbar;
- assert( tb != NULL );
- if( mode == 1 ){
- tb->hidden = true;
- tb->comp->rect.g_h = 0;
- tb->comp->bounds.max_height = 0;
-
- } else {
- tb->hidden = false;
- tb->comp->rect.g_h = toolbar_styles[tb->style].height;
- tb->comp->bounds.max_height = toolbar_styles[tb->style].height;
- }
- gw->browser->reformat_pending = true;
- browser_update_rects( gw );
- snd_rdw( gw->root->handle );
-}
-
diff --git a/atari/toolbar.h b/atari/toolbar.h
old mode 100755
new mode 100644
index 7f86408..7cc7b92
--- a/atari/toolbar.h
+++ b/atari/toolbar.h
@@ -1,118 +1,38 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * 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/>.
- */
-
-#ifndef NS_ATARI_TOOLBAR_H
+#ifndef NS_ATARI_TOOLBAR_H
#define NS_ATARI_TOOLBAR_H
+#include <stdbool.h>
+#include <stdint.h>
+
#include "desktop/textarea.h"
-#include "desktop/textinput.h"
-#include "content/hlcache.h"
-#include "atari/browser.h"
-
-#define TB_BUTTON_WIDTH 32
-#define THROBBER_WIDTH 32
-#define THROBBER_MIN_INDEX 1
-#define THROBBER_MAX_INDEX 12
-#define THROBBER_INACTIVE_INDEX 13
+#include "desktop/browser.h"
-#define TOOLBAR_URL_MARGIN_LEFT 2
-#define TOOLBAR_URL_MARGIN_RIGHT 2
-#define TOOLBAR_URL_MARGIN_TOP 2
-#define TOOLBAR_URL_MARGIN_BOTTOM 2
-
-enum e_toolbar_button_states {
- button_on = 0,
- button_off = 1
-};
-#define TOOLBAR_BUTTON_NUM_STATES 2
-
-struct s_tb_button
-{
- short rsc_id;
- void (*cb_click)(struct gui_window * gw);
- COMPONENT * comp;
- hlcache_handle * icon[TOOLBAR_BUTTON_NUM_STATES];
- struct gui_window * gw;
- short state;
- short index;
-};
-
-
-struct s_url_widget
-{
- bool redraw; /* widget is only redrawn when this flag is set */
- struct text_area *textarea;
- COMPONENT * comp;
- GRECT rdw_area;
-};
-
-struct s_throbber_widget
-{
- COMPONENT * comp;
- short index;
- short max_index;
- bool running;
-};
+struct s_toolbar;
-struct s_toolbar
-{
- COMPONENT * comp;
- struct gui_window * owner;
- struct s_url_widget url;
- struct s_throbber_widget throbber;
- GRECT btdim;
- /* size & location of buttons: */
- struct s_tb_button * buttons;
- bool hidden;
- int btcnt;
- int style;
- bool redraw;
-};
+enum toolbar_textarea {
+ URL_INPUT_TEXT_AREA = 1
+};
-/* interface to the toolbar */
-
-/* Must be called before any other toolbar function is called: */
-void toolbar_init( void );
-/*Must be called when netsurf exits to free toolbar resources: */
+void toolbar_init(void);
+struct s_toolbar *toolbar_create(struct s_gui_win_root *owner);
+void toolbar_destroy(struct s_toolbar * tb);
void toolbar_exit( void );
-CMP_TOOLBAR tb_create( struct gui_window * gw );
-void tb_destroy( CMP_TOOLBAR tb );
-/* recalculate size/position of nested controls within the toolbar: */
-void tb_adjust_size( struct gui_window * gw );
-/* report click to toolbar, relative coords : */
-void tb_click( struct gui_window * gw, short mx, short my, short mb, short kstat );
-void tb_back_click( struct gui_window * gw );
-void tb_reload_click( struct gui_window * gw );
-void tb_forward_click( struct gui_window * gw );
-void tb_home_click( struct gui_window * gw );
-void tb_stop_click( struct gui_window * gw );
-/* enable / disable buttons etc. */
-void tb_update_buttons( struct gui_window * gw, short buttonid );
-/* handles clicks on url widget: */
-void tb_url_click( struct gui_window * gw, short mx, short my, short mb, short kstat );
-/* handle keybd event while url widget has focus:*/
-bool tb_url_input( struct gui_window * gw, short keycode );
-/* set the url: */
-void tb_url_set( struct gui_window * gw, char * text );
-/* perform redraw of invalidated url textinput areas: */
-void tb_url_redraw( struct gui_window * gw );
-struct gui_window * tb_gui_window( CMP_TOOLBAR tb );
-/* hide toolbar, mode = 1: hide, mode = 0: show */
-void tb_hide( struct gui_window * gw, short mode );
-
-#endif
+void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area);
+void toolbar_set_url(struct s_toolbar *tb, const char *text);
+bool toolbar_text_input(struct s_toolbar *tb, char *text);
+bool toolbar_key_input(struct s_toolbar *tb, short nkc);
+void toolbar_mouse_input(struct s_toolbar *tb, short mx, short my);
+void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
+ short idx);
+void toolbar_get_grect(struct s_toolbar *tb, short which, short opt, GRECT *g);
+struct text_area *toolbar_get_textarea(struct s_toolbar *tb,
+ enum toolbar_textarea which);
+/* public events handlers: */
+void toolbar_back_click(struct s_toolbar *tb);
+void toolbar_reload_click(struct s_toolbar *tb);
+void toolbar_forward_click(struct s_toolbar *tb);
+void toolbar_home_click(struct s_toolbar *tb);
+void toolbar_stop_click(struct s_toolbar *tb);
+
+
+#endif
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. fefc9ed6bea667d9ed2a8c02e8aafb2ab9e60e31
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/fefc9ed6bea667d9ed2a8...
...commit http://git.netsurf-browser.org/netsurf.git/commit/fefc9ed6bea667d9ed2a8c0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/fefc9ed6bea667d9ed2a8c02e...
The branch, master has been updated
via fefc9ed6bea667d9ed2a8c02e8aafb2ab9e60e31 (commit)
via 567017898c06b8c74c29580b6817899922f95d24 (commit)
via f9d94af893c83e7083065c12a643c798089ff6d8 (commit)
from fb13fcf16648a0e5ba71ac64f9c0441f0516004a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/fefc9ed6bea667d9ed2...
commit fefc9ed6bea667d9ed2a8c02e8aafb2ab9e60e31
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
html renderer error path fixups for meta refresh
diff --git a/render/html.c b/render/html.c
index b5896e1..548295c 100644
--- a/render/html.c
+++ b/render/html.c
@@ -1049,17 +1049,20 @@ static nserror html_meta_refresh_process_element(html_content *c, dom_node *n)
* \return true on success, false otherwise (error reported)
*/
-static bool html_meta_refresh(html_content *c, dom_node *head)
+static nserror html_meta_refresh(html_content *c, dom_node *head)
{
dom_node *n, *next;
dom_exception exc;
+ nserror ns_error = NSERROR_OK;
- if (head == NULL)
- return true;
+ if (head == NULL) {
+ return ns_error;
+ }
exc = dom_node_get_first_child(head, &n);
- if (exc != DOM_NO_ERR)
- return false;
+ if (exc != DOM_NO_ERR) {
+ return NSERROR_DOM;
+ }
while (n != NULL) {
dom_node_type type;
@@ -1067,7 +1070,7 @@ static bool html_meta_refresh(html_content *c, dom_node *head)
exc = dom_node_get_node_type(n, &type);
if (exc != DOM_NO_ERR) {
dom_node_unref(n);
- return false;
+ return NSERROR_DOM;
}
if (type == DOM_ELEMENT_NODE) {
@@ -1076,36 +1079,35 @@ static bool html_meta_refresh(html_content *c, dom_node *head)
exc = dom_node_get_node_name(n, &name);
if (exc != DOM_NO_ERR) {
dom_node_unref(n);
- return false;
+ return NSERROR_DOM;
}
/* Recurse into noscript elements */
- if (dom_string_caseless_lwc_isequal(name,
- corestring_lwc_noscript)) {
- if (html_meta_refresh(c, n) == false) {
+ if (dom_string_caseless_lwc_isequal(name, corestring_lwc_noscript)) {
+ ns_error = html_meta_refresh(c, n);
+ if (ns_error != NSERROR_OK) {
/* Some error occurred */
dom_string_unref(name);
dom_node_unref(n);
- return false;
- } else if (c->base.refresh) {
+ return ns_error;
+ } else if (c->base.refresh != NULL) {
/* Meta refresh found - stop */
dom_string_unref(name);
dom_node_unref(n);
- return true;
+ return NSERROR_OK;
}
- } else if (dom_string_caseless_lwc_isequal(name,
- corestring_lwc_meta)) {
- if (html_meta_refresh_process_element(c,
- n) == false) {
+ } else if (dom_string_caseless_lwc_isequal(name, corestring_lwc_meta)) {
+ ns_error = html_meta_refresh_process_element(c, n);
+ if (ns_error != NSERROR_OK) {
/* Some error occurred */
dom_string_unref(name);
dom_node_unref(n);
- return false;
+ return ns_error;
} else if (c->base.refresh != NULL) {
/* Meta refresh found - stop */
dom_string_unref(name);
dom_node_unref(n);
- return true;
+ return NSERROR_OK;
}
}
dom_string_unref(name);
@@ -1114,14 +1116,14 @@ static bool html_meta_refresh(html_content *c, dom_node *head)
exc = dom_node_get_next_sibling(n, &next);
if (exc != DOM_NO_ERR) {
dom_node_unref(n);
- return false;
+ return NSERROR_DOM;
}
dom_node_unref(n);
n = next;
}
- return true;
+ return ns_error;
}
/**
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/567017898c06b8c74c2...
commit 567017898c06b8c74c29580b6817899922f95d24
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
remove example binding its out of date and in nsgenbind anyway
diff --git a/javascript/jsapi/example.bnd b/javascript/jsapi/example.bnd
deleted file mode 100644
index f2f81fb..0000000
--- a/javascript/jsapi/example.bnd
+++ /dev/null
@@ -1,229 +0,0 @@
-/* Example binding to generate Example interface
- *
- * The js_libdom (javascript to libdom) binding type is currently the
- * only one implemented and this principly describes that binding.
- *
- * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * Released under the terms of the MIT License,
- * http://www.opensource.org/licenses/mit-license
- */
-
-/* additional binding fragments may be included
- * Note: this is not preprocessed despite the #include name, the
- * parser will simply switch input to the included file and carry on
- * cosntructing the bindings Abstract Syntax Tree (AST)
- */
-#include "dom.bnd"
-
-/* directive to read WebIDL file and add its contents to the webidl AST */
-webidlfile "html.idl";
-
-/* The hdrcomment are added into the geenrated output comment header */
-hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
-hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
-hdrcomment "Released under the terms of the MIT License,";
-hdrcomment " http://www.opensource.org/licenses/mit-license";
-
-/* the preamble block is copied verbatum into the generated output
- *
- * This can be used for includes, comments or whatever else is desired
- */
-preamble %{
-
-#include <dom/dom.h>
-
-#include "utils/config.h"
-#include "utils/log.h"
-
-#include "javascript/jsapi.h"
-#include "javascript/jsapi/binding.h"
-
-%}
-
-/* this block describes the binding to be generated
- *
- * Depending on the type of binding being generated multiple blocks
- * may be allowed.
- *
- * Note: the js_libdom (javascript to libdom) binding as currently
- * implemented only allows for a single binding per file, this may
- * be improved in future.
- */
-binding example {
- type js_libdom; /* the binding type */
-
- interface Navigator; /* The WebIDL interface to generate a binding for */
-
- /* private members:
- * - stored in private context structure.
- * - passed as parameters to constructor and stored automatically.
- * - are *not* considered for property getters/setters.
- */
- private "dom_document *" node;
-
- /* internal members:
- * - value stored in private context structure
- * - not passed to constructor
- * - must be instantiated by constructor
- * - are considered for property getters/setters.
- */
- internal "void *" fluff;
-
-}
-
-/* operation implementation code.
- *
- * The body is copied verbatum into operation binding
- *
- * several values are generated automatically:
- *
- * - The generated operations use a macro to create a JSNative JSAPI
- * callback. The interface allows a uniform interface despite the
- * evolution of the interface over differing spidermonkey versions.
- *
- * - The above implies the javascript context is in a variable called cx
- *
- * - If private or internal binding members are present they may be
- * accessed through a structure named "private"
- *
- * - if there are arguemnts they may be accesed via an argc/argv jsval
- * vector.
- *
- * - Arguments are automatically converted into c variables (named as
- * per the WebIDL names.
- *
- * - Return values (excepting void return types where its omitted) are
- * always named "retval" and are of the appropriate c type. The
- * initial value is set appropriately.
- */
-operation foo %{
- retval = JS_NewStringCopyN(cx, "foo", SLEN("foo"));
-%}
-
-/* property getter implementation code.
- *
- * The body is copied verbatum into property getter binding
- *
- * several values are generated automatically:
- *
- * - The generated operations use a macro to create a JSPropertyOp
- * JSAPI callback. The interface allows a uniform interface despite
- * the evolution of the interface over differing spidermonkey
- * versions.
- *
- * - The above implies the javascript context is available in a
- * variable called "cx".
- *
- * - If private or internal binding members are present they may be
- * accessed through a structure named "private"
- *
- * - Return values (void on a getter is not possible) are always named
- * "retval" and are of the appropriate c type. The initial value is
- * set appropriately.
- *
- * - If the getter is omitted altogether but an internal or private
- * value of the same name appears in the private structure a getter
- * is automatically constructed to return that value.
- */
-getter bar %{
- retval = JS_NewStringCopyN(cx, "bar", SLEN("bar"));
-%}
-
-/* property setter implementation code.
- *
- * The body is copied verbatum into property getter binding
- *
- * several values are generated automatically:
- *
- * - The generated operations use a macro to create a JSPropertyOp
- * JSAPI callback. The interface allows a uniform interface despite
- * the evolution of the interface over differing spidermonkey
- * versions.
- *
- * - The above implies the javascript context is available in a
- * variable called "cx".
- *
- * - If private or internal binding members are present they may be
- * accessed through a structure named "private"
- *
- * - Value to set is placed in a c variable named "setval" of the
- * appropriate type.
- *
- * - Return value, named retval" is a boolean (default true) which
- * indicates if the set was performed.
- *
- * - If the setter is omitted altogether but an internal or private
- * value of the same name appears in the private structure a setter
- * is automatically constructed to assign that value.
- */
-setter baz %{
- printf("%s\n", setval);
-%}
-
-/* implementation of the class initilisation
- *
- * This allows the default JS_InitClass to be overriden - currently
- * only used for the window (global) object to cause all the other class
- * initialisors to be called.
- *
- * function prototype is:
- * JSObject *jsapi_InitClass_HTMLElement(JSContext *cx, JSObject *parent)
- */
-api init %{
- %}
-
-/* implementation of the c instance creation
- *
- * This allows the overriding of the construction of an interface instance.
- *
- * The body is copied verbatum and must return the new object in the
- * "newobject" variable.
- *
- * The base prototype is
- * JSObject *jsapi_new_HTMLElement(JSContext *cx, JSObject *prototype, JSObject *parent, ...)
- * The varadic elements are private variables as specified in the binding
- *
- * If there are private or internal values the private struct is
- * constructed and instantiated. The struct is available during the
- * new function and is automatically attached as the private value to
- * the object.
- *
- * The default implemenattion simply calls JS_NewObject()
- *
- * Note this does *not* rely upon (or even call) the instances
- * javascript constructor allowing the c code to create objects that
- * cannot be instantiated from javascript.
- *
- */
-api new %{
- %}
-
-/* additional code in the instance finalise operation.
- *
- * The body is copied verbatum into the output
- *
- * Prototype is
- * void jsclass_finalize(JSContext *cx, JSObject *obj)
- *
- * private is available (if appropriate) and freed after the body
- */
-api finalise %{
- %}
-
-/* resolver code
- *
- * A resolver is only generated if this api is provided. This is a
- * JSResolveOp with JSCLASS_NEW_RESOLVE specified and must provide a
- * complete implementation.
- *
- * The body is copied verbatum into the output
- *
- * Prototype is:
- * JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp)
- *
- */
-api resolve %{
- %}
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/f9d94af893c83e70830...
commit f9d94af893c83e7083065c12a643c798089ff6d8
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
add correct copyright headers
diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd
index 7ca4948..0ed7ac1 100644
--- a/javascript/jsapi/htmldocument.bnd
+++ b/javascript/jsapi/htmldocument.bnd
@@ -1,10 +1,21 @@
-/* Binding to generate htmldocument */
+/* Binding to generate HTMLdocument interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
#include "dom.bnd"
webidlfile "html.idl";
-hdrcomment "Part of NetSurf Project";
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
preamble %{
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index 3fe2afd..7875ab4 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -1,10 +1,21 @@
-/* binding to generate window */
+/* Binding to generate window interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
#include "dom.bnd"
webidlfile "html.idl";
-hdrcomment "Part of NetSurf Project";
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
preamble %{
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi/example.bnd | 229 -------------------------------------
javascript/jsapi/htmldocument.bnd | 15 ++-
javascript/jsapi/window.bnd | 15 ++-
render/html.c | 44 ++++----
4 files changed, 49 insertions(+), 254 deletions(-)
delete mode 100644 javascript/jsapi/example.bnd
diff --git a/javascript/jsapi/example.bnd b/javascript/jsapi/example.bnd
deleted file mode 100644
index f2f81fb..0000000
--- a/javascript/jsapi/example.bnd
+++ /dev/null
@@ -1,229 +0,0 @@
-/* Example binding to generate Example interface
- *
- * The js_libdom (javascript to libdom) binding type is currently the
- * only one implemented and this principly describes that binding.
- *
- * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * Released under the terms of the MIT License,
- * http://www.opensource.org/licenses/mit-license
- */
-
-/* additional binding fragments may be included
- * Note: this is not preprocessed despite the #include name, the
- * parser will simply switch input to the included file and carry on
- * cosntructing the bindings Abstract Syntax Tree (AST)
- */
-#include "dom.bnd"
-
-/* directive to read WebIDL file and add its contents to the webidl AST */
-webidlfile "html.idl";
-
-/* The hdrcomment are added into the geenrated output comment header */
-hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
-hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
-hdrcomment "Released under the terms of the MIT License,";
-hdrcomment " http://www.opensource.org/licenses/mit-license";
-
-/* the preamble block is copied verbatum into the generated output
- *
- * This can be used for includes, comments or whatever else is desired
- */
-preamble %{
-
-#include <dom/dom.h>
-
-#include "utils/config.h"
-#include "utils/log.h"
-
-#include "javascript/jsapi.h"
-#include "javascript/jsapi/binding.h"
-
-%}
-
-/* this block describes the binding to be generated
- *
- * Depending on the type of binding being generated multiple blocks
- * may be allowed.
- *
- * Note: the js_libdom (javascript to libdom) binding as currently
- * implemented only allows for a single binding per file, this may
- * be improved in future.
- */
-binding example {
- type js_libdom; /* the binding type */
-
- interface Navigator; /* The WebIDL interface to generate a binding for */
-
- /* private members:
- * - stored in private context structure.
- * - passed as parameters to constructor and stored automatically.
- * - are *not* considered for property getters/setters.
- */
- private "dom_document *" node;
-
- /* internal members:
- * - value stored in private context structure
- * - not passed to constructor
- * - must be instantiated by constructor
- * - are considered for property getters/setters.
- */
- internal "void *" fluff;
-
-}
-
-/* operation implementation code.
- *
- * The body is copied verbatum into operation binding
- *
- * several values are generated automatically:
- *
- * - The generated operations use a macro to create a JSNative JSAPI
- * callback. The interface allows a uniform interface despite the
- * evolution of the interface over differing spidermonkey versions.
- *
- * - The above implies the javascript context is in a variable called cx
- *
- * - If private or internal binding members are present they may be
- * accessed through a structure named "private"
- *
- * - if there are arguemnts they may be accesed via an argc/argv jsval
- * vector.
- *
- * - Arguments are automatically converted into c variables (named as
- * per the WebIDL names.
- *
- * - Return values (excepting void return types where its omitted) are
- * always named "retval" and are of the appropriate c type. The
- * initial value is set appropriately.
- */
-operation foo %{
- retval = JS_NewStringCopyN(cx, "foo", SLEN("foo"));
-%}
-
-/* property getter implementation code.
- *
- * The body is copied verbatum into property getter binding
- *
- * several values are generated automatically:
- *
- * - The generated operations use a macro to create a JSPropertyOp
- * JSAPI callback. The interface allows a uniform interface despite
- * the evolution of the interface over differing spidermonkey
- * versions.
- *
- * - The above implies the javascript context is available in a
- * variable called "cx".
- *
- * - If private or internal binding members are present they may be
- * accessed through a structure named "private"
- *
- * - Return values (void on a getter is not possible) are always named
- * "retval" and are of the appropriate c type. The initial value is
- * set appropriately.
- *
- * - If the getter is omitted altogether but an internal or private
- * value of the same name appears in the private structure a getter
- * is automatically constructed to return that value.
- */
-getter bar %{
- retval = JS_NewStringCopyN(cx, "bar", SLEN("bar"));
-%}
-
-/* property setter implementation code.
- *
- * The body is copied verbatum into property getter binding
- *
- * several values are generated automatically:
- *
- * - The generated operations use a macro to create a JSPropertyOp
- * JSAPI callback. The interface allows a uniform interface despite
- * the evolution of the interface over differing spidermonkey
- * versions.
- *
- * - The above implies the javascript context is available in a
- * variable called "cx".
- *
- * - If private or internal binding members are present they may be
- * accessed through a structure named "private"
- *
- * - Value to set is placed in a c variable named "setval" of the
- * appropriate type.
- *
- * - Return value, named retval" is a boolean (default true) which
- * indicates if the set was performed.
- *
- * - If the setter is omitted altogether but an internal or private
- * value of the same name appears in the private structure a setter
- * is automatically constructed to assign that value.
- */
-setter baz %{
- printf("%s\n", setval);
-%}
-
-/* implementation of the class initilisation
- *
- * This allows the default JS_InitClass to be overriden - currently
- * only used for the window (global) object to cause all the other class
- * initialisors to be called.
- *
- * function prototype is:
- * JSObject *jsapi_InitClass_HTMLElement(JSContext *cx, JSObject *parent)
- */
-api init %{
- %}
-
-/* implementation of the c instance creation
- *
- * This allows the overriding of the construction of an interface instance.
- *
- * The body is copied verbatum and must return the new object in the
- * "newobject" variable.
- *
- * The base prototype is
- * JSObject *jsapi_new_HTMLElement(JSContext *cx, JSObject *prototype, JSObject *parent, ...)
- * The varadic elements are private variables as specified in the binding
- *
- * If there are private or internal values the private struct is
- * constructed and instantiated. The struct is available during the
- * new function and is automatically attached as the private value to
- * the object.
- *
- * The default implemenattion simply calls JS_NewObject()
- *
- * Note this does *not* rely upon (or even call) the instances
- * javascript constructor allowing the c code to create objects that
- * cannot be instantiated from javascript.
- *
- */
-api new %{
- %}
-
-/* additional code in the instance finalise operation.
- *
- * The body is copied verbatum into the output
- *
- * Prototype is
- * void jsclass_finalize(JSContext *cx, JSObject *obj)
- *
- * private is available (if appropriate) and freed after the body
- */
-api finalise %{
- %}
-
-/* resolver code
- *
- * A resolver is only generated if this api is provided. This is a
- * JSResolveOp with JSCLASS_NEW_RESOLVE specified and must provide a
- * complete implementation.
- *
- * The body is copied verbatum into the output
- *
- * Prototype is:
- * JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp)
- *
- */
-api resolve %{
- %}
diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd
index 7ca4948..0ed7ac1 100644
--- a/javascript/jsapi/htmldocument.bnd
+++ b/javascript/jsapi/htmldocument.bnd
@@ -1,10 +1,21 @@
-/* Binding to generate htmldocument */
+/* Binding to generate HTMLdocument interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
#include "dom.bnd"
webidlfile "html.idl";
-hdrcomment "Part of NetSurf Project";
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
preamble %{
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index 3fe2afd..7875ab4 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -1,10 +1,21 @@
-/* binding to generate window */
+/* Binding to generate window interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
#include "dom.bnd"
webidlfile "html.idl";
-hdrcomment "Part of NetSurf Project";
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
preamble %{
diff --git a/render/html.c b/render/html.c
index b5896e1..548295c 100644
--- a/render/html.c
+++ b/render/html.c
@@ -1049,17 +1049,20 @@ static nserror html_meta_refresh_process_element(html_content *c, dom_node *n)
* \return true on success, false otherwise (error reported)
*/
-static bool html_meta_refresh(html_content *c, dom_node *head)
+static nserror html_meta_refresh(html_content *c, dom_node *head)
{
dom_node *n, *next;
dom_exception exc;
+ nserror ns_error = NSERROR_OK;
- if (head == NULL)
- return true;
+ if (head == NULL) {
+ return ns_error;
+ }
exc = dom_node_get_first_child(head, &n);
- if (exc != DOM_NO_ERR)
- return false;
+ if (exc != DOM_NO_ERR) {
+ return NSERROR_DOM;
+ }
while (n != NULL) {
dom_node_type type;
@@ -1067,7 +1070,7 @@ static bool html_meta_refresh(html_content *c, dom_node *head)
exc = dom_node_get_node_type(n, &type);
if (exc != DOM_NO_ERR) {
dom_node_unref(n);
- return false;
+ return NSERROR_DOM;
}
if (type == DOM_ELEMENT_NODE) {
@@ -1076,36 +1079,35 @@ static bool html_meta_refresh(html_content *c, dom_node *head)
exc = dom_node_get_node_name(n, &name);
if (exc != DOM_NO_ERR) {
dom_node_unref(n);
- return false;
+ return NSERROR_DOM;
}
/* Recurse into noscript elements */
- if (dom_string_caseless_lwc_isequal(name,
- corestring_lwc_noscript)) {
- if (html_meta_refresh(c, n) == false) {
+ if (dom_string_caseless_lwc_isequal(name, corestring_lwc_noscript)) {
+ ns_error = html_meta_refresh(c, n);
+ if (ns_error != NSERROR_OK) {
/* Some error occurred */
dom_string_unref(name);
dom_node_unref(n);
- return false;
- } else if (c->base.refresh) {
+ return ns_error;
+ } else if (c->base.refresh != NULL) {
/* Meta refresh found - stop */
dom_string_unref(name);
dom_node_unref(n);
- return true;
+ return NSERROR_OK;
}
- } else if (dom_string_caseless_lwc_isequal(name,
- corestring_lwc_meta)) {
- if (html_meta_refresh_process_element(c,
- n) == false) {
+ } else if (dom_string_caseless_lwc_isequal(name, corestring_lwc_meta)) {
+ ns_error = html_meta_refresh_process_element(c, n);
+ if (ns_error != NSERROR_OK) {
/* Some error occurred */
dom_string_unref(name);
dom_node_unref(n);
- return false;
+ return ns_error;
} else if (c->base.refresh != NULL) {
/* Meta refresh found - stop */
dom_string_unref(name);
dom_node_unref(n);
- return true;
+ return NSERROR_OK;
}
}
dom_string_unref(name);
@@ -1114,14 +1116,14 @@ static bool html_meta_refresh(html_content *c, dom_node *head)
exc = dom_node_get_next_sibling(n, &next);
if (exc != DOM_NO_ERR) {
dom_node_unref(n);
- return false;
+ return NSERROR_DOM;
}
dom_node_unref(n);
n = next;
}
- return true;
+ return ns_error;
}
/**
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. fb13fcf16648a0e5ba71ac64f9c0441f0516004a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/fb13fcf16648a0e5ba71a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/fb13fcf16648a0e5ba71ac6...
...tree http://git.netsurf-browser.org/netsurf.git/tree/fb13fcf16648a0e5ba71ac64f...
The branch, master has been updated
via fb13fcf16648a0e5ba71ac64f9c0441f0516004a (commit)
via ce309aa5a9c1f813f6bdf152221f9bff88c4d3e1 (commit)
via 2fef76db1555f49cff7f2baeec7fa084c8a5facb (commit)
from 840284b24d1a03c14592dd907894b136a37c495c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/fb13fcf16648a0e5ba7...
commit fb13fcf16648a0e5ba71ac64f9c0441f0516004a
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
Improve html renderer error reporting
diff --git a/render/box.h b/render/box.h
index 6b1d28d..a4622e3 100644
--- a/render/box.h
+++ b/render/box.h
@@ -339,7 +339,7 @@ bool box_hscrollbar_present(const struct box *box);
nserror box_construct_init(void);
void box_construct_fini(void);
-bool xml_to_box(struct dom_node *n, struct html_content *c,
+nserror dom_to_box(struct dom_node *n, struct html_content *c,
box_construct_complete_cb cb);
bool box_normalise_block(struct box *block, struct html_content *c);
diff --git a/render/box_construct.c b/render/box_construct.c
index 26d9b54..6357587 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -157,10 +157,10 @@ static const struct element_entry element_table[] = {
* \param n xml tree
* \param c content of type CONTENT_HTML to construct box tree in
* \param cb callback to report conversion completion
- * \return true on success, false on memory exhaustion
+ * \return netsurf error code indicating status of call
*/
-bool xml_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
+nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
{
struct box_construct_ctx *ctx;
@@ -168,13 +168,14 @@ bool xml_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
/* create a context allocation for this box tree */
c->bctx = talloc_zero(0, int);
if (c->bctx == NULL) {
- return false;
+ return NSERROR_NOMEM;
}
}
ctx = malloc(sizeof(*ctx));
- if (ctx == NULL)
- return false;
+ if (ctx == NULL) {
+ return NSERROR_NOMEM;
+ }
ctx->content = c;
ctx->n = dom_node_ref(n);
@@ -184,7 +185,7 @@ bool xml_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
schedule(0, (schedule_callback_fn) convert_xml_to_box, ctx);
- return true;
+ return NSERROR_OK;
}
/* mapping from CSS display to box type
diff --git a/render/html.c b/render/html.c
index 6c6dcdf..b5896e1 100644
--- a/render/html.c
+++ b/render/html.c
@@ -78,6 +78,93 @@ static nsurl *html_adblock_stylesheet_url;
static nsurl *html_quirks_stylesheet_url;
static nsurl *html_user_stylesheet_url;
+static nserror css_error_to_nserror(css_error error)
+{
+ switch (error) {
+ case CSS_OK:
+ return NSERROR_OK;
+
+ case CSS_NOMEM:
+ return NSERROR_NOMEM;
+
+ case CSS_BADPARM:
+ return NSERROR_BAD_PARAMETER;
+
+ case CSS_INVALID:
+ return NSERROR_INVALID;
+
+ case CSS_FILENOTFOUND:
+ return NSERROR_NOT_FOUND;
+
+ case CSS_NEEDDATA:
+ return NSERROR_NEED_DATA;
+
+ case CSS_BADCHARSET:
+ return NSERROR_BAD_ENCODING;
+
+ case CSS_EOF:
+ case CSS_IMPORTS_PENDING:
+ case CSS_PROPERTY_NOT_SET:
+ default:
+ break;
+ }
+ return NSERROR_CSS;
+}
+
+static nserror
+dom_hubbub_error_to_nserror(dom_hubbub_error error)
+{
+ switch (error) {
+
+ /* HUBBUB_REPROCESS is not handled here because it can
+ * never occur outside the hubbub treebuilder
+ */
+
+ case DOM_HUBBUB_OK:
+ /* parsed ok */
+ return NSERROR_OK;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED):
+ /* hubbub input paused */
+ return NSERROR_OK;
+
+ case DOM_HUBBUB_NOMEM:
+ /* out of memory error from DOM */
+ return NSERROR_NOMEM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE):
+ /* encoding changed */
+ return NSERROR_ENCODING_CHANGE;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM):
+ /* out of memory error from parser */
+ return NSERROR_NOMEM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM):
+ return NSERROR_BAD_PARAMETER;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID):
+ return NSERROR_INVALID;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND):
+ return NSERROR_NOT_FOUND;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA):
+ return NSERROR_NEED_DATA;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING):
+ return NSERROR_BAD_ENCODING;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN):
+ /* currently only generated by the libdom hubbub binding */
+ return NSERROR_DOM;
+ default:
+ /* unknown error */
+ /** @todo better error handling and reporting */
+ return NSERROR_UNKNOWN;
+ }
+ return NSERROR_UNKNOWN;
+}
static void html_destroy_objects(html_content *html)
{
@@ -106,7 +193,7 @@ static void html_destroy_objects(html_content *html)
*/
static void html_box_convert_done(html_content *c, bool success)
{
- union content_msg_data msg_data;
+ nserror err;
dom_exception exc; /* returned by libdom functions */
dom_node *html;
@@ -114,17 +201,19 @@ static void html_box_convert_done(html_content *c, bool success)
/* Clean up and report error if unsuccessful or aborted */
if ((success == false) || (c->aborted)) {
+ html_destroy_objects(c);
+
if (success == false) {
- msg_data.errorcode = NSERROR_BOX_CONVERT;
+ content_broadcast_errorcode(&c->base, NSERROR_BOX_CONVERT);
} else {
- msg_data.errorcode = NSERROR_STOPPED;
+ content_broadcast_errorcode(&c->base, NSERROR_STOPPED);
}
- html_destroy_objects(c);
- content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data);
+
content_set_error(&c->base);
return;
}
+
#if ALWAYS_DUMP_BOX
box_dump(stderr, c->layout->children, 0);
#endif
@@ -139,18 +228,17 @@ static void html_box_convert_done(html_content *c, bool success)
* like the other error paths
*/
LOG(("error retrieving html element from dom"));
- msg_data.errorcode = NSERROR_DOM;
- content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_DOM);
content_set_error(&c->base);
return;
}
- /* extract image maps - can't do this sensibly in xml_to_box */
- msg_data.errorcode = imagemap_extract(c);
- if (msg_data.errorcode != NSERROR_OK) {
+ /* extract image maps - can't do this sensibly in dom_to_box */
+ err = imagemap_extract(c);
+ if (err != NSERROR_OK) {
LOG(("imagemap extraction failed"));
html_destroy_objects(c);
- content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data);
+ content_broadcast_errorcode(&c->base, err);
content_set_error(&c->base);
dom_node_unref(html);
return;
@@ -171,6 +259,7 @@ static void html_box_convert_done(html_content *c, bool success)
dom_node_unref(html);
}
+
/**
* Complete conversion of an HTML document
*
@@ -182,29 +271,28 @@ void html_finish_conversion(html_content *c)
dom_exception exc; /* returned by libdom functions */
dom_node *html;
uint32_t i;
- css_error error;
+ css_error css_ret;
+ nserror error;
/* Bail out if we've been aborted */
if (c->aborted) {
- msg_data.error = messages_get("Stopped");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_STOPPED);
content_set_error(&c->base);
return;
}
/* check that the base stylesheet loaded; layout fails without it */
if (c->stylesheets[STYLESHEET_BASE].data.external == NULL) {
- msg_data.error = "Base stylesheet failed to load";
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_CSS_BASE);
content_set_error(&c->base);
return;
}
/* Create selection context */
- error = css_select_ctx_create(ns_realloc, c, &c->select_ctx);
- if (error != CSS_OK) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ css_ret = css_select_ctx_create(ns_realloc, c, &c->select_ctx);
+ if (css_ret != CSS_OK) {
+ content_broadcast_errorcode(&c->base,
+ css_error_to_nserror(css_ret));
content_set_error(&c->base);
return;
}
@@ -230,21 +318,21 @@ void html_finish_conversion(html_content *c)
}
if (sheet != NULL) {
- error = css_select_ctx_append_sheet(
- c->select_ctx, sheet,
- origin, CSS_MEDIA_SCREEN);
- if (error != CSS_OK) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR,
- msg_data);
+ css_ret = css_select_ctx_append_sheet(c->select_ctx,
+ sheet,
+ origin,
+ CSS_MEDIA_SCREEN);
+ if (css_ret != CSS_OK) {
+ content_broadcast_errorcode(&c->base,
+ css_error_to_nserror(css_ret));
content_set_error(&c->base);
return;
}
}
}
- /* convert xml tree to box tree */
- LOG(("XML to box (%p)", c));
+ /* convert dom tree to box tree */
+ LOG(("DOM to box (%p)", c));
content_set_status(&c->base, messages_get("Processing"));
msg_data.explicit_status_text = NULL;
content_broadcast(&c->base, CONTENT_MSG_STATUS, msg_data);
@@ -252,17 +340,16 @@ void html_finish_conversion(html_content *c)
exc = dom_document_get_document_element(c->document, (void *) &html);
if ((exc != DOM_NO_ERR) || (html == NULL)) {
LOG(("error retrieving html element from dom"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_DOM);
content_set_error(&c->base);
return;
}
- if (xml_to_box(html, c, html_box_convert_done) == false) {
+ error = dom_to_box(html, c, html_box_convert_done);
+ if (error != NSERROR_OK) {
dom_node_unref(html);
html_destroy_objects(c);
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, error);
content_set_error(&c->base);
return;
}
@@ -276,7 +363,6 @@ static nserror
html_create_html_data(html_content *c, const http_parameter *params)
{
lwc_string *charset;
- union content_msg_data msg_data;
nserror nerror;
c->parser = NULL;
@@ -310,9 +396,6 @@ html_create_html_data(html_content *c, const http_parameter *params)
c->base.active = 1; /* The html content itself is active */
if (lwc_intern_string("*", SLEN("*"), &c->universal) != lwc_error_ok) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
-
return NSERROR_NOMEM;
}
@@ -327,10 +410,6 @@ html_create_html_data(html_content *c, const http_parameter *params)
if (c->encoding == NULL) {
lwc_string_unref(c->universal);
c->universal = NULL;
-
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
-
return NSERROR_NOMEM;
}
@@ -367,9 +446,6 @@ html_create_html_data(html_content *c, const http_parameter *params)
lwc_string_unref(c->universal);
c->universal = NULL;
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
-
return NSERROR_NOMEM;
}
@@ -409,6 +485,7 @@ html_create(const content_handler *handler,
error = html_create_html_data(html, params);
if (error != NSERROR_OK) {
+ content_broadcast_errorcode(&html->base, error);
free(html);
return error;
}
@@ -418,60 +495,6 @@ html_create(const content_handler *handler,
return NSERROR_OK;
}
-static nserror
-parse_chunk_to_nserror(dom_hubbub_error error)
-{
- switch (error) {
-
- /* HUBBUB_REPROCESS is not handled here because it can
- * never occur outside the hubbub treebuilder
- */
-
- case DOM_HUBBUB_OK:
- /* parsed ok */
- return NSERROR_OK;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED):
- /* hubbub input paused */
- return NSERROR_OK;
-
- case DOM_HUBBUB_NOMEM:
- /* out of memory error from DOM */
- return NSERROR_NOMEM;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE):
- /* encoding changed */
- return NSERROR_ENCODING_CHANGE;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM):
- /* out of memory error from parser */
- return NSERROR_NOMEM;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM):
- return NSERROR_BAD_PARAMETER;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID):
- return NSERROR_INVALID;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND):
- return NSERROR_NOT_FOUND;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA):
- return NSERROR_NEED_DATA;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING):
- return NSERROR_BAD_ENCODING;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN):
- /* currently only generated by the libdom hubbub binding */
- return NSERROR_DOM;
- default:
- /* unknown error */
- /** @todo better error handling and reporting */
- return NSERROR_UNKNOWN;
- }
- return NSERROR_UNKNOWN;
-}
static nserror
@@ -554,7 +577,7 @@ html_process_encoding_change(struct content *c,
(const uint8_t *)source_data,
source_size);
- return parse_chunk_to_nserror(error);
+ return dom_hubbub_error_to_nserror(error);
}
@@ -566,26 +589,23 @@ static bool
html_process_data(struct content *c, const char *data, unsigned int size)
{
html_content *html = (html_content *) c;
- dom_hubbub_error error;
- union content_msg_data msg_data;
-
- msg_data.errorcode = NSERROR_OK; /* assume its all going to be ok */
+ dom_hubbub_error dom_ret;
+ nserror err = NSERROR_OK; /* assume its all going to be ok */
- error = dom_hubbub_parser_parse_chunk(html->parser,
+ dom_ret = dom_hubbub_parser_parse_chunk(html->parser,
(const uint8_t *) data,
size);
-
- msg_data.errorcode = parse_chunk_to_nserror(error);
+ err = dom_hubbub_error_to_nserror(dom_ret);
/* deal with encoding change */
- if (msg_data.errorcode == NSERROR_ENCODING_CHANGE) {
- msg_data.errorcode = html_process_encoding_change(c, data, size);
+ if (err == NSERROR_ENCODING_CHANGE) {
+ err = html_process_encoding_change(c, data, size);
}
/* broadcast the error if necessary */
- if (msg_data.errorcode != NSERROR_OK) {
- content_broadcast(c, CONTENT_MSG_ERRORCODE, msg_data);
+ if (err != NSERROR_OK) {
+ content_broadcast_errorcode(c, err);
return false;
}
@@ -776,7 +796,7 @@ static bool html_process_base(html_content *c, dom_node *node)
* The title and base href are extracted if present.
*/
-static bool html_head(html_content *c, dom_node *head)
+static nserror html_head(html_content *c, dom_node *head)
{
dom_node *node;
dom_exception exc; /* returned by libdom functions */
@@ -786,7 +806,7 @@ static bool html_head(html_content *c, dom_node *head)
exc = dom_node_get_first_child(head, &node);
if (exc != DOM_NO_ERR) {
- return false;
+ return NSERROR_DOM;
}
while (node != NULL) {
@@ -810,8 +830,9 @@ static bool html_head(html_content *c, dom_node *head)
html_process_link(c, node);
}
}
- if (node_name != NULL)
+ if (node_name != NULL) {
dom_string_unref(node_name);
+ }
}
/* move to next node */
@@ -824,10 +845,10 @@ static bool html_head(html_content *c, dom_node *head)
}
}
- return true;
+ return NSERROR_OK;
}
-static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
+static nserror html_meta_refresh_process_element(html_content *c, dom_node *n)
{
union content_msg_data msg_data;
const char *url, *end, *refresh = NULL;
@@ -836,28 +857,32 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
dom_string *equiv, *content;
dom_exception exc;
nsurl *nsurl;
- nserror error;
+ nserror error = NSERROR_OK;
exc = dom_element_get_attribute(n, corestring_dom_http_equiv, &equiv);
- if (exc != DOM_NO_ERR)
- return false;
+ if (exc != DOM_NO_ERR) {
+ return NSERROR_DOM;
+ }
- if (equiv == NULL)
- return true;
+ if (equiv == NULL) {
+ return NSERROR_OK;
+ }
if (!dom_string_caseless_lwc_isequal(equiv, corestring_lwc_refresh)) {
dom_string_unref(equiv);
- return true;
+ return NSERROR_OK;
}
dom_string_unref(equiv);
exc = dom_element_get_attribute(n, corestring_dom_content, &content);
- if (exc != DOM_NO_ERR)
- return false;
+ if (exc != DOM_NO_ERR) {
+ return NSERROR_DOM;
+ }
- if (content == NULL)
- return true;
+ if (content == NULL) {
+ return NSERROR_OK;
+ }
end = dom_string_data(content) + dom_string_byte_length(content);
@@ -883,15 +908,16 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
if (url == end || (*url < '0' || '9' < *url)) {
/* Empty content, or invalid timeval */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
msg_data.delay = (int) strtol(url, &new_url, 10);
/* a very small delay and self-referencing URL can cause a loop
* that grinds machines to a halt. To prevent this we set a
* minimum refresh delay of 1s. */
- if (msg_data.delay < 1)
+ if (msg_data.delay < 1) {
msg_data.delay = 1;
+ }
url = new_url;
@@ -922,9 +948,9 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
c->base.refresh = nsurl_ref(
content_get_url(&c->base));
- content_broadcast(&c->base, CONTENT_MSG_REFRESH,
- msg_data);
- return true;
+ content_broadcast(&c->base, CONTENT_MSG_REFRESH, msg_data);
+
+ return NSERROR_OK;
}
/* "url" */
@@ -934,12 +960,12 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
} else {
/* Unexpected input, ignore this header */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
} else {
/* Insufficient input, ignore this header */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
/* *LWS */
@@ -954,12 +980,12 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
} else {
/* Unexpected input, ignore this header */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
} else {
/* Insufficient input, ignore this header */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
/* *LWS */
@@ -992,32 +1018,25 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
new_url = strndup(refresh, url - refresh);
if (new_url == NULL) {
dom_string_unref(content);
- return false;
+ return NSERROR_NOMEM;
}
error = nsurl_join(c->base_url, new_url, &nsurl);
- if (error != NSERROR_OK) {
- free(new_url);
-
- dom_string_unref(content);
+ if (error == NSERROR_OK) {
+ /* broadcast valid refresh url */
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR,
- msg_data);
+ c->base.refresh = nsurl;
- return false;
+ content_broadcast(&c->base, CONTENT_MSG_REFRESH, msg_data);
}
free(new_url);
- c->base.refresh = nsurl;
-
- content_broadcast(&c->base, CONTENT_MSG_REFRESH, msg_data);
}
dom_string_unref(content);
- return true;
+ return error;
}
/**
@@ -1556,7 +1575,6 @@ html_process_style_element(html_content *c,
dom_node *child, *next;
dom_string *val;
dom_exception exc;
- union content_msg_data msg_data;
struct html_stylesheet *stylesheets;
struct content_css_data *sheet;
nserror error;
@@ -1609,7 +1627,8 @@ html_process_style_element(html_content *c,
if (error != NSERROR_OK) {
free(sheet);
c->stylesheet_count--;
- goto no_memory;
+ content_broadcast_errorcode(&c->base, error);
+ return false;
}
/* can't just use xmlNodeGetContent(style), because that won't
@@ -1680,8 +1699,7 @@ html_process_style_element(html_content *c,
return true;
no_memory:
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
return false;
}
@@ -1701,7 +1719,6 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx)
dom_string *rel, *type_attr, *media, *href;
struct html_stylesheet *stylesheets;
nsurl *joined;
- union content_msg_data msg_data;
dom_exception exc;
nserror ns_error;
hlcache_child_context child;
@@ -1779,6 +1796,7 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx)
sizeof(struct html_stylesheet) * (ctx->count + 1));
if (stylesheets == NULL) {
nsurl_unref(joined);
+ ns_error = NSERROR_NOMEM;
goto no_memory;
}
@@ -1812,10 +1830,8 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx)
return true;
no_memory:
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&ctx->c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&ctx->c->base, ns_error);
return false;
-
}
@@ -1831,7 +1847,6 @@ no_memory:
static bool html_find_stylesheets(html_content *c, dom_node *html)
{
- union content_msg_data msg_data;
nserror ns_error;
bool result;
struct find_stylesheet_ctx ctx;
@@ -1847,6 +1862,7 @@ static bool html_find_stylesheets(html_content *c, dom_node *html)
* stylesheet 3 is the user stylesheet */
c->stylesheets = calloc(STYLESHEET_START, sizeof(struct html_stylesheet));
if (c->stylesheets == NULL) {
+ ns_error = NSERROR_NOMEM;
goto html_find_stylesheets_no_memory;
}
@@ -1911,7 +1927,6 @@ static bool html_find_stylesheets(html_content *c, dom_node *html)
c->base.active++;
LOG(("%d fetches active", c->base.active));
-
result = libdom_treewalk(html, html_process_stylesheet, &ctx);
assert(c->stylesheet_count == ctx.count);
@@ -1919,8 +1934,7 @@ static bool html_find_stylesheets(html_content *c, dom_node *html)
return result;
html_find_stylesheets_no_memory:
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, ns_error);
return false;
}
@@ -1945,7 +1959,6 @@ static bool html_convert(struct content *c)
htmlc->base.active--; /* the html fetch is no longer active */
LOG(("%d fetches active", htmlc->base.active));
-
/* if there are no active fetches in progress no scripts are
* being fetched or they completed already.
*/
@@ -1953,14 +1966,13 @@ static bool html_convert(struct content *c)
return html_begin_conversion(htmlc);
}
return true;
-
}
bool
html_begin_conversion(html_content *htmlc)
{
dom_node *html, *head;
- union content_msg_data msg_data;
+ nserror ns_error;
struct form *f;
dom_exception exc; /* returned by libdom functions */
dom_string *node_name = NULL;
@@ -1969,19 +1981,28 @@ html_begin_conversion(html_content *htmlc)
/* complete parsing */
error = dom_hubbub_parser_completed(htmlc->parser);
if (error != DOM_HUBBUB_OK) {
- union content_msg_data msg_data;
-
- /** @todo Improve processing of errors */
LOG(("Parsing failed"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ dom_hubbub_error_to_nserror(error));
+
+ return false;
+ }
+
+ /* Give up processing if we've been aborted */
+ if (htmlc->aborted) {
+ content_broadcast_errorcode(&htmlc->base, NSERROR_STOPPED);
return false;
}
+
/* complete script execution */
html_scripts_exec(htmlc);
+ /* fire a simple event that bubbles named DOMContentLoaded at
+ * the Document.
+ */
+
/* quirks mode */
exc = dom_document_get_quirks_mode(htmlc->document, &htmlc->quirks);
if (exc != DOM_NO_ERR) {
@@ -1997,32 +2018,24 @@ html_begin_conversion(html_content *htmlc)
encoding = dom_hubbub_parser_get_encoding(htmlc->parser,
&htmlc->encoding_source);
if (encoding == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ NSERROR_NOMEM);
return false;
}
htmlc->encoding = strdup(encoding);
if (htmlc->encoding == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ NSERROR_NOMEM);
return false;
}
}
- /* Give up processing if we've been aborted */
- if (htmlc->aborted) {
- msg_data.error = messages_get("Stopped");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
- return false;
- }
-
/* locate root element and ensure it is html */
exc = dom_document_get_document_element(htmlc->document, (void *) &html);
if ((exc != DOM_NO_ERR) || (html == NULL)) {
LOG(("error retrieving html element from dom"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base, NSERROR_DOM);
return false;
}
@@ -2032,8 +2045,7 @@ html_begin_conversion(html_content *htmlc)
(!dom_string_caseless_lwc_isequal(node_name,
corestring_lwc_html))) {
LOG(("root element not html"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base, NSERROR_DOM);
dom_node_unref(html);
return false;
}
@@ -2041,16 +2053,20 @@ html_begin_conversion(html_content *htmlc)
head = libdom_find_first_element(html, corestring_lwc_head);
if (head != NULL) {
- if (html_head(htmlc, head) == false) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ ns_error = html_head(htmlc, head);
+ if (ns_error != NSERROR_OK) {
+ content_broadcast_errorcode(&htmlc->base, ns_error);
+
dom_node_unref(html);
dom_node_unref(head);
return false;
}
/* handle meta refresh */
- if (html_meta_refresh(htmlc, head) == false) {
+ ns_error = html_meta_refresh(htmlc, head);
+ if (ns_error != NSERROR_OK) {
+ content_broadcast_errorcode(&htmlc->base, ns_error);
+
dom_node_unref(html);
dom_node_unref(head);
return false;
@@ -2062,21 +2078,23 @@ html_begin_conversion(html_content *htmlc)
(dom_html_document *) htmlc->document);
for (f = htmlc->forms; f != NULL; f = f->prev) {
nsurl *action;
- nserror res;
/* Make all actions absolute */
if (f->action == NULL || f->action[0] == '\0') {
/* HTML5 4.10.22.3 step 9 */
nsurl *doc_addr = content_get_url(&htmlc->base);
- res = nsurl_join(htmlc->base_url,
- nsurl_access(doc_addr), &action);
+ ns_error = nsurl_join(htmlc->base_url,
+ nsurl_access(doc_addr),
+ &action);
} else {
- res = nsurl_join(htmlc->base_url, f->action, &action);
+ ns_error = nsurl_join(htmlc->base_url,
+ f->action,
+ &action);
}
- if (res != NSERROR_OK) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ if (ns_error != NSERROR_OK) {
+ content_broadcast_errorcode(&htmlc->base, ns_error);
+
dom_node_unref(html);
dom_node_unref(head);
return false;
@@ -2086,8 +2104,9 @@ html_begin_conversion(html_content *htmlc)
f->action = strdup(nsurl_access(action));
nsurl_unref(action);
if (f->action == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ NSERROR_NOMEM);
+
dom_node_unref(html);
dom_node_unref(head);
return false;
@@ -2097,10 +2116,8 @@ html_begin_conversion(html_content *htmlc)
if (f->document_charset == NULL) {
f->document_charset = strdup(htmlc->encoding);
if (f->document_charset == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base,
- CONTENT_MSG_ERROR,
- msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ NSERROR_NOMEM);
dom_node_unref(html);
dom_node_unref(head);
return false;
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/ce309aa5a9c1f813f6b...
commit ce309aa5a9c1f813f6bdf152221f9bff88c4d3e1
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
add message retrival of error codes ensuring there are messages for all codes
diff --git a/desktop/browser.c b/desktop/browser.c
index 8948460..6262f24 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1195,99 +1195,7 @@ browser_window_callback_errorcode(hlcache_handle *c,
{
const char* message;
- switch (code) {
- case NSERROR_OK:
- /**< No error */
- message = messages_get("OK");
- break;
-
- case NSERROR_NOMEM:
- /**< Memory exhaustion */
- message = messages_get("NoMemory");
- break;
-
- case NSERROR_NO_FETCH_HANDLER:
- /**< No fetch handler for URL scheme */
- message = messages_get("NoHandler");
- break;
-
- case NSERROR_NOT_FOUND:
- /**< Requested item not found */
- message = messages_get("NotFound");
- break;
-
- case NSERROR_SAVE_FAILED:
- /**< Failed to save data */
- message = messages_get("SaveFailed");
- break;
-
- case NSERROR_CLONE_FAILED:
- /**< Failed to clone handle */
- message = messages_get("CloneFailed");
- break;
-
- case NSERROR_INIT_FAILED:
- /**< Initialisation failed */
- message = messages_get("InitFailed");
- break;
-
- case NSERROR_MNG_ERROR:
- /**< An MNG error occurred */
- message = messages_get("MNGError");
- break;
-
- case NSERROR_BAD_ENCODING:
- /**< The character set is unknown */
- message = messages_get("BadEncoding");
- break;
-
- case NSERROR_NEED_DATA:
- /**< More data needed */
- message = messages_get("NeedData");
- break;
-
- case NSERROR_ENCODING_CHANGE:
- /**< The character set encoding change was unhandled */
- message = messages_get("EncodingChanged");
- break;
-
- case NSERROR_BAD_PARAMETER:
- /**< Bad Parameter */
- message = messages_get("BadParameter");
- break;
-
- case NSERROR_INVALID:
- /**< Invalid data */
- message = messages_get("Invalid");
- break;
-
- case NSERROR_BOX_CONVERT:
- /**< Box conversion failed */
- message = messages_get("BoxConvert");
- break;
-
- case NSERROR_STOPPED:
- /**< Content conversion stopped */
- message = messages_get("Stopped");
- break;
-
- case NSERROR_DOM:
- /**< DOM call returned error */
- message = messages_get("ParsingFail");
- break;
-
- case NSERROR_BAD_URL:
- /**< Bad URL */
- message = messages_get("BadURL");
- break;
-
- default:
- case NSERROR_UNKNOWN:
- /**< Unknown error */
- message = messages_get("Unknown");
- break;
-
- }
+ message = messages_get_errorcode(code);
browser_window_set_status(bw, message);
diff --git a/resources/FatMessages b/resources/FatMessages
index d54acad..45b3086 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -2787,6 +2787,8 @@ de.all.ParsingFail:Dokumentparsing ist fehlgeschlagen.
fr.all.ParsingFail:L'analyse syntaxique du document a échoué.
it.all.ParsingFail:Analisi del documento fallita.
nl.all.ParsingFail:fout bij ontleden van dit document.
+en.all.CSSGeneric:Error processing CSS
+en.all.CSSBase:Base stylesheet failed to load
en.all.BadGIF:Reading GIF failed.
de.all.BadGIF:Lesen einer GIF Datei fehlgeschlagen.
fr.all.BadGIF:Erreur de lecture de GIF.
diff --git a/utils/errors.h b/utils/errors.h
index 9ad613d..7fcb5bd 100644
--- a/utils/errors.h
+++ b/utils/errors.h
@@ -61,6 +61,10 @@ typedef enum {
NSERROR_DOM, /**< DOM call returned error */
+ NSERROR_CSS, /**< CSS call returned error */
+
+ NSERROR_CSS_BASE, /**< CSS base sheet failed */
+
NSERROR_BAD_URL /**< Bad URL */
} nserror;
diff --git a/utils/messages.c b/utils/messages.c
index 5b62912..8ae616b 100644
--- a/utils/messages.c
+++ b/utils/messages.c
@@ -200,3 +200,99 @@ const char *messages_get(const char *key)
{
return messages_get_ctx(key, messages_hash);
}
+
+
+/**
+ * lookup of a message by errorcode from the standard Messages hash.
+ *
+ * \param code errorcode of message
+ * \return message text
+ */
+
+const char *messages_get_errorcode(nserror code)
+{
+ switch (code) {
+ case NSERROR_OK:
+ /**< No error */
+ return messages_get_ctx("OK", messages_hash);
+
+ case NSERROR_NOMEM:
+ /**< Memory exhaustion */
+ return messages_get_ctx("NoMemory", messages_hash);
+
+ case NSERROR_NO_FETCH_HANDLER:
+ /**< No fetch handler for URL scheme */
+ return messages_get_ctx("NoHandler", messages_hash);
+
+ case NSERROR_NOT_FOUND:
+ /**< Requested item not found */
+ return messages_get_ctx("NotFound", messages_hash);
+
+ case NSERROR_SAVE_FAILED:
+ /**< Failed to save data */
+ return messages_get_ctx("SaveFailed", messages_hash);
+
+ case NSERROR_CLONE_FAILED:
+ /**< Failed to clone handle */
+ return messages_get_ctx("CloneFailed", messages_hash);
+
+ case NSERROR_INIT_FAILED:
+ /**< Initialisation failed */
+ return messages_get_ctx("InitFailed", messages_hash);
+
+ case NSERROR_MNG_ERROR:
+ /**< An MNG error occurred */
+ return messages_get_ctx("MNGError", messages_hash);
+
+ case NSERROR_BAD_ENCODING:
+ /**< The character set is unknown */
+ return messages_get_ctx("BadEncoding", messages_hash);
+
+ case NSERROR_NEED_DATA:
+ /**< More data needed */
+ return messages_get_ctx("NeedData", messages_hash);
+
+ case NSERROR_ENCODING_CHANGE:
+ /**< The character set encoding change was unhandled */
+ return messages_get_ctx("EncodingChanged", messages_hash);
+
+ case NSERROR_BAD_PARAMETER:
+ /**< Bad Parameter */
+ return messages_get_ctx("BadParameter", messages_hash);
+
+ case NSERROR_INVALID:
+ /**< Invalid data */
+ return messages_get_ctx("Invalid", messages_hash);
+
+ case NSERROR_BOX_CONVERT:
+ /**< Box conversion failed */
+ return messages_get_ctx("BoxConvert", messages_hash);
+
+ case NSERROR_STOPPED:
+ /**< Content conversion stopped */
+ return messages_get_ctx("Stopped", messages_hash);
+
+ case NSERROR_DOM:
+ /**< DOM call returned error */
+ return messages_get_ctx("ParsingFail", messages_hash);
+
+ case NSERROR_CSS:
+ /**< CSS call returned error */
+ return messages_get_ctx("CSSGeneric", messages_hash);
+
+ case NSERROR_CSS_BASE:
+ /**< CSS base sheet failed */
+ return messages_get_ctx("CSSBase", messages_hash);
+
+ case NSERROR_BAD_URL:
+ /**< Bad URL */
+ return messages_get_ctx("BadURL", messages_hash);
+
+ default:
+ case NSERROR_UNKNOWN:
+ break;
+ }
+
+ /**< Unknown error */
+ return messages_get_ctx("Unknown", messages_hash);
+}
diff --git a/utils/messages.h b/utils/messages.h
index 2b78d07..81c3805 100644
--- a/utils/messages.h
+++ b/utils/messages.h
@@ -33,6 +33,7 @@
#ifndef _NETSURF_UTILS_MESSAGES_H_
#define _NETSURF_UTILS_MESSAGES_H_
+#include "utils/errors.h"
#include "utils/hashtable.h"
void messages_load(const char *path);
@@ -41,6 +42,14 @@ const char *messages_get_ctx(const char *key, struct hash_table *ctx);
const char *messages_get(const char *key);
/**
+ * lookup of a message by errorcode from the standard Messages hash.
+ *
+ * \param code errorcode of message
+ * \return message text
+ */
+const char *messages_get_errorcode(nserror code);
+
+/**
* Formatted message from a key in the global message hash.
*
* \param key key of message
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/2fef76db1555f49cff7...
commit 2fef76db1555f49cff7f2baeec7fa084c8a5facb
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
add errorcode content broadcast API
diff --git a/content/content.c b/content/content.c
index 353abee..1a92e40 100644
--- a/content/content.c
+++ b/content/content.c
@@ -678,6 +678,23 @@ void content_broadcast(struct content *c, content_msg msg,
}
}
+/* exported interface documented in content_protected.h */
+void content_broadcast_errorcode(struct content *c, nserror errorcode)
+{
+ struct content_user *user, *next;
+ union content_msg_data data;
+
+ assert(c);
+
+ data.errorcode = errorcode;
+
+ for (user = c->user_list->next; user != 0; user = next) {
+ next = user->next; /* user may be destroyed during callback */
+ if (user->callback != 0)
+ user->callback(c, CONTENT_MSG_ERRORCODE, data, user->pw);
+ }
+}
+
/**
* A window containing the content has been opened.
diff --git a/content/content_protected.h b/content/content_protected.h
index e399797..ecbe17f 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -160,6 +160,11 @@ void content_set_error(struct content *c);
void content_set_status(struct content *c, const char *status_message);
void content_broadcast(struct content *c, content_msg msg,
union content_msg_data data);
+/**
+ * Send an errorcode message to all users.
+ */
+void content_broadcast_errorcode(struct content *c, nserror errorcode);
+
void content_add_error(struct content *c, const char *token,
unsigned int line);
-----------------------------------------------------------------------
Summary of changes:
content/content.c | 17 ++
content/content_protected.h | 5 +
desktop/browser.c | 94 +----------
render/box.h | 2 +-
render/box_construct.c | 13 +-
render/html.c | 417 ++++++++++++++++++++++---------------------
resources/FatMessages | 2 +
utils/errors.h | 4 +
utils/messages.c | 96 ++++++++++
utils/messages.h | 9 +
10 files changed, 359 insertions(+), 300 deletions(-)
diff --git a/content/content.c b/content/content.c
index 353abee..1a92e40 100644
--- a/content/content.c
+++ b/content/content.c
@@ -678,6 +678,23 @@ void content_broadcast(struct content *c, content_msg msg,
}
}
+/* exported interface documented in content_protected.h */
+void content_broadcast_errorcode(struct content *c, nserror errorcode)
+{
+ struct content_user *user, *next;
+ union content_msg_data data;
+
+ assert(c);
+
+ data.errorcode = errorcode;
+
+ for (user = c->user_list->next; user != 0; user = next) {
+ next = user->next; /* user may be destroyed during callback */
+ if (user->callback != 0)
+ user->callback(c, CONTENT_MSG_ERRORCODE, data, user->pw);
+ }
+}
+
/**
* A window containing the content has been opened.
diff --git a/content/content_protected.h b/content/content_protected.h
index e399797..ecbe17f 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -160,6 +160,11 @@ void content_set_error(struct content *c);
void content_set_status(struct content *c, const char *status_message);
void content_broadcast(struct content *c, content_msg msg,
union content_msg_data data);
+/**
+ * Send an errorcode message to all users.
+ */
+void content_broadcast_errorcode(struct content *c, nserror errorcode);
+
void content_add_error(struct content *c, const char *token,
unsigned int line);
diff --git a/desktop/browser.c b/desktop/browser.c
index 8948460..6262f24 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1195,99 +1195,7 @@ browser_window_callback_errorcode(hlcache_handle *c,
{
const char* message;
- switch (code) {
- case NSERROR_OK:
- /**< No error */
- message = messages_get("OK");
- break;
-
- case NSERROR_NOMEM:
- /**< Memory exhaustion */
- message = messages_get("NoMemory");
- break;
-
- case NSERROR_NO_FETCH_HANDLER:
- /**< No fetch handler for URL scheme */
- message = messages_get("NoHandler");
- break;
-
- case NSERROR_NOT_FOUND:
- /**< Requested item not found */
- message = messages_get("NotFound");
- break;
-
- case NSERROR_SAVE_FAILED:
- /**< Failed to save data */
- message = messages_get("SaveFailed");
- break;
-
- case NSERROR_CLONE_FAILED:
- /**< Failed to clone handle */
- message = messages_get("CloneFailed");
- break;
-
- case NSERROR_INIT_FAILED:
- /**< Initialisation failed */
- message = messages_get("InitFailed");
- break;
-
- case NSERROR_MNG_ERROR:
- /**< An MNG error occurred */
- message = messages_get("MNGError");
- break;
-
- case NSERROR_BAD_ENCODING:
- /**< The character set is unknown */
- message = messages_get("BadEncoding");
- break;
-
- case NSERROR_NEED_DATA:
- /**< More data needed */
- message = messages_get("NeedData");
- break;
-
- case NSERROR_ENCODING_CHANGE:
- /**< The character set encoding change was unhandled */
- message = messages_get("EncodingChanged");
- break;
-
- case NSERROR_BAD_PARAMETER:
- /**< Bad Parameter */
- message = messages_get("BadParameter");
- break;
-
- case NSERROR_INVALID:
- /**< Invalid data */
- message = messages_get("Invalid");
- break;
-
- case NSERROR_BOX_CONVERT:
- /**< Box conversion failed */
- message = messages_get("BoxConvert");
- break;
-
- case NSERROR_STOPPED:
- /**< Content conversion stopped */
- message = messages_get("Stopped");
- break;
-
- case NSERROR_DOM:
- /**< DOM call returned error */
- message = messages_get("ParsingFail");
- break;
-
- case NSERROR_BAD_URL:
- /**< Bad URL */
- message = messages_get("BadURL");
- break;
-
- default:
- case NSERROR_UNKNOWN:
- /**< Unknown error */
- message = messages_get("Unknown");
- break;
-
- }
+ message = messages_get_errorcode(code);
browser_window_set_status(bw, message);
diff --git a/render/box.h b/render/box.h
index 6b1d28d..a4622e3 100644
--- a/render/box.h
+++ b/render/box.h
@@ -339,7 +339,7 @@ bool box_hscrollbar_present(const struct box *box);
nserror box_construct_init(void);
void box_construct_fini(void);
-bool xml_to_box(struct dom_node *n, struct html_content *c,
+nserror dom_to_box(struct dom_node *n, struct html_content *c,
box_construct_complete_cb cb);
bool box_normalise_block(struct box *block, struct html_content *c);
diff --git a/render/box_construct.c b/render/box_construct.c
index 26d9b54..6357587 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -157,10 +157,10 @@ static const struct element_entry element_table[] = {
* \param n xml tree
* \param c content of type CONTENT_HTML to construct box tree in
* \param cb callback to report conversion completion
- * \return true on success, false on memory exhaustion
+ * \return netsurf error code indicating status of call
*/
-bool xml_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
+nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
{
struct box_construct_ctx *ctx;
@@ -168,13 +168,14 @@ bool xml_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
/* create a context allocation for this box tree */
c->bctx = talloc_zero(0, int);
if (c->bctx == NULL) {
- return false;
+ return NSERROR_NOMEM;
}
}
ctx = malloc(sizeof(*ctx));
- if (ctx == NULL)
- return false;
+ if (ctx == NULL) {
+ return NSERROR_NOMEM;
+ }
ctx->content = c;
ctx->n = dom_node_ref(n);
@@ -184,7 +185,7 @@ bool xml_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
schedule(0, (schedule_callback_fn) convert_xml_to_box, ctx);
- return true;
+ return NSERROR_OK;
}
/* mapping from CSS display to box type
diff --git a/render/html.c b/render/html.c
index 6c6dcdf..b5896e1 100644
--- a/render/html.c
+++ b/render/html.c
@@ -78,6 +78,93 @@ static nsurl *html_adblock_stylesheet_url;
static nsurl *html_quirks_stylesheet_url;
static nsurl *html_user_stylesheet_url;
+static nserror css_error_to_nserror(css_error error)
+{
+ switch (error) {
+ case CSS_OK:
+ return NSERROR_OK;
+
+ case CSS_NOMEM:
+ return NSERROR_NOMEM;
+
+ case CSS_BADPARM:
+ return NSERROR_BAD_PARAMETER;
+
+ case CSS_INVALID:
+ return NSERROR_INVALID;
+
+ case CSS_FILENOTFOUND:
+ return NSERROR_NOT_FOUND;
+
+ case CSS_NEEDDATA:
+ return NSERROR_NEED_DATA;
+
+ case CSS_BADCHARSET:
+ return NSERROR_BAD_ENCODING;
+
+ case CSS_EOF:
+ case CSS_IMPORTS_PENDING:
+ case CSS_PROPERTY_NOT_SET:
+ default:
+ break;
+ }
+ return NSERROR_CSS;
+}
+
+static nserror
+dom_hubbub_error_to_nserror(dom_hubbub_error error)
+{
+ switch (error) {
+
+ /* HUBBUB_REPROCESS is not handled here because it can
+ * never occur outside the hubbub treebuilder
+ */
+
+ case DOM_HUBBUB_OK:
+ /* parsed ok */
+ return NSERROR_OK;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED):
+ /* hubbub input paused */
+ return NSERROR_OK;
+
+ case DOM_HUBBUB_NOMEM:
+ /* out of memory error from DOM */
+ return NSERROR_NOMEM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE):
+ /* encoding changed */
+ return NSERROR_ENCODING_CHANGE;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM):
+ /* out of memory error from parser */
+ return NSERROR_NOMEM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM):
+ return NSERROR_BAD_PARAMETER;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID):
+ return NSERROR_INVALID;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND):
+ return NSERROR_NOT_FOUND;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA):
+ return NSERROR_NEED_DATA;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING):
+ return NSERROR_BAD_ENCODING;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN):
+ /* currently only generated by the libdom hubbub binding */
+ return NSERROR_DOM;
+ default:
+ /* unknown error */
+ /** @todo better error handling and reporting */
+ return NSERROR_UNKNOWN;
+ }
+ return NSERROR_UNKNOWN;
+}
static void html_destroy_objects(html_content *html)
{
@@ -106,7 +193,7 @@ static void html_destroy_objects(html_content *html)
*/
static void html_box_convert_done(html_content *c, bool success)
{
- union content_msg_data msg_data;
+ nserror err;
dom_exception exc; /* returned by libdom functions */
dom_node *html;
@@ -114,17 +201,19 @@ static void html_box_convert_done(html_content *c, bool success)
/* Clean up and report error if unsuccessful or aborted */
if ((success == false) || (c->aborted)) {
+ html_destroy_objects(c);
+
if (success == false) {
- msg_data.errorcode = NSERROR_BOX_CONVERT;
+ content_broadcast_errorcode(&c->base, NSERROR_BOX_CONVERT);
} else {
- msg_data.errorcode = NSERROR_STOPPED;
+ content_broadcast_errorcode(&c->base, NSERROR_STOPPED);
}
- html_destroy_objects(c);
- content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data);
+
content_set_error(&c->base);
return;
}
+
#if ALWAYS_DUMP_BOX
box_dump(stderr, c->layout->children, 0);
#endif
@@ -139,18 +228,17 @@ static void html_box_convert_done(html_content *c, bool success)
* like the other error paths
*/
LOG(("error retrieving html element from dom"));
- msg_data.errorcode = NSERROR_DOM;
- content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_DOM);
content_set_error(&c->base);
return;
}
- /* extract image maps - can't do this sensibly in xml_to_box */
- msg_data.errorcode = imagemap_extract(c);
- if (msg_data.errorcode != NSERROR_OK) {
+ /* extract image maps - can't do this sensibly in dom_to_box */
+ err = imagemap_extract(c);
+ if (err != NSERROR_OK) {
LOG(("imagemap extraction failed"));
html_destroy_objects(c);
- content_broadcast(&c->base, CONTENT_MSG_ERRORCODE, msg_data);
+ content_broadcast_errorcode(&c->base, err);
content_set_error(&c->base);
dom_node_unref(html);
return;
@@ -171,6 +259,7 @@ static void html_box_convert_done(html_content *c, bool success)
dom_node_unref(html);
}
+
/**
* Complete conversion of an HTML document
*
@@ -182,29 +271,28 @@ void html_finish_conversion(html_content *c)
dom_exception exc; /* returned by libdom functions */
dom_node *html;
uint32_t i;
- css_error error;
+ css_error css_ret;
+ nserror error;
/* Bail out if we've been aborted */
if (c->aborted) {
- msg_data.error = messages_get("Stopped");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_STOPPED);
content_set_error(&c->base);
return;
}
/* check that the base stylesheet loaded; layout fails without it */
if (c->stylesheets[STYLESHEET_BASE].data.external == NULL) {
- msg_data.error = "Base stylesheet failed to load";
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_CSS_BASE);
content_set_error(&c->base);
return;
}
/* Create selection context */
- error = css_select_ctx_create(ns_realloc, c, &c->select_ctx);
- if (error != CSS_OK) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ css_ret = css_select_ctx_create(ns_realloc, c, &c->select_ctx);
+ if (css_ret != CSS_OK) {
+ content_broadcast_errorcode(&c->base,
+ css_error_to_nserror(css_ret));
content_set_error(&c->base);
return;
}
@@ -230,21 +318,21 @@ void html_finish_conversion(html_content *c)
}
if (sheet != NULL) {
- error = css_select_ctx_append_sheet(
- c->select_ctx, sheet,
- origin, CSS_MEDIA_SCREEN);
- if (error != CSS_OK) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR,
- msg_data);
+ css_ret = css_select_ctx_append_sheet(c->select_ctx,
+ sheet,
+ origin,
+ CSS_MEDIA_SCREEN);
+ if (css_ret != CSS_OK) {
+ content_broadcast_errorcode(&c->base,
+ css_error_to_nserror(css_ret));
content_set_error(&c->base);
return;
}
}
}
- /* convert xml tree to box tree */
- LOG(("XML to box (%p)", c));
+ /* convert dom tree to box tree */
+ LOG(("DOM to box (%p)", c));
content_set_status(&c->base, messages_get("Processing"));
msg_data.explicit_status_text = NULL;
content_broadcast(&c->base, CONTENT_MSG_STATUS, msg_data);
@@ -252,17 +340,16 @@ void html_finish_conversion(html_content *c)
exc = dom_document_get_document_element(c->document, (void *) &html);
if ((exc != DOM_NO_ERR) || (html == NULL)) {
LOG(("error retrieving html element from dom"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_DOM);
content_set_error(&c->base);
return;
}
- if (xml_to_box(html, c, html_box_convert_done) == false) {
+ error = dom_to_box(html, c, html_box_convert_done);
+ if (error != NSERROR_OK) {
dom_node_unref(html);
html_destroy_objects(c);
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, error);
content_set_error(&c->base);
return;
}
@@ -276,7 +363,6 @@ static nserror
html_create_html_data(html_content *c, const http_parameter *params)
{
lwc_string *charset;
- union content_msg_data msg_data;
nserror nerror;
c->parser = NULL;
@@ -310,9 +396,6 @@ html_create_html_data(html_content *c, const http_parameter *params)
c->base.active = 1; /* The html content itself is active */
if (lwc_intern_string("*", SLEN("*"), &c->universal) != lwc_error_ok) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
-
return NSERROR_NOMEM;
}
@@ -327,10 +410,6 @@ html_create_html_data(html_content *c, const http_parameter *params)
if (c->encoding == NULL) {
lwc_string_unref(c->universal);
c->universal = NULL;
-
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
-
return NSERROR_NOMEM;
}
@@ -367,9 +446,6 @@ html_create_html_data(html_content *c, const http_parameter *params)
lwc_string_unref(c->universal);
c->universal = NULL;
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
-
return NSERROR_NOMEM;
}
@@ -409,6 +485,7 @@ html_create(const content_handler *handler,
error = html_create_html_data(html, params);
if (error != NSERROR_OK) {
+ content_broadcast_errorcode(&html->base, error);
free(html);
return error;
}
@@ -418,60 +495,6 @@ html_create(const content_handler *handler,
return NSERROR_OK;
}
-static nserror
-parse_chunk_to_nserror(dom_hubbub_error error)
-{
- switch (error) {
-
- /* HUBBUB_REPROCESS is not handled here because it can
- * never occur outside the hubbub treebuilder
- */
-
- case DOM_HUBBUB_OK:
- /* parsed ok */
- return NSERROR_OK;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED):
- /* hubbub input paused */
- return NSERROR_OK;
-
- case DOM_HUBBUB_NOMEM:
- /* out of memory error from DOM */
- return NSERROR_NOMEM;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE):
- /* encoding changed */
- return NSERROR_ENCODING_CHANGE;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM):
- /* out of memory error from parser */
- return NSERROR_NOMEM;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM):
- return NSERROR_BAD_PARAMETER;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID):
- return NSERROR_INVALID;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND):
- return NSERROR_NOT_FOUND;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA):
- return NSERROR_NEED_DATA;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING):
- return NSERROR_BAD_ENCODING;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN):
- /* currently only generated by the libdom hubbub binding */
- return NSERROR_DOM;
- default:
- /* unknown error */
- /** @todo better error handling and reporting */
- return NSERROR_UNKNOWN;
- }
- return NSERROR_UNKNOWN;
-}
static nserror
@@ -554,7 +577,7 @@ html_process_encoding_change(struct content *c,
(const uint8_t *)source_data,
source_size);
- return parse_chunk_to_nserror(error);
+ return dom_hubbub_error_to_nserror(error);
}
@@ -566,26 +589,23 @@ static bool
html_process_data(struct content *c, const char *data, unsigned int size)
{
html_content *html = (html_content *) c;
- dom_hubbub_error error;
- union content_msg_data msg_data;
-
- msg_data.errorcode = NSERROR_OK; /* assume its all going to be ok */
+ dom_hubbub_error dom_ret;
+ nserror err = NSERROR_OK; /* assume its all going to be ok */
- error = dom_hubbub_parser_parse_chunk(html->parser,
+ dom_ret = dom_hubbub_parser_parse_chunk(html->parser,
(const uint8_t *) data,
size);
-
- msg_data.errorcode = parse_chunk_to_nserror(error);
+ err = dom_hubbub_error_to_nserror(dom_ret);
/* deal with encoding change */
- if (msg_data.errorcode == NSERROR_ENCODING_CHANGE) {
- msg_data.errorcode = html_process_encoding_change(c, data, size);
+ if (err == NSERROR_ENCODING_CHANGE) {
+ err = html_process_encoding_change(c, data, size);
}
/* broadcast the error if necessary */
- if (msg_data.errorcode != NSERROR_OK) {
- content_broadcast(c, CONTENT_MSG_ERRORCODE, msg_data);
+ if (err != NSERROR_OK) {
+ content_broadcast_errorcode(c, err);
return false;
}
@@ -776,7 +796,7 @@ static bool html_process_base(html_content *c, dom_node *node)
* The title and base href are extracted if present.
*/
-static bool html_head(html_content *c, dom_node *head)
+static nserror html_head(html_content *c, dom_node *head)
{
dom_node *node;
dom_exception exc; /* returned by libdom functions */
@@ -786,7 +806,7 @@ static bool html_head(html_content *c, dom_node *head)
exc = dom_node_get_first_child(head, &node);
if (exc != DOM_NO_ERR) {
- return false;
+ return NSERROR_DOM;
}
while (node != NULL) {
@@ -810,8 +830,9 @@ static bool html_head(html_content *c, dom_node *head)
html_process_link(c, node);
}
}
- if (node_name != NULL)
+ if (node_name != NULL) {
dom_string_unref(node_name);
+ }
}
/* move to next node */
@@ -824,10 +845,10 @@ static bool html_head(html_content *c, dom_node *head)
}
}
- return true;
+ return NSERROR_OK;
}
-static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
+static nserror html_meta_refresh_process_element(html_content *c, dom_node *n)
{
union content_msg_data msg_data;
const char *url, *end, *refresh = NULL;
@@ -836,28 +857,32 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
dom_string *equiv, *content;
dom_exception exc;
nsurl *nsurl;
- nserror error;
+ nserror error = NSERROR_OK;
exc = dom_element_get_attribute(n, corestring_dom_http_equiv, &equiv);
- if (exc != DOM_NO_ERR)
- return false;
+ if (exc != DOM_NO_ERR) {
+ return NSERROR_DOM;
+ }
- if (equiv == NULL)
- return true;
+ if (equiv == NULL) {
+ return NSERROR_OK;
+ }
if (!dom_string_caseless_lwc_isequal(equiv, corestring_lwc_refresh)) {
dom_string_unref(equiv);
- return true;
+ return NSERROR_OK;
}
dom_string_unref(equiv);
exc = dom_element_get_attribute(n, corestring_dom_content, &content);
- if (exc != DOM_NO_ERR)
- return false;
+ if (exc != DOM_NO_ERR) {
+ return NSERROR_DOM;
+ }
- if (content == NULL)
- return true;
+ if (content == NULL) {
+ return NSERROR_OK;
+ }
end = dom_string_data(content) + dom_string_byte_length(content);
@@ -883,15 +908,16 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
if (url == end || (*url < '0' || '9' < *url)) {
/* Empty content, or invalid timeval */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
msg_data.delay = (int) strtol(url, &new_url, 10);
/* a very small delay and self-referencing URL can cause a loop
* that grinds machines to a halt. To prevent this we set a
* minimum refresh delay of 1s. */
- if (msg_data.delay < 1)
+ if (msg_data.delay < 1) {
msg_data.delay = 1;
+ }
url = new_url;
@@ -922,9 +948,9 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
c->base.refresh = nsurl_ref(
content_get_url(&c->base));
- content_broadcast(&c->base, CONTENT_MSG_REFRESH,
- msg_data);
- return true;
+ content_broadcast(&c->base, CONTENT_MSG_REFRESH, msg_data);
+
+ return NSERROR_OK;
}
/* "url" */
@@ -934,12 +960,12 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
} else {
/* Unexpected input, ignore this header */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
} else {
/* Insufficient input, ignore this header */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
/* *LWS */
@@ -954,12 +980,12 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
} else {
/* Unexpected input, ignore this header */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
} else {
/* Insufficient input, ignore this header */
dom_string_unref(content);
- return true;
+ return NSERROR_OK;
}
/* *LWS */
@@ -992,32 +1018,25 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
new_url = strndup(refresh, url - refresh);
if (new_url == NULL) {
dom_string_unref(content);
- return false;
+ return NSERROR_NOMEM;
}
error = nsurl_join(c->base_url, new_url, &nsurl);
- if (error != NSERROR_OK) {
- free(new_url);
-
- dom_string_unref(content);
+ if (error == NSERROR_OK) {
+ /* broadcast valid refresh url */
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR,
- msg_data);
+ c->base.refresh = nsurl;
- return false;
+ content_broadcast(&c->base, CONTENT_MSG_REFRESH, msg_data);
}
free(new_url);
- c->base.refresh = nsurl;
-
- content_broadcast(&c->base, CONTENT_MSG_REFRESH, msg_data);
}
dom_string_unref(content);
- return true;
+ return error;
}
/**
@@ -1556,7 +1575,6 @@ html_process_style_element(html_content *c,
dom_node *child, *next;
dom_string *val;
dom_exception exc;
- union content_msg_data msg_data;
struct html_stylesheet *stylesheets;
struct content_css_data *sheet;
nserror error;
@@ -1609,7 +1627,8 @@ html_process_style_element(html_content *c,
if (error != NSERROR_OK) {
free(sheet);
c->stylesheet_count--;
- goto no_memory;
+ content_broadcast_errorcode(&c->base, error);
+ return false;
}
/* can't just use xmlNodeGetContent(style), because that won't
@@ -1680,8 +1699,7 @@ html_process_style_element(html_content *c,
return true;
no_memory:
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
return false;
}
@@ -1701,7 +1719,6 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx)
dom_string *rel, *type_attr, *media, *href;
struct html_stylesheet *stylesheets;
nsurl *joined;
- union content_msg_data msg_data;
dom_exception exc;
nserror ns_error;
hlcache_child_context child;
@@ -1779,6 +1796,7 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx)
sizeof(struct html_stylesheet) * (ctx->count + 1));
if (stylesheets == NULL) {
nsurl_unref(joined);
+ ns_error = NSERROR_NOMEM;
goto no_memory;
}
@@ -1812,10 +1830,8 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx)
return true;
no_memory:
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&ctx->c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&ctx->c->base, ns_error);
return false;
-
}
@@ -1831,7 +1847,6 @@ no_memory:
static bool html_find_stylesheets(html_content *c, dom_node *html)
{
- union content_msg_data msg_data;
nserror ns_error;
bool result;
struct find_stylesheet_ctx ctx;
@@ -1847,6 +1862,7 @@ static bool html_find_stylesheets(html_content *c, dom_node *html)
* stylesheet 3 is the user stylesheet */
c->stylesheets = calloc(STYLESHEET_START, sizeof(struct html_stylesheet));
if (c->stylesheets == NULL) {
+ ns_error = NSERROR_NOMEM;
goto html_find_stylesheets_no_memory;
}
@@ -1911,7 +1927,6 @@ static bool html_find_stylesheets(html_content *c, dom_node *html)
c->base.active++;
LOG(("%d fetches active", c->base.active));
-
result = libdom_treewalk(html, html_process_stylesheet, &ctx);
assert(c->stylesheet_count == ctx.count);
@@ -1919,8 +1934,7 @@ static bool html_find_stylesheets(html_content *c, dom_node *html)
return result;
html_find_stylesheets_no_memory:
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&c->base, ns_error);
return false;
}
@@ -1945,7 +1959,6 @@ static bool html_convert(struct content *c)
htmlc->base.active--; /* the html fetch is no longer active */
LOG(("%d fetches active", htmlc->base.active));
-
/* if there are no active fetches in progress no scripts are
* being fetched or they completed already.
*/
@@ -1953,14 +1966,13 @@ static bool html_convert(struct content *c)
return html_begin_conversion(htmlc);
}
return true;
-
}
bool
html_begin_conversion(html_content *htmlc)
{
dom_node *html, *head;
- union content_msg_data msg_data;
+ nserror ns_error;
struct form *f;
dom_exception exc; /* returned by libdom functions */
dom_string *node_name = NULL;
@@ -1969,19 +1981,28 @@ html_begin_conversion(html_content *htmlc)
/* complete parsing */
error = dom_hubbub_parser_completed(htmlc->parser);
if (error != DOM_HUBBUB_OK) {
- union content_msg_data msg_data;
-
- /** @todo Improve processing of errors */
LOG(("Parsing failed"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ dom_hubbub_error_to_nserror(error));
+
+ return false;
+ }
+
+ /* Give up processing if we've been aborted */
+ if (htmlc->aborted) {
+ content_broadcast_errorcode(&htmlc->base, NSERROR_STOPPED);
return false;
}
+
/* complete script execution */
html_scripts_exec(htmlc);
+ /* fire a simple event that bubbles named DOMContentLoaded at
+ * the Document.
+ */
+
/* quirks mode */
exc = dom_document_get_quirks_mode(htmlc->document, &htmlc->quirks);
if (exc != DOM_NO_ERR) {
@@ -1997,32 +2018,24 @@ html_begin_conversion(html_content *htmlc)
encoding = dom_hubbub_parser_get_encoding(htmlc->parser,
&htmlc->encoding_source);
if (encoding == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ NSERROR_NOMEM);
return false;
}
htmlc->encoding = strdup(encoding);
if (htmlc->encoding == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ NSERROR_NOMEM);
return false;
}
}
- /* Give up processing if we've been aborted */
- if (htmlc->aborted) {
- msg_data.error = messages_get("Stopped");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
- return false;
- }
-
/* locate root element and ensure it is html */
exc = dom_document_get_document_element(htmlc->document, (void *) &html);
if ((exc != DOM_NO_ERR) || (html == NULL)) {
LOG(("error retrieving html element from dom"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base, NSERROR_DOM);
return false;
}
@@ -2032,8 +2045,7 @@ html_begin_conversion(html_content *htmlc)
(!dom_string_caseless_lwc_isequal(node_name,
corestring_lwc_html))) {
LOG(("root element not html"));
- msg_data.error = messages_get("ParsingFail");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base, NSERROR_DOM);
dom_node_unref(html);
return false;
}
@@ -2041,16 +2053,20 @@ html_begin_conversion(html_content *htmlc)
head = libdom_find_first_element(html, corestring_lwc_head);
if (head != NULL) {
- if (html_head(htmlc, head) == false) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ ns_error = html_head(htmlc, head);
+ if (ns_error != NSERROR_OK) {
+ content_broadcast_errorcode(&htmlc->base, ns_error);
+
dom_node_unref(html);
dom_node_unref(head);
return false;
}
/* handle meta refresh */
- if (html_meta_refresh(htmlc, head) == false) {
+ ns_error = html_meta_refresh(htmlc, head);
+ if (ns_error != NSERROR_OK) {
+ content_broadcast_errorcode(&htmlc->base, ns_error);
+
dom_node_unref(html);
dom_node_unref(head);
return false;
@@ -2062,21 +2078,23 @@ html_begin_conversion(html_content *htmlc)
(dom_html_document *) htmlc->document);
for (f = htmlc->forms; f != NULL; f = f->prev) {
nsurl *action;
- nserror res;
/* Make all actions absolute */
if (f->action == NULL || f->action[0] == '\0') {
/* HTML5 4.10.22.3 step 9 */
nsurl *doc_addr = content_get_url(&htmlc->base);
- res = nsurl_join(htmlc->base_url,
- nsurl_access(doc_addr), &action);
+ ns_error = nsurl_join(htmlc->base_url,
+ nsurl_access(doc_addr),
+ &action);
} else {
- res = nsurl_join(htmlc->base_url, f->action, &action);
+ ns_error = nsurl_join(htmlc->base_url,
+ f->action,
+ &action);
}
- if (res != NSERROR_OK) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ if (ns_error != NSERROR_OK) {
+ content_broadcast_errorcode(&htmlc->base, ns_error);
+
dom_node_unref(html);
dom_node_unref(head);
return false;
@@ -2086,8 +2104,9 @@ html_begin_conversion(html_content *htmlc)
f->action = strdup(nsurl_access(action));
nsurl_unref(action);
if (f->action == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base, CONTENT_MSG_ERROR, msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ NSERROR_NOMEM);
+
dom_node_unref(html);
dom_node_unref(head);
return false;
@@ -2097,10 +2116,8 @@ html_begin_conversion(html_content *htmlc)
if (f->document_charset == NULL) {
f->document_charset = strdup(htmlc->encoding);
if (f->document_charset == NULL) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(&htmlc->base,
- CONTENT_MSG_ERROR,
- msg_data);
+ content_broadcast_errorcode(&htmlc->base,
+ NSERROR_NOMEM);
dom_node_unref(html);
dom_node_unref(head);
return false;
diff --git a/resources/FatMessages b/resources/FatMessages
index d54acad..45b3086 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -2787,6 +2787,8 @@ de.all.ParsingFail:Dokumentparsing ist fehlgeschlagen.
fr.all.ParsingFail:L'analyse syntaxique du document a échoué.
it.all.ParsingFail:Analisi del documento fallita.
nl.all.ParsingFail:fout bij ontleden van dit document.
+en.all.CSSGeneric:Error processing CSS
+en.all.CSSBase:Base stylesheet failed to load
en.all.BadGIF:Reading GIF failed.
de.all.BadGIF:Lesen einer GIF Datei fehlgeschlagen.
fr.all.BadGIF:Erreur de lecture de GIF.
diff --git a/utils/errors.h b/utils/errors.h
index 9ad613d..7fcb5bd 100644
--- a/utils/errors.h
+++ b/utils/errors.h
@@ -61,6 +61,10 @@ typedef enum {
NSERROR_DOM, /**< DOM call returned error */
+ NSERROR_CSS, /**< CSS call returned error */
+
+ NSERROR_CSS_BASE, /**< CSS base sheet failed */
+
NSERROR_BAD_URL /**< Bad URL */
} nserror;
diff --git a/utils/messages.c b/utils/messages.c
index 5b62912..8ae616b 100644
--- a/utils/messages.c
+++ b/utils/messages.c
@@ -200,3 +200,99 @@ const char *messages_get(const char *key)
{
return messages_get_ctx(key, messages_hash);
}
+
+
+/**
+ * lookup of a message by errorcode from the standard Messages hash.
+ *
+ * \param code errorcode of message
+ * \return message text
+ */
+
+const char *messages_get_errorcode(nserror code)
+{
+ switch (code) {
+ case NSERROR_OK:
+ /**< No error */
+ return messages_get_ctx("OK", messages_hash);
+
+ case NSERROR_NOMEM:
+ /**< Memory exhaustion */
+ return messages_get_ctx("NoMemory", messages_hash);
+
+ case NSERROR_NO_FETCH_HANDLER:
+ /**< No fetch handler for URL scheme */
+ return messages_get_ctx("NoHandler", messages_hash);
+
+ case NSERROR_NOT_FOUND:
+ /**< Requested item not found */
+ return messages_get_ctx("NotFound", messages_hash);
+
+ case NSERROR_SAVE_FAILED:
+ /**< Failed to save data */
+ return messages_get_ctx("SaveFailed", messages_hash);
+
+ case NSERROR_CLONE_FAILED:
+ /**< Failed to clone handle */
+ return messages_get_ctx("CloneFailed", messages_hash);
+
+ case NSERROR_INIT_FAILED:
+ /**< Initialisation failed */
+ return messages_get_ctx("InitFailed", messages_hash);
+
+ case NSERROR_MNG_ERROR:
+ /**< An MNG error occurred */
+ return messages_get_ctx("MNGError", messages_hash);
+
+ case NSERROR_BAD_ENCODING:
+ /**< The character set is unknown */
+ return messages_get_ctx("BadEncoding", messages_hash);
+
+ case NSERROR_NEED_DATA:
+ /**< More data needed */
+ return messages_get_ctx("NeedData", messages_hash);
+
+ case NSERROR_ENCODING_CHANGE:
+ /**< The character set encoding change was unhandled */
+ return messages_get_ctx("EncodingChanged", messages_hash);
+
+ case NSERROR_BAD_PARAMETER:
+ /**< Bad Parameter */
+ return messages_get_ctx("BadParameter", messages_hash);
+
+ case NSERROR_INVALID:
+ /**< Invalid data */
+ return messages_get_ctx("Invalid", messages_hash);
+
+ case NSERROR_BOX_CONVERT:
+ /**< Box conversion failed */
+ return messages_get_ctx("BoxConvert", messages_hash);
+
+ case NSERROR_STOPPED:
+ /**< Content conversion stopped */
+ return messages_get_ctx("Stopped", messages_hash);
+
+ case NSERROR_DOM:
+ /**< DOM call returned error */
+ return messages_get_ctx("ParsingFail", messages_hash);
+
+ case NSERROR_CSS:
+ /**< CSS call returned error */
+ return messages_get_ctx("CSSGeneric", messages_hash);
+
+ case NSERROR_CSS_BASE:
+ /**< CSS base sheet failed */
+ return messages_get_ctx("CSSBase", messages_hash);
+
+ case NSERROR_BAD_URL:
+ /**< Bad URL */
+ return messages_get_ctx("BadURL", messages_hash);
+
+ default:
+ case NSERROR_UNKNOWN:
+ break;
+ }
+
+ /**< Unknown error */
+ return messages_get_ctx("Unknown", messages_hash);
+}
diff --git a/utils/messages.h b/utils/messages.h
index 2b78d07..81c3805 100644
--- a/utils/messages.h
+++ b/utils/messages.h
@@ -33,6 +33,7 @@
#ifndef _NETSURF_UTILS_MESSAGES_H_
#define _NETSURF_UTILS_MESSAGES_H_
+#include "utils/errors.h"
#include "utils/hashtable.h"
void messages_load(const char *path);
@@ -41,6 +42,14 @@ const char *messages_get_ctx(const char *key, struct hash_table *ctx);
const char *messages_get(const char *key);
/**
+ * lookup of a message by errorcode from the standard Messages hash.
+ *
+ * \param code errorcode of message
+ * \return message text
+ */
+const char *messages_get_errorcode(nserror code);
+
+/**
* Formatted message from a key in the global message hash.
*
* \param key key of message
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. 840284b24d1a03c14592dd907894b136a37c495c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/840284b24d1a03c14592d...
...commit http://git.netsurf-browser.org/netsurf.git/commit/840284b24d1a03c14592dd9...
...tree http://git.netsurf-browser.org/netsurf.git/tree/840284b24d1a03c14592dd907...
The branch, master has been updated
via 840284b24d1a03c14592dd907894b136a37c495c (commit)
via 2836c1775ab1f3bd4257f7ab43f21366b60a2206 (commit)
via e38c0f2c3bd81501cbc3ff504c2e61fa90fcec3d (commit)
via 2a01907ca1c1574da0619a0d9012e8c6445ab0f1 (commit)
via 08a659292ed0590687f4a072e7f5603c40337a89 (commit)
via 1765212be2689b31fa8b1ce24b28a5f8125380de (commit)
via eb454ff9f2389e7aca47b4c753a7225a9e4dae1f (commit)
via 17e19b283f8cf0e2772e61ac1e11f9919b03489b (commit)
via 38b17e11123d7da014d6c53c28f3d181a15517eb (commit)
via 8a12a8d5459a0fff8cd2e7f424300b71ec733feb (commit)
via 9b009dfb013d26a305612d58463731be0f527e48 (commit)
via dea524f585d8ceff39b7ce06767feeabc9fd6184 (commit)
via fde30ff958434d3a9564d6a033081554ed547144 (commit)
via c496d9080fa19314a2b910386228f6b10170cc3c (commit)
via 7e5ac02785ea909f72b39d1c30f2aa15fbacfa87 (commit)
via eb28188661262eef8aad4b530a3f16532aceffd4 (commit)
from 7915708b583699f16412d5eeab6a42602319e720 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/840284b24d1a03c1459...
commit 840284b24d1a03c14592dd907894b136a37c495c
Merge: 7915708 2836c17
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
Merge remote-tracking branch 'origin/mmu_man/beos-fixes'
-----------------------------------------------------------------------
Summary of changes:
Makefile | 2 +-
beos/Makefile.target | 28 ++--
beos/WindowStack.h | 45 ++++++
beos/bitmap.cpp | 2 -
beos/download.cpp | 249 +++++++++++++++++++++++++++++++++
riscos/searchweb.c => beos/download.h | 2 +-
beos/fetch_rsrc.cpp | 16 ++-
beos/gui.cpp | 150 +++++++++++----------
beos/gui.h | 2 +
beos/login.cpp | 25 ++--
beos/res.rdef | 46 ++++++
beos/scaffolding.cpp | 185 ++++++++++++++++++++++---
beos/scaffolding.h | 4 +
beos/schedule.cpp | 6 +-
beos/window.cpp | 76 ++++++++---
desktop/hotlist.c | 2 +-
utils/config.h | 4 +-
17 files changed, 695 insertions(+), 149 deletions(-)
create mode 100644 beos/WindowStack.h
create mode 100644 beos/download.cpp
copy riscos/searchweb.c => beos/download.h (89%)
diff --git a/Makefile b/Makefile
index c80378c..428aa74 100644
--- a/Makefile
+++ b/Makefile
@@ -453,7 +453,7 @@ ifeq ($(TARGET),beos)
$(Q)$(BEOS_SETVER) $(EXETARGET) \
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
-short "NetSurf $(VERSION_FULL)" \
- -long "NetSurf $(VERSION_FULL) © 2003 - 2008 The NetSurf Developers"
+ -long "NetSurf $(VERSION_FULL) © 2003 - 2012 The NetSurf Developers"
$(VQ)echo " MIMESET: $(EXETARGET)"
$(Q)$(BEOS_MIMESET) $(EXETARGET)
endif
diff --git a/beos/Makefile.target b/beos/Makefile.target
index af7c939..27981be 100644
--- a/beos/Makefile.target
+++ b/beos/Makefile.target
@@ -9,12 +9,14 @@
# for Haiku
LDFLAGS += -L/boot/common/lib
# some people do *not* have libm...
- LDFLAGS += -lcurl -liconv
- LDFLAGS += -lssl -lcrypto -lcss -ldom -lparserutils -lhubbub -lwapcaplet
+ LDFLAGS += -lssl -lcrypto -lcss
+ $(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
+ LDFLAGS += -ldom -lparserutils -lhubbub -lwapcaplet
+ LDFLAGS += -lexpat -lcurl -liconv
CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \
-D_BSD_SOURCE -D_POSIX_C_SOURCE \
- -Drestrict="" -Wno-multichar
+ -Drestrict="" -Wno-multichar
# DEBUG
CFLAGS += -g -O0
# -DDEBUG=1
@@ -59,9 +61,13 @@
# cross: Haiku ?
NETLDFLAGS := -lnetwork
endif
- LDFLAGS += -lbe -ltranslation $(NETLDFLAGS)
+ LDFLAGS += -lbe -ltranslation -ltracker $(NETLDFLAGS)
+ ifeq ($(GCCVER),2)
+ LDFLAGS += -lstdc++.r4
+ else
+ LDFLAGS += -lstdc++ -lsupc++
+ endif
- $(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
ifeq ($(HOST),beos)
CFLAGS += -I$(PREFIX)/include
LDFLAGS += -L$(PREFIX)/lib
@@ -82,11 +88,9 @@
# ----------------------------------------------------------------------------
# S_BEOS are sources purely for the BeOS build
-S_BEOS := about.cpp bitmap.cpp fetch_rsrc.cpp \
- filetype.cpp font.cpp gui.cpp login.cpp \
- gui_options.cpp plotters.cpp \
- scaffolding.cpp search.cpp schedule.cpp \
- thumbnail.cpp treeview.cpp throbber.cpp \
+S_BEOS := about.cpp bitmap.cpp download.cpp fetch_rsrc.cpp filetype.cpp \
+ font.cpp gui.cpp login.cpp gui_options.cpp plotters.cpp scaffolding.cpp \
+ search.cpp schedule.cpp thumbnail.cpp treeview.cpp throbber.cpp \
window.cpp system_colour.cpp
S_BEOS := $(addprefix beos/,$(S_BEOS))
@@ -98,7 +102,7 @@ RDEF_IMP_BEOS := $(addprefix $(OBJROOT)/,$(subst /,_,$(RDEF_IMP_BEOS)))
RDEP_BEOS := \
adblock.css beosdefault.css default.css internal.css quirks.css \
- netsurf.png ca-bundle.txt messages
+ netsurf.png ca-bundle.txt
RDEP_BEOS := $(addprefix beos/res/,$(RDEP_BEOS)) \
$(wildcard beos/res/Icons/*.png) \
$(wildcard beos/res/throbber/throbber*.png)
@@ -126,7 +130,7 @@ install-beos:
@cp -vRL beos/res/beosdefault.css $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
@cp -vRL gtk/res/license $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
# @cp -vRL beos/res/throbber/*.png $(DESTDIR)$(NETSURF_BEOS_RESOURCES)throbber
- gzip -9v < beos/res/messages > $(DESTDIR)$(NETSURF_BEOS_RESOURCES)messages
+ $(call split_install_messages, beos, $(DESTDIR)$(NETSURF_BEOS_RESOURCES))
# ----------------------------------------------------------------------------
# Package target
diff --git a/beos/WindowStack.h b/beos/WindowStack.h
new file mode 100644
index 0000000..947b143
--- /dev/null
+++ b/beos/WindowStack.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2010, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef WINDOW_STACK_H
+#define WINDOW_STACK_H
+
+
+#include <Window.h>
+
+
+class BWindowStack {
+public:
+ BWindowStack(BWindow* window);
+ ~BWindowStack();
+
+ status_t AddWindow(const BWindow* window);
+ status_t AddWindow(const BMessenger& window);
+ status_t AddWindowAt(const BWindow* window,
+ int32 position);
+ status_t AddWindowAt(const BMessenger& window,
+ int32 position);
+
+ status_t RemoveWindow(const BWindow* window);
+ status_t RemoveWindow(const BMessenger& window);
+ status_t RemoveWindowAt(int32 position,
+ BMessenger* window = NULL);
+
+ int32 CountWindows();
+
+ status_t WindowAt(int32 position,
+ BMessenger& messenger);
+ bool HasWindow(const BWindow* window);
+ bool HasWindow(const BMessenger& window);
+
+private:
+ status_t _AttachMessenger(const BMessenger& window);
+ status_t _ReadMessenger(BMessenger& window);
+ status_t _StartMessage(int32 what);
+
+ BPrivate::PortLink* fLink;
+};
+
+
+#endif
diff --git a/beos/bitmap.cpp b/beos/bitmap.cpp
index 83dedf7..02724a0 100644
--- a/beos/bitmap.cpp
+++ b/beos/bitmap.cpp
@@ -106,7 +106,6 @@ static inline void nsbeos_rgba_to_bgra(void *src, void *dst, int width, int heig
void *bitmap_create(int width, int height, unsigned int state)
{
- CALLED();
struct bitmap *bmp = (struct bitmap *)malloc(sizeof(struct bitmap));
if (bmp == NULL)
return NULL;
@@ -288,7 +287,6 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_modified(void *vbitmap) {
- CALLED();
struct bitmap *bitmap = (struct bitmap *)vbitmap;
// convert the shadow (ABGR) to into the primary bitmap
nsbeos_rgba_to_bgra(bitmap->shadow->Bits(), bitmap->primary->Bits(),
diff --git a/beos/download.cpp b/beos/download.cpp
new file mode 100644
index 0000000..bdd85b5
--- /dev/null
+++ b/beos/download.cpp
@@ -0,0 +1,249 @@
+/*
+ * Copyright 2012 Adrien Destugues <pulkomandy(a)pulkomandy.tk>
+ *
+ * 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/>.
+ */
+
+#define __STDBOOL_H__ 1
+#include <stdbool.h>
+
+extern "C" {
+#include "desktop/gui.h"
+}
+#include "beos/download.h"
+
+#include <File.h>
+#include <FilePanel.h>
+#include <Locker.h>
+#include <Messenger.h>
+#include <StatusBar.h>
+#include <Window.h>
+
+class NSDownloadWindow: public BWindow
+{
+ public:
+ NSDownloadWindow(download_context* ctx);
+ ~NSDownloadWindow();
+
+ void MessageReceived(BMessage* message);
+
+ void Progress(int size);
+ void Failure(const char* error);
+ void Success();
+ private:
+ download_context* ctx;
+ BStatusBar* bar;
+ unsigned long progress;
+ bool success;
+};
+
+
+struct gui_download_window {
+ download_context* ctx;
+ NSDownloadWindow* window;
+
+ BLocker* storageLock;
+ BDataIO* storage;
+};
+
+
+NSDownloadWindow::NSDownloadWindow(download_context* ctx)
+ : BWindow(BRect(30, 30, 400, 200), "Downloads", B_TITLED_WINDOW,
+ B_NOT_RESIZABLE)
+ , ctx(ctx)
+ , progress(0)
+ , success(false)
+{
+ unsigned long dlsize = download_context_get_total_length(ctx);
+ char* buffer = human_friendly_bytesize(dlsize);
+
+ // Create the status bar
+ BRect rect = Bounds();
+ rect.InsetBy(3, 3);
+ bar = new BStatusBar(rect, "progress",
+ download_context_get_filename(ctx), buffer);
+ bar->SetMaxValue(dlsize);
+
+ // Create the backgroundview (just so that the area around the progress bar
+ // is B_PANEL_BACKGROUND_COLOR instead of white)
+ BView* back = new BView(Bounds(), "back", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
+ back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+
+ // Add the views to the window
+ back->AddChild(bar);
+ AddChild(back);
+
+ // Resize the window to leave a margin around the progress bar
+ BRect size = bar->Bounds();
+ ResizeTo(size.Width() + 6, size.Height() + 6);
+ Show();
+}
+
+
+NSDownloadWindow::~NSDownloadWindow()
+{
+ download_context_abort(ctx);
+ download_context_destroy(ctx);
+}
+
+
+void
+NSDownloadWindow::MessageReceived(BMessage* message)
+{
+ switch(message->what)
+ {
+ case B_SAVE_REQUESTED:
+ {
+ entry_ref directory;
+ const char* name;
+ struct gui_download_window* dw;
+ BFilePanel* source;
+
+ message->FindRef("directory", &directory);
+ message->FindString("name", &name);
+ message->FindPointer("dw", (void**)&dw);
+
+ BDirectory dir(&directory);
+ BFile* storage = new BFile(&dir, name,
+ B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
+ dw->storageLock->Lock();
+
+ BMallocIO* tempstore = dynamic_cast<BMallocIO*>(dw->storage);
+
+ storage->Write(tempstore->Buffer(), tempstore->BufferLength());
+ delete dw->storage;
+
+ if (success)
+ delete storage; // File is already finished downloading !
+ else
+ dw->storage = storage;
+ dw->storageLock->Unlock();
+
+ message->FindPointer("source", (void**)&source);
+ delete source;
+
+ break;
+ }
+ default:
+ BWindow::MessageReceived(message);
+ }
+}
+
+
+void
+NSDownloadWindow::Progress(int size)
+{
+ progress += size;
+
+ char* buffer = human_friendly_bytesize(progress);
+ strcat(buffer, "/");
+
+ bar->LockLooper();
+ bar->Update(size, NULL, buffer);
+ bar->Invalidate();
+ bar->UnlockLooper();
+}
+
+
+void
+NSDownloadWindow::Success()
+{
+ bar->LockLooper();
+ bar->SetBarColor(ui_color(B_SUCCESS_COLOR));
+ bar->UnlockLooper();
+
+ success = true;
+}
+
+
+void
+NSDownloadWindow::Failure(const char* error)
+{
+ bar->LockLooper();
+ bar->Update(0, NULL, error);
+ bar->SetBarColor(ui_color(B_FAILURE_COLOR));
+ bar->UnlockLooper();
+}
+
+
+struct gui_download_window *gui_download_window_create(download_context *ctx,
+ struct gui_window *parent)
+{
+ struct gui_download_window *download = (struct gui_download_window*)malloc(sizeof *download);
+ if (download == NULL)
+ return NULL;
+
+ download->storageLock = new BLocker("storage_lock");
+ download->storage = new BMallocIO();
+ download->ctx = ctx;
+
+ download->window = new NSDownloadWindow(ctx);
+
+ // Also ask the user where to save the file
+ // TODO inject the suggested name somehow
+ BMessage* msg = new BMessage(B_SAVE_REQUESTED);
+
+ BFilePanel* panel = new BFilePanel(B_SAVE_PANEL,
+ new BMessenger(download->window), NULL, 0, false);
+
+ msg->AddPointer("source", panel);
+ msg->AddPointer("dw", download);
+ panel->SetMessage(msg);
+
+ panel->Show();
+
+ return download;
+}
+
+
+nserror gui_download_window_data(struct gui_download_window *dw,
+ const char *data, unsigned int size)
+{
+ dw->window->Progress(size);
+
+ dw->storageLock->Lock();
+ dw->storage->Write(data, size);
+ dw->storageLock->Unlock();
+
+ return NSERROR_OK;
+}
+
+
+void gui_download_window_error(struct gui_download_window *dw,
+ const char *error_msg)
+{
+ dw->window->Failure(error_msg);
+
+ delete dw->storageLock;
+ delete dw->storage;
+}
+
+
+void gui_download_window_done(struct gui_download_window *dw)
+{
+ dw->window->Success();
+
+ dw->storageLock->Lock();
+
+ // Only delete if the storage is already a file. Else, we must wait for the
+ // user to select something in the BFilePanel!
+ BFile* file = dynamic_cast<BFile*>(dw->storage);
+ delete file;
+ if (file)
+ delete dw->storageLock;
+ else
+ dw->storageLock->Unlock();
+}
+
diff --git a/riscos/searchweb.c b/beos/download.h
similarity index 89%
copy from riscos/searchweb.c
copy to beos/download.h
index 14246d2..9c8d3ad 100644
--- a/riscos/searchweb.c
+++ b/beos/download.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ * Copyright 2012 Adrien Destugues <pulkomandy(a)pulkomandy.tk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
diff --git a/beos/fetch_rsrc.cpp b/beos/fetch_rsrc.cpp
index 79dea4e..f7c99d7 100644
--- a/beos/fetch_rsrc.cpp
+++ b/beos/fetch_rsrc.cpp
@@ -48,6 +48,7 @@ extern "C" {
#include <image.h>
#include <Resources.h>
+#include <String.h>
struct fetch_rsrc_context {
struct fetch *parent_fetch;
@@ -65,7 +66,7 @@ struct fetch_rsrc_context {
static struct fetch_rsrc_context *ring = NULL;
-static BResources *gAppResources = NULL;
+BResources *gAppResources = NULL;
static bool fetch_rsrc_initialise(lwc_string *scheme)
{
@@ -197,11 +198,11 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
uint8 c1, c2, c3, c4;
if (sscanf(params, "%c%c%c%c", &c1, &c2, &c3, &c4) > 3) {
type = c1 << 24 | c2 << 16 | c3 << 8 | c4;
- printf("type:%4.4s\n", &type);
+ LOG(("fetch_rsrc: type:%4.4s\n", &type));
}
}
- fprintf(stderr, "fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name);
+ LOG(("fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name));
bool found;
if (id)
@@ -209,8 +210,13 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
else
found = gAppResources->HasResource(type, c->name);
if (!found) {
+ BString error("Cannot locate resource: ");
+ if (id)
+ error << id;
+ else
+ error << c->name;
msg.type = FETCH_ERROR;
- msg.data.error = "Cannot locate rsrc: URL";
+ msg.data.error = error.String();
fetch_rsrc_send_callback(&msg, c);
return false;
}
@@ -328,7 +334,7 @@ static int find_app_resources()
char path[B_PATH_NAME_LENGTH];
if (nsbeos_find_app_path(path) < B_OK)
return B_ERROR;
-//fprintf(stderr, "loading resources from '%s'\n", path);
+ //fprintf(stderr, "loading resources from '%s'\n", path);
BFile file(path, B_READ_ONLY);
if (file.InitCheck() < 0)
diff --git a/beos/gui.cpp b/beos/gui.cpp
index b275616..133ee8c 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -172,7 +172,6 @@ NSBrowserApplication::MessageReceived(BMessage *message)
void
NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
{
- CALLED();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
return;
@@ -186,7 +185,6 @@ NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
void
NSBrowserApplication::RefsReceived(BMessage *message)
{
- CALLED();
DetachCurrentMessage();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
@@ -325,7 +323,6 @@ image_id nsbeos_find_app_path(char *path)
static char *find_resource(char *buf, const char *filename, const char *def)
{
- CALLED();
const char *cdir = NULL;
status_t err;
BPath path;
@@ -388,7 +385,6 @@ static char *find_resource(char *buf, const char *filename, const char *def)
*/
static void check_homedir(void)
{
- CALLED();
status_t err;
BPath path;
@@ -423,14 +419,13 @@ nsurl *gui_get_resource_url(const char *path)
u << "beosdefault.css";
else
u << path;
- fprintf(stderr, "%s(%s) -> '%s'\n", __FUNCTION__, path, u.String());
+ LOG(("(%s) -> '%s'\n", path, u.String()));
nsurl_create(u.String(), &url);
return url;
}
static void gui_init2(int argc, char** argv)
{
- CALLED();
const char *addr = NETSURF_HOMEPAGE;
if (nsoption_charp(homepage_url) != NULL)
@@ -450,7 +445,6 @@ static void gui_init2(int argc, char** argv)
/** Normal entry point from OS */
int main(int argc, char** argv)
{
- char buf[PATH_MAX];
setbuf(stderr, NULL);
BPath options;
@@ -458,12 +452,16 @@ int main(int argc, char** argv)
options.Append("x-vnd.NetSurf");
}
- find_resource(buf, "messages", "./beos/res/messages");
- LOG(("Using '%s' as Messages file", buf));
- //messages_load(buf);
+ if (!replicated) {
+ // create the Application object before trying to use messages
+ // so we can open an alert in case of error.
+ new NSBrowserApplication;
+ }
+
+ char* messages = "/boot/apps/netsurf/res/en/Messages";
/* initialise netsurf */
- netsurf_init(&argc, &argv, options.Path(), buf);
+ netsurf_init(&argc, &argv, options.Path(), messages);
gui_init(argc, argv);
gui_init2(argc, argv);
@@ -475,6 +473,27 @@ int main(int argc, char** argv)
return 0;
}
+/** called when replicated from NSBaseView::Instantiate() */
+int gui_init_replicant(int argc, char** argv)
+{
+ setbuf(stderr, NULL);
+
+ BPath options;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
+ options.Append("x-vnd.NetSurf");
+ }
+
+ char* messages = "/boot/apps/netsurf/res/en/Messages";
+
+ /* initialise netsurf */
+ netsurf_init(&argc, &argv, options.Path(), messages);
+
+ gui_init(argc, argv);
+ gui_init2(argc, argv);
+
+ return 0;
+}
+
/* Documented in desktop/options.h */
void gui_options_init_defaults(void)
{
@@ -485,12 +504,10 @@ void gui_options_init_defaults(void)
void gui_init(int argc, char** argv)
{
char buf[PATH_MAX];
- CALLED();
if (pipe(sEventPipe) < 0)
return;
if (!replicated) {
- new NSBrowserApplication;
sBAppThreadID = spawn_thread(bapp_thread, "BApplication(NetSurf)", B_NORMAL_PRIORITY, (void *)find_thread(NULL));
if (sBAppThreadID < B_OK)
return; /* #### handle errors */
@@ -553,37 +570,38 @@ void gui_init(int argc, char** argv)
/* check what the font settings are, setting them to a default font
* if they're not set - stops Pango whinging
*/
+#define SETFONTDEFAULT(OPTION,y) if (nsoption_charp(OPTION) == NULL) nsoption_set_charp(OPTION, strdup((y)))
//XXX: use be_plain_font & friends, when we can check if font is serif or not.
/*
font_family family;
font_style style;
be_plain_font->GetFamilyAndStyle(&family, &style);
- nsoption_setnull_charp(font_sans, family);
- nsoption_setnull_charp(font_serif, family);
- nsoption_setnull_charp(font_mono, family);
- nsoption_setnull_charp(font_cursive, family);
- nsoption_setnull_charp(font_fantasy, family);
+ SETFONTDEFAULT(font_sans, family);
+ SETFONTDEFAULT(font_serif, family);
+ SETFONTDEFAULT(font_mono, family);
+ SETFONTDEFAULT(font_cursive, family);
+ SETFONTDEFAULT(font_fantasy, family);
*/
#ifdef __HAIKU__
- nsoption_setnull_charp(font_sans, "DejaVu Sans");
- nsoption_setnull_charp(font_serif, "DejaVu Serif");
- nsoption_setnull_charp(font_mono, "DejaVu Mono");
- nsoption_setnull_charp(font_cursive, "DejaVu Sans");
- nsoption_setnull_charp(font_fantasy, "DejaVu Sans");
+ SETFONTDEFAULT(font_sans, "DejaVu Sans");
+ SETFONTDEFAULT(font_serif, "DejaVu Serif");
+ SETFONTDEFAULT(font_mono, "DejaVu Mono");
+ SETFONTDEFAULT(font_cursive, "DejaVu Sans");
+ SETFONTDEFAULT(font_fantasy, "DejaVu Sans");
#else
- nsoption_setnull_charp(font_sans, "Bitstream Vera Sans");
- nsoption_setnull_charp(font_serif, "Bitstream Vera Serif");
- nsoption_setnull_charp(font_mono, "Bitstream Vera Sans Mono");
- nsoption_setnull_charp(font_cursive, "Bitstream Vera Serif");
- nsoption_setnull_charp(font_fantasy, "Bitstream Vera Serif");
+ SETFONTDEFAULT(font_sans, "Bitstream Vera Sans");
+ SETFONTDEFAULT(font_serif, "Bitstream Vera Serif");
+ SETFONTDEFAULT(font_mono, "Bitstream Vera Sans Mono");
+ SETFONTDEFAULT(font_cursive, "Bitstream Vera Serif");
+ SETFONTDEFAULT(font_fantasy, "Bitstream Vera Serif");
#if 0
- nsoption_setnull_charp(font_sans, "Swis721 BT");
- nsoption_setnull_charp(font_serif, "Dutch801 Rm BT");
- //nsoption_setnull_charp(font_mono, "Monospac821 BT");
- nsoption_setnull_charp(font_mono, "Courier10 BT");
- nsoption_setnull_charp(font_cursive, "Swis721 BT");
- nsoption_setnull_charp(font_fantasy, "Swis721 BT");
+ SETFONTDEFAULT(font_sans, "Swis721 BT");
+ SETFONTDEFAULT(font_serif, "Dutch801 Rm BT");
+ //SETFONTDEFAULT(font_mono, "Monospac821 BT");
+ SETFONTDEFAULT(font_mono, "Courier10 BT");
+ SETFONTDEFAULT(font_cursive, "Swis721 BT");
+ SETFONTDEFAULT(font_fantasy, "Swis721 BT");
#endif
#endif
@@ -680,17 +698,16 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf
void gui_poll(bool active)
{
- //CALLED();
CURLMcode code;
-
fd_set read_fd_set, write_fd_set, exc_fd_set;
int max_fd = 0;
struct timeval timeout;
unsigned int fd_count = 0;
bool block = true;
+ bigtime_t next_schedule = 0;
- if (browser_reformat_pending)
- block = false;
+ // handle early deadlines
+ schedule_run();
FD_ZERO(&read_fd_set);
FD_ZERO(&write_fd_set);
@@ -709,25 +726,42 @@ void gui_poll(bool active)
FD_SET(sEventPipe[0], &read_fd_set);
max_fd = MAX(max_fd, sEventPipe[0] + 1);
+ // If there are pending events elsewhere, we should not be blocking
+ if (!browser_reformat_pending) {
+ if (earliest_callback_timeout != B_INFINITE_TIMEOUT) {
+ next_schedule = earliest_callback_timeout - system_time();
+ block = false;
+ }
+
+ // we're quite late already...
+ if (next_schedule < 0)
+ next_schedule = 0;
- bigtime_t next_schedule = earliest_callback_timeout - system_time();
- if (!block)
- next_schedule = 0LL; // now
- if (block && earliest_callback_timeout != B_INFINITE_TIMEOUT)
+ } else //we're not allowed to sleep, there is other activity going on.
block = false;
+
+ /*
+ LOG(("gui_poll: browser_reformat_pending:%d earliest_callback_timeout:%Ld"
+ " next_schedule:%Ld block:%d ", browser_reformat_pending,
+ earliest_callback_timeout, next_schedule, block));
+ */
+
timeout.tv_sec = (long)(next_schedule / 1000000LL);
timeout.tv_usec = (long)(next_schedule % 1000000LL);
- LOG(("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule));
+ //LOG(("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule));
fd_count = select(max_fd, &read_fd_set, &write_fd_set, &exc_fd_set,
block ? NULL : &timeout);
+ //LOG(("select: %d\n", fd_count));
if (fd_count > 0 && FD_ISSET(sEventPipe[0], &read_fd_set)) {
BMessage *message;
int len = read(sEventPipe[0], &message, sizeof(void *));
- LOG(("gui_poll: BMessage ? %d read", len));
- if (len == sizeof(void *))
+ //LOG(("gui_poll: BMessage ? %d read", len));
+ if (len == sizeof(void *)) {
+ //LOG(("gui_poll: BMessage.what %-4.4s\n", &(message->what)));
nsbeos_dispatch_event(message);
+ }
}
schedule_run();
@@ -739,7 +773,6 @@ void gui_poll(bool active)
void gui_quit(void)
{
- CALLED();
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
//options_save_tree(hotlist,nsoption_charp(hotlist_file),messages_get("TreeHotlist"));
@@ -751,31 +784,6 @@ void gui_quit(void)
}
-
-struct gui_download_window *gui_download_window_create(download_context *ctx,
- struct gui_window *gui)
-{
- return NULL;
-}
-
-
-nserror gui_download_window_data(struct gui_download_window *dw,
- const char *data, unsigned int size)
-{
- return NSERROR_OK;
-}
-
-
-void gui_download_window_error(struct gui_download_window *dw,
- const char *error_msg)
-{
-}
-
-
-void gui_download_window_done(struct gui_download_window *dw)
-{
-}
-
#if 0 /* GTK */
static void nsbeos_select_menu_clicked(BCheckMenuItem *checkmenuitem,
gpointer user_data)
diff --git a/beos/gui.h b/beos/gui.h
index 6bbfa1d..af35677 100644
--- a/beos/gui.h
+++ b/beos/gui.h
@@ -30,6 +30,8 @@
#define CALLED() fprintf(stderr, "%s()\n", __FUNCTION__);
extern bool replicated;
+int gui_init_replicant(int argc, char** argv);
+
#if 0 /* GTK */
//extern GladeXML *gladeWindows;
diff --git a/beos/login.cpp b/beos/login.cpp
index 32860de..90cadde 100644
--- a/beos/login.cpp
+++ b/beos/login.cpp
@@ -45,7 +45,7 @@ class LoginAlert : public BAlert {
public:
LoginAlert(nserror (*callback)(bool proceed, void *pw),
void *callbaclpw,
- const char *url,
+ nsurl *url,
const char *host,
const char *realm,
const char *text);
@@ -53,7 +53,7 @@ public:
void MessageReceived(BMessage *message);
private:
- BString fUrl; /**< URL being fetched */
+ nsurl* fUrl; /**< URL being fetched */
BString fHost; /**< Host for user display */
BString fRealm; /**< Authentication realm */
nserror (*fCallback)(bool proceed, void *pw);
@@ -63,8 +63,8 @@ private:
BTextControl *fPassControl;
};
-static void create_login_window(const char *host,
- const char *realm, const char *fetchurl,
+static void create_login_window(nsurl *host,
+ lwc_string *realm, const char *fetchurl,
nserror (*cb)(bool proceed, void *pw), void *cbpw);
@@ -73,7 +73,7 @@ static void create_login_window(const char *host,
LoginAlert::LoginAlert(nserror (*callback)(bool proceed, void *pw),
void *callbackpw,
- const char *url,
+ nsurl *url,
const char *host,
const char *realm,
const char *text)
@@ -140,7 +140,7 @@ LoginAlert::MessageReceived(BMessage *message)
break;
BMessage *m = new BMessage(*message);
m->what = 'nsLO';
- m->AddString("URL", fUrl.String());
+ m->AddPointer("URL", fUrl);
m->AddString("Host", fHost.String());
m->AddString("Realm", fRealm.String());
m->AddPointer("callback", (void *)fCallback);
@@ -163,14 +163,13 @@ LoginAlert::MessageReceived(BMessage *message)
}
-void gui_401login_open(const char *url, const char *realm,
+extern "C" void gui_401login_open(nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
- char *host;
+ lwc_string *host;
url_func_result res;
- res = url_host(url, &host);
- assert(res == URL_FUNC_OK);
+ host = nsurl_get_component(url, NSURL_HOST);
create_login_window(url, host, realm, cb, cbpw);
@@ -179,7 +178,7 @@ void gui_401login_open(const char *url, const char *realm,
//void create_login_window(struct browser_window *bw, const char *host,
// const char *realm, const char *fetchurl)
-static void create_login_window(const char *url, const char *host,
+static void create_login_window(nsurl *url, lwc_string *host,
const char *realm, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
@@ -191,8 +190,8 @@ static void create_login_window(const char *url, const char *host,
text << "Host: " << host << "\n";
//text << "\n";
- LoginAlert *a = new LoginAlert(cb, cbpw, url, host, r.String(),
- text.String());
+ LoginAlert *a = new LoginAlert(cb, cbpw, url, lwc_string_data(host),
+ r.String(), text.String());
// asynchronously
a->Go(NULL);
diff --git a/beos/res.rdef b/beos/res.rdef
index b047bd0..862d6d0 100644
--- a/beos/res.rdef
+++ b/beos/res.rdef
@@ -32,6 +32,7 @@ resource(408, "throbber8.png") #'data' import "res/throbber/throbber8.png";
/* */
resource(500, "credits.html") #'data' import "res/en/credits.html,faf";
resource(501, "licence.html") #'data' import "res/en/licence.html,faf";
+resource(502, "welcome.html") #'data' import "res/en/welcome.html,faf";
resource(1, "BEOS:APP_FLAGS") (#'APPF') $"01000000";
@@ -397,3 +398,48 @@ resource(101, "BEOS:V:STD_ICON") #'zICO' array {
$"7F793EDCE3F417BB10DA0B"
};
+/* toolbar icons from Zumi <http://zumi.xoom.it/myhaiku>
+ * (generated by Icon-O-Matic from the HFIV source file,
+ * can't be automated)
+ */
+
+resource(102, "forward_button") #'VICN' array {
+ $"6E6369660304006603005900020006020000003C6000C000000000004C000048"
+ $"A0000080FF80FF00B300010A0748353448343E223E222C342C3422030A000100"
+ $"30222201178322040A0101001001178322040A02010000"
+};
+
+resource(103, "back_button") #'VICN' array {
+ $"6E6369660304006603005900020006020000003C6000C000000000004C000048"
+ $"A0000080FF80FF00B300010A0722353622362C482C483E363E3648030A000100"
+ $"30222201178322040A0101001001178322040A02010000"
+};
+
+resource(104, "stop_button") #'VICN' array {
+ $"6E6369660304006603800000020006020000003C6000C000000000004C000048"
+ $"A00000FFABABFFD900000208022A40402A02043525BEE325B7D825253525B7D8"
+ $"25BEE33545B7D845BEE345453545BEE345B7D8030A0002000130222201178900"
+ $"040A010200011001178900040A02020100100117850004"
+};
+
+resource(105, "reload_button") #'VICN' array {
+ $"6E6369660404006603004080020006020000003A0000C000000000004C000046"
+ $"7FFF00ABD5FFFF006CD9020006020000003A0000C000000000004C0000467FFF"
+ $"FFAAD4FF00006CD9010606C60F482232383D2D3D2D3826222A2B2329224327BC"
+ $"B7B25A4327060A00010030222201178322040A0101001001178322040A020100"
+ $"000A00010012C00000000000000000C000004AC0004AC00001178422040A0101"
+ $"0012C00000000000000000C000004AA0004AA00001178422040A03010002C000"
+ $"00000000000000C000004AA0004AA000"
+};
+
+resource(106, "home_button") #'VICN' array {
+ $"6E6369660804006603800000020006020000003A8000C000000000004C000047"
+ $"000000FFABABFFD900000554020016020000003AC000C000000000004BE00048"
+ $"A00000FFFFE50300590002000602000000370000C000000000004C00004A5000"
+ $"0080FF80FF00B20003806040040A064836483035222230223635280A04484848"
+ $"42224222480A0542404234352A283428400A042C342C4032403234080A030102"
+ $"1001178400040A040102000A0101001001178402040A020100000A0501011001"
+ $"178402040A060101000A070103000A0701030240AAAA0000000000003E000045"
+ $"0000468000"
+};
+
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 4003b09..bcd9943 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -22,7 +22,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include <BeBuild.h>
+#include <Box.h>
#include <Button.h>
#include <Dragger.h>
#include <Menu.h>
@@ -31,6 +33,8 @@
#include <Node.h>
#include <Path.h>
#include <PopUpMenu.h>
+#include <Resources.h>
+#include <Roster.h>
#include <Screen.h>
#include <ScrollView.h>
#include <String.h>
@@ -38,6 +42,12 @@
#include <TextControl.h>
#include <View.h>
#include <Window.h>
+
+#if defined(__HAIKU__)
+#include <IconUtils.h>
+#include "WindowStack.h"
+#endif
+
#include <fs_attr.h>
extern "C" {
#include "content/content.h"
@@ -164,6 +174,10 @@ static int32 nsbeos_replicant_main_thread(void *_arg);
// in beos_gui.cpp
extern int main(int argc, char** argv);
+// in fetch_rsrc.cpp
+extern BResources *gAppResources;
+
+
#warning XXX
#if 0 /* GTK */
static gboolean nsbeos_window_url_activate_event(beosWidget *, gpointer);
@@ -320,6 +334,7 @@ void
NSThrobber::SetBitmap(const BBitmap *bitmap)
{
fBitmap = bitmap;
+ Invalidate();
}
@@ -458,7 +473,7 @@ NSBaseView::MessageReceived(BMessage *message)
nsbeos_pipe_message_top(message, NULL, fScaffolding);
break;
default:
- message->PrintToStream();
+ //message->PrintToStream();
BView::MessageReceived(message);
}
}
@@ -490,12 +505,13 @@ NSBaseView::Instantiate(BMessage *archive)
if (!validate_instantiation(archive, "NSBaseView"))
return NULL;
const char *url;
- if (archive->FindString("url", &url) < B_OK) {
- return NULL;
+ if (archive->FindString("url", &url) < B_OK
+ || url == NULL || strlen(url) == 0) {
+ url = "about:";
}
struct replicant_thread_info *info = new replicant_thread_info;
- info->url = url;
+ info->url = BString(url);
if (nsbeos_find_app_path(info->app) < B_OK)
return NULL;
info->args[0] = info->app;
@@ -510,6 +526,10 @@ NSBaseView::Instantiate(BMessage *archive)
//netsurf_init(2, info->args);
//return NULL;
+ // do as much as possible in this thread to avoid deadlocks
+
+ gui_init_replicant(2, info->args);
+
replicant_done_sem = create_sem(0, "NS Replicant created");
thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
"NetSurf Main Thread", B_NORMAL_PRIORITY, info);
@@ -520,7 +540,8 @@ NSBaseView::Instantiate(BMessage *archive)
return NULL;
}
resume_thread(nsMainThread);
- while (acquire_sem(replicant_done_sem) == EINTR);
+ //XXX: deadlocks BeHappy
+ //while (acquire_sem(replicant_done_sem) == EINTR);
return view;
}
@@ -539,6 +560,7 @@ void
NSBaseView::AllAttached()
{
BView::AllAttached();
+
struct beos_scaffolding *g = fScaffolding;
if (!g)
return;
@@ -576,6 +598,8 @@ NSBrowserWindow::NSBrowserWindow(BRect frame, struct beos_scaffolding *scaf)
NSBrowserWindow::~NSBrowserWindow()
{
+ if(activeWindow == this)
+ activeWindow = NULL;
}
@@ -621,17 +645,26 @@ NSBrowserWindow::QuitRequested(void)
}
+void
+NSBrowserWindow::WindowActivated(bool active)
+{
+ if(active)
+ activeWindow = this;
+ else if(activeWindow == this)
+ activeWindow = NULL;
+}
+
+
// #pragma mark - implementation
int32 nsbeos_replicant_main_thread(void *_arg)
{
struct replicant_thread_info *info = (struct replicant_thread_info *)_arg;
- int32 ret;
- ret = main(2, info->args);
- //netsurf_main_loop();
- //netsurf_exit();
+ int32 ret = 0;
+
+ netsurf_main_loop();
+ netsurf_exit();
delete info;
- //release
delete_sem(replicant_done_sem);
return ret;
}
@@ -686,6 +719,10 @@ void nsbeos_scaffolding_update_colors(nsbeos_scaffolding *g)
}
+/*static*/ BWindow*
+NSBrowserWindow::activeWindow = NULL;
+
+
void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *message)
{
int width, height;
@@ -907,6 +944,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
text = scaffold->url_bar->Text();
scaffold->url_bar->UnlockLooper();
+ NSBrowserWindow::activeWindow = scaffold->window;
browser_window_create(text.String(), bw, NULL, false, false);
break;
}
@@ -1570,7 +1608,20 @@ void nsbeos_attach_toplevel_view(nsbeos_scaffolding *g, BView *view)
message->AddPointer("scaffolding", g);
g->window->AddShortcut('H', 0, message, view);
+
+#if defined(__HAIKU__)
+ // Make sure the window is layouted and answering to events, but do not
+ // show it before it is actually resized
+ g->window->Hide();
+ g->window->Show();
+
+ if(NSBrowserWindow::activeWindow) {
+ BWindowStack stack(NSBrowserWindow::activeWindow);
+ stack.AddWindow(g->window);
+ }
+#endif
g->window->Show();
+
} else {
if (g->top_view->Looper())
g->top_view->UnlockLooper();
@@ -1659,6 +1710,97 @@ static BMenuItem *make_menu_item(const char *name, BMessage *message)
return item;
}
+
+class BBitmapButton: public BButton
+{
+ public:
+ BBitmapButton(BRect rect, const char* name, const char* label,
+ BMessage* message);
+ ~BBitmapButton();
+
+ void Draw(BRect updateRect);
+ void SetBitmap(const char* attrName);
+ private:
+ BBitmap* fBitmap;
+ BBitmap* fDisabledBitmap;
+};
+
+
+BBitmapButton::BBitmapButton(BRect rect, const char* name, const char* label,
+ BMessage* message)
+ : BButton(rect, name, label, message)
+{
+ SetBitmap(name);
+}
+
+
+BBitmapButton::~BBitmapButton()
+{
+ delete fBitmap;
+ delete fDisabledBitmap;
+}
+
+
+void BBitmapButton::Draw(BRect updateRect)
+{
+ if(fBitmap == NULL) {
+ BButton::Draw(updateRect);
+ return;
+ }
+
+ SetDrawingMode(B_OP_COPY);
+ FillRect(updateRect, B_SOLID_LOW);
+ rgb_color color = LowColor();
+
+ SetDrawingMode(B_OP_ALPHA);
+ if(IsEnabled()) {
+ if(Value() != 0) {
+ // button is clicked
+ DrawBitmap(fBitmap, BPoint(1, 1));
+ } else {
+ // button is released
+ DrawBitmap(fBitmap, BPoint(0, 0));
+ }
+ } else
+ DrawBitmap(fDisabledBitmap, BPoint(0, 0));
+}
+
+
+void BBitmapButton::SetBitmap(const char* attrname)
+{
+#ifdef __HAIKU__
+ size_t size = 0;
+ const void* data = gAppResources->LoadResource('VICN', attrname, &size);
+
+ if (!data) {
+ printf("CANT LOAD RESOURCE %s\n", attrname);
+ return;
+ }
+
+ fBitmap = new BBitmap(BRect(0, 0, 32, 32), B_RGB32);
+ status_t status = BIconUtils::GetVectorIcon((const uint8*)data, size, fBitmap);
+
+ if(status != B_OK) {
+ fprintf(stderr, "%s > oops %s\n", attrname, strerror(status));
+ delete fBitmap;
+ fBitmap = NULL;
+ }
+
+ fDisabledBitmap = new BBitmap(fBitmap);
+ rgb_color* pixel = (rgb_color*)fDisabledBitmap->Bits();
+ for(int i = 0; i < fDisabledBitmap->BitsLength()/4; i++)
+ {
+ *pixel = tint_color(*pixel, B_DISABLED_MARK_TINT);
+ pixel++;
+ }
+#else
+ // No vector icon support on BeOS. We could try to load a bitmap one
+ fBitmap = NULL;
+ fDisabledBitmap = NULL;
+#endif
+}
+
+
nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
{
struct beos_scaffolding *g = (struct beos_scaffolding *)malloc(sizeof(*g));
@@ -1676,7 +1818,6 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
g->window = NULL;
g->menu_bar = NULL;
- g->window = NULL;
if (replicated && !replicant_view) {
warn_user("Error: No subwindow allowed when replicated.", NULL);
@@ -1685,7 +1826,6 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
if (!replicant_view) {
-
BRect frame(0, 0, 600-1, 500-1);
if (nsoption_int(window_width) > 0) {
frame.Set(0, 0, nsoption_int(window_width) - 1, nsoption_int(window_height) - 1);
@@ -1696,7 +1836,7 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
NSBrowserWindow *win = nsbeos_find_last_window();
if (win) {
pos = win->Frame().LeftTop();
- win->Unlock();
+ win->UnlockLooper();
}
pos += BPoint(20, 20);
BScreen screen;
@@ -2035,17 +2175,19 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
// the toolbar is also the dragger for now
// XXX: try to stuff it in the status bar at the bottom
// (BDragger *must* be a parent, sibiling or direct child of NSBaseView!)
+ // XXX: B_FULL_UPDATE_ON_RESIZE avoids leaving bits on resize,
+ // but causes flicker
rect = g->top_view->Bounds();
rect.bottom = rect.top + TOOLBAR_HEIGHT - 1;
rect.right = rect.right - DRAGGER_WIDTH;
- g->tool_bar = new BView(rect, "Toolbar",
- B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW);
+ g->tool_bar = new BBox(rect, "Toolbar",
+ B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS
+ | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
g->top_view->AddChild(g->tool_bar);
g->tool_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
g->tool_bar->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
// buttons
-#warning use BPictureButton
rect = g->tool_bar->Bounds();
rect.right = TOOLBAR_HEIGHT;
rect.InsetBySelf(5, 5);
@@ -2054,35 +2196,35 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
message = new BMessage('back');
message->AddPointer("scaffolding", g);
- g->back_button = new BButton(rect, "back_button", "<", message);
+ g->back_button = new BBitmapButton(rect, "back_button", "<", message);
g->tool_bar->AddChild(g->back_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('forw');
message->AddPointer("scaffolding", g);
- g->forward_button = new BButton(rect, "forward_button", ">", message);
+ g->forward_button = new BBitmapButton(rect, "forward_button", ">", message);
g->tool_bar->AddChild(g->forward_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('stop');
message->AddPointer("scaffolding", g);
- g->stop_button = new BButton(rect, "stop_button", "S", message);
+ g->stop_button = new BBitmapButton(rect, "stop_button", "S", message);
g->tool_bar->AddChild(g->stop_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('relo');
message->AddPointer("scaffolding", g);
- g->reload_button = new BButton(rect, "reload_button", "R", message);
+ g->reload_button = new BBitmapButton(rect, "reload_button", "R", message);
g->tool_bar->AddChild(g->reload_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('home');
message->AddPointer("scaffolding", g);
- g->home_button = new BButton(rect, "home_button", "H", message);
+ g->home_button = new BBitmapButton(rect, "home_button", "H", message);
g->tool_bar->AddChild(g->home_button);
nButtons++;
@@ -2407,3 +2549,4 @@ void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where)
{
g->popup_menu->Go(where);
}
+
diff --git a/beos/scaffolding.h b/beos/scaffolding.h
index ae78391..bd13230 100644
--- a/beos/scaffolding.h
+++ b/beos/scaffolding.h
@@ -61,11 +61,15 @@ virtual ~NSBrowserWindow();
virtual void DispatchMessage(BMessage *message, BHandler *handler);
virtual void MessageReceived(BMessage *message);
virtual bool QuitRequested(void);
+void WindowActivated(bool active);
struct beos_scaffolding *Scaffolding() const { return fScaffolding; };
+static BWindow* activeWindow;
private:
struct beos_scaffolding *fScaffolding;
+
+
};
diff --git a/beos/schedule.cpp b/beos/schedule.cpp
index 3f82235..db0992e 100644
--- a/beos/schedule.cpp
+++ b/beos/schedule.cpp
@@ -95,8 +95,9 @@ schedule(int t, void (*callback)(void *p), void *p)
cb->context = p;
cb->callback_killed = cb->callback_fired = false;
cb->timeout = timeout;
- if (earliest_callback_timeout > timeout)
+ if (earliest_callback_timeout > timeout) {
earliest_callback_timeout = timeout;
+ }
callbacks->AddItem(cb);
}
@@ -104,11 +105,12 @@ bool
schedule_run(void)
{
LOG(("schedule_run()"));
+
+ earliest_callback_timeout = B_INFINITE_TIMEOUT;
if (callbacks == NULL)
return false; /* Nothing to do */
bigtime_t now = system_time();
- earliest_callback_timeout = B_INFINITE_TIMEOUT;
int32 i;
LOG(("Checking %ld callbacks to for deadline.", this_run->CountItems()));
diff --git a/beos/window.cpp b/beos/window.cpp
index 253b5d1..f26ba91 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -131,7 +131,7 @@ static GdkCursor *nsbeos_create_menu_cursor(void);
NSBrowserFrameView::NSBrowserFrameView(BRect frame, struct gui_window *gui)
: BView(frame, "NSBrowserFrameView", B_FOLLOW_ALL_SIDES,
- B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS /*| B_SUBPIXEL_PRECISE*/),
+ B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS ),
fGuiWindow(gui)
{
}
@@ -250,7 +250,7 @@ NSBrowserFrameView::MessageReceived(BMessage *message)
nsbeos_pipe_message_top(message, NULL, fGuiWindow->scaffold);
break;
default:
- message->PrintToStream();
+ //message->PrintToStream();
BView::MessageReceived(message);
}
}
@@ -756,18 +756,25 @@ void nsbeos_dispatch_event(BMessage *message)
break;
case 'nsLO': // login
{
- BString url;
+ nsurl* url;
BString realm;
BString auth;
- if (message->FindString("URL", &url) < B_OK)
+ void* cbpw;
+ nserror (*cb)(bool proceed, void* pw);
+
+ if (message->FindPointer("URL", (void**)&url) < B_OK)
break;
if (message->FindString("Realm", &realm) < B_OK)
break;
if (message->FindString("Auth", &auth) < B_OK)
break;
+ if (message->FindPointer("callback", (void**)&cb) < B_OK)
+ break;
+ if (message->FindPointer("callback_pw", (void**)&cbpw) < B_OK)
+ break;
//printf("login to '%s' with '%s'\n", url.String(), auth.String());
- urldb_set_auth_details(url.String(), realm.String(), auth.String());
- browser_window_go(gui->bw, url.String(), 0, true);
+ urldb_set_auth_details(url, realm.String(), auth.String());
+ cb(true, cbpw);
break;
}
default:
@@ -926,11 +933,44 @@ void nsbeos_window_keypress_event(BView *view, gui_window *g, BMessage *event)
nskey = utf8_to_ucs4(bytes, numbytes);
}
- bool done = browser_window_key_press(g->bw, nskey);
- LOG(("nskey %d %d", nskey, done));
- //if (browser_window_key_press(g->bw, nskey))
+ if(browser_window_key_press(g->bw, nskey))
return;
-
+
+ // Remaining events are for scrolling the page around
+ float hdelta = 0.0f, vdelta = 0.0f;
+ g->view->LockLooper();
+ BRect size = g->view->Bounds();
+ switch (byte) {
+ case B_HOME:
+ g->view->ScrollTo(0.0f, 0.0f);
+ break;
+ case B_END:
+ {
+ // TODO
+ break;
+ }
+ case B_PAGE_UP:
+ vdelta = -size.Height();
+ break;
+ case B_PAGE_DOWN:
+ vdelta = size.Height();
+ break;
+ case B_LEFT_ARROW:
+ hdelta = -10;
+ break;
+ case B_RIGHT_ARROW:
+ hdelta = 10;
+ break;
+ case B_UP_ARROW:
+ vdelta = -10;
+ break;
+ case B_DOWN_ARROW:
+ vdelta = 10;
+ break;
+ }
+
+ g->view->ScrollBy(hdelta, vdelta);
+ g->view->UnlockLooper();
}
#warning WRITEME
@@ -1038,7 +1078,7 @@ gboolean nsbeos_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
{
- CALLED();
+ //CALLED();
int32 width;
int32 height;
@@ -1088,7 +1128,7 @@ void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
void nsbeos_window_moved_event(BView *view, gui_window *g, BMessage *event)
{
- CALLED();
+ //CALLED();
#warning XXX: Invalidate ?
if (!view || !view->LockLooper())
@@ -1272,7 +1312,7 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
- CALLED();
+ //CALLED();
if (g->view == NULL)
return false;
if (!g->view->LockLooper())
@@ -1302,7 +1342,7 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
- CALLED();
+ //CALLED();
if (g->view == NULL)
return;
if (!g->view->LockLooper())
@@ -1344,7 +1384,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
void gui_window_update_extent(struct gui_window *g)
{
- CALLED();
+ //CALLED();
if (!g->bw->current_content)
return;
@@ -1359,7 +1399,7 @@ void gui_window_update_extent(struct gui_window *g)
float y_prop = g->view->Bounds().Height() / y_max;
x_max -= g->view->Bounds().Width() + 1;
y_max -= g->view->Bounds().Height() + 1;
-printf("x_max = %f y_max = %f x_prop = %f y_prop = %f\n", x_max, y_max, x_prop, y_prop);
+ LOG(("x_max = %f y_max = %f x_prop = %f y_prop = %f\n", x_max, y_max, x_prop, y_prop));
if (g->view->ScrollBar(B_HORIZONTAL)) {
g->view->ScrollBar(B_HORIZONTAL)->SetRange(0, x_max);
g->view->ScrollBar(B_HORIZONTAL)->SetProportion(x_prop);
@@ -1542,7 +1582,7 @@ void gui_window_hide_pointer(struct gui_window *g)
void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
{
- CALLED();
+ //CALLED();
if (g->view == NULL)
return;
if (!g->view->LockLooper())
@@ -1674,7 +1714,7 @@ bool gui_add_to_clipboard(const char *text, size_t length, bool space,
BFont font;
text_run *run = new text_run;
- nsbeos_style_to_font(font, &fstyle);
+ nsbeos_style_to_font(font, fstyle);
run->offset = current_selection.Length();
run->font = font;
run->color = nsbeos_rgb_colour(fstyle->foreground);
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index b6eac36..e2386fc 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -415,8 +415,8 @@ void hotlist_add_entry(bool selected)
{
struct node *node;
struct node *parent = NULL;
- creating_node = true;
nsurl *url;
+ creating_node = true;
if (selected == true) {
parent = tree_get_selected_node(tree_get_root(hotlist_tree));
diff --git a/utils/config.h b/utils/config.h
index bd2e303..1c1eef6 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -24,14 +24,14 @@
/* Try to detect which features the target OS supports */
-#if (defined(_GNU_SOURCE) && !defined(__APPLE__))
+#if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__HAIKU__))
#define HAVE_STRNDUP
#else
#undef HAVE_STRNDUP
char *strndup(const char *s, size_t n);
#endif
-#if (defined(_GNU_SOURCE) || defined(__APPLE__))
+#if (defined(_GNU_SOURCE) || defined(__APPLE__) || defined(__HAIKU__))
#define HAVE_STRCASESTR
#else
#undef HAVE_STRCASESTR
--
NetSurf Browser
10 years, 6 months
netsurf: branch mmu_man/beos-fixes updated. 2836c1775ab1f3bd4257f7ab43f21366b60a2206
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2836c1775ab1f3bd4257f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2836c1775ab1f3bd4257f7a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2836c1775ab1f3bd4257f7ab4...
The branch, mmu_man/beos-fixes has been updated
via 2836c1775ab1f3bd4257f7ab43f21366b60a2206 (commit)
from e38c0f2c3bd81501cbc3ff504c2e61fa90fcec3d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/2836c1775ab1f3bd425...
commit 2836c1775ab1f3bd4257f7ab43f21366b60a2206
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: Don't link with libxml2 anymore
diff --git a/beos/Makefile.target b/beos/Makefile.target
index 0c662cb..27981be 100644
--- a/beos/Makefile.target
+++ b/beos/Makefile.target
@@ -12,7 +12,7 @@
LDFLAGS += -lssl -lcrypto -lcss
$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
LDFLAGS += -ldom -lparserutils -lhubbub -lwapcaplet
- LDFLAGS += -lexpat -lxml2 -lcurl -liconv
+ LDFLAGS += -lexpat -lcurl -liconv
CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \
-D_BSD_SOURCE -D_POSIX_C_SOURCE \
-----------------------------------------------------------------------
Summary of changes:
beos/Makefile.target | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/beos/Makefile.target b/beos/Makefile.target
index 0c662cb..27981be 100644
--- a/beos/Makefile.target
+++ b/beos/Makefile.target
@@ -12,7 +12,7 @@
LDFLAGS += -lssl -lcrypto -lcss
$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
LDFLAGS += -ldom -lparserutils -lhubbub -lwapcaplet
- LDFLAGS += -lexpat -lxml2 -lcurl -liconv
+ LDFLAGS += -lexpat -lcurl -liconv
CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \
-D_BSD_SOURCE -D_POSIX_C_SOURCE \
--
NetSurf Browser
10 years, 6 months
netsurf: branch mmu_man/beos-fixes updated. e38c0f2c3bd81501cbc3ff504c2e61fa90fcec3d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e38c0f2c3bd81501cbc3f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e38c0f2c3bd81501cbc3ff5...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e38c0f2c3bd81501cbc3ff504...
The branch, mmu_man/beos-fixes has been updated
via e38c0f2c3bd81501cbc3ff504c2e61fa90fcec3d (commit)
from 2a01907ca1c1574da0619a0d9012e8c6445ab0f1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/e38c0f2c3bd81501cbc...
commit e38c0f2c3bd81501cbc3ff504c2e61fa90fcec3d
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: comment on why the rdef file includes hexdump for icons
diff --git a/beos/res.rdef b/beos/res.rdef
index d40aec2..862d6d0 100644
--- a/beos/res.rdef
+++ b/beos/res.rdef
@@ -398,7 +398,10 @@ resource(101, "BEOS:V:STD_ICON") #'zICO' array {
$"7F793EDCE3F417BB10DA0B"
};
-/* toolbar icons from Zumi <http://zumi.xoom.it/myhaiku> */
+/* toolbar icons from Zumi <http://zumi.xoom.it/myhaiku>
+ * (generated by Icon-O-Matic from the HFIV source file,
+ * can't be automated)
+ */
resource(102, "forward_button") #'VICN' array {
$"6E6369660304006603005900020006020000003C6000C000000000004C000048"
-----------------------------------------------------------------------
Summary of changes:
beos/res.rdef | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/beos/res.rdef b/beos/res.rdef
index d40aec2..862d6d0 100644
--- a/beos/res.rdef
+++ b/beos/res.rdef
@@ -398,7 +398,10 @@ resource(101, "BEOS:V:STD_ICON") #'zICO' array {
$"7F793EDCE3F417BB10DA0B"
};
-/* toolbar icons from Zumi <http://zumi.xoom.it/myhaiku> */
+/* toolbar icons from Zumi <http://zumi.xoom.it/myhaiku>
+ * (generated by Icon-O-Matic from the HFIV source file,
+ * can't be automated)
+ */
resource(102, "forward_button") #'VICN' array {
$"6E6369660304006603005900020006020000003C6000C000000000004C000048"
--
NetSurf Browser
10 years, 6 months
netsurf: branch mmu_man/beos-fixes updated. 2a01907ca1c1574da0619a0d9012e8c6445ab0f1
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2a01907ca1c1574da0619...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2a01907ca1c1574da0619a0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2a01907ca1c1574da0619a0d9...
The branch, mmu_man/beos-fixes has been updated
via 2a01907ca1c1574da0619a0d9012e8c6445ab0f1 (commit)
from 08a659292ed0590687f4a072e7f5603c40337a89 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/2a01907ca1c1574da06...
commit 2a01907ca1c1574da0619a0d9012e8c6445ab0f1
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: debug output cleanup
diff --git a/beos/bitmap.cpp b/beos/bitmap.cpp
index 0dd8972..02724a0 100644
--- a/beos/bitmap.cpp
+++ b/beos/bitmap.cpp
@@ -106,7 +106,6 @@ static inline void nsbeos_rgba_to_bgra(void *src, void *dst, int width, int heig
void *bitmap_create(int width, int height, unsigned int state)
{
- //CALLED();
struct bitmap *bmp = (struct bitmap *)malloc(sizeof(struct bitmap));
if (bmp == NULL)
return NULL;
@@ -288,7 +287,6 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_modified(void *vbitmap) {
- //CALLED();
struct bitmap *bitmap = (struct bitmap *)vbitmap;
// convert the shadow (ABGR) to into the primary bitmap
nsbeos_rgba_to_bgra(bitmap->shadow->Bits(), bitmap->primary->Bits(),
diff --git a/beos/gui.cpp b/beos/gui.cpp
index bddd610..133ee8c 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -172,7 +172,6 @@ NSBrowserApplication::MessageReceived(BMessage *message)
void
NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
{
- //CALLED();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
return;
@@ -186,7 +185,6 @@ NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
void
NSBrowserApplication::RefsReceived(BMessage *message)
{
- //CALLED();
DetachCurrentMessage();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
@@ -325,7 +323,6 @@ image_id nsbeos_find_app_path(char *path)
static char *find_resource(char *buf, const char *filename, const char *def)
{
- //CALLED();
const char *cdir = NULL;
status_t err;
BPath path;
@@ -388,7 +385,6 @@ static char *find_resource(char *buf, const char *filename, const char *def)
*/
static void check_homedir(void)
{
- //CALLED();
status_t err;
BPath path;
@@ -430,7 +426,6 @@ nsurl *gui_get_resource_url(const char *path)
static void gui_init2(int argc, char** argv)
{
- //CALLED();
const char *addr = NETSURF_HOMEPAGE;
if (nsoption_charp(homepage_url) != NULL)
@@ -509,7 +504,6 @@ void gui_options_init_defaults(void)
void gui_init(int argc, char** argv)
{
char buf[PATH_MAX];
- //CALLED();
if (pipe(sEventPipe) < 0)
return;
@@ -704,7 +698,6 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf
void gui_poll(bool active)
{
- //CALLED();
CURLMcode code;
fd_set read_fd_set, write_fd_set, exc_fd_set;
int max_fd = 0;
@@ -780,7 +773,6 @@ void gui_poll(bool active)
void gui_quit(void)
{
- //CALLED();
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
//options_save_tree(hotlist,nsoption_charp(hotlist_file),messages_get("TreeHotlist"));
-----------------------------------------------------------------------
Summary of changes:
beos/bitmap.cpp | 2 --
beos/gui.cpp | 8 --------
2 files changed, 0 insertions(+), 10 deletions(-)
diff --git a/beos/bitmap.cpp b/beos/bitmap.cpp
index 0dd8972..02724a0 100644
--- a/beos/bitmap.cpp
+++ b/beos/bitmap.cpp
@@ -106,7 +106,6 @@ static inline void nsbeos_rgba_to_bgra(void *src, void *dst, int width, int heig
void *bitmap_create(int width, int height, unsigned int state)
{
- //CALLED();
struct bitmap *bmp = (struct bitmap *)malloc(sizeof(struct bitmap));
if (bmp == NULL)
return NULL;
@@ -288,7 +287,6 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_modified(void *vbitmap) {
- //CALLED();
struct bitmap *bitmap = (struct bitmap *)vbitmap;
// convert the shadow (ABGR) to into the primary bitmap
nsbeos_rgba_to_bgra(bitmap->shadow->Bits(), bitmap->primary->Bits(),
diff --git a/beos/gui.cpp b/beos/gui.cpp
index bddd610..133ee8c 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -172,7 +172,6 @@ NSBrowserApplication::MessageReceived(BMessage *message)
void
NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
{
- //CALLED();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
return;
@@ -186,7 +185,6 @@ NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
void
NSBrowserApplication::RefsReceived(BMessage *message)
{
- //CALLED();
DetachCurrentMessage();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
@@ -325,7 +323,6 @@ image_id nsbeos_find_app_path(char *path)
static char *find_resource(char *buf, const char *filename, const char *def)
{
- //CALLED();
const char *cdir = NULL;
status_t err;
BPath path;
@@ -388,7 +385,6 @@ static char *find_resource(char *buf, const char *filename, const char *def)
*/
static void check_homedir(void)
{
- //CALLED();
status_t err;
BPath path;
@@ -430,7 +426,6 @@ nsurl *gui_get_resource_url(const char *path)
static void gui_init2(int argc, char** argv)
{
- //CALLED();
const char *addr = NETSURF_HOMEPAGE;
if (nsoption_charp(homepage_url) != NULL)
@@ -509,7 +504,6 @@ void gui_options_init_defaults(void)
void gui_init(int argc, char** argv)
{
char buf[PATH_MAX];
- //CALLED();
if (pipe(sEventPipe) < 0)
return;
@@ -704,7 +698,6 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf
void gui_poll(bool active)
{
- //CALLED();
CURLMcode code;
fd_set read_fd_set, write_fd_set, exc_fd_set;
int max_fd = 0;
@@ -780,7 +773,6 @@ void gui_poll(bool active)
void gui_quit(void)
{
- //CALLED();
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
//options_save_tree(hotlist,nsoption_charp(hotlist_file),messages_get("TreeHotlist"));
--
NetSurf Browser
10 years, 6 months
netsurf: branch mmu_man/beos-fixes updated. 08a659292ed0590687f4a072e7f5603c40337a89
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/08a659292ed0590687f4a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/08a659292ed0590687f4a07...
...tree http://git.netsurf-browser.org/netsurf.git/tree/08a659292ed0590687f4a072e...
The branch, mmu_man/beos-fixes has been updated
via 08a659292ed0590687f4a072e7f5603c40337a89 (commit)
from 1765212be2689b31fa8b1ce24b28a5f8125380de (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/08a659292ed0590687f...
commit 08a659292ed0590687f4a072e7f5603c40337a89
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
Mention the origin of the icons added by Adrien
They come from Zumi's site, were proposed for Haiku,
and should be usable under MIT licence but it is not mentionned there.
I'll probably replace them anyway.
diff --git a/beos/res.rdef b/beos/res.rdef
index b41130a..d40aec2 100644
--- a/beos/res.rdef
+++ b/beos/res.rdef
@@ -398,6 +398,8 @@ resource(101, "BEOS:V:STD_ICON") #'zICO' array {
$"7F793EDCE3F417BB10DA0B"
};
+/* toolbar icons from Zumi <http://zumi.xoom.it/myhaiku> */
+
resource(102, "forward_button") #'VICN' array {
$"6E6369660304006603005900020006020000003C6000C000000000004C000048"
$"A0000080FF80FF00B300010A0748353448343E223E222C342C3422030A000100"
-----------------------------------------------------------------------
Summary of changes:
beos/res.rdef | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/beos/res.rdef b/beos/res.rdef
index b41130a..d40aec2 100644
--- a/beos/res.rdef
+++ b/beos/res.rdef
@@ -398,6 +398,8 @@ resource(101, "BEOS:V:STD_ICON") #'zICO' array {
$"7F793EDCE3F417BB10DA0B"
};
+/* toolbar icons from Zumi <http://zumi.xoom.it/myhaiku> */
+
resource(102, "forward_button") #'VICN' array {
$"6E6369660304006603005900020006020000003C6000C000000000004C000048"
$"A0000080FF80FF00B300010A0748353448343E223E222C342C3422030A000100"
--
NetSurf Browser
10 years, 6 months