netsurf: branch master updated. 7915708b583699f16412d5eeab6a42602319e720
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7915708b583699f16412d...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7915708b583699f16412d5e...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7915708b583699f16412d5eea...
The branch, master has been updated
via 7915708b583699f16412d5eeab6a42602319e720 (commit)
from ec43456e4bf0968bc68b437733199ad2af609c1e (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/7915708b583699f1641...
commit 7915708b583699f16412d5eeab6a42602319e720
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
update event handler to cope with nsgenbind changes
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index e439980..3fe2afd 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -201,9 +201,9 @@ getter self %{
%}
getter EventHandler %{
- JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+ JSLOG("propname[%d] %s %s", tinyid , jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval)));
%}
setter EventHandler %{
- JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+ JSLOG("propname[%d] %s %s", tinyid, jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval)));
%}
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi/window.bnd | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index e439980..3fe2afd 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -201,9 +201,9 @@ getter self %{
%}
getter EventHandler %{
- JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+ JSLOG("propname[%d] %s %s", tinyid , jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval)));
%}
setter EventHandler %{
- JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+ JSLOG("propname[%d] %s %s", tinyid, jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval)));
%}
--
NetSurf Browser
10 years, 2 months
netsurf: branch mmu_man/beos-fixes updated. 1765212be2689b31fa8b1ce24b28a5f8125380de
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/1765212be2689b31fa8b1...
...commit http://git.netsurf-browser.org/netsurf.git/commit/1765212be2689b31fa8b1ce...
...tree http://git.netsurf-browser.org/netsurf.git/tree/1765212be2689b31fa8b1ce24...
The branch, mmu_man/beos-fixes has been updated
via 1765212be2689b31fa8b1ce24b28a5f8125380de (commit)
from eb454ff9f2389e7aca47b4c753a7225a9e4dae1f (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/1765212be2689b31fa8...
commit 1765212be2689b31fa8b1ce24b28a5f8125380de
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: Fix replicating with empty URL in archive
We just got to about: when no valid URL is passed.
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index c83cf95..bcd9943 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -505,12 +505,13 @@ NSBaseView::Instantiate(BMessage *archive)
if (!validate_instantiation(archive, "NSBaseView"))
return NULL;
const char *url;
- if (archive->FindString("url", &url) < B_OK) {
- return NULL;
+ if (archive->FindString("url", &url) < B_OK
+ || url == NULL || strlen(url) == 0) {
+ url = "about:";
}
struct replicant_thread_info *info = new replicant_thread_info;
- info->url = url;
+ info->url = BString(url);
if (nsbeos_find_app_path(info->app) < B_OK)
return NULL;
info->args[0] = info->app;
-----------------------------------------------------------------------
Summary of changes:
beos/scaffolding.cpp | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index c83cf95..bcd9943 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -505,12 +505,13 @@ NSBaseView::Instantiate(BMessage *archive)
if (!validate_instantiation(archive, "NSBaseView"))
return NULL;
const char *url;
- if (archive->FindString("url", &url) < B_OK) {
- return NULL;
+ if (archive->FindString("url", &url) < B_OK
+ || url == NULL || strlen(url) == 0) {
+ url = "about:";
}
struct replicant_thread_info *info = new replicant_thread_info;
- info->url = url;
+ info->url = BString(url);
if (nsbeos_find_app_path(info->app) < B_OK)
return NULL;
info->args[0] = info->app;
--
NetSurf Browser
10 years, 2 months
nsgenjsbind: branch master updated. 6f54ba5f6a2008191c2bb3435f8015ae70bcf156
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/6f54ba5f6a2008191...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/6f54ba5f6a2008191c2...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/6f54ba5f6a2008191c2bb...
The branch, master has been updated
via 6f54ba5f6a2008191c2bb3435f8015ae70bcf156 (commit)
from a1486c92cdefe045619b5ced38b3368c8f4457cf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/6f54ba5f6a20081...
commit 6f54ba5f6a2008191c2bb3435f8015ae70bcf156
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
generate and use tinyid enum for properties
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 4e67120..87cbc10 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -17,6 +17,7 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
+static int generate_property_tinyid(struct binding *binding, const char *interface);
static int generate_property_spec(struct binding *binding, const char *interface);
static int generate_property_body(struct binding *binding, const char *interface);
@@ -52,6 +53,17 @@ output_property_name_get_vars(struct binding *binding, const char *argname)
argname, argname, argname, argname);
}
+/* generate vars for property tinyid getter */
+static inline int
+output_property_tinyid_get_vars(struct binding *binding, const char *argname)
+{
+ /* get property name */
+ return fprintf(binding->outfile,
+ "\tjsval %s_jsval;\n"
+ "\tint8_t %s = JSAPI_PROP_TINYID_END;\n",
+ argname, argname);
+}
+
/* generate property name getter */
static inline int
output_property_name_get(struct binding *binding, const char *argname)
@@ -67,6 +79,135 @@ output_property_name_get(struct binding *binding, const char *argname)
argname,argname,argname,argname,argname,argname,argname);
}
+/* generate property name getter */
+static inline int
+output_property_tinyid_get(struct binding *binding, const char *argname)
+{
+ /* get property name */
+ return fprintf(binding->outfile,
+ "\t /* obtain property tinyid */\n"
+ "\tJSAPI_PROP_IDVAL(cx, &%s_jsval);\n"
+ "\t%s = JSVAL_TO_INT(%s_jsval);\n\n",
+ argname, argname, argname);
+}
+
+
+/******************************** tinyid ********************************/
+
+static int
+webidl_property_tinyid_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ struct webidl_node *ident_node;
+ const char *ident;
+
+ ident_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
+ ident = webidl_node_gettext(ident_node);
+ if (ident == NULL) {
+ /* properties must have an operator
+ * http://www.w3.org/TR/WebIDL/#idl-attributes
+ */
+ return -1;
+ }
+
+ fprintf(binding->outfile, "\tJSAPI_PROP_TINYID_%s,\n", ident);
+
+ return 0;
+}
+
+/* callback to emit implements property spec */
+static int
+webidl_property_tinyid_implements_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+
+ return generate_property_tinyid(binding, webidl_node_gettext(node));
+}
+
+static int
+generate_property_tinyid(struct binding *binding, const char *interface)
+{
+ struct webidl_node *interface_node;
+ struct webidl_node *members_node;
+ struct webidl_node *inherit_node;
+ int res = 0;
+
+ /* find interface in webidl with correct ident attached */
+ interface_node = webidl_node_find_type_ident(binding->wi_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ interface);
+
+ if (interface_node == NULL) {
+ fprintf(stderr,
+ "Unable to find interface %s in loaded WebIDL\n",
+ interface);
+ return -1;
+ }
+
+ /* generate property entries for each list (partial interfaces) */
+ members_node = webidl_node_find_type(webidl_node_getnode(interface_node),
+ NULL,
+ WEBIDL_NODE_TYPE_LIST);
+
+ while (members_node != NULL) {
+
+ fprintf(binding->outfile,"\t/**** %s ****/\n", interface);
+
+ /* for each property emit a JSAPI_PS() */
+ webidl_node_for_each_type(webidl_node_getnode(members_node),
+ WEBIDL_NODE_TYPE_ATTRIBUTE,
+ webidl_property_tinyid_cb,
+ binding);
+
+ members_node = webidl_node_find_type(webidl_node_getnode(interface_node),
+ members_node,
+ WEBIDL_NODE_TYPE_LIST);
+ }
+
+ /* check for inherited nodes and insert them too */
+ inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+
+ if (inherit_node != NULL) {
+ res = generate_property_tinyid(binding, webidl_node_gettext(inherit_node));
+ }
+
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_property_tinyid_implements_cb,
+ binding);
+ }
+
+ return res;
+}
+
+/* exported interface documented in jsapi-libdom.h */
+int
+output_property_tinyid(struct binding *binding)
+{
+ int res;
+
+ fprintf(binding->outfile,
+ "enum property_tinyid {\n");
+
+ res = generate_property_tinyid(binding, binding->interface);
+
+ fprintf(binding->outfile,
+ "\tJSAPI_PROP_TINYID_END,\n"
+ "};\n\n");
+
+ return res;
+}
+
+
+
+/******************************** specifier ********************************/
+
/* search binding for property sharing modifier */
static enum genbind_type_modifier
@@ -141,9 +282,9 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
WEBIDL_NODE_TYPE_MODIFIER);
if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
- fprintf(binding->outfile, "\tJSAPI_PS_RO(\"%s\", ", ident);
+ fprintf(binding->outfile, "\tJSAPI_PS_RO(\"%s\",\n", ident);
} else {
- fprintf(binding->outfile, "\tJSAPI_PS(\"%s\", ", ident);
+ fprintf(binding->outfile, "\tJSAPI_PS(\"%s\",\n", ident);
}
/* generate property shared status */
@@ -156,34 +297,44 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
* js doesnt provide storage and setter/getter must
* perform all GC management.
*/
- fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
+ fprintf(binding->outfile,
+ "\t\t%s,\n"
+ "\t\tJSAPI_PROP_TINYID_%s,\n"
+ "\t\tJSPROP_SHARED | ",
+ ident,
ident);
break;
case GENBIND_TYPE_TYPE:
/* shared property with a type handler */
- fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
- type);
+ fprintf(binding->outfile,
+ "\t\t%s,\n"
+ "\t\tJSAPI_PROP_TINYID_%s,\n"
+ "\t\tJSPROP_SHARED | ",
+ type,
+ ident);
break;
case GENBIND_TYPE_UNSHARED:
/* unshared property without type handler */
fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE",
- ident);
+ "\t\t%s,\n"
+ "\t\tJSAPI_PROP_TINYID_%s,\n"
+ "\t\t",
+ ident, ident);
break;
case GENBIND_TYPE_TYPE_UNSHARED:
/* unshared property with a type handler */
fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE",
- type);
+ "\t\t%s,\n"
+ "\t\tJSAPI_PROP_TINYID_%s,\n"
+ "\t\t",
+ type, ident);
break;
}
- fprintf(binding->outfile, "),\n");
+ fprintf(binding->outfile, "JSPROP_ENUMERATE),\n");
return 0;
}
@@ -258,7 +409,9 @@ generate_property_spec(struct binding *binding, const char *interface)
return res;
}
-/* generate property specifier structure */
+
+
+/* exported interface documented in jsapi-libdom.h */
int
output_property_spec(struct binding *binding)
{
@@ -274,6 +427,10 @@ output_property_spec(struct binding *binding)
return res;
}
+
+/******************************** body ********************************/
+
+
static int output_return(struct binding *binding,
const char *ident,
struct webidl_node *node)
@@ -733,21 +890,26 @@ generate_property_body(struct binding *binding, const char *interface)
/* setter for type handler */
-static int output_property_type_setter(struct binding *binding, struct genbind_node *node, const char *type)
+static int
+output_property_type_setter(struct binding *binding,
+ struct genbind_node *node,
+ const char *type)
{
struct genbind_node *property_node;
+ node = node;/* currently unused */
fprintf(binding->outfile,
- "static JSBool JSAPI_PROP_SETTER(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
+ "static JSBool\n"
+ "JSAPI_PROP_SETTER(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
"{\n",
type);
/* property name vars */
- output_property_name_get_vars(binding, "propname");
+ output_property_tinyid_get_vars(binding, "tinyid");
/* context data */
output_private_get(binding, "private");
/* property name */
- output_property_name_get(binding, "propname");
+ output_property_tinyid_get(binding, "tinyid");
/* output binding code block */
property_node = genbind_node_find_type_ident(binding->gb_ast,
@@ -772,18 +934,19 @@ static int output_property_type_setter(struct binding *binding, struct genbind_n
static int output_property_type_getter(struct binding *binding, struct genbind_node *node, const char *type)
{
struct genbind_node *property_node;
+ node = node;/* currently unused */
fprintf(binding->outfile,
"static JSBool JSAPI_PROP_GETTER(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
"{\n",
type);
- /* property name vars */
- output_property_name_get_vars(binding, "propname");
+ /* property tinyid vars */
+ output_property_tinyid_get_vars(binding, "tinyid");
/* context data */
output_private_get(binding, "private");
- /* property name */
- output_property_name_get(binding, "propname");
+ /* property tinyid */
+ output_property_tinyid_get(binding, "tinyid");
/* output binding code block */
property_node = genbind_node_find_type_ident(binding->gb_ast,
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 0ac16e8..3e0bf08 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -414,24 +414,28 @@ output_class_new(struct binding *binding)
static int
output_jsclass(struct binding *binding)
{
+ /* forward declare the resolver */
if (binding->resolve != NULL) {
- /* forward declare the resolver */
fprintf(binding->outfile,
"static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);\n\n");
}
+ /* forward declare the GC mark operation */
if (binding->mark != NULL) {
fprintf(binding->outfile,
"static JSAPI_MARKOP(jsclass_mark);\n\n");
}
+ /* forward declare the finalizer */
if (binding->has_private || (binding->finalise != NULL)) {
-
- /* forward declare the finalizer */
fprintf(binding->outfile,
"static void jsclass_finalize(JSContext *cx, JSObject *obj);\n\n");
}
+ /* forward declare property list */
+ fprintf(binding->outfile,
+ "static JSPropertySpec jsclass_properties[];\n\n");
+
/* output the class */
fprintf(binding->outfile,
"JSClass JSClass_%s = {\n"
@@ -696,62 +700,73 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
/* get general binding information used in output */
binding = binding_new(outfilename, genbind_ast);
if (binding == NULL) {
- return 4;
+ return 40;
}
res = output_header_comments(binding);
if (res) {
- return 5;
+ return 50;
}
res = output_preamble(binding);
if (res) {
- return 6;
+ return 60;
}
res = output_private_declaration(binding);
if (res) {
- return 7;
+ return 70;
}
res = output_jsclass(binding);
if (res) {
- return 8;
+ return 80;
}
+ res = output_property_tinyid(binding);
+ if (res) {
+ return 85;
+ }
+
+ /* operator and atrtribute body generation */
+
res = output_operator_body(binding, binding->interface);
if (res) {
- return 9;
+ return 90;
}
res = output_property_body(binding);
if (res) {
- return 10;
+ return 100;
}
+ /* operator and atrtribute specifier generation */
+
res = output_function_spec(binding);
if (res) {
- return 11;
+ return 110;
}
res = output_property_spec(binding);
if (res) {
- return 12;
+ return 120;
}
+ /* binding specific operations (destructors etc.) */
+
res = output_api_operations(binding);
if (res) {
- return 13;
+ return 130;
}
res = output_class_init(binding);
if (res) {
- return 14;
+ return 140;
}
res = output_class_new(binding);
if (res) {
- return 15;
+ return 150;
}
fclose(binding->outfile);
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index 86214f4..8af39b2 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -27,9 +27,15 @@ struct binding {
FILE *outfile ; /* output file */
};
+/** Generate binding between jsapi and netsurf libdom */
+int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
+
/** output code block from a node */
void output_code_block(struct binding *binding, struct genbind_node *codelist);
+/* Generate jsapi native function specifiers */
+int output_function_spec(struct binding *binding);
+
/* Generate jsapi native function bodys
*
* web IDL describes methods as operators
@@ -46,15 +52,20 @@ void output_code_block(struct binding *binding, struct genbind_node *codelist);
* @param interface The interface to generate operator bodys for
*/
int output_operator_body(struct binding *binding, const char *interface);
-int output_function_spec(struct binding *binding);
+
+/** generate property tinyid enum */
+int output_property_tinyid(struct binding *binding);
+
+/** generate property specifier structure */
int output_property_spec(struct binding *binding);
+
+/** generate property function bodies */
int output_property_body(struct binding *binding);
+/** generate property definitions for constants */
int output_const_defines(struct binding *binding, const char *interface);
-/** Generate binding between jsapi and netsurf libdom */
-int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-property.c | 205 ++++++++++++++++++++++++++++++++++++++-----
src/jsapi-libdom.c | 45 ++++++---
src/jsapi-libdom.h | 17 +++-
3 files changed, 228 insertions(+), 39 deletions(-)
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 4e67120..87cbc10 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -17,6 +17,7 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
+static int generate_property_tinyid(struct binding *binding, const char *interface);
static int generate_property_spec(struct binding *binding, const char *interface);
static int generate_property_body(struct binding *binding, const char *interface);
@@ -52,6 +53,17 @@ output_property_name_get_vars(struct binding *binding, const char *argname)
argname, argname, argname, argname);
}
+/* generate vars for property tinyid getter */
+static inline int
+output_property_tinyid_get_vars(struct binding *binding, const char *argname)
+{
+ /* get property name */
+ return fprintf(binding->outfile,
+ "\tjsval %s_jsval;\n"
+ "\tint8_t %s = JSAPI_PROP_TINYID_END;\n",
+ argname, argname);
+}
+
/* generate property name getter */
static inline int
output_property_name_get(struct binding *binding, const char *argname)
@@ -67,6 +79,135 @@ output_property_name_get(struct binding *binding, const char *argname)
argname,argname,argname,argname,argname,argname,argname);
}
+/* generate property name getter */
+static inline int
+output_property_tinyid_get(struct binding *binding, const char *argname)
+{
+ /* get property name */
+ return fprintf(binding->outfile,
+ "\t /* obtain property tinyid */\n"
+ "\tJSAPI_PROP_IDVAL(cx, &%s_jsval);\n"
+ "\t%s = JSVAL_TO_INT(%s_jsval);\n\n",
+ argname, argname, argname);
+}
+
+
+/******************************** tinyid ********************************/
+
+static int
+webidl_property_tinyid_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ struct webidl_node *ident_node;
+ const char *ident;
+
+ ident_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
+ ident = webidl_node_gettext(ident_node);
+ if (ident == NULL) {
+ /* properties must have an operator
+ * http://www.w3.org/TR/WebIDL/#idl-attributes
+ */
+ return -1;
+ }
+
+ fprintf(binding->outfile, "\tJSAPI_PROP_TINYID_%s,\n", ident);
+
+ return 0;
+}
+
+/* callback to emit implements property spec */
+static int
+webidl_property_tinyid_implements_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+
+ return generate_property_tinyid(binding, webidl_node_gettext(node));
+}
+
+static int
+generate_property_tinyid(struct binding *binding, const char *interface)
+{
+ struct webidl_node *interface_node;
+ struct webidl_node *members_node;
+ struct webidl_node *inherit_node;
+ int res = 0;
+
+ /* find interface in webidl with correct ident attached */
+ interface_node = webidl_node_find_type_ident(binding->wi_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ interface);
+
+ if (interface_node == NULL) {
+ fprintf(stderr,
+ "Unable to find interface %s in loaded WebIDL\n",
+ interface);
+ return -1;
+ }
+
+ /* generate property entries for each list (partial interfaces) */
+ members_node = webidl_node_find_type(webidl_node_getnode(interface_node),
+ NULL,
+ WEBIDL_NODE_TYPE_LIST);
+
+ while (members_node != NULL) {
+
+ fprintf(binding->outfile,"\t/**** %s ****/\n", interface);
+
+ /* for each property emit a JSAPI_PS() */
+ webidl_node_for_each_type(webidl_node_getnode(members_node),
+ WEBIDL_NODE_TYPE_ATTRIBUTE,
+ webidl_property_tinyid_cb,
+ binding);
+
+ members_node = webidl_node_find_type(webidl_node_getnode(interface_node),
+ members_node,
+ WEBIDL_NODE_TYPE_LIST);
+ }
+
+ /* check for inherited nodes and insert them too */
+ inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+
+ if (inherit_node != NULL) {
+ res = generate_property_tinyid(binding, webidl_node_gettext(inherit_node));
+ }
+
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_property_tinyid_implements_cb,
+ binding);
+ }
+
+ return res;
+}
+
+/* exported interface documented in jsapi-libdom.h */
+int
+output_property_tinyid(struct binding *binding)
+{
+ int res;
+
+ fprintf(binding->outfile,
+ "enum property_tinyid {\n");
+
+ res = generate_property_tinyid(binding, binding->interface);
+
+ fprintf(binding->outfile,
+ "\tJSAPI_PROP_TINYID_END,\n"
+ "};\n\n");
+
+ return res;
+}
+
+
+
+/******************************** specifier ********************************/
+
/* search binding for property sharing modifier */
static enum genbind_type_modifier
@@ -141,9 +282,9 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
WEBIDL_NODE_TYPE_MODIFIER);
if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
- fprintf(binding->outfile, "\tJSAPI_PS_RO(\"%s\", ", ident);
+ fprintf(binding->outfile, "\tJSAPI_PS_RO(\"%s\",\n", ident);
} else {
- fprintf(binding->outfile, "\tJSAPI_PS(\"%s\", ", ident);
+ fprintf(binding->outfile, "\tJSAPI_PS(\"%s\",\n", ident);
}
/* generate property shared status */
@@ -156,34 +297,44 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
* js doesnt provide storage and setter/getter must
* perform all GC management.
*/
- fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
+ fprintf(binding->outfile,
+ "\t\t%s,\n"
+ "\t\tJSAPI_PROP_TINYID_%s,\n"
+ "\t\tJSPROP_SHARED | ",
+ ident,
ident);
break;
case GENBIND_TYPE_TYPE:
/* shared property with a type handler */
- fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
- type);
+ fprintf(binding->outfile,
+ "\t\t%s,\n"
+ "\t\tJSAPI_PROP_TINYID_%s,\n"
+ "\t\tJSPROP_SHARED | ",
+ type,
+ ident);
break;
case GENBIND_TYPE_UNSHARED:
/* unshared property without type handler */
fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE",
- ident);
+ "\t\t%s,\n"
+ "\t\tJSAPI_PROP_TINYID_%s,\n"
+ "\t\t",
+ ident, ident);
break;
case GENBIND_TYPE_TYPE_UNSHARED:
/* unshared property with a type handler */
fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE",
- type);
+ "\t\t%s,\n"
+ "\t\tJSAPI_PROP_TINYID_%s,\n"
+ "\t\t",
+ type, ident);
break;
}
- fprintf(binding->outfile, "),\n");
+ fprintf(binding->outfile, "JSPROP_ENUMERATE),\n");
return 0;
}
@@ -258,7 +409,9 @@ generate_property_spec(struct binding *binding, const char *interface)
return res;
}
-/* generate property specifier structure */
+
+
+/* exported interface documented in jsapi-libdom.h */
int
output_property_spec(struct binding *binding)
{
@@ -274,6 +427,10 @@ output_property_spec(struct binding *binding)
return res;
}
+
+/******************************** body ********************************/
+
+
static int output_return(struct binding *binding,
const char *ident,
struct webidl_node *node)
@@ -733,21 +890,26 @@ generate_property_body(struct binding *binding, const char *interface)
/* setter for type handler */
-static int output_property_type_setter(struct binding *binding, struct genbind_node *node, const char *type)
+static int
+output_property_type_setter(struct binding *binding,
+ struct genbind_node *node,
+ const char *type)
{
struct genbind_node *property_node;
+ node = node;/* currently unused */
fprintf(binding->outfile,
- "static JSBool JSAPI_PROP_SETTER(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
+ "static JSBool\n"
+ "JSAPI_PROP_SETTER(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
"{\n",
type);
/* property name vars */
- output_property_name_get_vars(binding, "propname");
+ output_property_tinyid_get_vars(binding, "tinyid");
/* context data */
output_private_get(binding, "private");
/* property name */
- output_property_name_get(binding, "propname");
+ output_property_tinyid_get(binding, "tinyid");
/* output binding code block */
property_node = genbind_node_find_type_ident(binding->gb_ast,
@@ -772,18 +934,19 @@ static int output_property_type_setter(struct binding *binding, struct genbind_n
static int output_property_type_getter(struct binding *binding, struct genbind_node *node, const char *type)
{
struct genbind_node *property_node;
+ node = node;/* currently unused */
fprintf(binding->outfile,
"static JSBool JSAPI_PROP_GETTER(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
"{\n",
type);
- /* property name vars */
- output_property_name_get_vars(binding, "propname");
+ /* property tinyid vars */
+ output_property_tinyid_get_vars(binding, "tinyid");
/* context data */
output_private_get(binding, "private");
- /* property name */
- output_property_name_get(binding, "propname");
+ /* property tinyid */
+ output_property_tinyid_get(binding, "tinyid");
/* output binding code block */
property_node = genbind_node_find_type_ident(binding->gb_ast,
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 0ac16e8..3e0bf08 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -414,24 +414,28 @@ output_class_new(struct binding *binding)
static int
output_jsclass(struct binding *binding)
{
+ /* forward declare the resolver */
if (binding->resolve != NULL) {
- /* forward declare the resolver */
fprintf(binding->outfile,
"static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);\n\n");
}
+ /* forward declare the GC mark operation */
if (binding->mark != NULL) {
fprintf(binding->outfile,
"static JSAPI_MARKOP(jsclass_mark);\n\n");
}
+ /* forward declare the finalizer */
if (binding->has_private || (binding->finalise != NULL)) {
-
- /* forward declare the finalizer */
fprintf(binding->outfile,
"static void jsclass_finalize(JSContext *cx, JSObject *obj);\n\n");
}
+ /* forward declare property list */
+ fprintf(binding->outfile,
+ "static JSPropertySpec jsclass_properties[];\n\n");
+
/* output the class */
fprintf(binding->outfile,
"JSClass JSClass_%s = {\n"
@@ -696,62 +700,73 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
/* get general binding information used in output */
binding = binding_new(outfilename, genbind_ast);
if (binding == NULL) {
- return 4;
+ return 40;
}
res = output_header_comments(binding);
if (res) {
- return 5;
+ return 50;
}
res = output_preamble(binding);
if (res) {
- return 6;
+ return 60;
}
res = output_private_declaration(binding);
if (res) {
- return 7;
+ return 70;
}
res = output_jsclass(binding);
if (res) {
- return 8;
+ return 80;
}
+ res = output_property_tinyid(binding);
+ if (res) {
+ return 85;
+ }
+
+ /* operator and atrtribute body generation */
+
res = output_operator_body(binding, binding->interface);
if (res) {
- return 9;
+ return 90;
}
res = output_property_body(binding);
if (res) {
- return 10;
+ return 100;
}
+ /* operator and atrtribute specifier generation */
+
res = output_function_spec(binding);
if (res) {
- return 11;
+ return 110;
}
res = output_property_spec(binding);
if (res) {
- return 12;
+ return 120;
}
+ /* binding specific operations (destructors etc.) */
+
res = output_api_operations(binding);
if (res) {
- return 13;
+ return 130;
}
res = output_class_init(binding);
if (res) {
- return 14;
+ return 140;
}
res = output_class_new(binding);
if (res) {
- return 15;
+ return 150;
}
fclose(binding->outfile);
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index 86214f4..8af39b2 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -27,9 +27,15 @@ struct binding {
FILE *outfile ; /* output file */
};
+/** Generate binding between jsapi and netsurf libdom */
+int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
+
/** output code block from a node */
void output_code_block(struct binding *binding, struct genbind_node *codelist);
+/* Generate jsapi native function specifiers */
+int output_function_spec(struct binding *binding);
+
/* Generate jsapi native function bodys
*
* web IDL describes methods as operators
@@ -46,15 +52,20 @@ void output_code_block(struct binding *binding, struct genbind_node *codelist);
* @param interface The interface to generate operator bodys for
*/
int output_operator_body(struct binding *binding, const char *interface);
-int output_function_spec(struct binding *binding);
+
+/** generate property tinyid enum */
+int output_property_tinyid(struct binding *binding);
+
+/** generate property specifier structure */
int output_property_spec(struct binding *binding);
+
+/** generate property function bodies */
int output_property_body(struct binding *binding);
+/** generate property definitions for constants */
int output_const_defines(struct binding *binding, const char *interface);
-/** Generate binding between jsapi and netsurf libdom */
-int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
--
NetSurf Generator for JavaScript bindings
10 years, 2 months
netsurf: branch mmu_man/beos-fixes updated. eb454ff9f2389e7aca47b4c753a7225a9e4dae1f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/eb454ff9f2389e7aca47b...
...commit http://git.netsurf-browser.org/netsurf.git/commit/eb454ff9f2389e7aca47b4c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/eb454ff9f2389e7aca47b4c75...
The branch, mmu_man/beos-fixes has been updated
via eb454ff9f2389e7aca47b4c753a7225a9e4dae1f (commit)
from 17e19b283f8cf0e2772e61ac1e11f9919b03489b (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/eb454ff9f2389e7aca4...
commit eb454ff9f2389e7aca47b4c753a7225a9e4dae1f
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: More debug output cleanup
diff --git a/beos/window.cpp b/beos/window.cpp
index 4bc9f2c..f26ba91 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -1078,7 +1078,7 @@ gboolean nsbeos_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
{
- CALLED();
+ //CALLED();
int32 width;
int32 height;
@@ -1128,7 +1128,7 @@ void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
void nsbeos_window_moved_event(BView *view, gui_window *g, BMessage *event)
{
- CALLED();
+ //CALLED();
#warning XXX: Invalidate ?
if (!view || !view->LockLooper())
@@ -1582,7 +1582,7 @@ void gui_window_hide_pointer(struct gui_window *g)
void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
{
- CALLED();
+ //CALLED();
if (g->view == NULL)
return;
if (!g->view->LockLooper())
-----------------------------------------------------------------------
Summary of changes:
beos/window.cpp | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/beos/window.cpp b/beos/window.cpp
index 4bc9f2c..f26ba91 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -1078,7 +1078,7 @@ gboolean nsbeos_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
{
- CALLED();
+ //CALLED();
int32 width;
int32 height;
@@ -1128,7 +1128,7 @@ void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
void nsbeos_window_moved_event(BView *view, gui_window *g, BMessage *event)
{
- CALLED();
+ //CALLED();
#warning XXX: Invalidate ?
if (!view || !view->LockLooper())
@@ -1582,7 +1582,7 @@ void gui_window_hide_pointer(struct gui_window *g)
void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
{
- CALLED();
+ //CALLED();
if (g->view == NULL)
return;
if (!g->view->LockLooper())
--
NetSurf Browser
10 years, 2 months
netsurf: branch mmu_man/beos-fixes updated. 17e19b283f8cf0e2772e61ac1e11f9919b03489b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/17e19b283f8cf0e2772e6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/17e19b283f8cf0e2772e61a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/17e19b283f8cf0e2772e61ac1...
The branch, mmu_man/beos-fixes has been updated
via 17e19b283f8cf0e2772e61ac1e11f9919b03489b (commit)
from 38b17e11123d7da014d6c53c28f3d181a15517eb (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/17e19b283f8cf0e2772...
commit 17e19b283f8cf0e2772e61ac1e11f9919b03489b
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: Silence debug output
Either comment them or change to LOG() calls.
diff --git a/beos/bitmap.cpp b/beos/bitmap.cpp
index 83dedf7..0dd8972 100644
--- a/beos/bitmap.cpp
+++ b/beos/bitmap.cpp
@@ -106,7 +106,7 @@ static inline void nsbeos_rgba_to_bgra(void *src, void *dst, int width, int heig
void *bitmap_create(int width, int height, unsigned int state)
{
- CALLED();
+ //CALLED();
struct bitmap *bmp = (struct bitmap *)malloc(sizeof(struct bitmap));
if (bmp == NULL)
return NULL;
@@ -288,7 +288,7 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_modified(void *vbitmap) {
- CALLED();
+ //CALLED();
struct bitmap *bitmap = (struct bitmap *)vbitmap;
// convert the shadow (ABGR) to into the primary bitmap
nsbeos_rgba_to_bgra(bitmap->shadow->Bits(), bitmap->primary->Bits(),
diff --git a/beos/fetch_rsrc.cpp b/beos/fetch_rsrc.cpp
index d841a1d..f7c99d7 100644
--- a/beos/fetch_rsrc.cpp
+++ b/beos/fetch_rsrc.cpp
@@ -198,11 +198,11 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
uint8 c1, c2, c3, c4;
if (sscanf(params, "%c%c%c%c", &c1, &c2, &c3, &c4) > 3) {
type = c1 << 24 | c2 << 16 | c3 << 8 | c4;
- printf("type:%4.4s\n", &type);
+ LOG(("fetch_rsrc: type:%4.4s\n", &type));
}
}
- fprintf(stderr, "fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name);
+ LOG(("fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name));
bool found;
if (id)
@@ -334,7 +334,7 @@ static int find_app_resources()
char path[B_PATH_NAME_LENGTH];
if (nsbeos_find_app_path(path) < B_OK)
return B_ERROR;
-//fprintf(stderr, "loading resources from '%s'\n", path);
+ //fprintf(stderr, "loading resources from '%s'\n", path);
BFile file(path, B_READ_ONLY);
if (file.InitCheck() < 0)
diff --git a/beos/gui.cpp b/beos/gui.cpp
index dacdee9..bddd610 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -172,7 +172,7 @@ NSBrowserApplication::MessageReceived(BMessage *message)
void
NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
{
- CALLED();
+ //CALLED();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
return;
@@ -186,7 +186,7 @@ NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
void
NSBrowserApplication::RefsReceived(BMessage *message)
{
- CALLED();
+ //CALLED();
DetachCurrentMessage();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
@@ -325,7 +325,7 @@ image_id nsbeos_find_app_path(char *path)
static char *find_resource(char *buf, const char *filename, const char *def)
{
- CALLED();
+ //CALLED();
const char *cdir = NULL;
status_t err;
BPath path;
@@ -388,7 +388,7 @@ static char *find_resource(char *buf, const char *filename, const char *def)
*/
static void check_homedir(void)
{
- CALLED();
+ //CALLED();
status_t err;
BPath path;
@@ -423,14 +423,14 @@ nsurl *gui_get_resource_url(const char *path)
u << "beosdefault.css";
else
u << path;
- fprintf(stderr, "%s(%s) -> '%s'\n", __FUNCTION__, path, u.String());
+ LOG(("(%s) -> '%s'\n", path, u.String()));
nsurl_create(u.String(), &url);
return url;
}
static void gui_init2(int argc, char** argv)
{
- CALLED();
+ //CALLED();
const char *addr = NETSURF_HOMEPAGE;
if (nsoption_charp(homepage_url) != NULL)
@@ -509,7 +509,7 @@ void gui_options_init_defaults(void)
void gui_init(int argc, char** argv)
{
char buf[PATH_MAX];
- CALLED();
+ //CALLED();
if (pipe(sEventPipe) < 0)
return;
@@ -780,7 +780,7 @@ void gui_poll(bool active)
void gui_quit(void)
{
- CALLED();
+ //CALLED();
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
//options_save_tree(hotlist,nsoption_charp(hotlist_file),messages_get("TreeHotlist"));
diff --git a/beos/window.cpp b/beos/window.cpp
index 3e6b2f5..4bc9f2c 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -1312,7 +1312,7 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
- CALLED();
+ //CALLED();
if (g->view == NULL)
return false;
if (!g->view->LockLooper())
@@ -1342,7 +1342,7 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
- CALLED();
+ //CALLED();
if (g->view == NULL)
return;
if (!g->view->LockLooper())
@@ -1384,7 +1384,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
void gui_window_update_extent(struct gui_window *g)
{
- CALLED();
+ //CALLED();
if (!g->bw->current_content)
return;
@@ -1399,7 +1399,7 @@ void gui_window_update_extent(struct gui_window *g)
float y_prop = g->view->Bounds().Height() / y_max;
x_max -= g->view->Bounds().Width() + 1;
y_max -= g->view->Bounds().Height() + 1;
-printf("x_max = %f y_max = %f x_prop = %f y_prop = %f\n", x_max, y_max, x_prop, y_prop);
+ LOG(("x_max = %f y_max = %f x_prop = %f y_prop = %f\n", x_max, y_max, x_prop, y_prop));
if (g->view->ScrollBar(B_HORIZONTAL)) {
g->view->ScrollBar(B_HORIZONTAL)->SetRange(0, x_max);
g->view->ScrollBar(B_HORIZONTAL)->SetProportion(x_prop);
-----------------------------------------------------------------------
Summary of changes:
beos/bitmap.cpp | 4 ++--
beos/fetch_rsrc.cpp | 6 +++---
beos/gui.cpp | 16 ++++++++--------
beos/window.cpp | 8 ++++----
4 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/beos/bitmap.cpp b/beos/bitmap.cpp
index 83dedf7..0dd8972 100644
--- a/beos/bitmap.cpp
+++ b/beos/bitmap.cpp
@@ -106,7 +106,7 @@ static inline void nsbeos_rgba_to_bgra(void *src, void *dst, int width, int heig
void *bitmap_create(int width, int height, unsigned int state)
{
- CALLED();
+ //CALLED();
struct bitmap *bmp = (struct bitmap *)malloc(sizeof(struct bitmap));
if (bmp == NULL)
return NULL;
@@ -288,7 +288,7 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
* \param vbitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_modified(void *vbitmap) {
- CALLED();
+ //CALLED();
struct bitmap *bitmap = (struct bitmap *)vbitmap;
// convert the shadow (ABGR) to into the primary bitmap
nsbeos_rgba_to_bgra(bitmap->shadow->Bits(), bitmap->primary->Bits(),
diff --git a/beos/fetch_rsrc.cpp b/beos/fetch_rsrc.cpp
index d841a1d..f7c99d7 100644
--- a/beos/fetch_rsrc.cpp
+++ b/beos/fetch_rsrc.cpp
@@ -198,11 +198,11 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
uint8 c1, c2, c3, c4;
if (sscanf(params, "%c%c%c%c", &c1, &c2, &c3, &c4) > 3) {
type = c1 << 24 | c2 << 16 | c3 << 8 | c4;
- printf("type:%4.4s\n", &type);
+ LOG(("fetch_rsrc: type:%4.4s\n", &type));
}
}
- fprintf(stderr, "fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name);
+ LOG(("fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name));
bool found;
if (id)
@@ -334,7 +334,7 @@ static int find_app_resources()
char path[B_PATH_NAME_LENGTH];
if (nsbeos_find_app_path(path) < B_OK)
return B_ERROR;
-//fprintf(stderr, "loading resources from '%s'\n", path);
+ //fprintf(stderr, "loading resources from '%s'\n", path);
BFile file(path, B_READ_ONLY);
if (file.InitCheck() < 0)
diff --git a/beos/gui.cpp b/beos/gui.cpp
index dacdee9..bddd610 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -172,7 +172,7 @@ NSBrowserApplication::MessageReceived(BMessage *message)
void
NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
{
- CALLED();
+ //CALLED();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
return;
@@ -186,7 +186,7 @@ NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
void
NSBrowserApplication::RefsReceived(BMessage *message)
{
- CALLED();
+ //CALLED();
DetachCurrentMessage();
NSBrowserWindow *win = nsbeos_find_last_window();
if (!win) {
@@ -325,7 +325,7 @@ image_id nsbeos_find_app_path(char *path)
static char *find_resource(char *buf, const char *filename, const char *def)
{
- CALLED();
+ //CALLED();
const char *cdir = NULL;
status_t err;
BPath path;
@@ -388,7 +388,7 @@ static char *find_resource(char *buf, const char *filename, const char *def)
*/
static void check_homedir(void)
{
- CALLED();
+ //CALLED();
status_t err;
BPath path;
@@ -423,14 +423,14 @@ nsurl *gui_get_resource_url(const char *path)
u << "beosdefault.css";
else
u << path;
- fprintf(stderr, "%s(%s) -> '%s'\n", __FUNCTION__, path, u.String());
+ LOG(("(%s) -> '%s'\n", path, u.String()));
nsurl_create(u.String(), &url);
return url;
}
static void gui_init2(int argc, char** argv)
{
- CALLED();
+ //CALLED();
const char *addr = NETSURF_HOMEPAGE;
if (nsoption_charp(homepage_url) != NULL)
@@ -509,7 +509,7 @@ void gui_options_init_defaults(void)
void gui_init(int argc, char** argv)
{
char buf[PATH_MAX];
- CALLED();
+ //CALLED();
if (pipe(sEventPipe) < 0)
return;
@@ -780,7 +780,7 @@ void gui_poll(bool active)
void gui_quit(void)
{
- CALLED();
+ //CALLED();
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
//options_save_tree(hotlist,nsoption_charp(hotlist_file),messages_get("TreeHotlist"));
diff --git a/beos/window.cpp b/beos/window.cpp
index 3e6b2f5..4bc9f2c 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -1312,7 +1312,7 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
- CALLED();
+ //CALLED();
if (g->view == NULL)
return false;
if (!g->view->LockLooper())
@@ -1342,7 +1342,7 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
- CALLED();
+ //CALLED();
if (g->view == NULL)
return;
if (!g->view->LockLooper())
@@ -1384,7 +1384,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
void gui_window_update_extent(struct gui_window *g)
{
- CALLED();
+ //CALLED();
if (!g->bw->current_content)
return;
@@ -1399,7 +1399,7 @@ void gui_window_update_extent(struct gui_window *g)
float y_prop = g->view->Bounds().Height() / y_max;
x_max -= g->view->Bounds().Width() + 1;
y_max -= g->view->Bounds().Height() + 1;
-printf("x_max = %f y_max = %f x_prop = %f y_prop = %f\n", x_max, y_max, x_prop, y_prop);
+ LOG(("x_max = %f y_max = %f x_prop = %f y_prop = %f\n", x_max, y_max, x_prop, y_prop));
if (g->view->ScrollBar(B_HORIZONTAL)) {
g->view->ScrollBar(B_HORIZONTAL)->SetRange(0, x_max);
g->view->ScrollBar(B_HORIZONTAL)->SetProportion(x_prop);
--
NetSurf Browser
10 years, 2 months
netsurf: branch mmu_man/beos-fixes updated. 38b17e11123d7da014d6c53c28f3d181a15517eb
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/38b17e11123d7da014d6c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/38b17e11123d7da014d6c53...
...tree http://git.netsurf-browser.org/netsurf.git/tree/38b17e11123d7da014d6c53c2...
The branch, mmu_man/beos-fixes has been updated
via 38b17e11123d7da014d6c53c28f3d181a15517eb (commit)
from 8a12a8d5459a0fff8cd2e7f424300b71ec733feb (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/38b17e11123d7da014d...
commit 38b17e11123d7da014d6c53c28f3d181a15517eb
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: Partial replicant instanciation fix
* use the correct resources
* work around a deadlock, allows BeHappy to start, though removing
the replicant from Tracker crashes
diff --git a/beos/fetch_rsrc.cpp b/beos/fetch_rsrc.cpp
index 563f431..d841a1d 100644
--- a/beos/fetch_rsrc.cpp
+++ b/beos/fetch_rsrc.cpp
@@ -66,7 +66,7 @@ struct fetch_rsrc_context {
static struct fetch_rsrc_context *ring = NULL;
-static BResources *gAppResources = NULL;
+BResources *gAppResources = NULL;
static bool fetch_rsrc_initialise(lwc_string *scheme)
{
diff --git a/beos/gui.cpp b/beos/gui.cpp
index 9e26d44..dacdee9 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -457,6 +457,12 @@ int main(int argc, char** argv)
options.Append("x-vnd.NetSurf");
}
+ if (!replicated) {
+ // create the Application object before trying to use messages
+ // so we can open an alert in case of error.
+ new NSBrowserApplication;
+ }
+
char* messages = "/boot/apps/netsurf/res/en/Messages";
/* initialise netsurf */
@@ -472,6 +478,27 @@ int main(int argc, char** argv)
return 0;
}
+/** called when replicated from NSBaseView::Instantiate() */
+int gui_init_replicant(int argc, char** argv)
+{
+ setbuf(stderr, NULL);
+
+ BPath options;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
+ options.Append("x-vnd.NetSurf");
+ }
+
+ char* messages = "/boot/apps/netsurf/res/en/Messages";
+
+ /* initialise netsurf */
+ netsurf_init(&argc, &argv, options.Path(), messages);
+
+ gui_init(argc, argv);
+ gui_init2(argc, argv);
+
+ return 0;
+}
+
/* Documented in desktop/options.h */
void gui_options_init_defaults(void)
{
@@ -487,7 +514,6 @@ void gui_init(int argc, char** argv)
if (pipe(sEventPipe) < 0)
return;
if (!replicated) {
- new NSBrowserApplication;
sBAppThreadID = spawn_thread(bapp_thread, "BApplication(NetSurf)", B_NORMAL_PRIORITY, (void *)find_thread(NULL));
if (sBAppThreadID < B_OK)
return; /* #### handle errors */
diff --git a/beos/gui.h b/beos/gui.h
index 6bbfa1d..af35677 100644
--- a/beos/gui.h
+++ b/beos/gui.h
@@ -30,6 +30,8 @@
#define CALLED() fprintf(stderr, "%s()\n", __FUNCTION__);
extern bool replicated;
+int gui_init_replicant(int argc, char** argv);
+
#if 0 /* GTK */
//extern GladeXML *gladeWindows;
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index e52e209..c83cf95 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -174,6 +174,10 @@ static int32 nsbeos_replicant_main_thread(void *_arg);
// in beos_gui.cpp
extern int main(int argc, char** argv);
+// in fetch_rsrc.cpp
+extern BResources *gAppResources;
+
+
#warning XXX
#if 0 /* GTK */
static gboolean nsbeos_window_url_activate_event(beosWidget *, gpointer);
@@ -521,6 +525,10 @@ NSBaseView::Instantiate(BMessage *archive)
//netsurf_init(2, info->args);
//return NULL;
+ // do as much as possible in this thread to avoid deadlocks
+
+ gui_init_replicant(2, info->args);
+
replicant_done_sem = create_sem(0, "NS Replicant created");
thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
"NetSurf Main Thread", B_NORMAL_PRIORITY, info);
@@ -531,7 +539,8 @@ NSBaseView::Instantiate(BMessage *archive)
return NULL;
}
resume_thread(nsMainThread);
- while (acquire_sem(replicant_done_sem) == EINTR);
+ //XXX: deadlocks BeHappy
+ //while (acquire_sem(replicant_done_sem) == EINTR);
return view;
}
@@ -650,12 +659,11 @@ NSBrowserWindow::WindowActivated(bool active)
int32 nsbeos_replicant_main_thread(void *_arg)
{
struct replicant_thread_info *info = (struct replicant_thread_info *)_arg;
- int32 ret;
- ret = main(2, info->args);
- //netsurf_main_loop();
- //netsurf_exit();
+ int32 ret = 0;
+
+ netsurf_main_loop();
+ netsurf_exit();
delete info;
- //release
delete_sem(replicant_done_sem);
return ret;
}
@@ -1761,7 +1769,7 @@ void BBitmapButton::SetBitmap(const char* attrname)
{
#ifdef __HAIKU__
size_t size = 0;
- const void* data = BApplication::AppResources()->LoadResource('VICN', attrname, &size);
+ const void* data = gAppResources->LoadResource('VICN', attrname, &size);
if (!data) {
printf("CANT LOAD RESOURCE %s\n", attrname);
-----------------------------------------------------------------------
Summary of changes:
beos/fetch_rsrc.cpp | 2 +-
beos/gui.cpp | 28 +++++++++++++++++++++++++++-
beos/gui.h | 2 ++
beos/scaffolding.cpp | 22 +++++++++++++++-------
4 files changed, 45 insertions(+), 9 deletions(-)
diff --git a/beos/fetch_rsrc.cpp b/beos/fetch_rsrc.cpp
index 563f431..d841a1d 100644
--- a/beos/fetch_rsrc.cpp
+++ b/beos/fetch_rsrc.cpp
@@ -66,7 +66,7 @@ struct fetch_rsrc_context {
static struct fetch_rsrc_context *ring = NULL;
-static BResources *gAppResources = NULL;
+BResources *gAppResources = NULL;
static bool fetch_rsrc_initialise(lwc_string *scheme)
{
diff --git a/beos/gui.cpp b/beos/gui.cpp
index 9e26d44..dacdee9 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -457,6 +457,12 @@ int main(int argc, char** argv)
options.Append("x-vnd.NetSurf");
}
+ if (!replicated) {
+ // create the Application object before trying to use messages
+ // so we can open an alert in case of error.
+ new NSBrowserApplication;
+ }
+
char* messages = "/boot/apps/netsurf/res/en/Messages";
/* initialise netsurf */
@@ -472,6 +478,27 @@ int main(int argc, char** argv)
return 0;
}
+/** called when replicated from NSBaseView::Instantiate() */
+int gui_init_replicant(int argc, char** argv)
+{
+ setbuf(stderr, NULL);
+
+ BPath options;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
+ options.Append("x-vnd.NetSurf");
+ }
+
+ char* messages = "/boot/apps/netsurf/res/en/Messages";
+
+ /* initialise netsurf */
+ netsurf_init(&argc, &argv, options.Path(), messages);
+
+ gui_init(argc, argv);
+ gui_init2(argc, argv);
+
+ return 0;
+}
+
/* Documented in desktop/options.h */
void gui_options_init_defaults(void)
{
@@ -487,7 +514,6 @@ void gui_init(int argc, char** argv)
if (pipe(sEventPipe) < 0)
return;
if (!replicated) {
- new NSBrowserApplication;
sBAppThreadID = spawn_thread(bapp_thread, "BApplication(NetSurf)", B_NORMAL_PRIORITY, (void *)find_thread(NULL));
if (sBAppThreadID < B_OK)
return; /* #### handle errors */
diff --git a/beos/gui.h b/beos/gui.h
index 6bbfa1d..af35677 100644
--- a/beos/gui.h
+++ b/beos/gui.h
@@ -30,6 +30,8 @@
#define CALLED() fprintf(stderr, "%s()\n", __FUNCTION__);
extern bool replicated;
+int gui_init_replicant(int argc, char** argv);
+
#if 0 /* GTK */
//extern GladeXML *gladeWindows;
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index e52e209..c83cf95 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -174,6 +174,10 @@ static int32 nsbeos_replicant_main_thread(void *_arg);
// in beos_gui.cpp
extern int main(int argc, char** argv);
+// in fetch_rsrc.cpp
+extern BResources *gAppResources;
+
+
#warning XXX
#if 0 /* GTK */
static gboolean nsbeos_window_url_activate_event(beosWidget *, gpointer);
@@ -521,6 +525,10 @@ NSBaseView::Instantiate(BMessage *archive)
//netsurf_init(2, info->args);
//return NULL;
+ // do as much as possible in this thread to avoid deadlocks
+
+ gui_init_replicant(2, info->args);
+
replicant_done_sem = create_sem(0, "NS Replicant created");
thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
"NetSurf Main Thread", B_NORMAL_PRIORITY, info);
@@ -531,7 +539,8 @@ NSBaseView::Instantiate(BMessage *archive)
return NULL;
}
resume_thread(nsMainThread);
- while (acquire_sem(replicant_done_sem) == EINTR);
+ //XXX: deadlocks BeHappy
+ //while (acquire_sem(replicant_done_sem) == EINTR);
return view;
}
@@ -650,12 +659,11 @@ NSBrowserWindow::WindowActivated(bool active)
int32 nsbeos_replicant_main_thread(void *_arg)
{
struct replicant_thread_info *info = (struct replicant_thread_info *)_arg;
- int32 ret;
- ret = main(2, info->args);
- //netsurf_main_loop();
- //netsurf_exit();
+ int32 ret = 0;
+
+ netsurf_main_loop();
+ netsurf_exit();
delete info;
- //release
delete_sem(replicant_done_sem);
return ret;
}
@@ -1761,7 +1769,7 @@ void BBitmapButton::SetBitmap(const char* attrname)
{
#ifdef __HAIKU__
size_t size = 0;
- const void* data = BApplication::AppResources()->LoadResource('VICN', attrname, &size);
+ const void* data = gAppResources->LoadResource('VICN', attrname, &size);
if (!data) {
printf("CANT LOAD RESOURCE %s\n", attrname);
--
NetSurf Browser
10 years, 2 months
netsurf: branch mmu_man/beos-fixes created. 9b009dfb013d26a305612d58463731be0f527e48
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/9b009dfb013d26a305612...
...commit http://git.netsurf-browser.org/netsurf.git/commit/9b009dfb013d26a305612d5...
...tree http://git.netsurf-browser.org/netsurf.git/tree/9b009dfb013d26a305612d584...
The branch, mmu_man/beos-fixes has been created
at 9b009dfb013d26a305612d58463731be0f527e48 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/9b009dfb013d26a3056...
commit 9b009dfb013d26a305612d58463731be0f527e48
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: Fix toolbar border
Use B_PLAIN_BORDER instead of the default B_FANCY_BORDER.
Also force full redraw on resize to avoid artefacts.
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 3c42624..e52e209 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -2166,11 +2166,14 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
// the toolbar is also the dragger for now
// XXX: try to stuff it in the status bar at the bottom
// (BDragger *must* be a parent, sibiling or direct child of NSBaseView!)
+ // XXX: B_FULL_UPDATE_ON_RESIZE avoids leaving bits on resize,
+ // but causes flicker
rect = g->top_view->Bounds();
rect.bottom = rect.top + TOOLBAR_HEIGHT - 1;
rect.right = rect.right - DRAGGER_WIDTH;
g->tool_bar = new BBox(rect, "Toolbar",
- B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW);
+ B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS
+ | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
g->top_view->AddChild(g->tool_bar);
g->tool_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
g->tool_bar->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/dea524f585d8ceff39b...
commit dea524f585d8ceff39b7ce06767feeabc9fd6184
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: gcc2 fix
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 74c3c81..3c42624 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -1607,7 +1607,8 @@ void nsbeos_attach_toplevel_view(nsbeos_scaffolding *g, BView *view)
g->window->Show();
if(NSBrowserWindow::activeWindow) {
- BWindowStack(NSBrowserWindow::activeWindow).AddWindow(g->window);
+ BWindowStack stack(NSBrowserWindow::activeWindow);
+ stack.AddWindow(g->window);
}
#endif
g->window->Show();
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/fde30ff958434d3a956...
commit fde30ff958434d3a9564d6a033081554ed547144
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: Fix gui_poll()
Reintroduce curl_multi_fdset() and fix timeout calculations.
diff --git a/beos/gui.cpp b/beos/gui.cpp
index c4e7feb..9e26d44 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -679,41 +679,74 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf
void gui_poll(bool active)
{
//CALLED();
+ CURLMcode code;
fd_set read_fd_set, write_fd_set, exc_fd_set;
+ int max_fd = 0;
struct timeval timeout;
unsigned int fd_count = 0;
+ bool block = true;
bigtime_t next_schedule = 0;
+ // handle early deadlines
schedule_run();
FD_ZERO(&read_fd_set);
FD_ZERO(&write_fd_set);
FD_ZERO(&exc_fd_set);
+ if (active) {
+ code = curl_multi_fdset(fetch_curl_multi,
+ &read_fd_set,
+ &write_fd_set,
+ &exc_fd_set,
+ &max_fd);
+ assert(code == CURLM_OK);
+ }
+
// our own event pipe
FD_SET(sEventPipe[0], &read_fd_set);
-
+ max_fd = MAX(max_fd, sEventPipe[0] + 1);
// If there are pending events elsewhere, we should not be blocking
- if ((!browser_reformat_pending) && (!active)) {
- next_schedule = earliest_callback_timeout - system_time();
+ if (!browser_reformat_pending) {
+ if (earliest_callback_timeout != B_INFINITE_TIMEOUT) {
+ next_schedule = earliest_callback_timeout - system_time();
+ block = false;
+ }
+
+ // we're quite late already...
+ if (next_schedule < 0)
+ next_schedule = 0;
- } // else, we're not allowed to sleep, there is other activity going on.
+ } else //we're not allowed to sleep, there is other activity going on.
+ block = false;
+
+ /*
+ LOG(("gui_poll: browser_reformat_pending:%d earliest_callback_timeout:%Ld"
+ " next_schedule:%Ld block:%d ", browser_reformat_pending,
+ earliest_callback_timeout, next_schedule, block));
+ */
timeout.tv_sec = (long)(next_schedule / 1000000LL);
timeout.tv_usec = (long)(next_schedule % 1000000LL);
- fd_count = select(sEventPipe[0] + 1, &read_fd_set, &write_fd_set, &exc_fd_set,
- &timeout);
+ //LOG(("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule));
+ fd_count = select(max_fd, &read_fd_set, &write_fd_set, &exc_fd_set,
+ block ? NULL : &timeout);
+ //LOG(("select: %d\n", fd_count));
if (fd_count > 0 && FD_ISSET(sEventPipe[0], &read_fd_set)) {
BMessage *message;
int len = read(sEventPipe[0], &message, sizeof(void *));
- LOG(("gui_poll: BMessage ? %d read", len));
- if (len == sizeof(void *))
+ //LOG(("gui_poll: BMessage ? %d read", len));
+ if (len == sizeof(void *)) {
+ //LOG(("gui_poll: BMessage.what %-4.4s\n", &(message->what)));
nsbeos_dispatch_event(message);
+ }
}
+ schedule_run();
+
if (browser_reformat_pending)
nsbeos_window_process_reformats();
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/c496d9080fa19314a2b...
commit c496d9080fa19314a2b910386228f6b10170cc3c
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: gcc2 fixes
We'll probably drop gcc2 support soon though.
diff --git a/beos/Makefile.target b/beos/Makefile.target
index ce47032..0c662cb 100644
--- a/beos/Makefile.target
+++ b/beos/Makefile.target
@@ -61,7 +61,12 @@
# cross: Haiku ?
NETLDFLAGS := -lnetwork
endif
- LDFLAGS += -lbe -ltranslation -ltracker $(NETLDFLAGS) -lstdc++ -lsupc++
+ LDFLAGS += -lbe -ltranslation -ltracker $(NETLDFLAGS)
+ ifeq ($(GCCVER),2)
+ LDFLAGS += -lstdc++.r4
+ else
+ LDFLAGS += -lstdc++ -lsupc++
+ endif
ifeq ($(HOST),beos)
CFLAGS += -I$(PREFIX)/include
diff --git a/beos/download.cpp b/beos/download.cpp
index e1a0c8c..bdd85b5 100644
--- a/beos/download.cpp
+++ b/beos/download.cpp
@@ -16,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define __STDBOOL_H__ 1
+#include <stdbool.h>
+
extern "C" {
#include "desktop/gui.h"
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/7e5ac02785ea909f72b...
commit 7e5ac02785ea909f72b39d1c30f2aa15fbacfa87
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
Whitespace cleanup
diff --git a/beos/Makefile.target b/beos/Makefile.target
index f4b51ab..ce47032 100644
--- a/beos/Makefile.target
+++ b/beos/Makefile.target
@@ -16,7 +16,7 @@
CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \
-D_BSD_SOURCE -D_POSIX_C_SOURCE \
- -Drestrict="" -Wno-multichar
+ -Drestrict="" -Wno-multichar
# DEBUG
CFLAGS += -g -O0
# -DDEBUG=1
@@ -97,7 +97,7 @@ RDEF_IMP_BEOS := $(addprefix $(OBJROOT)/,$(subst /,_,$(RDEF_IMP_BEOS)))
RDEP_BEOS := \
adblock.css beosdefault.css default.css internal.css quirks.css \
- netsurf.png ca-bundle.txt
+ netsurf.png ca-bundle.txt
RDEP_BEOS := $(addprefix beos/res/,$(RDEP_BEOS)) \
$(wildcard beos/res/Icons/*.png) \
$(wildcard beos/res/throbber/throbber*.png)
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/eb28188661262eef8aa...
commit eb28188661262eef8aad4b530a3f16532aceffd4
Author: Adrien Destugues - PulkoMandy <pulkomandy(a)pulkomandy.tk>
Commit: François Revol <revol(a)free.fr>
Update the BeOS/Haiku port
* Toolbar use HVIF icons on Haiku
* Download window
* Some tweaks to the event loop to let network traffic happen
Signed-off-by: François Revol <revol(a)free.fr>
diff --git a/Makefile b/Makefile
index c80378c..428aa74 100644
--- a/Makefile
+++ b/Makefile
@@ -453,7 +453,7 @@ ifeq ($(TARGET),beos)
$(Q)$(BEOS_SETVER) $(EXETARGET) \
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
-short "NetSurf $(VERSION_FULL)" \
- -long "NetSurf $(VERSION_FULL) © 2003 - 2008 The NetSurf Developers"
+ -long "NetSurf $(VERSION_FULL) © 2003 - 2012 The NetSurf Developers"
$(VQ)echo " MIMESET: $(EXETARGET)"
$(Q)$(BEOS_MIMESET) $(EXETARGET)
endif
diff --git a/beos/Makefile.target b/beos/Makefile.target
index af7c939..f4b51ab 100644
--- a/beos/Makefile.target
+++ b/beos/Makefile.target
@@ -9,8 +9,10 @@
# for Haiku
LDFLAGS += -L/boot/common/lib
# some people do *not* have libm...
- LDFLAGS += -lcurl -liconv
- LDFLAGS += -lssl -lcrypto -lcss -ldom -lparserutils -lhubbub -lwapcaplet
+ LDFLAGS += -lssl -lcrypto -lcss
+ $(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
+ LDFLAGS += -ldom -lparserutils -lhubbub -lwapcaplet
+ LDFLAGS += -lexpat -lxml2 -lcurl -liconv
CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \
-D_BSD_SOURCE -D_POSIX_C_SOURCE \
@@ -59,9 +61,8 @@
# cross: Haiku ?
NETLDFLAGS := -lnetwork
endif
- LDFLAGS += -lbe -ltranslation $(NETLDFLAGS)
+ LDFLAGS += -lbe -ltranslation -ltracker $(NETLDFLAGS) -lstdc++ -lsupc++
- $(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
ifeq ($(HOST),beos)
CFLAGS += -I$(PREFIX)/include
LDFLAGS += -L$(PREFIX)/lib
@@ -82,11 +83,9 @@
# ----------------------------------------------------------------------------
# S_BEOS are sources purely for the BeOS build
-S_BEOS := about.cpp bitmap.cpp fetch_rsrc.cpp \
- filetype.cpp font.cpp gui.cpp login.cpp \
- gui_options.cpp plotters.cpp \
- scaffolding.cpp search.cpp schedule.cpp \
- thumbnail.cpp treeview.cpp throbber.cpp \
+S_BEOS := about.cpp bitmap.cpp download.cpp fetch_rsrc.cpp filetype.cpp \
+ font.cpp gui.cpp login.cpp gui_options.cpp plotters.cpp scaffolding.cpp \
+ search.cpp schedule.cpp thumbnail.cpp treeview.cpp throbber.cpp \
window.cpp system_colour.cpp
S_BEOS := $(addprefix beos/,$(S_BEOS))
@@ -98,7 +97,7 @@ RDEF_IMP_BEOS := $(addprefix $(OBJROOT)/,$(subst /,_,$(RDEF_IMP_BEOS)))
RDEP_BEOS := \
adblock.css beosdefault.css default.css internal.css quirks.css \
- netsurf.png ca-bundle.txt messages
+ netsurf.png ca-bundle.txt
RDEP_BEOS := $(addprefix beos/res/,$(RDEP_BEOS)) \
$(wildcard beos/res/Icons/*.png) \
$(wildcard beos/res/throbber/throbber*.png)
@@ -126,7 +125,7 @@ install-beos:
@cp -vRL beos/res/beosdefault.css $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
@cp -vRL gtk/res/license $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
# @cp -vRL beos/res/throbber/*.png $(DESTDIR)$(NETSURF_BEOS_RESOURCES)throbber
- gzip -9v < beos/res/messages > $(DESTDIR)$(NETSURF_BEOS_RESOURCES)messages
+ $(call split_install_messages, beos, $(DESTDIR)$(NETSURF_BEOS_RESOURCES))
# ----------------------------------------------------------------------------
# Package target
diff --git a/beos/WindowStack.h b/beos/WindowStack.h
new file mode 100644
index 0000000..947b143
--- /dev/null
+++ b/beos/WindowStack.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2010, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef WINDOW_STACK_H
+#define WINDOW_STACK_H
+
+
+#include <Window.h>
+
+
+class BWindowStack {
+public:
+ BWindowStack(BWindow* window);
+ ~BWindowStack();
+
+ status_t AddWindow(const BWindow* window);
+ status_t AddWindow(const BMessenger& window);
+ status_t AddWindowAt(const BWindow* window,
+ int32 position);
+ status_t AddWindowAt(const BMessenger& window,
+ int32 position);
+
+ status_t RemoveWindow(const BWindow* window);
+ status_t RemoveWindow(const BMessenger& window);
+ status_t RemoveWindowAt(int32 position,
+ BMessenger* window = NULL);
+
+ int32 CountWindows();
+
+ status_t WindowAt(int32 position,
+ BMessenger& messenger);
+ bool HasWindow(const BWindow* window);
+ bool HasWindow(const BMessenger& window);
+
+private:
+ status_t _AttachMessenger(const BMessenger& window);
+ status_t _ReadMessenger(BMessenger& window);
+ status_t _StartMessage(int32 what);
+
+ BPrivate::PortLink* fLink;
+};
+
+
+#endif
diff --git a/beos/download.cpp b/beos/download.cpp
new file mode 100644
index 0000000..e1a0c8c
--- /dev/null
+++ b/beos/download.cpp
@@ -0,0 +1,246 @@
+/*
+ * Copyright 2012 Adrien Destugues <pulkomandy(a)pulkomandy.tk>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+extern "C" {
+#include "desktop/gui.h"
+}
+#include "beos/download.h"
+
+#include <File.h>
+#include <FilePanel.h>
+#include <Locker.h>
+#include <Messenger.h>
+#include <StatusBar.h>
+#include <Window.h>
+
+class NSDownloadWindow: public BWindow
+{
+ public:
+ NSDownloadWindow(download_context* ctx);
+ ~NSDownloadWindow();
+
+ void MessageReceived(BMessage* message);
+
+ void Progress(int size);
+ void Failure(const char* error);
+ void Success();
+ private:
+ download_context* ctx;
+ BStatusBar* bar;
+ unsigned long progress;
+ bool success;
+};
+
+
+struct gui_download_window {
+ download_context* ctx;
+ NSDownloadWindow* window;
+
+ BLocker* storageLock;
+ BDataIO* storage;
+};
+
+
+NSDownloadWindow::NSDownloadWindow(download_context* ctx)
+ : BWindow(BRect(30, 30, 400, 200), "Downloads", B_TITLED_WINDOW,
+ B_NOT_RESIZABLE)
+ , ctx(ctx)
+ , progress(0)
+ , success(false)
+{
+ unsigned long dlsize = download_context_get_total_length(ctx);
+ char* buffer = human_friendly_bytesize(dlsize);
+
+ // Create the status bar
+ BRect rect = Bounds();
+ rect.InsetBy(3, 3);
+ bar = new BStatusBar(rect, "progress",
+ download_context_get_filename(ctx), buffer);
+ bar->SetMaxValue(dlsize);
+
+ // Create the backgroundview (just so that the area around the progress bar
+ // is B_PANEL_BACKGROUND_COLOR instead of white)
+ BView* back = new BView(Bounds(), "back", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
+ back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+
+ // Add the views to the window
+ back->AddChild(bar);
+ AddChild(back);
+
+ // Resize the window to leave a margin around the progress bar
+ BRect size = bar->Bounds();
+ ResizeTo(size.Width() + 6, size.Height() + 6);
+ Show();
+}
+
+
+NSDownloadWindow::~NSDownloadWindow()
+{
+ download_context_abort(ctx);
+ download_context_destroy(ctx);
+}
+
+
+void
+NSDownloadWindow::MessageReceived(BMessage* message)
+{
+ switch(message->what)
+ {
+ case B_SAVE_REQUESTED:
+ {
+ entry_ref directory;
+ const char* name;
+ struct gui_download_window* dw;
+ BFilePanel* source;
+
+ message->FindRef("directory", &directory);
+ message->FindString("name", &name);
+ message->FindPointer("dw", (void**)&dw);
+
+ BDirectory dir(&directory);
+ BFile* storage = new BFile(&dir, name,
+ B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
+ dw->storageLock->Lock();
+
+ BMallocIO* tempstore = dynamic_cast<BMallocIO*>(dw->storage);
+
+ storage->Write(tempstore->Buffer(), tempstore->BufferLength());
+ delete dw->storage;
+
+ if (success)
+ delete storage; // File is already finished downloading !
+ else
+ dw->storage = storage;
+ dw->storageLock->Unlock();
+
+ message->FindPointer("source", (void**)&source);
+ delete source;
+
+ break;
+ }
+ default:
+ BWindow::MessageReceived(message);
+ }
+}
+
+
+void
+NSDownloadWindow::Progress(int size)
+{
+ progress += size;
+
+ char* buffer = human_friendly_bytesize(progress);
+ strcat(buffer, "/");
+
+ bar->LockLooper();
+ bar->Update(size, NULL, buffer);
+ bar->Invalidate();
+ bar->UnlockLooper();
+}
+
+
+void
+NSDownloadWindow::Success()
+{
+ bar->LockLooper();
+ bar->SetBarColor(ui_color(B_SUCCESS_COLOR));
+ bar->UnlockLooper();
+
+ success = true;
+}
+
+
+void
+NSDownloadWindow::Failure(const char* error)
+{
+ bar->LockLooper();
+ bar->Update(0, NULL, error);
+ bar->SetBarColor(ui_color(B_FAILURE_COLOR));
+ bar->UnlockLooper();
+}
+
+
+struct gui_download_window *gui_download_window_create(download_context *ctx,
+ struct gui_window *parent)
+{
+ struct gui_download_window *download = (struct gui_download_window*)malloc(sizeof *download);
+ if (download == NULL)
+ return NULL;
+
+ download->storageLock = new BLocker("storage_lock");
+ download->storage = new BMallocIO();
+ download->ctx = ctx;
+
+ download->window = new NSDownloadWindow(ctx);
+
+ // Also ask the user where to save the file
+ // TODO inject the suggested name somehow
+ BMessage* msg = new BMessage(B_SAVE_REQUESTED);
+
+ BFilePanel* panel = new BFilePanel(B_SAVE_PANEL,
+ new BMessenger(download->window), NULL, 0, false);
+
+ msg->AddPointer("source", panel);
+ msg->AddPointer("dw", download);
+ panel->SetMessage(msg);
+
+ panel->Show();
+
+ return download;
+}
+
+
+nserror gui_download_window_data(struct gui_download_window *dw,
+ const char *data, unsigned int size)
+{
+ dw->window->Progress(size);
+
+ dw->storageLock->Lock();
+ dw->storage->Write(data, size);
+ dw->storageLock->Unlock();
+
+ return NSERROR_OK;
+}
+
+
+void gui_download_window_error(struct gui_download_window *dw,
+ const char *error_msg)
+{
+ dw->window->Failure(error_msg);
+
+ delete dw->storageLock;
+ delete dw->storage;
+}
+
+
+void gui_download_window_done(struct gui_download_window *dw)
+{
+ dw->window->Success();
+
+ dw->storageLock->Lock();
+
+ // Only delete if the storage is already a file. Else, we must wait for the
+ // user to select something in the BFilePanel!
+ BFile* file = dynamic_cast<BFile*>(dw->storage);
+ delete file;
+ if (file)
+ delete dw->storageLock;
+ else
+ dw->storageLock->Unlock();
+}
+
diff --git a/beos/download.h b/beos/download.h
new file mode 100644
index 0000000..9c8d3ad
--- /dev/null
+++ b/beos/download.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2012 Adrien Destugues <pulkomandy(a)pulkomandy.tk>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
diff --git a/beos/fetch_rsrc.cpp b/beos/fetch_rsrc.cpp
index 79dea4e..563f431 100644
--- a/beos/fetch_rsrc.cpp
+++ b/beos/fetch_rsrc.cpp
@@ -48,6 +48,7 @@ extern "C" {
#include <image.h>
#include <Resources.h>
+#include <String.h>
struct fetch_rsrc_context {
struct fetch *parent_fetch;
@@ -209,8 +210,13 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
else
found = gAppResources->HasResource(type, c->name);
if (!found) {
+ BString error("Cannot locate resource: ");
+ if (id)
+ error << id;
+ else
+ error << c->name;
msg.type = FETCH_ERROR;
- msg.data.error = "Cannot locate rsrc: URL";
+ msg.data.error = error.String();
fetch_rsrc_send_callback(&msg, c);
return false;
}
diff --git a/beos/gui.cpp b/beos/gui.cpp
index b275616..c4e7feb 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -450,7 +450,6 @@ static void gui_init2(int argc, char** argv)
/** Normal entry point from OS */
int main(int argc, char** argv)
{
- char buf[PATH_MAX];
setbuf(stderr, NULL);
BPath options;
@@ -458,12 +457,10 @@ int main(int argc, char** argv)
options.Append("x-vnd.NetSurf");
}
- find_resource(buf, "messages", "./beos/res/messages");
- LOG(("Using '%s' as Messages file", buf));
- //messages_load(buf);
+ char* messages = "/boot/apps/netsurf/res/en/Messages";
/* initialise netsurf */
- netsurf_init(&argc, &argv, options.Path(), buf);
+ netsurf_init(&argc, &argv, options.Path(), messages);
gui_init(argc, argv);
gui_init2(argc, argv);
@@ -553,37 +550,38 @@ void gui_init(int argc, char** argv)
/* check what the font settings are, setting them to a default font
* if they're not set - stops Pango whinging
*/
+#define SETFONTDEFAULT(OPTION,y) if (nsoption_charp(OPTION) == NULL) nsoption_set_charp(OPTION, strdup((y)))
//XXX: use be_plain_font & friends, when we can check if font is serif or not.
/*
font_family family;
font_style style;
be_plain_font->GetFamilyAndStyle(&family, &style);
- nsoption_setnull_charp(font_sans, family);
- nsoption_setnull_charp(font_serif, family);
- nsoption_setnull_charp(font_mono, family);
- nsoption_setnull_charp(font_cursive, family);
- nsoption_setnull_charp(font_fantasy, family);
+ SETFONTDEFAULT(font_sans, family);
+ SETFONTDEFAULT(font_serif, family);
+ SETFONTDEFAULT(font_mono, family);
+ SETFONTDEFAULT(font_cursive, family);
+ SETFONTDEFAULT(font_fantasy, family);
*/
#ifdef __HAIKU__
- nsoption_setnull_charp(font_sans, "DejaVu Sans");
- nsoption_setnull_charp(font_serif, "DejaVu Serif");
- nsoption_setnull_charp(font_mono, "DejaVu Mono");
- nsoption_setnull_charp(font_cursive, "DejaVu Sans");
- nsoption_setnull_charp(font_fantasy, "DejaVu Sans");
+ SETFONTDEFAULT(font_sans, "DejaVu Sans");
+ SETFONTDEFAULT(font_serif, "DejaVu Serif");
+ SETFONTDEFAULT(font_mono, "DejaVu Mono");
+ SETFONTDEFAULT(font_cursive, "DejaVu Sans");
+ SETFONTDEFAULT(font_fantasy, "DejaVu Sans");
#else
- nsoption_setnull_charp(font_sans, "Bitstream Vera Sans");
- nsoption_setnull_charp(font_serif, "Bitstream Vera Serif");
- nsoption_setnull_charp(font_mono, "Bitstream Vera Sans Mono");
- nsoption_setnull_charp(font_cursive, "Bitstream Vera Serif");
- nsoption_setnull_charp(font_fantasy, "Bitstream Vera Serif");
+ SETFONTDEFAULT(font_sans, "Bitstream Vera Sans");
+ SETFONTDEFAULT(font_serif, "Bitstream Vera Serif");
+ SETFONTDEFAULT(font_mono, "Bitstream Vera Sans Mono");
+ SETFONTDEFAULT(font_cursive, "Bitstream Vera Serif");
+ SETFONTDEFAULT(font_fantasy, "Bitstream Vera Serif");
#if 0
- nsoption_setnull_charp(font_sans, "Swis721 BT");
- nsoption_setnull_charp(font_serif, "Dutch801 Rm BT");
- //nsoption_setnull_charp(font_mono, "Monospac821 BT");
- nsoption_setnull_charp(font_mono, "Courier10 BT");
- nsoption_setnull_charp(font_cursive, "Swis721 BT");
- nsoption_setnull_charp(font_fantasy, "Swis721 BT");
+ SETFONTDEFAULT(font_sans, "Swis721 BT");
+ SETFONTDEFAULT(font_serif, "Dutch801 Rm BT");
+ //SETFONTDEFAULT(font_mono, "Monospac821 BT");
+ SETFONTDEFAULT(font_mono, "Courier10 BT");
+ SETFONTDEFAULT(font_cursive, "Swis721 BT");
+ SETFONTDEFAULT(font_fantasy, "Swis721 BT");
#endif
#endif
@@ -681,46 +679,32 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf
void gui_poll(bool active)
{
//CALLED();
- CURLMcode code;
-
fd_set read_fd_set, write_fd_set, exc_fd_set;
- int max_fd = 0;
struct timeval timeout;
unsigned int fd_count = 0;
- bool block = true;
+ bigtime_t next_schedule = 0;
- if (browser_reformat_pending)
- block = false;
+ schedule_run();
FD_ZERO(&read_fd_set);
FD_ZERO(&write_fd_set);
FD_ZERO(&exc_fd_set);
- if (active) {
- code = curl_multi_fdset(fetch_curl_multi,
- &read_fd_set,
- &write_fd_set,
- &exc_fd_set,
- &max_fd);
- assert(code == CURLM_OK);
- }
-
// our own event pipe
FD_SET(sEventPipe[0], &read_fd_set);
- max_fd = MAX(max_fd, sEventPipe[0] + 1);
- bigtime_t next_schedule = earliest_callback_timeout - system_time();
- if (!block)
- next_schedule = 0LL; // now
- if (block && earliest_callback_timeout != B_INFINITE_TIMEOUT)
- block = false;
+ // If there are pending events elsewhere, we should not be blocking
+ if ((!browser_reformat_pending) && (!active)) {
+ next_schedule = earliest_callback_timeout - system_time();
+
+ } // else, we're not allowed to sleep, there is other activity going on.
+
timeout.tv_sec = (long)(next_schedule / 1000000LL);
timeout.tv_usec = (long)(next_schedule % 1000000LL);
- LOG(("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule));
- fd_count = select(max_fd, &read_fd_set, &write_fd_set, &exc_fd_set,
- block ? NULL : &timeout);
+ fd_count = select(sEventPipe[0] + 1, &read_fd_set, &write_fd_set, &exc_fd_set,
+ &timeout);
if (fd_count > 0 && FD_ISSET(sEventPipe[0], &read_fd_set)) {
BMessage *message;
@@ -730,8 +714,6 @@ void gui_poll(bool active)
nsbeos_dispatch_event(message);
}
- schedule_run();
-
if (browser_reformat_pending)
nsbeos_window_process_reformats();
}
@@ -751,31 +733,6 @@ void gui_quit(void)
}
-
-struct gui_download_window *gui_download_window_create(download_context *ctx,
- struct gui_window *gui)
-{
- return NULL;
-}
-
-
-nserror gui_download_window_data(struct gui_download_window *dw,
- const char *data, unsigned int size)
-{
- return NSERROR_OK;
-}
-
-
-void gui_download_window_error(struct gui_download_window *dw,
- const char *error_msg)
-{
-}
-
-
-void gui_download_window_done(struct gui_download_window *dw)
-{
-}
-
#if 0 /* GTK */
static void nsbeos_select_menu_clicked(BCheckMenuItem *checkmenuitem,
gpointer user_data)
diff --git a/beos/login.cpp b/beos/login.cpp
index 32860de..90cadde 100644
--- a/beos/login.cpp
+++ b/beos/login.cpp
@@ -45,7 +45,7 @@ class LoginAlert : public BAlert {
public:
LoginAlert(nserror (*callback)(bool proceed, void *pw),
void *callbaclpw,
- const char *url,
+ nsurl *url,
const char *host,
const char *realm,
const char *text);
@@ -53,7 +53,7 @@ public:
void MessageReceived(BMessage *message);
private:
- BString fUrl; /**< URL being fetched */
+ nsurl* fUrl; /**< URL being fetched */
BString fHost; /**< Host for user display */
BString fRealm; /**< Authentication realm */
nserror (*fCallback)(bool proceed, void *pw);
@@ -63,8 +63,8 @@ private:
BTextControl *fPassControl;
};
-static void create_login_window(const char *host,
- const char *realm, const char *fetchurl,
+static void create_login_window(nsurl *host,
+ lwc_string *realm, const char *fetchurl,
nserror (*cb)(bool proceed, void *pw), void *cbpw);
@@ -73,7 +73,7 @@ static void create_login_window(const char *host,
LoginAlert::LoginAlert(nserror (*callback)(bool proceed, void *pw),
void *callbackpw,
- const char *url,
+ nsurl *url,
const char *host,
const char *realm,
const char *text)
@@ -140,7 +140,7 @@ LoginAlert::MessageReceived(BMessage *message)
break;
BMessage *m = new BMessage(*message);
m->what = 'nsLO';
- m->AddString("URL", fUrl.String());
+ m->AddPointer("URL", fUrl);
m->AddString("Host", fHost.String());
m->AddString("Realm", fRealm.String());
m->AddPointer("callback", (void *)fCallback);
@@ -163,14 +163,13 @@ LoginAlert::MessageReceived(BMessage *message)
}
-void gui_401login_open(const char *url, const char *realm,
+extern "C" void gui_401login_open(nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
- char *host;
+ lwc_string *host;
url_func_result res;
- res = url_host(url, &host);
- assert(res == URL_FUNC_OK);
+ host = nsurl_get_component(url, NSURL_HOST);
create_login_window(url, host, realm, cb, cbpw);
@@ -179,7 +178,7 @@ void gui_401login_open(const char *url, const char *realm,
//void create_login_window(struct browser_window *bw, const char *host,
// const char *realm, const char *fetchurl)
-static void create_login_window(const char *url, const char *host,
+static void create_login_window(nsurl *url, lwc_string *host,
const char *realm, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
@@ -191,8 +190,8 @@ static void create_login_window(const char *url, const char *host,
text << "Host: " << host << "\n";
//text << "\n";
- LoginAlert *a = new LoginAlert(cb, cbpw, url, host, r.String(),
- text.String());
+ LoginAlert *a = new LoginAlert(cb, cbpw, url, lwc_string_data(host),
+ r.String(), text.String());
// asynchronously
a->Go(NULL);
diff --git a/beos/res.rdef b/beos/res.rdef
index b047bd0..b41130a 100644
--- a/beos/res.rdef
+++ b/beos/res.rdef
@@ -32,6 +32,7 @@ resource(408, "throbber8.png") #'data' import "res/throbber/throbber8.png";
/* */
resource(500, "credits.html") #'data' import "res/en/credits.html,faf";
resource(501, "licence.html") #'data' import "res/en/licence.html,faf";
+resource(502, "welcome.html") #'data' import "res/en/welcome.html,faf";
resource(1, "BEOS:APP_FLAGS") (#'APPF') $"01000000";
@@ -397,3 +398,43 @@ resource(101, "BEOS:V:STD_ICON") #'zICO' array {
$"7F793EDCE3F417BB10DA0B"
};
+resource(102, "forward_button") #'VICN' array {
+ $"6E6369660304006603005900020006020000003C6000C000000000004C000048"
+ $"A0000080FF80FF00B300010A0748353448343E223E222C342C3422030A000100"
+ $"30222201178322040A0101001001178322040A02010000"
+};
+
+resource(103, "back_button") #'VICN' array {
+ $"6E6369660304006603005900020006020000003C6000C000000000004C000048"
+ $"A0000080FF80FF00B300010A0722353622362C482C483E363E3648030A000100"
+ $"30222201178322040A0101001001178322040A02010000"
+};
+
+resource(104, "stop_button") #'VICN' array {
+ $"6E6369660304006603800000020006020000003C6000C000000000004C000048"
+ $"A00000FFABABFFD900000208022A40402A02043525BEE325B7D825253525B7D8"
+ $"25BEE33545B7D845BEE345453545BEE345B7D8030A0002000130222201178900"
+ $"040A010200011001178900040A02020100100117850004"
+};
+
+resource(105, "reload_button") #'VICN' array {
+ $"6E6369660404006603004080020006020000003A0000C000000000004C000046"
+ $"7FFF00ABD5FFFF006CD9020006020000003A0000C000000000004C0000467FFF"
+ $"FFAAD4FF00006CD9010606C60F482232383D2D3D2D3826222A2B2329224327BC"
+ $"B7B25A4327060A00010030222201178322040A0101001001178322040A020100"
+ $"000A00010012C00000000000000000C000004AC0004AC00001178422040A0101"
+ $"0012C00000000000000000C000004AA0004AA00001178422040A03010002C000"
+ $"00000000000000C000004AA0004AA000"
+};
+
+resource(106, "home_button") #'VICN' array {
+ $"6E6369660804006603800000020006020000003A8000C000000000004C000047"
+ $"000000FFABABFFD900000554020016020000003AC000C000000000004BE00048"
+ $"A00000FFFFE50300590002000602000000370000C000000000004C00004A5000"
+ $"0080FF80FF00B20003806040040A064836483035222230223635280A04484848"
+ $"42224222480A0542404234352A283428400A042C342C4032403234080A030102"
+ $"1001178400040A040102000A0101001001178402040A020100000A0501011001"
+ $"178402040A060101000A070103000A0701030240AAAA0000000000003E000045"
+ $"0000468000"
+};
+
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 4003b09..74c3c81 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -22,7 +22,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include <BeBuild.h>
+#include <Box.h>
#include <Button.h>
#include <Dragger.h>
#include <Menu.h>
@@ -31,6 +33,8 @@
#include <Node.h>
#include <Path.h>
#include <PopUpMenu.h>
+#include <Resources.h>
+#include <Roster.h>
#include <Screen.h>
#include <ScrollView.h>
#include <String.h>
@@ -38,6 +42,12 @@
#include <TextControl.h>
#include <View.h>
#include <Window.h>
+
+#if defined(__HAIKU__)
+#include <IconUtils.h>
+#include "WindowStack.h"
+#endif
+
#include <fs_attr.h>
extern "C" {
#include "content/content.h"
@@ -320,6 +330,7 @@ void
NSThrobber::SetBitmap(const BBitmap *bitmap)
{
fBitmap = bitmap;
+ Invalidate();
}
@@ -458,7 +469,7 @@ NSBaseView::MessageReceived(BMessage *message)
nsbeos_pipe_message_top(message, NULL, fScaffolding);
break;
default:
- message->PrintToStream();
+ //message->PrintToStream();
BView::MessageReceived(message);
}
}
@@ -539,6 +550,7 @@ void
NSBaseView::AllAttached()
{
BView::AllAttached();
+
struct beos_scaffolding *g = fScaffolding;
if (!g)
return;
@@ -576,6 +588,8 @@ NSBrowserWindow::NSBrowserWindow(BRect frame, struct beos_scaffolding *scaf)
NSBrowserWindow::~NSBrowserWindow()
{
+ if(activeWindow == this)
+ activeWindow = NULL;
}
@@ -621,6 +635,16 @@ NSBrowserWindow::QuitRequested(void)
}
+void
+NSBrowserWindow::WindowActivated(bool active)
+{
+ if(active)
+ activeWindow = this;
+ else if(activeWindow == this)
+ activeWindow = NULL;
+}
+
+
// #pragma mark - implementation
int32 nsbeos_replicant_main_thread(void *_arg)
@@ -686,6 +710,10 @@ void nsbeos_scaffolding_update_colors(nsbeos_scaffolding *g)
}
+/*static*/ BWindow*
+NSBrowserWindow::activeWindow = NULL;
+
+
void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *message)
{
int width, height;
@@ -907,6 +935,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
text = scaffold->url_bar->Text();
scaffold->url_bar->UnlockLooper();
+ NSBrowserWindow::activeWindow = scaffold->window;
browser_window_create(text.String(), bw, NULL, false, false);
break;
}
@@ -1570,7 +1599,19 @@ void nsbeos_attach_toplevel_view(nsbeos_scaffolding *g, BView *view)
message->AddPointer("scaffolding", g);
g->window->AddShortcut('H', 0, message, view);
+
+#if defined(__HAIKU__)
+ // Make sure the window is layouted and answering to events, but do not
+ // show it before it is actually resized
+ g->window->Hide();
+ g->window->Show();
+
+ if(NSBrowserWindow::activeWindow) {
+ BWindowStack(NSBrowserWindow::activeWindow).AddWindow(g->window);
+ }
+#endif
g->window->Show();
+
} else {
if (g->top_view->Looper())
g->top_view->UnlockLooper();
@@ -1659,6 +1700,97 @@ static BMenuItem *make_menu_item(const char *name, BMessage *message)
return item;
}
+
+class BBitmapButton: public BButton
+{
+ public:
+ BBitmapButton(BRect rect, const char* name, const char* label,
+ BMessage* message);
+ ~BBitmapButton();
+
+ void Draw(BRect updateRect);
+ void SetBitmap(const char* attrName);
+ private:
+ BBitmap* fBitmap;
+ BBitmap* fDisabledBitmap;
+};
+
+
+BBitmapButton::BBitmapButton(BRect rect, const char* name, const char* label,
+ BMessage* message)
+ : BButton(rect, name, label, message)
+{
+ SetBitmap(name);
+}
+
+
+BBitmapButton::~BBitmapButton()
+{
+ delete fBitmap;
+ delete fDisabledBitmap;
+}
+
+
+void BBitmapButton::Draw(BRect updateRect)
+{
+ if(fBitmap == NULL) {
+ BButton::Draw(updateRect);
+ return;
+ }
+
+ SetDrawingMode(B_OP_COPY);
+ FillRect(updateRect, B_SOLID_LOW);
+ rgb_color color = LowColor();
+
+ SetDrawingMode(B_OP_ALPHA);
+ if(IsEnabled()) {
+ if(Value() != 0) {
+ // button is clicked
+ DrawBitmap(fBitmap, BPoint(1, 1));
+ } else {
+ // button is released
+ DrawBitmap(fBitmap, BPoint(0, 0));
+ }
+ } else
+ DrawBitmap(fDisabledBitmap, BPoint(0, 0));
+}
+
+
+void BBitmapButton::SetBitmap(const char* attrname)
+{
+#ifdef __HAIKU__
+ size_t size = 0;
+ const void* data = BApplication::AppResources()->LoadResource('VICN', attrname, &size);
+
+ if (!data) {
+ printf("CANT LOAD RESOURCE %s\n", attrname);
+ return;
+ }
+
+ fBitmap = new BBitmap(BRect(0, 0, 32, 32), B_RGB32);
+ status_t status = BIconUtils::GetVectorIcon((const uint8*)data, size, fBitmap);
+
+ if(status != B_OK) {
+ fprintf(stderr, "%s > oops %s\n", attrname, strerror(status));
+ delete fBitmap;
+ fBitmap = NULL;
+ }
+
+ fDisabledBitmap = new BBitmap(fBitmap);
+ rgb_color* pixel = (rgb_color*)fDisabledBitmap->Bits();
+ for(int i = 0; i < fDisabledBitmap->BitsLength()/4; i++)
+ {
+ *pixel = tint_color(*pixel, B_DISABLED_MARK_TINT);
+ pixel++;
+ }
+#else
+ // No vector icon support on BeOS. We could try to load a bitmap one
+ fBitmap = NULL;
+ fDisabledBitmap = NULL;
+#endif
+}
+
+
nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
{
struct beos_scaffolding *g = (struct beos_scaffolding *)malloc(sizeof(*g));
@@ -1676,7 +1808,6 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
g->window = NULL;
g->menu_bar = NULL;
- g->window = NULL;
if (replicated && !replicant_view) {
warn_user("Error: No subwindow allowed when replicated.", NULL);
@@ -1685,7 +1816,6 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
if (!replicant_view) {
-
BRect frame(0, 0, 600-1, 500-1);
if (nsoption_int(window_width) > 0) {
frame.Set(0, 0, nsoption_int(window_width) - 1, nsoption_int(window_height) - 1);
@@ -1696,7 +1826,7 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
NSBrowserWindow *win = nsbeos_find_last_window();
if (win) {
pos = win->Frame().LeftTop();
- win->Unlock();
+ win->UnlockLooper();
}
pos += BPoint(20, 20);
BScreen screen;
@@ -2038,14 +2168,13 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
rect = g->top_view->Bounds();
rect.bottom = rect.top + TOOLBAR_HEIGHT - 1;
rect.right = rect.right - DRAGGER_WIDTH;
- g->tool_bar = new BView(rect, "Toolbar",
+ g->tool_bar = new BBox(rect, "Toolbar",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW);
g->top_view->AddChild(g->tool_bar);
g->tool_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
g->tool_bar->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
// buttons
-#warning use BPictureButton
rect = g->tool_bar->Bounds();
rect.right = TOOLBAR_HEIGHT;
rect.InsetBySelf(5, 5);
@@ -2054,35 +2183,35 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
message = new BMessage('back');
message->AddPointer("scaffolding", g);
- g->back_button = new BButton(rect, "back_button", "<", message);
+ g->back_button = new BBitmapButton(rect, "back_button", "<", message);
g->tool_bar->AddChild(g->back_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('forw');
message->AddPointer("scaffolding", g);
- g->forward_button = new BButton(rect, "forward_button", ">", message);
+ g->forward_button = new BBitmapButton(rect, "forward_button", ">", message);
g->tool_bar->AddChild(g->forward_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('stop');
message->AddPointer("scaffolding", g);
- g->stop_button = new BButton(rect, "stop_button", "S", message);
+ g->stop_button = new BBitmapButton(rect, "stop_button", "S", message);
g->tool_bar->AddChild(g->stop_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('relo');
message->AddPointer("scaffolding", g);
- g->reload_button = new BButton(rect, "reload_button", "R", message);
+ g->reload_button = new BBitmapButton(rect, "reload_button", "R", message);
g->tool_bar->AddChild(g->reload_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('home');
message->AddPointer("scaffolding", g);
- g->home_button = new BButton(rect, "home_button", "H", message);
+ g->home_button = new BBitmapButton(rect, "home_button", "H", message);
g->tool_bar->AddChild(g->home_button);
nButtons++;
@@ -2407,3 +2536,4 @@ void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where)
{
g->popup_menu->Go(where);
}
+
diff --git a/beos/scaffolding.h b/beos/scaffolding.h
index ae78391..bd13230 100644
--- a/beos/scaffolding.h
+++ b/beos/scaffolding.h
@@ -61,11 +61,15 @@ virtual ~NSBrowserWindow();
virtual void DispatchMessage(BMessage *message, BHandler *handler);
virtual void MessageReceived(BMessage *message);
virtual bool QuitRequested(void);
+void WindowActivated(bool active);
struct beos_scaffolding *Scaffolding() const { return fScaffolding; };
+static BWindow* activeWindow;
private:
struct beos_scaffolding *fScaffolding;
+
+
};
diff --git a/beos/schedule.cpp b/beos/schedule.cpp
index 3f82235..db0992e 100644
--- a/beos/schedule.cpp
+++ b/beos/schedule.cpp
@@ -95,8 +95,9 @@ schedule(int t, void (*callback)(void *p), void *p)
cb->context = p;
cb->callback_killed = cb->callback_fired = false;
cb->timeout = timeout;
- if (earliest_callback_timeout > timeout)
+ if (earliest_callback_timeout > timeout) {
earliest_callback_timeout = timeout;
+ }
callbacks->AddItem(cb);
}
@@ -104,11 +105,12 @@ bool
schedule_run(void)
{
LOG(("schedule_run()"));
+
+ earliest_callback_timeout = B_INFINITE_TIMEOUT;
if (callbacks == NULL)
return false; /* Nothing to do */
bigtime_t now = system_time();
- earliest_callback_timeout = B_INFINITE_TIMEOUT;
int32 i;
LOG(("Checking %ld callbacks to for deadline.", this_run->CountItems()));
diff --git a/beos/window.cpp b/beos/window.cpp
index 253b5d1..3e6b2f5 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -131,7 +131,7 @@ static GdkCursor *nsbeos_create_menu_cursor(void);
NSBrowserFrameView::NSBrowserFrameView(BRect frame, struct gui_window *gui)
: BView(frame, "NSBrowserFrameView", B_FOLLOW_ALL_SIDES,
- B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS /*| B_SUBPIXEL_PRECISE*/),
+ B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS ),
fGuiWindow(gui)
{
}
@@ -250,7 +250,7 @@ NSBrowserFrameView::MessageReceived(BMessage *message)
nsbeos_pipe_message_top(message, NULL, fGuiWindow->scaffold);
break;
default:
- message->PrintToStream();
+ //message->PrintToStream();
BView::MessageReceived(message);
}
}
@@ -756,18 +756,25 @@ void nsbeos_dispatch_event(BMessage *message)
break;
case 'nsLO': // login
{
- BString url;
+ nsurl* url;
BString realm;
BString auth;
- if (message->FindString("URL", &url) < B_OK)
+ void* cbpw;
+ nserror (*cb)(bool proceed, void* pw);
+
+ if (message->FindPointer("URL", (void**)&url) < B_OK)
break;
if (message->FindString("Realm", &realm) < B_OK)
break;
if (message->FindString("Auth", &auth) < B_OK)
break;
+ if (message->FindPointer("callback", (void**)&cb) < B_OK)
+ break;
+ if (message->FindPointer("callback_pw", (void**)&cbpw) < B_OK)
+ break;
//printf("login to '%s' with '%s'\n", url.String(), auth.String());
- urldb_set_auth_details(url.String(), realm.String(), auth.String());
- browser_window_go(gui->bw, url.String(), 0, true);
+ urldb_set_auth_details(url, realm.String(), auth.String());
+ cb(true, cbpw);
break;
}
default:
@@ -926,11 +933,44 @@ void nsbeos_window_keypress_event(BView *view, gui_window *g, BMessage *event)
nskey = utf8_to_ucs4(bytes, numbytes);
}
- bool done = browser_window_key_press(g->bw, nskey);
- LOG(("nskey %d %d", nskey, done));
- //if (browser_window_key_press(g->bw, nskey))
+ if(browser_window_key_press(g->bw, nskey))
return;
-
+
+ // Remaining events are for scrolling the page around
+ float hdelta = 0.0f, vdelta = 0.0f;
+ g->view->LockLooper();
+ BRect size = g->view->Bounds();
+ switch (byte) {
+ case B_HOME:
+ g->view->ScrollTo(0.0f, 0.0f);
+ break;
+ case B_END:
+ {
+ // TODO
+ break;
+ }
+ case B_PAGE_UP:
+ vdelta = -size.Height();
+ break;
+ case B_PAGE_DOWN:
+ vdelta = size.Height();
+ break;
+ case B_LEFT_ARROW:
+ hdelta = -10;
+ break;
+ case B_RIGHT_ARROW:
+ hdelta = 10;
+ break;
+ case B_UP_ARROW:
+ vdelta = -10;
+ break;
+ case B_DOWN_ARROW:
+ vdelta = 10;
+ break;
+ }
+
+ g->view->ScrollBy(hdelta, vdelta);
+ g->view->UnlockLooper();
}
#warning WRITEME
@@ -1674,7 +1714,7 @@ bool gui_add_to_clipboard(const char *text, size_t length, bool space,
BFont font;
text_run *run = new text_run;
- nsbeos_style_to_font(font, &fstyle);
+ nsbeos_style_to_font(font, fstyle);
run->offset = current_selection.Length();
run->font = font;
run->color = nsbeos_rgb_colour(fstyle->foreground);
diff --git a/utils/config.h b/utils/config.h
index bd2e303..1c1eef6 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -24,14 +24,14 @@
/* Try to detect which features the target OS supports */
-#if (defined(_GNU_SOURCE) && !defined(__APPLE__))
+#if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__HAIKU__))
#define HAVE_STRNDUP
#else
#undef HAVE_STRNDUP
char *strndup(const char *s, size_t n);
#endif
-#if (defined(_GNU_SOURCE) || defined(__APPLE__))
+#if (defined(_GNU_SOURCE) || defined(__APPLE__) || defined(__HAIKU__))
#define HAVE_STRCASESTR
#else
#undef HAVE_STRCASESTR
-----------------------------------------------------------------------
--
NetSurf Browser
10 years, 2 months
netsurf: branch chris/frame-scroll updated. bf61eec476f2ff9124dd16999c454638745ab3bb
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/bf61eec476f2ff9124dd1...
...commit http://git.netsurf-browser.org/netsurf.git/commit/bf61eec476f2ff9124dd169...
...tree http://git.netsurf-browser.org/netsurf.git/tree/bf61eec476f2ff9124dd16999...
The branch, chris/frame-scroll has been updated
via bf61eec476f2ff9124dd16999c454638745ab3bb (commit)
via 50b7b41ab7c06462517a348b88b644157a1d4852 (commit)
via ec43456e4bf0968bc68b437733199ad2af609c1e (commit)
via 8bccf1615876f7c0ddf62c05f1b9fbc78b011b94 (commit)
via 7d83151d1adb03eaa28df9ae05d0d8e8fb7e7f54 (commit)
via 966fb9f215915567d44cff97a73cf3730dd8c431 (commit)
via 054984099fd8867da92fa685dce728e1cc665fd0 (commit)
via c2cd36fda86b9bdfbb36cc340e35cfbc6609fd32 (commit)
via a159a4a79b1facc77ae41983e9f96f8117f07f21 (commit)
via 7757008433c414974c527c4745e64aa5976d606a (commit)
via bb6b546b4be757cd515253cd10eccadf78e9afb6 (commit)
via e042008f2b7295243d2e6c72f948febe3cad0516 (commit)
via 47c0ce6f14417da5c169e3a79a4396c7d2d5eea5 (commit)
via 6797e1f8ef51e7e22020797b68f07e0c295091ff (commit)
via 4769698d13ca82c535896d7b168ee956709b12a8 (commit)
via 8810bc01635996fc6afa33a84ffb004aca6095e3 (commit)
via ba867955a2fc4be2e17cade11dbd0a1be86ad26e (commit)
via fa9046fc97cb73329652c86d3c77376d32935333 (commit)
via 99d3633e0348fcff3f99d87696b57a70cbdcaf4d (commit)
via bec871152864b1cfb42484505a6622f7f524a405 (commit)
via b1ca83ad8c68f18194d47c06bdcb410064ca8c25 (commit)
from 9a1a1209be4461eb3b7ff40eed23aa35ab0c54e2 (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/bf61eec476f2ff9124d...
commit bf61eec476f2ff9124dd16999c454638745ab3bb
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Adjust values to always be in range
diff --git a/amiga/gui.c b/amiga/gui.c
index 45b0b41..1526556 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1036,7 +1036,7 @@ void ami_update_quals(struct gui_window_2 *gwin)
}
}
-bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y)
+bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y, bool adjust)
{
ULONG xs, ys;
int ns_x = *x;
@@ -1048,15 +1048,21 @@ bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y)
ns_x *= gwin->bw->scale;
ns_y *= gwin->bw->scale;
- if((ns_x < 0) || (ns_x > bbox->Width) || (ns_y < 0) || (ns_y > bbox->Height))
- /* outside screen bounds, but we don't care yet - return false */;
-
ami_get_hscroll_pos(gwin, (ULONG *)&xs);
ami_get_vscroll_pos(gwin, (ULONG *)&ys);
- ns_x += xs;
- ns_y += ys;
+ ns_x -= xs;
+ ns_y -= ys;
+ if((ns_x < 0) || (ns_x > bbox->Width) || (ns_y < 0) || (ns_y > bbox->Height)) {
+ if(adjust == false) return false;
+
+ if(ns_x < 0) ns_x = 0;
+ if(ns_x > bbox->Width) ns_x = bbox->Width;
+ if(ns_y < 0) ns_y = 0;
+ if(ns_x > bbox->Height) ns_y = bbox->Height;
+ }
+
ns_x += bbox->Left;
ns_y += bbox->Top;
@@ -3606,9 +3612,9 @@ bool gui_window_copy_box(struct gui_window *g, const struct rect *rect, int x, i
int src_x1 = rect->x1;
int src_y1 = rect->y1;
printf("%ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
- if(ami_ns_to_screen_coords(gwin, &src_x, &src_y) == false) return false;
- if(ami_ns_to_screen_coords(gwin, &src_x1, &src_y1) == false) return false;
- if(ami_ns_to_screen_coords(gwin, &dest_x, &dest_y) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &src_x, &src_y, true) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &src_x1, &src_y1, true) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &dest_x, &dest_y, true) == false) return false;
printf("== %ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
if(nsoption_bool(faster_scroll) == false) return false; /* for testing */
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/50b7b41ab7c06462517...
commit 50b7b41ab7c06462517a348b88b644157a1d4852
Merge: 9a1a120 ec43456
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Merge branch 'master' of git://git.netsurf-browser.org/netsurf into chris/frame-scroll
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 24 +-
atari/Makefile.target | 2 +-
atari/deskmenu.c | 660 --------------------
atari/deskmenu.h | 12 -
atari/global_evnt.c | 534 +++++++++++++++-
atari/global_evnt.h | 23 +-
atari/gui.c | 47 +-
atari/misc.c | 3 +-
atari/settings.c | 5 +-
javascript/jsapi.h | 126 +++--
javascript/jsapi/binding.h | 3 +-
javascript/jsapi/console.bnd | 12 -
javascript/jsapi/dom.bnd | 45 ++
javascript/jsapi/htmlelement.bnd | 173 +++++-
javascript/jsapi/location.bnd | 117 +++-
javascript/jsapi/window.bnd | 21 +-
render/html.c | 9 +-
...-enumerate.html => dom-document-enumerate.html} | 13 +-
test/js/dom-element-childElementCount.html | 11 +
...om1.html => dom-element-firstElementChild.html} | 0
test/js/dom-element-lastElementChild.html | 11 +
test/js/dom-element-next_prev_ElementSibling.html | 14 +
test/js/event-onload.html | 29 +
test/js/index.html | 7 +-
...node-enumerate.html => location-enumerate.html} | 13 +-
...m-node-enumerate.html => window-enumerate.html} | 13 +-
26 files changed, 1080 insertions(+), 847 deletions(-)
delete mode 100644 atari/deskmenu.c
delete mode 100644 atari/deskmenu.h
copy test/js/{dom-node-enumerate.html => dom-document-enumerate.html} (68%)
create mode 100644 test/js/dom-element-childElementCount.html
rename test/js/{doc-dom1.html => dom-element-firstElementChild.html} (100%)
create mode 100644 test/js/dom-element-lastElementChild.html
create mode 100644 test/js/dom-element-next_prev_ElementSibling.html
create mode 100644 test/js/event-onload.html
copy test/js/{dom-node-enumerate.html => location-enumerate.html} (68%)
copy test/js/{dom-node-enumerate.html => window-enumerate.html} (69%)
diff --git a/amiga/gui.c b/amiga/gui.c
index 45b0b41..1526556 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1036,7 +1036,7 @@ void ami_update_quals(struct gui_window_2 *gwin)
}
}
-bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y)
+bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y, bool adjust)
{
ULONG xs, ys;
int ns_x = *x;
@@ -1048,15 +1048,21 @@ bool ami_ns_to_screen_coords(struct gui_window_2 *gwin, int *x, int *y)
ns_x *= gwin->bw->scale;
ns_y *= gwin->bw->scale;
- if((ns_x < 0) || (ns_x > bbox->Width) || (ns_y < 0) || (ns_y > bbox->Height))
- /* outside screen bounds, but we don't care yet - return false */;
-
ami_get_hscroll_pos(gwin, (ULONG *)&xs);
ami_get_vscroll_pos(gwin, (ULONG *)&ys);
- ns_x += xs;
- ns_y += ys;
+ ns_x -= xs;
+ ns_y -= ys;
+ if((ns_x < 0) || (ns_x > bbox->Width) || (ns_y < 0) || (ns_y > bbox->Height)) {
+ if(adjust == false) return false;
+
+ if(ns_x < 0) ns_x = 0;
+ if(ns_x > bbox->Width) ns_x = bbox->Width;
+ if(ns_y < 0) ns_y = 0;
+ if(ns_x > bbox->Height) ns_y = bbox->Height;
+ }
+
ns_x += bbox->Left;
ns_y += bbox->Top;
@@ -3606,9 +3612,9 @@ bool gui_window_copy_box(struct gui_window *g, const struct rect *rect, int x, i
int src_x1 = rect->x1;
int src_y1 = rect->y1;
printf("%ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
- if(ami_ns_to_screen_coords(gwin, &src_x, &src_y) == false) return false;
- if(ami_ns_to_screen_coords(gwin, &src_x1, &src_y1) == false) return false;
- if(ami_ns_to_screen_coords(gwin, &dest_x, &dest_y) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &src_x, &src_y, true) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &src_x1, &src_y1, true) == false) return false;
+ if(ami_ns_to_screen_coords(gwin, &dest_x, &dest_y, true) == false) return false;
printf("== %ld,%ld,%ld,%ld,%ld,%ld\n", src_x, src_y, src_x1, src_y1, dest_x, dest_y);
if(nsoption_bool(faster_scroll) == false) return false; /* for testing */
diff --git a/atari/Makefile.target b/atari/Makefile.target
index f7e1a63..ad90807 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -81,7 +81,7 @@ S_ATARI := gui.c findfile.c filetype.c misc.c bitmap.c schedule.c \
redrawslots.c encoding.c \
browser_win.c toolbar.c statusbar.c browser.c \
global_evnt.c osspec.c dragdrop.c system_colour.c \
- ctxmenu.c settings.c msgbox.c deskmenu.c
+ ctxmenu.c settings.c msgbox.c
S_ATARI := $(addprefix atari/,$(S_ATARI))
# This is the final source build list
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
deleted file mode 100644
index 38e3539..0000000
--- a/atari/deskmenu.c
+++ /dev/null
@@ -1,660 +0,0 @@
-#include <stdlib.h>
-#include <windom.h>
-
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/options.h"
-#include "desktop/save_complete.h"
-
-#include "atari/res/netsurf.rsh"
-#include "atari/deskmenu.h"
-#include "atari/hotlist.h"
-#include "atari/history.h"
-#include "atari/toolbar.h"
-#include "atari/settings.h"
-#include "atari/search.h"
-#include "atari/misc.h"
-#include "atari/gui.h"
-#include "atari/findfile.h"
-#include "atari/browser.h"
-#include "atari/browser_win.h"
-
-typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
-
-struct s_accelerator
-{
- char ascii; /* either ascii or */
- long keycode; /* normalised keycode is valid */
- short mod; /* shift / ctrl etc */
-};
-
-struct s_menu_item_evnt {
- short title; /* to which menu this item belongs */
- short rid; /* resource ID */
- menu_evnt_func menu_func; /* click handler */
- struct s_accelerator accel; /* accelerator info */
- char * menustr;
-};
-
-static void register_menu_str(struct s_menu_item_evnt * mi);
-static void __CDECL evnt_menu(WINDOW * win, short buff[8]);
-
-extern void *h_gem_rsrc;
-extern bool html_redraw_debug;
-extern struct gui_window * input_window;
-extern char options[PATH_MAX];
-extern const char * option_homepage_url;
-extern int option_window_width;
-extern int option_window_height;
-extern int option_window_x;
-extern int option_window_y;
-
-static OBJECT * h_gem_menu;
-
-
-/* Zero based resource tree ids: */
-#define T_ABOUT 0
-#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
-#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
-#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
-#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
-#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-/* Count of the above defines: */
-#define NUM_MENU_TITLES 7
-
-
-static void __CDECL menu_about(short item, short title, void *data);
-static void __CDECL menu_new_win(short item, short title, void *data);
-static void __CDECL menu_open_url(short item, short title, void *data);
-static void __CDECL menu_open_file(short item, short title, void *data);
-static void __CDECL menu_close_win(short item, short title, void *data);
-static void __CDECL menu_save_page(short item, short title, void *data);
-static void __CDECL menu_quit(short item, short title, void *data);
-static void __CDECL menu_cut(short item, short title, void *data);
-static void __CDECL menu_copy(short item, short title, void *data);
-static void __CDECL menu_paste(short item, short title, void *data);
-static void __CDECL menu_find(short item, short title, void *data);
-static void __CDECL menu_choices(short item, short title, void *data);
-static void __CDECL menu_stop(short item, short title, void *data);
-static void __CDECL menu_reload(short item, short title, void *data);
-static void __CDECL menu_toolbars(short item, short title, void *data);
-static void __CDECL menu_savewin(short item, short title, void *data);
-static void __CDECL menu_debug_render(short item, short title, void *data);
-static void __CDECL menu_fg_images(short item, short title, void *data);
-static void __CDECL menu_bg_images(short item, short title, void *data);
-static void __CDECL menu_back(short item, short title, void *data);
-static void __CDECL menu_forward(short item, short title, void *data);
-static void __CDECL menu_home(short item, short title, void *data);
-static void __CDECL menu_lhistory(short item, short title, void *data);
-static void __CDECL menu_ghistory(short item, short title, void *data);
-static void __CDECL menu_add_bookmark(short item, short title, void *data);
-static void __CDECL menu_bookmarks(short item, short title, void *data);
-static void __CDECL menu_vlog(short item, short title, void *data);
-static void __CDECL menu_help_content(short item, short title, void *data);
-
-struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {-1, -1, NULL,{0,0,0}, NULL }
-};
-
-
-/*
- Parse encoded menu key shortcut
-
- The format is:
-
- "[" - marks start of the shortcut
- "@,^,<" - If the keyshortcut is only valid
- with modifier keys, one of these characters must directly
- follow the start mark.
- Meaning:
- @ -> Alternate
- ^ -> Control
- "#" - keycode or ascii character.
- The value is handled as keycode if the character value
- is <= 28 ( Atari chracter table )
- or if it is interpreted as function key string.
- (strings: F1 - F10)
-
-*/
-static void register_menu_str( struct s_menu_item_evnt * mi )
-{
- OBJECT *gem_menu = deskmenu_get_obj_tree();
-
- assert(gem_menu != NULL);
-
- char * str = ObjcString( gem_menu, mi->rid, NULL );
- int l = strlen(str);
- int i = l;
- int x = -1;
- struct s_accelerator * accel = &mi->accel;
-
- while (i > 2) {
- if( str[i] == '['){
- x = i;
- break;
- }
- i--;
- }
- if( x > -1 ){
- mi->menustr = malloc( l+1 );
- strcpy(mi->menustr, str );
- mi->menustr[x]=' ';
- x++;
- if( str[x] == '@' ){
- accel->mod = K_ALT;
- mi->menustr[x] = 0x07;
- x++;
- }
- else if( str[x] == '^' ) {
- accel->mod = K_CTRL;
- x++;
- }
- if( str[x] <= 28 ){
- // parse symbol
- unsigned short keycode=0;
- switch( str[x] ){
- case 0x03:
- accel->keycode = NK_RIGHT;
- break;
- case 0x04:
- accel->keycode = NK_LEFT;
- break;
- case 0x1B:
- accel->keycode = NK_ESC;
- break;
- default:
- break;
- }
- } else {
- if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
- // parse function key
- short fkey = atoi( &str[x+1] );
- if( (fkey >= 0) && (fkey <= 10) ){
- accel->keycode = NK_F1 - 1 + fkey;
- }
- } else {
- accel->ascii = str[x];
- }
- }
- }
-}
-
-static void __CDECL evnt_menu(WINDOW * win, short buff[8])
-{
- int title = buff[3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
- int i=0;
-
- deskmenu_dispatch_item(buff[3], buff[4]);
-}
-
-/*
- Menu item event handlers:
-*/
-
-static void __CDECL menu_about(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- char buf[PATH_MAX];
- strcpy((char*)&buf, "file://");
- strncat((char*)&buf, (char*)"./doc/README.TXT",
- PATH_MAX - (strlen("file://")+1) );
- browser_window_create((char*)&buf, 0, 0, true, false);
-}
-
-static void __CDECL menu_new_win(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- browser_window_create(option_homepage_url, 0, 0, true, false);
-}
-
-static void __CDECL menu_open_url(short item, short title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
- LOG(("%s", __FUNCTION__));
-
- gw = input_window;
- if( gw == NULL ) {
- bw = browser_window_create("", 0, 0, true, false);
- gw = bw->window;
-
- }
- /* Loose focus: */
- window_set_focus( gw, WIDGET_NONE, NULL );
-
- /* trigger on-focus event (select all text): */
- window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
-
- /* delete selection: */
- tb_url_input( gw, NK_DEL );
-}
-
-static void __CDECL menu_open_file(short item, short title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
-
- LOG(("%s", __FUNCTION__));
-
- const char * filename = file_select( messages_get("OpenFile"), "" );
- if( filename != NULL ){
- char * url = local_file_to_url( filename );
- if( url ){
- bw = browser_window_create(url, NULL, NULL, true, false);
- free( url );
- }
- }
-}
-
-static void __CDECL menu_close_win(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- gui_window_destroy( input_window );
-}
-
-static void __CDECL menu_save_page(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- static bool init = true;
- bool is_folder=false;
- const char * path;
-
- if( !input_window )
- return;
-
- if( init ){
- init = false;
- save_complete_init();
- }
-
- do {
- // TODO: localize string
- path = file_select("Select folder", "");
- if (path)
- is_folder = is_dir(path);
- } while( !is_folder && path != NULL );
-
- if( path != NULL ){
- save_complete( input_window->browser->bw->current_content, path, NULL );
- }
-
-}
-
-static void __CDECL menu_quit(short item, short title, void *data)
-{
- short buff[8];
- memset( &buff, 0, sizeof(short)*8 );
- LOG(("%s", __FUNCTION__));
- netsurf_quit = true;
-}
-
-static void __CDECL menu_cut(short item, short title, void *data)
-{
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
-}
-
-static void __CDECL menu_copy(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
-}
-
-static void __CDECL menu_paste(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_PASTE);
-}
-
-static void __CDECL menu_find(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- open_browser_search( input_window );
-}
-
-static void __CDECL menu_choices(short item, short title, void *data)
-{
- static WINDOW * settings_dlg = NULL;
- LOG(("%s", __FUNCTION__));
- settings_dlg = open_settings();
-}
-
-static void __CDECL menu_stop(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_stop_click( input_window );
-
-}
-
-static void __CDECL menu_reload(short item, short title, void *data)
-{
- if( input_window == NULL)
- return;
- tb_reload_click( input_window );
- LOG(("%s", __FUNCTION__));
-}
-
-static void __CDECL menu_toolbars(short item, short title, void *data)
-{
- static int state = 0;
- LOG(("%s", __FUNCTION__));
- if( input_window != null && input_window->root->toolbar != null ){
- state = !state;
- tb_hide( input_window, state );
- }
-}
-
-static void __CDECL menu_savewin(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window && input_window->browser) {
- GRECT rect;
- wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
- option_window_width = rect.g_w;
- option_window_height = rect.g_h;
- option_window_x = rect.g_x;
- option_window_y = rect.g_y;
- nsoption_set_int(window_width, rect.g_w);
- nsoption_set_int(window_height, rect.g_h);
- nsoption_set_int(window_x, rect.g_x);
- nsoption_set_int(window_y, rect.g_y);
- nsoption_write((const char*)&options);
- }
-
-}
-
-static void __CDECL menu_debug_render(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- html_redraw_debug = !html_redraw_debug;
- if( input_window != NULL ) {
- if ( input_window->browser != NULL
- && input_window->browser->bw != NULL) {
- LGRECT rect;
- browser_get_rect( input_window, BR_CONTENT, &rect );
- browser_window_reformat(input_window->browser->bw, false,
- rect.g_w, rect.g_h );
- MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
- (html_redraw_debug) ? 1 : 0 );
- }
- }
-}
-
-static void __CDECL menu_fg_images(short item, short title, void *data)
-{
- nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
- MenuIcheck( NULL, MAINMENU_M_FG_IMAGES,
- (nsoption_bool(foreground_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_bg_images(short item, short title, void *data)
-{
- nsoption_set_bool(background_images, !nsoption_bool(background_images));
- MenuIcheck( NULL, MAINMENU_M_BG_IMAGES,
- (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_back(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_back_click( input_window );
-}
-
-static void __CDECL menu_forward(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_forward_click( input_window );
-}
-
-static void __CDECL menu_home(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- tb_home_click( input_window );
-}
-
-static void __CDECL menu_lhistory(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
-}
-
-static void __CDECL menu_ghistory(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- global_history_open();
-}
-
-static void __CDECL menu_add_bookmark(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window) {
- if( input_window->browser->bw->current_content != NULL ){
- atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
- NULL
- );
- }
- }
-}
-
-static void __CDECL menu_bookmarks(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- hotlist_open();
-}
-
-static void __CDECL menu_vlog(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- verbose_log = !verbose_log;
- MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
-}
-
-static void __CDECL menu_help_content(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
-}
-
-/*
- Public deskmenu interface:
-*/
-
-
-/**
-* Setup & display an desktop menu.
-*/
-
-void deskmenu_init(void)
-{
- int i;
-
- h_gem_menu = get_tree(MAINMENU);
-
- // TODO: remove that call somehow...
-
- /* parse and update menu items: */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- char * str = ObjcString(h_gem_menu, menu_evnt_tbl[i].rid, NULL );
- register_menu_str( &menu_evnt_tbl[i] );
- /* Update menu string if not null: */
- if( menu_evnt_tbl[i].menustr != NULL ){
- menu_text(h_gem_menu, menu_evnt_tbl[i].rid,
- menu_evnt_tbl[i].menustr);
- }
- i++;
- }
- deskmenu_update();
-
- menu_bar(h_gem_menu, 100);
- menu_bar(h_gem_menu, 1);
-
- // TODO: remove windom dependency.
- EvntAttach(NULL, MN_SELECTED, evnt_menu);
-}
-
-/**
-* Uninstall the desktop menu
-*/
-void deskmenu_destroy(void)
-{
- int i;
-
- /* Remove menu from desktop: */
- menu_bar(h_gem_menu, 0);
-
- /* Free modified menu titles: */
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
- }
-}
-
-/**
-* Return the deskmenu AES OBJECT tree
-*/
-OBJECT * deskmenu_get_obj_tree(void)
-{
- return(h_gem_menu);
-}
-
-/**
-* Handle an menu item event
-*/
-int deskmenu_dispatch_item(short title, short item)
-{
- int i=0;
- int retval = 0;
- OBJECT * menu_root = deskmenu_get_obj_tree();
-
- menu_tnormal(menu_root, item, 1);
- menu_tnormal(menu_root, title, 1);
- menu_bar(menu_root, 1);
-
- // legacy code, is this sensible?:
- /*
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
- }
- */
-
-
- while (menu_evnt_tbl[i].rid != -1) {
- if (menu_evnt_tbl[i].rid == item) {
- if (menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func(item, title, NULL);
- }
- break;
- }
- i++;
- }
-
- return(retval);
-}
-
-/**
-* Handle an keypress (check for accelerator)
-*/
-int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
- unsigned short nkc)
-{
- char sascii;
- bool done = 0;
- int i = 0;
-
- sascii = keybd2ascii(kcode, K_LSHIFT);
-
- /* Iterate through the menu function table: */
- while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if( kstate == menu_evnt_tbl[i].accel.mod
- && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- deskmenu_dispatch_item(menu_evnt_tbl[i].title,
- menu_evnt_tbl[i].rid);
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod) {
- deskmenu_dispatch_item(menu_evnt_tbl[i].title,
- menu_evnt_tbl[i].rid);
- done = true;
- break;
- }
- }
- }
- i++;
- }
- return((done==true) ? 1 : 0);
-}
-
-/**
-* Refresh the desk menu, reflecting netsurf current state.
-*/
-void deskmenu_update(void)
-{
- OBJECT * gem_menu = deskmenu_get_obj_tree();
-
- menu_icheck(gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_FG_IMAGES,
- (nsoption_bool(foreground_images)) ? 1 : 0);
- menu_icheck(gem_menu, MAINMENU_M_BG_IMAGES,
- (nsoption_bool(background_images)) ? 1 : 0);
-}
-
diff --git a/atari/deskmenu.h b/atari/deskmenu.h
deleted file mode 100644
index 6ab00dc..0000000
--- a/atari/deskmenu.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef DESKMENU_H_INCLUDED
-#define DESKMENU_H_INCLUDED
-
-void deskmenu_init(void);
-void deskmenu_destroy(void);
-int deskmenu_dispatch_item(short title, short item);
-int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
- unsigned short nkc);
-OBJECT * deskmenu_get_obj_tree(void);
-void deskmenu_update( void );
-
-#endif // DESKMENU_H_INCLUDED
diff --git a/atari/global_evnt.c b/atari/global_evnt.c
index e3a93a0..3b15af8 100755
--- a/atari/global_evnt.c
+++ b/atari/global_evnt.c
@@ -26,31 +26,379 @@
#include <windom.h>
#include "desktop/gui.h"
+#include "desktop/netsurf.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/mouse.h"
+#include "desktop/textinput.h"
+#include "desktop/hotlist.h"
+#include "desktop/save_complete.h"
+#include "desktop/options.h"
#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
-#include "atari/misc.h"
#include "atari/gui.h"
#include "atari/browser_win.h"
#include "atari/toolbar.h"
#include "atari/browser.h"
+#include "atari/hotlist.h"
+#include "atari/history.h"
+#include "atari/misc.h"
#include "atari/global_evnt.h"
+#include "atari/browser_win.h"
#include "atari/res/netsurf.rsh"
-#include "atari/deskmenu.h"
+#include "atari/search.h"
+#include "atari/findfile.h"
+#include "atari/settings.h"
#include "cflib.h"
extern struct gui_window *input_window;
+extern OBJECT * h_gem_menu;
extern int mouse_click_time[3];
extern int mouse_hold_start[3];
extern browser_mouse_state bmstate;
extern short last_drag_x;
extern short last_drag_y;
+extern bool html_redraw_debug;
+
+extern const char * option_homepage_url;
+extern int option_window_width;
+extern int option_window_height;
+extern int option_window_x;
+extern int option_window_y;
+extern char options[PATH_MAX];
+
+/* Zero based resource tree ids: */
+#define T_ABOUT 0
+#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
+#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
+#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
+#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
+#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+/* Count of the above defines: */
+#define NUM_MENU_TITLES 7
/* Global event handlers: */
static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
+static void __CDECL global_evnt_menu( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] );
static void __CDECL global_evnt_keybd( WINDOW * win, short buff[8],void * data);
-void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
+/* Menu event handlers: */
+static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
+
+
+/* Menu event handlers: */
+static void __CDECL menu_about(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ char buf[PATH_MAX];
+ strcpy((char*)&buf, "file://");
+ strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) );
+ browser_window_create((char*)&buf, 0, 0, true, false);
+}
+
+static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ browser_window_create(option_homepage_url, 0, 0, true, false);
+}
+
+static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+ LOG(("%s", __FUNCTION__));
+
+ gw = input_window;
+ if( gw == NULL ) {
+ bw = browser_window_create("", 0, 0, true, false);
+ gw = bw->window;
+
+ }
+ /* Loose focus: */
+ window_set_focus( gw, WIDGET_NONE, NULL );
+
+ /* trigger on-focus event (select all text): */
+ window_set_focus( gw, URL_WIDGET, &gw->root->toolbar->url );
+
+ /* delete selection: */
+ tb_url_input( gw, NK_DEL );
+}
+
+static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
+
+ LOG(("%s", __FUNCTION__));
+
+ const char * filename = file_select( messages_get("OpenFile"), "" );
+ if( filename != NULL ){
+ char * url = local_file_to_url( filename );
+ if( url ){
+ bw = browser_window_create(url, NULL, NULL, true, false);
+ free( url );
+ }
+ }
+}
+
+static void __CDECL menu_close_win(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ gui_window_destroy( input_window );
+}
+
+static void __CDECL menu_save_page(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ static bool init = true;
+ bool is_folder=false;
+ const char * path;
+
+ if( !input_window )
+ return;
+
+ if( init ){
+ init = false;
+ save_complete_init();
+ }
+
+ do {
+ // TODO: localize string
+ path = file_select("Select folder", "");
+ if (path)
+ is_folder = is_dir(path);
+ } while( !is_folder && path != NULL );
+
+ if( path != NULL ){
+ save_complete( input_window->browser->bw->current_content, path, NULL );
+ }
+
+}
+
+static void __CDECL menu_quit(WINDOW *win, int item, int title, void *data)
+{
+ short buff[8];
+ memset( &buff, 0, sizeof(short)*8 );
+ LOG(("%s", __FUNCTION__));
+ global_evnt_apterm( NULL, buff );
+}
+
+static void __CDECL menu_cut(WINDOW *win, int item, int title, void *data)
+{
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
+}
+
+static void __CDECL menu_copy(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
+}
+
+static void __CDECL menu_paste(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_PASTE);
+}
+
+static void __CDECL menu_find(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ open_browser_search( input_window );
+}
+
+static void __CDECL menu_choices(WINDOW *win, int item, int title, void *data)
+{
+ static WINDOW * settings_dlg = NULL;
+ LOG(("%s", __FUNCTION__));
+ settings_dlg = open_settings();
+}
+
+static void __CDECL menu_stop(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_stop_click( input_window );
+
+}
+
+static void __CDECL menu_reload(WINDOW *win, int item, int title, void *data)
+{
+ if( input_window == NULL)
+ return;
+ tb_reload_click( input_window );
+ LOG(("%s", __FUNCTION__));
+}
+
+static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data)
+{
+ static int state = 0;
+ LOG(("%s", __FUNCTION__));
+ if( input_window != null && input_window->root->toolbar != null ){
+ state = !state;
+ tb_hide( input_window, state );
+ }
+}
+
+static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if (input_window && input_window->browser) {
+ GRECT rect;
+ wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect);
+ option_window_width = rect.g_w;
+ option_window_height = rect.g_h;
+ option_window_x = rect.g_x;
+ option_window_y = rect.g_y;
+ nsoption_set_int(window_width, rect.g_w);
+ nsoption_set_int(window_height, rect.g_h);
+ nsoption_set_int(window_x, rect.g_x);
+ nsoption_set_int(window_y, rect.g_y);
+ nsoption_write((const char*)&options);
+ }
+
+}
+
+static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ html_redraw_debug = !html_redraw_debug;
+ if( input_window != NULL ) {
+ if ( input_window->browser != NULL && input_window->browser->bw != NULL) {
+ LGRECT rect;
+ browser_get_rect( input_window, BR_CONTENT, &rect );
+ browser_window_reformat(input_window->browser->bw, false,
+ rect.g_w, rect.g_h );
+ MenuIcheck(NULL, MAINMENU_M_DEBUG_RENDER,
+ (html_redraw_debug) ? 1 : 0 );
+ }
+ }
+}
+
+static void __CDECL menu_fg_images(WINDOW *win, int item, int title, void *data)
+{
+ nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_bg_images(WINDOW *win, int item, int title, void *data)
+{
+ nsoption_set_bool(background_images, !nsoption_bool(background_images));
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_back(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_back_click( input_window );
+}
+
+static void __CDECL menu_forward(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_forward_click( input_window );
+}
+
+static void __CDECL menu_home(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ tb_home_click( input_window );
+}
+
+static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+}
+
+static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ global_history_open();
+}
+
+static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window ) {
+ if( input_window->browser->bw->current_content != NULL ){
+ atari_hotlist_add_page(
+ nsurl_access(hlcache_handle_get_url( input_window->browser->bw->current_content)),
+ NULL
+ );
+ }
+ }
+}
+
+static void __CDECL menu_bookmarks(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ hotlist_open();
+}
+
+static void __CDECL menu_vlog(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ verbose_log = !verbose_log;
+ MenuIcheck(NULL, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0 );
+}
+
+static void __CDECL menu_help_content(WINDOW *win, int item, int title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+}
+
+static struct s_menu_item_evnt menu_evnt_tbl[] =
+{
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+ {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {T_HELP, -1, NULL,{0,0,0}, NULL }
+};
+
+void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
{
int i = 0;
LOG((""));
@@ -58,7 +406,7 @@ void __CDECL global_evnt_apterm(WINDOW * win, short buff[8])
}
-static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
+static void __CDECL global_evnt_m1( WINDOW * win, short buff[8] )
{
struct gui_window * gw = input_window;
static bool prev_url = false;
@@ -68,23 +416,23 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
LGRECT urlbox, bwbox, sbbox;
int nx, ny;
- if (gw == NULL)
+ if( gw == NULL)
return;
- if (prev_x == evnt.mx && prev_y == evnt.my) {
+ if( prev_x == evnt.mx && prev_y == evnt.my ){
return;
}
short ghandle = wind_find( evnt.mx, evnt.my );
- if (input_window->root->handle->handle == ghandle) {
+ if( input_window->root->handle->handle == ghandle ){
// The window found at x,y is an gui_window
// and it's the input window.
browser_get_rect( gw, BR_CONTENT, &bwbox );
- if (evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
- evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h) {
+ if( evnt.mx > bwbox.g_x && evnt.mx < bwbox.g_x + bwbox.g_w &&
+ evnt.my > bwbox.g_y && evnt.my < bwbox.g_y + bwbox.g_h ){
within = true;
browser_window_mouse_track(
input_window->browser->bw,
@@ -94,7 +442,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
);
}
- if (gw->root->toolbar && within == false) {
+ if( gw->root->toolbar && within == false ) {
mt_CompGetLGrect(&app, gw->root->toolbar->url.comp, WF_WORKXYWH, &urlbox);
if( (evnt.mx > urlbox.g_x && evnt.mx < urlbox.g_x + urlbox.g_w ) &&
(evnt.my > urlbox.g_y && evnt.my < + urlbox.g_y + urlbox.g_h )) {
@@ -118,6 +466,7 @@ static void __CDECL global_evnt_m1(WINDOW * win, short buff[8])
void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
{
+ char sascii;
long kstate = 0;
long kcode = 0;
unsigned short nkc = 0;
@@ -151,23 +500,178 @@ void __CDECL global_evnt_keybd( WINDOW * win, short buff[8], void * data)
gw_tmp = gw_tmp->next;
}
}
- }
- if(!done)
- deskmenu_dispatch_keypress(evnt.keybd, kstate, nkc);
+ }
+ sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
+ while( menu_evnt_tbl[i].rid != -1 && done == false) {
+ if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
+ if( menu_evnt_tbl[i].accel.ascii == sascii) {
+ menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
+ done = true;
+ break;
+ }
+ } else {
+ /* the accel code hides in the keycode: */
+ if( menu_evnt_tbl[i].accel.keycode != 0) {
+ if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
+ kstate == menu_evnt_tbl[i].accel.mod &&
+ menu_evnt_tbl[i].menu_func != NULL) {
+ menu_evnt_tbl[i].menu_func( NULL,
+ menu_evnt_tbl[i].rid,
+ MAINMENU, buff
+ );
+ done = true;
+ break;
+ }
+ }
+ }
+ i++;
+ }
}
+/*
+ Parse encoded menu key shortcut
+
+ The format is:
+
+ "[" - marks start of the shortcut
+ "@,^,<" - If the keyshortcut is only valid
+ with modifier keys, one of these characters must directly
+ follow the start mark.
+ Meaning:
+ @ -> Alternate
+ ^ -> Control
+ "#" - keycode or ascii character.
+ The value is handled as keycode if the character value
+ is <= 28 ( Atari chracter table )
+ or if it is interpreted as function key string.
+ (strings: F1 - F10)
+
+*/
+static void register_menu_str( struct s_menu_item_evnt * mi )
+{
+ char * str = ObjcString( h_gem_menu, mi->rid, NULL );
+ int l = strlen(str);
+ int i = l;
+ int x = -1;
+ struct s_accelerator * accel = &mi->accel;
+
+
+
+ while( i>2 ){
+ if( str[i] == '['){
+ x = i;
+ break;
+ }
+ i--;
+ }
+ if( x > -1 ){
+ mi->menustr = malloc( l+1 );
+ strcpy(mi->menustr, str );
+ mi->menustr[x]=' ';
+ x++;
+ if( str[x] == '@' ){
+ accel->mod = K_ALT;
+ mi->menustr[x] = 0x07;
+ x++;
+ }
+ else if( str[x] == '^' ) {
+ accel->mod = K_CTRL;
+ x++;
+ }
+ if( str[x] <= 28 ){
+ // parse symbol
+ unsigned short keycode=0;
+ switch( str[x] ){
+ case 0x03:
+ accel->keycode = NK_RIGHT;
+ break;
+ case 0x04:
+ accel->keycode = NK_LEFT;
+ break;
+ case 0x1B:
+ accel->keycode = NK_ESC;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
+ // parse function key
+ short fkey = atoi( &str[x+1] );
+ if( (fkey >= 0) && (fkey <= 10) ){
+ accel->keycode = NK_F1 - 1 + fkey;
+ }
+ } else {
+ accel->ascii = str[x];
+ }
+ }
+ }
+}
+
+
+void __CDECL global_evnt_menu( WINDOW * win, short buff[8] )
+{
+ int title = buff[ 3];
+ INT16 x,y;
+ char *str;
+ struct gui_window * gw = window_list;
+ int i=0;
+ MenuTnormal( NULL, title, 1);
+ while( gw ) {
+ window_set_focus( gw, WIDGET_NONE, NULL );
+ gw = gw->next;
+ }
+ while( menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].rid == buff[4] ) {
+ menu_evnt_tbl[i].menu_func(win, (int)buff[4], (int)buff[3], NULL );
+ break;
+ }
+ i++;
+ }
+}
+
+void main_menu_update( void )
+{
+ MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_FG_IMAGES, (nsoption_bool(foreground_images)) ? 1 : 0);
+ MenuIcheck( NULL, MAINMENU_M_BG_IMAGES, (nsoption_bool(background_images)) ? 1 : 0);
+}
+
/* Bind global and menu events to event handler functions, create accelerators */
void bind_global_events( void )
{
+ int i, len;
+ int maxlen[NUM_MENU_TITLES]={0};
+ char * m, *u, *t;
+ char spare[128];
memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
- EvntAttach( NULL, AP_TERM, global_evnt_apterm );
+ EvntAttach( NULL, AP_TERM, global_evnt_apterm );
+ EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
EvntAttach( NULL, WM_XM1, global_evnt_m1 );
+
+ /* parse and update menu items: */
+ i = 0;
+ while( menu_evnt_tbl[i].rid != -1 ) {
+ char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
+ register_menu_str( &menu_evnt_tbl[i] );
+ if( menu_evnt_tbl[i].menustr != NULL ){
+ MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
+ }
+ i++;
+ }
+ main_menu_update();
}
void unbind_global_events( void )
{
-
+ int i;
+ i=0;
+ while(menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].menustr != NULL )
+ free(menu_evnt_tbl[i].menustr);
+ i++;
+ }
}
diff --git a/atari/global_evnt.h b/atari/global_evnt.h
index 76e73fc..1e13264 100755
--- a/atari/global_evnt.h
+++ b/atari/global_evnt.h
@@ -18,8 +18,6 @@
#ifndef NS_ATARI_GLOBAL_EVNT_H
#define NS_ATARI_GLOBAL_EVNT_H
-
-#include <stdbool.h>
struct s_keybd_evnt_data
{
@@ -34,14 +32,31 @@ struct s_evnt_data
} u;
};
-struct s_evnt_data evnt_data;
+struct s_evnt_data evnt_data;
+
+struct s_accelerator
+{
+ char ascii; /* either ascii or */
+ long keycode; /* normalised keycode is valid */
+ short mod; /* shift / ctrl etc */
+};
+
+typedef void __CDECL (*menu_evnt_func)(WINDOW * win, int item, int title, void * data);
+struct s_menu_item_evnt {
+ short title; /* to which menu this item belongs */
+ short rid; /* resource ID */
+ menu_evnt_func menu_func; /* click handler */
+ struct s_accelerator accel; /* accelerator info */
+ char * menustr;
+};
/*
- Global event handlers
+ Global & Menu event handlers
*/
void bind_global_events( void );
void unbind_global_events( void );
+void main_menu_update( void );
#endif
diff --git a/atari/gui.c b/atari/gui.c
index fdcb752..c2158e0 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -73,8 +73,7 @@
#include "atari/plot/plot.h"
#include "atari/clipboard.h"
#include "atari/osspec.h"
-#include "atari/search.h"
-#include "atari/deskmenu.h"
+#include "atari/search.h"
#include "cflib.h"
#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
@@ -83,8 +82,9 @@ char *tmp_clipboard;
struct gui_window *input_window = NULL;
struct gui_window *window_list = NULL;
void * h_gem_rsrc;
-//OBJECT **rsc_trindex;
-//short rsc_ntree;
+OBJECT * h_gem_menu;
+OBJECT **rsc_trindex;
+short rsc_ntree;
long next_poll;
bool rendering = false;
@@ -789,8 +789,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;
@@ -804,8 +802,10 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_file));
urldb_save(nsoption_charp(url_file));
-
- deskmenu_destroy();
+
+ RsrcXtype( 0, rsc_trindex, rsc_ntree);
+ unbind_global_events();
+ MenuBar( h_gem_menu , 0 );
if( h_gem_rsrc != NULL ) {
RsrcXfree(h_gem_rsrc );
}
@@ -885,8 +885,7 @@ process_cmdline(int argc, char** argv)
return true;
}
-static inline void create_cursor(int flags, short mode, void * form,
- MFORM_EX * m)
+static inline void create_cursor(int flags, short mode, void * form, MFORM_EX * m)
{
m->flags = flags;
m->number = mode;
@@ -929,18 +928,16 @@ static void gui_init(int argc, char** argv)
OBJECT * cursors;
atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
- LOG(("%s ", (char*)&buf));
- if (rsrc_load(buf)==0) {
- die("Uable to open GEM Resource file!");
- }
- //h_gem_rsrc = RsrcXload( (char*) &buf );
+ LOG(("%s ", (char*)&buf));
+ h_gem_rsrc = RsrcXload( (char*) &buf );
- //if( !h_gem_rsrc )
- // die("Uable to open GEM Resource file!");
- //rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
- //rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
+ if( !h_gem_rsrc )
+ die("Uable to open GEM Resource file!");
+ rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
+ rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
- //RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
+ RsrcGaddr( h_gem_rsrc, R_TREE, MAINMENU , &h_gem_menu );
+ RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
@@ -984,19 +981,19 @@ static void gui_init(int argc, char** argv)
die("unable to process command line.\n");
nkc_init();
- plot_init(nsoption_charp(atari_font_driver));
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+ plot_init(nsoption_charp(atari_font_driver));
}
static char *theapp = (char*)"NetSurf";
static void gui_init2(int argc, char** argv)
{
- deskmenu_init();
+ MenuBar( h_gem_menu , 1 );
+ bind_global_events();
menu_register( -1, theapp);
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
- }
- bind_global_events();
+ }
+ tree_set_icon_dir( nsoption_charp(tree_icons_path) );
global_history_init();
hotlist_init();
toolbar_init();
diff --git a/atari/misc.c b/atari/misc.c
index e5b0dc1..8b745fd 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -273,8 +273,7 @@ char *get_rsc_string( int idx) {
OBJECT *get_tree( int idx) {
OBJECT *tree;
- rsrc_gaddr(R_TREE, idx, &tree);
- //RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
+ RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
return tree;
}
diff --git a/atari/settings.c b/atari/settings.c
index 25e0c0f..8143cdc 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -31,8 +31,7 @@
#include "desktop/plot_style.h"
#include "atari/res/netsurf.rsh"
#include "atari/settings.h"
-//#include "atari/global_evnt.h"
-#include "atari/deskmenu.h"
+#include "atari/global_evnt.h"
#include "atari/misc.h"
#include "atari/plot/plot.h"
#include "atari/bitmap.h"
@@ -233,7 +232,7 @@ saveform( WINDOW *win, int index, int unused, void *unused2)
close_settings();
ObjcChange( OC_FORM, win, index, NORMAL, TRUE);
form_alert(1, "[1][Some options require an netsurf restart!][OK]");
- deskmenu_update();
+ main_menu_update();
}
static void __CDECL clear_history( WINDOW *win, int index, int unused,
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index 8b7fe51..6b0f112 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -47,24 +47,24 @@
*/
/* native function definition with five parameters */
-#define JSAPI_NATIVE(name, cx, argc, vp) \
- jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
+#define JSAPI_FUNC(name, cx, argc, vp) \
+ jsapi_func_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
-/* native function return value */
-#define JSAPI_RVAL(cx, vp) (jsapi_rval)
+/* native function return value - No macro available */
+#define JSAPI_FUNC_RVAL(cx, vp) (jsapi_rval)
-/* native function return value setter with no JS_SET_RVAL */
-#define JSAPI_SET_RVAL(cx, vp, v) (*jsapi_rval = (v))
+/* native function return value setter - No macro available */
+#define JSAPI_FUNC_SET_RVAL(cx, vp, v) (*jsapi_rval = (v))
/* arguments */
-#define JSAPI_ARGV(cx, vp) (vp)
+#define JSAPI_FUNC_ARGV(cx, vp) (vp)
/* check if a jsval is an object */
#define JSAPI_JSVAL_IS_OBJECT(v) JSVAL_IS_OBJECT(v)
/* native function specifier with five parameters and no JS_FS macro */
#define JSAPI_FS(name, nargs, flags) \
- { #name, jsapi_native_##name, nargs, flags, 0 }
+ { #name, jsapi_func_##name, nargs, flags, 0 }
/* native function specifier list end */
#define JSAPI_FS_END { NULL, NULL, 0, 0, 0 }
@@ -73,21 +73,27 @@
/* native proprty definition */
-#define JSAPI_PROPERTYGET(name, cx, obj, vp) \
- jsapi_property_##name##_get(cx, obj, jsval id, vp)
-#define JSAPI_PROPERTYSET(name, cx, obj, vp) \
- jsapi_property_##name##_set(cx, obj, jsval id, vp)
+#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
+ jsapi_property_##name##_get(cx, obj, jsval jsapi_id, vp)
+#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
+ jsapi_property_##name##_set(cx, obj, jsval jsapi_id, vp)
+
+/* native property return value */
+#define JSAPI_PROP_RVAL(cx, vp) (vp)
/* native property getter return value */
-#define JS_SET_RVAL(cx, vp, v) (*(vp) = (v))
+#define JSAPI_PROP_SET_RVAL(cx, vp, v) (*(vp) = (v))
+
+/* native property ID value as a jsval */
+#define JSAPI_PROP_IDVAL(cx, vp) (*(vp) = jsapi_id)
/* native property specifier */
-#define JSAPI_PS(name, tinyid, flags) \
- { #name , tinyid , flags , jsapi_property_##name##_get , jsapi_property_##name##_set }
+#define JSAPI_PS(name, fnname, tinyid, flags) \
+ { name , tinyid , flags , jsapi_property_##fnname##_get , jsapi_property_##fnname##_set }
/* native property specifier with no setter */
-#define JSAPI_PS_RO(name, tinyid, flags) \
- { #name , tinyid , flags | JSPROP_READONLY, jsapi_property_##name##_get , NULL }
+#define JSAPI_PS_RO(name, fnname, tinyid, flags) \
+ { name , tinyid , flags | JSPROP_READONLY, jsapi_property_##fnname##_get , NULL }
/* native property specifier list end */
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
@@ -155,12 +161,12 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
*/
/* five parameter jsapi native call */
-#define JSAPI_NATIVE(name, cx, argc, vp) \
- jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
+#define JSAPI_FUNC(name, cx, argc, vp) \
+ jsapi_func_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
/* five parameter function descriptor */
#define JSAPI_FS(name, nargs, flags) \
- JS_FS(#name, jsapi_native_##name, nargs, flags, 0)
+ JS_FS(#name, jsapi_func_##name, nargs, flags, 0)
/* function descriptor end */
#define JSAPI_FS_END JS_FS_END
@@ -169,10 +175,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_RVAL(cx, vp) JS_RVAL(cx, jsapi_rval)
/* return value setter */
-#define JSAPI_SET_RVAL(cx, vp, v) JS_SET_RVAL(cx, jsapi_rval, v)
+#define JSAPI_FUNC_SET_RVAL(cx, vp, v) JS_SET_RVAL(cx, jsapi_rval, v)
/* arguments */
-#define JSAPI_ARGV(cx, vp) (vp)
+#define JSAPI_FUNC_ARGV(cx, vp) (vp)
/* check if a jsval is an object */
#define JSAPI_JSVAL_IS_OBJECT(v) JSVAL_IS_OBJECT(v)
@@ -180,21 +186,36 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* The object instance in a native call */
#define JSAPI_THIS_OBJECT(cx,vp) jsapi_this
+
+
+
/* proprty native calls */
-#define JSAPI_PROPERTYGET(name, cx, obj, vp) \
- jsapi_property_##name##_get(cx, obj, jsval id, vp)
-#define JSAPI_PROPERTYSET(name, cx, obj, vp) \
- jsapi_property_##name##_set(cx, obj, jsval id, vp)
+#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
+ jsapi_property_##name##_get(cx, obj, jsval jsapi_id, vp)
+#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
+ jsapi_property_##name##_set(cx, obj, jsval jsapi_id, vp)
+
+/* native property return value */
+#define JSAPI_PROP_RVAL JS_RVAL
+
+/* native property return value setter */
+#define JSAPI_PROP_SET_RVAL JS_SET_RVAL
+
+/* native property ID value as a jsval */
+#define JSAPI_PROP_IDVAL(cx, vp) (*(vp) = jsapi_id)
/* property specifier */
-#define JSAPI_PS(name, tinyid, flags) \
- { #name , tinyid , flags , jsapi_property_##name##_get , jsapi_property_##name##_set }
+#define JSAPI_PS(name, fnname, tinyid, flags) \
+ { name , tinyid , flags , jsapi_property_##fnname##_get , jsapi_property_##fnname##_set }
-#define JSAPI_PS_RO(name, tinyid, flags) \
- { #name , tinyid , flags | JSPROP_READONLY, jsapi_property_##name##_get , NULL }
+#define JSAPI_PS_RO(name, fnname, tinyid, flags) \
+ { name , tinyid , flags | JSPROP_READONLY, jsapi_property_##fnname##_get , NULL }
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
+
+
+
static inline JSObject *
JS_NewCompartmentAndGlobalObject(JSContext *cx,
JSClass *jsclass,
@@ -248,11 +269,11 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/************************** Spidermonkey 1.8.5 **************************/
/* three parameter jsapi native call */
-#define JSAPI_NATIVE(name, cx, argc, vp) jsapi_native_##name(cx, argc, vp)
+#define JSAPI_FUNC(name, cx, argc, vp) jsapi_func_##name(cx, argc, vp)
/* three parameter function descriptor */
#define JSAPI_FS(name, nargs, flags) \
- JS_FS(#name, jsapi_native_##name, nargs, flags)
+ JS_FS(#name, jsapi_func_##name, nargs, flags)
/* function descriptor end */
#define JSAPI_FS_END JS_FS_END
@@ -261,10 +282,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_RVAL JS_RVAL
/* return value setter */
-#define JSAPI_SET_RVAL JS_SET_RVAL
+#define JSAPI_FUNC_SET_RVAL JS_SET_RVAL
/* arguments */
-#define JSAPI_ARGV(cx, vp) JS_ARGV(cx,vp)
+#define JSAPI_FUNC_ARGV(cx, vp) JS_ARGV(cx,vp)
/* check if a jsval is an object */
#define JSAPI_JSVAL_IS_OBJECT(v) JSVAL_IS_OBJECT(v)
@@ -278,25 +299,34 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_THIS_OBJECT(cx,vp) JS_THIS_OBJECT(cx,vp)
/* proprty native calls */
-#define JSAPI_PROPERTYGET(name, cx, obj, vp) \
- jsapi_property_##name##_get(cx, obj, jsid id, vp)
-#define JSAPI_PROPERTYSET(name, cx, obj, vp) \
- jsapi_property_##name##_set(cx, obj, jsid id, JSBool strict, vp)
+#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
+ jsapi_property_##name##_get(cx, obj, jsid jsapi_id, vp)
+#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
+ jsapi_property_##name##_set(cx, obj, jsid jsapi_id, JSBool strict, vp)
+
+/* native property return value */
+#define JSAPI_PROP_RVAL JS_RVAL
+
+/* native property getter return value */
+#define JSAPI_PROP_SET_RVAL JS_SET_RVAL
+
+/* native property ID value as a jsval */
+#define JSAPI_PROP_IDVAL(cx, vp) JS_IdToValue(cx, jsapi_id, vp)
/* property specifier */
-#define JSAPI_PS(name, tinyid, flags) { \
- #name , \
- tinyid , \
- flags , \
- jsapi_property_##name##_get , \
- jsapi_property_##name##_set \
+#define JSAPI_PS(name, fnname, tinyid, flags) { \
+ name, \
+ tinyid, \
+ flags, \
+ jsapi_property_##fnname##_get, \
+ jsapi_property_##fnname##_set \
}
-#define JSAPI_PS_RO(name, tinyid, flags) { \
- #name , \
- tinyid , \
+#define JSAPI_PS_RO(name, fnname, tinyid, flags) { \
+ name, \
+ tinyid, \
flags | JSPROP_READONLY, \
- jsapi_property_##name##_get , \
+ jsapi_property_##fnname##_get, \
NULL \
}
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index 6400217..6d069b9 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -45,7 +45,8 @@ JSObject *jsapi_InitClass_Location(JSContext *cx, JSObject *parent);
JSObject *jsapi_new_Location(JSContext *cx,
JSObject *window,
JSObject *parent,
- struct browser_window *bw);
+ struct browser_window *bw,
+ nsurl *url);
JSObject *jsapi_InitClass_Document(JSContext *cx, JSObject *parent);
diff --git a/javascript/jsapi/console.bnd b/javascript/jsapi/console.bnd
index 6aef9dc..7c34845 100644
--- a/javascript/jsapi/console.bnd
+++ b/javascript/jsapi/console.bnd
@@ -30,18 +30,6 @@ binding navigator {
interface Console; /* Web IDL interface to generate */
- /* private members:
- * - stored in private context structure.
- * - passed as parameters to constructor and stored automatically.
- * - are *not* considered for property getters/setters.
- *
- * internal members:
- * - value stored in private context structure
- * - not passed to constructor
- * - must be instantiated by constructor
- * - are considered for property getters/setters.
- */
- internal "void *" gui_console;
}
operation log %{
diff --git a/javascript/jsapi/dom.bnd b/javascript/jsapi/dom.bnd
index 3a35525..89d0d84 100644
--- a/javascript/jsapi/dom.bnd
+++ b/javascript/jsapi/dom.bnd
@@ -4,6 +4,51 @@ webidlfile "dom.idl";
/* interface Node members */
+getter nodeType %{
+ dom_exception exc;
+ dom_node_type node_type;
+
+ exc = dom_node_get_node_type(private->node, &node_type);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+ jsret = node_type;
+%}
+
+
+getter nodeName %{
+ dom_exception exc;
+ dom_string *name;
+
+ exc = dom_node_get_node_name(private->node, &name);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ if (name != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ dom_string_data(name),
+ dom_string_length(name));
+ dom_string_unref(name);
+ }
+%}
+
+getter nodeValue %{
+ dom_exception exc;
+ dom_string *value;
+
+ exc = dom_node_get_node_value(private->node, &value);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ if (value != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ dom_string_data(value),
+ dom_string_length(value));
+ dom_string_unref(value);
+ }
+%}
getter textContent %{
dom_exception exc;
diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd
index 18e343f..71bb31b 100644
--- a/javascript/jsapi/htmlelement.bnd
+++ b/javascript/jsapi/htmlelement.bnd
@@ -20,7 +20,7 @@ hdrcomment " http://www.opensource.org/licenses/mit-license";
preamble %{
#include <dom/dom.h>
-
+
#include "utils/config.h"
#include "utils/log.h"
@@ -35,23 +35,182 @@ binding htmlelement {
interface HTMLElement; /* Web IDL interface to generate */
private "dom_element *" node;
- private "struct html_content *" htmlc;
+ private "struct html_content *" htmlc;
}
api finalise %{
- if (private != NULL) {
- dom_node_unref(private->node);
- }
+ if (private != NULL) {
+ dom_node_unref(private->node);
+ }
%}
+/* interface Element in dom idl */
+
+/*
+ * DOM 3 has these as the element traversal extension
+ *
+ * http://dev.w3.org/2006/webapi/ElementTraversal/publish/ElementTraversal.html
+ */
+
getter firstElementChild %{
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *next_node;
+
+ exc = dom_node_get_first_child(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_next_sibling(element, &next_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = next_node;
+ } else {
+ element = NULL;
+ }
+
+ }
+
+
%}
getter lastElementChild %{
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *sib_node;
+
+ exc = dom_node_get_last_child(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_previous_sibling(element, &sib_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = sib_node;
+ } else {
+ element = NULL;
+ }
+
+ }
%}
getter previousElementSibling %{
- %}
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *sib_node;
+
+ exc = dom_node_get_previous_sibling(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_previous_sibling(element, &sib_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = sib_node;
+ } else {
+ element = NULL;
+ }
+ }
+%}
getter nextElementSibling %{
- %}
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *sib_node;
+
+ exc = dom_node_get_next_sibling(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ /* found it */
+ jsret = jsapi_new_HTMLElement(cx,
+ NULL,
+ NULL,
+ (dom_element *)element,
+ private->htmlc);
+ break;
+ }
+
+ exc = dom_node_get_next_sibling(element, &sib_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = sib_node;
+ } else {
+ element = NULL;
+ }
+ }
+%}
+
+getter childElementCount %{
+ dom_node *element;
+ dom_exception exc;
+ dom_node_type node_type;
+ dom_node *next_node;
+
+ exc = dom_node_get_first_child(private->node, &element);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ while (element != NULL) {
+ exc = dom_node_get_node_type(element, &node_type);
+ if ((exc == DOM_NO_ERR) && (node_type == DOM_ELEMENT_NODE)) {
+ jsret += 1;
+ }
+
+ exc = dom_node_get_next_sibling(element, &next_node);
+ dom_node_unref(element);
+ if (exc == DOM_NO_ERR) {
+ element = next_node;
+ } else {
+ element = NULL;
+ }
+ }
+%}
diff --git a/javascript/jsapi/location.bnd b/javascript/jsapi/location.bnd
index c83fe46..32e38da 100644
--- a/javascript/jsapi/location.bnd
+++ b/javascript/jsapi/location.bnd
@@ -8,8 +8,6 @@
* http://www.opensource.org/licenses/mit-license
*/
-#include "dom.bnd"
-
webidlfile "html.idl";
hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
@@ -30,24 +28,107 @@ preamble %{
%}
binding location {
- type js_libdom; /* the binding type */
-
- interface Location; /* Web IDL interface to generate */
-
- /* private members:
- * - stored in private context structure.
- * - passed as parameters to constructor and stored automatically.
- * - are *not* considered for property getters/setters.
- *
- * internal members:
- * - value stored in private context structure
- * - not passed to constructor
- * - must be instantiated by constructor
- * - are considered for property getters/setters.
- */
+ type js_libdom; /* the binding type */
+
+ interface Location; /* Web IDL interface to generate */
+
private "struct browser_window *" bw;
+ private "nsurl *" url;
+
}
operation reload %{
- browser_window_reload(private->bw, false);
+ browser_window_reload(private->bw, false);
+%}
+
+
+getter href %{
+ char *url_s = NULL;
+ size_t url_l;
+ nsurl_get(private->url, NSURL_COMPLETE, &url_s, &url_l);
+ if (url_s != NULL) {
+ jsret = JS_NewStringCopyN(cx, url_s, url_l);
+ free(url_s);
+ }
+%}
+
+getter protocol %{
+ lwc_string *component;
+ component = nsurl_get_component(private->url, NSURL_SCHEME);
+ if (component != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ lwc_string_data(component),
+ lwc_string_length(component));
+ lwc_string_unref(component);
+ }
+%}
+
+getter host %{
+ lwc_string *component;
+ component = nsurl_get_component(private->url, NSURL_HOST);
+ if (component != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ lwc_string_data(component),
+ lwc_string_length(component));
+ lwc_string_unref(component);
+ }
+%}
+
+getter hostname %{
+ lwc_string *component;
+ component = nsurl_get_component(private->url, NSURL_HOST);
+ if (component != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ lwc_string_data(component),
+ lwc_string_length(component));
+ lwc_string_unref(component);
+ }
+
+%}
+
+getter port %{
+ lwc_string *component;
+ component = nsurl_get_component(private->url, NSURL_PORT);
+ if (component != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ lwc_string_data(component),
+ lwc_string_length(component));
+ lwc_string_unref(component);
+ }
+
+%}
+
+getter pathname %{
+ lwc_string *component;
+ component = nsurl_get_component(private->url, NSURL_PATH);
+ if (component != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ lwc_string_data(component),
+ lwc_string_length(component));
+ lwc_string_unref(component);
+ }
+
+%}
+
+getter search %{
+ lwc_string *component;
+ component = nsurl_get_component(private->url, NSURL_QUERY);
+ if (component != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ lwc_string_data(component),
+ lwc_string_length(component));
+ lwc_string_unref(component);
+ }
+
+%}
+
+getter hash %{
+ lwc_string *component;
+ component = nsurl_get_component(private->url, NSURL_FRAGMENT);
+ if (component != NULL) {
+ jsret = JS_NewStringCopyN(cx,
+ lwc_string_data(component),
+ lwc_string_length(component));
+ lwc_string_unref(component);
+ }
%}
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index 767b94f..e439980 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -23,19 +23,15 @@ binding window {
interface Window; /* Web IDL interface to generate */
- /* private are parameters to constructor stored in private
- * context structure.
- *
- * internal are value stored in private context structure but not
- * passed to constructor but are considered for property
- * getters/setters.
- */
private "struct browser_window *" bw;
private "struct html_content *" htmlc;
+
internal "JSObject *" document;
internal "JSObject *" navigator;
internal "JSObject *" console;
internal "JSObject *" location;
+
+ property unshared type EventHandler;
}
api mark %{
@@ -166,7 +162,8 @@ api new %{
return NULL;
}
- private->location = jsapi_new_Location(cx, NULL, newobject, bw);
+ private->location = jsapi_new_Location(cx, NULL, newobject, bw,
+ llcache_handle_get_url(private->htmlc->base.llcache));
if (private->location == NULL) {
free(private);
return NULL;
@@ -202,3 +199,11 @@ getter window %{
getter self %{
jsret = obj;
%}
+
+getter EventHandler %{
+ JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+%}
+
+setter EventHandler %{
+ JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+%}
diff --git a/render/html.c b/render/html.c
index f6e3fda..6c6dcdf 100644
--- a/render/html.c
+++ b/render/html.c
@@ -2622,9 +2622,12 @@ html_get_contextual_content(struct content *c,
if (box->usemap) {
const char *target = NULL;
- data->link_url = nsurl_access(imagemap_get(html,
- box->usemap, box_x, box_y, x, y,
- &target));
+ nsurl *url = imagemap_get(html, box->usemap, box_x,
+ box_y, x, y, &target);
+ /* Box might have imagemap, but no actual link area
+ * at point */
+ if (url != NULL)
+ data->link_url = nsurl_access(url);
}
if (box->gadget) {
switch (box->gadget->type) {
diff --git a/test/js/dom-node-enumerate.html b/test/js/dom-document-enumerate.html
similarity index 68%
copy from test/js/dom-node-enumerate.html
copy to test/js/dom-document-enumerate.html
index 573e27b..18146ab 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/dom-document-enumerate.html
@@ -1,24 +1,25 @@
<html>
<head>
-<title>Node interface enumeration</title>
+<title>document interface enumeration</title>
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Node interface enumeration</h1>
+<h1>Document interface enumeration</h1>
<script>
function output(x,y) {
document.body.appendChild(document.createTextNode(x));
document.body.appendChild(document.createTextNode("("));
if (y != undefined) {
-document.body.appendChild(document.createTextNode(y.length));
-}
+ document.body.appendChild(document.createTextNode(y.length));
+ }
document.body.appendChild(document.createTextNode(") = "));
document.body.appendChild(document.createTextNode(y));
document.body.appendChild(document.createElement('br'));
}
-for(var key in Node){
-output(key, Node[key]);
+
+for(var key in document) {
+ output(key, document[key]);
}
</script>
</body>
diff --git a/test/js/dom-element-childElementCount.html b/test/js/dom-element-childElementCount.html
new file mode 100644
index 0000000..ec4b7f8
--- /dev/null
+++ b/test/js/dom-element-childElementCount.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="tst.css">
+<title>DOM childElementCount reference</title>
+</head>
+<body>
+<h1>DOM childElementCount reference</h1>
+<p><b>head.childElementCount:</b> <script>document.write(document.head.childElementCount);</script></p>
+<p><b>body.childElementCount:</b> <script>document.write(document.body.childElementCount);</script></p>
+</body>
+</html>
diff --git a/test/js/doc-dom1.html b/test/js/dom-element-firstElementChild.html
similarity index 100%
rename from test/js/doc-dom1.html
rename to test/js/dom-element-firstElementChild.html
diff --git a/test/js/dom-element-lastElementChild.html b/test/js/dom-element-lastElementChild.html
new file mode 100644
index 0000000..e4e9f11
--- /dev/null
+++ b/test/js/dom-element-lastElementChild.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="tst.css">
+<title>DOM lastElementChild reference</title>
+</head>
+<body>
+<h1>DOM lastElementChild reference</h1>
+<p><b>head.lastElementChild:</b> <script>document.write(document.head.lastElementChild.textContent);</script></p>
+<p><b>body.lastElementChild:</b> <script>document.write(document.body.lastElementChild.textContent);</script></p>
+</body>
+</html>
diff --git a/test/js/dom-element-next_prev_ElementSibling.html b/test/js/dom-element-next_prev_ElementSibling.html
new file mode 100644
index 0000000..85263cc
--- /dev/null
+++ b/test/js/dom-element-next_prev_ElementSibling.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>DOM previousElementSibling and nextElementSibling reference</title>
+<!-- comment node should be skipped -->
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<h1>DOM previousElementSibling and nextElementSibling reference</h1>
+<!-- comment node should be skipped -->
+<p><b>head.lastElementChild.previousElementSibling:</b> <script>document.write(document.head.lastElementChild.previousElementSibling.textContent);</script></p>
+<!-- comment node should be skipped -->
+<p><b>body.firstElementChild.nextElementSibling:</b> <script>document.write(document.body.firstElementChild.nextElementSibling.textContent);</script></p>
+</body>
+</html>
diff --git a/test/js/event-onload.html b/test/js/event-onload.html
new file mode 100644
index 0000000..aede985
--- /dev/null
+++ b/test/js/event-onload.html
@@ -0,0 +1,29 @@
+<html>
+<head>
+<title>createTextNode onload example</title>
+
+<script type="text/javascript">
+
+function addTextNode()
+{
+var newtext = document.createTextNode(" Some text added dynamically. ");
+var para = document.getElementById("p1");
+para.appendChild(newtext);
+}
+
+</script>
+</head>
+
+<body>
+<div style="border: 1px solid red">
+<p id="p1">First line of paragraph.<br /></p>
+</div><br />
+
+<button onclick="addTextNode();">add another textNode.</button>
+
+<script>
+window.onload = addTextNode;
+</script>
+
+</body>
+</html>
diff --git a/test/js/index.html b/test/js/index.html
index f02c4df..7a17c95 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -8,6 +8,7 @@
<h2>Window</h2>
<ul>
<li><a href="window.lately.html">location</a></li>
+<li><a href="window-enumerate.html">enumerate</a></li>
</ul>
<h2>Document write</h2>
@@ -24,7 +25,10 @@
<h2>DOM tests</h2>
<h3>Reference method tests</h3>
<ul>
-<li><a href="doc-dom1.html">firstElementChild</a></li>
+<li><a href="dom-element-firstElementChild.html">firstElementChild</a></li>
+<li><a href="dom-element-lastElementChild.html">lastElementChild</a></li>
+<li><a href="dom-element-next_prev_ElementSibling.html">previousElementSibling nextElementSibling</a></li>
+<li><a href="dom-element-childElementCount.html">childElementCount</a></li>
<li><a href="doc-dom2.html">getElementById</a></li>
<li><a href="dom-getElementsByTagName.html">getElementsByTagName</a></li>
@@ -33,6 +37,7 @@
<ul>
<li><a href="dom-node-enumerate.html">Node element interface</a></li>
<li><a href="dom-body-enumerate.html">Body element interface</a></li>
+<li><a href="dom-document-enumerate.html">Document interface</a></li>
</ul>
<h3>Document element specific</h3>
<ul>
diff --git a/test/js/dom-node-enumerate.html b/test/js/location-enumerate.html
similarity index 68%
copy from test/js/dom-node-enumerate.html
copy to test/js/location-enumerate.html
index 573e27b..d455c75 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/location-enumerate.html
@@ -1,24 +1,25 @@
<html>
<head>
-<title>Node interface enumeration</title>
+<title>location interface enumeration</title>
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Node interface enumeration</h1>
+<h1>location interface enumeration</h1>
<script>
function output(x,y) {
document.body.appendChild(document.createTextNode(x));
document.body.appendChild(document.createTextNode("("));
if (y != undefined) {
-document.body.appendChild(document.createTextNode(y.length));
-}
+ document.body.appendChild(document.createTextNode(y.length));
+ }
document.body.appendChild(document.createTextNode(") = "));
document.body.appendChild(document.createTextNode(y));
document.body.appendChild(document.createElement('br'));
}
-for(var key in Node){
-output(key, Node[key]);
+
+for(var key in location) {
+ output(key, location[key]);
}
</script>
</body>
diff --git a/test/js/dom-node-enumerate.html b/test/js/window-enumerate.html
similarity index 69%
copy from test/js/dom-node-enumerate.html
copy to test/js/window-enumerate.html
index 573e27b..92a3111 100644
--- a/test/js/dom-node-enumerate.html
+++ b/test/js/window-enumerate.html
@@ -1,24 +1,25 @@
<html>
<head>
-<title>Node interface enumeration</title>
+<title>window interface enumeration</title>
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Node interface enumeration</h1>
+<h1>window interface enumeration</h1>
<script>
function output(x,y) {
document.body.appendChild(document.createTextNode(x));
document.body.appendChild(document.createTextNode("("));
if (y != undefined) {
-document.body.appendChild(document.createTextNode(y.length));
-}
+ document.body.appendChild(document.createTextNode(y.length));
+ }
document.body.appendChild(document.createTextNode(") = "));
document.body.appendChild(document.createTextNode(y));
document.body.appendChild(document.createElement('br'));
}
-for(var key in Node){
-output(key, Node[key]);
+
+for(var key in window) {
+ output(key, window[key]);
}
</script>
</body>
--
NetSurf Browser
10 years, 2 months
netsurf: branch master updated. ec43456e4bf0968bc68b437733199ad2af609c1e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ec43456e4bf0968bc68b4...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ec43456e4bf0968bc68b437...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ec43456e4bf0968bc68b43773...
The branch, master has been updated
via ec43456e4bf0968bc68b437733199ad2af609c1e (commit)
from 8bccf1615876f7c0ddf62c05f1b9fbc78b011b94 (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/ec43456e4bf0968bc68...
commit ec43456e4bf0968bc68b437733199ad2af609c1e
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
use unshared type handler for all events on window
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index 718dd20..6b0f112 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -74,9 +74,9 @@
/* native proprty definition */
#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
- jsapi_property_##name##_get(cx, obj, jsval id, vp)
+ jsapi_property_##name##_get(cx, obj, jsval jsapi_id, vp)
#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
- jsapi_property_##name##_set(cx, obj, jsval id, vp)
+ jsapi_property_##name##_set(cx, obj, jsval jsapi_id, vp)
/* native property return value */
#define JSAPI_PROP_RVAL(cx, vp) (vp)
@@ -84,6 +84,9 @@
/* native property getter return value */
#define JSAPI_PROP_SET_RVAL(cx, vp, v) (*(vp) = (v))
+/* native property ID value as a jsval */
+#define JSAPI_PROP_IDVAL(cx, vp) (*(vp) = jsapi_id)
+
/* native property specifier */
#define JSAPI_PS(name, fnname, tinyid, flags) \
{ name , tinyid , flags , jsapi_property_##fnname##_get , jsapi_property_##fnname##_set }
@@ -183,11 +186,14 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* The object instance in a native call */
#define JSAPI_THIS_OBJECT(cx,vp) jsapi_this
+
+
+
/* proprty native calls */
#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
- jsapi_property_##name##_get(cx, obj, jsval id, vp)
+ jsapi_property_##name##_get(cx, obj, jsval jsapi_id, vp)
#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
- jsapi_property_##name##_set(cx, obj, jsval id, vp)
+ jsapi_property_##name##_set(cx, obj, jsval jsapi_id, vp)
/* native property return value */
#define JSAPI_PROP_RVAL JS_RVAL
@@ -195,6 +201,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* native property return value setter */
#define JSAPI_PROP_SET_RVAL JS_SET_RVAL
+/* native property ID value as a jsval */
+#define JSAPI_PROP_IDVAL(cx, vp) (*(vp) = jsapi_id)
+
/* property specifier */
#define JSAPI_PS(name, fnname, tinyid, flags) \
{ name , tinyid , flags , jsapi_property_##fnname##_get , jsapi_property_##fnname##_set }
@@ -204,6 +213,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
+
+
+
static inline JSObject *
JS_NewCompartmentAndGlobalObject(JSContext *cx,
JSClass *jsclass,
@@ -288,9 +300,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* proprty native calls */
#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
- jsapi_property_##name##_get(cx, obj, jsid id, vp)
+ jsapi_property_##name##_get(cx, obj, jsid jsapi_id, vp)
#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
- jsapi_property_##name##_set(cx, obj, jsid id, JSBool strict, vp)
+ jsapi_property_##name##_set(cx, obj, jsid jsapi_id, JSBool strict, vp)
/* native property return value */
#define JSAPI_PROP_RVAL JS_RVAL
@@ -298,6 +310,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* native property getter return value */
#define JSAPI_PROP_SET_RVAL JS_SET_RVAL
+/* native property ID value as a jsval */
+#define JSAPI_PROP_IDVAL(cx, vp) JS_IdToValue(cx, jsapi_id, vp)
+
/* property specifier */
#define JSAPI_PS(name, fnname, tinyid, flags) { \
name, \
diff --git a/javascript/jsapi/location.bnd b/javascript/jsapi/location.bnd
index a381db1..32e38da 100644
--- a/javascript/jsapi/location.bnd
+++ b/javascript/jsapi/location.bnd
@@ -34,6 +34,7 @@ binding location {
private "struct browser_window *" bw;
private "nsurl *" url;
+
}
operation reload %{
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index dbc38a7..e439980 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -30,6 +30,8 @@ binding window {
internal "JSObject *" navigator;
internal "JSObject *" console;
internal "JSObject *" location;
+
+ property unshared type EventHandler;
}
api mark %{
@@ -197,3 +199,11 @@ getter window %{
getter self %{
jsret = obj;
%}
+
+getter EventHandler %{
+ JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+%}
+
+setter EventHandler %{
+ JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+%}
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi.h | 27 +++++++++++++++++++++------
javascript/jsapi/location.bnd | 1 +
javascript/jsapi/window.bnd | 10 ++++++++++
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index 718dd20..6b0f112 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -74,9 +74,9 @@
/* native proprty definition */
#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
- jsapi_property_##name##_get(cx, obj, jsval id, vp)
+ jsapi_property_##name##_get(cx, obj, jsval jsapi_id, vp)
#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
- jsapi_property_##name##_set(cx, obj, jsval id, vp)
+ jsapi_property_##name##_set(cx, obj, jsval jsapi_id, vp)
/* native property return value */
#define JSAPI_PROP_RVAL(cx, vp) (vp)
@@ -84,6 +84,9 @@
/* native property getter return value */
#define JSAPI_PROP_SET_RVAL(cx, vp, v) (*(vp) = (v))
+/* native property ID value as a jsval */
+#define JSAPI_PROP_IDVAL(cx, vp) (*(vp) = jsapi_id)
+
/* native property specifier */
#define JSAPI_PS(name, fnname, tinyid, flags) \
{ name , tinyid , flags , jsapi_property_##fnname##_get , jsapi_property_##fnname##_set }
@@ -183,11 +186,14 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* The object instance in a native call */
#define JSAPI_THIS_OBJECT(cx,vp) jsapi_this
+
+
+
/* proprty native calls */
#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
- jsapi_property_##name##_get(cx, obj, jsval id, vp)
+ jsapi_property_##name##_get(cx, obj, jsval jsapi_id, vp)
#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
- jsapi_property_##name##_set(cx, obj, jsval id, vp)
+ jsapi_property_##name##_set(cx, obj, jsval jsapi_id, vp)
/* native property return value */
#define JSAPI_PROP_RVAL JS_RVAL
@@ -195,6 +201,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* native property return value setter */
#define JSAPI_PROP_SET_RVAL JS_SET_RVAL
+/* native property ID value as a jsval */
+#define JSAPI_PROP_IDVAL(cx, vp) (*(vp) = jsapi_id)
+
/* property specifier */
#define JSAPI_PS(name, fnname, tinyid, flags) \
{ name , tinyid , flags , jsapi_property_##fnname##_get , jsapi_property_##fnname##_set }
@@ -204,6 +213,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
+
+
+
static inline JSObject *
JS_NewCompartmentAndGlobalObject(JSContext *cx,
JSClass *jsclass,
@@ -288,9 +300,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* proprty native calls */
#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
- jsapi_property_##name##_get(cx, obj, jsid id, vp)
+ jsapi_property_##name##_get(cx, obj, jsid jsapi_id, vp)
#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
- jsapi_property_##name##_set(cx, obj, jsid id, JSBool strict, vp)
+ jsapi_property_##name##_set(cx, obj, jsid jsapi_id, JSBool strict, vp)
/* native property return value */
#define JSAPI_PROP_RVAL JS_RVAL
@@ -298,6 +310,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* native property getter return value */
#define JSAPI_PROP_SET_RVAL JS_SET_RVAL
+/* native property ID value as a jsval */
+#define JSAPI_PROP_IDVAL(cx, vp) JS_IdToValue(cx, jsapi_id, vp)
+
/* property specifier */
#define JSAPI_PS(name, fnname, tinyid, flags) { \
name, \
diff --git a/javascript/jsapi/location.bnd b/javascript/jsapi/location.bnd
index a381db1..32e38da 100644
--- a/javascript/jsapi/location.bnd
+++ b/javascript/jsapi/location.bnd
@@ -34,6 +34,7 @@ binding location {
private "struct browser_window *" bw;
private "nsurl *" url;
+
}
operation reload %{
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index dbc38a7..e439980 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -30,6 +30,8 @@ binding window {
internal "JSObject *" navigator;
internal "JSObject *" console;
internal "JSObject *" location;
+
+ property unshared type EventHandler;
}
api mark %{
@@ -197,3 +199,11 @@ getter window %{
getter self %{
jsret = obj;
%}
+
+getter EventHandler %{
+ JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+%}
+
+setter EventHandler %{
+ JSLOG("propname:%s %s", propname, JS_GetTypeName(cx, JS_TypeOfValue(cx, propname_jsval)));
+%}
--
NetSurf Browser
10 years, 2 months