netsurf: branch master updated. release/3.6-291-ge182a4d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e182a4d67c56aeb95179c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e182a4d67c56aeb95179cde...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e182a4d67c56aeb95179cde78...
The branch, master has been updated
via e182a4d67c56aeb95179cde78886532665e0036b (commit)
via e190cdf926a7ff4071053f8507e489cb8da63b13 (commit)
via 3217c82cdb4348960dfbdd978c68721f268fd385 (commit)
via 718da3ffffd1181a0b5b2d590214bc408ca44117 (commit)
from ca942e9e26cbd28ad5003b0e8bf29a771aafed94 (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/commit/?id=e182a4d67c56aeb9517...
commit e182a4d67c56aeb95179cde78886532665e0036b
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix memory leak in beos instantiate error path
diff --git a/frontends/beos/scaffolding.cpp b/frontends/beos/scaffolding.cpp
index 5e386bd..7efdb59 100644
--- a/frontends/beos/scaffolding.cpp
+++ b/frontends/beos/scaffolding.cpp
@@ -608,8 +608,10 @@ NSBaseView::Instantiate(BMessage *archive)
struct replicant_thread_info *info = new replicant_thread_info;
info->url = BString(url);
- if (nsbeos_find_app_path(info->app) < B_OK)
+ if (nsbeos_find_app_path(info->app) < B_OK) {
+ delete info;
return NULL;
+ }
info->args[0] = info->app;
info->args[1] = (char *)info->url.String();
info->args[2] = NULL;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e190cdf926a7ff40710...
commit e190cdf926a7ff4071053f8507e489cb8da63b13
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix uninitialised variable usage in atari ssl viewer
cppcheck identified uninitialised variable usage error
diff --git a/frontends/atari/verify_ssl.c b/frontends/atari/verify_ssl.c
index 055fd30..33136ee 100644
--- a/frontends/atari/verify_ssl.c
+++ b/frontends/atari/verify_ssl.c
@@ -182,8 +182,10 @@ static void do_popup( WINDOW *win, int index, int mode, void *data)
-bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_infos_n ,
- unsigned long num_certs )
+bool
+verify_ssl_form_do(const char * url,
+ const struct ssl_cert_info * cert_infos_n,
+ unsigned long num_certs)
{
OBJECT *tree;
WINDOW * form;
@@ -191,6 +193,13 @@ bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_inf
bool bres = false;
bool cont = true;
int res = 0;
+
+ RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree);
+ ObjcString( tree, VERIFY_LBL_HOST, (char*)url );
+ ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 );
+ ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 );
+ form = FormWindBegin( tree, (char*)"SSL Verify failed" );
+
dp.cert_infos_n = (struct ssl_cert_info *)cert_infos_n;
dp.num_certs = num_certs;
dp.scrollx = 0;
@@ -199,12 +208,6 @@ bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_inf
dp.cols = cert_display_width( &dp.cert_infos_n[dp.current] );
dp.rows = 8;
dp.tree = tree;
-
- RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree);
- ObjcString( tree, VERIFY_LBL_HOST, (char*)url );
- ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 );
- ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 );
- form = FormWindBegin( tree, (char*)"SSL Verify failed" );
EvntDataAdd( form, WM_REDRAW, cert_info_draw, (void*)&dp, EV_BOT );
/* this results in some extended objects which can not be freed: :( */
/* RsrcUserDraw( OC_FORM, tree, VERIFY_BOX_DETAILS, cert_info_draw,(void*)&dp ) ; */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3217c82cdb4348960df...
commit 3217c82cdb4348960dfbdd978c68721f268fd385
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
attempt to remove unintended sign extension warning in fs backing store
diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c
index bcb97d2..9d41065 100644
--- a/content/fs_backing_store.c
+++ b/content/fs_backing_store.c
@@ -1654,7 +1654,7 @@ static nserror store_write_block(struct store_state *state,
state->blocks_opened = true;
}
- offst = bi << log2_block_size[elem_idx];
+ offst = (unsigned int)bi << log2_block_size[elem_idx];
wr = nsu_pwrite(state->blocks[elem_idx][bf].fd,
bse->elem[elem_idx].data,
@@ -1822,7 +1822,7 @@ static nserror store_read_block(struct store_state *state,
state->blocks_opened = true;
}
- offst = bi << log2_block_size[elem_idx];
+ offst = (unsigned int)bi << log2_block_size[elem_idx];
rd = nsu_pread(state->blocks[elem_idx][bf].fd,
bse->elem[elem_idx].data,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=718da3ffffd1181a0b5...
commit 718da3ffffd1181a0b5b2d590214bc408ca44117
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make urldb internal parse macros less prone to control flow errors
fixes issue highlighted by coverity (CID 1361696)
diff --git a/content/urldb.c b/content/urldb.c
index 60944f7..c1c39c1 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -3796,7 +3796,7 @@ void urldb_load_cookies(const char *filename)
if (!fp)
return;
-#define FIND_T { \
+#define FIND_T do { \
for (; *p && *p != '\t'; p++) \
; /* do nothing */ \
if (p >= end) { \
@@ -3804,16 +3804,16 @@ void urldb_load_cookies(const char *filename)
continue; \
} \
*p++ = '\0'; \
-}
+ } while(0)
-#define SKIP_T { \
+#define SKIP_T do { \
for (; *p && *p == '\t'; p++) \
; /* do nothing */ \
if (p >= end) { \
LOG("Overran input"); \
continue; \
} \
-}
+ } while(0)
while (fgets(s, sizeof s, fp)) {
char *p = s, *end = 0,
-----------------------------------------------------------------------
Summary of changes:
content/fs_backing_store.c | 4 ++--
content/urldb.c | 8 ++++----
frontends/atari/verify_ssl.c | 19 +++++++++++--------
frontends/beos/scaffolding.cpp | 4 +++-
4 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c
index bcb97d2..9d41065 100644
--- a/content/fs_backing_store.c
+++ b/content/fs_backing_store.c
@@ -1654,7 +1654,7 @@ static nserror store_write_block(struct store_state *state,
state->blocks_opened = true;
}
- offst = bi << log2_block_size[elem_idx];
+ offst = (unsigned int)bi << log2_block_size[elem_idx];
wr = nsu_pwrite(state->blocks[elem_idx][bf].fd,
bse->elem[elem_idx].data,
@@ -1822,7 +1822,7 @@ static nserror store_read_block(struct store_state *state,
state->blocks_opened = true;
}
- offst = bi << log2_block_size[elem_idx];
+ offst = (unsigned int)bi << log2_block_size[elem_idx];
rd = nsu_pread(state->blocks[elem_idx][bf].fd,
bse->elem[elem_idx].data,
diff --git a/content/urldb.c b/content/urldb.c
index 60944f7..c1c39c1 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -3796,7 +3796,7 @@ void urldb_load_cookies(const char *filename)
if (!fp)
return;
-#define FIND_T { \
+#define FIND_T do { \
for (; *p && *p != '\t'; p++) \
; /* do nothing */ \
if (p >= end) { \
@@ -3804,16 +3804,16 @@ void urldb_load_cookies(const char *filename)
continue; \
} \
*p++ = '\0'; \
-}
+ } while(0)
-#define SKIP_T { \
+#define SKIP_T do { \
for (; *p && *p == '\t'; p++) \
; /* do nothing */ \
if (p >= end) { \
LOG("Overran input"); \
continue; \
} \
-}
+ } while(0)
while (fgets(s, sizeof s, fp)) {
char *p = s, *end = 0,
diff --git a/frontends/atari/verify_ssl.c b/frontends/atari/verify_ssl.c
index 055fd30..33136ee 100644
--- a/frontends/atari/verify_ssl.c
+++ b/frontends/atari/verify_ssl.c
@@ -182,8 +182,10 @@ static void do_popup( WINDOW *win, int index, int mode, void *data)
-bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_infos_n ,
- unsigned long num_certs )
+bool
+verify_ssl_form_do(const char * url,
+ const struct ssl_cert_info * cert_infos_n,
+ unsigned long num_certs)
{
OBJECT *tree;
WINDOW * form;
@@ -191,6 +193,13 @@ bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_inf
bool bres = false;
bool cont = true;
int res = 0;
+
+ RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree);
+ ObjcString( tree, VERIFY_LBL_HOST, (char*)url );
+ ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 );
+ ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 );
+ form = FormWindBegin( tree, (char*)"SSL Verify failed" );
+
dp.cert_infos_n = (struct ssl_cert_info *)cert_infos_n;
dp.num_certs = num_certs;
dp.scrollx = 0;
@@ -199,12 +208,6 @@ bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_inf
dp.cols = cert_display_width( &dp.cert_infos_n[dp.current] );
dp.rows = 8;
dp.tree = tree;
-
- RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree);
- ObjcString( tree, VERIFY_LBL_HOST, (char*)url );
- ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 );
- ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 );
- form = FormWindBegin( tree, (char*)"SSL Verify failed" );
EvntDataAdd( form, WM_REDRAW, cert_info_draw, (void*)&dp, EV_BOT );
/* this results in some extended objects which can not be freed: :( */
/* RsrcUserDraw( OC_FORM, tree, VERIFY_BOX_DETAILS, cert_info_draw,(void*)&dp ) ; */
diff --git a/frontends/beos/scaffolding.cpp b/frontends/beos/scaffolding.cpp
index 5e386bd..7efdb59 100644
--- a/frontends/beos/scaffolding.cpp
+++ b/frontends/beos/scaffolding.cpp
@@ -608,8 +608,10 @@ NSBaseView::Instantiate(BMessage *archive)
struct replicant_thread_info *info = new replicant_thread_info;
info->url = BString(url);
- if (nsbeos_find_app_path(info->app) < B_OK)
+ if (nsbeos_find_app_path(info->app) < B_OK) {
+ delete info;
return NULL;
+ }
info->args[0] = info->app;
info->args[1] = (char *)info->url.String();
info->args[2] = NULL;
--
NetSurf Browser
5 years, 11 months
netsurf: branch master updated. release/3.6-287-gca942e9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ca942e9e26cbd28ad5003...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ca942e9e26cbd28ad5003b0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ca942e9e26cbd28ad5003b0e8...
The branch, master has been updated
via ca942e9e26cbd28ad5003b0e8bf29a771aafed94 (commit)
from 30ccc0698422f09f231807b64c00cb35597f5a64 (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/commit/?id=ca942e9e26cbd28ad50...
commit ca942e9e26cbd28ad5003b0e8bf29a771aafed94
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix use of uninitialised variables in gtk print
fixes errors detected by coverity.
diff --git a/frontends/gtk/print.c b/frontends/gtk/print.c
index d2ca297..54edeee 100644
--- a/frontends/gtk/print.c
+++ b/frontends/gtk/print.c
@@ -324,11 +324,11 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx,
const plot_style_t *style,
const struct rect *rect)
{
- int x0,y0,x1,y1;
LOG("x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i",
rect->x0, rect->y0, rect->x1, rect->y1);
if (style->fill_type != PLOT_OP_TYPE_NONE) {
+ int x0,y0,x1,y1;
nsgtk_print_set_colour(style->fill_colour);
nsgtk_print_set_solid();
@@ -349,7 +349,15 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx,
}
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- nsgtk_print_set_colour(style->stroke_colour);
+ int stroke_width;
+
+ /* ensure minimum stroke width */
+ stroke_width = style->stroke_width;
+ if (stroke_width == 0) {
+ stroke_width = 1;
+ }
+
+ nsgtk_print_set_colour(style->stroke_colour);
switch (style->stroke_type) {
case PLOT_OP_TYPE_SOLID: /**< Solid colour */
@@ -366,12 +374,12 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx,
break;
}
- if (style->stroke_width == 0)
- cairo_set_line_width(gtk_print_current_cr, 1);
- else
- cairo_set_line_width(gtk_print_current_cr, style->stroke_width);
+ cairo_set_line_width(gtk_print_current_cr, stroke_width);
+
+ cairo_rectangle(gtk_print_current_cr,
+ rect->x0, rect->y0,
+ rect->x1 - rect->x0, rect->y1 - rect->y0);
- cairo_rectangle(gtk_print_current_cr, x0, y0, x1 - x0, y1 - y0);
cairo_stroke(gtk_print_current_cr);
}
-----------------------------------------------------------------------
Summary of changes:
frontends/gtk/print.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/frontends/gtk/print.c b/frontends/gtk/print.c
index d2ca297..54edeee 100644
--- a/frontends/gtk/print.c
+++ b/frontends/gtk/print.c
@@ -324,11 +324,11 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx,
const plot_style_t *style,
const struct rect *rect)
{
- int x0,y0,x1,y1;
LOG("x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i",
rect->x0, rect->y0, rect->x1, rect->y1);
if (style->fill_type != PLOT_OP_TYPE_NONE) {
+ int x0,y0,x1,y1;
nsgtk_print_set_colour(style->fill_colour);
nsgtk_print_set_solid();
@@ -349,7 +349,15 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx,
}
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- nsgtk_print_set_colour(style->stroke_colour);
+ int stroke_width;
+
+ /* ensure minimum stroke width */
+ stroke_width = style->stroke_width;
+ if (stroke_width == 0) {
+ stroke_width = 1;
+ }
+
+ nsgtk_print_set_colour(style->stroke_colour);
switch (style->stroke_type) {
case PLOT_OP_TYPE_SOLID: /**< Solid colour */
@@ -366,12 +374,12 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx,
break;
}
- if (style->stroke_width == 0)
- cairo_set_line_width(gtk_print_current_cr, 1);
- else
- cairo_set_line_width(gtk_print_current_cr, style->stroke_width);
+ cairo_set_line_width(gtk_print_current_cr, stroke_width);
+
+ cairo_rectangle(gtk_print_current_cr,
+ rect->x0, rect->y0,
+ rect->x1 - rect->x0, rect->y1 - rect->y0);
- cairo_rectangle(gtk_print_current_cr, x0, y0, x1 - x0, y1 - y0);
cairo_stroke(gtk_print_current_cr);
}
--
NetSurf Browser
5 years, 11 months
netsurf: branch master updated. release/3.6-286-g30ccc06
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/30ccc0698422f09f23180...
...commit http://git.netsurf-browser.org/netsurf.git/commit/30ccc0698422f09f231807b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/30ccc0698422f09f231807b64...
The branch, master has been updated
via 30ccc0698422f09f231807b64c00cb35597f5a64 (commit)
from 0a8976156a037bc2ec2d4d10f33334ada36eac9d (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/commit/?id=30ccc0698422f09f231...
commit 30ccc0698422f09f231807b64c00cb35597f5a64
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix errors from cppcheck in amiga frontend
diff --git a/frontends/amiga/download.c b/frontends/amiga/download.c
index 47485e0..18d3a59 100644
--- a/frontends/amiga/download.c
+++ b/frontends/amiga/download.c
@@ -305,7 +305,7 @@ static void gui_download_window_error(struct gui_download_window *dw,
static void ami_download_window_abort(void *w)
{
- struct gui_download_window *dw = (struct gui_download_window *)dw;
+ struct gui_download_window *dw = (struct gui_download_window *)w;
download_context_abort(dw->ctx);
dw->result = AMINS_DLOAD_ABORT;
gui_download_window_done(dw);
diff --git a/frontends/amiga/drag.c b/frontends/amiga/drag.c
index 92617dd..a8d3aa9 100644
--- a/frontends/amiga/drag.c
+++ b/frontends/amiga/drag.c
@@ -110,6 +110,8 @@ void ami_drag_save(struct Window *win)
ULONG which = WBO_NONE, type;
char path[1025], dpath[1025];
+ path[0] = 0; /* ensure path is terminated */
+
ami_drag_icon_close(NULL);
ami_autoscroll = true;
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index e8a13d7..5e5efd5 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1035,6 +1035,7 @@ static void gui_init2(int argc, char** argv)
amiga_warn_user(messages_get_errorcode(error), 0);
}
free(temp_homepage_url);
+ temp_homepage_url = NULL;
}
if(cli_force == true) {
@@ -1115,6 +1116,7 @@ static void gui_init2(int argc, char** argv)
if(temp_homepage_url) {
sendcmd = ASPrintf("OPEN \"%s\" NEW%s", temp_homepage_url, newtab);
free(temp_homepage_url);
+ temp_homepage_url = NULL;
} else {
sendcmd = ASPrintf("OPEN \"%s\" NEW%s", nsoption_charp(homepage_url), newtab);
}
@@ -1566,6 +1568,7 @@ static struct IBox *ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct
if(ibox == NULL) return NULL;
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
+ free(ibox);
amiga_warn_user("NoMemory", "");
return NULL;
}
diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c
index 6b9b207..0469dd5 100644
--- a/frontends/amiga/gui_menu.c
+++ b/frontends/amiga/gui_menu.c
@@ -504,9 +504,9 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
DevNameFromLock(lock, temp, 1024, DN_FULLPATH);
AddPart(temp, script, 1024);
ami_arexx_execute(temp);
- free(temp);
UnLock(lock);
}
+ free(temp);
}
}
}
diff --git a/frontends/amiga/icon.c b/frontends/amiga/icon.c
index 6521854..9de040d 100644
--- a/frontends/amiga/icon.c
+++ b/frontends/amiga/icon.c
@@ -336,7 +336,10 @@ static ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG
if (!argbicon) return(NULL);
cmap=GetColorMap(pals1);
- if(!cmap) return(NULL);
+ if(!cmap) {
+ free(argbicon);
+ return(NULL);
+ }
for(i=0;i<(width*height);i++)
{
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/download.c | 2 +-
frontends/amiga/drag.c | 2 ++
frontends/amiga/gui.c | 3 +++
frontends/amiga/gui_menu.c | 2 +-
frontends/amiga/icon.c | 5 ++++-
5 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/frontends/amiga/download.c b/frontends/amiga/download.c
index 47485e0..18d3a59 100644
--- a/frontends/amiga/download.c
+++ b/frontends/amiga/download.c
@@ -305,7 +305,7 @@ static void gui_download_window_error(struct gui_download_window *dw,
static void ami_download_window_abort(void *w)
{
- struct gui_download_window *dw = (struct gui_download_window *)dw;
+ struct gui_download_window *dw = (struct gui_download_window *)w;
download_context_abort(dw->ctx);
dw->result = AMINS_DLOAD_ABORT;
gui_download_window_done(dw);
diff --git a/frontends/amiga/drag.c b/frontends/amiga/drag.c
index 92617dd..a8d3aa9 100644
--- a/frontends/amiga/drag.c
+++ b/frontends/amiga/drag.c
@@ -110,6 +110,8 @@ void ami_drag_save(struct Window *win)
ULONG which = WBO_NONE, type;
char path[1025], dpath[1025];
+ path[0] = 0; /* ensure path is terminated */
+
ami_drag_icon_close(NULL);
ami_autoscroll = true;
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index e8a13d7..5e5efd5 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1035,6 +1035,7 @@ static void gui_init2(int argc, char** argv)
amiga_warn_user(messages_get_errorcode(error), 0);
}
free(temp_homepage_url);
+ temp_homepage_url = NULL;
}
if(cli_force == true) {
@@ -1115,6 +1116,7 @@ static void gui_init2(int argc, char** argv)
if(temp_homepage_url) {
sendcmd = ASPrintf("OPEN \"%s\" NEW%s", temp_homepage_url, newtab);
free(temp_homepage_url);
+ temp_homepage_url = NULL;
} else {
sendcmd = ASPrintf("OPEN \"%s\" NEW%s", nsoption_charp(homepage_url), newtab);
}
@@ -1566,6 +1568,7 @@ static struct IBox *ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct
if(ibox == NULL) return NULL;
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
+ free(ibox);
amiga_warn_user("NoMemory", "");
return NULL;
}
diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c
index 6b9b207..0469dd5 100644
--- a/frontends/amiga/gui_menu.c
+++ b/frontends/amiga/gui_menu.c
@@ -504,9 +504,9 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
DevNameFromLock(lock, temp, 1024, DN_FULLPATH);
AddPart(temp, script, 1024);
ami_arexx_execute(temp);
- free(temp);
UnLock(lock);
}
+ free(temp);
}
}
}
diff --git a/frontends/amiga/icon.c b/frontends/amiga/icon.c
index 6521854..9de040d 100644
--- a/frontends/amiga/icon.c
+++ b/frontends/amiga/icon.c
@@ -336,7 +336,10 @@ static ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG
if (!argbicon) return(NULL);
cmap=GetColorMap(pals1);
- if(!cmap) return(NULL);
+ if(!cmap) {
+ free(argbicon);
+ return(NULL);
+ }
for(i=0;i<(width*height);i++)
{
--
NetSurf Browser
5 years, 11 months
netsurf: branch master updated. release/3.6-285-g0a89761
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/0a8976156a037bc2ec2d4...
...commit http://git.netsurf-browser.org/netsurf.git/commit/0a8976156a037bc2ec2d4d1...
...tree http://git.netsurf-browser.org/netsurf.git/tree/0a8976156a037bc2ec2d4d10f...
The branch, master has been updated
via 0a8976156a037bc2ec2d4d10f33334ada36eac9d (commit)
via 6083de4ee1370dbd483e489e4e63ec2a58becc71 (commit)
via 855721282c01a0cd0c94c87e03ac8229da077372 (commit)
from 028c4e2860a5cf75ce8a3b97c04d12adaee7ef1b (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/commit/?id=0a8976156a037bc2ec2...
commit 0a8976156a037bc2ec2d4d10f33334ada36eac9d
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
split out browser window drag context into separate structure
diff --git a/desktop/browser.c b/desktop/browser.c
index 8e39c08..0a4afc1 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -421,22 +421,24 @@ void browser_window_set_position(struct browser_window *bw, int x, int y)
}
/* exported interface, documented in browser.h */
-void browser_window_set_drag_type(struct browser_window *bw,
- browser_drag_type type, const struct rect *rect)
+void
+browser_window_set_drag_type(struct browser_window *bw,
+ browser_drag_type type,
+ const struct rect *rect)
{
struct browser_window *top_bw = browser_window_get_root(bw);
gui_drag_type gtype;
- bw->drag_type = type;
+ bw->drag.type = type;
if (type == DRAGGING_NONE) {
- top_bw->drag_window = NULL;
+ top_bw->drag.window = NULL;
} else {
- top_bw->drag_window = bw;
+ top_bw->drag.window = bw;
switch (type) {
case DRAGGING_SELECTION:
- /* TODO: tell front end */
+ /** \todo tell front end */
return;
case DRAGGING_SCR_X:
case DRAGGING_SCR_Y:
@@ -455,7 +457,7 @@ void browser_window_set_drag_type(struct browser_window *bw,
/* exported interface, documented in browser.h */
browser_drag_type browser_window_get_drag_type(struct browser_window *bw)
{
- return bw->drag_type;
+ return bw->drag.type;
}
/* exported interface, documented in browser.h */
@@ -939,7 +941,7 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
/* window characteristics */
bw->refresh_interval = -1;
- bw->drag_type = DRAGGING_NONE;
+ bw->drag.type = DRAGGING_NONE;
bw->scroll_x = NULL;
bw->scroll_y = NULL;
@@ -2879,7 +2881,7 @@ static void browser_window_mouse_drag_end(struct browser_window *bw,
{
int scr_x, scr_y;
- switch (bw->drag_type) {
+ switch (bw->drag.type) {
case DRAGGING_SELECTION:
case DRAGGING_OTHER:
case DRAGGING_CONTENT_SCROLLBAR:
@@ -2895,7 +2897,7 @@ static void browser_window_mouse_drag_end(struct browser_window *bw,
scrollbar_mouse_drag_end(bw->scroll_x, mouse, scr_x, scr_y);
- bw->drag_type = DRAGGING_NONE;
+ bw->drag.type = DRAGGING_NONE;
break;
case DRAGGING_SCR_Y:
@@ -2907,7 +2909,7 @@ static void browser_window_mouse_drag_end(struct browser_window *bw,
scrollbar_mouse_drag_end(bw->scroll_y, mouse, scr_x, scr_y);
- bw->drag_type = DRAGGING_NONE;
+ bw->drag.type = DRAGGING_NONE;
break;
default:
@@ -2925,11 +2927,11 @@ void browser_window_mouse_track(struct browser_window *bw,
const char *status = NULL;
browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
- if (bw->window != NULL && bw->drag_window && bw != bw->drag_window) {
+ if (bw->window != NULL && bw->drag.window && bw != bw->drag.window) {
/* This is the root browser window and there's an active drag
* in a sub window.
* Pass the mouse action straight on to that bw. */
- struct browser_window *drag_bw = bw->drag_window;
+ struct browser_window *drag_bw = bw->drag.window;
int off_x = 0;
int off_y = 0;
@@ -2982,25 +2984,27 @@ void browser_window_mouse_track(struct browser_window *bw,
return;
}
- if (c == NULL && bw->drag_type != DRAGGING_FRAME)
+ if (c == NULL && bw->drag.type != DRAGGING_FRAME) {
return;
+ }
- if (bw->drag_type != DRAGGING_NONE && !mouse) {
+ if (bw->drag.type != DRAGGING_NONE && !mouse) {
browser_window_mouse_drag_end(bw, mouse, x, y);
}
/* Browser window's horizontal scrollbar */
- if (bw->scroll_x != NULL && bw->drag_type != DRAGGING_SCR_Y) {
+ if (bw->scroll_x != NULL && bw->drag.type != DRAGGING_SCR_Y) {
int scr_x, scr_y;
browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
- if ((scr_x > 0 && scr_x < browser_window_get_scrollbar_len(bw,
- true) &&
- scr_y > 0 && scr_y < SCROLLBAR_WIDTH &&
- bw->drag_type == DRAGGING_NONE) ||
- bw->drag_type == DRAGGING_SCR_X) {
+ if ((bw->drag.type == DRAGGING_SCR_X) ||
+ (scr_x > 0 &&
+ scr_x < browser_window_get_scrollbar_len(bw, true) &&
+ scr_y > 0 &&
+ scr_y < SCROLLBAR_WIDTH &&
+ bw->drag.type == DRAGGING_NONE)) {
/* Start a scrollbar drag, or continue existing drag */
status = scrollbar_mouse_status_to_message(
scrollbar_mouse_action(
@@ -3008,8 +3012,9 @@ void browser_window_mouse_track(struct browser_window *bw,
scr_x, scr_y));
pointer = BROWSER_POINTER_DEFAULT;
- if (status != NULL)
+ if (status != NULL) {
browser_window_set_status(bw, status);
+ }
browser_window_set_pointer(bw, pointer);
return;
@@ -3023,11 +3028,12 @@ void browser_window_mouse_track(struct browser_window *bw,
scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
- if ((scr_y > 0 && scr_y < browser_window_get_scrollbar_len(bw,
- false) &&
- scr_x > 0 && scr_x < SCROLLBAR_WIDTH &&
- bw->drag_type == DRAGGING_NONE) ||
- bw->drag_type == DRAGGING_SCR_Y) {
+ if ((bw->drag.type == DRAGGING_SCR_Y) ||
+ (scr_y > 0 &&
+ scr_y < browser_window_get_scrollbar_len(bw, false) &&
+ scr_x > 0 &&
+ scr_x < SCROLLBAR_WIDTH &&
+ bw->drag.type == DRAGGING_NONE)) {
/* Start a scrollbar drag, or continue existing drag */
status = scrollbar_mouse_status_to_message(
scrollbar_mouse_action(
@@ -3035,27 +3041,28 @@ void browser_window_mouse_track(struct browser_window *bw,
scr_x, scr_y));
pointer = BROWSER_POINTER_DEFAULT;
- if (status != NULL)
+ if (status != NULL) {
browser_window_set_status(bw, status);
+ }
browser_window_set_pointer(bw, pointer);
return;
}
}
- if (bw->drag_type == DRAGGING_FRAME) {
+ if (bw->drag.type == DRAGGING_FRAME) {
browser_window_resize_frame(bw, bw->x + x, bw->y + y);
- } else if (bw->drag_type == DRAGGING_PAGE_SCROLL) {
+ } else if (bw->drag.type == DRAGGING_PAGE_SCROLL) {
/* mouse movement since drag started */
- int scrollx = bw->drag_start_x - x;
- int scrolly = bw->drag_start_y - y;
+ int scrollx = bw->drag.start_x - x;
+ int scrolly = bw->drag.start_y - y;
/* new scroll offsets */
- scrollx += bw->drag_start_scroll_x;
- scrolly += bw->drag_start_scroll_y;
+ scrollx += bw->drag.start_scroll_x;
+ scrolly += bw->drag.start_scroll_y;
- bw->drag_start_scroll_x = scrollx;
- bw->drag_start_scroll_y = scrolly;
+ bw->drag.start_scroll_x = scrollx;
+ bw->drag.start_scroll_y = scrolly;
browser_window_set_scroll(bw, scrollx, scrolly);
} else {
@@ -3205,19 +3212,20 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y)
browser_window_set_drag_type(bw, DRAGGING_PAGE_SCROLL, NULL);
- bw->drag_start_x = x;
- bw->drag_start_y = y;
+ bw->drag.start_x = x;
+ bw->drag.start_y = y;
if (bw->window != NULL) {
/* Front end window */
- guit->window->get_scroll(bw->window, &bw->drag_start_scroll_x,
- &bw->drag_start_scroll_y);
+ guit->window->get_scroll(bw->window,
+ &bw->drag.start_scroll_x,
+ &bw->drag.start_scroll_y);
guit->window->scroll_start(bw->window);
} else {
/* Core managed browser window */
- bw->drag_start_scroll_x = scrollbar_get_offset(bw->scroll_x);
- bw->drag_start_scroll_y = scrollbar_get_offset(bw->scroll_y);
+ bw->drag.start_scroll_x = scrollbar_get_offset(bw->scroll_x);
+ bw->drag.start_scroll_y = scrollbar_get_offset(bw->scroll_y);
}
}
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index b8dce84..3e9b846 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -90,23 +90,32 @@ struct browser_window {
/** Fragment identifier for current_content. */
lwc_string *frag_id;
- /** Current drag status. */
- browser_drag_type drag_type;
-
- /** Current drag's browser window, when not in root bw. */
- struct browser_window *drag_window;
-
- /** Mouse position at start of current scroll drag. */
- int drag_start_x;
- int drag_start_y;
- /** Scroll offsets at start of current scroll draw. */
- int drag_start_scroll_x;
- int drag_start_scroll_y;
- /** Frame resize directions for current frame resize drag. */
- unsigned int drag_resize_left : 1;
- unsigned int drag_resize_right : 1;
- unsigned int drag_resize_up : 1;
- unsigned int drag_resize_down : 1;
+ /**
+ * Current drag status.
+ *
+ * These values are only vald whle type is not DRAGGING_NONE
+ */
+ struct {
+ /** the type of drag in progress */
+ browser_drag_type type;
+
+ /** Current drag's browser window, when not in root bw. */
+ struct browser_window *window;
+
+ /** Mouse position at start of current scroll drag. */
+ int start_x;
+ int start_y;
+
+ /** Scroll offsets at start of current scroll draw. */
+ int start_scroll_x;
+ int start_scroll_y;
+
+ /** Frame resize directions for current frame resize drag. */
+ unsigned int resize_left : 1;
+ unsigned int resize_right : 1;
+ unsigned int resize_up : 1;
+ unsigned int resize_down : 1;
+ } drag;
/** Current fetch is download */
bool download;
diff --git a/desktop/frames.c b/desktop/frames.c
index 70e51e7..9eefefe 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -675,25 +675,31 @@ void browser_window_resize_frame(struct browser_window *bw, int x, int y)
assert((col >= 0) && (row >= 0));
sibling = NULL;
- if (bw->drag_resize_left)
+ if (bw->drag.resize_left) {
sibling = &parent->children[row * parent->cols + (col - 1)];
- else if (bw->drag_resize_right)
+ } else if (bw->drag.resize_right) {
sibling = &parent->children[row * parent->cols + (col + 1)];
- if (sibling)
+ }
+ if (sibling) {
change |= browser_window_resolve_frame_dimension(bw, sibling,
x, y, true, false);
+ }
sibling = NULL;
- if (bw->drag_resize_up)
+ if (bw->drag.resize_up) {
sibling = &parent->children[(row - 1) * parent->cols + col];
- else if (bw->drag_resize_down)
+ } else if (bw->drag.resize_down) {
sibling = &parent->children[(row + 1) * parent->cols + col];
- if (sibling)
+ }
+
+ if (sibling) {
change |= browser_window_resolve_frame_dimension(bw, sibling,
x, y, false, true);
+ }
- if (change)
+ if (change) {
browser_window_recalculate_frameset(parent);
+ }
}
@@ -711,20 +717,22 @@ bool browser_window_resolve_frame_dimension(struct browser_window *bw,
/* extend/shrink the box to the pointer */
if (width) {
- if (bw->drag_resize_left)
+ if (bw->drag.resize_left) {
bw_dimension = bw->x + bw->width - x;
- else
+ } else {
bw_dimension = x - bw->x;
+ }
bw_pixels = bw->width;
sibling_pixels = sibling->width;
bw_d = &bw->frame_width;
sibling_d = &sibling->frame_width;
frame_size = bw->parent->width;
} else {
- if (bw->drag_resize_up)
+ if (bw->drag.resize_up) {
bw_dimension = bw->y + bw->height - y;
- else
+ } else {
bw_dimension = y - bw->y;
+ }
bw_pixels = bw->height;
sibling_pixels = sibling->height;
bw_d = &bw->frame_height;
@@ -919,12 +927,12 @@ static bool browser_window_resize_frames(struct browser_window *bw,
* front end to clamp pointer range */
browser_window_set_drag_type(bw,
DRAGGING_FRAME, NULL);
- bw->drag_start_x = x;
- bw->drag_start_y = y;
- bw->drag_resize_left = left;
- bw->drag_resize_right = right;
- bw->drag_resize_up = up;
- bw->drag_resize_down = down;
+ bw->drag.start_x = x;
+ bw->drag.start_y = y;
+ bw->drag.resize_left = left;
+ bw->drag.resize_right = right;
+ bw->drag.resize_up = up;
+ bw->drag.resize_down = down;
}
return true;
}
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 482dcb9..858d4ae 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -43,6 +43,9 @@ struct rect;
struct redraw_context;
enum content_debug;
+/**
+ * type of browser window drag in progess
+ */
typedef enum {
DRAGGING_NONE,
DRAGGING_SELECTION,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6083de4ee1370dbd483...
commit 6083de4ee1370dbd483e489e4e63ec2a58becc71
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
split out browser windoe favicon context to separate structure
diff --git a/desktop/browser.c b/desktop/browser.c
index 05e8a6e..8e39c08 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1059,30 +1059,37 @@ static void browser_window_stop_throbber(struct browser_window *bw)
/**
* Callback for fetchcache() for browser window favicon fetches.
+ *
+ * \param c content handle of favicon
+ * \param event The event to process
+ * \param pw a context containing the browser window
+ * \return NSERROR_OK on success else appropriate error code.
*/
-static nserror browser_window_favicon_callback(hlcache_handle *c,
- const hlcache_event *event, void *pw)
+static nserror
+browser_window_favicon_callback(hlcache_handle *c,
+ const hlcache_event *event,
+ void *pw)
{
struct browser_window *bw = pw;
switch (event->type) {
case CONTENT_MSG_DONE:
- if (bw->current_favicon != NULL) {
+ if (bw->favicon.current != NULL) {
content_status status =
- content_get_status(bw->current_favicon);
+ content_get_status(bw->favicon.current);
if ((status == CONTENT_STATUS_READY) ||
(status == CONTENT_STATUS_DONE))
- content_close(bw->current_favicon);
+ content_close(bw->favicon.current);
- hlcache_handle_release(bw->current_favicon);
+ hlcache_handle_release(bw->favicon.current);
}
- bw->current_favicon = c;
- bw->loading_favicon = NULL;
+ bw->favicon.current = c;
+ bw->favicon.loading = NULL;
/* content_get_bitmap on the hlcache_handle should give
- * us the favicon bitmap at this point
+ * the favicon bitmap at this point
*/
guit->window->set_icon(bw->window, c);
break;
@@ -1090,32 +1097,31 @@ static nserror browser_window_favicon_callback(hlcache_handle *c,
case CONTENT_MSG_ERROR:
/* clean up after ourselves */
- if (c == bw->loading_favicon)
- bw->loading_favicon = NULL;
- else if (c == bw->current_favicon) {
- bw->current_favicon = NULL;
+ if (c == bw->favicon.loading) {
+ bw->favicon.loading = NULL;
+ } else if (c == bw->favicon.current) {
+ bw->favicon.current = NULL;
}
hlcache_handle_release(c);
- if (bw->failed_favicon == false) {
+ if (bw->favicon.failed == false) {
nsurl *nsref = NULL;
nsurl *nsurl;
nserror error;
- bw->failed_favicon = true;
+ bw->favicon.failed = true;
error = nsurl_create("resource:favicon.ico", &nsurl);
if (error != NSERROR_OK) {
LOG("Unable to create default location url");
} else {
-
hlcache_handle_retrieve(nsurl,
HLCACHE_RETRIEVE_SNIFF_TYPE,
nsref, NULL,
browser_window_favicon_callback,
bw, NULL, CONTENT_IMAGE,
- &bw->loading_favicon);
+ &bw->favicon.loading);
nsurl_unref(nsurl);
}
@@ -1129,8 +1135,18 @@ static nserror browser_window_favicon_callback(hlcache_handle *c,
return NSERROR_OK;
}
-static void browser_window_update_favicon(hlcache_handle *c,
- struct browser_window *bw, struct content_rfc5988_link *link)
+
+/**
+ * update the favicon associated with the browser window
+ *
+ * \param c the page content handle.
+ * \param bw A top level browser window.
+ * \param link A link context or NULL to attempt fallback scanning.
+ */
+static void
+browser_window_update_favicon(hlcache_handle *c,
+ struct browser_window *bw,
+ struct content_rfc5988_link *link)
{
nsurl *nsref = NULL;
nsurl *nsurl;
@@ -1144,10 +1160,10 @@ static void browser_window_update_favicon(hlcache_handle *c,
return;
/* already fetching the favicon - use that */
- if (bw->loading_favicon != NULL)
+ if (bw->favicon.loading != NULL)
return;
- bw->failed_favicon = false;
+ bw->favicon.failed = false;
if (link == NULL) {
/* Look for "icon" */
@@ -1184,7 +1200,7 @@ static void browser_window_update_favicon(hlcache_handle *c,
/* no favicon via link, try for the default location */
error = nsurl_join(nsurl, "/favicon.ico", &nsurl);
} else {
- bw->failed_favicon = true;
+ bw->favicon.failed = true;
error = nsurl_create("resource:favicon.ico", &nsurl);
}
if (error != NSERROR_OK) {
@@ -1203,7 +1219,7 @@ static void browser_window_update_favicon(hlcache_handle *c,
hlcache_handle_retrieve(nsurl, HLCACHE_RETRIEVE_SNIFF_TYPE,
nsref, NULL, browser_window_favicon_callback,
- bw, NULL, CONTENT_IMAGE, &bw->loading_favicon);
+ bw, NULL, CONTENT_IMAGE, &bw->favicon.loading);
nsurl_unref(nsurl);
}
@@ -1833,21 +1849,22 @@ static void browser_window_destroy_internal(struct browser_window *bw)
bw->current_content = NULL;
}
- if (bw->loading_favicon != NULL) {
- hlcache_handle_abort(bw->loading_favicon);
- hlcache_handle_release(bw->loading_favicon);
- bw->loading_favicon = NULL;
+ if (bw->favicon.loading != NULL) {
+ hlcache_handle_abort(bw->favicon.loading);
+ hlcache_handle_release(bw->favicon.loading);
+ bw->favicon.loading = NULL;
}
- if (bw->current_favicon != NULL) {
- content_status status = content_get_status(bw->current_favicon);
+ if (bw->favicon.current != NULL) {
+ content_status status = content_get_status(bw->favicon.current);
if (status == CONTENT_STATUS_READY ||
- status == CONTENT_STATUS_DONE)
- content_close(bw->current_favicon);
+ status == CONTENT_STATUS_DONE) {
+ content_close(bw->favicon.current);
+ }
- hlcache_handle_release(bw->current_favicon);
- bw->current_favicon = NULL;
+ hlcache_handle_release(bw->favicon.current);
+ bw->favicon.current = NULL;
}
if (bw->box != NULL) {
@@ -1861,8 +1878,9 @@ static void browser_window_destroy_internal(struct browser_window *bw)
/* These simply free memory, so are safe here */
- if (bw->frag_id != NULL)
+ if (bw->frag_id != NULL) {
lwc_string_unref(bw->frag_id);
+ }
browser_window_history_destroy(bw);
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 0234cce..b8dce84 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -46,18 +46,33 @@ struct browser_window {
* READY or DONE status or NULL for no content.
*/
struct hlcache_handle *current_content;
- /** Page being loaded, or NULL. */
+ /**
+ * Content handle of page in process of being loaded or NULL
+ * if no page is being loaded.
+ */
struct hlcache_handle *loading_content;
- /** Page Favicon */
- struct hlcache_handle *current_favicon;
- /** handle for favicon which we started loading early */
- struct hlcache_handle *loading_favicon;
/**
- * flag to indicate favicon fetch already failed which
- * prevents infinite error looping.
+ * Favicon
*/
- bool failed_favicon;
+ struct {
+ /**
+ * content handle of current page favicon
+ */
+ struct hlcache_handle *current;
+
+ /**
+ * content handle for favicon which we started loading
+ * early
+ */
+ struct hlcache_handle *loading;
+
+ /**
+ * flag to indicate favicon fetch already failed which
+ * prevents infinite error looping.
+ */
+ bool failed;
+ } favicon;
/** local history handle. */
struct history *history;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=855721282c01a0cd0c9...
commit 855721282c01a0cd0c94c87e03ac8229da077372
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
split out status bar text cache into separate struct
diff --git a/desktop/browser.c b/desktop/browser.c
index d0114ef..05e8a6e 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -87,7 +87,6 @@
* \param x Updated to x-coord of top left of scrollbar widget
* \param y Updated to y-coord of top left of scrollbar widget
*/
-
static inline void browser_window_get_scrollbar_pos(struct browser_window *bw,
bool horizontal, int *x, int *y)
{
@@ -129,6 +128,7 @@ browser_window_get_name(struct browser_window *bw, const char **out_name)
return NSERROR_OK;
}
+
/* exported interface, documented in browser.h */
nserror
browser_window_set_name(struct browser_window *bw, const char *name)
@@ -153,6 +153,7 @@ browser_window_set_name(struct browser_window *bw, const char *name)
return NSERROR_OK;
}
+
/* exported interface, documented in browser.h */
bool
browser_window_redraw(struct browser_window *bw,
@@ -330,6 +331,7 @@ browser_window_redraw(struct browser_window *bw,
return plot_ok;
}
+
/* exported interface, documented in browser.h */
bool browser_window_redraw_ready(struct browser_window *bw)
{
@@ -344,6 +346,7 @@ bool browser_window_redraw_ready(struct browser_window *bw)
return true;
}
+
/* exported interface, documented in browser_private.h */
void browser_window_update_extent(struct browser_window *bw)
{
@@ -355,9 +358,13 @@ void browser_window_update_extent(struct browser_window *bw)
browser_window_handle_scrollbars(bw);
}
+
/* exported interface, documented in browser.h */
-void browser_window_get_position(struct browser_window *bw, bool root,
- int *pos_x, int *pos_y)
+void
+browser_window_get_position(struct browser_window *bw,
+ bool root,
+ int *pos_x,
+ int *pos_y)
{
*pos_x = 0;
*pos_y = 0;
@@ -397,6 +404,7 @@ void browser_window_get_position(struct browser_window *bw, bool root,
}
}
+
/* exported interface, documented in browser.h */
void browser_window_set_position(struct browser_window *bw, int x, int y)
{
@@ -939,10 +947,10 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
bw->focus = NULL;
/* initialise status text cache */
- bw->status_text = NULL;
- bw->status_text_len = 0;
- bw->status_match = 0;
- bw->status_miss = 0;
+ bw->status.text = NULL;
+ bw->status.text_len = 0;
+ bw->status.match = 0;
+ bw->status.miss = 0;
return NSERROR_OK;
}
@@ -1318,8 +1326,10 @@ static void browser_window_convert_to_download(struct browser_window *bw,
/**
* Browser window content event callback handler.
*/
-static nserror browser_window_callback(hlcache_handle *c,
- const hlcache_event *event, void *pw)
+static nserror
+browser_window_callback(hlcache_handle *c,
+ const hlcache_event *event,
+ void *pw)
{
struct browser_window *bw = pw;
nserror res = NSERROR_OK;
@@ -1857,9 +1867,9 @@ static void browser_window_destroy_internal(struct browser_window *bw)
browser_window_history_destroy(bw);
free(bw->name);
- free(bw->status_text);
- bw->status_text = NULL;
- LOG("Status text cache match:miss %d:%d", bw->status_match, bw->status_miss);
+ free(bw->status.text);
+ bw->status.text = NULL;
+ LOG("Status text cache match:miss %d:%d", bw->status.match, bw->status.miss);
}
/**
@@ -1931,7 +1941,8 @@ nserror browser_window_refresh_url_bar(struct browser_window *bw)
/* exported interface documented in netsurf/browser_window.h */
-nserror browser_window_navigate(struct browser_window *bw,
+nserror
+browser_window_navigate(struct browser_window *bw,
nsurl *url,
nsurl *referrer,
enum browser_window_nav_flags flags,
@@ -2289,14 +2300,16 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
browser_window_update_extent(bw);
- if (scroll_to_top)
- browser_window_set_scroll(bw, 0, 0);
-
/* if frag_id exists, then try to scroll to it */
/** @todo don't do this if the user has scrolled */
- if (bw->frag_id && html_get_id_offset(bw->current_content,
- bw->frag_id, &x, &y)) {
+ if (bw->frag_id &&
+ html_get_id_offset(bw->current_content,
+ bw->frag_id, &x, &y)) {
browser_window_set_scroll(bw, x, y);
+ } else {
+ if (scroll_to_top) {
+ browser_window_set_scroll(bw, 0, 0);
+ }
}
guit->window->redraw(bw->window);
@@ -2476,10 +2489,10 @@ void browser_window_set_status(struct browser_window *bw, const char *text)
while (bw->parent)
bw = bw->parent;
- if ((bw->status_text != NULL) &&
- (strcmp(text, bw->status_text) == 0)) {
+ if ((bw->status.text != NULL) &&
+ (strcmp(text, bw->status.text) == 0)) {
/* status text is unchanged */
- bw->status_match++;
+ bw->status.match++;
return;
}
@@ -2487,18 +2500,18 @@ void browser_window_set_status(struct browser_window *bw, const char *text)
text_len = strlen(text);
- if ((bw->status_text == NULL) || (bw->status_text_len < text_len)) {
+ if ((bw->status.text == NULL) || (bw->status.text_len < text_len)) {
/* no current string allocation or it is not long enough */
- free(bw->status_text);
- bw->status_text = strdup(text);
- bw->status_text_len = text_len;
+ free(bw->status.text);
+ bw->status.text = strdup(text);
+ bw->status.text_len = text_len;
} else {
/* current allocation has enough space */
- memcpy(bw->status_text, text, text_len + 1);
+ memcpy(bw->status.text, text, text_len + 1);
}
- bw->status_miss++;
- guit->window->set_status(bw->window, bw->status_text);
+ bw->status.miss++;
+ guit->window->set_status(bw->window, bw->status.text);
}
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 072a894..0234cce 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -37,24 +37,34 @@ struct gui_window;
struct history;
struct selection;
-/** Browser window data. */
+/**
+ * Browser window data.
+ */
struct browser_window {
- /** Page currently displayed, or 0. Must have status READY or DONE. */
+ /**
+ * Content handle of page currently displayed which must have
+ * READY or DONE status or NULL for no content.
+ */
struct hlcache_handle *current_content;
- /** Page being loaded, or 0. */
+ /** Page being loaded, or NULL. */
struct hlcache_handle *loading_content;
/** Page Favicon */
struct hlcache_handle *current_favicon;
/** handle for favicon which we started loading early */
struct hlcache_handle *loading_favicon;
- /** favicon fetch already failed - prevents infinite error looping */
+ /**
+ * flag to indicate favicon fetch already failed which
+ * prevents infinite error looping.
+ */
bool failed_favicon;
- /** Window history structure. */
+ /** local history handle. */
struct history *history;
- /** Platform specific window data. */
+ /**
+ * Platform specific window data only valid at top level.
+ */
struct gui_window *window;
/** Busy indicator is active. */
@@ -156,14 +166,15 @@ struct browser_window {
struct jscontext *jsctx;
/** cache of the currently displayed status text. */
- char *status_text; /**< Current status bar text. */
- int status_text_len; /**< Length of the browser_window::status_text buffer. */
- int status_match; /**< Number of times an idempotent status-set operation was performed. */
- int status_miss; /**< Number of times status was really updated. */
+ struct {
+ char *text; /**< Current status bar text. */
+ int text_len; /**< Length of the status::text buffer. */
+ int match; /**< Number of times an idempotent status-set operation was performed. */
+ int miss; /**< Number of times status was really updated. */
+ } status;
};
-
/**
* Initialise common parts of a browser window
*
@@ -174,6 +185,7 @@ struct browser_window {
nserror browser_window_initialise_common(enum browser_window_create_flags flags,
struct browser_window *bw, struct browser_window *existing);
+
/**
* Get the dimensions of the area a browser window occupies
*
@@ -185,6 +197,7 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
void browser_window_get_dimensions(struct browser_window *bw,
int *width, int *height, bool scaled);
+
/**
* Update the extent of the inside of a browser window to that of the current
* content
@@ -193,6 +206,7 @@ void browser_window_get_dimensions(struct browser_window *bw,
*/
void browser_window_update_extent(struct browser_window *bw);
+
/**
* Change the status bar of a browser window.
*
@@ -201,6 +215,7 @@ void browser_window_update_extent(struct browser_window *bw);
*/
void browser_window_set_status(struct browser_window *bw, const char *text);
+
/**
* Get the root level browser window
*
-----------------------------------------------------------------------
Summary of changes:
desktop/browser.c | 247 ++++++++++++++++++++++----------------
desktop/browser_private.h | 103 +++++++++++-----
desktop/frames.c | 42 ++++---
include/netsurf/browser_window.h | 3 +
4 files changed, 242 insertions(+), 153 deletions(-)
diff --git a/desktop/browser.c b/desktop/browser.c
index d0114ef..0a4afc1 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -87,7 +87,6 @@
* \param x Updated to x-coord of top left of scrollbar widget
* \param y Updated to y-coord of top left of scrollbar widget
*/
-
static inline void browser_window_get_scrollbar_pos(struct browser_window *bw,
bool horizontal, int *x, int *y)
{
@@ -129,6 +128,7 @@ browser_window_get_name(struct browser_window *bw, const char **out_name)
return NSERROR_OK;
}
+
/* exported interface, documented in browser.h */
nserror
browser_window_set_name(struct browser_window *bw, const char *name)
@@ -153,6 +153,7 @@ browser_window_set_name(struct browser_window *bw, const char *name)
return NSERROR_OK;
}
+
/* exported interface, documented in browser.h */
bool
browser_window_redraw(struct browser_window *bw,
@@ -330,6 +331,7 @@ browser_window_redraw(struct browser_window *bw,
return plot_ok;
}
+
/* exported interface, documented in browser.h */
bool browser_window_redraw_ready(struct browser_window *bw)
{
@@ -344,6 +346,7 @@ bool browser_window_redraw_ready(struct browser_window *bw)
return true;
}
+
/* exported interface, documented in browser_private.h */
void browser_window_update_extent(struct browser_window *bw)
{
@@ -355,9 +358,13 @@ void browser_window_update_extent(struct browser_window *bw)
browser_window_handle_scrollbars(bw);
}
+
/* exported interface, documented in browser.h */
-void browser_window_get_position(struct browser_window *bw, bool root,
- int *pos_x, int *pos_y)
+void
+browser_window_get_position(struct browser_window *bw,
+ bool root,
+ int *pos_x,
+ int *pos_y)
{
*pos_x = 0;
*pos_y = 0;
@@ -397,6 +404,7 @@ void browser_window_get_position(struct browser_window *bw, bool root,
}
}
+
/* exported interface, documented in browser.h */
void browser_window_set_position(struct browser_window *bw, int x, int y)
{
@@ -413,22 +421,24 @@ void browser_window_set_position(struct browser_window *bw, int x, int y)
}
/* exported interface, documented in browser.h */
-void browser_window_set_drag_type(struct browser_window *bw,
- browser_drag_type type, const struct rect *rect)
+void
+browser_window_set_drag_type(struct browser_window *bw,
+ browser_drag_type type,
+ const struct rect *rect)
{
struct browser_window *top_bw = browser_window_get_root(bw);
gui_drag_type gtype;
- bw->drag_type = type;
+ bw->drag.type = type;
if (type == DRAGGING_NONE) {
- top_bw->drag_window = NULL;
+ top_bw->drag.window = NULL;
} else {
- top_bw->drag_window = bw;
+ top_bw->drag.window = bw;
switch (type) {
case DRAGGING_SELECTION:
- /* TODO: tell front end */
+ /** \todo tell front end */
return;
case DRAGGING_SCR_X:
case DRAGGING_SCR_Y:
@@ -447,7 +457,7 @@ void browser_window_set_drag_type(struct browser_window *bw,
/* exported interface, documented in browser.h */
browser_drag_type browser_window_get_drag_type(struct browser_window *bw)
{
- return bw->drag_type;
+ return bw->drag.type;
}
/* exported interface, documented in browser.h */
@@ -931,7 +941,7 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
/* window characteristics */
bw->refresh_interval = -1;
- bw->drag_type = DRAGGING_NONE;
+ bw->drag.type = DRAGGING_NONE;
bw->scroll_x = NULL;
bw->scroll_y = NULL;
@@ -939,10 +949,10 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
bw->focus = NULL;
/* initialise status text cache */
- bw->status_text = NULL;
- bw->status_text_len = 0;
- bw->status_match = 0;
- bw->status_miss = 0;
+ bw->status.text = NULL;
+ bw->status.text_len = 0;
+ bw->status.match = 0;
+ bw->status.miss = 0;
return NSERROR_OK;
}
@@ -1051,30 +1061,37 @@ static void browser_window_stop_throbber(struct browser_window *bw)
/**
* Callback for fetchcache() for browser window favicon fetches.
+ *
+ * \param c content handle of favicon
+ * \param event The event to process
+ * \param pw a context containing the browser window
+ * \return NSERROR_OK on success else appropriate error code.
*/
-static nserror browser_window_favicon_callback(hlcache_handle *c,
- const hlcache_event *event, void *pw)
+static nserror
+browser_window_favicon_callback(hlcache_handle *c,
+ const hlcache_event *event,
+ void *pw)
{
struct browser_window *bw = pw;
switch (event->type) {
case CONTENT_MSG_DONE:
- if (bw->current_favicon != NULL) {
+ if (bw->favicon.current != NULL) {
content_status status =
- content_get_status(bw->current_favicon);
+ content_get_status(bw->favicon.current);
if ((status == CONTENT_STATUS_READY) ||
(status == CONTENT_STATUS_DONE))
- content_close(bw->current_favicon);
+ content_close(bw->favicon.current);
- hlcache_handle_release(bw->current_favicon);
+ hlcache_handle_release(bw->favicon.current);
}
- bw->current_favicon = c;
- bw->loading_favicon = NULL;
+ bw->favicon.current = c;
+ bw->favicon.loading = NULL;
/* content_get_bitmap on the hlcache_handle should give
- * us the favicon bitmap at this point
+ * the favicon bitmap at this point
*/
guit->window->set_icon(bw->window, c);
break;
@@ -1082,32 +1099,31 @@ static nserror browser_window_favicon_callback(hlcache_handle *c,
case CONTENT_MSG_ERROR:
/* clean up after ourselves */
- if (c == bw->loading_favicon)
- bw->loading_favicon = NULL;
- else if (c == bw->current_favicon) {
- bw->current_favicon = NULL;
+ if (c == bw->favicon.loading) {
+ bw->favicon.loading = NULL;
+ } else if (c == bw->favicon.current) {
+ bw->favicon.current = NULL;
}
hlcache_handle_release(c);
- if (bw->failed_favicon == false) {
+ if (bw->favicon.failed == false) {
nsurl *nsref = NULL;
nsurl *nsurl;
nserror error;
- bw->failed_favicon = true;
+ bw->favicon.failed = true;
error = nsurl_create("resource:favicon.ico", &nsurl);
if (error != NSERROR_OK) {
LOG("Unable to create default location url");
} else {
-
hlcache_handle_retrieve(nsurl,
HLCACHE_RETRIEVE_SNIFF_TYPE,
nsref, NULL,
browser_window_favicon_callback,
bw, NULL, CONTENT_IMAGE,
- &bw->loading_favicon);
+ &bw->favicon.loading);
nsurl_unref(nsurl);
}
@@ -1121,8 +1137,18 @@ static nserror browser_window_favicon_callback(hlcache_handle *c,
return NSERROR_OK;
}
-static void browser_window_update_favicon(hlcache_handle *c,
- struct browser_window *bw, struct content_rfc5988_link *link)
+
+/**
+ * update the favicon associated with the browser window
+ *
+ * \param c the page content handle.
+ * \param bw A top level browser window.
+ * \param link A link context or NULL to attempt fallback scanning.
+ */
+static void
+browser_window_update_favicon(hlcache_handle *c,
+ struct browser_window *bw,
+ struct content_rfc5988_link *link)
{
nsurl *nsref = NULL;
nsurl *nsurl;
@@ -1136,10 +1162,10 @@ static void browser_window_update_favicon(hlcache_handle *c,
return;
/* already fetching the favicon - use that */
- if (bw->loading_favicon != NULL)
+ if (bw->favicon.loading != NULL)
return;
- bw->failed_favicon = false;
+ bw->favicon.failed = false;
if (link == NULL) {
/* Look for "icon" */
@@ -1176,7 +1202,7 @@ static void browser_window_update_favicon(hlcache_handle *c,
/* no favicon via link, try for the default location */
error = nsurl_join(nsurl, "/favicon.ico", &nsurl);
} else {
- bw->failed_favicon = true;
+ bw->favicon.failed = true;
error = nsurl_create("resource:favicon.ico", &nsurl);
}
if (error != NSERROR_OK) {
@@ -1195,7 +1221,7 @@ static void browser_window_update_favicon(hlcache_handle *c,
hlcache_handle_retrieve(nsurl, HLCACHE_RETRIEVE_SNIFF_TYPE,
nsref, NULL, browser_window_favicon_callback,
- bw, NULL, CONTENT_IMAGE, &bw->loading_favicon);
+ bw, NULL, CONTENT_IMAGE, &bw->favicon.loading);
nsurl_unref(nsurl);
}
@@ -1318,8 +1344,10 @@ static void browser_window_convert_to_download(struct browser_window *bw,
/**
* Browser window content event callback handler.
*/
-static nserror browser_window_callback(hlcache_handle *c,
- const hlcache_event *event, void *pw)
+static nserror
+browser_window_callback(hlcache_handle *c,
+ const hlcache_event *event,
+ void *pw)
{
struct browser_window *bw = pw;
nserror res = NSERROR_OK;
@@ -1823,21 +1851,22 @@ static void browser_window_destroy_internal(struct browser_window *bw)
bw->current_content = NULL;
}
- if (bw->loading_favicon != NULL) {
- hlcache_handle_abort(bw->loading_favicon);
- hlcache_handle_release(bw->loading_favicon);
- bw->loading_favicon = NULL;
+ if (bw->favicon.loading != NULL) {
+ hlcache_handle_abort(bw->favicon.loading);
+ hlcache_handle_release(bw->favicon.loading);
+ bw->favicon.loading = NULL;
}
- if (bw->current_favicon != NULL) {
- content_status status = content_get_status(bw->current_favicon);
+ if (bw->favicon.current != NULL) {
+ content_status status = content_get_status(bw->favicon.current);
if (status == CONTENT_STATUS_READY ||
- status == CONTENT_STATUS_DONE)
- content_close(bw->current_favicon);
+ status == CONTENT_STATUS_DONE) {
+ content_close(bw->favicon.current);
+ }
- hlcache_handle_release(bw->current_favicon);
- bw->current_favicon = NULL;
+ hlcache_handle_release(bw->favicon.current);
+ bw->favicon.current = NULL;
}
if (bw->box != NULL) {
@@ -1851,15 +1880,16 @@ static void browser_window_destroy_internal(struct browser_window *bw)
/* These simply free memory, so are safe here */
- if (bw->frag_id != NULL)
+ if (bw->frag_id != NULL) {
lwc_string_unref(bw->frag_id);
+ }
browser_window_history_destroy(bw);
free(bw->name);
- free(bw->status_text);
- bw->status_text = NULL;
- LOG("Status text cache match:miss %d:%d", bw->status_match, bw->status_miss);
+ free(bw->status.text);
+ bw->status.text = NULL;
+ LOG("Status text cache match:miss %d:%d", bw->status.match, bw->status.miss);
}
/**
@@ -1931,7 +1961,8 @@ nserror browser_window_refresh_url_bar(struct browser_window *bw)
/* exported interface documented in netsurf/browser_window.h */
-nserror browser_window_navigate(struct browser_window *bw,
+nserror
+browser_window_navigate(struct browser_window *bw,
nsurl *url,
nsurl *referrer,
enum browser_window_nav_flags flags,
@@ -2289,14 +2320,16 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
browser_window_update_extent(bw);
- if (scroll_to_top)
- browser_window_set_scroll(bw, 0, 0);
-
/* if frag_id exists, then try to scroll to it */
/** @todo don't do this if the user has scrolled */
- if (bw->frag_id && html_get_id_offset(bw->current_content,
- bw->frag_id, &x, &y)) {
+ if (bw->frag_id &&
+ html_get_id_offset(bw->current_content,
+ bw->frag_id, &x, &y)) {
browser_window_set_scroll(bw, x, y);
+ } else {
+ if (scroll_to_top) {
+ browser_window_set_scroll(bw, 0, 0);
+ }
}
guit->window->redraw(bw->window);
@@ -2476,10 +2509,10 @@ void browser_window_set_status(struct browser_window *bw, const char *text)
while (bw->parent)
bw = bw->parent;
- if ((bw->status_text != NULL) &&
- (strcmp(text, bw->status_text) == 0)) {
+ if ((bw->status.text != NULL) &&
+ (strcmp(text, bw->status.text) == 0)) {
/* status text is unchanged */
- bw->status_match++;
+ bw->status.match++;
return;
}
@@ -2487,18 +2520,18 @@ void browser_window_set_status(struct browser_window *bw, const char *text)
text_len = strlen(text);
- if ((bw->status_text == NULL) || (bw->status_text_len < text_len)) {
+ if ((bw->status.text == NULL) || (bw->status.text_len < text_len)) {
/* no current string allocation or it is not long enough */
- free(bw->status_text);
- bw->status_text = strdup(text);
- bw->status_text_len = text_len;
+ free(bw->status.text);
+ bw->status.text = strdup(text);
+ bw->status.text_len = text_len;
} else {
/* current allocation has enough space */
- memcpy(bw->status_text, text, text_len + 1);
+ memcpy(bw->status.text, text, text_len + 1);
}
- bw->status_miss++;
- guit->window->set_status(bw->window, bw->status_text);
+ bw->status.miss++;
+ guit->window->set_status(bw->window, bw->status.text);
}
@@ -2848,7 +2881,7 @@ static void browser_window_mouse_drag_end(struct browser_window *bw,
{
int scr_x, scr_y;
- switch (bw->drag_type) {
+ switch (bw->drag.type) {
case DRAGGING_SELECTION:
case DRAGGING_OTHER:
case DRAGGING_CONTENT_SCROLLBAR:
@@ -2864,7 +2897,7 @@ static void browser_window_mouse_drag_end(struct browser_window *bw,
scrollbar_mouse_drag_end(bw->scroll_x, mouse, scr_x, scr_y);
- bw->drag_type = DRAGGING_NONE;
+ bw->drag.type = DRAGGING_NONE;
break;
case DRAGGING_SCR_Y:
@@ -2876,7 +2909,7 @@ static void browser_window_mouse_drag_end(struct browser_window *bw,
scrollbar_mouse_drag_end(bw->scroll_y, mouse, scr_x, scr_y);
- bw->drag_type = DRAGGING_NONE;
+ bw->drag.type = DRAGGING_NONE;
break;
default:
@@ -2894,11 +2927,11 @@ void browser_window_mouse_track(struct browser_window *bw,
const char *status = NULL;
browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
- if (bw->window != NULL && bw->drag_window && bw != bw->drag_window) {
+ if (bw->window != NULL && bw->drag.window && bw != bw->drag.window) {
/* This is the root browser window and there's an active drag
* in a sub window.
* Pass the mouse action straight on to that bw. */
- struct browser_window *drag_bw = bw->drag_window;
+ struct browser_window *drag_bw = bw->drag.window;
int off_x = 0;
int off_y = 0;
@@ -2951,25 +2984,27 @@ void browser_window_mouse_track(struct browser_window *bw,
return;
}
- if (c == NULL && bw->drag_type != DRAGGING_FRAME)
+ if (c == NULL && bw->drag.type != DRAGGING_FRAME) {
return;
+ }
- if (bw->drag_type != DRAGGING_NONE && !mouse) {
+ if (bw->drag.type != DRAGGING_NONE && !mouse) {
browser_window_mouse_drag_end(bw, mouse, x, y);
}
/* Browser window's horizontal scrollbar */
- if (bw->scroll_x != NULL && bw->drag_type != DRAGGING_SCR_Y) {
+ if (bw->scroll_x != NULL && bw->drag.type != DRAGGING_SCR_Y) {
int scr_x, scr_y;
browser_window_get_scrollbar_pos(bw, true, &scr_x, &scr_y);
scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
- if ((scr_x > 0 && scr_x < browser_window_get_scrollbar_len(bw,
- true) &&
- scr_y > 0 && scr_y < SCROLLBAR_WIDTH &&
- bw->drag_type == DRAGGING_NONE) ||
- bw->drag_type == DRAGGING_SCR_X) {
+ if ((bw->drag.type == DRAGGING_SCR_X) ||
+ (scr_x > 0 &&
+ scr_x < browser_window_get_scrollbar_len(bw, true) &&
+ scr_y > 0 &&
+ scr_y < SCROLLBAR_WIDTH &&
+ bw->drag.type == DRAGGING_NONE)) {
/* Start a scrollbar drag, or continue existing drag */
status = scrollbar_mouse_status_to_message(
scrollbar_mouse_action(
@@ -2977,8 +3012,9 @@ void browser_window_mouse_track(struct browser_window *bw,
scr_x, scr_y));
pointer = BROWSER_POINTER_DEFAULT;
- if (status != NULL)
+ if (status != NULL) {
browser_window_set_status(bw, status);
+ }
browser_window_set_pointer(bw, pointer);
return;
@@ -2992,11 +3028,12 @@ void browser_window_mouse_track(struct browser_window *bw,
scr_x = x - scr_x - scrollbar_get_offset(bw->scroll_x);
scr_y = y - scr_y - scrollbar_get_offset(bw->scroll_y);
- if ((scr_y > 0 && scr_y < browser_window_get_scrollbar_len(bw,
- false) &&
- scr_x > 0 && scr_x < SCROLLBAR_WIDTH &&
- bw->drag_type == DRAGGING_NONE) ||
- bw->drag_type == DRAGGING_SCR_Y) {
+ if ((bw->drag.type == DRAGGING_SCR_Y) ||
+ (scr_y > 0 &&
+ scr_y < browser_window_get_scrollbar_len(bw, false) &&
+ scr_x > 0 &&
+ scr_x < SCROLLBAR_WIDTH &&
+ bw->drag.type == DRAGGING_NONE)) {
/* Start a scrollbar drag, or continue existing drag */
status = scrollbar_mouse_status_to_message(
scrollbar_mouse_action(
@@ -3004,27 +3041,28 @@ void browser_window_mouse_track(struct browser_window *bw,
scr_x, scr_y));
pointer = BROWSER_POINTER_DEFAULT;
- if (status != NULL)
+ if (status != NULL) {
browser_window_set_status(bw, status);
+ }
browser_window_set_pointer(bw, pointer);
return;
}
}
- if (bw->drag_type == DRAGGING_FRAME) {
+ if (bw->drag.type == DRAGGING_FRAME) {
browser_window_resize_frame(bw, bw->x + x, bw->y + y);
- } else if (bw->drag_type == DRAGGING_PAGE_SCROLL) {
+ } else if (bw->drag.type == DRAGGING_PAGE_SCROLL) {
/* mouse movement since drag started */
- int scrollx = bw->drag_start_x - x;
- int scrolly = bw->drag_start_y - y;
+ int scrollx = bw->drag.start_x - x;
+ int scrolly = bw->drag.start_y - y;
/* new scroll offsets */
- scrollx += bw->drag_start_scroll_x;
- scrolly += bw->drag_start_scroll_y;
+ scrollx += bw->drag.start_scroll_x;
+ scrolly += bw->drag.start_scroll_y;
- bw->drag_start_scroll_x = scrollx;
- bw->drag_start_scroll_y = scrolly;
+ bw->drag.start_scroll_x = scrollx;
+ bw->drag.start_scroll_y = scrolly;
browser_window_set_scroll(bw, scrollx, scrolly);
} else {
@@ -3174,19 +3212,20 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y)
browser_window_set_drag_type(bw, DRAGGING_PAGE_SCROLL, NULL);
- bw->drag_start_x = x;
- bw->drag_start_y = y;
+ bw->drag.start_x = x;
+ bw->drag.start_y = y;
if (bw->window != NULL) {
/* Front end window */
- guit->window->get_scroll(bw->window, &bw->drag_start_scroll_x,
- &bw->drag_start_scroll_y);
+ guit->window->get_scroll(bw->window,
+ &bw->drag.start_scroll_x,
+ &bw->drag.start_scroll_y);
guit->window->scroll_start(bw->window);
} else {
/* Core managed browser window */
- bw->drag_start_scroll_x = scrollbar_get_offset(bw->scroll_x);
- bw->drag_start_scroll_y = scrollbar_get_offset(bw->scroll_y);
+ bw->drag.start_scroll_x = scrollbar_get_offset(bw->scroll_x);
+ bw->drag.start_scroll_y = scrollbar_get_offset(bw->scroll_y);
}
}
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 072a894..3e9b846 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -37,24 +37,49 @@ struct gui_window;
struct history;
struct selection;
-/** Browser window data. */
+/**
+ * Browser window data.
+ */
struct browser_window {
- /** Page currently displayed, or 0. Must have status READY or DONE. */
+ /**
+ * Content handle of page currently displayed which must have
+ * READY or DONE status or NULL for no content.
+ */
struct hlcache_handle *current_content;
- /** Page being loaded, or 0. */
+ /**
+ * Content handle of page in process of being loaded or NULL
+ * if no page is being loaded.
+ */
struct hlcache_handle *loading_content;
- /** Page Favicon */
- struct hlcache_handle *current_favicon;
- /** handle for favicon which we started loading early */
- struct hlcache_handle *loading_favicon;
- /** favicon fetch already failed - prevents infinite error looping */
- bool failed_favicon;
-
- /** Window history structure. */
+ /**
+ * Favicon
+ */
+ struct {
+ /**
+ * content handle of current page favicon
+ */
+ struct hlcache_handle *current;
+
+ /**
+ * content handle for favicon which we started loading
+ * early
+ */
+ struct hlcache_handle *loading;
+
+ /**
+ * flag to indicate favicon fetch already failed which
+ * prevents infinite error looping.
+ */
+ bool failed;
+ } favicon;
+
+ /** local history handle. */
struct history *history;
- /** Platform specific window data. */
+ /**
+ * Platform specific window data only valid at top level.
+ */
struct gui_window *window;
/** Busy indicator is active. */
@@ -65,23 +90,32 @@ struct browser_window {
/** Fragment identifier for current_content. */
lwc_string *frag_id;
- /** Current drag status. */
- browser_drag_type drag_type;
+ /**
+ * Current drag status.
+ *
+ * These values are only vald whle type is not DRAGGING_NONE
+ */
+ struct {
+ /** the type of drag in progress */
+ browser_drag_type type;
+
+ /** Current drag's browser window, when not in root bw. */
+ struct browser_window *window;
+
+ /** Mouse position at start of current scroll drag. */
+ int start_x;
+ int start_y;
- /** Current drag's browser window, when not in root bw. */
- struct browser_window *drag_window;
+ /** Scroll offsets at start of current scroll draw. */
+ int start_scroll_x;
+ int start_scroll_y;
- /** Mouse position at start of current scroll drag. */
- int drag_start_x;
- int drag_start_y;
- /** Scroll offsets at start of current scroll draw. */
- int drag_start_scroll_x;
- int drag_start_scroll_y;
- /** Frame resize directions for current frame resize drag. */
- unsigned int drag_resize_left : 1;
- unsigned int drag_resize_right : 1;
- unsigned int drag_resize_up : 1;
- unsigned int drag_resize_down : 1;
+ /** Frame resize directions for current frame resize drag. */
+ unsigned int resize_left : 1;
+ unsigned int resize_right : 1;
+ unsigned int resize_up : 1;
+ unsigned int resize_down : 1;
+ } drag;
/** Current fetch is download */
bool download;
@@ -156,14 +190,15 @@ struct browser_window {
struct jscontext *jsctx;
/** cache of the currently displayed status text. */
- char *status_text; /**< Current status bar text. */
- int status_text_len; /**< Length of the browser_window::status_text buffer. */
- int status_match; /**< Number of times an idempotent status-set operation was performed. */
- int status_miss; /**< Number of times status was really updated. */
+ struct {
+ char *text; /**< Current status bar text. */
+ int text_len; /**< Length of the status::text buffer. */
+ int match; /**< Number of times an idempotent status-set operation was performed. */
+ int miss; /**< Number of times status was really updated. */
+ } status;
};
-
/**
* Initialise common parts of a browser window
*
@@ -174,6 +209,7 @@ struct browser_window {
nserror browser_window_initialise_common(enum browser_window_create_flags flags,
struct browser_window *bw, struct browser_window *existing);
+
/**
* Get the dimensions of the area a browser window occupies
*
@@ -185,6 +221,7 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
void browser_window_get_dimensions(struct browser_window *bw,
int *width, int *height, bool scaled);
+
/**
* Update the extent of the inside of a browser window to that of the current
* content
@@ -193,6 +230,7 @@ void browser_window_get_dimensions(struct browser_window *bw,
*/
void browser_window_update_extent(struct browser_window *bw);
+
/**
* Change the status bar of a browser window.
*
@@ -201,6 +239,7 @@ void browser_window_update_extent(struct browser_window *bw);
*/
void browser_window_set_status(struct browser_window *bw, const char *text);
+
/**
* Get the root level browser window
*
diff --git a/desktop/frames.c b/desktop/frames.c
index 70e51e7..9eefefe 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -675,25 +675,31 @@ void browser_window_resize_frame(struct browser_window *bw, int x, int y)
assert((col >= 0) && (row >= 0));
sibling = NULL;
- if (bw->drag_resize_left)
+ if (bw->drag.resize_left) {
sibling = &parent->children[row * parent->cols + (col - 1)];
- else if (bw->drag_resize_right)
+ } else if (bw->drag.resize_right) {
sibling = &parent->children[row * parent->cols + (col + 1)];
- if (sibling)
+ }
+ if (sibling) {
change |= browser_window_resolve_frame_dimension(bw, sibling,
x, y, true, false);
+ }
sibling = NULL;
- if (bw->drag_resize_up)
+ if (bw->drag.resize_up) {
sibling = &parent->children[(row - 1) * parent->cols + col];
- else if (bw->drag_resize_down)
+ } else if (bw->drag.resize_down) {
sibling = &parent->children[(row + 1) * parent->cols + col];
- if (sibling)
+ }
+
+ if (sibling) {
change |= browser_window_resolve_frame_dimension(bw, sibling,
x, y, false, true);
+ }
- if (change)
+ if (change) {
browser_window_recalculate_frameset(parent);
+ }
}
@@ -711,20 +717,22 @@ bool browser_window_resolve_frame_dimension(struct browser_window *bw,
/* extend/shrink the box to the pointer */
if (width) {
- if (bw->drag_resize_left)
+ if (bw->drag.resize_left) {
bw_dimension = bw->x + bw->width - x;
- else
+ } else {
bw_dimension = x - bw->x;
+ }
bw_pixels = bw->width;
sibling_pixels = sibling->width;
bw_d = &bw->frame_width;
sibling_d = &sibling->frame_width;
frame_size = bw->parent->width;
} else {
- if (bw->drag_resize_up)
+ if (bw->drag.resize_up) {
bw_dimension = bw->y + bw->height - y;
- else
+ } else {
bw_dimension = y - bw->y;
+ }
bw_pixels = bw->height;
sibling_pixels = sibling->height;
bw_d = &bw->frame_height;
@@ -919,12 +927,12 @@ static bool browser_window_resize_frames(struct browser_window *bw,
* front end to clamp pointer range */
browser_window_set_drag_type(bw,
DRAGGING_FRAME, NULL);
- bw->drag_start_x = x;
- bw->drag_start_y = y;
- bw->drag_resize_left = left;
- bw->drag_resize_right = right;
- bw->drag_resize_up = up;
- bw->drag_resize_down = down;
+ bw->drag.start_x = x;
+ bw->drag.start_y = y;
+ bw->drag.resize_left = left;
+ bw->drag.resize_right = right;
+ bw->drag.resize_up = up;
+ bw->drag.resize_down = down;
}
return true;
}
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 482dcb9..858d4ae 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -43,6 +43,9 @@ struct rect;
struct redraw_context;
enum content_debug;
+/**
+ * type of browser window drag in progess
+ */
typedef enum {
DRAGGING_NONE,
DRAGGING_SELECTION,
--
NetSurf Browser
5 years, 11 months
netsurf: branch master updated. release/3.6-282-g028c4e2
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/028c4e2860a5cf75ce8a3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/028c4e2860a5cf75ce8a3b9...
...tree http://git.netsurf-browser.org/netsurf.git/tree/028c4e2860a5cf75ce8a3b97c...
The branch, master has been updated
via 028c4e2860a5cf75ce8a3b97c04d12adaee7ef1b (commit)
from 44c5aef1c8a79a3a9afbd472d1f6e6e238c8ed5c (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/commit/?id=028c4e2860a5cf75ce8...
commit 028c4e2860a5cf75ce8a3b97c04d12adaee7ef1b
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
improve documentation comments in ssl certificate viewer
diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c
index 09a281c..e7f87bd 100644
--- a/desktop/sslcert_viewer.c
+++ b/desktop/sslcert_viewer.c
@@ -17,8 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * SSL Certificate verification UI (implementation)
+/**
+ * \file
+ * SSL Certificate verification UI implementation
*/
#include <assert.h>
@@ -33,6 +34,9 @@
#include "utils/log.h"
#include "utils/utils.h"
+/**
+ * ssl certificate viewer data fields
+ */
enum sslcert_viewer_field {
SSLCERT_V_SUBJECT,
SSLCERT_V_SERIAL,
@@ -45,7 +49,10 @@ enum sslcert_viewer_field {
SSLCERT_V_N_FIELDS
};
-/** ssl certificate verification context. */
+
+/**
+ * ssl certificate verification context.
+ */
struct sslcert_session_data {
struct ssl_cert_info *certs; /**< Certificates */
unsigned long num; /**< Number of certificates in chain */
@@ -57,6 +64,10 @@ struct sslcert_session_data {
struct treeview_field_desc fields[SSLCERT_V_N_FIELDS];
};
+
+/**
+ * ssl certificate tree entry
+ */
struct sslcert_entry {
treeview_node *entry;
char version[24];
@@ -67,12 +78,11 @@ struct sslcert_entry {
/**
- * Free a sll certificate viewer entry's treeview field data.
+ * Free a ssl certificate viewer entry's treeview field data.
*
- * \param e Entry to free data from
+ * \param e Entry to free data from
*/
-static void sslcert_viewer_free_treeview_field_data(
- struct sslcert_entry *e)
+static void sslcert_viewer_free_treeview_field_data(struct sslcert_entry *e)
{
}
@@ -80,17 +90,17 @@ static void sslcert_viewer_free_treeview_field_data(
/**
* Build a sslcert viewer treeview field from given text
*
- * \param field SSL certificate treeview field to build
- * \param data SSL certificate entry field data to set
- * \param value Text to set in field, ownership yielded
- * \param ssl_d SSL certificate session data
+ * \param field SSL certificate treeview field to build
+ * \param data SSL certificate entry field data to set
+ * \param value Text to set in field, ownership yielded
+ * \param ssl_d SSL certificate session data
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static inline nserror sslcert_viewer_field_builder(
- enum sslcert_viewer_field field,
- struct treeview_field_data *data,
- const char *value,
- struct sslcert_session_data *ssl_d)
+static inline nserror
+sslcert_viewer_field_builder(enum sslcert_viewer_field field,
+ struct treeview_field_data *data,
+ const char *value,
+ struct sslcert_session_data *ssl_d)
{
data->field = ssl_d->fields[field].field;
data->value = value;
@@ -103,15 +113,15 @@ static inline nserror sslcert_viewer_field_builder(
/**
* Set a sslcert viewer entry's data from the certificate.
*
- * \param e Entry to set up
- * \param cert Data associated with entry's certificate
- * \param ssl_d SSL certificate session data
+ * \param e Entry to set up
+ * \param cert Data associated with entry's certificate
+ * \param ssl_d SSL certificate session data
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror sslcert_viewer_set_treeview_field_data(
- struct sslcert_entry *e,
- const struct ssl_cert_info *cert,
- struct sslcert_session_data *ssl_d)
+static nserror
+sslcert_viewer_set_treeview_field_data(struct sslcert_entry *e,
+ const struct ssl_cert_info *cert,
+ struct sslcert_session_data *ssl_d)
{
unsigned int written;
@@ -121,39 +131,39 @@ static nserror sslcert_viewer_set_treeview_field_data(
/* Set the fields up */
sslcert_viewer_field_builder(SSLCERT_V_SUBJECT,
- &e->data[SSLCERT_V_SUBJECT],
- cert->subject, ssl_d);
+ &e->data[SSLCERT_V_SUBJECT],
+ cert->subject, ssl_d);
written = snprintf(e->serial, sizeof(e->serial), "%li", cert->serial);
assert(written < sizeof(e->serial));
sslcert_viewer_field_builder(SSLCERT_V_SERIAL,
- &e->data[SSLCERT_V_SERIAL],
- e->serial, ssl_d);
+ &e->data[SSLCERT_V_SERIAL],
+ e->serial, ssl_d);
written = snprintf(e->type, sizeof(e->type), "%i", cert->cert_type);
assert(written < sizeof(e->type));
sslcert_viewer_field_builder(SSLCERT_V_TYPE,
- &e->data[SSLCERT_V_TYPE],
- e->type, ssl_d);
+ &e->data[SSLCERT_V_TYPE],
+ e->type, ssl_d);
sslcert_viewer_field_builder(SSLCERT_V_VALID_UNTIL,
- &e->data[SSLCERT_V_VALID_UNTIL],
- cert->not_after, ssl_d);
+ &e->data[SSLCERT_V_VALID_UNTIL],
+ cert->not_after, ssl_d);
sslcert_viewer_field_builder(SSLCERT_V_VALID_FROM,
- &e->data[SSLCERT_V_VALID_FROM],
- cert->not_before, ssl_d);
+ &e->data[SSLCERT_V_VALID_FROM],
+ cert->not_before, ssl_d);
written = snprintf(e->version, sizeof(e->version),
- "%li", cert->version);
+ "%li", cert->version);
assert(written < sizeof(e->version));
sslcert_viewer_field_builder(SSLCERT_V_VERSION,
- &e->data[SSLCERT_V_VERSION],
- e->version, ssl_d);
+ &e->data[SSLCERT_V_VERSION],
+ e->version, ssl_d);
sslcert_viewer_field_builder(SSLCERT_V_ISSUER,
- &e->data[SSLCERT_V_ISSUER],
- cert->issuer, ssl_d);
+ &e->data[SSLCERT_V_ISSUER],
+ cert->issuer, ssl_d);
return NSERROR_OK;
}
@@ -162,12 +172,12 @@ static nserror sslcert_viewer_set_treeview_field_data(
/**
* Create a treeview node for a certificate
*
- * \param ssl_d SSL certificate session data
- * \param n Number of SSL certificate in chain, to make node for
- * \return true on success, false on memory exhaustion
+ * \param ssl_d SSL certificate session data
+ * \param n Number of SSL certificate in chain, to make node for
+ * \return NSERROR_OK on success otherwise error code.
*/
-static nserror sslcert_viewer_create_node(
- struct sslcert_session_data *ssl_d, int n)
+static nserror
+sslcert_viewer_create_node(struct sslcert_session_data *ssl_d, int n)
{
struct sslcert_entry *e;
const struct ssl_cert_info *cert = &(ssl_d->certs[n]);
@@ -187,8 +197,8 @@ static nserror sslcert_viewer_create_node(
/* Create the new treeview node */
err = treeview_create_node_entry(ssl_d->tree, &(e->entry),
- NULL, TREE_REL_FIRST_CHILD,
- e->data, e, TREE_OPTION_NONE);
+ NULL, TREE_REL_FIRST_CHILD,
+ e->data, e, TREE_OPTION_NONE);
if (err != NSERROR_OK) {
sslcert_viewer_free_treeview_field_data(e);
free(e);
@@ -200,10 +210,10 @@ static nserror sslcert_viewer_create_node(
/**
- * Initialise the treeview entry feilds
+ * Initialise the treeview entry fields
*
- * \param ssl_d SSL certificate session data
- * \return true on success, false on memory exhaustion
+ * \param ssl_d SSL certificate session data
+ * \return NSERROR_OK on success otherwise error code.
*/
static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
{
@@ -217,8 +227,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelSubject";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_SUBJECT].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_SUBJECT].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -226,8 +236,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelSerial";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_SERIAL].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_SERIAL].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -235,8 +245,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelType";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_TYPE].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_TYPE].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -244,8 +254,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelValidUntil";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_VALID_UNTIL].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_VALID_UNTIL].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -253,8 +263,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelValidFrom";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_VALID_FROM].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_VALID_FROM].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -262,8 +272,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelVersion";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_VERSION].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_VERSION].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -271,8 +281,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelIssuer";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_ISSUER].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_ISSUER].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -280,8 +290,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelCertificates";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_CERTIFICATES].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_CERTIFICATES].field) !=
+ lwc_error_ok) {
return false;
}
@@ -299,7 +309,7 @@ error:
/**
* Delete ssl certificate viewer entries
*
- * \param e Entry to delete.
+ * \param e Entry to delete.
*/
static void sslcert_viewer_delete_entry(struct sslcert_entry *e)
{
@@ -308,8 +318,15 @@ static void sslcert_viewer_delete_entry(struct sslcert_entry *e)
}
-static nserror sslcert_viewer_tree_node_folder_cb(
- struct treeview_node_msg msg, void *data)
+/**
+ * folder operation callback
+ *
+ * \param msg treeview message
+ * \param data message context
+ * \return NSERROR_OK on success
+ */
+static nserror
+sslcert_viewer_tree_node_folder_cb(struct treeview_node_msg msg, void *data)
{
switch (msg.msg) {
case TREE_MSG_NODE_DELETE:
@@ -320,8 +337,17 @@ static nserror sslcert_viewer_tree_node_folder_cb(
return NSERROR_OK;
}
-static nserror sslcert_viewer_tree_node_entry_cb(
- struct treeview_node_msg msg, void *data)
+
+
+/**
+ * node entry callback
+ *
+ * \param msg treeview message
+ * \param data message context
+ * \return NSERROR_OK on success
+ */
+static nserror
+sslcert_viewer_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
{
struct sslcert_entry *e = data;
@@ -338,6 +364,11 @@ static nserror sslcert_viewer_tree_node_entry_cb(
return NSERROR_OK;
}
+
+
+/**
+ * ssl certificate treeview callbacks
+ */
struct treeview_callback_table sslv_tree_cb_t = {
.folder = sslcert_viewer_tree_node_folder_cb,
.entry = sslcert_viewer_tree_node_entry_cb
@@ -345,8 +376,10 @@ struct treeview_callback_table sslv_tree_cb_t = {
/* Exported interface, documented in sslcert_viewer.h */
-nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
- void *core_window_handle, struct sslcert_session_data *ssl_d)
+nserror
+sslcert_viewer_init(struct core_window_callback_table *cw_t,
+ void *core_window_handle,
+ struct sslcert_session_data *ssl_d)
{
nserror err;
int cert_loop;
@@ -369,8 +402,8 @@ nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
/* Create the certificate treeview */
err = treeview_create(&ssl_d->tree, &sslv_tree_cb_t,
- SSLCERT_V_N_FIELDS, ssl_d->fields,
- cw_t, core_window_handle, TREEVIEW_READ_ONLY);
+ SSLCERT_V_N_FIELDS, ssl_d->fields,
+ cw_t, core_window_handle, TREEVIEW_READ_ONLY);
if (err != NSERROR_OK) {
ssl_d->tree = NULL;
return err;
@@ -393,7 +426,7 @@ nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
/**
* Free SSL certificate session data
*
- * \param ssl_d SSL certificate session data
+ * \param ssl_d SSL certificate session data
*/
static void sslcert_cleanup_session(struct sslcert_session_data *ssl_d)
{
@@ -444,10 +477,13 @@ nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d)
/* Exported interface, documented in sslcert_viewer.h */
-nserror sslcert_viewer_create_session_data(unsigned long num, nsurl *url,
- llcache_query_response cb, void *cbpw,
- const struct ssl_cert_info *certs,
- struct sslcert_session_data **ssl_d)
+nserror
+sslcert_viewer_create_session_data(unsigned long num,
+ nsurl *url,
+ llcache_query_response cb,
+ void *cbpw,
+ const struct ssl_cert_info *certs,
+ struct sslcert_session_data **ssl_d)
{
struct sslcert_session_data *data;
@@ -506,9 +542,11 @@ nserror sslcert_viewer_accept(struct sslcert_session_data *ssl_d)
/* Exported interface, documented in sslcert_viewer.h */
-void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
- int x, int y, struct rect *clip,
- const struct redraw_context *ctx)
+void
+sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
+ int x, int y,
+ struct rect *clip,
+ const struct redraw_context *ctx)
{
assert(ssl_d != NULL &&
"sslcert_viewer_redraw() given bad session data");
@@ -518,8 +556,10 @@ void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
/* Exported interface, documented in sslcert_viewer.h */
-void sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
- browser_mouse_state mouse, int x, int y)
+void
+sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
+ browser_mouse_state mouse,
+ int x, int y)
{
treeview_mouse_action(ssl_d->tree, mouse, x, y);
}
diff --git a/desktop/sslcert_viewer.h b/desktop/sslcert_viewer.h
index 9b21cd1..9a57b96 100644
--- a/desktop/sslcert_viewer.h
+++ b/desktop/sslcert_viewer.h
@@ -17,9 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * SSL Certificate verification UI interface
+ */
-#ifndef _NETSURF_DESKTOP_SSLCERT_VIEWER_H_
-#define _NETSURF_DESKTOP_SSLCERT_VIEWER_H_
+#ifndef NETSURF_DESKTOP_SSLCERT_VIEWER_H
+#define NETSURF_DESKTOP_SSLCERT_VIEWER_H
#include "content/llcache.h"
#include "netsurf/mouse.h"
@@ -48,6 +52,7 @@ nserror sslcert_viewer_create_session_data(
void *cbpw, const struct ssl_cert_info *certs,
struct sslcert_session_data **ssl_d);
+
/**
* Initialise a ssl certificate viewer from session data.
*
@@ -61,6 +66,7 @@ nserror sslcert_viewer_create_session_data(
nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
void *core_window_handle, struct sslcert_session_data *ssl_d);
+
/**
* Finalise a ssl certificate viewer.
*
@@ -72,6 +78,7 @@ nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
*/
nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d);
+
/**
* Reject a certificate chain.
*
@@ -80,6 +87,7 @@ nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d);
*/
nserror sslcert_viewer_reject(struct sslcert_session_data *ssl_d);
+
/**
* Accept a certificate chain.
*
@@ -88,6 +96,7 @@ nserror sslcert_viewer_reject(struct sslcert_session_data *ssl_d);
*/
nserror sslcert_viewer_accept(struct sslcert_session_data *ssl_d);
+
/**
* Redraw the ssl certificate viewer.
*
@@ -101,6 +110,7 @@ void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
int x, int y, struct rect *clip,
const struct redraw_context *ctx);
+
/**
* Handles all kinds of mouse action
*
@@ -112,6 +122,7 @@ void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
void sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
browser_mouse_state mouse, int x, int y);
+
/**
* Key press handling.
*
-----------------------------------------------------------------------
Summary of changes:
desktop/sslcert_viewer.c | 206 +++++++++++++++++++++++++++-------------------
desktop/sslcert_viewer.h | 15 +++-
2 files changed, 136 insertions(+), 85 deletions(-)
diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c
index 09a281c..e7f87bd 100644
--- a/desktop/sslcert_viewer.c
+++ b/desktop/sslcert_viewer.c
@@ -17,8 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * SSL Certificate verification UI (implementation)
+/**
+ * \file
+ * SSL Certificate verification UI implementation
*/
#include <assert.h>
@@ -33,6 +34,9 @@
#include "utils/log.h"
#include "utils/utils.h"
+/**
+ * ssl certificate viewer data fields
+ */
enum sslcert_viewer_field {
SSLCERT_V_SUBJECT,
SSLCERT_V_SERIAL,
@@ -45,7 +49,10 @@ enum sslcert_viewer_field {
SSLCERT_V_N_FIELDS
};
-/** ssl certificate verification context. */
+
+/**
+ * ssl certificate verification context.
+ */
struct sslcert_session_data {
struct ssl_cert_info *certs; /**< Certificates */
unsigned long num; /**< Number of certificates in chain */
@@ -57,6 +64,10 @@ struct sslcert_session_data {
struct treeview_field_desc fields[SSLCERT_V_N_FIELDS];
};
+
+/**
+ * ssl certificate tree entry
+ */
struct sslcert_entry {
treeview_node *entry;
char version[24];
@@ -67,12 +78,11 @@ struct sslcert_entry {
/**
- * Free a sll certificate viewer entry's treeview field data.
+ * Free a ssl certificate viewer entry's treeview field data.
*
- * \param e Entry to free data from
+ * \param e Entry to free data from
*/
-static void sslcert_viewer_free_treeview_field_data(
- struct sslcert_entry *e)
+static void sslcert_viewer_free_treeview_field_data(struct sslcert_entry *e)
{
}
@@ -80,17 +90,17 @@ static void sslcert_viewer_free_treeview_field_data(
/**
* Build a sslcert viewer treeview field from given text
*
- * \param field SSL certificate treeview field to build
- * \param data SSL certificate entry field data to set
- * \param value Text to set in field, ownership yielded
- * \param ssl_d SSL certificate session data
+ * \param field SSL certificate treeview field to build
+ * \param data SSL certificate entry field data to set
+ * \param value Text to set in field, ownership yielded
+ * \param ssl_d SSL certificate session data
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static inline nserror sslcert_viewer_field_builder(
- enum sslcert_viewer_field field,
- struct treeview_field_data *data,
- const char *value,
- struct sslcert_session_data *ssl_d)
+static inline nserror
+sslcert_viewer_field_builder(enum sslcert_viewer_field field,
+ struct treeview_field_data *data,
+ const char *value,
+ struct sslcert_session_data *ssl_d)
{
data->field = ssl_d->fields[field].field;
data->value = value;
@@ -103,15 +113,15 @@ static inline nserror sslcert_viewer_field_builder(
/**
* Set a sslcert viewer entry's data from the certificate.
*
- * \param e Entry to set up
- * \param cert Data associated with entry's certificate
- * \param ssl_d SSL certificate session data
+ * \param e Entry to set up
+ * \param cert Data associated with entry's certificate
+ * \param ssl_d SSL certificate session data
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror sslcert_viewer_set_treeview_field_data(
- struct sslcert_entry *e,
- const struct ssl_cert_info *cert,
- struct sslcert_session_data *ssl_d)
+static nserror
+sslcert_viewer_set_treeview_field_data(struct sslcert_entry *e,
+ const struct ssl_cert_info *cert,
+ struct sslcert_session_data *ssl_d)
{
unsigned int written;
@@ -121,39 +131,39 @@ static nserror sslcert_viewer_set_treeview_field_data(
/* Set the fields up */
sslcert_viewer_field_builder(SSLCERT_V_SUBJECT,
- &e->data[SSLCERT_V_SUBJECT],
- cert->subject, ssl_d);
+ &e->data[SSLCERT_V_SUBJECT],
+ cert->subject, ssl_d);
written = snprintf(e->serial, sizeof(e->serial), "%li", cert->serial);
assert(written < sizeof(e->serial));
sslcert_viewer_field_builder(SSLCERT_V_SERIAL,
- &e->data[SSLCERT_V_SERIAL],
- e->serial, ssl_d);
+ &e->data[SSLCERT_V_SERIAL],
+ e->serial, ssl_d);
written = snprintf(e->type, sizeof(e->type), "%i", cert->cert_type);
assert(written < sizeof(e->type));
sslcert_viewer_field_builder(SSLCERT_V_TYPE,
- &e->data[SSLCERT_V_TYPE],
- e->type, ssl_d);
+ &e->data[SSLCERT_V_TYPE],
+ e->type, ssl_d);
sslcert_viewer_field_builder(SSLCERT_V_VALID_UNTIL,
- &e->data[SSLCERT_V_VALID_UNTIL],
- cert->not_after, ssl_d);
+ &e->data[SSLCERT_V_VALID_UNTIL],
+ cert->not_after, ssl_d);
sslcert_viewer_field_builder(SSLCERT_V_VALID_FROM,
- &e->data[SSLCERT_V_VALID_FROM],
- cert->not_before, ssl_d);
+ &e->data[SSLCERT_V_VALID_FROM],
+ cert->not_before, ssl_d);
written = snprintf(e->version, sizeof(e->version),
- "%li", cert->version);
+ "%li", cert->version);
assert(written < sizeof(e->version));
sslcert_viewer_field_builder(SSLCERT_V_VERSION,
- &e->data[SSLCERT_V_VERSION],
- e->version, ssl_d);
+ &e->data[SSLCERT_V_VERSION],
+ e->version, ssl_d);
sslcert_viewer_field_builder(SSLCERT_V_ISSUER,
- &e->data[SSLCERT_V_ISSUER],
- cert->issuer, ssl_d);
+ &e->data[SSLCERT_V_ISSUER],
+ cert->issuer, ssl_d);
return NSERROR_OK;
}
@@ -162,12 +172,12 @@ static nserror sslcert_viewer_set_treeview_field_data(
/**
* Create a treeview node for a certificate
*
- * \param ssl_d SSL certificate session data
- * \param n Number of SSL certificate in chain, to make node for
- * \return true on success, false on memory exhaustion
+ * \param ssl_d SSL certificate session data
+ * \param n Number of SSL certificate in chain, to make node for
+ * \return NSERROR_OK on success otherwise error code.
*/
-static nserror sslcert_viewer_create_node(
- struct sslcert_session_data *ssl_d, int n)
+static nserror
+sslcert_viewer_create_node(struct sslcert_session_data *ssl_d, int n)
{
struct sslcert_entry *e;
const struct ssl_cert_info *cert = &(ssl_d->certs[n]);
@@ -187,8 +197,8 @@ static nserror sslcert_viewer_create_node(
/* Create the new treeview node */
err = treeview_create_node_entry(ssl_d->tree, &(e->entry),
- NULL, TREE_REL_FIRST_CHILD,
- e->data, e, TREE_OPTION_NONE);
+ NULL, TREE_REL_FIRST_CHILD,
+ e->data, e, TREE_OPTION_NONE);
if (err != NSERROR_OK) {
sslcert_viewer_free_treeview_field_data(e);
free(e);
@@ -200,10 +210,10 @@ static nserror sslcert_viewer_create_node(
/**
- * Initialise the treeview entry feilds
+ * Initialise the treeview entry fields
*
- * \param ssl_d SSL certificate session data
- * \return true on success, false on memory exhaustion
+ * \param ssl_d SSL certificate session data
+ * \return NSERROR_OK on success otherwise error code.
*/
static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
{
@@ -217,8 +227,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelSubject";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_SUBJECT].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_SUBJECT].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -226,8 +236,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelSerial";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_SERIAL].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_SERIAL].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -235,8 +245,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelType";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_TYPE].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_TYPE].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -244,8 +254,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelValidUntil";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_VALID_UNTIL].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_VALID_UNTIL].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -253,8 +263,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelValidFrom";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_VALID_FROM].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_VALID_FROM].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -262,8 +272,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelVersion";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_VERSION].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_VERSION].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -271,8 +281,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelIssuer";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_ISSUER].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_ISSUER].field) !=
+ lwc_error_ok) {
goto error;
}
@@ -280,8 +290,8 @@ static nserror sslcert_init_entry_fields(struct sslcert_session_data *ssl_d)
label = "TreeviewLabelCertificates";
label = messages_get(label);
if (lwc_intern_string(label, strlen(label),
- &ssl_d->fields[SSLCERT_V_CERTIFICATES].field) !=
- lwc_error_ok) {
+ &ssl_d->fields[SSLCERT_V_CERTIFICATES].field) !=
+ lwc_error_ok) {
return false;
}
@@ -299,7 +309,7 @@ error:
/**
* Delete ssl certificate viewer entries
*
- * \param e Entry to delete.
+ * \param e Entry to delete.
*/
static void sslcert_viewer_delete_entry(struct sslcert_entry *e)
{
@@ -308,8 +318,15 @@ static void sslcert_viewer_delete_entry(struct sslcert_entry *e)
}
-static nserror sslcert_viewer_tree_node_folder_cb(
- struct treeview_node_msg msg, void *data)
+/**
+ * folder operation callback
+ *
+ * \param msg treeview message
+ * \param data message context
+ * \return NSERROR_OK on success
+ */
+static nserror
+sslcert_viewer_tree_node_folder_cb(struct treeview_node_msg msg, void *data)
{
switch (msg.msg) {
case TREE_MSG_NODE_DELETE:
@@ -320,8 +337,17 @@ static nserror sslcert_viewer_tree_node_folder_cb(
return NSERROR_OK;
}
-static nserror sslcert_viewer_tree_node_entry_cb(
- struct treeview_node_msg msg, void *data)
+
+
+/**
+ * node entry callback
+ *
+ * \param msg treeview message
+ * \param data message context
+ * \return NSERROR_OK on success
+ */
+static nserror
+sslcert_viewer_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
{
struct sslcert_entry *e = data;
@@ -338,6 +364,11 @@ static nserror sslcert_viewer_tree_node_entry_cb(
return NSERROR_OK;
}
+
+
+/**
+ * ssl certificate treeview callbacks
+ */
struct treeview_callback_table sslv_tree_cb_t = {
.folder = sslcert_viewer_tree_node_folder_cb,
.entry = sslcert_viewer_tree_node_entry_cb
@@ -345,8 +376,10 @@ struct treeview_callback_table sslv_tree_cb_t = {
/* Exported interface, documented in sslcert_viewer.h */
-nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
- void *core_window_handle, struct sslcert_session_data *ssl_d)
+nserror
+sslcert_viewer_init(struct core_window_callback_table *cw_t,
+ void *core_window_handle,
+ struct sslcert_session_data *ssl_d)
{
nserror err;
int cert_loop;
@@ -369,8 +402,8 @@ nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
/* Create the certificate treeview */
err = treeview_create(&ssl_d->tree, &sslv_tree_cb_t,
- SSLCERT_V_N_FIELDS, ssl_d->fields,
- cw_t, core_window_handle, TREEVIEW_READ_ONLY);
+ SSLCERT_V_N_FIELDS, ssl_d->fields,
+ cw_t, core_window_handle, TREEVIEW_READ_ONLY);
if (err != NSERROR_OK) {
ssl_d->tree = NULL;
return err;
@@ -393,7 +426,7 @@ nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
/**
* Free SSL certificate session data
*
- * \param ssl_d SSL certificate session data
+ * \param ssl_d SSL certificate session data
*/
static void sslcert_cleanup_session(struct sslcert_session_data *ssl_d)
{
@@ -444,10 +477,13 @@ nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d)
/* Exported interface, documented in sslcert_viewer.h */
-nserror sslcert_viewer_create_session_data(unsigned long num, nsurl *url,
- llcache_query_response cb, void *cbpw,
- const struct ssl_cert_info *certs,
- struct sslcert_session_data **ssl_d)
+nserror
+sslcert_viewer_create_session_data(unsigned long num,
+ nsurl *url,
+ llcache_query_response cb,
+ void *cbpw,
+ const struct ssl_cert_info *certs,
+ struct sslcert_session_data **ssl_d)
{
struct sslcert_session_data *data;
@@ -506,9 +542,11 @@ nserror sslcert_viewer_accept(struct sslcert_session_data *ssl_d)
/* Exported interface, documented in sslcert_viewer.h */
-void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
- int x, int y, struct rect *clip,
- const struct redraw_context *ctx)
+void
+sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
+ int x, int y,
+ struct rect *clip,
+ const struct redraw_context *ctx)
{
assert(ssl_d != NULL &&
"sslcert_viewer_redraw() given bad session data");
@@ -518,8 +556,10 @@ void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
/* Exported interface, documented in sslcert_viewer.h */
-void sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
- browser_mouse_state mouse, int x, int y)
+void
+sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
+ browser_mouse_state mouse,
+ int x, int y)
{
treeview_mouse_action(ssl_d->tree, mouse, x, y);
}
diff --git a/desktop/sslcert_viewer.h b/desktop/sslcert_viewer.h
index 9b21cd1..9a57b96 100644
--- a/desktop/sslcert_viewer.h
+++ b/desktop/sslcert_viewer.h
@@ -17,9 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * SSL Certificate verification UI interface
+ */
-#ifndef _NETSURF_DESKTOP_SSLCERT_VIEWER_H_
-#define _NETSURF_DESKTOP_SSLCERT_VIEWER_H_
+#ifndef NETSURF_DESKTOP_SSLCERT_VIEWER_H
+#define NETSURF_DESKTOP_SSLCERT_VIEWER_H
#include "content/llcache.h"
#include "netsurf/mouse.h"
@@ -48,6 +52,7 @@ nserror sslcert_viewer_create_session_data(
void *cbpw, const struct ssl_cert_info *certs,
struct sslcert_session_data **ssl_d);
+
/**
* Initialise a ssl certificate viewer from session data.
*
@@ -61,6 +66,7 @@ nserror sslcert_viewer_create_session_data(
nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
void *core_window_handle, struct sslcert_session_data *ssl_d);
+
/**
* Finalise a ssl certificate viewer.
*
@@ -72,6 +78,7 @@ nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
*/
nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d);
+
/**
* Reject a certificate chain.
*
@@ -80,6 +87,7 @@ nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d);
*/
nserror sslcert_viewer_reject(struct sslcert_session_data *ssl_d);
+
/**
* Accept a certificate chain.
*
@@ -88,6 +96,7 @@ nserror sslcert_viewer_reject(struct sslcert_session_data *ssl_d);
*/
nserror sslcert_viewer_accept(struct sslcert_session_data *ssl_d);
+
/**
* Redraw the ssl certificate viewer.
*
@@ -101,6 +110,7 @@ void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
int x, int y, struct rect *clip,
const struct redraw_context *ctx);
+
/**
* Handles all kinds of mouse action
*
@@ -112,6 +122,7 @@ void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
void sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
browser_mouse_state mouse, int x, int y);
+
/**
* Key press handling.
*
--
NetSurf Browser
5 years, 11 months
netsurf: branch master updated. release/3.6-281-g44c5aef
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/44c5aef1c8a79a3a9afbd...
...commit http://git.netsurf-browser.org/netsurf.git/commit/44c5aef1c8a79a3a9afbd47...
...tree http://git.netsurf-browser.org/netsurf.git/tree/44c5aef1c8a79a3a9afbd472d...
The branch, master has been updated
via 44c5aef1c8a79a3a9afbd472d1f6e6e238c8ed5c (commit)
from 2f5e5620e218d317d5e853fd4ee9d9123b346610 (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/commit/?id=44c5aef1c8a79a3a9af...
commit 44c5aef1c8a79a3a9afbd472d1f6e6e238c8ed5c
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make scrollbar redraw signal errors correctly
allow scrollbar redraw to return error codes and update documentation
commenst appropriately.
diff --git a/desktop/browser.c b/desktop/browser.c
index 3a7ac0e..d0114ef 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -154,8 +154,11 @@ browser_window_set_name(struct browser_window *bw, const char *name)
}
/* exported interface, documented in browser.h */
-bool browser_window_redraw(struct browser_window *bw, int x, int y,
- const struct rect *clip, const struct redraw_context *ctx)
+bool
+browser_window_redraw(struct browser_window *bw,
+ int x, int y,
+ const struct rect *clip,
+ const struct redraw_context *ctx)
{
struct redraw_context new_ctx = *ctx;
int width = 0;
@@ -164,6 +167,7 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
content_type content_type;
struct content_redraw_data data;
struct rect content_clip;
+ nserror res;
if (bw == NULL) {
LOG("NULL browser window");
@@ -299,16 +303,22 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
if (bw->scroll_x != NULL) {
browser_window_get_scrollbar_pos(bw, true,
&off_x, &off_y);
- plot_ok &= scrollbar_redraw(bw->scroll_x,
+ res = scrollbar_redraw(bw->scroll_x,
x + off_x, y + off_y, clip,
bw->scale, &new_ctx);
+ if (res != NSERROR_OK) {
+ plot_ok = false;
+ }
}
if (bw->scroll_y != NULL) {
browser_window_get_scrollbar_pos(bw, false,
&off_x, &off_y);
- plot_ok &= scrollbar_redraw(bw->scroll_y,
+ res = scrollbar_redraw(bw->scroll_y,
x + off_x, y + off_y, clip,
bw->scale, &new_ctx);
+ if (res != NSERROR_OK) {
+ plot_ok = false;
+ }
}
}
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 0432696..5a7420a 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -46,39 +46,56 @@ struct scrollbar {
/** Length of the scrollbar widget */
int length;
- int full_size; /* Length of the full scrollable area */
- int visible_size; /* Length visible part of the scrollable area */
-
- int offset; /* Current scroll offset to visible area */
-
- int bar_pos; /* Position of the scrollbar */
- int bar_len; /* Length of the scrollbar */
-
- scrollbar_client_callback client_callback; /* Callback receiving
- * scrollbar events */
- void *client_data; /* User data passed to the callback */
-
- bool dragging; /* Flag indicating drag at progess */
- int drag_start_coord; /* Coordinate value at drag start */
- int drag_start_pos; /* Scrollbar offset or bar_pos at drag start */
- bool drag_content; /* Flag indicating that the drag corresponds to
- * a dragged content area, rather than a dragged
- * scrollbar. */
+ /** Length of the full scrollable area */
+ int full_size;
+ /** Length visible part of the scrollable area */
+ int visible_size;
+
+ /** Current scroll offset to visible area */
+ int offset;
+
+ /** Position of the scrollbar */
+ int bar_pos;
+ /** Length of the scrollbar */
+ int bar_len;
+
+ /** Callback receiving scrollbar events */
+ scrollbar_client_callback client_callback;
+ /** User data passed to the callback */
+ void *client_data;
+
+ /** Flag indicating drag at progess */
+ bool dragging;
+ /** Coordinate value at drag start */
+ int drag_start_coord;
+ /** Scrollbar offset or bar_pos at drag start */
+ int drag_start_pos;
+ /** Flag indicating that the drag corresponds to a dragged
+ * content area, rather than a dragged scrollbar.
+ */
+ bool drag_content;
- struct scrollbar *pair; /* Parpendicular scrollbar, or NULL */
- bool pair_drag; /* Flag indicating that the current drag affects
- the perpendicular scrollbar too */
+ /** Parpendicular scrollbar, or NULL */
+ struct scrollbar *pair;
+ /** Flag indicating that the current drag affects the
+ * perpendicular scrollbar too
+ */
+ bool pair_drag;
};
/*
- * Exported function. Documented in desktop/scrollbar.h
+ * Exported interface. Documented in desktop/scrollbar.h
*/
-nserror scrollbar_create(bool horizontal, int length, int full_size,
- int visible_size, void *client_data,
- scrollbar_client_callback client_callback,
- struct scrollbar **s)
+nserror
+scrollbar_create(bool horizontal,
+ int length,
+ int full_size,
+ int visible_size,
+ void *client_data,
+ scrollbar_client_callback client_callback,
+ struct scrollbar **s)
{
struct scrollbar *scrollbar;
int well_length;
@@ -100,7 +117,7 @@ nserror scrollbar_create(bool horizontal, int length, int full_size,
well_length = length - 2 * SCROLLBAR_WIDTH;
scrollbar->bar_len = (full_size == 0) ? 0 :
- ((well_length * visible_size) / full_size);
+ ((well_length * visible_size) / full_size);
scrollbar->client_callback = client_callback;
scrollbar->client_data = client_data;
@@ -115,12 +132,13 @@ nserror scrollbar_create(bool horizontal, int length, int full_size,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_destroy(struct scrollbar *s)
{
- if (s->pair != NULL)
+ if (s->pair != NULL) {
s->pair->pair = NULL;
+ }
free(s);
}
@@ -135,7 +153,6 @@ void scrollbar_destroy(struct scrollbar *s)
* \param inset true for inset outline, false for an outset one
* \return NSERROR_OK on success else error code
*/
-
static inline nserror
scrollbar_rectangle(const struct redraw_context *ctx,
struct rect *area,
@@ -215,11 +232,14 @@ scrollbar_rectangle(const struct redraw_context *ctx,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
-bool scrollbar_redraw(struct scrollbar *s, int x, int y,
- const struct rect *clip, float scale,
- const struct redraw_context *ctx)
+nserror
+scrollbar_redraw(struct scrollbar *s,
+ int x, int y,
+ const struct rect *clip,
+ float scale,
+ const struct redraw_context *ctx)
{
int w = SCROLLBAR_WIDTH;
int bar_pos, bar_c0, bar_c1;
@@ -259,7 +279,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
area.y1 = y + (s->horizontal ? SCROLLBAR_WIDTH : s->length) - 1;
bar_pos = s->bar_pos;
bar_c1 = (s->horizontal ? area.x0 : area.y0) + SCROLLBAR_WIDTH +
- s->bar_pos + s->bar_len - 1;
+ s->bar_pos + s->bar_len - 1;
if (scale != 1.0) {
w *= scale;
@@ -278,7 +298,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
(area.y1 < clip->y0) ||
(clip->x1 < area.x0) ||
(clip->y1 < area.y0)) {
- return true;
+ return NSERROR_OK;
}
if (s->horizontal) {
@@ -288,7 +308,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
res = scrollbar_rectangle(ctx, &area,
bg_fill_style.fill_colour, true);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* left arrow icon border */
@@ -299,7 +319,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
res = scrollbar_rectangle(ctx, &rect,
fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* left arrow icon background */
@@ -309,7 +329,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - 1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* left arrow */
@@ -321,7 +341,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[5] = area.y0 + w * 3 / 4;
res = ctx->plot->polygon(ctx, &arrow_fill_style, v, 3);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* scrollbar well background */
@@ -331,7 +351,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1;
res = ctx->plot->rectangle(ctx, &bg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* scrollbar position indicator bar */
@@ -339,9 +359,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = bar_c1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
rect.x0 = bar_c0 + 1;
@@ -350,7 +371,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - 1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* right arrow icon border */
@@ -358,9 +379,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x1 - 1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* right arrow icon background */
@@ -370,7 +392,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - 1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* right arrow */
@@ -382,15 +404,16 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[5] = rect.y0 + w * 3 / 4;
res = ctx->plot->polygon(ctx, &arrow_fill_style, v, 3);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
} else {
/* scrollbar is vertical */
/* outline */
- res = scrollbar_rectangle(ctx, &area, bg_fill_style.fill_colour, true);
+ res = scrollbar_rectangle(ctx, &area,
+ bg_fill_style.fill_colour, true);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* top arrow border */
@@ -398,9 +421,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x1 - 1;
rect.y1 = area.y0 + w - 2;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* top arrow background */
@@ -410,7 +434,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y0 + w - 2;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* up arrow */
@@ -422,7 +446,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[5] = area.y0 + w * 3 / 4;
res = ctx->plot->polygon(ctx, &arrow_fill_style, v, 3);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* scrollbar well background */
@@ -432,7 +456,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - w + 2;
res = ctx->plot->rectangle(ctx, &bg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* scrollbar position indicator bar */
@@ -440,9 +464,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = bar_c0;
rect.x1 = area.x1 - 1;
rect.y1 = bar_c1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
rect.x0 = area.x0 + 2;
@@ -451,7 +476,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = bar_c1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* down arrow icon border */
@@ -459,9 +484,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y1 - w + 2;
rect.x1 = area.x1 - 1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* down arrow icon background */
@@ -471,7 +497,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - 1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* down arrow */
@@ -483,16 +509,16 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[5] = area.y1 - w * 3 / 4 + 1;
res = ctx->plot->polygon(ctx, &arrow_fill_style, v, 3);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
}
- return true;
+ return NSERROR_OK;
}
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_set(struct scrollbar *s, int value, bool bar_pos)
{
@@ -500,46 +526,49 @@ void scrollbar_set(struct scrollbar *s, int value, bool bar_pos)
int old_offset = s->offset;
struct scrollbar_msg_data msg;
- if (value < 0)
+ if (value < 0) {
value = 0;
+ }
- if (s->full_size == s->visible_size)
+ if (s->full_size == s->visible_size) {
return;
+ }
well_length = s->length - 2 * SCROLLBAR_WIDTH;
if (bar_pos) {
- if (value > well_length - s->bar_len)
+ if (value > well_length - s->bar_len) {
s->bar_pos = well_length - s->bar_len;
- else
+ } else {
s->bar_pos = value;
+ }
s->offset = ((well_length - s->bar_len) < 1) ? 0 :
- (((s->full_size - s->visible_size) *
- s->bar_pos) / (well_length - s->bar_len));
+ (((s->full_size - s->visible_size) *
+ s->bar_pos) / (well_length - s->bar_len));
} else {
- if (value > s->full_size - s->visible_size)
+ if (value > s->full_size - s->visible_size) {
s->offset = s->full_size - s->visible_size;
- else
+ } else {
s->offset = value;
+ }
s->bar_pos = (s->full_size < 1) ? 0 :
- ((well_length * s->offset) / s->full_size);
+ ((well_length * s->offset) / s->full_size);
}
- if (s->offset == old_offset)
- /* Nothing happened */
- return;
-
- msg.scrollbar = s;
- msg.msg = SCROLLBAR_MSG_MOVED;
- msg.scroll_offset = s->offset;
- s->client_callback(s->client_data, &msg);
+ if (s->offset != old_offset) {
+ /* client callback if there was a chnage */
+ msg.scrollbar = s;
+ msg.msg = SCROLLBAR_MSG_MOVED;
+ msg.scroll_offset = s->offset;
+ s->client_callback(s->client_data, &msg);
+ }
}
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
bool scrollbar_scroll(struct scrollbar *s, int change)
{
@@ -547,9 +576,10 @@ bool scrollbar_scroll(struct scrollbar *s, int change)
int old_offset = s->offset;
struct scrollbar_msg_data msg;
- if (change == 0 || s->full_size <= s->visible_size)
+ if (change == 0 || s->full_size <= s->visible_size) {
/* zero scroll step, or unscrollable */
return false;
+ }
/* Convert named change values to appropriate pixel offset value */
switch (change) {
@@ -575,21 +605,23 @@ bool scrollbar_scroll(struct scrollbar *s, int change)
}
/* Get new offset */
- if (s->offset + change > s->full_size - s->visible_size)
+ if (s->offset + change > s->full_size - s->visible_size) {
s->offset = s->full_size - s->visible_size;
- else if (s->offset + change < 0)
+ } else if (s->offset + change < 0) {
s->offset = 0;
- else
+ } else {
s->offset += change;
+ }
- if (s->offset == old_offset)
+ if (s->offset == old_offset) {
/* Nothing happened */
return false;
+ }
/* Update scrollbar */
well_length = s->length - 2 * SCROLLBAR_WIDTH;
s->bar_pos = (s->full_size < 1) ? 0 :
- ((well_length * s->offset) / s->full_size);
+ ((well_length * s->offset) / s->full_size);
msg.scrollbar = s;
msg.msg = SCROLLBAR_MSG_MOVED;
@@ -601,41 +633,47 @@ bool scrollbar_scroll(struct scrollbar *s, int change)
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
int scrollbar_get_offset(struct scrollbar *s)
{
- if (s == NULL)
+ if (s == NULL) {
return 0;
+ }
return s->offset;
}
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_set_extents(struct scrollbar *s, int length,
- int visible_size, int full_size)
+ int visible_size, int full_size)
{
int cur_excess = s->full_size - s->visible_size;
int well_length;
struct scrollbar_msg_data msg;
- if (length == s->length && visible_size == s->visible_size &&
- full_size == s->full_size) {
+ if (length == s->length &&
+ visible_size == s->visible_size &&
+ full_size == s->full_size) {
/* Nothing's changed. */
return;
}
- if (length != -1)
+ if (length != -1) {
s->length = length;
- if (visible_size != -1)
+ }
+ if (visible_size != -1) {
s->visible_size = visible_size;
- if (full_size != -1)
+ }
+ if (full_size != -1) {
s->full_size = full_size;
+ }
- if (s->full_size < s->visible_size)
+ if (s->full_size < s->visible_size) {
s->full_size = s->visible_size;
+ }
/* Update scroll offset (scaled in proportion with change in excess) */
if (cur_excess <= 0) {
@@ -662,7 +700,7 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
bool scrollbar_is_horizontal(struct scrollbar *s)
{
@@ -680,9 +718,11 @@ bool scrollbar_is_horizontal(struct scrollbar *s)
* user drags the content area, rather than the scrollbar)
* \param pair whether the drag is a '2D' scroll
*/
-
-static void scrollbar_drag_start_internal(struct scrollbar *s, int x, int y,
- bool content_drag, bool pair)
+static void
+scrollbar_drag_start_internal(struct scrollbar *s,
+ int x, int y,
+ bool content_drag,
+ bool pair)
{
struct scrollbar_msg_data msg;
@@ -694,7 +734,7 @@ static void scrollbar_drag_start_internal(struct scrollbar *s, int x, int y,
msg.scrollbar = s;
- /* \todo - some proper numbers please! */
+ /** \todo some proper numbers please! */
if (s->horizontal) {
msg.x0 = -2048;
msg.x1 = 2048;
@@ -711,10 +751,10 @@ static void scrollbar_drag_start_internal(struct scrollbar *s, int x, int y,
s->pair_drag = true;
s->pair->drag_start_coord =
- s->pair->horizontal ? x : y;
+ s->pair->horizontal ? x : y;
s->pair->drag_start_pos = (content_drag) ? s->pair->offset :
- s->pair->bar_pos;
+ s->pair->bar_pos;
s->pair->dragging = true;
s->pair->drag_content = content_drag;
@@ -733,10 +773,12 @@ static void scrollbar_drag_start_internal(struct scrollbar *s, int x, int y,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
-scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
- browser_mouse_state mouse, int x, int y)
+scrollbar_mouse_status
+scrollbar_mouse_action(struct scrollbar *s,
+ browser_mouse_state mouse,
+ int x, int y)
{
int x0, y0, x1, y1;
int val;
@@ -747,13 +789,13 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
* scrollbar indication bar to be launching actions on the scroll area
*/
bool but1 = ((mouse & BROWSER_MOUSE_PRESS_1) ||
- ((mouse & BROWSER_MOUSE_HOLDING_1) &&
- (mouse & BROWSER_MOUSE_DRAG_ON) &&
- !s->dragging));
+ ((mouse & BROWSER_MOUSE_HOLDING_1) &&
+ (mouse & BROWSER_MOUSE_DRAG_ON) &&
+ !s->dragging));
bool but2 = ((mouse & BROWSER_MOUSE_PRESS_2) ||
- ((mouse & BROWSER_MOUSE_HOLDING_2) &&
- (mouse & BROWSER_MOUSE_DRAG_ON) &&
- !s->dragging));
+ ((mouse & BROWSER_MOUSE_HOLDING_2) &&
+ (mouse & BROWSER_MOUSE_DRAG_ON) &&
+ !s->dragging));
h = s->horizontal;
@@ -768,24 +810,27 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
}
- if (h)
+ if (h) {
val = x;
- else
+ } else {
val = y;
+ }
if (s->dragging) {
val -= s->drag_start_coord;
- if (s->drag_content)
+ if (s->drag_content) {
val = -val;
- if (val != 0)
+ }
+ if (val != 0) {
scrollbar_set(s, s->drag_start_pos + val,
- !(s->drag_content));
+ !(s->drag_content));
+ }
if (s->pair_drag) {
scrollbar_mouse_action(s->pair, mouse, x, y);
status = SCROLLBAR_MOUSE_BOTH;
- } else
+ } else {
status = h ? SCROLLBAR_MOUSE_HRZ : SCROLLBAR_MOUSE_VRT;
-
+ }
return status;
}
@@ -793,42 +838,41 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
/* left/up arrow */
status = h ? SCROLLBAR_MOUSE_LFT : SCROLLBAR_MOUSE_UP;
- if (but1)
+ if (but1) {
scrollbar_set(s, s->offset - SCROLLBAR_WIDTH, false);
- else if (but2)
+ } else if (but2) {
scrollbar_set(s, s->offset + SCROLLBAR_WIDTH, false);
-
+ }
} else if (val < SCROLLBAR_WIDTH + s->bar_pos) {
/* well between left/up arrow and bar */
status = h ? SCROLLBAR_MOUSE_PLFT : SCROLLBAR_MOUSE_PUP;
- if (but1)
+ if (but1) {
scrollbar_set(s, s->offset - s->length, false);
- else if (but2)
+ } else if (but2) {
scrollbar_set(s, s->offset + s->length, false);
-
+ }
} else if (val > s->length - SCROLLBAR_WIDTH) {
/* right/down arrow */
status = h ? SCROLLBAR_MOUSE_RGT : SCROLLBAR_MOUSE_DWN;
- if (but1)
+ if (but1) {
scrollbar_set(s, s->offset + SCROLLBAR_WIDTH, false);
- else if (but2)
+ } else if (but2) {
scrollbar_set(s, s->offset - SCROLLBAR_WIDTH, false);
-
- } else if (val > SCROLLBAR_WIDTH + s->bar_pos +
- s->bar_len) {
+ }
+ } else if (val > SCROLLBAR_WIDTH + s->bar_pos + s->bar_len) {
/* well between right/down arrow and bar */
status = h ? SCROLLBAR_MOUSE_PRGT : SCROLLBAR_MOUSE_PDWN;
- if (but1)
+ if (but1) {
scrollbar_set(s, s->offset + s->length, false);
- else if (but2)
+ } else if (but2) {
scrollbar_set(s, s->offset - s->length, false);
- }
- else {
+ }
+ } else {
/* scrollbar position indication bar */
status = h ? SCROLLBAR_MOUSE_HRZ : SCROLLBAR_MOUSE_VRT;
@@ -836,20 +880,21 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2) &&
- (val >= SCROLLBAR_WIDTH + s->bar_pos
- && val < SCROLLBAR_WIDTH + s->bar_pos +
- s->bar_len))
+ (val >= SCROLLBAR_WIDTH + s->bar_pos
+ && val < SCROLLBAR_WIDTH + s->bar_pos +
+ s->bar_len)) {
/* The mouse event is a drag start on the scrollbar position
* indication bar. */
scrollbar_drag_start_internal(s, x, y, false,
- (mouse & BROWSER_MOUSE_DRAG_2) ? true : false);
+ (mouse & BROWSER_MOUSE_DRAG_2) ? true : false);
+ }
return status;
}
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
const char *scrollbar_mouse_status_to_message(scrollbar_mouse_status status)
{
@@ -893,10 +938,10 @@ const char *scrollbar_mouse_status_to_message(scrollbar_mouse_status status)
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_mouse_drag_end(struct scrollbar *s,
- browser_mouse_state mouse, int x, int y)
+ browser_mouse_state mouse, int x, int y)
{
struct scrollbar_msg_data msg;
int val, drag_start_pos;
@@ -906,10 +951,12 @@ void scrollbar_mouse_drag_end(struct scrollbar *s,
drag_start_pos = s->drag_start_pos;
val = (s->horizontal ? x : y) - s->drag_start_coord;
- if (s->drag_content)
+ if (s->drag_content) {
val = -val;
- if (val != 0)
+ }
+ if (val != 0) {
scrollbar_set(s, drag_start_pos + val, !(s->drag_content));
+ }
s->dragging = false;
s->drag_content = false;
@@ -920,11 +967,13 @@ void scrollbar_mouse_drag_end(struct scrollbar *s,
drag_start_pos = s->pair->drag_start_pos;
val = (s->pair->horizontal ? x : y) - s->pair->drag_start_coord;
- if (s->pair->drag_content)
+ if (s->pair->drag_content) {
val = -val;
- if (val != 0)
+ }
+ if (val != 0) {
scrollbar_set(s->pair, drag_start_pos + val,
- !(s->pair->drag_content));
+ !(s->pair->drag_content));
+ }
s->pair->dragging = false;
s->pair->drag_content = false;
@@ -937,7 +986,7 @@ void scrollbar_mouse_drag_end(struct scrollbar *s,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_start_content_drag(struct scrollbar *s, int x, int y)
{
@@ -946,13 +995,13 @@ void scrollbar_start_content_drag(struct scrollbar *s, int x, int y)
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_make_pair(struct scrollbar *horizontal,
- struct scrollbar *vertical)
+ struct scrollbar *vertical)
{
assert(horizontal->horizontal &&
- !vertical->horizontal);
+ !vertical->horizontal);
horizontal->pair = vertical;
vertical->pair = horizontal;
@@ -960,7 +1009,7 @@ void scrollbar_make_pair(struct scrollbar *horizontal,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void *scrollbar_get_data(struct scrollbar *s)
{
diff --git a/desktop/scrollbar.h b/desktop/scrollbar.h
index d277be2..f715331 100644
--- a/desktop/scrollbar.h
+++ b/desktop/scrollbar.h
@@ -16,12 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Scrollbar widget (interface).
+/**
+ * \file
+ * Scrollbar widget interface.
*/
-#ifndef _NETSURF_DESKTOP_SCROLLBAR_H_
-#define _NETSURF_DESKTOP_SCROLLBAR_H_
+#ifndef NETSURF_DESKTOP_SCROLLBAR_H
+#define NETSURF_DESKTOP_SCROLLBAR_H
#include <stdbool.h>
#include <limits.h>
@@ -36,16 +37,22 @@
struct scrollbar;
+/**
+ * scrollbar message types
+ */
typedef enum {
- SCROLLBAR_MSG_MOVED, /* the scroll value has changed */
- SCROLLBAR_MSG_SCROLL_START, /* a scrollbar drag has started, all
- * mouse events should be passed to
+ SCROLLBAR_MSG_MOVED, /**< the scroll value has changed */
+ SCROLLBAR_MSG_SCROLL_START, /**< a scrollbar drag has started, all
+ * mouse events should be passed to
* the scrollbar regardless of the
* coordinates
*/
- SCROLLBAR_MSG_SCROLL_FINISHED, /* cancel the above */
+ SCROLLBAR_MSG_SCROLL_FINISHED, /**< cancel a scrollbar drag */
} scrollbar_msg;
+/**
+ * scrollbar message context data
+ */
struct scrollbar_msg_data {
struct scrollbar *scrollbar;
scrollbar_msg msg;
@@ -53,9 +60,30 @@ struct scrollbar_msg_data {
int x0, y0, x1, y1;
};
+
+/**
+ * Scrollbar mouse input status flags
+ */
+typedef enum {
+ SCROLLBAR_MOUSE_NONE = 0, /**< Not relevant */
+ SCROLLBAR_MOUSE_USED = (1 << 0), /**< Took action with input */
+ SCROLLBAR_MOUSE_BOTH = (1 << 1), /**< Scrolling both bars */
+ SCROLLBAR_MOUSE_UP = (1 << 2), /**< Hover: scroll up */
+ SCROLLBAR_MOUSE_PUP = (1 << 3), /**< Hover: scroll page up */
+ SCROLLBAR_MOUSE_VRT = (1 << 4), /**< Hover: vert. drag bar */
+ SCROLLBAR_MOUSE_PDWN = (1 << 5), /**< Hover: scroll page down */
+ SCROLLBAR_MOUSE_DWN = (1 << 6), /**< Hover: scroll down */
+ SCROLLBAR_MOUSE_LFT = (1 << 7), /**< Hover: scroll left */
+ SCROLLBAR_MOUSE_PLFT = (1 << 8), /**< Hover: scroll page left */
+ SCROLLBAR_MOUSE_HRZ = (1 << 9), /**< Hover: horiz. drag bar */
+ SCROLLBAR_MOUSE_PRGT = (1 << 10), /**< Hover: scroll page right */
+ SCROLLBAR_MOUSE_RGT = (1 << 11) /**< Hover: scroll right */
+} scrollbar_mouse_status;
+
+
/**
* Client callback for the scrollbar.
- *
+ *
* \param client_data user data passed at scroll creation
* \param scrollbar_data scrollbar message data
*/
@@ -84,7 +112,7 @@ nserror scrollbar_create(bool horizontal, int length, int full_size,
/**
* Destroy a scrollbar.
*
- * \param s the scrollbar to be destroyed
+ * \param s the scrollbar to be destroyed
*/
void scrollbar_destroy(struct scrollbar *s);
@@ -97,9 +125,9 @@ void scrollbar_destroy(struct scrollbar *s);
* \param clip the clipping rectangle
* \param scale scale for the redraw
* \param ctx current redraw context
- * \return true on succes false otherwise
+ * \return NSERROR_OK on success otherwise error code
*/
-bool scrollbar_redraw(struct scrollbar *s, int x, int y,
+nserror scrollbar_redraw(struct scrollbar *s, int x, int y,
const struct rect *clip, float scale,
const struct redraw_context *ctx);
@@ -125,8 +153,8 @@ bool scrollbar_scroll(struct scrollbar *s, int change);
/**
* Get the current scroll offset to the visible part of the full area.
*
- * \param s the scrollbar to get the scroll offset value from
- * \return current scroll offset
+ * \param s the scrollbar to get the scroll offset value from
+ * \return current scroll offset
*/
int scrollbar_get_offset(struct scrollbar *s);
@@ -150,22 +178,6 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
*/
bool scrollbar_is_horizontal(struct scrollbar *s);
-/* Scrollbar mouse input status flags */
-typedef enum {
- SCROLLBAR_MOUSE_NONE = 0, /**< Not relevant */
- SCROLLBAR_MOUSE_USED = (1 << 0), /**< Took action with input */
- SCROLLBAR_MOUSE_BOTH = (1 << 1), /**< Scrolling both bars */
- SCROLLBAR_MOUSE_UP = (1 << 2), /**< Hover: scroll up */
- SCROLLBAR_MOUSE_PUP = (1 << 3), /**< Hover: scroll page up */
- SCROLLBAR_MOUSE_VRT = (1 << 4), /**< Hover: vert. drag bar */
- SCROLLBAR_MOUSE_PDWN = (1 << 5), /**< Hover: scroll page down */
- SCROLLBAR_MOUSE_DWN = (1 << 6), /**< Hover: scroll down */
- SCROLLBAR_MOUSE_LFT = (1 << 7), /**< Hover: scroll left */
- SCROLLBAR_MOUSE_PLFT = (1 << 8), /**< Hover: scroll page left */
- SCROLLBAR_MOUSE_HRZ = (1 << 9), /**< Hover: horiz. drag bar */
- SCROLLBAR_MOUSE_PRGT = (1 << 10), /**< Hover: scroll page right */
- SCROLLBAR_MOUSE_RGT = (1 << 11) /**< Hover: scroll right */
-} scrollbar_mouse_status;
/**
* Handle mouse actions other then drag ends.
@@ -179,6 +191,7 @@ typedef enum {
scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
browser_mouse_state mouse, int x, int y);
+
/**
* Get a status bar message from a scrollbar mouse input status.
*
@@ -187,6 +200,7 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
*/
const char *scrollbar_mouse_status_to_message(scrollbar_mouse_status status);
+
/**
* Handle end of mouse drags.
*
@@ -198,18 +212,21 @@ const char *scrollbar_mouse_status_to_message(scrollbar_mouse_status status);
void scrollbar_mouse_drag_end(struct scrollbar *s,
browser_mouse_state mouse, int x, int y);
+
/**
* Called when the content is being dragged to the scrollbars have to adjust.
+ *
* If the content has both scrollbars, and scrollbar_make_pair has beed called
* before, only the one scroll which will receive further mouse events has to be
* passed.
*
- * \param s one of the the scrollbars owned by the dragged content
- * \param x X coordinate of mouse during drag start
- * \param y Y coordinate of mouse during drag start
+ * \param s one of the the scrollbars owned by the dragged content
+ * \param x X coordinate of mouse during drag start
+ * \param y Y coordinate of mouse during drag start
*/
void scrollbar_start_content_drag(struct scrollbar *s, int x, int y);
+
/**
* Connect a horizontal and a vertical scrollbar into a pair so that they
* co-operate during 2D drags.
@@ -220,11 +237,12 @@ void scrollbar_start_content_drag(struct scrollbar *s, int x, int y);
void scrollbar_make_pair(struct scrollbar *horizontal,
struct scrollbar *vertical);
+
/**
* Get the scrollbar's client data
*
- * \param s the scrollbar to get the client data from
- * \return client data
+ * \param s the scrollbar to get the client data from
+ * \return client data
*/
void *scrollbar_get_data(struct scrollbar *s);
diff --git a/desktop/textarea.c b/desktop/textarea.c
index af1cd80..65ee8b8 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -2392,19 +2392,21 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
ctx->plot->clip(ctx, clip);
- if (ta->bar_x != NULL)
+ if (ta->bar_x != NULL) {
scrollbar_redraw(ta->bar_x,
x / scale + ta->border_width,
y / scale + ta->vis_height - ta->border_width -
SCROLLBAR_WIDTH,
clip, scale, ctx);
+ }
- if (ta->bar_y != NULL)
+ if (ta->bar_y != NULL) {
scrollbar_redraw(ta->bar_y,
x / scale + ta->vis_width - ta->border_width -
SCROLLBAR_WIDTH,
y / scale + ta->border_width,
clip, scale, ctx);
+ }
}
diff --git a/render/form.c b/render/form.c
index be07e80..a8b96fe 100644
--- a/render/form.c
+++ b/render/form.c
@@ -1298,11 +1298,13 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
option = option->next;
}
- if (!scrollbar_redraw(menu->scrollbar,
- x_cp + menu->width - SCROLLBAR_WIDTH,
- y_cp,
- clip, scale, ctx))
+ res = scrollbar_redraw(menu->scrollbar,
+ x_cp + menu->width - SCROLLBAR_WIDTH,
+ y_cp,
+ clip, scale, ctx);
+ if (res != NSERROR_OK) {
return false;
+ }
return true;
}
-----------------------------------------------------------------------
Summary of changes:
desktop/browser.c | 18 ++-
desktop/scrollbar.c | 355 +++++++++++++++++++++++++++++----------------------
desktop/scrollbar.h | 88 ++++++++-----
desktop/textarea.c | 6 +-
render/form.c | 10 +-
5 files changed, 279 insertions(+), 198 deletions(-)
diff --git a/desktop/browser.c b/desktop/browser.c
index 3a7ac0e..d0114ef 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -154,8 +154,11 @@ browser_window_set_name(struct browser_window *bw, const char *name)
}
/* exported interface, documented in browser.h */
-bool browser_window_redraw(struct browser_window *bw, int x, int y,
- const struct rect *clip, const struct redraw_context *ctx)
+bool
+browser_window_redraw(struct browser_window *bw,
+ int x, int y,
+ const struct rect *clip,
+ const struct redraw_context *ctx)
{
struct redraw_context new_ctx = *ctx;
int width = 0;
@@ -164,6 +167,7 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
content_type content_type;
struct content_redraw_data data;
struct rect content_clip;
+ nserror res;
if (bw == NULL) {
LOG("NULL browser window");
@@ -299,16 +303,22 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
if (bw->scroll_x != NULL) {
browser_window_get_scrollbar_pos(bw, true,
&off_x, &off_y);
- plot_ok &= scrollbar_redraw(bw->scroll_x,
+ res = scrollbar_redraw(bw->scroll_x,
x + off_x, y + off_y, clip,
bw->scale, &new_ctx);
+ if (res != NSERROR_OK) {
+ plot_ok = false;
+ }
}
if (bw->scroll_y != NULL) {
browser_window_get_scrollbar_pos(bw, false,
&off_x, &off_y);
- plot_ok &= scrollbar_redraw(bw->scroll_y,
+ res = scrollbar_redraw(bw->scroll_y,
x + off_x, y + off_y, clip,
bw->scale, &new_ctx);
+ if (res != NSERROR_OK) {
+ plot_ok = false;
+ }
}
}
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 0432696..5a7420a 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -46,39 +46,56 @@ struct scrollbar {
/** Length of the scrollbar widget */
int length;
- int full_size; /* Length of the full scrollable area */
- int visible_size; /* Length visible part of the scrollable area */
-
- int offset; /* Current scroll offset to visible area */
-
- int bar_pos; /* Position of the scrollbar */
- int bar_len; /* Length of the scrollbar */
-
- scrollbar_client_callback client_callback; /* Callback receiving
- * scrollbar events */
- void *client_data; /* User data passed to the callback */
-
- bool dragging; /* Flag indicating drag at progess */
- int drag_start_coord; /* Coordinate value at drag start */
- int drag_start_pos; /* Scrollbar offset or bar_pos at drag start */
- bool drag_content; /* Flag indicating that the drag corresponds to
- * a dragged content area, rather than a dragged
- * scrollbar. */
+ /** Length of the full scrollable area */
+ int full_size;
+ /** Length visible part of the scrollable area */
+ int visible_size;
+
+ /** Current scroll offset to visible area */
+ int offset;
+
+ /** Position of the scrollbar */
+ int bar_pos;
+ /** Length of the scrollbar */
+ int bar_len;
+
+ /** Callback receiving scrollbar events */
+ scrollbar_client_callback client_callback;
+ /** User data passed to the callback */
+ void *client_data;
+
+ /** Flag indicating drag at progess */
+ bool dragging;
+ /** Coordinate value at drag start */
+ int drag_start_coord;
+ /** Scrollbar offset or bar_pos at drag start */
+ int drag_start_pos;
+ /** Flag indicating that the drag corresponds to a dragged
+ * content area, rather than a dragged scrollbar.
+ */
+ bool drag_content;
- struct scrollbar *pair; /* Parpendicular scrollbar, or NULL */
- bool pair_drag; /* Flag indicating that the current drag affects
- the perpendicular scrollbar too */
+ /** Parpendicular scrollbar, or NULL */
+ struct scrollbar *pair;
+ /** Flag indicating that the current drag affects the
+ * perpendicular scrollbar too
+ */
+ bool pair_drag;
};
/*
- * Exported function. Documented in desktop/scrollbar.h
+ * Exported interface. Documented in desktop/scrollbar.h
*/
-nserror scrollbar_create(bool horizontal, int length, int full_size,
- int visible_size, void *client_data,
- scrollbar_client_callback client_callback,
- struct scrollbar **s)
+nserror
+scrollbar_create(bool horizontal,
+ int length,
+ int full_size,
+ int visible_size,
+ void *client_data,
+ scrollbar_client_callback client_callback,
+ struct scrollbar **s)
{
struct scrollbar *scrollbar;
int well_length;
@@ -100,7 +117,7 @@ nserror scrollbar_create(bool horizontal, int length, int full_size,
well_length = length - 2 * SCROLLBAR_WIDTH;
scrollbar->bar_len = (full_size == 0) ? 0 :
- ((well_length * visible_size) / full_size);
+ ((well_length * visible_size) / full_size);
scrollbar->client_callback = client_callback;
scrollbar->client_data = client_data;
@@ -115,12 +132,13 @@ nserror scrollbar_create(bool horizontal, int length, int full_size,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_destroy(struct scrollbar *s)
{
- if (s->pair != NULL)
+ if (s->pair != NULL) {
s->pair->pair = NULL;
+ }
free(s);
}
@@ -135,7 +153,6 @@ void scrollbar_destroy(struct scrollbar *s)
* \param inset true for inset outline, false for an outset one
* \return NSERROR_OK on success else error code
*/
-
static inline nserror
scrollbar_rectangle(const struct redraw_context *ctx,
struct rect *area,
@@ -215,11 +232,14 @@ scrollbar_rectangle(const struct redraw_context *ctx,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
-bool scrollbar_redraw(struct scrollbar *s, int x, int y,
- const struct rect *clip, float scale,
- const struct redraw_context *ctx)
+nserror
+scrollbar_redraw(struct scrollbar *s,
+ int x, int y,
+ const struct rect *clip,
+ float scale,
+ const struct redraw_context *ctx)
{
int w = SCROLLBAR_WIDTH;
int bar_pos, bar_c0, bar_c1;
@@ -259,7 +279,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
area.y1 = y + (s->horizontal ? SCROLLBAR_WIDTH : s->length) - 1;
bar_pos = s->bar_pos;
bar_c1 = (s->horizontal ? area.x0 : area.y0) + SCROLLBAR_WIDTH +
- s->bar_pos + s->bar_len - 1;
+ s->bar_pos + s->bar_len - 1;
if (scale != 1.0) {
w *= scale;
@@ -278,7 +298,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
(area.y1 < clip->y0) ||
(clip->x1 < area.x0) ||
(clip->y1 < area.y0)) {
- return true;
+ return NSERROR_OK;
}
if (s->horizontal) {
@@ -288,7 +308,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
res = scrollbar_rectangle(ctx, &area,
bg_fill_style.fill_colour, true);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* left arrow icon border */
@@ -299,7 +319,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
res = scrollbar_rectangle(ctx, &rect,
fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* left arrow icon background */
@@ -309,7 +329,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - 1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* left arrow */
@@ -321,7 +341,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[5] = area.y0 + w * 3 / 4;
res = ctx->plot->polygon(ctx, &arrow_fill_style, v, 3);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* scrollbar well background */
@@ -331,7 +351,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1;
res = ctx->plot->rectangle(ctx, &bg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* scrollbar position indicator bar */
@@ -339,9 +359,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = bar_c1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
rect.x0 = bar_c0 + 1;
@@ -350,7 +371,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - 1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* right arrow icon border */
@@ -358,9 +379,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x1 - 1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* right arrow icon background */
@@ -370,7 +392,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - 1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* right arrow */
@@ -382,15 +404,16 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[5] = rect.y0 + w * 3 / 4;
res = ctx->plot->polygon(ctx, &arrow_fill_style, v, 3);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
} else {
/* scrollbar is vertical */
/* outline */
- res = scrollbar_rectangle(ctx, &area, bg_fill_style.fill_colour, true);
+ res = scrollbar_rectangle(ctx, &area,
+ bg_fill_style.fill_colour, true);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* top arrow border */
@@ -398,9 +421,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x1 - 1;
rect.y1 = area.y0 + w - 2;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* top arrow background */
@@ -410,7 +434,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y0 + w - 2;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* up arrow */
@@ -422,7 +446,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[5] = area.y0 + w * 3 / 4;
res = ctx->plot->polygon(ctx, &arrow_fill_style, v, 3);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* scrollbar well background */
@@ -432,7 +456,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - w + 2;
res = ctx->plot->rectangle(ctx, &bg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* scrollbar position indicator bar */
@@ -440,9 +464,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = bar_c0;
rect.x1 = area.x1 - 1;
rect.y1 = bar_c1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
rect.x0 = area.x0 + 2;
@@ -451,7 +476,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = bar_c1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* down arrow icon border */
@@ -459,9 +484,10 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y1 - w + 2;
rect.x1 = area.x1 - 1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* down arrow icon background */
@@ -471,7 +497,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y1 = area.y1 - 1;
res = ctx->plot->rectangle(ctx, &fg_fill_style, &rect);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
/* down arrow */
@@ -483,16 +509,16 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
v[5] = area.y1 - w * 3 / 4 + 1;
res = ctx->plot->polygon(ctx, &arrow_fill_style, v, 3);
if (res != NSERROR_OK) {
- return false;
+ return res;
}
}
- return true;
+ return NSERROR_OK;
}
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_set(struct scrollbar *s, int value, bool bar_pos)
{
@@ -500,46 +526,49 @@ void scrollbar_set(struct scrollbar *s, int value, bool bar_pos)
int old_offset = s->offset;
struct scrollbar_msg_data msg;
- if (value < 0)
+ if (value < 0) {
value = 0;
+ }
- if (s->full_size == s->visible_size)
+ if (s->full_size == s->visible_size) {
return;
+ }
well_length = s->length - 2 * SCROLLBAR_WIDTH;
if (bar_pos) {
- if (value > well_length - s->bar_len)
+ if (value > well_length - s->bar_len) {
s->bar_pos = well_length - s->bar_len;
- else
+ } else {
s->bar_pos = value;
+ }
s->offset = ((well_length - s->bar_len) < 1) ? 0 :
- (((s->full_size - s->visible_size) *
- s->bar_pos) / (well_length - s->bar_len));
+ (((s->full_size - s->visible_size) *
+ s->bar_pos) / (well_length - s->bar_len));
} else {
- if (value > s->full_size - s->visible_size)
+ if (value > s->full_size - s->visible_size) {
s->offset = s->full_size - s->visible_size;
- else
+ } else {
s->offset = value;
+ }
s->bar_pos = (s->full_size < 1) ? 0 :
- ((well_length * s->offset) / s->full_size);
+ ((well_length * s->offset) / s->full_size);
}
- if (s->offset == old_offset)
- /* Nothing happened */
- return;
-
- msg.scrollbar = s;
- msg.msg = SCROLLBAR_MSG_MOVED;
- msg.scroll_offset = s->offset;
- s->client_callback(s->client_data, &msg);
+ if (s->offset != old_offset) {
+ /* client callback if there was a chnage */
+ msg.scrollbar = s;
+ msg.msg = SCROLLBAR_MSG_MOVED;
+ msg.scroll_offset = s->offset;
+ s->client_callback(s->client_data, &msg);
+ }
}
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
bool scrollbar_scroll(struct scrollbar *s, int change)
{
@@ -547,9 +576,10 @@ bool scrollbar_scroll(struct scrollbar *s, int change)
int old_offset = s->offset;
struct scrollbar_msg_data msg;
- if (change == 0 || s->full_size <= s->visible_size)
+ if (change == 0 || s->full_size <= s->visible_size) {
/* zero scroll step, or unscrollable */
return false;
+ }
/* Convert named change values to appropriate pixel offset value */
switch (change) {
@@ -575,21 +605,23 @@ bool scrollbar_scroll(struct scrollbar *s, int change)
}
/* Get new offset */
- if (s->offset + change > s->full_size - s->visible_size)
+ if (s->offset + change > s->full_size - s->visible_size) {
s->offset = s->full_size - s->visible_size;
- else if (s->offset + change < 0)
+ } else if (s->offset + change < 0) {
s->offset = 0;
- else
+ } else {
s->offset += change;
+ }
- if (s->offset == old_offset)
+ if (s->offset == old_offset) {
/* Nothing happened */
return false;
+ }
/* Update scrollbar */
well_length = s->length - 2 * SCROLLBAR_WIDTH;
s->bar_pos = (s->full_size < 1) ? 0 :
- ((well_length * s->offset) / s->full_size);
+ ((well_length * s->offset) / s->full_size);
msg.scrollbar = s;
msg.msg = SCROLLBAR_MSG_MOVED;
@@ -601,41 +633,47 @@ bool scrollbar_scroll(struct scrollbar *s, int change)
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
int scrollbar_get_offset(struct scrollbar *s)
{
- if (s == NULL)
+ if (s == NULL) {
return 0;
+ }
return s->offset;
}
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_set_extents(struct scrollbar *s, int length,
- int visible_size, int full_size)
+ int visible_size, int full_size)
{
int cur_excess = s->full_size - s->visible_size;
int well_length;
struct scrollbar_msg_data msg;
- if (length == s->length && visible_size == s->visible_size &&
- full_size == s->full_size) {
+ if (length == s->length &&
+ visible_size == s->visible_size &&
+ full_size == s->full_size) {
/* Nothing's changed. */
return;
}
- if (length != -1)
+ if (length != -1) {
s->length = length;
- if (visible_size != -1)
+ }
+ if (visible_size != -1) {
s->visible_size = visible_size;
- if (full_size != -1)
+ }
+ if (full_size != -1) {
s->full_size = full_size;
+ }
- if (s->full_size < s->visible_size)
+ if (s->full_size < s->visible_size) {
s->full_size = s->visible_size;
+ }
/* Update scroll offset (scaled in proportion with change in excess) */
if (cur_excess <= 0) {
@@ -662,7 +700,7 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
bool scrollbar_is_horizontal(struct scrollbar *s)
{
@@ -680,9 +718,11 @@ bool scrollbar_is_horizontal(struct scrollbar *s)
* user drags the content area, rather than the scrollbar)
* \param pair whether the drag is a '2D' scroll
*/
-
-static void scrollbar_drag_start_internal(struct scrollbar *s, int x, int y,
- bool content_drag, bool pair)
+static void
+scrollbar_drag_start_internal(struct scrollbar *s,
+ int x, int y,
+ bool content_drag,
+ bool pair)
{
struct scrollbar_msg_data msg;
@@ -694,7 +734,7 @@ static void scrollbar_drag_start_internal(struct scrollbar *s, int x, int y,
msg.scrollbar = s;
- /* \todo - some proper numbers please! */
+ /** \todo some proper numbers please! */
if (s->horizontal) {
msg.x0 = -2048;
msg.x1 = 2048;
@@ -711,10 +751,10 @@ static void scrollbar_drag_start_internal(struct scrollbar *s, int x, int y,
s->pair_drag = true;
s->pair->drag_start_coord =
- s->pair->horizontal ? x : y;
+ s->pair->horizontal ? x : y;
s->pair->drag_start_pos = (content_drag) ? s->pair->offset :
- s->pair->bar_pos;
+ s->pair->bar_pos;
s->pair->dragging = true;
s->pair->drag_content = content_drag;
@@ -733,10 +773,12 @@ static void scrollbar_drag_start_internal(struct scrollbar *s, int x, int y,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
-scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
- browser_mouse_state mouse, int x, int y)
+scrollbar_mouse_status
+scrollbar_mouse_action(struct scrollbar *s,
+ browser_mouse_state mouse,
+ int x, int y)
{
int x0, y0, x1, y1;
int val;
@@ -747,13 +789,13 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
* scrollbar indication bar to be launching actions on the scroll area
*/
bool but1 = ((mouse & BROWSER_MOUSE_PRESS_1) ||
- ((mouse & BROWSER_MOUSE_HOLDING_1) &&
- (mouse & BROWSER_MOUSE_DRAG_ON) &&
- !s->dragging));
+ ((mouse & BROWSER_MOUSE_HOLDING_1) &&
+ (mouse & BROWSER_MOUSE_DRAG_ON) &&
+ !s->dragging));
bool but2 = ((mouse & BROWSER_MOUSE_PRESS_2) ||
- ((mouse & BROWSER_MOUSE_HOLDING_2) &&
- (mouse & BROWSER_MOUSE_DRAG_ON) &&
- !s->dragging));
+ ((mouse & BROWSER_MOUSE_HOLDING_2) &&
+ (mouse & BROWSER_MOUSE_DRAG_ON) &&
+ !s->dragging));
h = s->horizontal;
@@ -768,24 +810,27 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
}
- if (h)
+ if (h) {
val = x;
- else
+ } else {
val = y;
+ }
if (s->dragging) {
val -= s->drag_start_coord;
- if (s->drag_content)
+ if (s->drag_content) {
val = -val;
- if (val != 0)
+ }
+ if (val != 0) {
scrollbar_set(s, s->drag_start_pos + val,
- !(s->drag_content));
+ !(s->drag_content));
+ }
if (s->pair_drag) {
scrollbar_mouse_action(s->pair, mouse, x, y);
status = SCROLLBAR_MOUSE_BOTH;
- } else
+ } else {
status = h ? SCROLLBAR_MOUSE_HRZ : SCROLLBAR_MOUSE_VRT;
-
+ }
return status;
}
@@ -793,42 +838,41 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
/* left/up arrow */
status = h ? SCROLLBAR_MOUSE_LFT : SCROLLBAR_MOUSE_UP;
- if (but1)
+ if (but1) {
scrollbar_set(s, s->offset - SCROLLBAR_WIDTH, false);
- else if (but2)
+ } else if (but2) {
scrollbar_set(s, s->offset + SCROLLBAR_WIDTH, false);
-
+ }
} else if (val < SCROLLBAR_WIDTH + s->bar_pos) {
/* well between left/up arrow and bar */
status = h ? SCROLLBAR_MOUSE_PLFT : SCROLLBAR_MOUSE_PUP;
- if (but1)
+ if (but1) {
scrollbar_set(s, s->offset - s->length, false);
- else if (but2)
+ } else if (but2) {
scrollbar_set(s, s->offset + s->length, false);
-
+ }
} else if (val > s->length - SCROLLBAR_WIDTH) {
/* right/down arrow */
status = h ? SCROLLBAR_MOUSE_RGT : SCROLLBAR_MOUSE_DWN;
- if (but1)
+ if (but1) {
scrollbar_set(s, s->offset + SCROLLBAR_WIDTH, false);
- else if (but2)
+ } else if (but2) {
scrollbar_set(s, s->offset - SCROLLBAR_WIDTH, false);
-
- } else if (val > SCROLLBAR_WIDTH + s->bar_pos +
- s->bar_len) {
+ }
+ } else if (val > SCROLLBAR_WIDTH + s->bar_pos + s->bar_len) {
/* well between right/down arrow and bar */
status = h ? SCROLLBAR_MOUSE_PRGT : SCROLLBAR_MOUSE_PDWN;
- if (but1)
+ if (but1) {
scrollbar_set(s, s->offset + s->length, false);
- else if (but2)
+ } else if (but2) {
scrollbar_set(s, s->offset - s->length, false);
- }
- else {
+ }
+ } else {
/* scrollbar position indication bar */
status = h ? SCROLLBAR_MOUSE_HRZ : SCROLLBAR_MOUSE_VRT;
@@ -836,20 +880,21 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2) &&
- (val >= SCROLLBAR_WIDTH + s->bar_pos
- && val < SCROLLBAR_WIDTH + s->bar_pos +
- s->bar_len))
+ (val >= SCROLLBAR_WIDTH + s->bar_pos
+ && val < SCROLLBAR_WIDTH + s->bar_pos +
+ s->bar_len)) {
/* The mouse event is a drag start on the scrollbar position
* indication bar. */
scrollbar_drag_start_internal(s, x, y, false,
- (mouse & BROWSER_MOUSE_DRAG_2) ? true : false);
+ (mouse & BROWSER_MOUSE_DRAG_2) ? true : false);
+ }
return status;
}
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
const char *scrollbar_mouse_status_to_message(scrollbar_mouse_status status)
{
@@ -893,10 +938,10 @@ const char *scrollbar_mouse_status_to_message(scrollbar_mouse_status status)
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_mouse_drag_end(struct scrollbar *s,
- browser_mouse_state mouse, int x, int y)
+ browser_mouse_state mouse, int x, int y)
{
struct scrollbar_msg_data msg;
int val, drag_start_pos;
@@ -906,10 +951,12 @@ void scrollbar_mouse_drag_end(struct scrollbar *s,
drag_start_pos = s->drag_start_pos;
val = (s->horizontal ? x : y) - s->drag_start_coord;
- if (s->drag_content)
+ if (s->drag_content) {
val = -val;
- if (val != 0)
+ }
+ if (val != 0) {
scrollbar_set(s, drag_start_pos + val, !(s->drag_content));
+ }
s->dragging = false;
s->drag_content = false;
@@ -920,11 +967,13 @@ void scrollbar_mouse_drag_end(struct scrollbar *s,
drag_start_pos = s->pair->drag_start_pos;
val = (s->pair->horizontal ? x : y) - s->pair->drag_start_coord;
- if (s->pair->drag_content)
+ if (s->pair->drag_content) {
val = -val;
- if (val != 0)
+ }
+ if (val != 0) {
scrollbar_set(s->pair, drag_start_pos + val,
- !(s->pair->drag_content));
+ !(s->pair->drag_content));
+ }
s->pair->dragging = false;
s->pair->drag_content = false;
@@ -937,7 +986,7 @@ void scrollbar_mouse_drag_end(struct scrollbar *s,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_start_content_drag(struct scrollbar *s, int x, int y)
{
@@ -946,13 +995,13 @@ void scrollbar_start_content_drag(struct scrollbar *s, int x, int y)
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void scrollbar_make_pair(struct scrollbar *horizontal,
- struct scrollbar *vertical)
+ struct scrollbar *vertical)
{
assert(horizontal->horizontal &&
- !vertical->horizontal);
+ !vertical->horizontal);
horizontal->pair = vertical;
vertical->pair = horizontal;
@@ -960,7 +1009,7 @@ void scrollbar_make_pair(struct scrollbar *horizontal,
/*
- * Exported function. Documented in scrollbar.h
+ * Exported interface. Documented in scrollbar.h
*/
void *scrollbar_get_data(struct scrollbar *s)
{
diff --git a/desktop/scrollbar.h b/desktop/scrollbar.h
index d277be2..f715331 100644
--- a/desktop/scrollbar.h
+++ b/desktop/scrollbar.h
@@ -16,12 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Scrollbar widget (interface).
+/**
+ * \file
+ * Scrollbar widget interface.
*/
-#ifndef _NETSURF_DESKTOP_SCROLLBAR_H_
-#define _NETSURF_DESKTOP_SCROLLBAR_H_
+#ifndef NETSURF_DESKTOP_SCROLLBAR_H
+#define NETSURF_DESKTOP_SCROLLBAR_H
#include <stdbool.h>
#include <limits.h>
@@ -36,16 +37,22 @@
struct scrollbar;
+/**
+ * scrollbar message types
+ */
typedef enum {
- SCROLLBAR_MSG_MOVED, /* the scroll value has changed */
- SCROLLBAR_MSG_SCROLL_START, /* a scrollbar drag has started, all
- * mouse events should be passed to
+ SCROLLBAR_MSG_MOVED, /**< the scroll value has changed */
+ SCROLLBAR_MSG_SCROLL_START, /**< a scrollbar drag has started, all
+ * mouse events should be passed to
* the scrollbar regardless of the
* coordinates
*/
- SCROLLBAR_MSG_SCROLL_FINISHED, /* cancel the above */
+ SCROLLBAR_MSG_SCROLL_FINISHED, /**< cancel a scrollbar drag */
} scrollbar_msg;
+/**
+ * scrollbar message context data
+ */
struct scrollbar_msg_data {
struct scrollbar *scrollbar;
scrollbar_msg msg;
@@ -53,9 +60,30 @@ struct scrollbar_msg_data {
int x0, y0, x1, y1;
};
+
+/**
+ * Scrollbar mouse input status flags
+ */
+typedef enum {
+ SCROLLBAR_MOUSE_NONE = 0, /**< Not relevant */
+ SCROLLBAR_MOUSE_USED = (1 << 0), /**< Took action with input */
+ SCROLLBAR_MOUSE_BOTH = (1 << 1), /**< Scrolling both bars */
+ SCROLLBAR_MOUSE_UP = (1 << 2), /**< Hover: scroll up */
+ SCROLLBAR_MOUSE_PUP = (1 << 3), /**< Hover: scroll page up */
+ SCROLLBAR_MOUSE_VRT = (1 << 4), /**< Hover: vert. drag bar */
+ SCROLLBAR_MOUSE_PDWN = (1 << 5), /**< Hover: scroll page down */
+ SCROLLBAR_MOUSE_DWN = (1 << 6), /**< Hover: scroll down */
+ SCROLLBAR_MOUSE_LFT = (1 << 7), /**< Hover: scroll left */
+ SCROLLBAR_MOUSE_PLFT = (1 << 8), /**< Hover: scroll page left */
+ SCROLLBAR_MOUSE_HRZ = (1 << 9), /**< Hover: horiz. drag bar */
+ SCROLLBAR_MOUSE_PRGT = (1 << 10), /**< Hover: scroll page right */
+ SCROLLBAR_MOUSE_RGT = (1 << 11) /**< Hover: scroll right */
+} scrollbar_mouse_status;
+
+
/**
* Client callback for the scrollbar.
- *
+ *
* \param client_data user data passed at scroll creation
* \param scrollbar_data scrollbar message data
*/
@@ -84,7 +112,7 @@ nserror scrollbar_create(bool horizontal, int length, int full_size,
/**
* Destroy a scrollbar.
*
- * \param s the scrollbar to be destroyed
+ * \param s the scrollbar to be destroyed
*/
void scrollbar_destroy(struct scrollbar *s);
@@ -97,9 +125,9 @@ void scrollbar_destroy(struct scrollbar *s);
* \param clip the clipping rectangle
* \param scale scale for the redraw
* \param ctx current redraw context
- * \return true on succes false otherwise
+ * \return NSERROR_OK on success otherwise error code
*/
-bool scrollbar_redraw(struct scrollbar *s, int x, int y,
+nserror scrollbar_redraw(struct scrollbar *s, int x, int y,
const struct rect *clip, float scale,
const struct redraw_context *ctx);
@@ -125,8 +153,8 @@ bool scrollbar_scroll(struct scrollbar *s, int change);
/**
* Get the current scroll offset to the visible part of the full area.
*
- * \param s the scrollbar to get the scroll offset value from
- * \return current scroll offset
+ * \param s the scrollbar to get the scroll offset value from
+ * \return current scroll offset
*/
int scrollbar_get_offset(struct scrollbar *s);
@@ -150,22 +178,6 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
*/
bool scrollbar_is_horizontal(struct scrollbar *s);
-/* Scrollbar mouse input status flags */
-typedef enum {
- SCROLLBAR_MOUSE_NONE = 0, /**< Not relevant */
- SCROLLBAR_MOUSE_USED = (1 << 0), /**< Took action with input */
- SCROLLBAR_MOUSE_BOTH = (1 << 1), /**< Scrolling both bars */
- SCROLLBAR_MOUSE_UP = (1 << 2), /**< Hover: scroll up */
- SCROLLBAR_MOUSE_PUP = (1 << 3), /**< Hover: scroll page up */
- SCROLLBAR_MOUSE_VRT = (1 << 4), /**< Hover: vert. drag bar */
- SCROLLBAR_MOUSE_PDWN = (1 << 5), /**< Hover: scroll page down */
- SCROLLBAR_MOUSE_DWN = (1 << 6), /**< Hover: scroll down */
- SCROLLBAR_MOUSE_LFT = (1 << 7), /**< Hover: scroll left */
- SCROLLBAR_MOUSE_PLFT = (1 << 8), /**< Hover: scroll page left */
- SCROLLBAR_MOUSE_HRZ = (1 << 9), /**< Hover: horiz. drag bar */
- SCROLLBAR_MOUSE_PRGT = (1 << 10), /**< Hover: scroll page right */
- SCROLLBAR_MOUSE_RGT = (1 << 11) /**< Hover: scroll right */
-} scrollbar_mouse_status;
/**
* Handle mouse actions other then drag ends.
@@ -179,6 +191,7 @@ typedef enum {
scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
browser_mouse_state mouse, int x, int y);
+
/**
* Get a status bar message from a scrollbar mouse input status.
*
@@ -187,6 +200,7 @@ scrollbar_mouse_status scrollbar_mouse_action(struct scrollbar *s,
*/
const char *scrollbar_mouse_status_to_message(scrollbar_mouse_status status);
+
/**
* Handle end of mouse drags.
*
@@ -198,18 +212,21 @@ const char *scrollbar_mouse_status_to_message(scrollbar_mouse_status status);
void scrollbar_mouse_drag_end(struct scrollbar *s,
browser_mouse_state mouse, int x, int y);
+
/**
* Called when the content is being dragged to the scrollbars have to adjust.
+ *
* If the content has both scrollbars, and scrollbar_make_pair has beed called
* before, only the one scroll which will receive further mouse events has to be
* passed.
*
- * \param s one of the the scrollbars owned by the dragged content
- * \param x X coordinate of mouse during drag start
- * \param y Y coordinate of mouse during drag start
+ * \param s one of the the scrollbars owned by the dragged content
+ * \param x X coordinate of mouse during drag start
+ * \param y Y coordinate of mouse during drag start
*/
void scrollbar_start_content_drag(struct scrollbar *s, int x, int y);
+
/**
* Connect a horizontal and a vertical scrollbar into a pair so that they
* co-operate during 2D drags.
@@ -220,11 +237,12 @@ void scrollbar_start_content_drag(struct scrollbar *s, int x, int y);
void scrollbar_make_pair(struct scrollbar *horizontal,
struct scrollbar *vertical);
+
/**
* Get the scrollbar's client data
*
- * \param s the scrollbar to get the client data from
- * \return client data
+ * \param s the scrollbar to get the client data from
+ * \return client data
*/
void *scrollbar_get_data(struct scrollbar *s);
diff --git a/desktop/textarea.c b/desktop/textarea.c
index af1cd80..65ee8b8 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -2392,19 +2392,21 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
ctx->plot->clip(ctx, clip);
- if (ta->bar_x != NULL)
+ if (ta->bar_x != NULL) {
scrollbar_redraw(ta->bar_x,
x / scale + ta->border_width,
y / scale + ta->vis_height - ta->border_width -
SCROLLBAR_WIDTH,
clip, scale, ctx);
+ }
- if (ta->bar_y != NULL)
+ if (ta->bar_y != NULL) {
scrollbar_redraw(ta->bar_y,
x / scale + ta->vis_width - ta->border_width -
SCROLLBAR_WIDTH,
y / scale + ta->border_width,
clip, scale, ctx);
+ }
}
diff --git a/render/form.c b/render/form.c
index be07e80..a8b96fe 100644
--- a/render/form.c
+++ b/render/form.c
@@ -1298,11 +1298,13 @@ bool form_redraw_select_menu(struct form_control *control, int x, int y,
option = option->next;
}
- if (!scrollbar_redraw(menu->scrollbar,
- x_cp + menu->width - SCROLLBAR_WIDTH,
- y_cp,
- clip, scale, ctx))
+ res = scrollbar_redraw(menu->scrollbar,
+ x_cp + menu->width - SCROLLBAR_WIDTH,
+ y_cp,
+ clip, scale, ctx);
+ if (res != NSERROR_OK) {
return false;
+ }
return true;
}
--
NetSurf Browser
5 years, 11 months
netsurf: branch master updated. release/3.6-280-g2f5e562
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2f5e5620e218d317d5e85...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2f5e5620e218d317d5e853f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2f5e5620e218d317d5e853fd4...
The branch, master has been updated
via 2f5e5620e218d317d5e853fd4ee9d9123b346610 (commit)
from e72b89ac3d691acb5c306c1565eaa1e559495ec8 (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/commit/?id=2f5e5620e218d317d5e...
commit 2f5e5620e218d317d5e853fd4ee9d9123b346610
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Change interface to system colours to allow reporting of errors
Allow system colour interface to report errors instead of silently
failing and propogate the errors. This also fixes teh system colour
documentation.
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 10154b7..cf70c47 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -478,17 +478,27 @@ static bool browser_window_history__enumerate_entry(
/* exported interface documented in desktop/browser_history.h */
nserror browser_window_history_create(struct browser_window *bw)
{
+ nserror res;
struct history *history;
- pstyle_bg.fill_colour = ns_system_colour_char("Window");
+ res = ns_system_colour_char("Window", &pstyle_bg.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
pfstyle_node.background = pstyle_bg.fill_colour;
pfstyle_node_sel.background = pstyle_bg.fill_colour;
- pstyle_line.stroke_colour = ns_system_colour_char("GrayText");
+ res = ns_system_colour_char("GrayText", &pstyle_line.stroke_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
pstyle_rect.stroke_colour = pstyle_line.stroke_colour;
pfstyle_node.foreground = pstyle_line.stroke_colour;
- pstyle_rect_sel.stroke_colour = ns_system_colour_char("Highlight");
+ res = ns_system_colour_char("Highlight", &pstyle_rect_sel.stroke_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour;
bw->history = NULL;
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 4f30434..0432696 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -228,23 +228,31 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
struct rect rect;
nserror res;
- colour bg_fill_colour = ns_system_colour_char("Scrollbar");
- colour fg_fill_colour = ns_system_colour_char("ButtonFace");
- colour arrow_fill_colour = ns_system_colour_char("ButtonText");
-
plot_style_t bg_fill_style = {
.fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = bg_fill_colour
};
plot_style_t fg_fill_style = {
.fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = fg_fill_colour
};
plot_style_t arrow_fill_style = {
.fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = arrow_fill_colour
};
+ res = ns_system_colour_char("Scrollbar", &bg_fill_style.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ res = ns_system_colour_char("ButtonFace", &fg_fill_style.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ res = ns_system_colour_char("ButtonText", &arrow_fill_style.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
area.x0 = x;
area.y0 = y;
area.x1 = x + (s->horizontal ? s->length : SCROLLBAR_WIDTH) - 1;
@@ -277,7 +285,8 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
/* scrollbar is horizontal */
/* scrollbar outline */
- res = scrollbar_rectangle(ctx, &area, bg_fill_colour, true);
+ res = scrollbar_rectangle(ctx, &area,
+ bg_fill_style.fill_colour, true);
if (res != NSERROR_OK) {
return false;
}
@@ -287,7 +296,8 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x0 + w - 2;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -329,7 +339,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = bar_c1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -348,7 +358,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x1 - 1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -378,7 +388,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
/* scrollbar is vertical */
/* outline */
- res = scrollbar_rectangle(ctx, &area, bg_fill_colour, true);
+ res = scrollbar_rectangle(ctx, &area, bg_fill_style.fill_colour, true);
if (res != NSERROR_OK) {
return false;
}
@@ -388,7 +398,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x1 - 1;
rect.y1 = area.y0 + w - 2;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -430,7 +440,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = bar_c0;
rect.x1 = area.x1 - 1;
rect.y1 = bar_c1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -449,7 +459,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y1 - w + 2;
rect.x1 = area.x1 - 1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
diff --git a/desktop/system_colour.c b/desktop/system_colour.c
index f33b57a..42a51ea 100644
--- a/desktop/system_colour.c
+++ b/desktop/system_colour.c
@@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * System colour handling
- *
+/**
+ * \file
+ * System colour handling implementation.
*/
#include <string.h>
@@ -38,6 +38,7 @@ static lwc_string *colour_list[colour_list_len];
static lwc_string **ns_system_colour_pw = NULL;
+/* exported interface documented in desktop/system_colour.h */
nserror ns_system_colour_init(void)
{
unsigned int ccount;
@@ -61,6 +62,8 @@ nserror ns_system_colour_init(void)
return NSERROR_OK;
}
+
+/* exported interface documented in desktop/system_colour.h */
void ns_system_colour_finalize(void)
{
unsigned int ccount;
@@ -70,21 +73,25 @@ void ns_system_colour_finalize(void)
}
}
-colour ns_system_colour_char(const char *name)
+
+/* exported interface documented in desktop/system_colour.h */
+nserror ns_system_colour_char(const char *name, colour *colour_out)
{
- colour ret = 0;
unsigned int ccount;
for (ccount = 0; ccount < colour_list_len; ccount++) {
if (strcmp(name,
nsoptions[ccount + NSOPTION_SYS_COLOUR_START].key + SLEN("sys_colour_")) == 0) {
- ret = nsoptions[ccount + NSOPTION_SYS_COLOUR_START].value.c;
- break;
+ *colour_out = nsoptions[ccount + NSOPTION_SYS_COLOUR_START].value.c;
+ return NSERROR_OK;
}
}
- return ret;
+
+ return NSERROR_INVALID;
}
+
+/* exported interface documented in desktop/system_colour.h */
css_error ns_system_colour(void *pw, lwc_string *name, css_color *colour)
{
unsigned int ccount;
diff --git a/desktop/system_colour.h b/desktop/system_colour.h
index 8e82818..0b75530 100644
--- a/desktop/system_colour.h
+++ b/desktop/system_colour.h
@@ -16,25 +16,59 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
+/**
+ * \file
* Interface to system colour values.
+ *
+ * Netsurf has a list of user configurable colours with frontend
+ * specific defaults. These colours are used for the css system
+ * colours and to colour and style internally rendered widgets
+ * (e.g. cookies treeview or local file directory views.
*/
-#ifndef _NETSURF_DESKTOP_SYSTEM_COLOUR_H_
-#define _NETSURF_DESKTOP_SYSTEM_COLOUR_H_
+#ifndef NETSURF_DESKTOP_SYSTEM_COLOUR_H
+#define NETSURF_DESKTOP_SYSTEM_COLOUR_H
#include <libcss/libcss.h>
#include "utils/errors.h"
#include "netsurf/types.h"
-/** css callback to obtain named system colours. */
+/**
+ * css callback to obtain named system colour.
+ *
+ * \param[in] pw context unused in implementation
+ * \param[in] name The name of the colour being looked up
+ * \param[out] color The system colour associated with the name.
+ * \return CSS_OK and \a color updated on success else CSS_INVALID if
+ * the \a name is unrecognised
+ */
css_error ns_system_colour(void *pw, lwc_string *name, css_color *color);
-/** Obtain a named system colour from a frontend. */
-colour ns_system_colour_char(const char *name);
+/**
+ * Obtain a system colour from a name.
+ *
+ * \param[in] name The name of the colour being looked up
+ * \param[out] color The system colour associated with the name in the
+ * netsurf colour representation.
+ * \return NSERROR_OK and \a color updated on success else appropriate
+ * error code.
+ */
+nserror ns_system_colour_char(const char *name, colour *color);
+
+
+/**
+ * Initialise the system colours
+ *
+ * \return NSERROR_OK on success else appropriate error code.
+ */
nserror ns_system_colour_init(void);
+
+
+/**
+ * release any resources associated with the system colours.
+ */
void ns_system_colour_finalize(void);
#endif
diff --git a/desktop/textarea.h b/desktop/textarea.h
index 65e2594..8986097 100644
--- a/desktop/textarea.h
+++ b/desktop/textarea.h
@@ -1,6 +1,6 @@
/*
* Copyright 2006 John-Mark Bell <jmb(a)netsurf-browser.org>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
+ * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -17,12 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Single/Multi-line UTF-8 text area (interface)
+/**
+ * \file
+ * Single/Multi-line UTF-8 text area interface
*/
-#ifndef _NETSURF_DESKTOP_TEXTAREA_H_
-#define _NETSURF_DESKTOP_TEXTAREA_H_
+#ifndef NETSURF_DESKTOP_TEXTAREA_H
+#define NETSURF_DESKTOP_TEXTAREA_H
#include <stdint.h>
#include <stdbool.h>
@@ -33,21 +34,31 @@
struct textarea;
struct redraw_context;
-/* Text area flags */
+/**
+ * Text area flags
+ */
typedef enum {
- TEXTAREA_DEFAULT = (1 << 0), /**< Standard input */
- TEXTAREA_MULTILINE = (1 << 1), /**< Multiline area */
- TEXTAREA_READONLY = (1 << 2), /**< Non-editable */
- TEXTAREA_INTERNAL_CARET = (1 << 3), /**< Render own caret */
- TEXTAREA_PASSWORD = (1 << 4) /**< Obscured display */
+ TEXTAREA_DEFAULT = (1 << 0), /**< Standard input */
+ TEXTAREA_MULTILINE = (1 << 1), /**< Multiline area */
+ TEXTAREA_READONLY = (1 << 2), /**< Non-editable */
+ TEXTAREA_INTERNAL_CARET = (1 << 3), /**< Render own caret */
+ TEXTAREA_PASSWORD = (1 << 4) /**< Obscured display */
} textarea_flags;
+
+/**
+ * Textarea drag status
+ */
typedef enum {
TEXTAREA_DRAG_NONE,
TEXTAREA_DRAG_SCROLLBAR,
TEXTAREA_DRAG_SELECTION
-} textarea_drag_type; /**< Textarea drag status */
+} textarea_drag_type;
+
+/**
+ * textarea message types
+ */
typedef enum {
TEXTAREA_MSG_DRAG_REPORT, /**< Textarea drag start/end report */
TEXTAREA_MSG_SELECTION_REPORT, /**< Textarea text selection presence */
@@ -56,6 +67,10 @@ typedef enum {
TEXTAREA_MSG_TEXT_MODIFIED /**< Textarea text modified */
} textarea_msg_type;
+
+/**
+ * textarea message
+ */
struct textarea_msg {
struct textarea *ta; /**< The textarea widget */
@@ -73,10 +88,10 @@ struct textarea_msg {
TEXTAREA_CARET_HIDE /**< Hide */
} type;
struct {
- int x; /**< Carret x-coord */
- int y; /**< Carret y-coord */
- int height; /**< Carret height */
- struct rect *clip; /**< Carret clip rect */
+ int x; /**< Caret x-coord */
+ int y; /**< Caret y-coord */
+ int height; /**< Caret height */
+ struct rect *clip; /**< Caret clip rect */
} pos; /**< With _CARET_SET_POS */
} caret; /**< With _CARET_UPDATE */
struct {
@@ -86,6 +101,10 @@ struct textarea_msg {
} data; /**< Depends on msg type */
};
+
+/**
+ * textarea setup parameters
+ */
typedef struct textarea_setup {
int width; /**< Textarea width */
int height; /**< Textarea height */
@@ -104,14 +123,39 @@ typedef struct textarea_setup {
} textarea_setup;
+
+/**
+ * Text area mouse input status flags
+ */
+typedef enum {
+ TEXTAREA_MOUSE_NONE = 0, /**< Not relevant */
+ TEXTAREA_MOUSE_USED = (1 << 0), /**< Took action with input */
+ TEXTAREA_MOUSE_EDITOR = (1 << 1), /**< Hover: caret pointer */
+ TEXTAREA_MOUSE_SELECTION= (1 << 2), /**< Hover: selection */
+ TEXTAREA_MOUSE_SCR_USED = (1 << 3), /**< Scrollbar action */
+ TEXTAREA_MOUSE_SCR_BOTH = (1 << 4), /**< Scrolling both bars */
+ TEXTAREA_MOUSE_SCR_UP = (1 << 5), /**< Hover: scroll up */
+ TEXTAREA_MOUSE_SCR_PUP = (1 << 6), /**< Hover: scroll page up */
+ TEXTAREA_MOUSE_SCR_VRT = (1 << 7), /**< Hover: vert. drag bar */
+ TEXTAREA_MOUSE_SCR_PDWN = (1 << 8), /**< Hover: scroll page down */
+ TEXTAREA_MOUSE_SCR_DWN = (1 << 9), /**< Hover: scroll down */
+ TEXTAREA_MOUSE_SCR_LFT = (1 << 10), /**< Hover: scroll left */
+ TEXTAREA_MOUSE_SCR_PLFT = (1 << 11), /**< Hover: scroll page left */
+ TEXTAREA_MOUSE_SCR_HRZ = (1 << 12), /**< Hover: horiz. drag bar */
+ TEXTAREA_MOUSE_SCR_PRGT = (1 << 13), /**< Hover: scroll page right */
+ TEXTAREA_MOUSE_SCR_RGT = (1 << 14) /**< Hover: scroll right */
+} textarea_mouse_status;
+
+
/**
* Client callback for the textarea
*
- * \param data user data passed at textarea creation
- * \param textarea_msg textarea message data
+ * \param data user data passed at textarea creation
+ * \param msg textarea message data
*/
typedef void(*textarea_client_callback)(void *data, struct textarea_msg *msg);
+
/**
* Create a text area.
*
@@ -125,6 +169,7 @@ struct textarea *textarea_create(const textarea_flags flags,
const textarea_setup *setup,
textarea_client_callback callback, void *data);
+
/**
* Destroy a text area
*
@@ -132,6 +177,7 @@ struct textarea *textarea_create(const textarea_flags flags,
*/
void textarea_destroy(struct textarea *ta);
+
/**
* Set the text in a text area, discarding any current text
*
@@ -141,6 +187,7 @@ void textarea_destroy(struct textarea *ta);
*/
bool textarea_set_text(struct textarea *ta, const char *text);
+
/**
* Insert the text in a text area at the caret, replacing any selection.
*
@@ -152,6 +199,7 @@ bool textarea_set_text(struct textarea *ta, const char *text);
bool textarea_drop_text(struct textarea *ta, const char *text,
size_t text_length);
+
/**
* Extract the text from a text area
*
@@ -163,16 +211,18 @@ bool textarea_drop_text(struct textarea *ta, const char *text,
*/
int textarea_get_text(struct textarea *ta, char *buf, unsigned int len);
+
/**
* Set the caret's position
*
- * \param ta Text area
- * \param caret 0-based character index to place caret at, -1 removes
- * the caret
+ * \param ta Text area
+ * \param caret 0-based character index to place caret at, -1 removes
+ * the caret
* \return true on success false otherwise
*/
bool textarea_set_caret(struct textarea *ta, int caret);
+
/**
* Handle redraw requests for text areas
*
@@ -187,34 +237,16 @@ bool textarea_set_caret(struct textarea *ta, int caret);
void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
const struct rect *clip, const struct redraw_context *ctx);
+
/**
* Key press handling for text areas.
*
* \param ta The text area which got the keypress
* \param key The ucs4 character codepoint
- * \return true if the keypress is dealt with, false otherwise.
+ * \return true if the keypress is dealt with, false otherwise.
*/
bool textarea_keypress(struct textarea *ta, uint32_t key);
-/* Text area mouse input status flags */
-typedef enum {
- TEXTAREA_MOUSE_NONE = 0, /**< Not relevant */
- TEXTAREA_MOUSE_USED = (1 << 0), /**< Took action with input */
- TEXTAREA_MOUSE_EDITOR = (1 << 1), /**< Hover: caret pointer */
- TEXTAREA_MOUSE_SELECTION= (1 << 2), /**< Hover: selection */
- TEXTAREA_MOUSE_SCR_USED = (1 << 3), /**< Scrollbar action */
- TEXTAREA_MOUSE_SCR_BOTH = (1 << 4), /**< Scrolling both bars */
- TEXTAREA_MOUSE_SCR_UP = (1 << 5), /**< Hover: scroll up */
- TEXTAREA_MOUSE_SCR_PUP = (1 << 6), /**< Hover: scroll page up */
- TEXTAREA_MOUSE_SCR_VRT = (1 << 7), /**< Hover: vert. drag bar */
- TEXTAREA_MOUSE_SCR_PDWN = (1 << 8), /**< Hover: scroll page down */
- TEXTAREA_MOUSE_SCR_DWN = (1 << 9), /**< Hover: scroll down */
- TEXTAREA_MOUSE_SCR_LFT = (1 << 10), /**< Hover: scroll left */
- TEXTAREA_MOUSE_SCR_PLFT = (1 << 11), /**< Hover: scroll page left */
- TEXTAREA_MOUSE_SCR_HRZ = (1 << 12), /**< Hover: horiz. drag bar */
- TEXTAREA_MOUSE_SCR_PRGT = (1 << 13), /**< Hover: scroll page right */
- TEXTAREA_MOUSE_SCR_RGT = (1 << 14) /**< Hover: scroll right */
-} textarea_mouse_status;
/**
* Handles all kinds of mouse action
@@ -228,22 +260,28 @@ typedef enum {
textarea_mouse_status textarea_mouse_action(struct textarea *ta,
browser_mouse_state mouse, int x, int y);
+
/**
* Clear any selection in the textarea.
*
- * \param ta textarea widget
+ * \param ta textarea widget
* \return true if there was a selection to clear, false otherwise
*/
bool textarea_clear_selection(struct textarea *ta);
+
/**
- * Get selected text, ownership passed to caller, which needs to free() it.
+ * Get selected text.
+ *
+ * ownership of the returned string is passed to caller which needs to
+ * free it.
*
- * \param ta Textarea widget
+ * \param ta Textarea widget
* \return Selected text, or NULL if none.
*/
char *textarea_get_selection(struct textarea *ta);
+
/**
* Gets the dimensions of a textarea
*
@@ -253,22 +291,28 @@ char *textarea_get_selection(struct textarea *ta);
*/
void textarea_get_dimensions(struct textarea *ta, int *width, int *height);
+
/**
- * Set the dimensions of a textarea, causing a reflow and
- * Does not emit a redraw request. Up to client to call textarea_redraw.
+ * Set the dimensions of a textarea.
+ *
+ * This causes a reflow of the text and does not emit a redraw
+ * request. Up to client to call textarea_redraw.
*
* \param ta textarea widget
- * \param width the new width of the textarea
+ * \param width the new width of the textarea
* \param height the new height of the textarea
*/
void textarea_set_dimensions(struct textarea *ta, int width, int height);
+
/**
- * Set the dimensions and padding of a textarea, causing a reflow.
- * Does not emit a redraw request. Up to client to call textarea_redraw.
+ * Set the dimensions and padding of a textarea.
+ *
+ * This causes a reflow of the text. Does not emit a redraw request.
+ * Up to client to call textarea_redraw.
*
* \param ta textarea widget
- * \param width the new width of the textarea
+ * \param width the new width of the textarea
* \param height the new height of the textarea
* \param top the new top padding of the textarea
* \param right the new right padding of the textarea
@@ -278,9 +322,12 @@ void textarea_set_dimensions(struct textarea *ta, int width, int height);
void textarea_set_layout(struct textarea *ta, int width, int height,
int top, int right, int bottom, int left);
+
/**
- * Scroll a textarea by an amount. Only does anything if multi-line textarea
- * has scrollbars. If it scrolls, it will emit a redraw request.
+ * Scroll a textarea by an amount.
+ *
+ * Only does anything if multi-line textarea has scrollbars. If it
+ * scrolls, it will emit a redraw request.
*
* \param ta textarea widget
* \param scrx number of px try to scroll in x direction
@@ -288,5 +335,5 @@ void textarea_set_layout(struct textarea *ta, int width, int height,
* \return true iff the textarea was scrolled
*/
bool textarea_scroll(struct textarea *ta, int scrx, int scry);
-#endif
+#endif
diff --git a/desktop/textinput.h b/desktop/textinput.h
index 5859ea8..7c6be95 100644
--- a/desktop/textinput.h
+++ b/desktop/textinput.h
@@ -24,19 +24,19 @@
* Textual input handling interface
*/
-#ifndef _NETSURF_DESKTOP_TEXTINPUT_H_
-#define _NETSURF_DESKTOP_TEXTINPUT_H_
+#ifndef NETSURF_DESKTOP_TEXTINPUT_H
+#define NETSURF_DESKTOP_TEXTINPUT_H
struct browser_window;
/**
* Position the caret and assign a callback for key presses.
*
- * \param bw The browser window in which to place the caret
- * \param x X coordinate of the caret
- * \param y Y coordinate
- * \param height Height of caret
- * \param clip Clip rectangle for caret, or NULL if none
+ * \param bw The browser window in which to place the caret
+ * \param x X coordinate of the caret
+ * \param y Y coordinate
+ * \param height Height of caret
+ * \param clip Clip rectangle for caret, or NULL if none
*/
void browser_window_place_caret(struct browser_window *bw, int x, int y,
int height, const struct rect *clip);
diff --git a/desktop/treeview.c b/desktop/treeview.c
index c0d685e..ff13fb0 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1858,7 +1858,7 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
res = treeview_node_contract_internal(tree, node);
if (res == NSERROR_OK) {
- /* sucessful contraction, request redraw */
+ /* successful contraction, request redraw */
r.x0 = 0;
r.y0 = treeview_node_y(tree, node);
r.x1 = REDRAW_MAX;
@@ -1933,7 +1933,7 @@ struct treeview_expand_data {
* \param ctx node expansion context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_expand_cb(treeview_node *n,
@@ -1978,7 +1978,7 @@ nserror treeview_expand(treeview *tree, bool only_folders)
treeview_expand_cb,
&data);
if (res == NSERROR_OK) {
- /* expansion suceeded, schedule redraw */
+ /* expansion succeeded, schedule redraw */
r.x0 = 0;
r.y0 = 0;
@@ -2212,7 +2212,7 @@ treeview_redraw(treeview *tree,
render_y += tree_g.line_height;
}
- /* Finshed rendering expanded entry */
+ /* Finished rendering expanded entry */
if (render_y > r.y1) {
/* Passed the bottom of what's in the clip region.
@@ -2303,7 +2303,7 @@ struct treeview_selection_walk_data {
* \param ctx node selection context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_node_selection_walk_cb(treeview_node *n,
@@ -2718,7 +2718,7 @@ static bool treeview_propagate_selection(treeview *tree, struct rect *rect)
*
* \param tree Treeview object to move selected nodes in
* \param rect Redraw rectangle
- * \return NSERROR_OK on sucess else appropriate error code
+ * \return NSERROR_OK on success else appropriate error code
*/
static nserror treeview_move_selection(treeview *tree, struct rect *rect)
{
@@ -2850,7 +2850,7 @@ treeview_node_launch_walk_bwd_cb(treeview_node *n, void *ctx, bool *end)
* \param ctx node launch context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_node_launch_walk_fwd_cb(treeview_node *n,
@@ -2967,11 +2967,11 @@ struct treeview_nav_state {
/**
* Treewalk node callback for handling mouse action.
*
- * \param n current node
+ * \param node current node
* \param ctx node context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_node_nav_cb(treeview_node *node,
@@ -3227,7 +3227,7 @@ treeview_set_move_indicator(treeview *tree,
target = target->parent;
}
- /* Find top ajdacent selected sibling */
+ /* Find top adjacent selected sibling */
while (target->prev_sib &&
target->prev_sib->flags & TV_NFLAGS_SELECTED) {
target = target->prev_sib;
@@ -3555,11 +3555,11 @@ struct treeview_mouse_action {
/**
* Treewalk node callback for handling mouse action.
*
- * \param n current node
+ * \param node current node
* \param ctx node context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_node_mouse_action_cb(treeview_node *node,
@@ -3988,46 +3988,67 @@ int treeview_get_height(treeview *tree)
* Initialise the plot styles from CSS system colour values.
*
* \param font_pt_size font size to use
+ * \return NSERROR_OK on success else appropriate error code
*/
-static void treeview_init_plot_styles(int font_pt_size)
+static nserror treeview_init_plot_styles(int font_pt_size)
{
+ nserror res;
+
/* Background colour */
plot_style_even.bg.stroke_type = PLOT_OP_TYPE_NONE;
plot_style_even.bg.stroke_width = 0;
plot_style_even.bg.stroke_colour = 0;
plot_style_even.bg.fill_type = PLOT_OP_TYPE_SOLID;
- plot_style_even.bg.fill_colour = ns_system_colour_char("Window");
+ res = ns_system_colour_char("Window", &plot_style_even.bg.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* Text colour */
plot_style_even.text.family = PLOT_FONT_FAMILY_SANS_SERIF;
plot_style_even.text.size = font_pt_size;
plot_style_even.text.weight = 400;
plot_style_even.text.flags = FONTF_NONE;
- plot_style_even.text.foreground = ns_system_colour_char("WindowText");
- plot_style_even.text.background = ns_system_colour_char("Window");
+ res = ns_system_colour_char("WindowText", &plot_style_even.text.foreground);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+ res = ns_system_colour_char("Window", &plot_style_even.text.background);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* Entry field text colour */
plot_style_even.itext = plot_style_even.text;
plot_style_even.itext.foreground = mix_colour(
plot_style_even.text.foreground,
- plot_style_even.text.background, 255 * 10 / 16);
+ plot_style_even.text.background,
+ 255 * 10 / 16);
/* Selected background colour */
plot_style_even.sbg = plot_style_even.bg;
- plot_style_even.sbg.fill_colour = ns_system_colour_char("Highlight");
+ res = ns_system_colour_char("Highlight", &plot_style_even.sbg.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* Selected text colour */
plot_style_even.stext = plot_style_even.text;
- plot_style_even.stext.foreground =
- ns_system_colour_char("HighlightText");
- plot_style_even.stext.background = ns_system_colour_char("Highlight");
+ res = ns_system_colour_char("HighlightText", &plot_style_even.stext.foreground);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+ res = ns_system_colour_char("Highlight", &plot_style_even.stext.background);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* Selected entry field text colour */
plot_style_even.sitext = plot_style_even.stext;
plot_style_even.sitext.foreground = mix_colour(
plot_style_even.stext.foreground,
- plot_style_even.stext.background, 255 * 25 / 32);
-
+ plot_style_even.stext.background,
+ 255 * 25 / 32);
/* Odd numbered node styles */
plot_style_odd.bg = plot_style_even.bg;
@@ -4044,14 +4065,16 @@ static void treeview_init_plot_styles(int font_pt_size)
plot_style_odd.sbg = plot_style_even.sbg;
plot_style_odd.stext = plot_style_even.stext;
plot_style_odd.sitext = plot_style_even.sitext;
+
+ return NSERROR_OK;
}
/**
- * Callback for hlcache retreving resources.
+ * Callback for hlcache retrieving resources.
*
* \param handle content hlcache handle
- * \param event The event that occoured on the content
+ * \param event The event that occurred on the content
* \param pw treeview resource context
*/
static nserror
@@ -4373,7 +4396,7 @@ nserror treeview_init(void)
{
long long font_px_size;
long long font_pt_size;
- nserror err;
+ nserror res;
if (tree_g.initialised > 0) {
tree_g.initialised++;
@@ -4391,11 +4414,17 @@ nserror treeview_init(void)
10 + 36) / 72;
tree_g.line_height = (font_px_size * 8 + 3) / 6;
- treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
+ res = treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
treeview_init_resources();
- err = treeview_init_furniture();
- if (err != NSERROR_OK)
- return err;
+
+ res = treeview_init_furniture();
+ if (res != NSERROR_OK) {
+ return res;
+ }
tree_g.step_width = tree_g.furniture_width;
tree_g.window_padding = 6;
diff --git a/desktop/treeview.h b/desktop/treeview.h
index 0dbde11..45469b7 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -228,7 +228,7 @@ nserror treeview_destroy(treeview *tree);
/**
- * Find a releation for node creation.
+ * Find a relation for node creation.
*
* If at_y is set, we find a relation that will put the created node at that
* position.
@@ -239,7 +239,7 @@ nserror treeview_destroy(treeview *tree);
* \param tree Treeview object in which to create folder
* \param relation Existing node to insert as relation of, or NULL
* \param rel Folder's relationship to relation
- * \param at_y Iff true, insert at y-offest
+ * \param at_y Iff true, insert at y-offset
* \param y Y-offset in px from top of hotlist. Ignored if (!at_y).
* \return NSERROR_OK on success, appropriate error otherwise
*/
-----------------------------------------------------------------------
Summary of changes:
desktop/browser_history.c | 16 ++++-
desktop/scrollbar.c | 40 +++++++-----
desktop/system_colour.c | 23 ++++---
desktop/system_colour.h | 46 ++++++++++++--
desktop/textarea.h | 153 +++++++++++++++++++++++++++++----------------
desktop/textinput.h | 14 ++---
desktop/treeview.c | 89 +++++++++++++++++---------
desktop/treeview.h | 4 +-
8 files changed, 261 insertions(+), 124 deletions(-)
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 10154b7..cf70c47 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -478,17 +478,27 @@ static bool browser_window_history__enumerate_entry(
/* exported interface documented in desktop/browser_history.h */
nserror browser_window_history_create(struct browser_window *bw)
{
+ nserror res;
struct history *history;
- pstyle_bg.fill_colour = ns_system_colour_char("Window");
+ res = ns_system_colour_char("Window", &pstyle_bg.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
pfstyle_node.background = pstyle_bg.fill_colour;
pfstyle_node_sel.background = pstyle_bg.fill_colour;
- pstyle_line.stroke_colour = ns_system_colour_char("GrayText");
+ res = ns_system_colour_char("GrayText", &pstyle_line.stroke_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
pstyle_rect.stroke_colour = pstyle_line.stroke_colour;
pfstyle_node.foreground = pstyle_line.stroke_colour;
- pstyle_rect_sel.stroke_colour = ns_system_colour_char("Highlight");
+ res = ns_system_colour_char("Highlight", &pstyle_rect_sel.stroke_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour;
bw->history = NULL;
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 4f30434..0432696 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -228,23 +228,31 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
struct rect rect;
nserror res;
- colour bg_fill_colour = ns_system_colour_char("Scrollbar");
- colour fg_fill_colour = ns_system_colour_char("ButtonFace");
- colour arrow_fill_colour = ns_system_colour_char("ButtonText");
-
plot_style_t bg_fill_style = {
.fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = bg_fill_colour
};
plot_style_t fg_fill_style = {
.fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = fg_fill_colour
};
plot_style_t arrow_fill_style = {
.fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = arrow_fill_colour
};
+ res = ns_system_colour_char("Scrollbar", &bg_fill_style.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ res = ns_system_colour_char("ButtonFace", &fg_fill_style.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ res = ns_system_colour_char("ButtonText", &arrow_fill_style.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
area.x0 = x;
area.y0 = y;
area.x1 = x + (s->horizontal ? s->length : SCROLLBAR_WIDTH) - 1;
@@ -277,7 +285,8 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
/* scrollbar is horizontal */
/* scrollbar outline */
- res = scrollbar_rectangle(ctx, &area, bg_fill_colour, true);
+ res = scrollbar_rectangle(ctx, &area,
+ bg_fill_style.fill_colour, true);
if (res != NSERROR_OK) {
return false;
}
@@ -287,7 +296,8 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x0 + w - 2;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect,
+ fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -329,7 +339,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = bar_c1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -348,7 +358,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x1 - 1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -378,7 +388,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
/* scrollbar is vertical */
/* outline */
- res = scrollbar_rectangle(ctx, &area, bg_fill_colour, true);
+ res = scrollbar_rectangle(ctx, &area, bg_fill_style.fill_colour, true);
if (res != NSERROR_OK) {
return false;
}
@@ -388,7 +398,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y0 + 1;
rect.x1 = area.x1 - 1;
rect.y1 = area.y0 + w - 2;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -430,7 +440,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = bar_c0;
rect.x1 = area.x1 - 1;
rect.y1 = bar_c1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
@@ -449,7 +459,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
rect.y0 = area.y1 - w + 2;
rect.x1 = area.x1 - 1;
rect.y1 = area.y1 - 1;
- res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
+ res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
if (res != NSERROR_OK) {
return false;
}
diff --git a/desktop/system_colour.c b/desktop/system_colour.c
index f33b57a..42a51ea 100644
--- a/desktop/system_colour.c
+++ b/desktop/system_colour.c
@@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * System colour handling
- *
+/**
+ * \file
+ * System colour handling implementation.
*/
#include <string.h>
@@ -38,6 +38,7 @@ static lwc_string *colour_list[colour_list_len];
static lwc_string **ns_system_colour_pw = NULL;
+/* exported interface documented in desktop/system_colour.h */
nserror ns_system_colour_init(void)
{
unsigned int ccount;
@@ -61,6 +62,8 @@ nserror ns_system_colour_init(void)
return NSERROR_OK;
}
+
+/* exported interface documented in desktop/system_colour.h */
void ns_system_colour_finalize(void)
{
unsigned int ccount;
@@ -70,21 +73,25 @@ void ns_system_colour_finalize(void)
}
}
-colour ns_system_colour_char(const char *name)
+
+/* exported interface documented in desktop/system_colour.h */
+nserror ns_system_colour_char(const char *name, colour *colour_out)
{
- colour ret = 0;
unsigned int ccount;
for (ccount = 0; ccount < colour_list_len; ccount++) {
if (strcmp(name,
nsoptions[ccount + NSOPTION_SYS_COLOUR_START].key + SLEN("sys_colour_")) == 0) {
- ret = nsoptions[ccount + NSOPTION_SYS_COLOUR_START].value.c;
- break;
+ *colour_out = nsoptions[ccount + NSOPTION_SYS_COLOUR_START].value.c;
+ return NSERROR_OK;
}
}
- return ret;
+
+ return NSERROR_INVALID;
}
+
+/* exported interface documented in desktop/system_colour.h */
css_error ns_system_colour(void *pw, lwc_string *name, css_color *colour)
{
unsigned int ccount;
diff --git a/desktop/system_colour.h b/desktop/system_colour.h
index 8e82818..0b75530 100644
--- a/desktop/system_colour.h
+++ b/desktop/system_colour.h
@@ -16,25 +16,59 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
+/**
+ * \file
* Interface to system colour values.
+ *
+ * Netsurf has a list of user configurable colours with frontend
+ * specific defaults. These colours are used for the css system
+ * colours and to colour and style internally rendered widgets
+ * (e.g. cookies treeview or local file directory views.
*/
-#ifndef _NETSURF_DESKTOP_SYSTEM_COLOUR_H_
-#define _NETSURF_DESKTOP_SYSTEM_COLOUR_H_
+#ifndef NETSURF_DESKTOP_SYSTEM_COLOUR_H
+#define NETSURF_DESKTOP_SYSTEM_COLOUR_H
#include <libcss/libcss.h>
#include "utils/errors.h"
#include "netsurf/types.h"
-/** css callback to obtain named system colours. */
+/**
+ * css callback to obtain named system colour.
+ *
+ * \param[in] pw context unused in implementation
+ * \param[in] name The name of the colour being looked up
+ * \param[out] color The system colour associated with the name.
+ * \return CSS_OK and \a color updated on success else CSS_INVALID if
+ * the \a name is unrecognised
+ */
css_error ns_system_colour(void *pw, lwc_string *name, css_color *color);
-/** Obtain a named system colour from a frontend. */
-colour ns_system_colour_char(const char *name);
+/**
+ * Obtain a system colour from a name.
+ *
+ * \param[in] name The name of the colour being looked up
+ * \param[out] color The system colour associated with the name in the
+ * netsurf colour representation.
+ * \return NSERROR_OK and \a color updated on success else appropriate
+ * error code.
+ */
+nserror ns_system_colour_char(const char *name, colour *color);
+
+
+/**
+ * Initialise the system colours
+ *
+ * \return NSERROR_OK on success else appropriate error code.
+ */
nserror ns_system_colour_init(void);
+
+
+/**
+ * release any resources associated with the system colours.
+ */
void ns_system_colour_finalize(void);
#endif
diff --git a/desktop/textarea.h b/desktop/textarea.h
index 65e2594..8986097 100644
--- a/desktop/textarea.h
+++ b/desktop/textarea.h
@@ -1,6 +1,6 @@
/*
* Copyright 2006 John-Mark Bell <jmb(a)netsurf-browser.org>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
+ * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -17,12 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Single/Multi-line UTF-8 text area (interface)
+/**
+ * \file
+ * Single/Multi-line UTF-8 text area interface
*/
-#ifndef _NETSURF_DESKTOP_TEXTAREA_H_
-#define _NETSURF_DESKTOP_TEXTAREA_H_
+#ifndef NETSURF_DESKTOP_TEXTAREA_H
+#define NETSURF_DESKTOP_TEXTAREA_H
#include <stdint.h>
#include <stdbool.h>
@@ -33,21 +34,31 @@
struct textarea;
struct redraw_context;
-/* Text area flags */
+/**
+ * Text area flags
+ */
typedef enum {
- TEXTAREA_DEFAULT = (1 << 0), /**< Standard input */
- TEXTAREA_MULTILINE = (1 << 1), /**< Multiline area */
- TEXTAREA_READONLY = (1 << 2), /**< Non-editable */
- TEXTAREA_INTERNAL_CARET = (1 << 3), /**< Render own caret */
- TEXTAREA_PASSWORD = (1 << 4) /**< Obscured display */
+ TEXTAREA_DEFAULT = (1 << 0), /**< Standard input */
+ TEXTAREA_MULTILINE = (1 << 1), /**< Multiline area */
+ TEXTAREA_READONLY = (1 << 2), /**< Non-editable */
+ TEXTAREA_INTERNAL_CARET = (1 << 3), /**< Render own caret */
+ TEXTAREA_PASSWORD = (1 << 4) /**< Obscured display */
} textarea_flags;
+
+/**
+ * Textarea drag status
+ */
typedef enum {
TEXTAREA_DRAG_NONE,
TEXTAREA_DRAG_SCROLLBAR,
TEXTAREA_DRAG_SELECTION
-} textarea_drag_type; /**< Textarea drag status */
+} textarea_drag_type;
+
+/**
+ * textarea message types
+ */
typedef enum {
TEXTAREA_MSG_DRAG_REPORT, /**< Textarea drag start/end report */
TEXTAREA_MSG_SELECTION_REPORT, /**< Textarea text selection presence */
@@ -56,6 +67,10 @@ typedef enum {
TEXTAREA_MSG_TEXT_MODIFIED /**< Textarea text modified */
} textarea_msg_type;
+
+/**
+ * textarea message
+ */
struct textarea_msg {
struct textarea *ta; /**< The textarea widget */
@@ -73,10 +88,10 @@ struct textarea_msg {
TEXTAREA_CARET_HIDE /**< Hide */
} type;
struct {
- int x; /**< Carret x-coord */
- int y; /**< Carret y-coord */
- int height; /**< Carret height */
- struct rect *clip; /**< Carret clip rect */
+ int x; /**< Caret x-coord */
+ int y; /**< Caret y-coord */
+ int height; /**< Caret height */
+ struct rect *clip; /**< Caret clip rect */
} pos; /**< With _CARET_SET_POS */
} caret; /**< With _CARET_UPDATE */
struct {
@@ -86,6 +101,10 @@ struct textarea_msg {
} data; /**< Depends on msg type */
};
+
+/**
+ * textarea setup parameters
+ */
typedef struct textarea_setup {
int width; /**< Textarea width */
int height; /**< Textarea height */
@@ -104,14 +123,39 @@ typedef struct textarea_setup {
} textarea_setup;
+
+/**
+ * Text area mouse input status flags
+ */
+typedef enum {
+ TEXTAREA_MOUSE_NONE = 0, /**< Not relevant */
+ TEXTAREA_MOUSE_USED = (1 << 0), /**< Took action with input */
+ TEXTAREA_MOUSE_EDITOR = (1 << 1), /**< Hover: caret pointer */
+ TEXTAREA_MOUSE_SELECTION= (1 << 2), /**< Hover: selection */
+ TEXTAREA_MOUSE_SCR_USED = (1 << 3), /**< Scrollbar action */
+ TEXTAREA_MOUSE_SCR_BOTH = (1 << 4), /**< Scrolling both bars */
+ TEXTAREA_MOUSE_SCR_UP = (1 << 5), /**< Hover: scroll up */
+ TEXTAREA_MOUSE_SCR_PUP = (1 << 6), /**< Hover: scroll page up */
+ TEXTAREA_MOUSE_SCR_VRT = (1 << 7), /**< Hover: vert. drag bar */
+ TEXTAREA_MOUSE_SCR_PDWN = (1 << 8), /**< Hover: scroll page down */
+ TEXTAREA_MOUSE_SCR_DWN = (1 << 9), /**< Hover: scroll down */
+ TEXTAREA_MOUSE_SCR_LFT = (1 << 10), /**< Hover: scroll left */
+ TEXTAREA_MOUSE_SCR_PLFT = (1 << 11), /**< Hover: scroll page left */
+ TEXTAREA_MOUSE_SCR_HRZ = (1 << 12), /**< Hover: horiz. drag bar */
+ TEXTAREA_MOUSE_SCR_PRGT = (1 << 13), /**< Hover: scroll page right */
+ TEXTAREA_MOUSE_SCR_RGT = (1 << 14) /**< Hover: scroll right */
+} textarea_mouse_status;
+
+
/**
* Client callback for the textarea
*
- * \param data user data passed at textarea creation
- * \param textarea_msg textarea message data
+ * \param data user data passed at textarea creation
+ * \param msg textarea message data
*/
typedef void(*textarea_client_callback)(void *data, struct textarea_msg *msg);
+
/**
* Create a text area.
*
@@ -125,6 +169,7 @@ struct textarea *textarea_create(const textarea_flags flags,
const textarea_setup *setup,
textarea_client_callback callback, void *data);
+
/**
* Destroy a text area
*
@@ -132,6 +177,7 @@ struct textarea *textarea_create(const textarea_flags flags,
*/
void textarea_destroy(struct textarea *ta);
+
/**
* Set the text in a text area, discarding any current text
*
@@ -141,6 +187,7 @@ void textarea_destroy(struct textarea *ta);
*/
bool textarea_set_text(struct textarea *ta, const char *text);
+
/**
* Insert the text in a text area at the caret, replacing any selection.
*
@@ -152,6 +199,7 @@ bool textarea_set_text(struct textarea *ta, const char *text);
bool textarea_drop_text(struct textarea *ta, const char *text,
size_t text_length);
+
/**
* Extract the text from a text area
*
@@ -163,16 +211,18 @@ bool textarea_drop_text(struct textarea *ta, const char *text,
*/
int textarea_get_text(struct textarea *ta, char *buf, unsigned int len);
+
/**
* Set the caret's position
*
- * \param ta Text area
- * \param caret 0-based character index to place caret at, -1 removes
- * the caret
+ * \param ta Text area
+ * \param caret 0-based character index to place caret at, -1 removes
+ * the caret
* \return true on success false otherwise
*/
bool textarea_set_caret(struct textarea *ta, int caret);
+
/**
* Handle redraw requests for text areas
*
@@ -187,34 +237,16 @@ bool textarea_set_caret(struct textarea *ta, int caret);
void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
const struct rect *clip, const struct redraw_context *ctx);
+
/**
* Key press handling for text areas.
*
* \param ta The text area which got the keypress
* \param key The ucs4 character codepoint
- * \return true if the keypress is dealt with, false otherwise.
+ * \return true if the keypress is dealt with, false otherwise.
*/
bool textarea_keypress(struct textarea *ta, uint32_t key);
-/* Text area mouse input status flags */
-typedef enum {
- TEXTAREA_MOUSE_NONE = 0, /**< Not relevant */
- TEXTAREA_MOUSE_USED = (1 << 0), /**< Took action with input */
- TEXTAREA_MOUSE_EDITOR = (1 << 1), /**< Hover: caret pointer */
- TEXTAREA_MOUSE_SELECTION= (1 << 2), /**< Hover: selection */
- TEXTAREA_MOUSE_SCR_USED = (1 << 3), /**< Scrollbar action */
- TEXTAREA_MOUSE_SCR_BOTH = (1 << 4), /**< Scrolling both bars */
- TEXTAREA_MOUSE_SCR_UP = (1 << 5), /**< Hover: scroll up */
- TEXTAREA_MOUSE_SCR_PUP = (1 << 6), /**< Hover: scroll page up */
- TEXTAREA_MOUSE_SCR_VRT = (1 << 7), /**< Hover: vert. drag bar */
- TEXTAREA_MOUSE_SCR_PDWN = (1 << 8), /**< Hover: scroll page down */
- TEXTAREA_MOUSE_SCR_DWN = (1 << 9), /**< Hover: scroll down */
- TEXTAREA_MOUSE_SCR_LFT = (1 << 10), /**< Hover: scroll left */
- TEXTAREA_MOUSE_SCR_PLFT = (1 << 11), /**< Hover: scroll page left */
- TEXTAREA_MOUSE_SCR_HRZ = (1 << 12), /**< Hover: horiz. drag bar */
- TEXTAREA_MOUSE_SCR_PRGT = (1 << 13), /**< Hover: scroll page right */
- TEXTAREA_MOUSE_SCR_RGT = (1 << 14) /**< Hover: scroll right */
-} textarea_mouse_status;
/**
* Handles all kinds of mouse action
@@ -228,22 +260,28 @@ typedef enum {
textarea_mouse_status textarea_mouse_action(struct textarea *ta,
browser_mouse_state mouse, int x, int y);
+
/**
* Clear any selection in the textarea.
*
- * \param ta textarea widget
+ * \param ta textarea widget
* \return true if there was a selection to clear, false otherwise
*/
bool textarea_clear_selection(struct textarea *ta);
+
/**
- * Get selected text, ownership passed to caller, which needs to free() it.
+ * Get selected text.
+ *
+ * ownership of the returned string is passed to caller which needs to
+ * free it.
*
- * \param ta Textarea widget
+ * \param ta Textarea widget
* \return Selected text, or NULL if none.
*/
char *textarea_get_selection(struct textarea *ta);
+
/**
* Gets the dimensions of a textarea
*
@@ -253,22 +291,28 @@ char *textarea_get_selection(struct textarea *ta);
*/
void textarea_get_dimensions(struct textarea *ta, int *width, int *height);
+
/**
- * Set the dimensions of a textarea, causing a reflow and
- * Does not emit a redraw request. Up to client to call textarea_redraw.
+ * Set the dimensions of a textarea.
+ *
+ * This causes a reflow of the text and does not emit a redraw
+ * request. Up to client to call textarea_redraw.
*
* \param ta textarea widget
- * \param width the new width of the textarea
+ * \param width the new width of the textarea
* \param height the new height of the textarea
*/
void textarea_set_dimensions(struct textarea *ta, int width, int height);
+
/**
- * Set the dimensions and padding of a textarea, causing a reflow.
- * Does not emit a redraw request. Up to client to call textarea_redraw.
+ * Set the dimensions and padding of a textarea.
+ *
+ * This causes a reflow of the text. Does not emit a redraw request.
+ * Up to client to call textarea_redraw.
*
* \param ta textarea widget
- * \param width the new width of the textarea
+ * \param width the new width of the textarea
* \param height the new height of the textarea
* \param top the new top padding of the textarea
* \param right the new right padding of the textarea
@@ -278,9 +322,12 @@ void textarea_set_dimensions(struct textarea *ta, int width, int height);
void textarea_set_layout(struct textarea *ta, int width, int height,
int top, int right, int bottom, int left);
+
/**
- * Scroll a textarea by an amount. Only does anything if multi-line textarea
- * has scrollbars. If it scrolls, it will emit a redraw request.
+ * Scroll a textarea by an amount.
+ *
+ * Only does anything if multi-line textarea has scrollbars. If it
+ * scrolls, it will emit a redraw request.
*
* \param ta textarea widget
* \param scrx number of px try to scroll in x direction
@@ -288,5 +335,5 @@ void textarea_set_layout(struct textarea *ta, int width, int height,
* \return true iff the textarea was scrolled
*/
bool textarea_scroll(struct textarea *ta, int scrx, int scry);
-#endif
+#endif
diff --git a/desktop/textinput.h b/desktop/textinput.h
index 5859ea8..7c6be95 100644
--- a/desktop/textinput.h
+++ b/desktop/textinput.h
@@ -24,19 +24,19 @@
* Textual input handling interface
*/
-#ifndef _NETSURF_DESKTOP_TEXTINPUT_H_
-#define _NETSURF_DESKTOP_TEXTINPUT_H_
+#ifndef NETSURF_DESKTOP_TEXTINPUT_H
+#define NETSURF_DESKTOP_TEXTINPUT_H
struct browser_window;
/**
* Position the caret and assign a callback for key presses.
*
- * \param bw The browser window in which to place the caret
- * \param x X coordinate of the caret
- * \param y Y coordinate
- * \param height Height of caret
- * \param clip Clip rectangle for caret, or NULL if none
+ * \param bw The browser window in which to place the caret
+ * \param x X coordinate of the caret
+ * \param y Y coordinate
+ * \param height Height of caret
+ * \param clip Clip rectangle for caret, or NULL if none
*/
void browser_window_place_caret(struct browser_window *bw, int x, int y,
int height, const struct rect *clip);
diff --git a/desktop/treeview.c b/desktop/treeview.c
index c0d685e..ff13fb0 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1858,7 +1858,7 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
res = treeview_node_contract_internal(tree, node);
if (res == NSERROR_OK) {
- /* sucessful contraction, request redraw */
+ /* successful contraction, request redraw */
r.x0 = 0;
r.y0 = treeview_node_y(tree, node);
r.x1 = REDRAW_MAX;
@@ -1933,7 +1933,7 @@ struct treeview_expand_data {
* \param ctx node expansion context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_expand_cb(treeview_node *n,
@@ -1978,7 +1978,7 @@ nserror treeview_expand(treeview *tree, bool only_folders)
treeview_expand_cb,
&data);
if (res == NSERROR_OK) {
- /* expansion suceeded, schedule redraw */
+ /* expansion succeeded, schedule redraw */
r.x0 = 0;
r.y0 = 0;
@@ -2212,7 +2212,7 @@ treeview_redraw(treeview *tree,
render_y += tree_g.line_height;
}
- /* Finshed rendering expanded entry */
+ /* Finished rendering expanded entry */
if (render_y > r.y1) {
/* Passed the bottom of what's in the clip region.
@@ -2303,7 +2303,7 @@ struct treeview_selection_walk_data {
* \param ctx node selection context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_node_selection_walk_cb(treeview_node *n,
@@ -2718,7 +2718,7 @@ static bool treeview_propagate_selection(treeview *tree, struct rect *rect)
*
* \param tree Treeview object to move selected nodes in
* \param rect Redraw rectangle
- * \return NSERROR_OK on sucess else appropriate error code
+ * \return NSERROR_OK on success else appropriate error code
*/
static nserror treeview_move_selection(treeview *tree, struct rect *rect)
{
@@ -2850,7 +2850,7 @@ treeview_node_launch_walk_bwd_cb(treeview_node *n, void *ctx, bool *end)
* \param ctx node launch context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_node_launch_walk_fwd_cb(treeview_node *n,
@@ -2967,11 +2967,11 @@ struct treeview_nav_state {
/**
* Treewalk node callback for handling mouse action.
*
- * \param n current node
+ * \param node current node
* \param ctx node context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_node_nav_cb(treeview_node *node,
@@ -3227,7 +3227,7 @@ treeview_set_move_indicator(treeview *tree,
target = target->parent;
}
- /* Find top ajdacent selected sibling */
+ /* Find top adjacent selected sibling */
while (target->prev_sib &&
target->prev_sib->flags & TV_NFLAGS_SELECTED) {
target = target->prev_sib;
@@ -3555,11 +3555,11 @@ struct treeview_mouse_action {
/**
* Treewalk node callback for handling mouse action.
*
- * \param n current node
+ * \param node current node
* \param ctx node context
* \param skip_children flag to allow children to be skipped
* \param end flag to allow iteration to be finished early.
- * \return NSERROR_OK on sucess else error code.
+ * \return NSERROR_OK on success else error code.
*/
static nserror
treeview_node_mouse_action_cb(treeview_node *node,
@@ -3988,46 +3988,67 @@ int treeview_get_height(treeview *tree)
* Initialise the plot styles from CSS system colour values.
*
* \param font_pt_size font size to use
+ * \return NSERROR_OK on success else appropriate error code
*/
-static void treeview_init_plot_styles(int font_pt_size)
+static nserror treeview_init_plot_styles(int font_pt_size)
{
+ nserror res;
+
/* Background colour */
plot_style_even.bg.stroke_type = PLOT_OP_TYPE_NONE;
plot_style_even.bg.stroke_width = 0;
plot_style_even.bg.stroke_colour = 0;
plot_style_even.bg.fill_type = PLOT_OP_TYPE_SOLID;
- plot_style_even.bg.fill_colour = ns_system_colour_char("Window");
+ res = ns_system_colour_char("Window", &plot_style_even.bg.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* Text colour */
plot_style_even.text.family = PLOT_FONT_FAMILY_SANS_SERIF;
plot_style_even.text.size = font_pt_size;
plot_style_even.text.weight = 400;
plot_style_even.text.flags = FONTF_NONE;
- plot_style_even.text.foreground = ns_system_colour_char("WindowText");
- plot_style_even.text.background = ns_system_colour_char("Window");
+ res = ns_system_colour_char("WindowText", &plot_style_even.text.foreground);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+ res = ns_system_colour_char("Window", &plot_style_even.text.background);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* Entry field text colour */
plot_style_even.itext = plot_style_even.text;
plot_style_even.itext.foreground = mix_colour(
plot_style_even.text.foreground,
- plot_style_even.text.background, 255 * 10 / 16);
+ plot_style_even.text.background,
+ 255 * 10 / 16);
/* Selected background colour */
plot_style_even.sbg = plot_style_even.bg;
- plot_style_even.sbg.fill_colour = ns_system_colour_char("Highlight");
+ res = ns_system_colour_char("Highlight", &plot_style_even.sbg.fill_colour);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* Selected text colour */
plot_style_even.stext = plot_style_even.text;
- plot_style_even.stext.foreground =
- ns_system_colour_char("HighlightText");
- plot_style_even.stext.background = ns_system_colour_char("Highlight");
+ res = ns_system_colour_char("HighlightText", &plot_style_even.stext.foreground);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+ res = ns_system_colour_char("Highlight", &plot_style_even.stext.background);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* Selected entry field text colour */
plot_style_even.sitext = plot_style_even.stext;
plot_style_even.sitext.foreground = mix_colour(
plot_style_even.stext.foreground,
- plot_style_even.stext.background, 255 * 25 / 32);
-
+ plot_style_even.stext.background,
+ 255 * 25 / 32);
/* Odd numbered node styles */
plot_style_odd.bg = plot_style_even.bg;
@@ -4044,14 +4065,16 @@ static void treeview_init_plot_styles(int font_pt_size)
plot_style_odd.sbg = plot_style_even.sbg;
plot_style_odd.stext = plot_style_even.stext;
plot_style_odd.sitext = plot_style_even.sitext;
+
+ return NSERROR_OK;
}
/**
- * Callback for hlcache retreving resources.
+ * Callback for hlcache retrieving resources.
*
* \param handle content hlcache handle
- * \param event The event that occoured on the content
+ * \param event The event that occurred on the content
* \param pw treeview resource context
*/
static nserror
@@ -4373,7 +4396,7 @@ nserror treeview_init(void)
{
long long font_px_size;
long long font_pt_size;
- nserror err;
+ nserror res;
if (tree_g.initialised > 0) {
tree_g.initialised++;
@@ -4391,11 +4414,17 @@ nserror treeview_init(void)
10 + 36) / 72;
tree_g.line_height = (font_px_size * 8 + 3) / 6;
- treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
+ res = treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
treeview_init_resources();
- err = treeview_init_furniture();
- if (err != NSERROR_OK)
- return err;
+
+ res = treeview_init_furniture();
+ if (res != NSERROR_OK) {
+ return res;
+ }
tree_g.step_width = tree_g.furniture_width;
tree_g.window_padding = 6;
diff --git a/desktop/treeview.h b/desktop/treeview.h
index 0dbde11..45469b7 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -228,7 +228,7 @@ nserror treeview_destroy(treeview *tree);
/**
- * Find a releation for node creation.
+ * Find a relation for node creation.
*
* If at_y is set, we find a relation that will put the created node at that
* position.
@@ -239,7 +239,7 @@ nserror treeview_destroy(treeview *tree);
* \param tree Treeview object in which to create folder
* \param relation Existing node to insert as relation of, or NULL
* \param rel Folder's relationship to relation
- * \param at_y Iff true, insert at y-offest
+ * \param at_y Iff true, insert at y-offset
* \param y Y-offset in px from top of hotlist. Ignored if (!at_y).
* \return NSERROR_OK on success, appropriate error otherwise
*/
--
NetSurf Browser
5 years, 11 months