netsurf: branch mmu_man/xf86keys created. 6167b8862d25178fb6fec5f4b9848da758753ee6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6167b8862d25178fb6fec...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6167b8862d25178fb6fec5f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6167b8862d25178fb6fec5f4b...
The branch, mmu_man/xf86keys has been created
at 6167b8862d25178fb6fec5f4b9848da758753ee6 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/6167b8862d25178fb6f...
commit 6167b8862d25178fb6fec5f4b9848da758753ee6
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
gtk: Handle Back and Forward keys
Those extra keys are available on some keyboards, like on thinkpads.
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 91288a2..687ade8 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -313,7 +313,7 @@ void nsgtk_scaffolding_destroy(nsgtk_scaffolding *g)
/**
* Update the back and forward button sensitivity.
*/
-static void nsgtk_window_update_back_forward(struct gtk_scaffolding *g)
+void nsgtk_window_update_back_forward(struct gtk_scaffolding *g)
{
int width, height;
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
diff --git a/gtk/scaffolding.h b/gtk/scaffolding.h
index cf75f0a..0781584 100644
--- a/gtk/scaffolding.h
+++ b/gtk/scaffolding.h
@@ -144,6 +144,7 @@ void nsgtk_scaffolding_set_top_level(struct gui_window *g);
void nsgtk_scaffolding_destroy(nsgtk_scaffolding *g);
+void nsgtk_window_update_back_forward(struct gtk_scaffolding *g);
void nsgtk_scaffolding_set_sensitivity(struct gtk_scaffolding *g);
void nsgtk_scaffolding_initial_sensitivity(struct gtk_scaffolding *g);
void nsgtk_scaffolding_popup_menu(struct gtk_scaffolding *g, gdouble x,
diff --git a/gtk/window.c b/gtk/window.c
index 8a3a085..42344e6 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -29,6 +29,7 @@
#include "content/hlcache.h"
#include "gtk/window.h"
#include "desktop/browser_private.h"
+#include "desktop/history_core.h"
#include "desktop/mouse.h"
#include "desktop/options.h"
#include "desktop/searchweb.h"
@@ -37,6 +38,7 @@
#include "gtk/compat.h"
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
+#include "gtk/search.h"
#include "gtk/plotters.h"
#include "gtk/schedule.h"
#include "gtk/tabs.h"
@@ -579,6 +581,32 @@ static gboolean nsgtk_window_keypress_event(GtkWidget *widget,
gtk_adjustment_set_value(vscroll, value);
break;
+ case GDK_KEY(Forward):
+ if (g->bw && history_back_available(g->bw->history)) {
+ /* clear potential search effects */
+ browser_window_search_destroy_context(g->bw);
+
+ nsgtk_search_set_forward_state(true, g->bw);
+ nsgtk_search_set_back_state(true, g->bw);
+
+ history_forward(g->bw, g->bw->history);
+ nsgtk_window_update_back_forward(g->scaffold);
+ }
+ break;
+
+ case GDK_KEY(Back):
+ if (g->bw && history_back_available(g->bw->history)) {
+ /* clear potential search effects */
+ browser_window_search_destroy_context(g->bw);
+
+ nsgtk_search_set_forward_state(true, g->bw);
+ nsgtk_search_set_back_state(true, g->bw);
+
+ history_back(g->bw, g->bw->history);
+ nsgtk_window_update_back_forward(g->scaffold);
+ }
+ break;
+
default:
break;
-----------------------------------------------------------------------
--
NetSurf Browser
10 years, 3 months
libdom: branch master updated. 8051772672c6cae6e00847f396cea6f7e3f43f3b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/8051772672c6cae6e00847...
...commit http://git.netsurf-browser.org/libdom.git/commit/8051772672c6cae6e00847f3...
...tree http://git.netsurf-browser.org/libdom.git/tree/8051772672c6cae6e00847f396...
The branch, master has been updated
via 8051772672c6cae6e00847f396cea6f7e3f43f3b (commit)
from 44a1b75fe3664687238929c61e58399940d3f862 (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/libdom.git/commitdiff/8051772672c6cae6e008...
commit 8051772672c6cae6e00847f396cea6f7e3f43f3b
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
fix example for new parameter setup
diff --git a/examples/dom-structure-dump.c b/examples/dom-structure-dump.c
index 833bbe1..4ce7670 100644
--- a/examples/dom-structure-dump.c
+++ b/examples/dom-structure-dump.c
@@ -60,13 +60,21 @@ dom_document *create_doc_dom_from_file(char *file)
FILE *handle;
int chunk_length;
dom_hubbub_error error;
+ dom_hubbub_parser_params params;
dom_document *doc;
unsigned char buffer[buffer_size];
+ params.enc = NULL;
+ params.fix_enc = true;
+ params.enable_script = false;
+ params.msg = NULL;
+ params.script = NULL;
+ params.ctx = NULL;
+ params.daf = NULL;
+
/* Create Hubbub parser */
- parser = dom_hubbub_parser_create(NULL, true, false, NULL, NULL,
- NULL, &doc);
- if (parser == NULL) {
+ error = dom_hubbub_parser_create(¶ms, &parser, &doc);
+ if (error != DOM_HUBBUB_OK) {
printf("Can't create Hubbub Parser\n");
return NULL;
}
-----------------------------------------------------------------------
Summary of changes:
examples/dom-structure-dump.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/examples/dom-structure-dump.c b/examples/dom-structure-dump.c
index 833bbe1..4ce7670 100644
--- a/examples/dom-structure-dump.c
+++ b/examples/dom-structure-dump.c
@@ -60,13 +60,21 @@ dom_document *create_doc_dom_from_file(char *file)
FILE *handle;
int chunk_length;
dom_hubbub_error error;
+ dom_hubbub_parser_params params;
dom_document *doc;
unsigned char buffer[buffer_size];
+ params.enc = NULL;
+ params.fix_enc = true;
+ params.enable_script = false;
+ params.msg = NULL;
+ params.script = NULL;
+ params.ctx = NULL;
+ params.daf = NULL;
+
/* Create Hubbub parser */
- parser = dom_hubbub_parser_create(NULL, true, false, NULL, NULL,
- NULL, &doc);
- if (parser == NULL) {
+ error = dom_hubbub_parser_create(¶ms, &parser, &doc);
+ if (error != DOM_HUBBUB_OK) {
printf("Can't create Hubbub Parser\n");
return NULL;
}
--
Document Object Model library
10 years, 3 months
netsurf: branch master updated. 912b9de92808c43a78680d41bba1ad982e120d86
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/912b9de92808c43a78680...
...commit http://git.netsurf-browser.org/netsurf.git/commit/912b9de92808c43a78680d4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/912b9de92808c43a78680d41b...
The branch, master has been updated
via 912b9de92808c43a78680d41bba1ad982e120d86 (commit)
from 646aed64ff07fa356f8aef034e77792cf634b053 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/912b9de92808c43a786...
commit 912b9de92808c43a78680d41bba1ad982e120d86
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
ensure default action fetcher is set to NULL
diff --git a/render/html.c b/render/html.c
index 0b2c543..19ea5a9 100644
--- a/render/html.c
+++ b/render/html.c
@@ -378,6 +378,7 @@ html_create_html_data(html_content *c, const http_parameter *params)
parse_params.msg = NULL;
parse_params.script = html_process_script;
parse_params.ctx = c;
+ parse_params.daf = NULL;
error = dom_hubbub_parser_create(&parse_params,
&c->parser,
@@ -495,6 +496,7 @@ html_process_encoding_change(struct content *c,
parse_params.msg = NULL;
parse_params.script = html_process_script;
parse_params.ctx = html;
+ parse_params.daf = NULL;
/* Create new binding, using the new encoding */
error = dom_hubbub_parser_create(&parse_params,
diff --git a/utils/libdom.c b/utils/libdom.c
index ebb90ee..9e7e776 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -343,6 +343,7 @@ nserror libdom_parse_file(const char *filename, const char *encoding, dom_docume
parse_params.msg = ignore_dom_msg;
parse_params.script = NULL;
parse_params.ctx = NULL;
+ parse_params.daf = NULL;
error = dom_hubbub_parser_create(&parse_params, &parser, &document);
if (error != DOM_HUBBUB_OK) {
-----------------------------------------------------------------------
Summary of changes:
render/html.c | 2 ++
utils/libdom.c | 1 +
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/render/html.c b/render/html.c
index 0b2c543..19ea5a9 100644
--- a/render/html.c
+++ b/render/html.c
@@ -378,6 +378,7 @@ html_create_html_data(html_content *c, const http_parameter *params)
parse_params.msg = NULL;
parse_params.script = html_process_script;
parse_params.ctx = c;
+ parse_params.daf = NULL;
error = dom_hubbub_parser_create(&parse_params,
&c->parser,
@@ -495,6 +496,7 @@ html_process_encoding_change(struct content *c,
parse_params.msg = NULL;
parse_params.script = html_process_script;
parse_params.ctx = html;
+ parse_params.daf = NULL;
/* Create new binding, using the new encoding */
error = dom_hubbub_parser_create(&parse_params,
diff --git a/utils/libdom.c b/utils/libdom.c
index ebb90ee..9e7e776 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -343,6 +343,7 @@ nserror libdom_parse_file(const char *filename, const char *encoding, dom_docume
parse_params.msg = ignore_dom_msg;
parse_params.script = NULL;
parse_params.ctx = NULL;
+ parse_params.daf = NULL;
error = dom_hubbub_parser_create(&parse_params, &parser, &document);
if (error != DOM_HUBBUB_OK) {
--
NetSurf Browser
10 years, 3 months
libdom: branch master updated. 44a1b75fe3664687238929c61e58399940d3f862
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/44a1b75fe3664687238929...
...commit http://git.netsurf-browser.org/libdom.git/commit/44a1b75fe3664687238929c6...
...tree http://git.netsurf-browser.org/libdom.git/tree/44a1b75fe3664687238929c61e...
The branch, master has been updated
via 44a1b75fe3664687238929c61e58399940d3f862 (commit)
from 2f8d84b8961315d3531608b2d3d36b23979d3e15 (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/libdom.git/commitdiff/44a1b75fe36646872389...
commit 44a1b75fe3664687238929c61e58399940d3f862
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
add default action fetcher to binding parameters
diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c
index 947c6f3..0c80a65 100644
--- a/bindings/hubbub/parser.c
+++ b/bindings/hubbub/parser.c
@@ -788,12 +788,13 @@ dom_hubbub_parser_create(dom_hubbub_parser_params *params,
return (DOM_HUBBUB_HUBBUB_ERR | error);
}
- /* TODO: Just pass the dom_events_default_action_fetcher a NULL,
- * we should pass the real function when we integrate libDOM with
- * NetSurf */
+ /* create DOM document */
err = dom_implementation_create_document(DOM_IMPLEMENTATION_HTML,
- NULL, NULL, NULL,
- NULL, &binding->doc);
+ NULL,
+ NULL,
+ NULL,
+ params->daf,
+ &binding->doc);
if (err != DOM_NO_ERR) {
hubbub_parser_destroy(binding->parser);
free(binding);
diff --git a/bindings/hubbub/parser.h b/bindings/hubbub/parser.h
index 132cc86..54ad0c8 100644
--- a/bindings/hubbub/parser.h
+++ b/bindings/hubbub/parser.h
@@ -60,6 +60,9 @@ typedef struct dom_hubbub_parser_params {
dom_msg msg; /**< Informational message function */
void *ctx; /**< Pointer to client-specific private data */
+
+ /** default action fetcher function */
+ dom_events_default_action_fetcher daf;
} dom_hubbub_parser_params;
/* Create a Hubbub parser instance */
diff --git a/test/testutils/load.c b/test/testutils/load.c
index da22870..eba4cb0 100644
--- a/test/testutils/load.c
+++ b/test/testutils/load.c
@@ -113,6 +113,7 @@ dom_document *load_html(const char *file, bool willBeModified)
params.msg = mymsg;
params.script = NULL;
params.ctx = NULL;
+ params.daf = NULL;
error = dom_hubbub_parser_create(¶ms, &parser, &ret);
if (error != DOM_HUBBUB_OK) {
-----------------------------------------------------------------------
Summary of changes:
bindings/hubbub/parser.c | 11 ++++++-----
bindings/hubbub/parser.h | 3 +++
test/testutils/load.c | 1 +
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c
index 947c6f3..0c80a65 100644
--- a/bindings/hubbub/parser.c
+++ b/bindings/hubbub/parser.c
@@ -788,12 +788,13 @@ dom_hubbub_parser_create(dom_hubbub_parser_params *params,
return (DOM_HUBBUB_HUBBUB_ERR | error);
}
- /* TODO: Just pass the dom_events_default_action_fetcher a NULL,
- * we should pass the real function when we integrate libDOM with
- * NetSurf */
+ /* create DOM document */
err = dom_implementation_create_document(DOM_IMPLEMENTATION_HTML,
- NULL, NULL, NULL,
- NULL, &binding->doc);
+ NULL,
+ NULL,
+ NULL,
+ params->daf,
+ &binding->doc);
if (err != DOM_NO_ERR) {
hubbub_parser_destroy(binding->parser);
free(binding);
diff --git a/bindings/hubbub/parser.h b/bindings/hubbub/parser.h
index 132cc86..54ad0c8 100644
--- a/bindings/hubbub/parser.h
+++ b/bindings/hubbub/parser.h
@@ -60,6 +60,9 @@ typedef struct dom_hubbub_parser_params {
dom_msg msg; /**< Informational message function */
void *ctx; /**< Pointer to client-specific private data */
+
+ /** default action fetcher function */
+ dom_events_default_action_fetcher daf;
} dom_hubbub_parser_params;
/* Create a Hubbub parser instance */
diff --git a/test/testutils/load.c b/test/testutils/load.c
index da22870..eba4cb0 100644
--- a/test/testutils/load.c
+++ b/test/testutils/load.c
@@ -113,6 +113,7 @@ dom_document *load_html(const char *file, bool willBeModified)
params.msg = mymsg;
params.script = NULL;
params.ctx = NULL;
+ params.daf = NULL;
error = dom_hubbub_parser_create(¶ms, &parser, &ret);
if (error != DOM_HUBBUB_OK) {
--
Document Object Model library
10 years, 3 months
netsurf: branch master updated. 646aed64ff07fa356f8aef034e77792cf634b053
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/646aed64ff07fa356f8ae...
...commit http://git.netsurf-browser.org/netsurf.git/commit/646aed64ff07fa356f8aef0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/646aed64ff07fa356f8aef034...
The branch, master has been updated
via 646aed64ff07fa356f8aef034e77792cf634b053 (commit)
from 61723e01c1beed8591d877c92035b65c448f46df (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/646aed64ff07fa356f8...
commit 646aed64ff07fa356f8aef034e77792cf634b053
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
change to parameterised parser binding creation
diff --git a/render/html.c b/render/html.c
index 812c690..0b2c543 100644
--- a/render/html.c
+++ b/render/html.c
@@ -112,60 +112,6 @@ static nserror css_error_to_nserror(css_error error)
return NSERROR_CSS;
}
-static nserror
-dom_hubbub_error_to_nserror(dom_hubbub_error error)
-{
- switch (error) {
-
- /* HUBBUB_REPROCESS is not handled here because it can
- * never occur outside the hubbub treebuilder
- */
-
- case DOM_HUBBUB_OK:
- /* parsed ok */
- return NSERROR_OK;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED):
- /* hubbub input paused */
- return NSERROR_OK;
-
- case DOM_HUBBUB_NOMEM:
- /* out of memory error from DOM */
- return NSERROR_NOMEM;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE):
- /* encoding changed */
- return NSERROR_ENCODING_CHANGE;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM):
- /* out of memory error from parser */
- return NSERROR_NOMEM;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM):
- return NSERROR_BAD_PARAMETER;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID):
- return NSERROR_INVALID;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND):
- return NSERROR_NOT_FOUND;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA):
- return NSERROR_NEED_DATA;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING):
- return NSERROR_BAD_ENCODING;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN):
- /* currently only generated by the libdom hubbub binding */
- return NSERROR_DOM;
- default:
- /* unknown error */
- /** @todo better error handling and reporting */
- return NSERROR_UNKNOWN;
- }
- return NSERROR_UNKNOWN;
-}
static void html_destroy_objects(html_content *html)
{
@@ -371,6 +317,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
{
lwc_string *charset;
nserror nerror;
+ dom_hubbub_parser_params parse_params;
+ dom_hubbub_error error;
c->parser = NULL;
c->document = NULL;
@@ -424,36 +372,37 @@ html_create_html_data(html_content *c, const http_parameter *params)
}
/* Create the parser binding */
- c->parser = dom_hubbub_parser_create(c->encoding,
- true,
- nsoption_bool(enable_javascript),
- NULL,
- html_process_script,
- c,
- &c->document);
- if ((c->parser == NULL) && (c->encoding != NULL)) {
+ parse_params.enc = c->encoding;
+ parse_params.fix_enc = true;
+ parse_params.enable_script = nsoption_bool(enable_javascript);
+ parse_params.msg = NULL;
+ parse_params.script = html_process_script;
+ parse_params.ctx = c;
+
+ error = dom_hubbub_parser_create(&parse_params,
+ &c->parser,
+ &c->document);
+ if ((error != DOM_HUBBUB_OK) && (c->encoding != NULL)) {
/* Ok, we don't support the declared encoding. Bailing out
* isn't exactly user-friendly, so fall back to autodetect */
free(c->encoding);
c->encoding = NULL;
- c->parser = dom_hubbub_parser_create(c->encoding,
- true,
- nsoption_bool(enable_javascript),
- NULL,
- html_process_script,
- c,
- &c->document);
+ parse_params.enc = c->encoding;
+
+ error = dom_hubbub_parser_create(&parse_params,
+ &c->parser,
+ &c->document);
}
- if (c->parser == NULL) {
+ if (error != DOM_HUBBUB_OK) {
nsurl_unref(c->base_url);
c->base_url = NULL;
lwc_string_unref(c->universal);
c->universal = NULL;
- return NSERROR_NOMEM;
+ return libdom_hubbub_error_to_nserror(error);
}
return NSERROR_OK;
@@ -510,6 +459,7 @@ html_process_encoding_change(struct content *c,
unsigned int size)
{
html_content *html = (html_content *) c;
+ dom_hubbub_parser_params parse_params;
dom_hubbub_error error;
const char *encoding;
const char *source_data;
@@ -539,15 +489,18 @@ html_process_encoding_change(struct content *c,
dom_node_unref(html->document);
}
+ parse_params.enc = html->encoding;
+ parse_params.fix_enc = true;
+ parse_params.enable_script = nsoption_bool(enable_javascript);
+ parse_params.msg = NULL;
+ parse_params.script = html_process_script;
+ parse_params.ctx = html;
+
/* Create new binding, using the new encoding */
- html->parser = dom_hubbub_parser_create(html->encoding,
- true,
- nsoption_bool(enable_javascript),
- NULL,
- html_process_script,
- html,
- &html->document);
- if (html->parser == NULL) {
+ error = dom_hubbub_parser_create(&parse_params,
+ &html->parser,
+ &html->document);
+ if (error != DOM_HUBBUB_OK) {
/* Ok, we don't support the declared encoding. Bailing out
* isn't exactly user-friendly, so fall back to Windows-1252 */
free(html->encoding);
@@ -555,21 +508,14 @@ html_process_encoding_change(struct content *c,
if (html->encoding == NULL) {
return NSERROR_NOMEM;
}
+ parse_params.enc = html->encoding;
- html->parser = dom_hubbub_parser_create(html->encoding,
- true,
- nsoption_bool(enable_javascript),
- NULL,
- html_process_script,
- html,
- &html->document);
-
- if (html->parser == NULL) {
- /** @todo add a message callback function and pass the
- * parser errors back instead of everything being
- * OOM
- */
- return NSERROR_NOMEM;
+ error = dom_hubbub_parser_create(&parse_params,
+ &html->parser,
+ &html->document);
+
+ if (error != DOM_HUBBUB_OK) {
+ return libdom_hubbub_error_to_nserror(error);
}
}
@@ -584,7 +530,7 @@ html_process_encoding_change(struct content *c,
(const uint8_t *)source_data,
source_size);
- return dom_hubbub_error_to_nserror(error);
+ return libdom_hubbub_error_to_nserror(error);
}
@@ -603,7 +549,7 @@ html_process_data(struct content *c, const char *data, unsigned int size)
(const uint8_t *) data,
size);
- err = dom_hubbub_error_to_nserror(dom_ret);
+ err = libdom_hubbub_error_to_nserror(dom_ret);
/* deal with encoding change */
if (err == NSERROR_ENCODING_CHANGE) {
@@ -1993,7 +1939,7 @@ html_begin_conversion(html_content *htmlc)
LOG(("Parsing failed"));
content_broadcast_errorcode(&htmlc->base,
- dom_hubbub_error_to_nserror(error));
+ libdom_hubbub_error_to_nserror(error));
return false;
}
diff --git a/utils/libdom.c b/utils/libdom.c
index 3b6cd15..ebb90ee 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -22,7 +22,6 @@
#include <assert.h>
#include <dom/dom.h>
-#include <dom/bindings/hubbub/parser.h>
#include "utils/config.h"
#include "utils/log.h"
@@ -254,6 +253,70 @@ void libdom_iterate_child_elements(dom_node *parent,
dom_nodelist_unref(children);
}
+/* exported interface documented in libdom.h */
+nserror libdom_hubbub_error_to_nserror(dom_hubbub_error error)
+{
+ switch (error) {
+
+ /* HUBBUB_REPROCESS is not handled here because it can
+ * never occur outside the hubbub treebuilder
+ */
+
+ case DOM_HUBBUB_OK:
+ /* parsed ok */
+ return NSERROR_OK;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED):
+ /* hubbub input paused */
+ return NSERROR_OK;
+
+ case DOM_HUBBUB_NOMEM:
+ /* out of memory error from DOM */
+ return NSERROR_NOMEM;
+
+ case DOM_HUBBUB_BADPARM:
+ /* Bad parameter passed to creation */
+ return NSERROR_BAD_PARAMETER;
+
+ case DOM_HUBBUB_DOM:
+ /* DOM call returned error */
+ return NSERROR_DOM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE):
+ /* encoding changed */
+ return NSERROR_ENCODING_CHANGE;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM):
+ /* out of memory error from parser */
+ return NSERROR_NOMEM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM):
+ return NSERROR_BAD_PARAMETER;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID):
+ return NSERROR_INVALID;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND):
+ return NSERROR_NOT_FOUND;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA):
+ return NSERROR_NEED_DATA;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING):
+ return NSERROR_BAD_ENCODING;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN):
+ /* currently only generated by the libdom hubbub binding */
+ return NSERROR_DOM;
+ default:
+ /* unknown error */
+ /** @todo better error handling and reporting */
+ return NSERROR_UNKNOWN;
+ }
+ return NSERROR_UNKNOWN;
+}
+
+
static void ignore_dom_msg(uint32_t severity, void *ctx, const char *msg, ...)
{
}
@@ -261,6 +324,7 @@ static void ignore_dom_msg(uint32_t severity, void *ctx, const char *msg, ...)
/* exported interface documented in libdom.h */
nserror libdom_parse_file(const char *filename, const char *encoding, dom_document **doc)
{
+ dom_hubbub_parser_params parse_params;
dom_hubbub_error error;
dom_hubbub_parser *parser;
dom_document *document;
@@ -273,11 +337,17 @@ nserror libdom_parse_file(const char *filename, const char *encoding, dom_docume
return NSERROR_NOT_FOUND;
}
- parser = dom_hubbub_parser_create(encoding, false, false,
- ignore_dom_msg, NULL, NULL, &document);
- if (parser == NULL) {
+ parse_params.enc = encoding;
+ parse_params.fix_enc = false;
+ parse_params.enable_script = false;
+ parse_params.msg = ignore_dom_msg;
+ parse_params.script = NULL;
+ parse_params.ctx = NULL;
+
+ error = dom_hubbub_parser_create(&parse_params, &parser, &document);
+ if (error != DOM_HUBBUB_OK) {
fclose(fp);
- return NSERROR_DOM;
+ return libdom_hubbub_error_to_nserror(error);
}
while (feof(fp) == 0) {
@@ -297,7 +367,7 @@ nserror libdom_parse_file(const char *filename, const char *encoding, dom_docume
dom_node_unref(document);
dom_hubbub_parser_destroy(parser);
fclose(fp);
- return NSERROR_DOM;
+ return libdom_hubbub_error_to_nserror(error);
}
dom_hubbub_parser_destroy(parser);
diff --git a/utils/libdom.h b/utils/libdom.h
index d79c92d..36caf01 100644
--- a/utils/libdom.h
+++ b/utils/libdom.h
@@ -28,7 +28,11 @@
#include <dom/dom.h>
-/* depth-first walk the dom calling callback for each element
+#include <dom/bindings/hubbub/parser.h>
+#include <dom/bindings/hubbub/errors.h>
+
+/**
+ * depth-first walk the dom calling callback for each element
*
* \param root the dom node to use as the root of the tree walk
* \return true if all nodes were examined, false if the callback terminated
@@ -65,4 +69,12 @@ void libdom_iterate_child_elements(dom_node *parent,
nserror libdom_parse_file(const char *filename, const char *encoding,
dom_document **doc);
+/**
+ * Convert libdom hubbub binding errors to nserrors.
+ *
+ * \param error The hubbub binding error to convert
+ * \return The appropriate nserror
+ */
+nserror libdom_hubbub_error_to_nserror(dom_hubbub_error error);
+
#endif
-----------------------------------------------------------------------
Summary of changes:
render/html.c | 138 +++++++++++++++++---------------------------------------
utils/libdom.c | 82 +++++++++++++++++++++++++++++++---
utils/libdom.h | 14 +++++-
3 files changed, 131 insertions(+), 103 deletions(-)
diff --git a/render/html.c b/render/html.c
index 812c690..0b2c543 100644
--- a/render/html.c
+++ b/render/html.c
@@ -112,60 +112,6 @@ static nserror css_error_to_nserror(css_error error)
return NSERROR_CSS;
}
-static nserror
-dom_hubbub_error_to_nserror(dom_hubbub_error error)
-{
- switch (error) {
-
- /* HUBBUB_REPROCESS is not handled here because it can
- * never occur outside the hubbub treebuilder
- */
-
- case DOM_HUBBUB_OK:
- /* parsed ok */
- return NSERROR_OK;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED):
- /* hubbub input paused */
- return NSERROR_OK;
-
- case DOM_HUBBUB_NOMEM:
- /* out of memory error from DOM */
- return NSERROR_NOMEM;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE):
- /* encoding changed */
- return NSERROR_ENCODING_CHANGE;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM):
- /* out of memory error from parser */
- return NSERROR_NOMEM;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM):
- return NSERROR_BAD_PARAMETER;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID):
- return NSERROR_INVALID;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND):
- return NSERROR_NOT_FOUND;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA):
- return NSERROR_NEED_DATA;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING):
- return NSERROR_BAD_ENCODING;
-
- case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN):
- /* currently only generated by the libdom hubbub binding */
- return NSERROR_DOM;
- default:
- /* unknown error */
- /** @todo better error handling and reporting */
- return NSERROR_UNKNOWN;
- }
- return NSERROR_UNKNOWN;
-}
static void html_destroy_objects(html_content *html)
{
@@ -371,6 +317,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
{
lwc_string *charset;
nserror nerror;
+ dom_hubbub_parser_params parse_params;
+ dom_hubbub_error error;
c->parser = NULL;
c->document = NULL;
@@ -424,36 +372,37 @@ html_create_html_data(html_content *c, const http_parameter *params)
}
/* Create the parser binding */
- c->parser = dom_hubbub_parser_create(c->encoding,
- true,
- nsoption_bool(enable_javascript),
- NULL,
- html_process_script,
- c,
- &c->document);
- if ((c->parser == NULL) && (c->encoding != NULL)) {
+ parse_params.enc = c->encoding;
+ parse_params.fix_enc = true;
+ parse_params.enable_script = nsoption_bool(enable_javascript);
+ parse_params.msg = NULL;
+ parse_params.script = html_process_script;
+ parse_params.ctx = c;
+
+ error = dom_hubbub_parser_create(&parse_params,
+ &c->parser,
+ &c->document);
+ if ((error != DOM_HUBBUB_OK) && (c->encoding != NULL)) {
/* Ok, we don't support the declared encoding. Bailing out
* isn't exactly user-friendly, so fall back to autodetect */
free(c->encoding);
c->encoding = NULL;
- c->parser = dom_hubbub_parser_create(c->encoding,
- true,
- nsoption_bool(enable_javascript),
- NULL,
- html_process_script,
- c,
- &c->document);
+ parse_params.enc = c->encoding;
+
+ error = dom_hubbub_parser_create(&parse_params,
+ &c->parser,
+ &c->document);
}
- if (c->parser == NULL) {
+ if (error != DOM_HUBBUB_OK) {
nsurl_unref(c->base_url);
c->base_url = NULL;
lwc_string_unref(c->universal);
c->universal = NULL;
- return NSERROR_NOMEM;
+ return libdom_hubbub_error_to_nserror(error);
}
return NSERROR_OK;
@@ -510,6 +459,7 @@ html_process_encoding_change(struct content *c,
unsigned int size)
{
html_content *html = (html_content *) c;
+ dom_hubbub_parser_params parse_params;
dom_hubbub_error error;
const char *encoding;
const char *source_data;
@@ -539,15 +489,18 @@ html_process_encoding_change(struct content *c,
dom_node_unref(html->document);
}
+ parse_params.enc = html->encoding;
+ parse_params.fix_enc = true;
+ parse_params.enable_script = nsoption_bool(enable_javascript);
+ parse_params.msg = NULL;
+ parse_params.script = html_process_script;
+ parse_params.ctx = html;
+
/* Create new binding, using the new encoding */
- html->parser = dom_hubbub_parser_create(html->encoding,
- true,
- nsoption_bool(enable_javascript),
- NULL,
- html_process_script,
- html,
- &html->document);
- if (html->parser == NULL) {
+ error = dom_hubbub_parser_create(&parse_params,
+ &html->parser,
+ &html->document);
+ if (error != DOM_HUBBUB_OK) {
/* Ok, we don't support the declared encoding. Bailing out
* isn't exactly user-friendly, so fall back to Windows-1252 */
free(html->encoding);
@@ -555,21 +508,14 @@ html_process_encoding_change(struct content *c,
if (html->encoding == NULL) {
return NSERROR_NOMEM;
}
+ parse_params.enc = html->encoding;
- html->parser = dom_hubbub_parser_create(html->encoding,
- true,
- nsoption_bool(enable_javascript),
- NULL,
- html_process_script,
- html,
- &html->document);
-
- if (html->parser == NULL) {
- /** @todo add a message callback function and pass the
- * parser errors back instead of everything being
- * OOM
- */
- return NSERROR_NOMEM;
+ error = dom_hubbub_parser_create(&parse_params,
+ &html->parser,
+ &html->document);
+
+ if (error != DOM_HUBBUB_OK) {
+ return libdom_hubbub_error_to_nserror(error);
}
}
@@ -584,7 +530,7 @@ html_process_encoding_change(struct content *c,
(const uint8_t *)source_data,
source_size);
- return dom_hubbub_error_to_nserror(error);
+ return libdom_hubbub_error_to_nserror(error);
}
@@ -603,7 +549,7 @@ html_process_data(struct content *c, const char *data, unsigned int size)
(const uint8_t *) data,
size);
- err = dom_hubbub_error_to_nserror(dom_ret);
+ err = libdom_hubbub_error_to_nserror(dom_ret);
/* deal with encoding change */
if (err == NSERROR_ENCODING_CHANGE) {
@@ -1993,7 +1939,7 @@ html_begin_conversion(html_content *htmlc)
LOG(("Parsing failed"));
content_broadcast_errorcode(&htmlc->base,
- dom_hubbub_error_to_nserror(error));
+ libdom_hubbub_error_to_nserror(error));
return false;
}
diff --git a/utils/libdom.c b/utils/libdom.c
index 3b6cd15..ebb90ee 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -22,7 +22,6 @@
#include <assert.h>
#include <dom/dom.h>
-#include <dom/bindings/hubbub/parser.h>
#include "utils/config.h"
#include "utils/log.h"
@@ -254,6 +253,70 @@ void libdom_iterate_child_elements(dom_node *parent,
dom_nodelist_unref(children);
}
+/* exported interface documented in libdom.h */
+nserror libdom_hubbub_error_to_nserror(dom_hubbub_error error)
+{
+ switch (error) {
+
+ /* HUBBUB_REPROCESS is not handled here because it can
+ * never occur outside the hubbub treebuilder
+ */
+
+ case DOM_HUBBUB_OK:
+ /* parsed ok */
+ return NSERROR_OK;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED):
+ /* hubbub input paused */
+ return NSERROR_OK;
+
+ case DOM_HUBBUB_NOMEM:
+ /* out of memory error from DOM */
+ return NSERROR_NOMEM;
+
+ case DOM_HUBBUB_BADPARM:
+ /* Bad parameter passed to creation */
+ return NSERROR_BAD_PARAMETER;
+
+ case DOM_HUBBUB_DOM:
+ /* DOM call returned error */
+ return NSERROR_DOM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_ENCODINGCHANGE):
+ /* encoding changed */
+ return NSERROR_ENCODING_CHANGE;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NOMEM):
+ /* out of memory error from parser */
+ return NSERROR_NOMEM;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADPARM):
+ return NSERROR_BAD_PARAMETER;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_INVALID):
+ return NSERROR_INVALID;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_FILENOTFOUND):
+ return NSERROR_NOT_FOUND;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_NEEDDATA):
+ return NSERROR_NEED_DATA;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_BADENCODING):
+ return NSERROR_BAD_ENCODING;
+
+ case (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_UNKNOWN):
+ /* currently only generated by the libdom hubbub binding */
+ return NSERROR_DOM;
+ default:
+ /* unknown error */
+ /** @todo better error handling and reporting */
+ return NSERROR_UNKNOWN;
+ }
+ return NSERROR_UNKNOWN;
+}
+
+
static void ignore_dom_msg(uint32_t severity, void *ctx, const char *msg, ...)
{
}
@@ -261,6 +324,7 @@ static void ignore_dom_msg(uint32_t severity, void *ctx, const char *msg, ...)
/* exported interface documented in libdom.h */
nserror libdom_parse_file(const char *filename, const char *encoding, dom_document **doc)
{
+ dom_hubbub_parser_params parse_params;
dom_hubbub_error error;
dom_hubbub_parser *parser;
dom_document *document;
@@ -273,11 +337,17 @@ nserror libdom_parse_file(const char *filename, const char *encoding, dom_docume
return NSERROR_NOT_FOUND;
}
- parser = dom_hubbub_parser_create(encoding, false, false,
- ignore_dom_msg, NULL, NULL, &document);
- if (parser == NULL) {
+ parse_params.enc = encoding;
+ parse_params.fix_enc = false;
+ parse_params.enable_script = false;
+ parse_params.msg = ignore_dom_msg;
+ parse_params.script = NULL;
+ parse_params.ctx = NULL;
+
+ error = dom_hubbub_parser_create(&parse_params, &parser, &document);
+ if (error != DOM_HUBBUB_OK) {
fclose(fp);
- return NSERROR_DOM;
+ return libdom_hubbub_error_to_nserror(error);
}
while (feof(fp) == 0) {
@@ -297,7 +367,7 @@ nserror libdom_parse_file(const char *filename, const char *encoding, dom_docume
dom_node_unref(document);
dom_hubbub_parser_destroy(parser);
fclose(fp);
- return NSERROR_DOM;
+ return libdom_hubbub_error_to_nserror(error);
}
dom_hubbub_parser_destroy(parser);
diff --git a/utils/libdom.h b/utils/libdom.h
index d79c92d..36caf01 100644
--- a/utils/libdom.h
+++ b/utils/libdom.h
@@ -28,7 +28,11 @@
#include <dom/dom.h>
-/* depth-first walk the dom calling callback for each element
+#include <dom/bindings/hubbub/parser.h>
+#include <dom/bindings/hubbub/errors.h>
+
+/**
+ * depth-first walk the dom calling callback for each element
*
* \param root the dom node to use as the root of the tree walk
* \return true if all nodes were examined, false if the callback terminated
@@ -65,4 +69,12 @@ void libdom_iterate_child_elements(dom_node *parent,
nserror libdom_parse_file(const char *filename, const char *encoding,
dom_document **doc);
+/**
+ * Convert libdom hubbub binding errors to nserrors.
+ *
+ * \param error The hubbub binding error to convert
+ * \return The appropriate nserror
+ */
+nserror libdom_hubbub_error_to_nserror(dom_hubbub_error error);
+
#endif
--
NetSurf Browser
10 years, 3 months
libdom: branch master updated. 2f8d84b8961315d3531608b2d3d36b23979d3e15
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/2f8d84b8961315d3531608...
...commit http://git.netsurf-browser.org/libdom.git/commit/2f8d84b8961315d3531608b2...
...tree http://git.netsurf-browser.org/libdom.git/tree/2f8d84b8961315d3531608b2d3...
The branch, master has been updated
via 2f8d84b8961315d3531608b2d3d36b23979d3e15 (commit)
from 77efdb615b56e66fcdd4fc49efac37a460196fc3 (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/libdom.git/commitdiff/2f8d84b8961315d35316...
commit 2f8d84b8961315d3531608b2d3d36b23979d3e15
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
make the hubbub binding creation take a parameter struct and return standard error codes
diff --git a/bindings/hubbub/errors.h b/bindings/hubbub/errors.h
index 19bab3a..381199c 100644
--- a/bindings/hubbub/errors.h
+++ b/bindings/hubbub/errors.h
@@ -13,6 +13,10 @@ typedef enum {
DOM_HUBBUB_NOMEM = 1,
+ DOM_HUBBUB_BADPARM = 2, /**< Bad input parameter */
+
+ DOM_HUBBUB_DOM = 3, /**< DOM operation failed */
+
DOM_HUBBUB_HUBBUB_ERR = (1<<16),
DOM_HUBBUB_HUBBUB_ERR_PAUSED = (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED),
diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c
index 6478e89..947c6f3 100644
--- a/bindings/hubbub/parser.c
+++ b/bindings/hubbub/parser.c
@@ -720,68 +720,72 @@ dom_hubbub_parser_default_script(void *ctx, struct dom_node *node)
/**
* Create a Hubbub parser instance
*
- * \param enc Source charset, or NULL
- * \param fix_enc Whether fix the encoding
- * \param enable_script Whether scripting should be enabled.
- * \param msg Informational message function
- * \param script Script callback function
- * \param mctx Pointer to client-specific private data
- * \param document Pointer to location to receive document
- * \return Pointer to instance, or NULL on memory exhaustion
+ * \param params The binding creation parameters
+ * \param parser Pointer to location to recive instance.
+ * \param document Pointer to location to receive document.
+ * \return Error code
*/
-dom_hubbub_parser *
-dom_hubbub_parser_create(const char *enc,
- bool fix_enc,
- bool enable_script,
- dom_msg msg,
- dom_script script,
- void *mctx,
+dom_hubbub_error
+dom_hubbub_parser_create(dom_hubbub_parser_params *params,
+ dom_hubbub_parser **parser,
dom_document **document)
{
- dom_hubbub_parser *parser;
- hubbub_parser_optparams params;
+ dom_hubbub_parser *binding;
+ hubbub_parser_optparams optparams;
hubbub_error error;
dom_exception err;
dom_string *idname = NULL;
- /* check result parameter */
+ /* check result parameters */
if (document == NULL) {
- msg(DOM_MSG_CRITICAL, mctx, "Bad document return parameter");
- return NULL;
+ return DOM_HUBBUB_BADPARM;
}
- parser = malloc(sizeof(dom_hubbub_parser));
if (parser == NULL) {
- msg(DOM_MSG_CRITICAL, mctx, "No memory for parsing context");
- return NULL;
+ return DOM_HUBBUB_BADPARM;
}
- parser->parser = NULL;
- parser->doc = NULL;
- parser->encoding = enc;
- parser->encoding_source = enc != NULL ? DOM_HUBBUB_ENCODING_SOURCE_HEADER
- : DOM_HUBBUB_ENCODING_SOURCE_DETECTED;
- parser->complete = false;
+ /* setup binding parser context */
+ binding = malloc(sizeof(dom_hubbub_parser));
+ if (binding == NULL) {
+ return DOM_HUBBUB_NOMEM;
+ }
+
+ binding->parser = NULL;
+ binding->doc = NULL;
+ binding->encoding = params->enc;
- if (msg == NULL) {
- msg = dom_hubbub_parser_default_msg;
+ if (params->enc != NULL) {
+ binding->encoding_source = DOM_HUBBUB_ENCODING_SOURCE_HEADER;
+ } else {
+ binding->encoding_source = DOM_HUBBUB_ENCODING_SOURCE_DETECTED;
}
- parser->msg = msg;
- parser->mctx = mctx;
- /* ensure script function is valid or use the default */
- if (script == NULL) {
- script = dom_hubbub_parser_default_script;
+ binding->complete = false;
+
+ if (params->msg == NULL) {
+ binding->msg = dom_hubbub_parser_default_msg;
+ } else {
+ binding->msg = params->msg;
}
- parser->script = script;
+ binding->mctx = params->ctx;
+ /* ensure script function is valid or use the default */
+ if (params->script == NULL) {
+ binding->script = dom_hubbub_parser_default_script;
+ } else {
+ binding->script = params->script;
+ }
- error = hubbub_parser_create(enc, fix_enc, dom_hubbub_alloc, NULL,
- &parser->parser);
+ /* create hubbub parser */
+ error = hubbub_parser_create(binding->encoding,
+ params->fix_enc,
+ dom_hubbub_alloc,
+ NULL,
+ &binding->parser);
if (error != HUBBUB_OK) {
- free(parser);
- msg(DOM_MSG_CRITICAL, mctx, "Can't create parser");
- return NULL;
+ free(binding);
+ return (DOM_HUBBUB_HUBBUB_ERR | error);
}
/* TODO: Just pass the dom_events_default_action_fetcher a NULL,
@@ -789,30 +793,33 @@ dom_hubbub_parser_create(const char *enc,
* NetSurf */
err = dom_implementation_create_document(DOM_IMPLEMENTATION_HTML,
NULL, NULL, NULL,
- NULL, &parser->doc);
+ NULL, &binding->doc);
if (err != DOM_NO_ERR) {
- hubbub_parser_destroy(parser->parser);
- free(parser);
- msg(DOM_MSG_ERROR, mctx, "Can't create DOM document");
- return NULL;
+ hubbub_parser_destroy(binding->parser);
+ free(binding);
+ return DOM_HUBBUB_DOM;
}
- parser->tree_handler = tree_handler;
- parser->tree_handler.ctx = (void *) parser;
+ binding->tree_handler = tree_handler;
+ binding->tree_handler.ctx = (void *)binding;
- params.tree_handler = &parser->tree_handler;
- hubbub_parser_setopt(parser->parser, HUBBUB_PARSER_TREE_HANDLER,
- ¶ms);
+ /* set tree handler on parser */
+ optparams.tree_handler = &binding->tree_handler;
+ hubbub_parser_setopt(binding->parser,
+ HUBBUB_PARSER_TREE_HANDLER,
+ &optparams);
- dom_node_ref((struct dom_node *) parser->doc);
- params.document_node = parser->doc;
- hubbub_parser_setopt(parser->parser, HUBBUB_PARSER_DOCUMENT_NODE,
- ¶ms);
+ /* set document node*/
+ optparams.document_node = dom_node_ref((struct dom_node *)binding->doc);
+ hubbub_parser_setopt(binding->parser,
+ HUBBUB_PARSER_DOCUMENT_NODE,
+ &optparams);
- params.enable_scripting = enable_script;
- hubbub_parser_setopt(parser->parser,
+ /* set scripting state */
+ optparams.enable_scripting = params->enable_script;
+ hubbub_parser_setopt(binding->parser,
HUBBUB_PARSER_ENABLE_SCRIPTING,
- ¶ms);
+ &optparams);
/* set the document id parameter before the parse so searches
* based on id succeed.
@@ -821,18 +828,19 @@ dom_hubbub_parser_create(const char *enc,
SLEN("id"),
&idname);
if (err != DOM_NO_ERR) {
- hubbub_parser_destroy(parser->parser);
- free(parser);
- msg(DOM_MSG_ERROR, mctx, "Can't set DOM document id name");
- return NULL;
+ binding->msg(DOM_MSG_ERROR, binding->mctx, "Can't set DOM document id name");
+ hubbub_parser_destroy(binding->parser);
+ free(binding);
+ return DOM_HUBBUB_DOM;
}
- _dom_document_set_id_name(parser->doc, idname);
+ _dom_document_set_id_name(binding->doc, idname);
dom_string_unref(idname);
- /* set return parameter */
- *document = (dom_document *)dom_node_ref(parser->doc);
+ /* set return parameters */
+ *document = (dom_document *)dom_node_ref(binding->doc);
+ *parser = binding;
- return parser;
+ return DOM_HUBBUB_OK;
}
diff --git a/bindings/hubbub/parser.h b/bindings/hubbub/parser.h
index ef0a745..132cc86 100644
--- a/bindings/hubbub/parser.h
+++ b/bindings/hubbub/parser.h
@@ -48,10 +48,23 @@ typedef enum dom_hubbub_encoding_source {
* The client must not call any method of this parser after destruction.
*/
+/**
+ * Parameter block for dom_hubbub_parser_create
+ */
+typedef struct dom_hubbub_parser_params {
+ const char *enc; /**< Source charset, or NULL */
+ bool fix_enc; /**< Whether fix the encoding */
+
+ bool enable_script; /**< Whether scripting should be enabled. */
+ dom_script script; /**< Script callback function */
+
+ dom_msg msg; /**< Informational message function */
+ void *ctx; /**< Pointer to client-specific private data */
+} dom_hubbub_parser_params;
+
/* Create a Hubbub parser instance */
-dom_hubbub_parser *dom_hubbub_parser_create(const char *enc, bool fix_enc,
- bool enable_script, dom_msg msg,
- dom_script script, void *mctx,
+dom_hubbub_error dom_hubbub_parser_create(dom_hubbub_parser_params *params,
+ dom_hubbub_parser **parser,
dom_document **document);
/* Destroy a Hubbub parser instance */
diff --git a/test/testutils/load.c b/test/testutils/load.c
index 2c93fc0..da22870 100644
--- a/test/testutils/load.c
+++ b/test/testutils/load.c
@@ -103,11 +103,19 @@ dom_document *load_html(const char *file, bool willBeModified)
dom_hubbub_error error;
dom_document *ret;
uint8_t buffer[1024];
+ dom_hubbub_parser_params params;
UNUSED(willBeModified);
- parser = dom_hubbub_parser_create(NULL, true, false, mymsg, NULL, NULL, &ret);
- if (parser == NULL) {
+ params.enc = NULL;
+ params.fix_enc = true;
+ params.enable_script = false;
+ params.msg = mymsg;
+ params.script = NULL;
+ params.ctx = NULL;
+
+ error = dom_hubbub_parser_create(¶ms, &parser, &ret);
+ if (error != DOM_HUBBUB_OK) {
fprintf(stderr, "Can't create Hubbub Parser\n");
return NULL;
}
-----------------------------------------------------------------------
Summary of changes:
bindings/hubbub/errors.h | 4 +
bindings/hubbub/parser.c | 142 ++++++++++++++++++++++++----------------------
bindings/hubbub/parser.h | 19 +++++-
test/testutils/load.c | 12 +++-
4 files changed, 105 insertions(+), 72 deletions(-)
diff --git a/bindings/hubbub/errors.h b/bindings/hubbub/errors.h
index 19bab3a..381199c 100644
--- a/bindings/hubbub/errors.h
+++ b/bindings/hubbub/errors.h
@@ -13,6 +13,10 @@ typedef enum {
DOM_HUBBUB_NOMEM = 1,
+ DOM_HUBBUB_BADPARM = 2, /**< Bad input parameter */
+
+ DOM_HUBBUB_DOM = 3, /**< DOM operation failed */
+
DOM_HUBBUB_HUBBUB_ERR = (1<<16),
DOM_HUBBUB_HUBBUB_ERR_PAUSED = (DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED),
diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c
index 6478e89..947c6f3 100644
--- a/bindings/hubbub/parser.c
+++ b/bindings/hubbub/parser.c
@@ -720,68 +720,72 @@ dom_hubbub_parser_default_script(void *ctx, struct dom_node *node)
/**
* Create a Hubbub parser instance
*
- * \param enc Source charset, or NULL
- * \param fix_enc Whether fix the encoding
- * \param enable_script Whether scripting should be enabled.
- * \param msg Informational message function
- * \param script Script callback function
- * \param mctx Pointer to client-specific private data
- * \param document Pointer to location to receive document
- * \return Pointer to instance, or NULL on memory exhaustion
+ * \param params The binding creation parameters
+ * \param parser Pointer to location to recive instance.
+ * \param document Pointer to location to receive document.
+ * \return Error code
*/
-dom_hubbub_parser *
-dom_hubbub_parser_create(const char *enc,
- bool fix_enc,
- bool enable_script,
- dom_msg msg,
- dom_script script,
- void *mctx,
+dom_hubbub_error
+dom_hubbub_parser_create(dom_hubbub_parser_params *params,
+ dom_hubbub_parser **parser,
dom_document **document)
{
- dom_hubbub_parser *parser;
- hubbub_parser_optparams params;
+ dom_hubbub_parser *binding;
+ hubbub_parser_optparams optparams;
hubbub_error error;
dom_exception err;
dom_string *idname = NULL;
- /* check result parameter */
+ /* check result parameters */
if (document == NULL) {
- msg(DOM_MSG_CRITICAL, mctx, "Bad document return parameter");
- return NULL;
+ return DOM_HUBBUB_BADPARM;
}
- parser = malloc(sizeof(dom_hubbub_parser));
if (parser == NULL) {
- msg(DOM_MSG_CRITICAL, mctx, "No memory for parsing context");
- return NULL;
+ return DOM_HUBBUB_BADPARM;
}
- parser->parser = NULL;
- parser->doc = NULL;
- parser->encoding = enc;
- parser->encoding_source = enc != NULL ? DOM_HUBBUB_ENCODING_SOURCE_HEADER
- : DOM_HUBBUB_ENCODING_SOURCE_DETECTED;
- parser->complete = false;
+ /* setup binding parser context */
+ binding = malloc(sizeof(dom_hubbub_parser));
+ if (binding == NULL) {
+ return DOM_HUBBUB_NOMEM;
+ }
+
+ binding->parser = NULL;
+ binding->doc = NULL;
+ binding->encoding = params->enc;
- if (msg == NULL) {
- msg = dom_hubbub_parser_default_msg;
+ if (params->enc != NULL) {
+ binding->encoding_source = DOM_HUBBUB_ENCODING_SOURCE_HEADER;
+ } else {
+ binding->encoding_source = DOM_HUBBUB_ENCODING_SOURCE_DETECTED;
}
- parser->msg = msg;
- parser->mctx = mctx;
- /* ensure script function is valid or use the default */
- if (script == NULL) {
- script = dom_hubbub_parser_default_script;
+ binding->complete = false;
+
+ if (params->msg == NULL) {
+ binding->msg = dom_hubbub_parser_default_msg;
+ } else {
+ binding->msg = params->msg;
}
- parser->script = script;
+ binding->mctx = params->ctx;
+ /* ensure script function is valid or use the default */
+ if (params->script == NULL) {
+ binding->script = dom_hubbub_parser_default_script;
+ } else {
+ binding->script = params->script;
+ }
- error = hubbub_parser_create(enc, fix_enc, dom_hubbub_alloc, NULL,
- &parser->parser);
+ /* create hubbub parser */
+ error = hubbub_parser_create(binding->encoding,
+ params->fix_enc,
+ dom_hubbub_alloc,
+ NULL,
+ &binding->parser);
if (error != HUBBUB_OK) {
- free(parser);
- msg(DOM_MSG_CRITICAL, mctx, "Can't create parser");
- return NULL;
+ free(binding);
+ return (DOM_HUBBUB_HUBBUB_ERR | error);
}
/* TODO: Just pass the dom_events_default_action_fetcher a NULL,
@@ -789,30 +793,33 @@ dom_hubbub_parser_create(const char *enc,
* NetSurf */
err = dom_implementation_create_document(DOM_IMPLEMENTATION_HTML,
NULL, NULL, NULL,
- NULL, &parser->doc);
+ NULL, &binding->doc);
if (err != DOM_NO_ERR) {
- hubbub_parser_destroy(parser->parser);
- free(parser);
- msg(DOM_MSG_ERROR, mctx, "Can't create DOM document");
- return NULL;
+ hubbub_parser_destroy(binding->parser);
+ free(binding);
+ return DOM_HUBBUB_DOM;
}
- parser->tree_handler = tree_handler;
- parser->tree_handler.ctx = (void *) parser;
+ binding->tree_handler = tree_handler;
+ binding->tree_handler.ctx = (void *)binding;
- params.tree_handler = &parser->tree_handler;
- hubbub_parser_setopt(parser->parser, HUBBUB_PARSER_TREE_HANDLER,
- ¶ms);
+ /* set tree handler on parser */
+ optparams.tree_handler = &binding->tree_handler;
+ hubbub_parser_setopt(binding->parser,
+ HUBBUB_PARSER_TREE_HANDLER,
+ &optparams);
- dom_node_ref((struct dom_node *) parser->doc);
- params.document_node = parser->doc;
- hubbub_parser_setopt(parser->parser, HUBBUB_PARSER_DOCUMENT_NODE,
- ¶ms);
+ /* set document node*/
+ optparams.document_node = dom_node_ref((struct dom_node *)binding->doc);
+ hubbub_parser_setopt(binding->parser,
+ HUBBUB_PARSER_DOCUMENT_NODE,
+ &optparams);
- params.enable_scripting = enable_script;
- hubbub_parser_setopt(parser->parser,
+ /* set scripting state */
+ optparams.enable_scripting = params->enable_script;
+ hubbub_parser_setopt(binding->parser,
HUBBUB_PARSER_ENABLE_SCRIPTING,
- ¶ms);
+ &optparams);
/* set the document id parameter before the parse so searches
* based on id succeed.
@@ -821,18 +828,19 @@ dom_hubbub_parser_create(const char *enc,
SLEN("id"),
&idname);
if (err != DOM_NO_ERR) {
- hubbub_parser_destroy(parser->parser);
- free(parser);
- msg(DOM_MSG_ERROR, mctx, "Can't set DOM document id name");
- return NULL;
+ binding->msg(DOM_MSG_ERROR, binding->mctx, "Can't set DOM document id name");
+ hubbub_parser_destroy(binding->parser);
+ free(binding);
+ return DOM_HUBBUB_DOM;
}
- _dom_document_set_id_name(parser->doc, idname);
+ _dom_document_set_id_name(binding->doc, idname);
dom_string_unref(idname);
- /* set return parameter */
- *document = (dom_document *)dom_node_ref(parser->doc);
+ /* set return parameters */
+ *document = (dom_document *)dom_node_ref(binding->doc);
+ *parser = binding;
- return parser;
+ return DOM_HUBBUB_OK;
}
diff --git a/bindings/hubbub/parser.h b/bindings/hubbub/parser.h
index ef0a745..132cc86 100644
--- a/bindings/hubbub/parser.h
+++ b/bindings/hubbub/parser.h
@@ -48,10 +48,23 @@ typedef enum dom_hubbub_encoding_source {
* The client must not call any method of this parser after destruction.
*/
+/**
+ * Parameter block for dom_hubbub_parser_create
+ */
+typedef struct dom_hubbub_parser_params {
+ const char *enc; /**< Source charset, or NULL */
+ bool fix_enc; /**< Whether fix the encoding */
+
+ bool enable_script; /**< Whether scripting should be enabled. */
+ dom_script script; /**< Script callback function */
+
+ dom_msg msg; /**< Informational message function */
+ void *ctx; /**< Pointer to client-specific private data */
+} dom_hubbub_parser_params;
+
/* Create a Hubbub parser instance */
-dom_hubbub_parser *dom_hubbub_parser_create(const char *enc, bool fix_enc,
- bool enable_script, dom_msg msg,
- dom_script script, void *mctx,
+dom_hubbub_error dom_hubbub_parser_create(dom_hubbub_parser_params *params,
+ dom_hubbub_parser **parser,
dom_document **document);
/* Destroy a Hubbub parser instance */
diff --git a/test/testutils/load.c b/test/testutils/load.c
index 2c93fc0..da22870 100644
--- a/test/testutils/load.c
+++ b/test/testutils/load.c
@@ -103,11 +103,19 @@ dom_document *load_html(const char *file, bool willBeModified)
dom_hubbub_error error;
dom_document *ret;
uint8_t buffer[1024];
+ dom_hubbub_parser_params params;
UNUSED(willBeModified);
- parser = dom_hubbub_parser_create(NULL, true, false, mymsg, NULL, NULL, &ret);
- if (parser == NULL) {
+ params.enc = NULL;
+ params.fix_enc = true;
+ params.enable_script = false;
+ params.msg = mymsg;
+ params.script = NULL;
+ params.ctx = NULL;
+
+ error = dom_hubbub_parser_create(¶ms, &parser, &ret);
+ if (error != DOM_HUBBUB_OK) {
fprintf(stderr, "Can't create Hubbub Parser\n");
return NULL;
}
--
Document Object Model library
10 years, 3 months
netsurf: branch mono/removing-windom-dependency updated. c4b09a8439c3465354aa7c8545ed54d099eb17fa
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c4b09a8439c3465354aa7...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c4b09a8439c3465354aa7c8...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c4b09a8439c3465354aa7c854...
The branch, mono/removing-windom-dependency has been updated
via c4b09a8439c3465354aa7c8545ed54d099eb17fa (commit)
via 5d2ac2ecace0971ce2737f4169b62b56a2ca3a2a (commit)
from 395f161eb520b7d1b662966f03919a7eeca29fe3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/c4b09a8439c3465354a...
commit c4b09a8439c3465354aa7c8545ed54d099eb17fa
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Removed global_evnt.c module.
diff --git a/atari/Makefile.target b/atari/Makefile.target
index 9faa52d..616fa5a 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -76,6 +76,7 @@ LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
S_ATARI := gui.c \
findfile.c \
filetype.c \
+ font.c \
misc.c \
bitmap.c \
schedule.c \
@@ -86,14 +87,13 @@ S_ATARI := gui.c \
treeview.c \
hotlist.c \
history.c\
- search.c font.c \
+ search.c \
redrawslots.c \
encoding.c \
rootwin.c \
toolbar.c \
statusbar.c \
browser.c \
- global_evnt.c \
osspec.c \
system_colour.c \
ctxmenu.c \
diff --git a/atari/browser.c b/atari/browser.c
index fb0e673..83fcb43 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -47,7 +47,6 @@
#include "atari/gui.h"
#include "atari/rootwin.h"
#include "atari/misc.h"
-#include "atari/global_evnt.h"
#include "atari/res/netsurf.rsh"
#include "atari/redrawslots.h"
#include "atari/browser.h"
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index 568d7a9..646a09c 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -7,8 +7,7 @@
#include "desktop/browser.h"
#include "desktop/browser_private.h"
#include "desktop/options.h"
-#include "desktop/save_complete.h"
-
+#include "desktop/save_complete.h"
#include "atari/res/netsurf.rsh"
#include "atari/gemtk/gemtk.h"
#include "atari/deskmenu.h"
@@ -19,8 +18,9 @@
#include "atari/search.h"
#include "atari/misc.h"
#include "atari/gui.h"
-#include "atari/findfile.h"
#include "atari/browser.h"
+#include "atari/findfile.h"
+
#include "atari/rootwin.h"
typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
@@ -364,7 +364,7 @@ static void __CDECL menu_stop(short item, short title, void *data)
if( input_window == NULL )
return;
- assert(input_window->root);
+ assert(input_window && input_window->root);
toolbar_stop_click(input_window->root->toolbar);
}
diff --git a/atari/gui.c b/atari/gui.c
index e4fd08c..165fff6 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -68,7 +68,6 @@
#include "atari/hotlist.h"
#include "atari/history.h"
#include "atari/login.h"
-#include "atari/global_evnt.h"
#include "atari/encoding.h"
#include "atari/res/netsurf.rsh"
#include "atari/plot/plot.h"
@@ -140,7 +139,7 @@ void gui_poll(bool active)
struct gui_window * g;
if( !active ) {
- if(input_window->root->redraw_slots.areas_used > 0){
+ if(input_window && input_window->root->redraw_slots.areas_used > 0){
window_process_redraws(input_window->root);
}
/* this suits for stuff with lower priority */
@@ -380,15 +379,6 @@ void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
area.g_w = rect->x1 - rect->x0;
area.g_h = rect->y1 - rect->y0;
window_schedule_redraw_grect(gw->root, &area);
-/*
- int x0 = rect->x0 - b->scroll.current.x;
- int y0 = rect->y0 - b->scroll.current.y;
- int w,h;
- */
- //w = rect->x1 - rect->x0;
- //h = rect->y1 - rect->y0;
-
- //browser_schedule_redraw_rect( gw, x0, y0, w, h );
}
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
@@ -443,7 +433,6 @@ void gui_window_update_extent(struct gui_window *gw)
);
window_update_back_forward(gw->root);
GRECT area;
- printf("update extent\n");
guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &area);
window_schedule_redraw_grect(gw->root, &area);
}
@@ -645,7 +634,6 @@ gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
g->icon = bmp_icon;
-
if(input_window == g){
window_set_icon(g->root, bmp_icon);
}
@@ -885,8 +873,6 @@ void gui_quit(void)
struct gui_window * gw = window_list;
struct gui_window * tmp = window_list;
- unbind_global_events();
-
while( gw ) {
tmp = gw->next;
browser_window_destroy(gw->browser->bw);
@@ -1091,7 +1077,6 @@ static void gui_init2(int argc, char** argv)
menu_register( _AESapid, (char*)" NetSurf ");
}
guiwin_init();
- bind_global_events();
global_history_init();
hotlist_init();
toolbar_init();
diff --git a/atari/misc.c b/atari/misc.c
index 60678dc..d0d4cd5 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -39,7 +39,7 @@
#include "content/fetch.h"
#include "atari/gui.h"
#include "atari/toolbar.h"
-#include "atari/browser.h"
+
#include "atari/misc.h"
#include "atari/encoding.h"
#include "atari/gemtk/gemtk.h"
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 5dcb47f..3a2af1c 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -45,12 +45,12 @@
#include "atari/gemtk/gemtk.h"
#include "atari/gui.h"
#include "atari/rootwin.h"
-#include "atari/browser.h"
+
#include "atari/misc.h"
#include "atari/plot/plot.h"
-#include "atari/global_evnt.h"
+
#include "atari/res/netsurf.rsh"
-#include "atari/browser.h"
+
#include "atari/toolbar.h"
#include "atari/statusbar.h"
#include "atari/search.h"
@@ -58,6 +58,7 @@
#include "atari/encoding.h"
#include "atari/redrawslots.h"
#include "atari/toolbar.h"
+#include "atari/browser.h"
#include "atari/gemtk/gemtk.h"
extern struct gui_window *input_window;
@@ -116,12 +117,6 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
on_resized(data->rootwin);
break;
- case WM_ICONIFY:
- if( input_window->root == data->rootwin) {
- input_window = NULL;
- }
- break;
-
case WM_TOPPED:
case WM_NEWTOP:
case WM_UNICONIFY:
@@ -132,6 +127,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
// TODO: this needs to iterate through all gui windows and
// check if the rootwin is this window...
if (data->rootwin->active_gui_window != NULL) {
+ printf("destroy...\n");
browser_window_destroy(
data->rootwin->active_gui_window->browser->bw);
}
@@ -490,6 +486,7 @@ void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp )
if (rootwin->icon != NULL) {
short info, dummy;
if (guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED) {
+ printf("set & redraw\n");
window_redraw_favicon(rootwin, NULL);
}
}
@@ -550,6 +547,8 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
assert(rootwin);
+ printf("window_redraw_favicon: root: %p, win: %p\n", rootwin, rootwin->win);
+
guiwin_clear(rootwin->win);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
@@ -562,6 +561,7 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
}
if (rootwin->icon == NULL) {
+ printf("window_redraw_favicon OBJCTREE\n");
OBJECT * tree = get_tree(ICONIFY);
tree->ob_x = work.g_x;
tree->ob_y = work.g_y;
@@ -570,6 +570,7 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
objc_draw(tree, 0, 8, clip->g_x, clip->g_y, clip->g_w, clip->g_h);
} else {
// TODO: consider the clipping rectangle
+ printf("window_redraw_favicon image %p\n", rootwin->icon);
struct rect work_clip = { 0,0,work.g_w,work.g_h };
int xoff=0;
if (work.g_w > work.g_h) {
diff --git a/atari/statusbar.c b/atari/statusbar.c
index d76cf63..bf241e2 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -40,7 +40,7 @@
#include "atari/statusbar.h"
#include "atari/rootwin.h"
#include "atari/misc.h"
-#include "atari/global_evnt.h"
+
#include "atari/res/netsurf.rsh"
#include "atari/plot/plot.h"
#include "atari/osspec.h"
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 40cee80..c6bd745 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -43,10 +43,10 @@
#include "atari/gui.h"
#include "atari/toolbar.h"
#include "atari/rootwin.h"
-#include "atari/browser.h"
+
#include "atari/clipboard.h"
#include "atari/misc.h"
-#include "atari/global_evnt.h"
+#include "atari/browser.h"
#include "atari/plot/plot.h"
#include "cflib.h"
#include "atari/res/netsurf.rsh"
@@ -54,7 +54,7 @@
#include "desktop/textarea.h"
#include "desktop/textinput.h"
#include "content/hlcache.h"
-#include "atari/browser.h"
+
#define TB_BUTTON_WIDTH 32
#define THROBBER_WIDTH 32
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/5d2ac2ecace0971ce27...
commit 5d2ac2ecace0971ce2737f4169b62b56a2ca3a2a
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Only schedule on-screen redraw areas, and do not substract
scrolling positions from scheduled area.
diff --git a/atari/gui.c b/atari/gui.c
index cecf15d..e4fd08c 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -375,9 +375,8 @@ void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
slid = guiwin_get_scroll_info(gw->root->win);
guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &area);
-
- area.g_x += rect->x0 - slid->x_pos * slid->x_unit_px;
- area.g_y += rect->y0 - slid->y_pos * slid->y_unit_px;
+ area.g_x += rect->x0;
+ area.g_y += rect->y0;
area.g_w = rect->x1 - rect->x0;
area.g_h = rect->y1 - rect->y0;
window_schedule_redraw_grect(gw->root, &area);
@@ -444,6 +443,7 @@ void gui_window_update_extent(struct gui_window *gw)
);
window_update_back_forward(gw->root);
GRECT area;
+ printf("update extent\n");
guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &area);
window_schedule_redraw_grect(gw->root, &area);
}
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 824317a..5dcb47f 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -596,7 +596,8 @@ void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area)
//dbg_grect("window_schedule_redraw_grect input ", area);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
- rc_intersect(area, &work);
+ if(!rc_intersect(area, &work))
+ return;
//dbg_grect("window_schedule_redraw_grect intersection ", &work);
-----------------------------------------------------------------------
Summary of changes:
atari/Makefile.target | 4 ++--
atari/browser.c | 1 -
atari/deskmenu.c | 8 ++++----
atari/gui.c | 21 +++------------------
atari/misc.c | 2 +-
atari/rootwin.c | 22 ++++++++++++----------
atari/statusbar.c | 2 +-
atari/toolbar.c | 6 +++---
8 files changed, 26 insertions(+), 40 deletions(-)
diff --git a/atari/Makefile.target b/atari/Makefile.target
index 9faa52d..616fa5a 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -76,6 +76,7 @@ LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
S_ATARI := gui.c \
findfile.c \
filetype.c \
+ font.c \
misc.c \
bitmap.c \
schedule.c \
@@ -86,14 +87,13 @@ S_ATARI := gui.c \
treeview.c \
hotlist.c \
history.c\
- search.c font.c \
+ search.c \
redrawslots.c \
encoding.c \
rootwin.c \
toolbar.c \
statusbar.c \
browser.c \
- global_evnt.c \
osspec.c \
system_colour.c \
ctxmenu.c \
diff --git a/atari/browser.c b/atari/browser.c
index fb0e673..83fcb43 100755
--- a/atari/browser.c
+++ b/atari/browser.c
@@ -47,7 +47,6 @@
#include "atari/gui.h"
#include "atari/rootwin.h"
#include "atari/misc.h"
-#include "atari/global_evnt.h"
#include "atari/res/netsurf.rsh"
#include "atari/redrawslots.h"
#include "atari/browser.h"
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index 568d7a9..646a09c 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -7,8 +7,7 @@
#include "desktop/browser.h"
#include "desktop/browser_private.h"
#include "desktop/options.h"
-#include "desktop/save_complete.h"
-
+#include "desktop/save_complete.h"
#include "atari/res/netsurf.rsh"
#include "atari/gemtk/gemtk.h"
#include "atari/deskmenu.h"
@@ -19,8 +18,9 @@
#include "atari/search.h"
#include "atari/misc.h"
#include "atari/gui.h"
-#include "atari/findfile.h"
#include "atari/browser.h"
+#include "atari/findfile.h"
+
#include "atari/rootwin.h"
typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
@@ -364,7 +364,7 @@ static void __CDECL menu_stop(short item, short title, void *data)
if( input_window == NULL )
return;
- assert(input_window->root);
+ assert(input_window && input_window->root);
toolbar_stop_click(input_window->root->toolbar);
}
diff --git a/atari/gui.c b/atari/gui.c
index cecf15d..165fff6 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -68,7 +68,6 @@
#include "atari/hotlist.h"
#include "atari/history.h"
#include "atari/login.h"
-#include "atari/global_evnt.h"
#include "atari/encoding.h"
#include "atari/res/netsurf.rsh"
#include "atari/plot/plot.h"
@@ -140,7 +139,7 @@ void gui_poll(bool active)
struct gui_window * g;
if( !active ) {
- if(input_window->root->redraw_slots.areas_used > 0){
+ if(input_window && input_window->root->redraw_slots.areas_used > 0){
window_process_redraws(input_window->root);
}
/* this suits for stuff with lower priority */
@@ -375,21 +374,11 @@ void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
slid = guiwin_get_scroll_info(gw->root->win);
guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &area);
-
- area.g_x += rect->x0 - slid->x_pos * slid->x_unit_px;
- area.g_y += rect->y0 - slid->y_pos * slid->y_unit_px;
+ area.g_x += rect->x0;
+ area.g_y += rect->y0;
area.g_w = rect->x1 - rect->x0;
area.g_h = rect->y1 - rect->y0;
window_schedule_redraw_grect(gw->root, &area);
-/*
- int x0 = rect->x0 - b->scroll.current.x;
- int y0 = rect->y0 - b->scroll.current.y;
- int w,h;
- */
- //w = rect->x1 - rect->x0;
- //h = rect->y1 - rect->y0;
-
- //browser_schedule_redraw_rect( gw, x0, y0, w, h );
}
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
@@ -645,7 +634,6 @@ gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
g->icon = bmp_icon;
-
if(input_window == g){
window_set_icon(g->root, bmp_icon);
}
@@ -885,8 +873,6 @@ void gui_quit(void)
struct gui_window * gw = window_list;
struct gui_window * tmp = window_list;
- unbind_global_events();
-
while( gw ) {
tmp = gw->next;
browser_window_destroy(gw->browser->bw);
@@ -1091,7 +1077,6 @@ static void gui_init2(int argc, char** argv)
menu_register( _AESapid, (char*)" NetSurf ");
}
guiwin_init();
- bind_global_events();
global_history_init();
hotlist_init();
toolbar_init();
diff --git a/atari/misc.c b/atari/misc.c
index 60678dc..d0d4cd5 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -39,7 +39,7 @@
#include "content/fetch.h"
#include "atari/gui.h"
#include "atari/toolbar.h"
-#include "atari/browser.h"
+
#include "atari/misc.h"
#include "atari/encoding.h"
#include "atari/gemtk/gemtk.h"
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 824317a..3a2af1c 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -45,12 +45,12 @@
#include "atari/gemtk/gemtk.h"
#include "atari/gui.h"
#include "atari/rootwin.h"
-#include "atari/browser.h"
+
#include "atari/misc.h"
#include "atari/plot/plot.h"
-#include "atari/global_evnt.h"
+
#include "atari/res/netsurf.rsh"
-#include "atari/browser.h"
+
#include "atari/toolbar.h"
#include "atari/statusbar.h"
#include "atari/search.h"
@@ -58,6 +58,7 @@
#include "atari/encoding.h"
#include "atari/redrawslots.h"
#include "atari/toolbar.h"
+#include "atari/browser.h"
#include "atari/gemtk/gemtk.h"
extern struct gui_window *input_window;
@@ -116,12 +117,6 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
on_resized(data->rootwin);
break;
- case WM_ICONIFY:
- if( input_window->root == data->rootwin) {
- input_window = NULL;
- }
- break;
-
case WM_TOPPED:
case WM_NEWTOP:
case WM_UNICONIFY:
@@ -132,6 +127,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
// TODO: this needs to iterate through all gui windows and
// check if the rootwin is this window...
if (data->rootwin->active_gui_window != NULL) {
+ printf("destroy...\n");
browser_window_destroy(
data->rootwin->active_gui_window->browser->bw);
}
@@ -490,6 +486,7 @@ void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp )
if (rootwin->icon != NULL) {
short info, dummy;
if (guiwin_get_state(rootwin->win) & GW_STATUS_ICONIFIED) {
+ printf("set & redraw\n");
window_redraw_favicon(rootwin, NULL);
}
}
@@ -550,6 +547,8 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
assert(rootwin);
+ printf("window_redraw_favicon: root: %p, win: %p\n", rootwin, rootwin->win);
+
guiwin_clear(rootwin->win);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
@@ -562,6 +561,7 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
}
if (rootwin->icon == NULL) {
+ printf("window_redraw_favicon OBJCTREE\n");
OBJECT * tree = get_tree(ICONIFY);
tree->ob_x = work.g_x;
tree->ob_y = work.g_y;
@@ -570,6 +570,7 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip)
objc_draw(tree, 0, 8, clip->g_x, clip->g_y, clip->g_w, clip->g_h);
} else {
// TODO: consider the clipping rectangle
+ printf("window_redraw_favicon image %p\n", rootwin->icon);
struct rect work_clip = { 0,0,work.g_w,work.g_h };
int xoff=0;
if (work.g_w > work.g_h) {
@@ -596,7 +597,8 @@ void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area)
//dbg_grect("window_schedule_redraw_grect input ", area);
guiwin_get_grect(rootwin->win, GUIWIN_AREA_WORK, &work);
- rc_intersect(area, &work);
+ if(!rc_intersect(area, &work))
+ return;
//dbg_grect("window_schedule_redraw_grect intersection ", &work);
diff --git a/atari/statusbar.c b/atari/statusbar.c
index d76cf63..bf241e2 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -40,7 +40,7 @@
#include "atari/statusbar.h"
#include "atari/rootwin.h"
#include "atari/misc.h"
-#include "atari/global_evnt.h"
+
#include "atari/res/netsurf.rsh"
#include "atari/plot/plot.h"
#include "atari/osspec.h"
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 40cee80..c6bd745 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -43,10 +43,10 @@
#include "atari/gui.h"
#include "atari/toolbar.h"
#include "atari/rootwin.h"
-#include "atari/browser.h"
+
#include "atari/clipboard.h"
#include "atari/misc.h"
-#include "atari/global_evnt.h"
+#include "atari/browser.h"
#include "atari/plot/plot.h"
#include "cflib.h"
#include "atari/res/netsurf.rsh"
@@ -54,7 +54,7 @@
#include "desktop/textarea.h"
#include "desktop/textinput.h"
#include "content/hlcache.h"
-#include "atari/browser.h"
+
#define TB_BUTTON_WIDTH 32
#define THROBBER_WIDTH 32
--
NetSurf Browser
10 years, 3 months
netsurf: branch mono/removing-windom-dependency updated. 395f161eb520b7d1b662966f03919a7eeca29fe3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/395f161eb520b7d1b6629...
...commit http://git.netsurf-browser.org/netsurf.git/commit/395f161eb520b7d1b662966...
...tree http://git.netsurf-browser.org/netsurf.git/tree/395f161eb520b7d1b662966f0...
The branch, mono/removing-windom-dependency has been updated
via 395f161eb520b7d1b662966f03919a7eeca29fe3 (commit)
via fa0326af43f132e01ea715652c0ba59787723321 (commit)
via 434befd25b116286766732891f8eb83600f2b3bd (commit)
via 16812b0522a94adf22b868d303cbecb706af06cd (commit)
from f4ea103657f79f3ddf111789d8be98fcab5a54e0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/395f161eb520b7d1b66...
commit 395f161eb520b7d1b662966f03919a7eeca29fe3
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Use global variable desk_area for size calculation
diff --git a/atari/history.c b/atari/history.c
index 6e84ad3..e7db74b 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -39,6 +39,7 @@
#include "atari/history.h"
extern char * tree_directory_icon_name;
+extern GRECT desk_area;
struct s_atari_global_history gl_history;
@@ -51,11 +52,11 @@ void global_history_open( void )
if( gl_history.open == false ) {
GRECT pos;
- wind_get_grect(0, WF_FULLXYWH, &pos);
- pos.g_x = pos.g_w - pos.g_w / 4;
- pos.g_y = pos.g_y;
- pos.g_w = pos.g_w / 4;
- pos.g_h = pos.g_h;
+ wind_get_grect(0, WF_WORKXYWH, &pos);
+ pos.g_x = desk_area.g_w - desk_area.g_w / 4;
+ pos.g_y = desk_area.g_y;
+ pos.g_w = desk_area.g_w / 4;
+ pos.g_h = desk_area.g_h;
wind_open(guiwin_get_handle(gl_history.window), pos.g_x, pos.g_y,
pos.g_w, pos.g_h);
@@ -103,10 +104,8 @@ bool global_history_init( void )
GRECT desk;
int flags = ATARI_TREEVIEW_WIDGETS;
- wind_get_grect(0, WF_FULLXYWH, &desk);
-
gl_history.open = false;
- handle = wind_create(flags, 40, 40, desk.g_w, desk.g_h);
+ handle = wind_create(flags, 40, 40, desk_area.g_w, desk_area.g_h);
gl_history.window = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL);
if( gl_history.window == NULL ) {
LOG(("Failed to allocate history window"));
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 72d3445..f79a161 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -44,6 +44,8 @@
#include "atari/gemtk/gemtk.h"
#include "atari/res/netsurf.rsh"
+extern GRECT desk_area;
+
struct atari_hotlist hl;
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
@@ -115,9 +117,7 @@ void hotlist_init(void)
assert( tree );
hl.open = false;
- wind_get_grect(0, WF_FULLXYWH, &desk);
-
- handle = wind_create(flags, 0, 0, desk.g_w, desk.g_h);
+ handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
hl.window = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL);
if( hl.window == NULL ) {
LOG(("Failed to allocate Hotlist"));
@@ -158,11 +158,10 @@ void hotlist_open(void)
if( hl.open == false ) {
GRECT pos;
- wind_get_grect(0, WF_FULLXYWH, &pos);
- pos.g_x = pos.g_w - pos.g_w / 4;
- pos.g_y = pos.g_y;
- pos.g_w = pos.g_w / 4;
- pos.g_h = pos.g_h;
+ pos.g_x = desk_area.g_w - desk_area.g_w / 4;
+ pos.g_y = desk_area.g_y;
+ pos.g_w = desk_area.g_w / 4;
+ pos.g_h = desk_area.g_h;
wind_open_grect(guiwin_get_handle(hl.window), &pos);
hl.open = true;
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/fa0326af43f132e01ea...
commit fa0326af43f132e01ea715652c0ba59787723321
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Context menu now opens at the correct location.
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index 66c4b7f..c9189af 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -75,7 +75,7 @@ static struct s_context_info * get_context_info( struct gui_window * gw, short m
h = bw->current_content;
ctxinfo.flags = 0;
- browser_get_rect( gw, BR_CONTENT, &bwrect );
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &bwrect);
mx -= bwrect.g_x;
my -= bwrect.g_y;
if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) ){
@@ -109,7 +109,7 @@ static struct s_context_info * get_context_info( struct gui_window * gw, short m
return( &ctxinfo );
}
-void context_popup( struct gui_window * gw, short x, short y )
+void context_popup(struct gui_window * gw, short x, short y)
{
#define POP_FIRST_ITEM POP_CTX_CUT_SEL
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/434befd25b116286766...
commit 434befd25b116286766732891f8eb83600f2b3bd
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Implement mouse move event handling
diff --git a/atari/gui.c b/atari/gui.c
index 80e98c2..cecf15d 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -87,6 +87,7 @@ void * h_gem_rsrc;
long next_poll;
bool rendering = false;
bool gui_poll_repeat = false;
+GRECT desk_area;
/* Comandline / Options: */
@@ -102,7 +103,7 @@ const char * option_homepage_url;
char options[PATH_MAX];
EVMULT_IN aes_event_in = {
- .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON,
+ .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON | MU_M1,
.emi_bclicks = 258,
.emi_bmask = 3,
.emi_bstate = 0,
@@ -120,7 +121,7 @@ short aes_msg_out[8];
void gui_poll(bool active)
{
- int flags = MU_MESAG | MU_KEYBD | MU_BUTTON | MU_M1 | MU_MX;
+
short mx, my, dummy;
unsigned short nkc = 0;
@@ -131,25 +132,17 @@ void gui_poll(bool active)
if(active || rendering)
aes_event_in.emi_tlow = 0;
- struct gui_window * g;
-
- if(input_window->root->redraw_slots.areas_used > 0){
- window_process_redraws(input_window->root);
- }
+ if(aes_event_in.emi_tlow < 0){
+ aes_event_in.emi_tlow = 10000;
+ printf("long poll!\n");
+ }
-// for( g = window_list; g != NULL; g=g->next ) {
-// if( browser_redraw_required( g ) ) {
-// browser_redraw(g);
-// }
-// if(g->root->toolbar) {
-// //if(g->root->toolbar->url.redraw ) {
-// // TODO: implement toolbar redraw mechanism
-// //tb_url_redraw( g );
-// //}
-// }
-// }
+ struct gui_window * g;
if( !active ) {
+ if(input_window->root->redraw_slots.areas_used > 0){
+ window_process_redraws(input_window->root);
+ }
/* this suits for stuff with lower priority */
/* TBD: really be spare on redraws??? */
hotlist_redraw();
@@ -158,39 +151,43 @@ void gui_poll(bool active)
// Handle events until there are no more messages pending or
// until the engine indicates activity:
- do {
- evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
- if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
- if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
- LOG(("WM: %d\n", aes_msg_out[0]));
- switch(aes_msg_out[0]) {
-
- case MN_SELECTED:
- LOG(("Menu Item: %d\n",aes_msg_out[4]));
- deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
- break;
- default:
- break;
+ if(!(active || rendering) || (clock() >= next_poll)){
+ do {
+ short mx, my, dummy;
+
+ graf_mkstate(&mx, &my, &dummy, &dummy);
+ aes_event_in.emi_m1.g_x = mx;
+ aes_event_in.emi_m1.g_y = my;
+ evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
+ if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
+ if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
+ LOG(("WM: %d\n", aes_msg_out[0]));
+ switch(aes_msg_out[0]) {
+
+ case MN_SELECTED:
+ LOG(("Menu Item: %d\n",aes_msg_out[4]));
+ deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
+ break;
+ default:
+ break;
+ }
}
- }
- if((aes_event_out.emo_events & MU_KEYBD) != 0) {
- uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
- (short)aes_event_out.emo_kreturn);
- deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
- aes_event_out.emo_kmeta, nkc);
- }
-/*
- if((aes_event_out.emo_events & MU_KEYBD|MU_MX) != 0) {
- on_m1();
+ if((aes_event_out.emo_events & MU_KEYBD) != 0) {
+ uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
+ (short)aes_event_out.emo_kreturn);
+ deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta, nkc);
+ }
}
-*/
+ } while ( gui_poll_repeat && !(active||rendering));
+ if(input_window && input_window->root->redraw_slots.areas_used > 0 && !active){
+ window_process_redraws(input_window->root);
}
- } while ( gui_poll_repeat && !(active||rendering));
+ if(active || rendering)
+ next_poll = clock() + (CLOCKS_PER_SEC>>3);
+ }
- if(input_window && input_window->root->redraw_slots.areas_used > 0){
- window_process_redraws(input_window->root);
- }
}
@@ -1076,7 +1073,13 @@ static void gui_init(int argc, char** argv)
nkc_init();
plot_init(nsoption_charp(atari_font_driver));
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+ tree_set_icon_dir(nsoption_charp(tree_icons_path));
+
+ wind_get_grect(0, WF_WORKXYWH, &desk_area);
+ aes_event_in.emi_m1leave = MO_LEAVE;
+ aes_event_in.emi_m1.g_w = 1;
+ aes_event_in.emi_m1.g_h = 1;
+
}
static char *theapp = (char*)"NetSurf";
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 7da38d6..824317a 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -68,13 +68,14 @@ struct rootwin_data_s {
};
/* -------------------------------------------------------------------------- */
-/* Static module methods */
+/* Static module event handlers */
/* -------------------------------------------------------------------------- */
static void on_redraw(ROOTWIN *rootwin, short msg[8]);
static void on_resized(ROOTWIN *rootwin);
static void on_file_dropped(ROOTWIN *rootwin, short msg[8]);
static short on_window_key_input(ROOTWIN * rootwin, unsigned short nkc);
static bool on_content_mouse_click(ROOTWIN *rootwin);
+static bool on_content_mouse_move(ROOTWIN *rootwin, GRECT *content_area);
static bool redraw_active = false;
@@ -92,8 +93,13 @@ static const struct redraw_context rootwin_rdrw_ctx = {
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
short retval = 0;
+ GRECT content_area;
+ static bool prev_url = false;
+ static short prev_x=0;
+ static short prev_y=0;
struct rootwin_data_s * data = guiwin_get_user_data(win);
+
if ((ev_out->emo_events & MU_MESAG) != 0) {
// handle message
//printf("root win msg: %d\n", msg[0]);
@@ -152,17 +158,43 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
if ((ev_out->emo_events & MU_BUTTON) != 0) {
- LOG(("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y));
- GRECT carea;
- guiwin_get_grect(data->rootwin->win, GUIWIN_AREA_CONTENT, &carea);
- if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y, carea)) {
+ guiwin_get_grect(data->rootwin->win, GUIWIN_AREA_CONTENT,
+ &content_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
+ content_area)) {
on_content_mouse_click(data->rootwin);
}
}
- if ((ev_out->emo_events & (MU_M1 | MU_MX)) != 0) {
- printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
+ if ((ev_out->emo_events & (MU_M1)) != 0) {
+
+ short ghandle = wind_find(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y);
+
+ if (guiwin_get_handle(data->rootwin->win)==ghandle) {
+ // The window found at x,y is an gui_window
+ // and it's the input window.
+ window_get_grect(data->rootwin, BROWSER_AREA_CONTENT,
+ &content_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
+ content_area)) {
+ on_content_mouse_move(data->rootwin, &content_area);
+ } else {
+ GRECT tb_area;
+ window_get_grect(data->rootwin, BROWSER_AREA_URL_INPUT, &tb_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
+ tb_area)) {
+ gem_set_cursor(&gem_cursors.ibeam);
+ prev_url = true;
+ }
+ else {
+ if(prev_url) {
+ struct gui_window *gw;
+ gw = window_get_active_gui_window(data->rootwin);
+ gem_set_cursor(gw->cursor);
+ prev_url = false;
+ }
+ }
+ }
+ }
}
return(retval);
@@ -494,6 +526,20 @@ void window_get_scroll(ROOTWIN *rootwin, int *x, int *y)
*y = slid->y_pos * slid->y_unit_px;
}
+void window_get_grect(ROOTWIN *rootwin, enum browser_area_e which, GRECT *d)
+{
+ if (which == BROWSER_AREA_TOOLBAR) {
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, d);
+ } else if (which == BROWSER_AREA_CONTENT) {
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, d);
+ } else if (which == BROWSER_AREA_URL_INPUT) {
+ toolbar_get_grect(rootwin->toolbar, TOOLBAR_URL_AREA, d);
+ } else {
+
+ }
+
+}
+
/**
* Redraw the favicon
@@ -682,6 +728,27 @@ void window_process_redraws(ROOTWIN * rootwin)
/* -------------------------------------------------------------------------- */
/* Event Handlers: */
/* -------------------------------------------------------------------------- */
+static bool on_content_mouse_move(ROOTWIN *rootwin, GRECT *content_area)
+{
+ int mx, my, sx, sy;
+ struct guiwin_scroll_info_s *slid;
+ struct gui_window *gw;
+ struct browser_window *bw;
+
+ // make relative mouse coords:
+ mx = aes_event_out.emo_mouse.p_x - content_area->g_x;
+ my = aes_event_out.emo_mouse.p_y - content_area->g_y;
+
+ slid = guiwin_get_scroll_info(rootwin->win);
+ gw = window_get_active_gui_window(rootwin);
+ bw = gw->browser->bw;
+
+ // calculate scroll pos. in pixel:
+ sx = slid->x_pos * slid->x_unit_px;
+ sy = slid->y_pos * slid->y_unit_px;
+
+ browser_window_mouse_track(bw, 0, mx + sx, my + sy);
+}
static bool on_content_mouse_click(ROOTWIN *rootwin)
{
@@ -776,8 +843,8 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
} else {
/* Right button pressed? */
if ((aes_event_out.emo_mbutton & 2 ) ) {
- context_popup( gw, aes_event_out.emo_mouse.p_x,
- aes_event_out.emo_mouse.p_x);
+ context_popup(gw, aes_event_out.emo_mouse.p_x,
+ aes_event_out.emo_mouse.p_y);
} else {
browser_window_mouse_click(gw->browser->bw,
bmstate|BROWSER_MOUSE_PRESS_1,
diff --git a/atari/rootwin.h b/atari/rootwin.h
index 7eb5539..5f42a18 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -28,10 +28,15 @@
#define WIDGET_TOOLBAR 0x2
#define WIDGET_SCROLL 0x4
#define WIDGET_RESIZE 0x8
-
#define WIN_TOP 0x100
+
+enum browser_area_e {
+ BROWSER_AREA_CONTENT = 1,
+ BROWSER_AREA_STATUSBAR,
+ BROWSER_AREA_TOOLBAR,
+ BROWSER_AREA_URL_INPUT
+};
-/* WinDom & Custom bindings for gui window */
/* -------------------------------------------------------------------------- */
/* Public module functions: */
@@ -70,6 +75,7 @@ void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area);
void window_process_redraws(ROOTWIN * rootwin);
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
void window_get_scroll(ROOTWIN *rootwin, int *x, int *y);
+void window_get_grect(ROOTWIN *rootwin, enum browser_area_e which, GRECT *d);
void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
bool window_key_input(unsigned short kcode, unsigned short kstate,
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/16812b0522a94adf22b...
commit 16812b0522a94adf22b868d303cbecb706af06cd
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Removed debug statements.
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 056a85d..7da38d6 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -741,7 +741,6 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
rel_cur_x + slid->x_pos * slid->x_unit_px,
rel_cur_y + slid->y_pos * slid->y_unit_px);
do {
- printf("rel click coords: %d,%d\n", rel_cur_x, rel_cur_y);
// only consider movements of 5px or more as drag...:
if( abs(prev_x-rel_cur_x) > 5 || abs(prev_y-rel_cur_y) > 5 ) {
browser_window_mouse_track( gw->browser->bw,
@@ -751,10 +750,8 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
prev_x = rel_cur_x;
prev_y = rel_cur_y;
dragmode = true;
- printf("now dragmode is true...\n");
} else {
if( dragmode == false ) {
- printf("dragmode = false\n");
browser_window_mouse_track( gw->browser->bw,BROWSER_MOUSE_PRESS_1,
rel_cur_x + slid->x_pos * slid->x_unit_px,
rel_cur_y + slid->y_pos * slid->y_unit_px);
-----------------------------------------------------------------------
Summary of changes:
atari/ctxmenu.c | 4 +-
atari/gui.c | 97 ++++++++++++++++++++++++++++--------------------------
atari/history.c | 15 ++++----
atari/hotlist.c | 15 ++++----
atari/rootwin.c | 92 ++++++++++++++++++++++++++++++++++++++++++++--------
atari/rootwin.h | 10 ++++-
6 files changed, 152 insertions(+), 81 deletions(-)
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index 66c4b7f..c9189af 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -75,7 +75,7 @@ static struct s_context_info * get_context_info( struct gui_window * gw, short m
h = bw->current_content;
ctxinfo.flags = 0;
- browser_get_rect( gw, BR_CONTENT, &bwrect );
+ guiwin_get_grect(gw->root->win, GUIWIN_AREA_CONTENT, &bwrect);
mx -= bwrect.g_x;
my -= bwrect.g_y;
if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) ){
@@ -109,7 +109,7 @@ static struct s_context_info * get_context_info( struct gui_window * gw, short m
return( &ctxinfo );
}
-void context_popup( struct gui_window * gw, short x, short y )
+void context_popup(struct gui_window * gw, short x, short y)
{
#define POP_FIRST_ITEM POP_CTX_CUT_SEL
diff --git a/atari/gui.c b/atari/gui.c
index 80e98c2..cecf15d 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -87,6 +87,7 @@ void * h_gem_rsrc;
long next_poll;
bool rendering = false;
bool gui_poll_repeat = false;
+GRECT desk_area;
/* Comandline / Options: */
@@ -102,7 +103,7 @@ const char * option_homepage_url;
char options[PATH_MAX];
EVMULT_IN aes_event_in = {
- .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON,
+ .emi_flags = MU_MESAG | MU_TIMER | MU_KEYBD | MU_BUTTON | MU_M1,
.emi_bclicks = 258,
.emi_bmask = 3,
.emi_bstate = 0,
@@ -120,7 +121,7 @@ short aes_msg_out[8];
void gui_poll(bool active)
{
- int flags = MU_MESAG | MU_KEYBD | MU_BUTTON | MU_M1 | MU_MX;
+
short mx, my, dummy;
unsigned short nkc = 0;
@@ -131,25 +132,17 @@ void gui_poll(bool active)
if(active || rendering)
aes_event_in.emi_tlow = 0;
- struct gui_window * g;
-
- if(input_window->root->redraw_slots.areas_used > 0){
- window_process_redraws(input_window->root);
- }
+ if(aes_event_in.emi_tlow < 0){
+ aes_event_in.emi_tlow = 10000;
+ printf("long poll!\n");
+ }
-// for( g = window_list; g != NULL; g=g->next ) {
-// if( browser_redraw_required( g ) ) {
-// browser_redraw(g);
-// }
-// if(g->root->toolbar) {
-// //if(g->root->toolbar->url.redraw ) {
-// // TODO: implement toolbar redraw mechanism
-// //tb_url_redraw( g );
-// //}
-// }
-// }
+ struct gui_window * g;
if( !active ) {
+ if(input_window->root->redraw_slots.areas_used > 0){
+ window_process_redraws(input_window->root);
+ }
/* this suits for stuff with lower priority */
/* TBD: really be spare on redraws??? */
hotlist_redraw();
@@ -158,39 +151,43 @@ void gui_poll(bool active)
// Handle events until there are no more messages pending or
// until the engine indicates activity:
- do {
- evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
- if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
- if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
- LOG(("WM: %d\n", aes_msg_out[0]));
- switch(aes_msg_out[0]) {
-
- case MN_SELECTED:
- LOG(("Menu Item: %d\n",aes_msg_out[4]));
- deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
- break;
- default:
- break;
+ if(!(active || rendering) || (clock() >= next_poll)){
+ do {
+ short mx, my, dummy;
+
+ graf_mkstate(&mx, &my, &dummy, &dummy);
+ aes_event_in.emi_m1.g_x = mx;
+ aes_event_in.emi_m1.g_y = my;
+ evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
+ if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
+ if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
+ LOG(("WM: %d\n", aes_msg_out[0]));
+ switch(aes_msg_out[0]) {
+
+ case MN_SELECTED:
+ LOG(("Menu Item: %d\n",aes_msg_out[4]));
+ deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
+ break;
+ default:
+ break;
+ }
}
- }
- if((aes_event_out.emo_events & MU_KEYBD) != 0) {
- uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
- (short)aes_event_out.emo_kreturn);
- deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
- aes_event_out.emo_kmeta, nkc);
- }
-/*
- if((aes_event_out.emo_events & MU_KEYBD|MU_MX) != 0) {
- on_m1();
+ if((aes_event_out.emo_events & MU_KEYBD) != 0) {
+ uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta,
+ (short)aes_event_out.emo_kreturn);
+ deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta, nkc);
+ }
}
-*/
+ } while ( gui_poll_repeat && !(active||rendering));
+ if(input_window && input_window->root->redraw_slots.areas_used > 0 && !active){
+ window_process_redraws(input_window->root);
}
- } while ( gui_poll_repeat && !(active||rendering));
+ if(active || rendering)
+ next_poll = clock() + (CLOCKS_PER_SEC>>3);
+ }
- if(input_window && input_window->root->redraw_slots.areas_used > 0){
- window_process_redraws(input_window->root);
- }
}
@@ -1076,7 +1073,13 @@ static void gui_init(int argc, char** argv)
nkc_init();
plot_init(nsoption_charp(atari_font_driver));
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+ tree_set_icon_dir(nsoption_charp(tree_icons_path));
+
+ wind_get_grect(0, WF_WORKXYWH, &desk_area);
+ aes_event_in.emi_m1leave = MO_LEAVE;
+ aes_event_in.emi_m1.g_w = 1;
+ aes_event_in.emi_m1.g_h = 1;
+
}
static char *theapp = (char*)"NetSurf";
diff --git a/atari/history.c b/atari/history.c
index 6e84ad3..e7db74b 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -39,6 +39,7 @@
#include "atari/history.h"
extern char * tree_directory_icon_name;
+extern GRECT desk_area;
struct s_atari_global_history gl_history;
@@ -51,11 +52,11 @@ void global_history_open( void )
if( gl_history.open == false ) {
GRECT pos;
- wind_get_grect(0, WF_FULLXYWH, &pos);
- pos.g_x = pos.g_w - pos.g_w / 4;
- pos.g_y = pos.g_y;
- pos.g_w = pos.g_w / 4;
- pos.g_h = pos.g_h;
+ wind_get_grect(0, WF_WORKXYWH, &pos);
+ pos.g_x = desk_area.g_w - desk_area.g_w / 4;
+ pos.g_y = desk_area.g_y;
+ pos.g_w = desk_area.g_w / 4;
+ pos.g_h = desk_area.g_h;
wind_open(guiwin_get_handle(gl_history.window), pos.g_x, pos.g_y,
pos.g_w, pos.g_h);
@@ -103,10 +104,8 @@ bool global_history_init( void )
GRECT desk;
int flags = ATARI_TREEVIEW_WIDGETS;
- wind_get_grect(0, WF_FULLXYWH, &desk);
-
gl_history.open = false;
- handle = wind_create(flags, 40, 40, desk.g_w, desk.g_h);
+ handle = wind_create(flags, 40, 40, desk_area.g_w, desk_area.g_h);
gl_history.window = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL);
if( gl_history.window == NULL ) {
LOG(("Failed to allocate history window"));
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 72d3445..f79a161 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -44,6 +44,8 @@
#include "atari/gemtk/gemtk.h"
#include "atari/res/netsurf.rsh"
+extern GRECT desk_area;
+
struct atari_hotlist hl;
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
@@ -115,9 +117,7 @@ void hotlist_init(void)
assert( tree );
hl.open = false;
- wind_get_grect(0, WF_FULLXYWH, &desk);
-
- handle = wind_create(flags, 0, 0, desk.g_w, desk.g_h);
+ handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
hl.window = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL);
if( hl.window == NULL ) {
LOG(("Failed to allocate Hotlist"));
@@ -158,11 +158,10 @@ void hotlist_open(void)
if( hl.open == false ) {
GRECT pos;
- wind_get_grect(0, WF_FULLXYWH, &pos);
- pos.g_x = pos.g_w - pos.g_w / 4;
- pos.g_y = pos.g_y;
- pos.g_w = pos.g_w / 4;
- pos.g_h = pos.g_h;
+ pos.g_x = desk_area.g_w - desk_area.g_w / 4;
+ pos.g_y = desk_area.g_y;
+ pos.g_w = desk_area.g_w / 4;
+ pos.g_h = desk_area.g_h;
wind_open_grect(guiwin_get_handle(hl.window), &pos);
hl.open = true;
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 056a85d..824317a 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -68,13 +68,14 @@ struct rootwin_data_s {
};
/* -------------------------------------------------------------------------- */
-/* Static module methods */
+/* Static module event handlers */
/* -------------------------------------------------------------------------- */
static void on_redraw(ROOTWIN *rootwin, short msg[8]);
static void on_resized(ROOTWIN *rootwin);
static void on_file_dropped(ROOTWIN *rootwin, short msg[8]);
static short on_window_key_input(ROOTWIN * rootwin, unsigned short nkc);
static bool on_content_mouse_click(ROOTWIN *rootwin);
+static bool on_content_mouse_move(ROOTWIN *rootwin, GRECT *content_area);
static bool redraw_active = false;
@@ -92,8 +93,13 @@ static const struct redraw_context rootwin_rdrw_ctx = {
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
short retval = 0;
+ GRECT content_area;
+ static bool prev_url = false;
+ static short prev_x=0;
+ static short prev_y=0;
struct rootwin_data_s * data = guiwin_get_user_data(win);
+
if ((ev_out->emo_events & MU_MESAG) != 0) {
// handle message
//printf("root win msg: %d\n", msg[0]);
@@ -152,17 +158,43 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
if ((ev_out->emo_events & MU_BUTTON) != 0) {
- LOG(("Mouse click at: %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y));
- GRECT carea;
- guiwin_get_grect(data->rootwin->win, GUIWIN_AREA_CONTENT, &carea);
- if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y, carea)) {
+ guiwin_get_grect(data->rootwin->win, GUIWIN_AREA_CONTENT,
+ &content_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
+ content_area)) {
on_content_mouse_click(data->rootwin);
}
}
- if ((ev_out->emo_events & (MU_M1 | MU_MX)) != 0) {
- printf("mx event at %d,%d\n", ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
+ if ((ev_out->emo_events & (MU_M1)) != 0) {
+
+ short ghandle = wind_find(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y);
+
+ if (guiwin_get_handle(data->rootwin->win)==ghandle) {
+ // The window found at x,y is an gui_window
+ // and it's the input window.
+ window_get_grect(data->rootwin, BROWSER_AREA_CONTENT,
+ &content_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
+ content_area)) {
+ on_content_mouse_move(data->rootwin, &content_area);
+ } else {
+ GRECT tb_area;
+ window_get_grect(data->rootwin, BROWSER_AREA_URL_INPUT, &tb_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
+ tb_area)) {
+ gem_set_cursor(&gem_cursors.ibeam);
+ prev_url = true;
+ }
+ else {
+ if(prev_url) {
+ struct gui_window *gw;
+ gw = window_get_active_gui_window(data->rootwin);
+ gem_set_cursor(gw->cursor);
+ prev_url = false;
+ }
+ }
+ }
+ }
}
return(retval);
@@ -494,6 +526,20 @@ void window_get_scroll(ROOTWIN *rootwin, int *x, int *y)
*y = slid->y_pos * slid->y_unit_px;
}
+void window_get_grect(ROOTWIN *rootwin, enum browser_area_e which, GRECT *d)
+{
+ if (which == BROWSER_AREA_TOOLBAR) {
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_TOOLBAR, d);
+ } else if (which == BROWSER_AREA_CONTENT) {
+ guiwin_get_grect(rootwin->win, GUIWIN_AREA_CONTENT, d);
+ } else if (which == BROWSER_AREA_URL_INPUT) {
+ toolbar_get_grect(rootwin->toolbar, TOOLBAR_URL_AREA, d);
+ } else {
+
+ }
+
+}
+
/**
* Redraw the favicon
@@ -682,6 +728,27 @@ void window_process_redraws(ROOTWIN * rootwin)
/* -------------------------------------------------------------------------- */
/* Event Handlers: */
/* -------------------------------------------------------------------------- */
+static bool on_content_mouse_move(ROOTWIN *rootwin, GRECT *content_area)
+{
+ int mx, my, sx, sy;
+ struct guiwin_scroll_info_s *slid;
+ struct gui_window *gw;
+ struct browser_window *bw;
+
+ // make relative mouse coords:
+ mx = aes_event_out.emo_mouse.p_x - content_area->g_x;
+ my = aes_event_out.emo_mouse.p_y - content_area->g_y;
+
+ slid = guiwin_get_scroll_info(rootwin->win);
+ gw = window_get_active_gui_window(rootwin);
+ bw = gw->browser->bw;
+
+ // calculate scroll pos. in pixel:
+ sx = slid->x_pos * slid->x_unit_px;
+ sy = slid->y_pos * slid->y_unit_px;
+
+ browser_window_mouse_track(bw, 0, mx + sx, my + sy);
+}
static bool on_content_mouse_click(ROOTWIN *rootwin)
{
@@ -741,7 +808,6 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
rel_cur_x + slid->x_pos * slid->x_unit_px,
rel_cur_y + slid->y_pos * slid->y_unit_px);
do {
- printf("rel click coords: %d,%d\n", rel_cur_x, rel_cur_y);
// only consider movements of 5px or more as drag...:
if( abs(prev_x-rel_cur_x) > 5 || abs(prev_y-rel_cur_y) > 5 ) {
browser_window_mouse_track( gw->browser->bw,
@@ -751,10 +817,8 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
prev_x = rel_cur_x;
prev_y = rel_cur_y;
dragmode = true;
- printf("now dragmode is true...\n");
} else {
if( dragmode == false ) {
- printf("dragmode = false\n");
browser_window_mouse_track( gw->browser->bw,BROWSER_MOUSE_PRESS_1,
rel_cur_x + slid->x_pos * slid->x_unit_px,
rel_cur_y + slid->y_pos * slid->y_unit_px);
@@ -779,8 +843,8 @@ static bool on_content_mouse_click(ROOTWIN *rootwin)
} else {
/* Right button pressed? */
if ((aes_event_out.emo_mbutton & 2 ) ) {
- context_popup( gw, aes_event_out.emo_mouse.p_x,
- aes_event_out.emo_mouse.p_x);
+ context_popup(gw, aes_event_out.emo_mouse.p_x,
+ aes_event_out.emo_mouse.p_y);
} else {
browser_window_mouse_click(gw->browser->bw,
bmstate|BROWSER_MOUSE_PRESS_1,
diff --git a/atari/rootwin.h b/atari/rootwin.h
index 7eb5539..5f42a18 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -28,10 +28,15 @@
#define WIDGET_TOOLBAR 0x2
#define WIDGET_SCROLL 0x4
#define WIDGET_RESIZE 0x8
-
#define WIN_TOP 0x100
+
+enum browser_area_e {
+ BROWSER_AREA_CONTENT = 1,
+ BROWSER_AREA_STATUSBAR,
+ BROWSER_AREA_TOOLBAR,
+ BROWSER_AREA_URL_INPUT
+};
-/* WinDom & Custom bindings for gui window */
/* -------------------------------------------------------------------------- */
/* Public module functions: */
@@ -70,6 +75,7 @@ void window_schedule_redraw_grect(ROOTWIN *rootwin, GRECT *area);
void window_process_redraws(ROOTWIN * rootwin);
struct gui_window * window_get_active_gui_window(ROOTWIN * rootwin);
void window_get_scroll(ROOTWIN *rootwin, int *x, int *y);
+void window_get_grect(ROOTWIN *rootwin, enum browser_area_e which, GRECT *d);
void window_redraw_favicon(struct s_gui_win_root * rootwin, GRECT *clip);
void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw);
bool window_key_input(unsigned short kcode, unsigned short kstate,
--
NetSurf Browser
10 years, 3 months
netsurf: branch master updated. 61723e01c1beed8591d877c92035b65c448f46df
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/61723e01c1beed8591d87...
...commit http://git.netsurf-browser.org/netsurf.git/commit/61723e01c1beed8591d877c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/61723e01c1beed8591d877c92...
The branch, master has been updated
via 61723e01c1beed8591d877c92035b65c448f46df (commit)
from 0718d809180b1bff9c83f4475be4cb918a8564e2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/61723e01c1beed8591d...
commit 61723e01c1beed8591d877c92035b65c448f46df
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Avoid NULL pointer access
diff --git a/amiga/gui.c b/amiga/gui.c
index 9fa83e1..c71afde 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -2518,7 +2518,7 @@ void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
gwin->win, NULL, TRUE);
- if(gwin->win) {
+ if(gwin->bw) {
gwin->redraw_required = true;
gwin->bw->reformat_pending = true;
}
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index 9fa83e1..c71afde 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -2518,7 +2518,7 @@ void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
gwin->win, NULL, TRUE);
- if(gwin->win) {
+ if(gwin->bw) {
gwin->redraw_required = true;
gwin->bw->reformat_pending = true;
}
--
NetSurf Browser
10 years, 3 months
netsurf: branch master updated. 0718d809180b1bff9c83f4475be4cb918a8564e2
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/0718d809180b1bff9c83f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/0718d809180b1bff9c83f44...
...tree http://git.netsurf-browser.org/netsurf.git/tree/0718d809180b1bff9c83f4475...
The branch, master has been updated
via 0718d809180b1bff9c83f4475be4cb918a8564e2 (commit)
from 897acff532415ed81f9066b8b811ae744918da84 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/0718d809180b1bff9c8...
commit 0718d809180b1bff9c83f4475be4cb918a8564e2
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
abstract out GC root manipulation for js values
diff --git a/javascript/jsapi.c b/javascript/jsapi.c
index eebb33f..73153fe 100644
--- a/javascript/jsapi.c
+++ b/javascript/jsapi.c
@@ -315,14 +315,14 @@ js_dom_event_add_listener(jscontext *ctx,
JSLOG("adding %p to listener", private);
- JS_AddValueRoot(cx, &private->funcval);
+ JSAPI_ADD_VALUE_ROOT(cx, &private->funcval);
exc = dom_event_target_add_event_listener(private->node,
private->type,
private->listener,
true);
if (exc != DOM_NO_ERR) {
JSLOG("failed to add listener");
- JS_RemoveValueRoot(cx, &private->funcval);
+ JSAPI_REMOVE_VALUE_ROOT(cx, &private->funcval);
}
return true;
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index 6b0f112..0493290 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -150,6 +150,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+#define JSAPI_ADD_VALUE_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_VALUE_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+
#elif JS_VERSION == 180
/************************** Spidermonkey 1.8.0 **************************/
@@ -263,6 +266,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+#define JSAPI_ADD_VALUE_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_VALUE_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+
#else /* #if JS_VERSION == 180 */
@@ -365,6 +371,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddObjectRoot(cx, obj)
#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveObjectRoot(cx, obj)
+#define JSAPI_ADD_VALUE_ROOT(cx, val) JS_AddValueRoot(cx, val)
+#define JSAPI_REMOVE_VALUE_ROOT(cx, val) JS_RemoveValueRoot(cx, val)
+
#endif
#define JSLOG(args...) LOG((args))
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi.c | 4 ++--
javascript/jsapi.h | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/javascript/jsapi.c b/javascript/jsapi.c
index eebb33f..73153fe 100644
--- a/javascript/jsapi.c
+++ b/javascript/jsapi.c
@@ -315,14 +315,14 @@ js_dom_event_add_listener(jscontext *ctx,
JSLOG("adding %p to listener", private);
- JS_AddValueRoot(cx, &private->funcval);
+ JSAPI_ADD_VALUE_ROOT(cx, &private->funcval);
exc = dom_event_target_add_event_listener(private->node,
private->type,
private->listener,
true);
if (exc != DOM_NO_ERR) {
JSLOG("failed to add listener");
- JS_RemoveValueRoot(cx, &private->funcval);
+ JSAPI_REMOVE_VALUE_ROOT(cx, &private->funcval);
}
return true;
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index 6b0f112..0493290 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -150,6 +150,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+#define JSAPI_ADD_VALUE_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_VALUE_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+
#elif JS_VERSION == 180
/************************** Spidermonkey 1.8.0 **************************/
@@ -263,6 +266,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+#define JSAPI_ADD_VALUE_ROOT(cx, obj) JS_AddRoot(cx, obj)
+#define JSAPI_REMOVE_VALUE_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
+
#else /* #if JS_VERSION == 180 */
@@ -365,6 +371,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddObjectRoot(cx, obj)
#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveObjectRoot(cx, obj)
+#define JSAPI_ADD_VALUE_ROOT(cx, val) JS_AddValueRoot(cx, val)
+#define JSAPI_REMOVE_VALUE_ROOT(cx, val) JS_RemoveValueRoot(cx, val)
+
#endif
#define JSLOG(args...) LOG((args))
--
NetSurf Browser
10 years, 3 months