netsurf: branch master updated. c2cd36fda86b9bdfbb36cc340e35cfbc6609fd32
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c2cd36fda86b9bdfbb36c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c2cd36fda86b9bdfbb36cc3...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c2cd36fda86b9bdfbb36cc340...
The branch, master has been updated
via c2cd36fda86b9bdfbb36cc340e35cfbc6609fd32 (commit)
from a159a4a79b1facc77ae41983e9f96f8117f07f21 (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/c2cd36fda86b9bdfbb3...
commit c2cd36fda86b9bdfbb36cc340e35cfbc6609fd32
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
improve location interface implementation
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/location.bnd b/javascript/jsapi/location.bnd
index db7a247..e91094f 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>";
@@ -35,8 +33,101 @@ binding location {
interface Location; /* Web IDL interface to generate */
private "struct browser_window *" bw;
+ private "nsurl *" url;
}
operation reload %{
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));
+ dom_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));
+ dom_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));
+ dom_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));
+ dom_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));
+ dom_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));
+ dom_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));
+ dom_string_unref(component);
+ }
+%}
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index c4e6e88..dbc38a7 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -160,7 +160,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;
diff --git a/test/js/location-enumerate.html b/test/js/location-enumerate.html
new file mode 100644
index 0000000..d455c75
--- /dev/null
+++ b/test/js/location-enumerate.html
@@ -0,0 +1,26 @@
+<html>
+<head>
+<title>location interface enumeration</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<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(") = "));
+ document.body.appendChild(document.createTextNode(y));
+ document.body.appendChild(document.createElement('br'));
+}
+
+for(var key in location) {
+ output(key, location[key]);
+}
+</script>
+</body>
+</html>
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi/binding.h | 3 +-
javascript/jsapi/location.bnd | 95 +++++++++++++++++++-
javascript/jsapi/window.bnd | 3 +-
...ment-enumerate.html => location-enumerate.html} | 8 +-
4 files changed, 101 insertions(+), 8 deletions(-)
copy test/js/{dom-document-enumerate.html => location-enumerate.html} (79%)
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/location.bnd b/javascript/jsapi/location.bnd
index db7a247..e91094f 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>";
@@ -35,8 +33,101 @@ binding location {
interface Location; /* Web IDL interface to generate */
private "struct browser_window *" bw;
+ private "nsurl *" url;
}
operation reload %{
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));
+ dom_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));
+ dom_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));
+ dom_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));
+ dom_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));
+ dom_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));
+ dom_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));
+ dom_string_unref(component);
+ }
+%}
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index c4e6e88..dbc38a7 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -160,7 +160,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;
diff --git a/test/js/dom-document-enumerate.html b/test/js/location-enumerate.html
similarity index 79%
copy from test/js/dom-document-enumerate.html
copy to test/js/location-enumerate.html
index 18146ab..d455c75 100644
--- a/test/js/dom-document-enumerate.html
+++ b/test/js/location-enumerate.html
@@ -1,10 +1,10 @@
<html>
<head>
-<title>document interface enumeration</title>
+<title>location interface enumeration</title>
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Document interface enumeration</h1>
+<h1>location interface enumeration</h1>
<script>
function output(x,y) {
@@ -18,8 +18,8 @@ function output(x,y) {
document.body.appendChild(document.createElement('br'));
}
-for(var key in document) {
- output(key, document[key]);
+for(var key in location) {
+ output(key, location[key]);
}
</script>
</body>
--
NetSurf Browser
10 years, 6 months
nsgenjsbind: branch master updated. 2bfd4d2720b55df0141189633ef6fae530663d04
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/2bfd4d2720b55df01...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/2bfd4d2720b55df0141...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/2bfd4d2720b55df014118...
The branch, master has been updated
via 2bfd4d2720b55df0141189633ef6fae530663d04 (commit)
via 93c89193c1f2a29b00741d1494f262642108abe2 (commit)
via 607ae9bceedd28fdf3cab01b820916ef2406d2eb (commit)
via 6c86695d0c0b01f38bc266b61a46cc38c49824bb (commit)
from e709f23f29d7135a71923921db6eb059826955cf (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/2bfd4d2720b55df...
commit 2bfd4d2720b55df0141189633ef6fae530663d04
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
name and docuemnt the binding property attribute
diff --git a/doc/example.bnd b/doc/example.bnd
index a57d970..6bd051c 100644
--- a/doc/example.bnd
+++ b/doc/example.bnd
@@ -27,14 +27,14 @@ hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
hdrcomment "Released under the terms of the MIT License,";
hdrcomment " http://www.opensource.org/licenses/mit-license";
-/* the preamble block is copied verbatum into the generated output
+/* the preamble block is copied verbatum into the generated output
*
- * This can be used for includes, comments or whatever else is desired
+ * This can be used for includes, comments or whatever else is desired
*/
preamble %{
#include <dom/dom.h>
-
+
#include "utils/config.h"
#include "utils/log.h"
@@ -46,8 +46,8 @@ preamble %{
/* this block describes the binding to be generated
*
* Depending on the type of binding being generated multiple blocks
- * may be allowed.
- *
+ * may be allowed.
+ *
* Note: the js_libdom (javascript to libdom) binding as currently
* implemented only allows for a single binding per file, this may
* be improved in future.
@@ -71,12 +71,23 @@ binding example {
* - are considered for property getters/setters.
*/
internal "void *" fluff;
-
+
+ /* property handler specifiers:
+ * - (un)shared flag allows control of the properties JSAPI shared state.
+ * The default for all unnamed properties on the interface
+ * is shared without a type handler.
+ * - type flag allows a set of properties whose type matches the
+ * identifier to be handled by the same callback function.
+ */
+ property shared bar; /* the default - a noop */
+ property shared type EventHandler;
+ property unshared foo;
+ property unshared type WindowProxy;
}
-/* operation implementation code.
+/* operation implementation code.
*
- * The body is copied verbatum into operation binding
+ * The body is copied verbatum into operation binding
*
* several values are generated automatically:
*
@@ -94,7 +105,7 @@ binding example {
*
* - Arguments are automatically converted into c variables (named as
* per the WebIDL names.
- *
+ *
* - Return values (excepting void return types where its omitted) are
* always named "retval" and are of the appropriate c type. The
* initial value is set appropriately.
@@ -103,9 +114,9 @@ operation foo %{
retval = JS_NewStringCopyN(cx, "foo", SLEN("foo"));
%}
-/* property getter implementation code.
+/* property getter implementation code.
*
- * The body is copied verbatum into property getter binding
+ * The body is copied verbatum into property getter binding
*
* several values are generated automatically:
*
@@ -132,9 +143,9 @@ getter bar %{
retval = JS_NewStringCopyN(cx, "bar", SLEN("bar"));
%}
-/* property setter implementation code.
+/* property setter implementation code.
*
- * The body is copied verbatum into property getter binding
+ * The body is copied verbatum into property getter binding
*
* several values are generated automatically:
*
@@ -163,7 +174,7 @@ setter baz %{
printf("%s\n", setval);
%}
-/* implementation of the class initilisation
+/* implementation of the class initilisation
*
* This allows the default JS_InitClass to be overriden - currently
* only used for the window (global) object to cause all the other class
@@ -178,7 +189,7 @@ api init %{
/* implementation of the c instance creation
*
* This allows the overriding of the construction of an interface instance.
- *
+ *
* The body is copied verbatum and must return the new object in the
* "newobject" variable.
*
@@ -189,9 +200,9 @@ api init %{
* If there are private or internal values the private struct is
* constructed and instantiated. The struct is available during the
* new function and is automatically attached as the private value to
- * the object.
+ * the object.
*
- * The default implemenattion simply calls JS_NewObject()
+ * The default implemenattion simply calls JS_NewObject()
*
* Note this does *not* rely upon (or even call) the instances
* javascript constructor allowing the c code to create objects that
@@ -203,11 +214,11 @@ api new %{
/* additional code in the instance finalise operation.
*
- * The body is copied verbatim into the output
+ * The body is copied verbatim into the output
*
- * Prototype is
+ * Prototype is
* void jsclass_finalize(JSContext *cx, JSObject *obj)
- *
+ *
* private is available (if appropriate) and freed after the body
*/
api finalise %{
@@ -219,7 +230,7 @@ api finalise %{
* JSResolveOp with JSCLASS_NEW_RESOLVE specified and must provide a
* complete implementation.
*
- * The body is copied verbatim into the output
+ * The body is copied verbatim into the output
*
* Prototype is:
* JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp)
@@ -227,7 +238,7 @@ api finalise %{
* By default returns JS_TRUE implying that *objp has been updated
*
* The minimal implementation would be "*objp = NULL;" but is
- * equivalent to simply omitting this directive and using the defaul stub.
+ * equivalent to simply omitting this directive and using the defaul stub.
*/
api resolve %{
%}
@@ -237,4 +248,4 @@ api resolve %{
* The body is discarded.
*/
api global %{
-%}
\ No newline at end of file
+%}
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 5502030..2bfb591 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -31,14 +31,14 @@ get_binding_shared_modifier(struct binding *binding, const char *type, const cha
/* look for node matching the ident first */
shared_node = genbind_node_find_type_ident(binding->binding_list,
NULL,
- GENBIND_NODE_TYPE_BINDING_SHARED,
+ GENBIND_NODE_TYPE_BINDING_PROPERTY,
ident);
/* look for a node matching the type */
if (shared_node == NULL) {
shared_node = genbind_node_find_type_ident(binding->binding_list,
NULL,
- GENBIND_NODE_TYPE_BINDING_SHARED,
+ GENBIND_NODE_TYPE_BINDING_PROPERTY,
type);
}
@@ -779,7 +779,7 @@ output_property_body(struct binding *binding)
if (res == 0) {
res = genbind_node_for_each_type(binding->binding_list,
- GENBIND_NODE_TYPE_BINDING_SHARED,
+ GENBIND_NODE_TYPE_BINDING_PROPERTY,
typehandler_property_cb,
binding);
}
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index fba7dcb..f5cdc78 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -228,7 +228,7 @@ struct genbind_node *genbind_node_getnode(struct genbind_node *node)
case GENBIND_NODE_TYPE_BINDING:
case GENBIND_NODE_TYPE_BINDING_PRIVATE:
case GENBIND_NODE_TYPE_BINDING_INTERNAL:
- case GENBIND_NODE_TYPE_BINDING_SHARED:
+ case GENBIND_NODE_TYPE_BINDING_PROPERTY:
case GENBIND_NODE_TYPE_OPERATION:
case GENBIND_NODE_TYPE_API:
case GENBIND_NODE_TYPE_GETTER:
@@ -294,8 +294,8 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_BINDING_INTERFACE:
return "Interface";
- case GENBIND_NODE_TYPE_BINDING_SHARED:
- return "Shared";
+ case GENBIND_NODE_TYPE_BINDING_PROPERTY:
+ return "Property";
case GENBIND_NODE_TYPE_OPERATION:
return "Operation";
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index cddf608..6368519 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -24,7 +24,7 @@ enum genbind_node_type {
GENBIND_NODE_TYPE_BINDING_PRIVATE,
GENBIND_NODE_TYPE_BINDING_INTERNAL,
GENBIND_NODE_TYPE_BINDING_INTERFACE,
- GENBIND_NODE_TYPE_BINDING_SHARED,
+ GENBIND_NODE_TYPE_BINDING_PROPERTY,
GENBIND_NODE_TYPE_API,
GENBIND_NODE_TYPE_OPERATION,
GENBIND_NODE_TYPE_GETTER,
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index 313d37b..e1c7740 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -100,6 +100,8 @@ unshared return TOK_UNSHARED;
shared return TOK_SHARED;
+property return TOK_PROPERTY;
+
operation return TOK_OPERATION;
api return TOK_API;
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index b104f2f..984513e 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -36,7 +36,7 @@ char *errtxt;
{
char* text;
struct genbind_node *node;
- int number;
+ long value;
}
%token TOK_IDLFILE
@@ -54,6 +54,7 @@ char *errtxt;
%token TOK_INTERNAL
%token TOK_UNSHARED
%token TOK_SHARED
+%token TOK_PROPERTY
%token <text> TOK_IDENTIFIER
%token <text> TOK_STRING_LITERAL
@@ -61,8 +62,8 @@ char *errtxt;
%type <text> CBlock
-%type <number> Modifiers
-%type <number> Modifier
+%type <value> Modifiers
+%type <value> Modifier
%type <node> Statement
%type <node> Statements
@@ -77,7 +78,7 @@ char *errtxt;
%type <node> Private
%type <node> Internal
%type <node> Interface
-%type <node> Shared
+%type <node> Property
%type <node> Operation
%type <node> Api
%type <node> Getter
@@ -261,7 +262,7 @@ BindingArg
|
Interface
|
- Shared
+ Property
;
Type
@@ -300,11 +301,11 @@ Interface
}
;
-Shared
+Property
:
- TOK_SHARED Modifiers TOK_IDENTIFIER ';'
+ TOK_PROPERTY Modifiers TOK_IDENTIFIER ';'
{
- $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_SHARED,
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_PROPERTY,
NULL,
genbind_new_node(GENBIND_NODE_TYPE_MODIFIER,
genbind_new_node(GENBIND_NODE_TYPE_IDENT,
@@ -318,7 +319,7 @@ Modifiers
:
/* empty */
{
- $$ = 0;
+ $$ = GENBIND_TYPE_NONE;
}
|
Modifiers Modifier
@@ -338,6 +339,11 @@ Modifier
{
$$ = GENBIND_TYPE_UNSHARED;
}
+ |
+ TOK_SHARED
+ {
+ $$ = GENBIND_TYPE_NONE;
+ }
;
%%
diff --git a/test/data/bindings/window.bnd b/test/data/bindings/window.bnd
index 7b411b1..50ffe51 100644
--- a/test/data/bindings/window.bnd
+++ b/test/data/bindings/window.bnd
@@ -31,8 +31,10 @@ binding window {
internal "JSObject *" console;
internal "JSObject *" location;
- shared unshared type EventHandler;
- shared unshared foo;
+ property unshared type WindowProxy;
+ property unshared foo;
+ property shared type EventHandler;
+ property shared baz;
}
api mark %{
@@ -199,3 +201,7 @@ getter window %{
getter self %{
jsret = obj;
%}
+
+getter EventHandler %{
+ /* example shared property type handler */
+%}
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/93c89193c1f2a29...
commit 93c89193c1f2a29b00741d1494f262642108abe2
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
make property shared status and type handling selection generic
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 866d8e6..5502030 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -21,11 +21,47 @@ static int generate_property_spec(struct binding *binding, const char *interface
static int generate_property_body(struct binding *binding, const char *interface);
+/* search binding for property sharing modifier */
+static enum genbind_type_modifier
+get_binding_shared_modifier(struct binding *binding, const char *type, const char *ident)
+{
+ struct genbind_node *shared_node;
+ struct genbind_node *shared_mod_node;
+
+ /* look for node matching the ident first */
+ shared_node = genbind_node_find_type_ident(binding->binding_list,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_SHARED,
+ ident);
+
+ /* look for a node matching the type */
+ if (shared_node == NULL) {
+ shared_node = genbind_node_find_type_ident(binding->binding_list,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_SHARED,
+ type);
+
+ }
+
+
+ if (shared_node != NULL) {
+ /* no explicit shared status */
+ shared_mod_node = genbind_node_find_type(genbind_node_getnode(shared_node),
+ NULL,
+ GENBIND_NODE_TYPE_MODIFIER);
+ if (shared_mod_node != NULL) {
+ return genbind_node_getint(shared_mod_node);
+ }
+ }
+ return GENBIND_TYPE_NONE;
+}
+
static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
- struct genbind_node *unshared_node;
+
struct webidl_node *type_node;
+ const char *type = NULL;
struct webidl_node *ident_node;
const char *ident;
struct webidl_node *modifier_node;
@@ -41,6 +77,18 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
return -1;
}
+
+ /* get type name */
+ type_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_TYPE);
+ ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
+ type = webidl_node_gettext(ident_node);
+
+
+ /* generate JSAPI_PS macro entry */
modifier_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_MODIFIER);
@@ -51,45 +99,42 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
fprintf(binding->outfile, "\tJSAPI_PS(\"%s\", ", ident);
}
- unshared_node = genbind_node_find_type_ident(binding->binding_list,
- NULL,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
- ident);
+ /* generate property shared status */
+ switch (get_binding_shared_modifier(binding, type, ident)) {
- if (unshared_node != NULL) {
- /* not a shared property */
- fprintf(binding->outfile, "%s, 0, JSPROP_ENUMERATE", ident);
- } else {
- /* examine if the property is of a unshared type */
- type_node = webidl_node_find_type(webidl_node_getnode(node),
- NULL,
- WEBIDL_NODE_TYPE_TYPE);
+ default:
+ case GENBIND_TYPE_NONE:
+ /* shared property without type handler
+ *
+ * js doesnt provide storage and setter/getter must
+ * perform all GC management.
+ */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
+ ident);
+ break;
- ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
- NULL,
- WEBIDL_NODE_TYPE_IDENT);
+ case GENBIND_TYPE_TYPE:
+ /* shared property with a type handler */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
+ type);
+ break;
- if (ident_node != NULL) {
- unshared_node = genbind_node_find_type_type(binding->binding_list,
- NULL,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
- webidl_node_gettext(ident_node));
- }
+ case GENBIND_TYPE_UNSHARED:
+ /* unshared property without type handler */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE",
+ ident);
+ break;
+
+ case GENBIND_TYPE_TYPE_UNSHARED:
+ /* unshared property with a type handler */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE",
+ type);
+ break;
- if (unshared_node != NULL) {
- /* property is not shared because of its type */
- fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE",
- webidl_node_gettext(ident_node));
- } else {
- /* property is shared
- * js doesnt provide storage and setter/getter must
- * perform all GC management.
- */
- fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
- ident);
- }
}
fprintf(binding->outfile, "),\n");
@@ -538,7 +583,9 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
struct webidl_node *ident_node;
const char *ident;
struct webidl_node *type_node;
+ const char *type = NULL;
int ret;
+ enum genbind_type_modifier shared_mod;
ident_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
@@ -551,31 +598,28 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
return -1;
}
- /* do not generate individual getters/setters for an unshared type */
+ /* get type name */
type_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_TYPE);
-
ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
NULL,
WEBIDL_NODE_TYPE_IDENT);
-
- if (ident_node != NULL) {
- struct genbind_node *unshared_node;
- unshared_node = genbind_node_find_type_type(binding->binding_list,
- NULL,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
- webidl_node_gettext(ident_node));
- if (unshared_node != NULL) {
- return 0;
+ type = webidl_node_gettext(ident_node);
+
+ /* find shared modifiers */
+ shared_mod = get_binding_shared_modifier(binding, type, ident);
+
+ /* only generate individual getters/setters if there is not a
+ * type handler
+ */
+ if ((shared_mod & GENBIND_TYPE_TYPE) == 0) {
+ ret = output_property_setter(binding, node, ident);
+ if (ret == 0) {
+ /* property getter */
+ ret = output_property_getter(binding, node, ident);
}
}
-
- ret = output_property_setter(binding, node, ident);
- if (ret == 0) {
- /* property getter */
- ret = output_property_getter(binding, node, ident);
- }
return ret;
}
@@ -652,21 +696,30 @@ generate_property_body(struct binding *binding, const char *interface)
return res;
}
-
-
-int unshared_property_cb(struct genbind_node *node, void *ctx)
+/* callback to emit property handlers for whole types */
+static int typehandler_property_cb(struct genbind_node *node, void *ctx)
{
struct binding *binding = ctx;
- struct genbind_node *type_node;
+ struct genbind_node *ident_node;
struct genbind_node *property_node;
const char *type;
+ struct genbind_node *mod_node;
+ enum genbind_type_modifier share_mod;
+
+ mod_node = genbind_node_find_type(genbind_node_getnode(node),
+ NULL,
+ GENBIND_NODE_TYPE_MODIFIER);
+ share_mod = genbind_node_getint(mod_node);
+ if ((share_mod & GENBIND_TYPE_TYPE) != GENBIND_TYPE_TYPE) {
+ /* not a type handler */
+ return 0;
+ }
- /* only need to generate property body for unshared types */
- type_node = genbind_node_find_type(genbind_node_getnode(node),
+ ident_node = genbind_node_find_type(genbind_node_getnode(node),
NULL,
- GENBIND_NODE_TYPE_TYPE);
- type = genbind_node_gettext(type_node);
- if (type== NULL) {
+ GENBIND_NODE_TYPE_IDENT);
+ type = genbind_node_gettext(ident_node);
+ if (type == NULL) {
return 0;
}
@@ -726,8 +779,8 @@ output_property_body(struct binding *binding)
if (res == 0) {
res = genbind_node_for_each_type(binding->binding_list,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
- unshared_property_cb,
+ GENBIND_NODE_TYPE_BINDING_SHARED,
+ typehandler_property_cb,
binding);
}
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index df6c608..fba7dcb 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -32,6 +32,7 @@ struct genbind_node {
void *value;
struct genbind_node *node;
char *text;
+ int number; /* node data is an integer */
} r;
};
@@ -140,6 +141,10 @@ genbind_node_find_type_ident(struct genbind_node *node,
struct genbind_node *found_node;
struct genbind_node *ident_node;
+ if (ident == NULL) {
+ return NULL;
+ }
+
found_node = genbind_node_find_type(node, prev, type);
@@ -223,7 +228,7 @@ struct genbind_node *genbind_node_getnode(struct genbind_node *node)
case GENBIND_NODE_TYPE_BINDING:
case GENBIND_NODE_TYPE_BINDING_PRIVATE:
case GENBIND_NODE_TYPE_BINDING_INTERNAL:
- case GENBIND_NODE_TYPE_BINDING_UNSHARED:
+ case GENBIND_NODE_TYPE_BINDING_SHARED:
case GENBIND_NODE_TYPE_OPERATION:
case GENBIND_NODE_TYPE_API:
case GENBIND_NODE_TYPE_GETTER:
@@ -238,6 +243,21 @@ struct genbind_node *genbind_node_getnode(struct genbind_node *node)
}
+int genbind_node_getint(struct genbind_node *node)
+{
+ if (node != NULL) {
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_MODIFIER:
+ return node->r.number;
+
+ default:
+ break;
+ }
+ }
+ return -1;
+
+}
+
static const char *genbind_node_type_to_str(enum genbind_node_type type)
{
switch(type) {
@@ -274,8 +294,8 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_BINDING_INTERFACE:
return "Interface";
- case GENBIND_NODE_TYPE_BINDING_UNSHARED:
- return "Unshared";
+ case GENBIND_NODE_TYPE_BINDING_SHARED:
+ return "Shared";
case GENBIND_NODE_TYPE_OPERATION:
return "Operation";
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index 544582c..cddf608 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -11,8 +11,9 @@
enum genbind_node_type {
GENBIND_NODE_TYPE_ROOT = 0,
- GENBIND_NODE_TYPE_IDENT, /* generic identifier string */
- GENBIND_NODE_TYPE_TYPE, /* generic type string */
+ GENBIND_NODE_TYPE_IDENT, /**< generic identifier string */
+ GENBIND_NODE_TYPE_TYPE, /**< generic type string */
+ GENBIND_NODE_TYPE_MODIFIER, /**< node modifier */
GENBIND_NODE_TYPE_CBLOCK,
GENBIND_NODE_TYPE_WEBIDLFILE,
@@ -23,13 +24,21 @@ enum genbind_node_type {
GENBIND_NODE_TYPE_BINDING_PRIVATE,
GENBIND_NODE_TYPE_BINDING_INTERNAL,
GENBIND_NODE_TYPE_BINDING_INTERFACE,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ GENBIND_NODE_TYPE_BINDING_SHARED,
GENBIND_NODE_TYPE_API,
GENBIND_NODE_TYPE_OPERATION,
GENBIND_NODE_TYPE_GETTER,
GENBIND_NODE_TYPE_SETTER,
};
+/* modifier flags */
+enum genbind_type_modifier {
+ GENBIND_TYPE_NONE = 0,
+ GENBIND_TYPE_TYPE = 1, /**< identifies a type handler */
+ GENBIND_TYPE_UNSHARED = 2, /**< unshared item */
+ GENBIND_TYPE_TYPE_UNSHARED = 3, /**< identifies a unshared type handler */
+};
+
struct genbind_node;
@@ -113,5 +122,6 @@ int genbind_node_for_each_type(struct genbind_node *node, enum genbind_node_type
char *genbind_node_gettext(struct genbind_node *node);
struct genbind_node *genbind_node_getnode(struct genbind_node *node);
+int genbind_node_getint(struct genbind_node *node);
#endif
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index aea68ee..313d37b 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -98,6 +98,8 @@ internal return TOK_INTERNAL;
unshared return TOK_UNSHARED;
+shared return TOK_SHARED;
+
operation return TOK_OPERATION;
api return TOK_API;
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index 6364bf7..b104f2f 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -34,8 +34,9 @@ char *errtxt;
%union
{
- char* text;
- struct genbind_node *node;
+ char* text;
+ struct genbind_node *node;
+ int number;
}
%token TOK_IDLFILE
@@ -52,6 +53,7 @@ char *errtxt;
%token TOK_PRIVATE
%token TOK_INTERNAL
%token TOK_UNSHARED
+%token TOK_SHARED
%token <text> TOK_IDENTIFIER
%token <text> TOK_STRING_LITERAL
@@ -59,6 +61,9 @@ char *errtxt;
%type <text> CBlock
+%type <number> Modifiers
+%type <number> Modifier
+
%type <node> Statement
%type <node> Statements
%type <node> IdlFile
@@ -72,12 +77,13 @@ char *errtxt;
%type <node> Private
%type <node> Internal
%type <node> Interface
-%type <node> Unshared
+%type <node> Shared
%type <node> Operation
%type <node> Api
%type <node> Getter
%type <node> Setter
+
%%
Input
@@ -255,7 +261,7 @@ BindingArg
|
Interface
|
- Unshared
+ Shared
;
Type
@@ -294,18 +300,44 @@ Interface
}
;
-Unshared
+Shared
:
- TOK_UNSHARED TOK_TYPE TOK_IDENTIFIER ';'
+ TOK_SHARED Modifiers TOK_IDENTIFIER ';'
{
- $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_UNSHARED, NULL,
- genbind_new_node(GENBIND_NODE_TYPE_TYPE, NULL, $3));
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_SHARED,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_MODIFIER,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ NULL,
+ $3),
+ (void *)$2));
+ }
+ ;
+
+Modifiers
+ :
+ /* empty */
+ {
+ $$ = 0;
}
|
- TOK_UNSHARED TOK_IDENTIFIER ';'
+ Modifiers Modifier
{
- $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_UNSHARED, NULL,
- genbind_new_node(GENBIND_NODE_TYPE_IDENT, NULL, $2));
+ $$ |= $2;
}
;
+
+Modifier
+ :
+ TOK_TYPE
+ {
+ $$ = GENBIND_TYPE_TYPE;
+ }
+ |
+ TOK_UNSHARED
+ {
+ $$ = GENBIND_TYPE_UNSHARED;
+ }
+ ;
+
%%
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 683a1a2..f719110 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -41,11 +41,11 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str)
%union
{
- int attr;
- long value;
+ int attr;
+ long value;
bool isit;
- char* text;
- struct webidl_node *node;
+ char* text;
+ struct webidl_node *node;
}
diff --git a/test/data/bindings/window.bnd b/test/data/bindings/window.bnd
index 42b40f4..7b411b1 100644
--- a/test/data/bindings/window.bnd
+++ b/test/data/bindings/window.bnd
@@ -31,8 +31,8 @@ binding window {
internal "JSObject *" console;
internal "JSObject *" location;
- unshared type EventHandler;
- unshared foo;
+ shared unshared type EventHandler;
+ shared unshared foo;
}
api mark %{
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/607ae9bceedd28f...
commit 607ae9bceedd28fdf3cab01b820916ef2406d2eb
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
output unshared bodies
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index deecc5e..866d8e6 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -527,9 +527,9 @@ static int output_property_setter(struct binding *binding,
"{\n"
" return JS_FALSE;\n"
"}\n\n");
-
- return 0;
+
+ return 0;
}
static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
@@ -567,7 +567,7 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
GENBIND_NODE_TYPE_BINDING_UNSHARED,
webidl_node_gettext(ident_node));
if (unshared_node != NULL) {
- return 0;
+ return 0;
}
}
@@ -658,33 +658,60 @@ int unshared_property_cb(struct genbind_node *node, void *ctx)
{
struct binding *binding = ctx;
struct genbind_node *type_node;
+ struct genbind_node *property_node;
+ const char *type;
/* only need to generate property body for unshared types */
type_node = genbind_node_find_type(genbind_node_getnode(node),
NULL,
GENBIND_NODE_TYPE_TYPE);
- if (type_node == NULL) {
+ type = genbind_node_gettext(type_node);
+ if (type== NULL) {
return 0;
}
+ /* setter for unshared types */
fprintf(binding->outfile,
- "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
- genbind_node_gettext(type_node));
+ "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
+ "{\n",
+ type);
+
+ property_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_SETTER,
+ type);
+
+ if (property_node != NULL) {
+ /* binding source block */
+ output_code_block(binding, genbind_node_getnode(property_node));
+ }
fprintf(binding->outfile,
- "{\n"
- " return JS_FALSE;\n"
+ " return JS_TRUE;\n"
"}\n\n");
+
+ /* getter for unshared types */
+
fprintf(binding->outfile,
- "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
- genbind_node_gettext(type_node));
+ "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
+ "{\n",
+ type);
+
+ property_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_GETTER,
+ type);
+
+ if (property_node != NULL) {
+ /* binding source block */
+ output_code_block(binding, genbind_node_getnode(property_node));
+ }
fprintf(binding->outfile,
- "{\n"
- " return JS_FALSE;\n"
+ " return JS_TRUE;\n"
"}\n\n");
-
+
return 0;
}
@@ -700,7 +727,7 @@ output_property_body(struct binding *binding)
if (res == 0) {
res = genbind_node_for_each_type(binding->binding_list,
GENBIND_NODE_TYPE_BINDING_UNSHARED,
- unshared_property_cb,
+ unshared_property_cb,
binding);
}
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/6c86695d0c0b01f...
commit 6c86695d0c0b01f38bc266b61a46cc38c49824bb
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
fix unshared type generation
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 4f30011..deecc5e 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -663,6 +663,9 @@ int unshared_property_cb(struct genbind_node *node, void *ctx)
type_node = genbind_node_find_type(genbind_node_getnode(node),
NULL,
GENBIND_NODE_TYPE_TYPE);
+ if (type_node == NULL) {
+ return 0;
+ }
fprintf(binding->outfile,
"static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
@@ -674,9 +677,13 @@ int unshared_property_cb(struct genbind_node *node, void *ctx)
"}\n\n");
fprintf(binding->outfile,
- "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
- "{\n",
+ "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
genbind_node_gettext(type_node));
+
+ fprintf(binding->outfile,
+ "{\n"
+ " return JS_FALSE;\n"
+ "}\n\n");
return 0;
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index a8a8361..df6c608 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -197,38 +197,45 @@ int genbind_cmp_node_type(struct genbind_node *node, void *ctx)
char *genbind_node_gettext(struct genbind_node *node)
{
- switch(node->type) {
- case GENBIND_NODE_TYPE_WEBIDLFILE:
- case GENBIND_NODE_TYPE_STRING:
- case GENBIND_NODE_TYPE_PREAMBLE:
- case GENBIND_NODE_TYPE_IDENT:
- case GENBIND_NODE_TYPE_TYPE:
- case GENBIND_NODE_TYPE_BINDING_INTERFACE:
- case GENBIND_NODE_TYPE_CBLOCK:
- return node->r.text;
-
- default:
- return NULL;
+ if (node != NULL) {
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_WEBIDLFILE:
+ case GENBIND_NODE_TYPE_STRING:
+ case GENBIND_NODE_TYPE_PREAMBLE:
+ case GENBIND_NODE_TYPE_IDENT:
+ case GENBIND_NODE_TYPE_TYPE:
+ case GENBIND_NODE_TYPE_BINDING_INTERFACE:
+ case GENBIND_NODE_TYPE_CBLOCK:
+ return node->r.text;
+
+ default:
+ break;
+ }
}
+ return NULL;
}
struct genbind_node *genbind_node_getnode(struct genbind_node *node)
{
- switch(node->type) {
- case GENBIND_NODE_TYPE_HDRCOMMENT:
- case GENBIND_NODE_TYPE_BINDING:
- case GENBIND_NODE_TYPE_BINDING_PRIVATE:
- case GENBIND_NODE_TYPE_BINDING_INTERNAL:
- case GENBIND_NODE_TYPE_BINDING_UNSHARED:
- case GENBIND_NODE_TYPE_OPERATION:
- case GENBIND_NODE_TYPE_API:
- case GENBIND_NODE_TYPE_GETTER:
- case GENBIND_NODE_TYPE_SETTER:
- return node->r.node;
-
- default:
- return NULL;
+ if (node != NULL) {
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_HDRCOMMENT:
+ case GENBIND_NODE_TYPE_BINDING:
+ case GENBIND_NODE_TYPE_BINDING_PRIVATE:
+ case GENBIND_NODE_TYPE_BINDING_INTERNAL:
+ case GENBIND_NODE_TYPE_BINDING_UNSHARED:
+ case GENBIND_NODE_TYPE_OPERATION:
+ case GENBIND_NODE_TYPE_API:
+ case GENBIND_NODE_TYPE_GETTER:
+ case GENBIND_NODE_TYPE_SETTER:
+ return node->r.node;
+
+ default:
+ break;
+ }
}
+ return NULL;
+
}
static const char *genbind_node_type_to_str(enum genbind_node_type type)
-----------------------------------------------------------------------
Summary of changes:
doc/example.bnd | 57 ++++++----
src/jsapi-libdom-property.c | 227 ++++++++++++++++++++++++++++-------------
src/nsgenbind-ast.c | 81 ++++++++++-----
src/nsgenbind-ast.h | 16 +++-
src/nsgenbind-lexer.l | 4 +
src/nsgenbind-parser.y | 60 +++++++++--
src/webidl-parser.y | 8 +-
test/data/bindings/window.bnd | 10 ++-
8 files changed, 323 insertions(+), 140 deletions(-)
diff --git a/doc/example.bnd b/doc/example.bnd
index a57d970..6bd051c 100644
--- a/doc/example.bnd
+++ b/doc/example.bnd
@@ -27,14 +27,14 @@ hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
hdrcomment "Released under the terms of the MIT License,";
hdrcomment " http://www.opensource.org/licenses/mit-license";
-/* the preamble block is copied verbatum into the generated output
+/* the preamble block is copied verbatum into the generated output
*
- * This can be used for includes, comments or whatever else is desired
+ * This can be used for includes, comments or whatever else is desired
*/
preamble %{
#include <dom/dom.h>
-
+
#include "utils/config.h"
#include "utils/log.h"
@@ -46,8 +46,8 @@ preamble %{
/* this block describes the binding to be generated
*
* Depending on the type of binding being generated multiple blocks
- * may be allowed.
- *
+ * may be allowed.
+ *
* Note: the js_libdom (javascript to libdom) binding as currently
* implemented only allows for a single binding per file, this may
* be improved in future.
@@ -71,12 +71,23 @@ binding example {
* - are considered for property getters/setters.
*/
internal "void *" fluff;
-
+
+ /* property handler specifiers:
+ * - (un)shared flag allows control of the properties JSAPI shared state.
+ * The default for all unnamed properties on the interface
+ * is shared without a type handler.
+ * - type flag allows a set of properties whose type matches the
+ * identifier to be handled by the same callback function.
+ */
+ property shared bar; /* the default - a noop */
+ property shared type EventHandler;
+ property unshared foo;
+ property unshared type WindowProxy;
}
-/* operation implementation code.
+/* operation implementation code.
*
- * The body is copied verbatum into operation binding
+ * The body is copied verbatum into operation binding
*
* several values are generated automatically:
*
@@ -94,7 +105,7 @@ binding example {
*
* - Arguments are automatically converted into c variables (named as
* per the WebIDL names.
- *
+ *
* - Return values (excepting void return types where its omitted) are
* always named "retval" and are of the appropriate c type. The
* initial value is set appropriately.
@@ -103,9 +114,9 @@ operation foo %{
retval = JS_NewStringCopyN(cx, "foo", SLEN("foo"));
%}
-/* property getter implementation code.
+/* property getter implementation code.
*
- * The body is copied verbatum into property getter binding
+ * The body is copied verbatum into property getter binding
*
* several values are generated automatically:
*
@@ -132,9 +143,9 @@ getter bar %{
retval = JS_NewStringCopyN(cx, "bar", SLEN("bar"));
%}
-/* property setter implementation code.
+/* property setter implementation code.
*
- * The body is copied verbatum into property getter binding
+ * The body is copied verbatum into property getter binding
*
* several values are generated automatically:
*
@@ -163,7 +174,7 @@ setter baz %{
printf("%s\n", setval);
%}
-/* implementation of the class initilisation
+/* implementation of the class initilisation
*
* This allows the default JS_InitClass to be overriden - currently
* only used for the window (global) object to cause all the other class
@@ -178,7 +189,7 @@ api init %{
/* implementation of the c instance creation
*
* This allows the overriding of the construction of an interface instance.
- *
+ *
* The body is copied verbatum and must return the new object in the
* "newobject" variable.
*
@@ -189,9 +200,9 @@ api init %{
* If there are private or internal values the private struct is
* constructed and instantiated. The struct is available during the
* new function and is automatically attached as the private value to
- * the object.
+ * the object.
*
- * The default implemenattion simply calls JS_NewObject()
+ * The default implemenattion simply calls JS_NewObject()
*
* Note this does *not* rely upon (or even call) the instances
* javascript constructor allowing the c code to create objects that
@@ -203,11 +214,11 @@ api new %{
/* additional code in the instance finalise operation.
*
- * The body is copied verbatim into the output
+ * The body is copied verbatim into the output
*
- * Prototype is
+ * Prototype is
* void jsclass_finalize(JSContext *cx, JSObject *obj)
- *
+ *
* private is available (if appropriate) and freed after the body
*/
api finalise %{
@@ -219,7 +230,7 @@ api finalise %{
* JSResolveOp with JSCLASS_NEW_RESOLVE specified and must provide a
* complete implementation.
*
- * The body is copied verbatim into the output
+ * The body is copied verbatim into the output
*
* Prototype is:
* JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp)
@@ -227,7 +238,7 @@ api finalise %{
* By default returns JS_TRUE implying that *objp has been updated
*
* The minimal implementation would be "*objp = NULL;" but is
- * equivalent to simply omitting this directive and using the defaul stub.
+ * equivalent to simply omitting this directive and using the defaul stub.
*/
api resolve %{
%}
@@ -237,4 +248,4 @@ api resolve %{
* The body is discarded.
*/
api global %{
-%}
\ No newline at end of file
+%}
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 4f30011..2bfb591 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -21,11 +21,47 @@ static int generate_property_spec(struct binding *binding, const char *interface
static int generate_property_body(struct binding *binding, const char *interface);
+/* search binding for property sharing modifier */
+static enum genbind_type_modifier
+get_binding_shared_modifier(struct binding *binding, const char *type, const char *ident)
+{
+ struct genbind_node *shared_node;
+ struct genbind_node *shared_mod_node;
+
+ /* look for node matching the ident first */
+ shared_node = genbind_node_find_type_ident(binding->binding_list,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_PROPERTY,
+ ident);
+
+ /* look for a node matching the type */
+ if (shared_node == NULL) {
+ shared_node = genbind_node_find_type_ident(binding->binding_list,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_PROPERTY,
+ type);
+
+ }
+
+
+ if (shared_node != NULL) {
+ /* no explicit shared status */
+ shared_mod_node = genbind_node_find_type(genbind_node_getnode(shared_node),
+ NULL,
+ GENBIND_NODE_TYPE_MODIFIER);
+ if (shared_mod_node != NULL) {
+ return genbind_node_getint(shared_mod_node);
+ }
+ }
+ return GENBIND_TYPE_NONE;
+}
+
static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
- struct genbind_node *unshared_node;
+
struct webidl_node *type_node;
+ const char *type = NULL;
struct webidl_node *ident_node;
const char *ident;
struct webidl_node *modifier_node;
@@ -41,6 +77,18 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
return -1;
}
+
+ /* get type name */
+ type_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_TYPE);
+ ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
+ type = webidl_node_gettext(ident_node);
+
+
+ /* generate JSAPI_PS macro entry */
modifier_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_MODIFIER);
@@ -51,45 +99,42 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
fprintf(binding->outfile, "\tJSAPI_PS(\"%s\", ", ident);
}
- unshared_node = genbind_node_find_type_ident(binding->binding_list,
- NULL,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
- ident);
+ /* generate property shared status */
+ switch (get_binding_shared_modifier(binding, type, ident)) {
- if (unshared_node != NULL) {
- /* not a shared property */
- fprintf(binding->outfile, "%s, 0, JSPROP_ENUMERATE", ident);
- } else {
- /* examine if the property is of a unshared type */
- type_node = webidl_node_find_type(webidl_node_getnode(node),
- NULL,
- WEBIDL_NODE_TYPE_TYPE);
+ default:
+ case GENBIND_TYPE_NONE:
+ /* shared property without type handler
+ *
+ * js doesnt provide storage and setter/getter must
+ * perform all GC management.
+ */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
+ ident);
+ break;
- ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
- NULL,
- WEBIDL_NODE_TYPE_IDENT);
+ case GENBIND_TYPE_TYPE:
+ /* shared property with a type handler */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
+ type);
+ break;
- if (ident_node != NULL) {
- unshared_node = genbind_node_find_type_type(binding->binding_list,
- NULL,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
- webidl_node_gettext(ident_node));
- }
+ case GENBIND_TYPE_UNSHARED:
+ /* unshared property without type handler */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE",
+ ident);
+ break;
+
+ case GENBIND_TYPE_TYPE_UNSHARED:
+ /* unshared property with a type handler */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE",
+ type);
+ break;
- if (unshared_node != NULL) {
- /* property is not shared because of its type */
- fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE",
- webidl_node_gettext(ident_node));
- } else {
- /* property is shared
- * js doesnt provide storage and setter/getter must
- * perform all GC management.
- */
- fprintf(binding->outfile,
- "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
- ident);
- }
}
fprintf(binding->outfile, "),\n");
@@ -527,9 +572,9 @@ static int output_property_setter(struct binding *binding,
"{\n"
" return JS_FALSE;\n"
"}\n\n");
-
- return 0;
+
+ return 0;
}
static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
@@ -538,7 +583,9 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
struct webidl_node *ident_node;
const char *ident;
struct webidl_node *type_node;
+ const char *type = NULL;
int ret;
+ enum genbind_type_modifier shared_mod;
ident_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
@@ -551,31 +598,28 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
return -1;
}
- /* do not generate individual getters/setters for an unshared type */
+ /* get type name */
type_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_TYPE);
-
ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
NULL,
WEBIDL_NODE_TYPE_IDENT);
-
- if (ident_node != NULL) {
- struct genbind_node *unshared_node;
- unshared_node = genbind_node_find_type_type(binding->binding_list,
- NULL,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
- webidl_node_gettext(ident_node));
- if (unshared_node != NULL) {
- return 0;
+ type = webidl_node_gettext(ident_node);
+
+ /* find shared modifiers */
+ shared_mod = get_binding_shared_modifier(binding, type, ident);
+
+ /* only generate individual getters/setters if there is not a
+ * type handler
+ */
+ if ((shared_mod & GENBIND_TYPE_TYPE) == 0) {
+ ret = output_property_setter(binding, node, ident);
+ if (ret == 0) {
+ /* property getter */
+ ret = output_property_getter(binding, node, ident);
}
}
-
- ret = output_property_setter(binding, node, ident);
- if (ret == 0) {
- /* property getter */
- ret = output_property_getter(binding, node, ident);
- }
return ret;
}
@@ -652,32 +696,75 @@ generate_property_body(struct binding *binding, const char *interface)
return res;
}
-
-
-int unshared_property_cb(struct genbind_node *node, void *ctx)
+/* callback to emit property handlers for whole types */
+static int typehandler_property_cb(struct genbind_node *node, void *ctx)
{
struct binding *binding = ctx;
- struct genbind_node *type_node;
+ struct genbind_node *ident_node;
+ struct genbind_node *property_node;
+ const char *type;
+ struct genbind_node *mod_node;
+ enum genbind_type_modifier share_mod;
- /* only need to generate property body for unshared types */
- type_node = genbind_node_find_type(genbind_node_getnode(node),
+ mod_node = genbind_node_find_type(genbind_node_getnode(node),
NULL,
- GENBIND_NODE_TYPE_TYPE);
+ GENBIND_NODE_TYPE_MODIFIER);
+ share_mod = genbind_node_getint(mod_node);
+ if ((share_mod & GENBIND_TYPE_TYPE) != GENBIND_TYPE_TYPE) {
+ /* not a type handler */
+ return 0;
+ }
+
+ ident_node = genbind_node_find_type(genbind_node_getnode(node),
+ NULL,
+ GENBIND_NODE_TYPE_IDENT);
+ type = genbind_node_gettext(ident_node);
+ if (type == NULL) {
+ return 0;
+ }
+ /* setter for unshared types */
fprintf(binding->outfile,
- "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
- genbind_node_gettext(type_node));
+ "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
+ "{\n",
+ type);
+
+ property_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_SETTER,
+ type);
+
+ if (property_node != NULL) {
+ /* binding source block */
+ output_code_block(binding, genbind_node_getnode(property_node));
+ }
fprintf(binding->outfile,
- "{\n"
- " return JS_FALSE;\n"
+ " return JS_TRUE;\n"
"}\n\n");
+
+ /* getter for unshared types */
+
fprintf(binding->outfile,
"static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
"{\n",
- genbind_node_gettext(type_node));
-
+ type);
+
+ property_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_GETTER,
+ type);
+
+ if (property_node != NULL) {
+ /* binding source block */
+ output_code_block(binding, genbind_node_getnode(property_node));
+ }
+
+ fprintf(binding->outfile,
+ " return JS_TRUE;\n"
+ "}\n\n");
+
return 0;
}
@@ -692,8 +779,8 @@ output_property_body(struct binding *binding)
if (res == 0) {
res = genbind_node_for_each_type(binding->binding_list,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
- unshared_property_cb,
+ GENBIND_NODE_TYPE_BINDING_PROPERTY,
+ typehandler_property_cb,
binding);
}
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index a8a8361..f5cdc78 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -32,6 +32,7 @@ struct genbind_node {
void *value;
struct genbind_node *node;
char *text;
+ int number; /* node data is an integer */
} r;
};
@@ -140,6 +141,10 @@ genbind_node_find_type_ident(struct genbind_node *node,
struct genbind_node *found_node;
struct genbind_node *ident_node;
+ if (ident == NULL) {
+ return NULL;
+ }
+
found_node = genbind_node_find_type(node, prev, type);
@@ -197,38 +202,60 @@ int genbind_cmp_node_type(struct genbind_node *node, void *ctx)
char *genbind_node_gettext(struct genbind_node *node)
{
- switch(node->type) {
- case GENBIND_NODE_TYPE_WEBIDLFILE:
- case GENBIND_NODE_TYPE_STRING:
- case GENBIND_NODE_TYPE_PREAMBLE:
- case GENBIND_NODE_TYPE_IDENT:
- case GENBIND_NODE_TYPE_TYPE:
- case GENBIND_NODE_TYPE_BINDING_INTERFACE:
- case GENBIND_NODE_TYPE_CBLOCK:
- return node->r.text;
-
- default:
- return NULL;
+ if (node != NULL) {
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_WEBIDLFILE:
+ case GENBIND_NODE_TYPE_STRING:
+ case GENBIND_NODE_TYPE_PREAMBLE:
+ case GENBIND_NODE_TYPE_IDENT:
+ case GENBIND_NODE_TYPE_TYPE:
+ case GENBIND_NODE_TYPE_BINDING_INTERFACE:
+ case GENBIND_NODE_TYPE_CBLOCK:
+ return node->r.text;
+
+ default:
+ break;
+ }
}
+ return NULL;
}
struct genbind_node *genbind_node_getnode(struct genbind_node *node)
{
- switch(node->type) {
- case GENBIND_NODE_TYPE_HDRCOMMENT:
- case GENBIND_NODE_TYPE_BINDING:
- case GENBIND_NODE_TYPE_BINDING_PRIVATE:
- case GENBIND_NODE_TYPE_BINDING_INTERNAL:
- case GENBIND_NODE_TYPE_BINDING_UNSHARED:
- case GENBIND_NODE_TYPE_OPERATION:
- case GENBIND_NODE_TYPE_API:
- case GENBIND_NODE_TYPE_GETTER:
- case GENBIND_NODE_TYPE_SETTER:
- return node->r.node;
+ if (node != NULL) {
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_HDRCOMMENT:
+ case GENBIND_NODE_TYPE_BINDING:
+ case GENBIND_NODE_TYPE_BINDING_PRIVATE:
+ case GENBIND_NODE_TYPE_BINDING_INTERNAL:
+ case GENBIND_NODE_TYPE_BINDING_PROPERTY:
+ case GENBIND_NODE_TYPE_OPERATION:
+ case GENBIND_NODE_TYPE_API:
+ case GENBIND_NODE_TYPE_GETTER:
+ case GENBIND_NODE_TYPE_SETTER:
+ return node->r.node;
+
+ default:
+ break;
+ }
+ }
+ return NULL;
- default:
- return NULL;
+}
+
+int genbind_node_getint(struct genbind_node *node)
+{
+ if (node != NULL) {
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_MODIFIER:
+ return node->r.number;
+
+ default:
+ break;
+ }
}
+ return -1;
+
}
static const char *genbind_node_type_to_str(enum genbind_node_type type)
@@ -267,8 +294,8 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_BINDING_INTERFACE:
return "Interface";
- case GENBIND_NODE_TYPE_BINDING_UNSHARED:
- return "Unshared";
+ case GENBIND_NODE_TYPE_BINDING_PROPERTY:
+ return "Property";
case GENBIND_NODE_TYPE_OPERATION:
return "Operation";
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index 544582c..6368519 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -11,8 +11,9 @@
enum genbind_node_type {
GENBIND_NODE_TYPE_ROOT = 0,
- GENBIND_NODE_TYPE_IDENT, /* generic identifier string */
- GENBIND_NODE_TYPE_TYPE, /* generic type string */
+ GENBIND_NODE_TYPE_IDENT, /**< generic identifier string */
+ GENBIND_NODE_TYPE_TYPE, /**< generic type string */
+ GENBIND_NODE_TYPE_MODIFIER, /**< node modifier */
GENBIND_NODE_TYPE_CBLOCK,
GENBIND_NODE_TYPE_WEBIDLFILE,
@@ -23,13 +24,21 @@ enum genbind_node_type {
GENBIND_NODE_TYPE_BINDING_PRIVATE,
GENBIND_NODE_TYPE_BINDING_INTERNAL,
GENBIND_NODE_TYPE_BINDING_INTERFACE,
- GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ GENBIND_NODE_TYPE_BINDING_PROPERTY,
GENBIND_NODE_TYPE_API,
GENBIND_NODE_TYPE_OPERATION,
GENBIND_NODE_TYPE_GETTER,
GENBIND_NODE_TYPE_SETTER,
};
+/* modifier flags */
+enum genbind_type_modifier {
+ GENBIND_TYPE_NONE = 0,
+ GENBIND_TYPE_TYPE = 1, /**< identifies a type handler */
+ GENBIND_TYPE_UNSHARED = 2, /**< unshared item */
+ GENBIND_TYPE_TYPE_UNSHARED = 3, /**< identifies a unshared type handler */
+};
+
struct genbind_node;
@@ -113,5 +122,6 @@ int genbind_node_for_each_type(struct genbind_node *node, enum genbind_node_type
char *genbind_node_gettext(struct genbind_node *node);
struct genbind_node *genbind_node_getnode(struct genbind_node *node);
+int genbind_node_getint(struct genbind_node *node);
#endif
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index aea68ee..e1c7740 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -98,6 +98,10 @@ internal return TOK_INTERNAL;
unshared return TOK_UNSHARED;
+shared return TOK_SHARED;
+
+property return TOK_PROPERTY;
+
operation return TOK_OPERATION;
api return TOK_API;
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index 6364bf7..984513e 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -34,8 +34,9 @@ char *errtxt;
%union
{
- char* text;
- struct genbind_node *node;
+ char* text;
+ struct genbind_node *node;
+ long value;
}
%token TOK_IDLFILE
@@ -52,6 +53,8 @@ char *errtxt;
%token TOK_PRIVATE
%token TOK_INTERNAL
%token TOK_UNSHARED
+%token TOK_SHARED
+%token TOK_PROPERTY
%token <text> TOK_IDENTIFIER
%token <text> TOK_STRING_LITERAL
@@ -59,6 +62,9 @@ char *errtxt;
%type <text> CBlock
+%type <value> Modifiers
+%type <value> Modifier
+
%type <node> Statement
%type <node> Statements
%type <node> IdlFile
@@ -72,12 +78,13 @@ char *errtxt;
%type <node> Private
%type <node> Internal
%type <node> Interface
-%type <node> Unshared
+%type <node> Property
%type <node> Operation
%type <node> Api
%type <node> Getter
%type <node> Setter
+
%%
Input
@@ -255,7 +262,7 @@ BindingArg
|
Interface
|
- Unshared
+ Property
;
Type
@@ -294,18 +301,49 @@ Interface
}
;
-Unshared
+Property
+ :
+ TOK_PROPERTY Modifiers TOK_IDENTIFIER ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_PROPERTY,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_MODIFIER,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ NULL,
+ $3),
+ (void *)$2));
+ }
+ ;
+
+Modifiers
+ :
+ /* empty */
+ {
+ $$ = GENBIND_TYPE_NONE;
+ }
+ |
+ Modifiers Modifier
+ {
+ $$ |= $2;
+ }
+ ;
+
+Modifier
:
- TOK_UNSHARED TOK_TYPE TOK_IDENTIFIER ';'
+ TOK_TYPE
{
- $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_UNSHARED, NULL,
- genbind_new_node(GENBIND_NODE_TYPE_TYPE, NULL, $3));
+ $$ = GENBIND_TYPE_TYPE;
}
|
- TOK_UNSHARED TOK_IDENTIFIER ';'
+ TOK_UNSHARED
{
- $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_UNSHARED, NULL,
- genbind_new_node(GENBIND_NODE_TYPE_IDENT, NULL, $2));
+ $$ = GENBIND_TYPE_UNSHARED;
+ }
+ |
+ TOK_SHARED
+ {
+ $$ = GENBIND_TYPE_NONE;
}
;
+
%%
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 683a1a2..f719110 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -41,11 +41,11 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str)
%union
{
- int attr;
- long value;
+ int attr;
+ long value;
bool isit;
- char* text;
- struct webidl_node *node;
+ char* text;
+ struct webidl_node *node;
}
diff --git a/test/data/bindings/window.bnd b/test/data/bindings/window.bnd
index 42b40f4..50ffe51 100644
--- a/test/data/bindings/window.bnd
+++ b/test/data/bindings/window.bnd
@@ -31,8 +31,10 @@ binding window {
internal "JSObject *" console;
internal "JSObject *" location;
- unshared type EventHandler;
- unshared foo;
+ property unshared type WindowProxy;
+ property unshared foo;
+ property shared type EventHandler;
+ property shared baz;
}
api mark %{
@@ -199,3 +201,7 @@ getter window %{
getter self %{
jsret = obj;
%}
+
+getter EventHandler %{
+ /* example shared property type handler */
+%}
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
netsurf: branch mono/removing-windom-dependency updated. 0672d5e2c9e66fc12311ad41a566e56cee30f7e3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/0672d5e2c9e66fc12311a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/0672d5e2c9e66fc12311ad4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/0672d5e2c9e66fc12311ad41a...
The branch, mono/removing-windom-dependency has been updated
via 0672d5e2c9e66fc12311ad41a566e56cee30f7e3 (commit)
from 7e94f32e4c99ced99ab4efaef1e56ad96430fb40 (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/0672d5e2c9e66fc1231...
commit 0672d5e2c9e66fc12311ad41a566e56cee30f7e3
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Implemented scroll handling in gemtk.
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index 4128715..5184451 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -1,22 +1,23 @@
-#ifndef GEMTK_H_INCLUDED
-#define GEMTK_H_INCLUDED
+#ifndef GEMTK_H_INCLUDED
+#define GEMTK_H_INCLUDED
#include <gem.h>
#include <mint/osbind.h>
#include <mint/cookie.h>
-#include <stdint.h>
-
-/* System type detection added by [GS] */
+#include <stdint.h>
+#include <stdbool.h>
+
+/* System type detection added by [GS] */
/* detect the system type, AES + kernel */
-#define SYS_TOS 0x0001
-#define SYS_MAGIC 0x0002
-#define SYS_MINT 0x0004
-#define SYS_GENEVA 0x0010
-#define SYS_NAES 0x0020
-#define SYS_XAAES 0x0040
-#define sys_type() (_systype_v ? _systype_v : _systype())
-#define sys_MAGIC() ((sys_type() & SYS_MAGIC) != 0)
-#define sys_NAES() ((sys_type() & SYS_NAES) != 0)
+#define SYS_TOS 0x0001
+#define SYS_MAGIC 0x0002
+#define SYS_MINT 0x0004
+#define SYS_GENEVA 0x0010
+#define SYS_NAES 0x0020
+#define SYS_XAAES 0x0040
+#define sys_type() (_systype_v ? _systype_v : _systype())
+#define sys_MAGIC() ((sys_type() & SYS_MAGIC) != 0)
+#define sys_NAES() ((sys_type() & SYS_NAES) != 0)
#define sys_XAAES() ((sys_type() & SYS_XAAES) != 0)
#define TOS4VER 0x03300 /* this is assumed to be the last single tasking OS */
@@ -29,20 +30,20 @@ extern unsigned short _systype_v;
unsigned short _systype (void);
OBJECT *get_tree( int idx );
-/*
-* MultiTOS Drag&Drop
-*/
-short ddcreate(short *pipe);
-short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename);
-short ddrexts(short fd, char *exts);
-short ddstry(short fd, char *ext, char *text, char *name, long size);
-void ddclose(short fd);
-void ddgetsig(long *oldsig);
-void ddsetsig(long oldsig);
-short ddopen(short ddnam, char ddmsg);
-short ddsexts(short fd, char *exts);
-short ddrtry(short fd, char *name, char *file, char *whichext, long *size);
-short ddreply(short fd, char ack);
+/*
+* MultiTOS Drag&Drop
+*/
+short ddcreate(short *pipe);
+short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename);
+short ddrexts(short fd, char *exts);
+short ddstry(short fd, char *ext, char *text, char *name, long size);
+void ddclose(short fd);
+void ddgetsig(long *oldsig);
+void ddsetsig(long oldsig);
+short ddopen(short ddnam, char ddmsg);
+short ddsexts(short fd, char *exts);
+short ddrtry(short fd, char *name, char *file, char *whichext, long *size);
+short ddreply(short fd, char ack);
/*
Message box
@@ -61,8 +62,12 @@ short msg_box_show(short type, const char * msg);
#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
#define GW_FLAG_CUSTOM_SCROLLING 0x10 // no internal scroller handling
-#define GW_STATUS_ICONIFIED 0x01
-#define GW_STATUS_SHADED 0x02
+#define GW_STATUS_ICONIFIED 0x01
+#define GW_STATUS_SHADED 0x02
+
+#define GUIWIN_VSLIDER 0x01
+#define GUIWIN_HSLIDER 0x02
+#define GUIWIN_VH_SLIDER 0x03
struct gui_window_s;
typedef struct gui_window_s GUIWIN;
@@ -101,9 +106,10 @@ void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb);
void guiwin_set_user_data(GUIWIN *win, void *data);
void *guiwin_get_user_data(GUIWIN *win);
struct guiwin_scroll_info_s * guiwin_get_scroll_info(GUIWIN *win);
-void guiwin_update_slider(GUIWIN *win, short mode);
+bool guiwin_update_slider(GUIWIN *win, short mode);
void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
+bool guiwin_has_intersection(GUIWIN *win, GRECT *work);
@@ -123,5 +129,5 @@ VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
#ifndef MIN
#define MIN(_a,_b) ((_a<_b) ? _a : _b)
#endif
-
-#endif // GEMTK_H_INCLUDED
+
+#endif // GEMTK_H_INCLUDED
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index e055aba..026b18c 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -8,7 +8,7 @@
#include <mt_gem.h>
#include "gemtk.h"
-//#define DEBUG_PRINT(x) printf x
+//#define DEBUG_PRINT(x) printf x
#define DEBUG_PRINT(x)
struct gui_window_s {
@@ -27,30 +27,37 @@ static GUIWIN * winlist;
static VdiHdl v_vdi_h = -1;
static short work_out[57];
-static void move_screen( int vhandle, GRECT *screen, int dx, int dy) {
- INT16 xy[ 8];
- long dum = 0L;
- GRECT g;
-
- /* get intersection with screen area */
- wind_get_grect(0, WF_CURRXYWH, &g);
- rc_intersect(&g, screen);
- xy[ 0] = screen -> g_x;
- xy[ 1] = screen -> g_y;
- xy[ 2] = xy[ 0] + screen -> g_w - 1;
- xy[ 3] = xy[ 1] + screen -> g_h - 1;
- xy[ 4] = xy[ 0] + dx;
- xy[ 5] = xy[ 1] + dy;
- xy[ 6] = xy[ 2] + dx;
- xy[ 7] = xy[ 3] + dy;
- vro_cpyfm( vhandle, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
+static void move_rect(GRECT *rect, int dx, int dy)
+{
+ INT16 xy[ 8];
+ long dum = 0L;
+ GRECT g;
+
+ while( !wind_update(BEG_UPDATE));
+ graf_mouse(M_OFF, 0L);
+
+ /* get intersection with screen area */
+ wind_get_grect(0, WF_CURRXYWH, &g);
+ rc_intersect(&g, rect);
+ xy[0] = rect->g_x;
+ xy[1] = rect->g_y;
+ xy[2] = xy[0] + rect->g_w-1;
+ xy[3] = xy[1] + rect->g_h-1;
+ xy[4] = xy[0] + dx;
+ xy[5] = xy[1] + dy;
+ xy[6] = xy[2] + dx;
+ xy[7] = xy[3] + dy;
+ vro_cpyfm(v_vdi_h, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
+
+ graf_mouse(M_ON, 0L);
+ wind_update(END_UPDATE);
}
static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
GRECT g, g_ro, tb_area, tb_area_ro;
short retval = 1;
- int val;
+ int val = 1;
struct guiwin_scroll_info_s *slid;
switch(msg[0]) {
@@ -63,49 +70,104 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
g_ro = g;
switch(msg[4]) {
- case WA_DNPAGE:
- val = g.g_h;
- // complete redraw
- // increase scroll val by page size...
- break;
+ case WA_UPPAGE:
+ val = g.g_h/slid->y_unit_px;
+ slid->y_pos = MAX(0, slid->y_pos-val);
+ guiwin_update_slider(gw, GUIWIN_VSLIDER);
+ guiwin_send_redraw(gw, &g_ro);
+ break;
case WA_UPLINE:
slid->y_pos = MAX(0, slid->y_pos-1);
- // partial redraw
+ guiwin_update_slider(gw, GUIWIN_VSLIDER);
+ if(!guiwin_has_intersection(gw, NULL)){
+ // blit screen area:
+ g.g_h -= slid->y_unit_px;
+ move_rect(&g, 0, +slid->y_unit_px);
+ g.g_y = g_ro.g_y;
+ g.g_h = slid->y_unit_px;
+ // redraw new content:
+ guiwin_send_redraw(gw, &g);
+ } else {
+ // let the draw implementation handle intersections:
+ guiwin_send_redraw(gw, &g_ro);
+ }
break;
- case WA_DNLINE:
- slid->y_pos = MIN(slid->y_pos_max, slid->y_pos+1);
- g.g_y += slid->y_unit_px;
- g.g_h -= slid->y_unit_px;
- move_screen(v_vdi_h, &g, 0, -slid->y_unit_px);
- g.g_y = g_ro.g_y + g_ro.g_h - slid->y_unit_px;
- g.g_h = slid->y_unit_px;
- guiwin_send_redraw(gw, &g);
- // move content up by unit size and sched redraw for the
- // bottom 16 px
- // partial redraw
+ case WA_DNPAGE:
+ val = g.g_h/slid->y_unit_px;
+ slid->y_pos = MIN(slid->y_pos_max, slid->y_pos+val);
+ guiwin_update_slider(gw, GUIWIN_VSLIDER);
+ guiwin_send_redraw(gw, &g_ro);
break;
- case WA_LFPAGE:
- // complete redraw
- // increase scroll val by page size...
+ case WA_DNLINE:
+ slid->y_pos = MIN(slid->y_pos_max, slid->y_pos+1);
+ guiwin_update_slider(gw, GUIWIN_VSLIDER);
+ if(!guiwin_has_intersection(gw, NULL)){
+ // blit screen area:
+ g.g_y += slid->y_unit_px;
+ g.g_h -= slid->y_unit_px;
+ move_rect(&g, 0, -slid->y_unit_px);
+ g.g_y = g_ro.g_y + g_ro.g_h - slid->y_unit_px;
+ g.g_h = slid->y_unit_px;
+ // redraw new content:
+ guiwin_send_redraw(gw, &g);
+ } else {
+ // let the draw implementation handle intersections:
+ guiwin_send_redraw(gw, &g_ro);
+ }
break;
- case WA_RTPAGE:
- // complete redraw
- // increase scroll val by page size...
+ case WA_LFPAGE:
+ val = g.g_w/slid->x_unit_px;
+ slid->x_pos = MAX(0, slid->x_pos-val);
+ guiwin_update_slider(gw, GUIWIN_HSLIDER);
+ guiwin_send_redraw(gw, &g_ro);
break;
case WA_LFLINE:
slid->x_pos = MAX(0, slid->x_pos-1);
+ guiwin_update_slider(gw, GUIWIN_HSLIDER);
+ if(!guiwin_has_intersection(gw, NULL)){
+ // blit screen area:
+ g.g_x -= slid->x_unit_px;
+ move_rect(&g, 0, +slid->x_unit_px);
+ // redraw new content:
+ g.g_x = g_ro.g_x;
+ g.g_w = slid->x_unit_px;
+ guiwin_send_redraw(gw, &g);
+ } else {
+ // let the draw implementation handle intersections:
+ guiwin_send_redraw(gw, &g_ro);
+ }
// partial redraw
break;
+ case WA_RTPAGE:
+ val = g.g_w/slid->x_unit_px;
+ slid->x_pos = MIN(slid->x_pos_max, slid->x_pos+val);
+ guiwin_update_slider(gw, GUIWIN_HSLIDER);
+ guiwin_send_redraw(gw, &g_ro);
+ break;
+
case WA_RTLINE:
slid->x_pos = MIN(slid->x_pos_max, slid->x_pos+1);
- // partial redraw
+ guiwin_update_slider(gw, GUIWIN_HSLIDER);
+ if(!guiwin_has_intersection(gw, NULL)){
+ // blit remaining area:
+ g.g_x += slid->x_unit_px;
+ g.g_w -= slid->y_unit_px;
+ move_rect(&g, 0, -slid->x_unit_px);
+ // redraw new content:
+ g.g_x = g_ro.g_x + g_ro.g_w - slid->x_unit_px;
+ g.g_h = slid->x_unit_px;
+ guiwin_send_redraw(gw, &g);
+ } else {
+ // let the draw implementation handle intersections:
+ guiwin_send_redraw(gw, &g_ro);
+ }
break;
default:
@@ -127,11 +189,21 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
case WM_REPOSED:
wind_get_grect(gw->handle, WF_CURRXYWH, &g);
wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]);
+ if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) {
+ if(guiwin_update_slider(gw, GUIWIN_VH_SLIDER)){
+ guiwin_send_redraw(gw, NULL);
+ }
+ }
break;
case WM_FULLED:
wind_get_grect(gw->handle, WF_FULLXYWH, &g);
wind_set_grect(gw->handle, WF_CURRXYWH, &g);
+ if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) {
+ if(guiwin_update_slider(gw, GUIWIN_VH_SLIDER)){
+ guiwin_send_redraw(gw, NULL);
+ }
+ }
break;
case WM_ICONIFY:
@@ -157,16 +229,22 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
tb_area = tb_area_ro;
if(rc_intersect((GRECT*)&msg[4], &tb_area)) {
+
+ gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
+ gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
+ gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
+ gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
+
wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
while (g.g_h > 0 || g.g_w > 0) {
- gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
- gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
- gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
- gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
- objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
- g.g_w, g.g_h);
+ if(rc_intersect(&tb_area_ro, &g)) {
+ objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
+ g.g_w, g.g_h);
+
+ }
wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
}
+
}
}
break;
@@ -174,7 +252,9 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
default:
retval = 0;
break;
+
}
+
return(retval);
}
@@ -391,46 +471,59 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
}
}
-void guiwin_update_slider(GUIWIN *win, short mode)
+bool guiwin_update_slider(GUIWIN *win, short mode)
{
GRECT viewport;
struct guiwin_scroll_info_s * slid;
unsigned long size, pos;
+ int old_x, old_y;
short handle = guiwin_get_handle(win);
guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &viewport);
slid = guiwin_get_scroll_info(win);
- if((mode & 1) && (slid->y_unit_px > 0)) {
+ old_x = slid->x_pos;
+ old_y = slid->y_pos;
+
+ if((mode & GUIWIN_VSLIDER) && (slid->y_unit_px > 0)) {
if ( slid->y_pos_max < (long)viewport.g_h/slid->y_unit_px)
size = 1000L;
else
- size = MAX( 50L, (unsigned long)viewport.g_h*1000L/(unsigned long)(slid->y_unit_px*slid->y_pos_max));
+ size = MAX( 50L, (unsigned long)viewport.g_h*1000L/
+ (unsigned long)(slid->y_unit_px*slid->y_pos_max));
wind_set(handle, WF_VSLSIZE, (int)size, 0, 0, 0);
if (slid->y_pos_max > (long)viewport.g_h/slid->y_unit_px) {
- pos = (unsigned long)slid->y_pos *1000L/(unsigned long)(slid->y_pos_max-viewport.g_h/slid->y_unit_px);
+ pos = (unsigned long)slid->y_pos *1000L/
+ (unsigned long)(slid->y_pos_max-viewport.g_h/slid->y_unit_px);
wind_set(handle, WF_VSLIDE, (int)pos, 0, 0, 0);
} else if (slid->y_pos) {
slid->y_pos = 0;
wind_set(handle, WF_VSLIDE, 0, 0, 0, 0);
}
}
- if((mode & 2) && (slid->x_unit_px > 0)) {
+ if((mode & GUIWIN_HSLIDER) && (slid->x_unit_px > 0)) {
if ( slid->x_pos_max < (long)viewport.g_w/slid->x_unit_px)
size = 1000L;
else
- size = MAX( 50L, (unsigned long)viewport.g_w*1000L/(unsigned long)(slid->x_unit_px*slid->x_pos_max));
+ size = MAX( 50L, (unsigned long)viewport.g_w*1000L/
+ (unsigned long)(slid->x_unit_px*slid->x_pos_max));
wind_set(handle, WF_HSLSIZE, (int)size, 0, 0, 0);
if( slid->x_pos_max > (long)viewport.g_w/slid->x_unit_px) {
- pos = (unsigned long)slid->x_pos*1000L/(unsigned long)(slid->x_pos_max-viewport.g_w/slid->x_unit_px);
+ pos = (unsigned long)slid->x_pos*1000L/
+ (unsigned long)(slid->x_pos_max-viewport.g_w/slid->x_unit_px);
wind_set(handle, WF_HSLIDE, (int)pos, 0, 0, 0);
} else if (slid->x_pos) {
slid->x_pos = 0;
wind_set(handle, WF_HSLIDE, 0, 0, 0, 0);
}
}
+
+ if(old_x != slid->x_pos || old_y != slid->y_pos){
+ return(true);
+ }
+ return(false);
}
short guiwin_get_handle(GUIWIN *win)
@@ -467,31 +560,50 @@ void *guiwin_get_user_data(GUIWIN *win)
return(win->user_data);
}
-struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win)
-{
+struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win) {
return(&win->scroll_info);
}
void guiwin_send_redraw(GUIWIN *win, GRECT *area)
{
- short msg[8];
- GRECT work;
+ short msg[8];
+ GRECT work;
- if(area == NULL){
- guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
- area = &work;
- }
+ if(area == NULL) {
+ guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
+ area = &work;
+ }
+
+ msg[0] = WM_REDRAW;
+ msg[1] = gl_apid;
+ msg[2] = 0;
+ msg[3] = win->handle;
+ msg[4] = area->g_x;
+ msg[5] = area->g_y;
+ msg[6] = area->g_w;
+ msg[7] = area->g_h;
- msg[0] = WM_REDRAW;
- msg[1] = gl_apid;
- msg[2] = 0;
- msg[3] = win->handle;
- msg[4] = area->g_x;
- msg[5] = area->g_y;
- msg[6] = area->g_w;
- msg[7] = area->g_h;
+ appl_write(gl_apid, 16, &msg);
+}
- appl_write(gl_apid, 16, &msg);
+bool guiwin_has_intersection(GUIWIN *win, GRECT *work)
+{
+ GRECT area, mywork;
+ bool retval = false;
+
+ if (work == NULL) {
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &mywork);
+ work = &mywork;
+ }
+
+ wind_get_grect(win->handle, WF_FIRSTXYWH, &area);
+ while (area.g_w && area.g_w) {
+ if (rc_intersect(work, &area)) {
+ retval = true;
+ }
+ wind_get_grect(win->handle, WF_NEXTXYWH, &area);
+ }
+ return(retval);
}
/*
void guiwin_exec_redraw(){
diff --git a/atari/gemtk/guiwin.h b/atari/gemtk/guiwin.h
index dba112c..6daf16c 100644
--- a/atari/gemtk/guiwin.h
+++ b/atari/gemtk/guiwin.h
@@ -1,5 +1,4 @@
#ifndef OPKG_GUI_GUIWIN_H
-#define OPKG_GUI_GUIWIN_H
-
+#define OPKG_GUI_GUIWIN_
#endif /* OPKG_GUIWIN_H */
diff --git a/atari/res/netsurf.rsc b/atari/res/netsurf.rsc
index a8a8b80..5a9327f 100755
Binary files a/atari/res/netsurf.rsc and b/atari/res/netsurf.rsc differ
diff --git a/atari/res/netsurf.rsh b/atari/res/netsurf.rsh
index 7b422ef..b0c800d 100755
--- a/atari/res/netsurf.rsh
+++ b/atari/res/netsurf.rsh
@@ -198,9 +198,7 @@
#define CHOICES_ABORT 108 /* BUTTON in tree CHOICES */
#define CHOICES_OK 109 /* BUTTON in tree CHOICES */
-#define ALERT 14 /* form/dial */
-
-#define VSCROLLER 15 /* form/dial */
+#define VSCROLLER 14 /* form/dial */
#define VSCROLLER_AREA 1 /* BOX in tree VSCROLLER */
#define VSCROLLER_SLIDER_AREA 2 /* BUTTON in tree VSCROLLER */
#define VSCROLLER_SLIDER 3 /* BUTTON in tree VSCROLLER */
diff --git a/atari/res/netsurf.rsm b/atari/res/netsurf.rsm
index 6996aea..ade2b1c 100755
--- a/atari/res/netsurf.rsm
+++ b/atari/res/netsurf.rsm
@@ -1,9 +1,9 @@
ResourceMaster v3.65
-#C 16@0@0@0@
+#C 15@0@0@0@
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
-#M 20010100@0@7728@606@
+#M 20010100@0@7728@610@
#T 0@1@MAINMENU@@62@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@@ -187,8 +187,7 @@ ResourceMaster v3.65
#O 107@26@CB_BG_IMAGES@@
#O 108@26@ABORT@@
#O 109@26@OK@@
-#T 14@2@ALERT@@1@@
-#T 15@2@VSCROLLER@@8@@
+#T 14@2@VSCROLLER@@8@@
#O 1@20@AREA@@
#O 2@26@SLIDER_AREA@@
#O 3@26@SLIDER@@
@@ -196,4 +195,4 @@ ResourceMaster v3.65
#O 5@33@BT_DOWN_PIC@@
#O 6@25@BT_UP@@
#O 4@33@BT_UP_PIC@@
-#c 9608@
+#c 2361@
diff --git a/atari/treeview.c b/atari/treeview.c
index 4cddea4..44a8630 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -1,68 +1,68 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "desktop/plotters.h"
-#include "desktop/textinput.h"
-#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
-#include "desktop/textinput.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "atari/gui.h"
-#include "atari/treeview.h"
-#include "atari/plot/plot.h"
+/*
+ * Copyright 2010 Ole Loots <ole(a)monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "content/urldb.h"
+#include "desktop/browser.h"
+#include "desktop/plotters.h"
+#include "desktop/textinput.h"
+#include "desktop/tree.h"
+#include "desktop/tree_url_node.h"
+#include "desktop/textinput.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "atari/gui.h"
+#include "atari/treeview.h"
+#include "atari/plot/plot.h"
#include "atari/misc.h"
-#include "atari/gemtk/gemtk.h"
+#include "atari/gemtk/gemtk.h"
#include "cflib.h"
enum treeview_area_e {
TREEVIEW_AREA_WORK = 0,
TREEVIEW_AREA_TOOLBAR,
TREEVIEW_AREA_CONTENT
-};
-
-extern int mouse_hold_start[3];
-extern browser_mouse_state bmstate;
-extern short last_drag_x;
-extern short last_drag_y;
+};
+
+extern int mouse_hold_start[3];
+extern browser_mouse_state bmstate;
+extern short last_drag_x;
+extern short last_drag_y;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
-
-static void atari_treeview_resized(struct tree *tree,int w,int h, void *pw);
-static void atari_treeview_scroll_visible(int y, int h, void *pw);
+
+static void atari_treeview_resized(struct tree *tree,int w,int h, void *pw);
+static void atari_treeview_scroll_visible(int y, int h, void *pw);
static void atari_treeview_get_dimensions(int *width, int *height, void *pw);
static void atari_treeview_get_grect(NSTREEVIEW tree,
- enum treeview_area_e mode, GRECT *dest);
-
-static const struct treeview_table atari_tree_callbacks = {
- atari_treeview_request_redraw,
- atari_treeview_resized,
- atari_treeview_scroll_visible,
- atari_treeview_get_dimensions
+ enum treeview_area_e mode, GRECT *dest);
+
+static const struct treeview_table atari_tree_callbacks = {
+ atari_treeview_request_redraw,
+ atari_treeview_resized,
+ atari_treeview_scroll_visible,
+ atari_treeview_get_dimensions
};
static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
@@ -79,7 +79,6 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
// handle message
- printf("treeview msg: %d\n", msg[0]);
switch (msg[0]) {
case WM_REDRAW:
@@ -88,7 +87,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
case WM_SIZED:
case WM_FULLED:
- guiwin_update_slider(win, 3);
+ //atari_treeview_resized(tv->tree, tv->extent.x, tv->extent.y, tv);
break;
default:
@@ -116,384 +115,390 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
return(0);
-}
-
+}
+
static void __CDECL on_keybd_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
- short msg[8])
-{
- bool r=false;
- long kstate = 0;
- long kcode = 0;
- long ucs4;
- long ik;
- unsigned short nkc = 0;
- unsigned short nks = 0;
- unsigned char ascii;
-
- kstate = ev_out->emo_kmeta;
- kcode = ev_out->emo_kreturn;
- nkc= gem_to_norm( (short)kstate, (short)kcode );
- ascii = (nkc & 0xFF);
- ik = nkc_to_input_key( nkc, &ucs4 );
-
- if( ik == 0 ){
- if (ascii >= 9 ) {
- r = tree_keypress( tv->tree, ucs4 );
- }
- } else {
- r = tree_keypress( tv->tree, ik );
- }
-}
-
-
+ short msg[8])
+{
+ bool r=false;
+ long kstate = 0;
+ long kcode = 0;
+ long ucs4;
+ long ik;
+ unsigned short nkc = 0;
+ unsigned short nks = 0;
+ unsigned char ascii;
+
+ kstate = ev_out->emo_kmeta;
+ kcode = ev_out->emo_kreturn;
+ nkc= gem_to_norm( (short)kstate, (short)kcode );
+ ascii = (nkc & 0xFF);
+ ik = nkc_to_input_key( nkc, &ucs4 );
+
+ if( ik == 0 ){
+ if (ascii >= 9 ) {
+ r = tree_keypress( tv->tree, ucs4 );
+ }
+ } else {
+ r = tree_keypress( tv->tree, ik );
+ }
+}
+
+
static void __CDECL on_redraw_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
- short msg[8])
-{
- GRECT work, clip;
+ short msg[8])
+{
+ GRECT work, clip;
+ struct guiwin_scroll_info_s *slid;
- if( tv == NULL )
- return;
+ if( tv == NULL )
+ return;
guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
-
- clip = work;
- if ( !rc_intersect( (GRECT*)&msg[4], &clip ) ) return;
- clip.g_x -= work.g_x;
- clip.g_y -= work.g_y;
- if( clip.g_x < 0 ) {
- clip.g_w = work.g_w + clip.g_x;
- clip.g_x = 0;
- }
- if( clip.g_y < 0 ) {
- clip.g_h = work.g_h + clip.g_y;
- clip.g_y = 0;
- }
+ slid = guiwin_get_scroll_info(tv->window);
+
+ clip = work;
+ if ( !rc_intersect( (GRECT*)&msg[4], &clip ) ) return;
+ clip.g_x -= work.g_x;
+ clip.g_y -= work.g_y;
+ if( clip.g_x < 0 ) {
+ clip.g_w = work.g_w + clip.g_x;
+ clip.g_x = 0;
+ }
+ if( clip.g_y < 0 ) {
+ clip.g_h = work.g_h + clip.g_y;
+ clip.g_y = 0;
+ }
if( clip.g_h > 0 && clip.g_w > 0 ) {
- // TODO: get slider values
- atari_treeview_request_redraw(
- /*win->xpos*win->w_u +*/ clip.g_x,
- /*win->ypos*win->h_u +*/ clip.g_y,
- clip.g_w, clip.g_h, tv
- );
- }
-}
-
+ // TODO: get slider values
+ atari_treeview_request_redraw((slid->x_pos*slid->x_unit_px) + clip.g_x,
+ (slid->y_pos*slid->y_unit_px) + clip.g_y,
+ clip.g_w, clip.g_h, tv
+ );
+ }
+}
+
static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
- short msg[8])
-{
- GRECT work;
- if(tv == NULL)
- return;
- if( evnt.mbut & 2 ) {
- /* do not handle right click */
- return;
+ short msg[8])
+{
+ struct guiwin_scroll_info_s *slid;
+ GRECT work;
+
+ if(tv == NULL)
+ return;
+ if( evnt.mbut & 2 ) {
+ /* do not handle right click */
+ return;
}
- guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
-
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+ slid = guiwin_get_scroll_info(tv->window);
+
/* mouse click relative origin: */
-
- // TODO: get scroll position
- //short origin_rel_x = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
- //short origin_rel_y = (evnt.my-work.g_y)+(win->ypos*win->h_u);
-
- short origin_rel_x = (ev_out->emo_mouse.p_x-work.g_x);
- short origin_rel_y = (ev_out->emo_mouse.p_y-work.g_y);
-
- if( origin_rel_x >= 0 && origin_rel_y >= 0
- && evnt.mx < work.g_x + work.g_w
- && evnt.my < work.g_y + work.g_h )
- {
- int bms;
- bool ignore=false;
- short cur_rel_x, cur_rel_y, dummy, mbut;
-
- if( evnt.nb_click == 2 ){
- tree_mouse_action(tv->tree,
- BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DOUBLE_CLICK,
- origin_rel_x, origin_rel_y );
- return;
- }
-
- graf_mkstate(&cur_rel_x, &cur_rel_x, &mbut, &dummy);
- if( (mbut&1) == 0 ){
- bms = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1;
- if( evnt.nb_click == 2 ) {
- bms = BROWSER_MOUSE_DOUBLE_CLICK;
- }
- tree_mouse_action(tv->tree, bms, origin_rel_x, origin_rel_y );
- } else {
- /* button still pressed */
-
- short prev_x = origin_rel_x;
- short prev_y = origin_rel_y;
-
- cur_rel_x = origin_rel_x;
- cur_rel_y = origin_rel_y;
-
- if( tree_is_edited(tv->tree) ){
- gem_set_cursor(&gem_cursors.ibeam);
- } else {
- gem_set_cursor(&gem_cursors.hand);
- }
-
- tv->startdrag.x = origin_rel_x;
- tv->startdrag.y = origin_rel_y;
-
- tree_mouse_action( tv->tree,
- BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON ,
- cur_rel_x, cur_rel_y );
- do{
- if( abs(prev_x-cur_rel_x) > 5 || abs(prev_y-cur_rel_y) > 5 ){
- tree_mouse_action( tv->tree,
- BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON,
- cur_rel_x, cur_rel_y);
- prev_x = cur_rel_x;
- prev_y = cur_rel_y;
- }
-
- if( tv->redraw )
- atari_treeview_redraw( tv );
- /* sample mouse button state: */
+
+ short origin_rel_x = (ev_out->emo_mouse.p_x-work.g_x) +
+ (slid->x_pos*slid->x_unit_px);
+ short origin_rel_y = (ev_out->emo_mouse.p_y-work.g_y) +
+ (slid->y_pos*slid->y_unit_px);
+
+ if( origin_rel_x >= 0 && origin_rel_y >= 0
+ && evnt.mx < work.g_x + work.g_w
+ && evnt.my < work.g_y + work.g_h )
+ {
+ int bms;
+ bool ignore=false;
+ short cur_rel_x, cur_rel_y, dummy, mbut;
+
+ if( evnt.nb_click == 2 ){
+ tree_mouse_action(tv->tree,
+ BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DOUBLE_CLICK,
+ origin_rel_x, origin_rel_y );
+ return;
+ }
+
+ graf_mkstate(&cur_rel_x, &cur_rel_x, &mbut, &dummy);
+ if( (mbut&1) == 0 ){
+ bms = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1;
+ if( evnt.nb_click == 2 ) {
+ bms = BROWSER_MOUSE_DOUBLE_CLICK;
+ }
+ tree_mouse_action(tv->tree, bms, origin_rel_x, origin_rel_y );
+ } else {
+ /* button still pressed */
+
+ short prev_x = origin_rel_x;
+ short prev_y = origin_rel_y;
+
+ cur_rel_x = origin_rel_x;
+ cur_rel_y = origin_rel_y;
+
+ if( tree_is_edited(tv->tree) ){
+ gem_set_cursor(&gem_cursors.ibeam);
+ } else {
+ gem_set_cursor(&gem_cursors.hand);
+ }
+
+ tv->startdrag.x = origin_rel_x;
+ tv->startdrag.y = origin_rel_y;
+
+ tree_mouse_action( tv->tree,
+ BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON ,
+ cur_rel_x, cur_rel_y );
+ do{
+ if( abs(prev_x-cur_rel_x) > 5 || abs(prev_y-cur_rel_y) > 5 ){
+ tree_mouse_action( tv->tree,
+ BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON,
+ cur_rel_x, cur_rel_y);
+ prev_x = cur_rel_x;
+ prev_y = cur_rel_y;
+ }
+
+ if( tv->redraw )
+ atari_treeview_redraw( tv );
+ /* sample mouse button state: */
graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy);
- // TODO : get guwin slider values;
- cur_rel_x = (cur_rel_x-work.g_x)/*+(win->xpos*win->w_u);*/;
- cur_rel_y = (cur_rel_y-work.g_y)/*+(win->ypos*win->h_u);*/;
- } while( mbut & 1 );
-
- tree_drag_end(tv->tree, 0, tv->startdrag.x, tv->startdrag.y,
- cur_rel_x, cur_rel_y );
- gem_set_cursor(&gem_cursors.arrow);
- }
- }
-}
-
+ cur_rel_x = (cur_rel_x-work.g_x)+(slid->x_pos*slid->x_unit_px);
+ cur_rel_y = (cur_rel_y-work.g_y)+(slid->y_pos*slid->y_unit_px);
+ } while( mbut & 1 );
+
+ tree_drag_end(tv->tree, 0, tv->startdrag.x, tv->startdrag.y,
+ cur_rel_x, cur_rel_y );
+ gem_set_cursor(&gem_cursors.arrow);
+ }
+ }
+}
+
NSTREEVIEW atari_treeview_create(uint32_t flags, GUIWIN *win,
- guiwin_event_handler_f user_func)
+ guiwin_event_handler_f user_func)
{
struct guiwin_scroll_info_s *slid;
-
- if( win == NULL )
- return( NULL );
- NSTREEVIEW new = malloc(sizeof(struct atari_treeview));
- if (new == NULL)
- return NULL;
- memset( new, 0, sizeof(struct atari_treeview));
- new->tree = tree_create(flags, &atari_tree_callbacks, new);
- if (new->tree == NULL) {
- free(new);
- return NULL;
- }
+
+ if( win == NULL )
+ return( NULL );
+ NSTREEVIEW new = malloc(sizeof(struct atari_treeview));
+ if (new == NULL)
+ return NULL;
+ memset( new, 0, sizeof(struct atari_treeview));
+ new->tree = tree_create(flags, &atari_tree_callbacks, new);
+ if (new->tree == NULL) {
+ free(new);
+ return NULL;
+ }
new->window = win;
new->user_func = user_func;
guiwin_set_event_handler(win, handle_event);
guiwin_set_user_data(win, (void*)new);
-
+
slid = guiwin_get_scroll_info(new->window);
slid->y_unit_px = 16;
- slid->x_unit_px = 16;
-
- return(new);
-}
-
-void atari_treeview_open( NSTREEVIEW tv )
-{
- if( tv->window != NULL ) {
- tree_set_redraw(tv->tree, true);
- }
-}
-
-void atari_treeview_close( NSTREEVIEW tv )
-{
- if( tv->window != NULL ) {
- tree_set_redraw(tv->tree, false);
- }
-}
-
-void atari_treeview_destroy( NSTREEVIEW tv )
-{
- if( tv != NULL ){
- tv->disposing = true;
- LOG(("tree: %p", tv));
- if( tv->tree != NULL ) {
- tree_delete(tv->tree);
- tv->tree = NULL;
- }
- free( tv );
- }
-}
-
-bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
-{
+ slid->x_unit_px = 16;
+
+ return(new);
+}
+
+void atari_treeview_open( NSTREEVIEW tv )
+{
+ if( tv->window != NULL ) {
+ tree_set_redraw(tv->tree, true);
+ }
+}
+
+void atari_treeview_close( NSTREEVIEW tv )
+{
+ if( tv->window != NULL ) {
+ tree_set_redraw(tv->tree, false);
+ }
+}
+
+void atari_treeview_destroy( NSTREEVIEW tv )
+{
+ if( tv != NULL ){
+ tv->disposing = true;
+ LOG(("tree: %p", tv));
+ if( tv->tree != NULL ) {
+ tree_delete(tv->tree);
+ tv->tree = NULL;
+ }
+ free( tv );
+ }
+}
+
+bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
+{
GRECT work;
struct guiwin_scroll_info_s *slid;
- if( tv == NULL )
- return ( false );
-
+ if( tv == NULL )
+ return ( false );
+
guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
slid = guiwin_get_scroll_info(tv->window);
-
- int rx = (x-work.g_x)+(slid->x_pos*slid->x_unit_px);
+
+ int rx = (x-work.g_x)+(slid->x_pos*slid->x_unit_px);
int ry = (y-work.g_y)+(slid->y_pos*slid->y_unit_px);
tree_mouse_action(tv->tree, bms, rx, ry);
-
- tv->click.x = rx;
- tv->click.y = ry;
-
- return( true );
-}
-
-
-
-void atari_treeview_redraw( NSTREEVIEW tv)
+
+ tv->click.x = rx;
+ tv->click.y = ry;
+
+ return( true );
+}
+
+
+
+void atari_treeview_redraw( NSTREEVIEW tv)
{
-
- if (tv != NULL) {
- if( tv->redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
+ if (tv != NULL) {
+ if( tv->redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
- short todo[4];
+ short todo[4];
GRECT work;
short handle = guiwin_get_handle(tv->window);
- struct guiwin_scroll_info_s *slid;
+ struct guiwin_scroll_info_s *slid;
- guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
slid = guiwin_get_scroll_info(tv->window);
-
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &atari_plotters
- };
- plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h);
- if (plot_lock() == false)
- return;
-
- todo[0] = work.g_x;
- todo[1] = work.g_y;
- todo[2] = todo[0] + work.g_w-1;
- todo[3] = todo[1] + work.g_h-1;
- vs_clip(atari_plot_vdi_handle, 1, (short*)&todo );
-
- if( wind_get(handle, WF_FIRSTXYWH,
- &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
- while (todo[2] && todo[3]) {
-
+
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &atari_plotters
+ };
+ plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h);
+ if (plot_lock() == false)
+ return;
+
+ if( wind_get(handle, WF_FIRSTXYWH,
+ &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
+ while (todo[2] && todo[3]) {
+
+ short pxy[4];
+ pxy[0] = todo[0];
+ pxy[1] = todo[1];
+ pxy[2] = todo[0] + todo[2]-1;
+ pxy[3] = todo[1] + todo[3]-1;
+ vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy);
+
/* convert screen to treeview coords: */
- // TODO: get slider values:
- todo[0] = todo[0] - work.g_x + slid->x_pos*slid->x_unit_px;
- todo[1] = todo[1] - work.g_y + slid->y_pos*slid->y_unit_px;
- if( todo[0] < 0 ){
- todo[2] = todo[2] + todo[0];
- todo[0] = 0;
- }
- if( todo[1] < 0 ){
- todo[3] = todo[3] + todo[1];
- todo[1] = 0;
- }
+ todo[0] = todo[0] - work.g_x + slid->x_pos*slid->x_unit_px;
+ todo[1] = todo[1] - work.g_y + slid->y_pos*slid->y_unit_px;
+ if( todo[0] < 0 ){
+ todo[2] = todo[2] + todo[0];
+ todo[0] = 0;
+ }
+ if( todo[1] < 0 ){
+ todo[3] = todo[3] + todo[1];
+ todo[1] = 0;
+ }
// TODO: get slider values
- if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
+ if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
tree_draw(tv->tree, -(slid->x_pos*slid->x_unit_px),
- -(slid->y_pos*slid->y_unit_px),
- todo[0], todo[1], todo[2], todo[3], &ctx
- );
- }
- if (wind_get(handle, WF_NEXTXYWH,
- &todo[0], &todo[1], &todo[2], &todo[3])==0) {
- break;
- }
- }
- } else {
- plot_unlock();
- return;
- }
- plot_unlock();
- vs_clip(atari_plot_vdi_handle, 0, (short*)&todo);
- tv->redraw = false;
- tv->rdw_area.g_x = 65000;
- tv->rdw_area.g_y = 65000;
- tv->rdw_area.g_w = -1;
- tv->rdw_area.g_h = -1;
- } else {
- /* just copy stuff from the offscreen buffer */
- }
- }
-}
-
-
-/**
- * Callback to force a redraw of part of the treeview window.
- *
- * \param x Min X Coordinate of area to be redrawn.
- * \param y Min Y Coordinate of area to be redrawn.
- * \param width Width of area to be redrawn.
- * \param height Height of area to be redrawn.
- * \param pw The treeview object to be redrawn.
- */
-void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
-{
- if ( pw != NULL ) {
- NSTREEVIEW tv = (NSTREEVIEW) pw;
- if( tv->redraw == false ){
- tv->redraw = true;
- tv->rdw_area.g_x = x;
- tv->rdw_area.g_y = y;
- tv->rdw_area.g_w = w;
- tv->rdw_area.g_h = h;
- } else {
- /* merge the redraw area to the new area.: */
- int newx1 = x+w;
- int newy1 = y+h;
- int oldx1 = tv->rdw_area.g_x + tv->rdw_area.g_w;
- int oldy1 = tv->rdw_area.g_y + tv->rdw_area.g_h;
- tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, x);
- tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, y);
- tv->rdw_area.g_w = ( oldx1 > newx1 ) ? oldx1 - tv->rdw_area.g_x : newx1 - tv->rdw_area.g_x;
- tv->rdw_area.g_h = ( oldy1 > newy1 ) ? oldy1 - tv->rdw_area.g_y : newy1 - tv->rdw_area.g_y;
- }
- }
-}
-
-
-/**
- * Callback to notify us of a new overall tree size.
- *
- * \param tree The tree being resized.
- * \param width The new width of the window.
- * \param height The new height of the window.
- * \param *pw The treeview object to be resized.
- */
-
-void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
-{
- if (pw != NULL) {
- NSTREEVIEW tv = (NSTREEVIEW) pw;
- if( tv->disposing )
- return;
- // TODO: update slider size
+ -(slid->y_pos*slid->y_unit_px),
+ todo[0], todo[1], todo[2], todo[3], &ctx
+ );
+ }
+ vs_clip(atari_plot_vdi_handle, 0, (short*)&pxy);
+ if (wind_get(handle, WF_NEXTXYWH,
+ &todo[0], &todo[1], &todo[2], &todo[3])==0) {
+ break;
+ }
+ }
+ } else {
+ plot_unlock();
+ return;
+ }
+ plot_unlock();
+ tv->redraw = false;
+ tv->rdw_area.g_x = 65000;
+ tv->rdw_area.g_y = 65000;
+ tv->rdw_area.g_w = -1;
+ tv->rdw_area.g_h = -1;
+ } else {
+ /* just copy stuff from the offscreen buffer */
+ }
+ }
+}
+
+
+/**
+ * Callback to force a redraw of part of the treeview window.
+ *
+ * \param x Min X Coordinate of area to be redrawn.
+ * \param y Min Y Coordinate of area to be redrawn.
+ * \param width Width of area to be redrawn.
+ * \param height Height of area to be redrawn.
+ * \param pw The treeview object to be redrawn.
+ */
+void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
+{
+ if ( pw != NULL ) {
+ NSTREEVIEW tv = (NSTREEVIEW) pw;
+ if( tv->redraw == false ){
+ tv->redraw = true;
+ tv->rdw_area.g_x = x;
+ tv->rdw_area.g_y = y;
+ tv->rdw_area.g_w = w;
+ tv->rdw_area.g_h = h;
+ } else {
+ /* merge the redraw area to the new area.: */
+ int newx1 = x+w;
+ int newy1 = y+h;
+ int oldx1 = tv->rdw_area.g_x + tv->rdw_area.g_w;
+ int oldy1 = tv->rdw_area.g_y + tv->rdw_area.g_h;
+ tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, x);
+ tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, y);
+ tv->rdw_area.g_w = ( oldx1 > newx1 ) ? oldx1 - tv->rdw_area.g_x : newx1 - tv->rdw_area.g_x;
+ tv->rdw_area.g_h = ( oldy1 > newy1 ) ? oldy1 - tv->rdw_area.g_y : newy1 - tv->rdw_area.g_y;
+ }
+ dbg_grect("atari_treeview_request_redraw", &tv->rdw_area);
+ }
+}
+
+
+/**
+ * Callback to notify us of a new overall tree size.
+ *
+ * \param tree The tree being resized.
+ * \param width The new width of the window.
+ * \param height The new height of the window.
+ * \param *pw The treeview object to be resized.
+ */
+
+void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
+{
+ GRECT area;
+ if (pw != NULL) {
+ NSTREEVIEW tv = (NSTREEVIEW) pw;
+ if( tv->disposing )
+ return;
+ tv->extent.x = width;
+ tv->extent.y = height;
struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(tv->window);
- slid->x_pos_max = (width / slid->x_unit_px);
- slid->y_pos_max = (height / slid->y_unit_px);
- guiwin_update_slider(tv->window, 3);
- }
-}
-
-
-/**
- * Callback to request that a section of the tree is scrolled into view.
- *
- * \param y The Y coordinate of top of the area in NS units.
- * \param height The height of the area in NS units.
- * \param *pw The treeview object affected.
- */
-
-void atari_treeview_scroll_visible(int y, int height, void *pw)
-{
- /* we don't support dragging outside the treeview */
- /* so we don't need to implement this? */
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &area);
+ slid->x_pos_max = (width/slid->x_unit_px);//-(area.g_w/slid->x_unit_px)+1;
+ slid->y_pos_max = (height/slid->y_unit_px);//-(area.g_h/slid->y_unit_px)+1;
+ printf("units content: %d, units viewport: %d\n", (height/slid->y_unit_px),
+ (area.g_h/slid->y_unit_px));
+ guiwin_update_slider(tv->window, GUIWIN_VH_SLIDER);
+ }
+}
+
+
+/**
+ * Callback to request that a section of the tree is scrolled into view.
+ *
+ * \param y The Y coordinate of top of the area in NS units.
+ * \param height The height of the area in NS units.
+ * \param *pw The treeview object affected.
+ */
+
+void atari_treeview_scroll_visible(int y, int height, void *pw)
+{
+ /* we don't support dragging outside the treeview */
+ /* so we don't need to implement this? */
}
static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode,
@@ -506,44 +511,44 @@ static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode,
else if (mode == TREEVIEW_AREA_TOOLBAR) {
guiwin_get_grect(tv->window, GUIWIN_AREA_TOOLBAR, dest);
}
-}
-
-/**
- * Callback to return the tree window dimensions to the treeview system.
- *
- * \param *width Return the window width.
- * \param *height Return the window height.
- * \param *pw The treeview object to use.
- */
-
-void atari_treeview_get_dimensions(int *width, int *height,
- void *pw)
-{
- if (pw != NULL && (width != NULL || height != NULL)) {
- NSTREEVIEW tv = (NSTREEVIEW) pw;
+}
+
+/**
+ * Callback to return the tree window dimensions to the treeview system.
+ *
+ * \param *width Return the window width.
+ * \param *height Return the window height.
+ * \param *pw The treeview object to use.
+ */
+
+void atari_treeview_get_dimensions(int *width, int *height,
+ void *pw)
+{
+ if (pw != NULL && (width != NULL || height != NULL)) {
+ NSTREEVIEW tv = (NSTREEVIEW) pw;
GRECT work;
- atari_treeview_get_grect(tv, TREEVIEW_AREA_CONTENT, &work);
- *width = work.g_w;
- *height = work.g_h;
- }
-}
-
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- strcpy( buffer, "content.png" );
- break;
- }
-}
+ atari_treeview_get_grect(tv, TREEVIEW_AREA_CONTENT, &work);
+ *width = work.g_w;
+ *height = work.g_h;
+ }
+}
+
+
+/**
+ * Translates a content_type to the name of a respective icon
+ *
+ * \param content_type content type
+ * \param buffer buffer for the icon name
+ */
+void tree_icon_name_from_content_type(char *buffer, content_type type)
+{
+ switch (type) {
+ case CONTENT_HTML:
+ case CONTENT_TEXTPLAIN:
+ case CONTENT_CSS:
+ case CONTENT_IMAGE:
+ default:
+ strcpy( buffer, "content.png" );
+ break;
+ }
+}
-----------------------------------------------------------------------
Summary of changes:
atari/gemtk/gemtk.h | 72 +++--
atari/gemtk/guiwin.c | 258 +++++++++++----
atari/gemtk/guiwin.h | 3 +-
atari/res/netsurf.rsc | Bin 35768 -> 35740 bytes
atari/res/netsurf.rsh | 4 +-
atari/res/netsurf.rsm | 9 +-
atari/treeview.c | 873 +++++++++++++++++++++++++------------------------
7 files changed, 669 insertions(+), 550 deletions(-)
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index 4128715..5184451 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -1,22 +1,23 @@
-#ifndef GEMTK_H_INCLUDED
-#define GEMTK_H_INCLUDED
+#ifndef GEMTK_H_INCLUDED
+#define GEMTK_H_INCLUDED
#include <gem.h>
#include <mint/osbind.h>
#include <mint/cookie.h>
-#include <stdint.h>
-
-/* System type detection added by [GS] */
+#include <stdint.h>
+#include <stdbool.h>
+
+/* System type detection added by [GS] */
/* detect the system type, AES + kernel */
-#define SYS_TOS 0x0001
-#define SYS_MAGIC 0x0002
-#define SYS_MINT 0x0004
-#define SYS_GENEVA 0x0010
-#define SYS_NAES 0x0020
-#define SYS_XAAES 0x0040
-#define sys_type() (_systype_v ? _systype_v : _systype())
-#define sys_MAGIC() ((sys_type() & SYS_MAGIC) != 0)
-#define sys_NAES() ((sys_type() & SYS_NAES) != 0)
+#define SYS_TOS 0x0001
+#define SYS_MAGIC 0x0002
+#define SYS_MINT 0x0004
+#define SYS_GENEVA 0x0010
+#define SYS_NAES 0x0020
+#define SYS_XAAES 0x0040
+#define sys_type() (_systype_v ? _systype_v : _systype())
+#define sys_MAGIC() ((sys_type() & SYS_MAGIC) != 0)
+#define sys_NAES() ((sys_type() & SYS_NAES) != 0)
#define sys_XAAES() ((sys_type() & SYS_XAAES) != 0)
#define TOS4VER 0x03300 /* this is assumed to be the last single tasking OS */
@@ -29,20 +30,20 @@ extern unsigned short _systype_v;
unsigned short _systype (void);
OBJECT *get_tree( int idx );
-/*
-* MultiTOS Drag&Drop
-*/
-short ddcreate(short *pipe);
-short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename);
-short ddrexts(short fd, char *exts);
-short ddstry(short fd, char *ext, char *text, char *name, long size);
-void ddclose(short fd);
-void ddgetsig(long *oldsig);
-void ddsetsig(long oldsig);
-short ddopen(short ddnam, char ddmsg);
-short ddsexts(short fd, char *exts);
-short ddrtry(short fd, char *name, char *file, char *whichext, long *size);
-short ddreply(short fd, char ack);
+/*
+* MultiTOS Drag&Drop
+*/
+short ddcreate(short *pipe);
+short ddmessage(short apid, short fd, short winid, short mx, short my, short kstate, short pipename);
+short ddrexts(short fd, char *exts);
+short ddstry(short fd, char *ext, char *text, char *name, long size);
+void ddclose(short fd);
+void ddgetsig(long *oldsig);
+void ddsetsig(long oldsig);
+short ddopen(short ddnam, char ddmsg);
+short ddsexts(short fd, char *exts);
+short ddrtry(short fd, char *name, char *file, char *whichext, long *size);
+short ddreply(short fd, char ack);
/*
Message box
@@ -61,8 +62,12 @@ short msg_box_show(short type, const char * msg);
#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
#define GW_FLAG_CUSTOM_SCROLLING 0x10 // no internal scroller handling
-#define GW_STATUS_ICONIFIED 0x01
-#define GW_STATUS_SHADED 0x02
+#define GW_STATUS_ICONIFIED 0x01
+#define GW_STATUS_SHADED 0x02
+
+#define GUIWIN_VSLIDER 0x01
+#define GUIWIN_HSLIDER 0x02
+#define GUIWIN_VH_SLIDER 0x03
struct gui_window_s;
typedef struct gui_window_s GUIWIN;
@@ -101,9 +106,10 @@ void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb);
void guiwin_set_user_data(GUIWIN *win, void *data);
void *guiwin_get_user_data(GUIWIN *win);
struct guiwin_scroll_info_s * guiwin_get_scroll_info(GUIWIN *win);
-void guiwin_update_slider(GUIWIN *win, short mode);
+bool guiwin_update_slider(GUIWIN *win, short mode);
void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
+bool guiwin_has_intersection(GUIWIN *win, GRECT *work);
@@ -123,5 +129,5 @@ VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
#ifndef MIN
#define MIN(_a,_b) ((_a<_b) ? _a : _b)
#endif
-
-#endif // GEMTK_H_INCLUDED
+
+#endif // GEMTK_H_INCLUDED
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index e055aba..026b18c 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -8,7 +8,7 @@
#include <mt_gem.h>
#include "gemtk.h"
-//#define DEBUG_PRINT(x) printf x
+//#define DEBUG_PRINT(x) printf x
#define DEBUG_PRINT(x)
struct gui_window_s {
@@ -27,30 +27,37 @@ static GUIWIN * winlist;
static VdiHdl v_vdi_h = -1;
static short work_out[57];
-static void move_screen( int vhandle, GRECT *screen, int dx, int dy) {
- INT16 xy[ 8];
- long dum = 0L;
- GRECT g;
-
- /* get intersection with screen area */
- wind_get_grect(0, WF_CURRXYWH, &g);
- rc_intersect(&g, screen);
- xy[ 0] = screen -> g_x;
- xy[ 1] = screen -> g_y;
- xy[ 2] = xy[ 0] + screen -> g_w - 1;
- xy[ 3] = xy[ 1] + screen -> g_h - 1;
- xy[ 4] = xy[ 0] + dx;
- xy[ 5] = xy[ 1] + dy;
- xy[ 6] = xy[ 2] + dx;
- xy[ 7] = xy[ 3] + dy;
- vro_cpyfm( vhandle, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
+static void move_rect(GRECT *rect, int dx, int dy)
+{
+ INT16 xy[ 8];
+ long dum = 0L;
+ GRECT g;
+
+ while( !wind_update(BEG_UPDATE));
+ graf_mouse(M_OFF, 0L);
+
+ /* get intersection with screen area */
+ wind_get_grect(0, WF_CURRXYWH, &g);
+ rc_intersect(&g, rect);
+ xy[0] = rect->g_x;
+ xy[1] = rect->g_y;
+ xy[2] = xy[0] + rect->g_w-1;
+ xy[3] = xy[1] + rect->g_h-1;
+ xy[4] = xy[0] + dx;
+ xy[5] = xy[1] + dy;
+ xy[6] = xy[2] + dx;
+ xy[7] = xy[3] + dy;
+ vro_cpyfm(v_vdi_h, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
+
+ graf_mouse(M_ON, 0L);
+ wind_update(END_UPDATE);
}
static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
GRECT g, g_ro, tb_area, tb_area_ro;
short retval = 1;
- int val;
+ int val = 1;
struct guiwin_scroll_info_s *slid;
switch(msg[0]) {
@@ -63,49 +70,104 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
g_ro = g;
switch(msg[4]) {
- case WA_DNPAGE:
- val = g.g_h;
- // complete redraw
- // increase scroll val by page size...
- break;
+ case WA_UPPAGE:
+ val = g.g_h/slid->y_unit_px;
+ slid->y_pos = MAX(0, slid->y_pos-val);
+ guiwin_update_slider(gw, GUIWIN_VSLIDER);
+ guiwin_send_redraw(gw, &g_ro);
+ break;
case WA_UPLINE:
slid->y_pos = MAX(0, slid->y_pos-1);
- // partial redraw
+ guiwin_update_slider(gw, GUIWIN_VSLIDER);
+ if(!guiwin_has_intersection(gw, NULL)){
+ // blit screen area:
+ g.g_h -= slid->y_unit_px;
+ move_rect(&g, 0, +slid->y_unit_px);
+ g.g_y = g_ro.g_y;
+ g.g_h = slid->y_unit_px;
+ // redraw new content:
+ guiwin_send_redraw(gw, &g);
+ } else {
+ // let the draw implementation handle intersections:
+ guiwin_send_redraw(gw, &g_ro);
+ }
break;
- case WA_DNLINE:
- slid->y_pos = MIN(slid->y_pos_max, slid->y_pos+1);
- g.g_y += slid->y_unit_px;
- g.g_h -= slid->y_unit_px;
- move_screen(v_vdi_h, &g, 0, -slid->y_unit_px);
- g.g_y = g_ro.g_y + g_ro.g_h - slid->y_unit_px;
- g.g_h = slid->y_unit_px;
- guiwin_send_redraw(gw, &g);
- // move content up by unit size and sched redraw for the
- // bottom 16 px
- // partial redraw
+ case WA_DNPAGE:
+ val = g.g_h/slid->y_unit_px;
+ slid->y_pos = MIN(slid->y_pos_max, slid->y_pos+val);
+ guiwin_update_slider(gw, GUIWIN_VSLIDER);
+ guiwin_send_redraw(gw, &g_ro);
break;
- case WA_LFPAGE:
- // complete redraw
- // increase scroll val by page size...
+ case WA_DNLINE:
+ slid->y_pos = MIN(slid->y_pos_max, slid->y_pos+1);
+ guiwin_update_slider(gw, GUIWIN_VSLIDER);
+ if(!guiwin_has_intersection(gw, NULL)){
+ // blit screen area:
+ g.g_y += slid->y_unit_px;
+ g.g_h -= slid->y_unit_px;
+ move_rect(&g, 0, -slid->y_unit_px);
+ g.g_y = g_ro.g_y + g_ro.g_h - slid->y_unit_px;
+ g.g_h = slid->y_unit_px;
+ // redraw new content:
+ guiwin_send_redraw(gw, &g);
+ } else {
+ // let the draw implementation handle intersections:
+ guiwin_send_redraw(gw, &g_ro);
+ }
break;
- case WA_RTPAGE:
- // complete redraw
- // increase scroll val by page size...
+ case WA_LFPAGE:
+ val = g.g_w/slid->x_unit_px;
+ slid->x_pos = MAX(0, slid->x_pos-val);
+ guiwin_update_slider(gw, GUIWIN_HSLIDER);
+ guiwin_send_redraw(gw, &g_ro);
break;
case WA_LFLINE:
slid->x_pos = MAX(0, slid->x_pos-1);
+ guiwin_update_slider(gw, GUIWIN_HSLIDER);
+ if(!guiwin_has_intersection(gw, NULL)){
+ // blit screen area:
+ g.g_x -= slid->x_unit_px;
+ move_rect(&g, 0, +slid->x_unit_px);
+ // redraw new content:
+ g.g_x = g_ro.g_x;
+ g.g_w = slid->x_unit_px;
+ guiwin_send_redraw(gw, &g);
+ } else {
+ // let the draw implementation handle intersections:
+ guiwin_send_redraw(gw, &g_ro);
+ }
// partial redraw
break;
+ case WA_RTPAGE:
+ val = g.g_w/slid->x_unit_px;
+ slid->x_pos = MIN(slid->x_pos_max, slid->x_pos+val);
+ guiwin_update_slider(gw, GUIWIN_HSLIDER);
+ guiwin_send_redraw(gw, &g_ro);
+ break;
+
case WA_RTLINE:
slid->x_pos = MIN(slid->x_pos_max, slid->x_pos+1);
- // partial redraw
+ guiwin_update_slider(gw, GUIWIN_HSLIDER);
+ if(!guiwin_has_intersection(gw, NULL)){
+ // blit remaining area:
+ g.g_x += slid->x_unit_px;
+ g.g_w -= slid->y_unit_px;
+ move_rect(&g, 0, -slid->x_unit_px);
+ // redraw new content:
+ g.g_x = g_ro.g_x + g_ro.g_w - slid->x_unit_px;
+ g.g_h = slid->x_unit_px;
+ guiwin_send_redraw(gw, &g);
+ } else {
+ // let the draw implementation handle intersections:
+ guiwin_send_redraw(gw, &g_ro);
+ }
break;
default:
@@ -127,11 +189,21 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
case WM_REPOSED:
wind_get_grect(gw->handle, WF_CURRXYWH, &g);
wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]);
+ if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) {
+ if(guiwin_update_slider(gw, GUIWIN_VH_SLIDER)){
+ guiwin_send_redraw(gw, NULL);
+ }
+ }
break;
case WM_FULLED:
wind_get_grect(gw->handle, WF_FULLXYWH, &g);
wind_set_grect(gw->handle, WF_CURRXYWH, &g);
+ if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) {
+ if(guiwin_update_slider(gw, GUIWIN_VH_SLIDER)){
+ guiwin_send_redraw(gw, NULL);
+ }
+ }
break;
case WM_ICONIFY:
@@ -157,16 +229,22 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
tb_area = tb_area_ro;
if(rc_intersect((GRECT*)&msg[4], &tb_area)) {
+
+ gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
+ gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
+ gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
+ gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
+
wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
while (g.g_h > 0 || g.g_w > 0) {
- gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
- gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
- gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
- gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
- objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
- g.g_w, g.g_h);
+ if(rc_intersect(&tb_area_ro, &g)) {
+ objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
+ g.g_w, g.g_h);
+
+ }
wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
}
+
}
}
break;
@@ -174,7 +252,9 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
default:
retval = 0;
break;
+
}
+
return(retval);
}
@@ -391,46 +471,59 @@ void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
}
}
-void guiwin_update_slider(GUIWIN *win, short mode)
+bool guiwin_update_slider(GUIWIN *win, short mode)
{
GRECT viewport;
struct guiwin_scroll_info_s * slid;
unsigned long size, pos;
+ int old_x, old_y;
short handle = guiwin_get_handle(win);
guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &viewport);
slid = guiwin_get_scroll_info(win);
- if((mode & 1) && (slid->y_unit_px > 0)) {
+ old_x = slid->x_pos;
+ old_y = slid->y_pos;
+
+ if((mode & GUIWIN_VSLIDER) && (slid->y_unit_px > 0)) {
if ( slid->y_pos_max < (long)viewport.g_h/slid->y_unit_px)
size = 1000L;
else
- size = MAX( 50L, (unsigned long)viewport.g_h*1000L/(unsigned long)(slid->y_unit_px*slid->y_pos_max));
+ size = MAX( 50L, (unsigned long)viewport.g_h*1000L/
+ (unsigned long)(slid->y_unit_px*slid->y_pos_max));
wind_set(handle, WF_VSLSIZE, (int)size, 0, 0, 0);
if (slid->y_pos_max > (long)viewport.g_h/slid->y_unit_px) {
- pos = (unsigned long)slid->y_pos *1000L/(unsigned long)(slid->y_pos_max-viewport.g_h/slid->y_unit_px);
+ pos = (unsigned long)slid->y_pos *1000L/
+ (unsigned long)(slid->y_pos_max-viewport.g_h/slid->y_unit_px);
wind_set(handle, WF_VSLIDE, (int)pos, 0, 0, 0);
} else if (slid->y_pos) {
slid->y_pos = 0;
wind_set(handle, WF_VSLIDE, 0, 0, 0, 0);
}
}
- if((mode & 2) && (slid->x_unit_px > 0)) {
+ if((mode & GUIWIN_HSLIDER) && (slid->x_unit_px > 0)) {
if ( slid->x_pos_max < (long)viewport.g_w/slid->x_unit_px)
size = 1000L;
else
- size = MAX( 50L, (unsigned long)viewport.g_w*1000L/(unsigned long)(slid->x_unit_px*slid->x_pos_max));
+ size = MAX( 50L, (unsigned long)viewport.g_w*1000L/
+ (unsigned long)(slid->x_unit_px*slid->x_pos_max));
wind_set(handle, WF_HSLSIZE, (int)size, 0, 0, 0);
if( slid->x_pos_max > (long)viewport.g_w/slid->x_unit_px) {
- pos = (unsigned long)slid->x_pos*1000L/(unsigned long)(slid->x_pos_max-viewport.g_w/slid->x_unit_px);
+ pos = (unsigned long)slid->x_pos*1000L/
+ (unsigned long)(slid->x_pos_max-viewport.g_w/slid->x_unit_px);
wind_set(handle, WF_HSLIDE, (int)pos, 0, 0, 0);
} else if (slid->x_pos) {
slid->x_pos = 0;
wind_set(handle, WF_HSLIDE, 0, 0, 0, 0);
}
}
+
+ if(old_x != slid->x_pos || old_y != slid->y_pos){
+ return(true);
+ }
+ return(false);
}
short guiwin_get_handle(GUIWIN *win)
@@ -467,31 +560,50 @@ void *guiwin_get_user_data(GUIWIN *win)
return(win->user_data);
}
-struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win)
-{
+struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win) {
return(&win->scroll_info);
}
void guiwin_send_redraw(GUIWIN *win, GRECT *area)
{
- short msg[8];
- GRECT work;
+ short msg[8];
+ GRECT work;
- if(area == NULL){
- guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
- area = &work;
- }
+ if(area == NULL) {
+ guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
+ area = &work;
+ }
+
+ msg[0] = WM_REDRAW;
+ msg[1] = gl_apid;
+ msg[2] = 0;
+ msg[3] = win->handle;
+ msg[4] = area->g_x;
+ msg[5] = area->g_y;
+ msg[6] = area->g_w;
+ msg[7] = area->g_h;
- msg[0] = WM_REDRAW;
- msg[1] = gl_apid;
- msg[2] = 0;
- msg[3] = win->handle;
- msg[4] = area->g_x;
- msg[5] = area->g_y;
- msg[6] = area->g_w;
- msg[7] = area->g_h;
+ appl_write(gl_apid, 16, &msg);
+}
- appl_write(gl_apid, 16, &msg);
+bool guiwin_has_intersection(GUIWIN *win, GRECT *work)
+{
+ GRECT area, mywork;
+ bool retval = false;
+
+ if (work == NULL) {
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &mywork);
+ work = &mywork;
+ }
+
+ wind_get_grect(win->handle, WF_FIRSTXYWH, &area);
+ while (area.g_w && area.g_w) {
+ if (rc_intersect(work, &area)) {
+ retval = true;
+ }
+ wind_get_grect(win->handle, WF_NEXTXYWH, &area);
+ }
+ return(retval);
}
/*
void guiwin_exec_redraw(){
diff --git a/atari/gemtk/guiwin.h b/atari/gemtk/guiwin.h
index dba112c..6daf16c 100644
--- a/atari/gemtk/guiwin.h
+++ b/atari/gemtk/guiwin.h
@@ -1,5 +1,4 @@
#ifndef OPKG_GUI_GUIWIN_H
-#define OPKG_GUI_GUIWIN_H
-
+#define OPKG_GUI_GUIWIN_
#endif /* OPKG_GUIWIN_H */
diff --git a/atari/res/netsurf.rsc b/atari/res/netsurf.rsc
index a8a8b80..5a9327f 100755
Binary files a/atari/res/netsurf.rsc and b/atari/res/netsurf.rsc differ
diff --git a/atari/res/netsurf.rsh b/atari/res/netsurf.rsh
index 7b422ef..b0c800d 100755
--- a/atari/res/netsurf.rsh
+++ b/atari/res/netsurf.rsh
@@ -198,9 +198,7 @@
#define CHOICES_ABORT 108 /* BUTTON in tree CHOICES */
#define CHOICES_OK 109 /* BUTTON in tree CHOICES */
-#define ALERT 14 /* form/dial */
-
-#define VSCROLLER 15 /* form/dial */
+#define VSCROLLER 14 /* form/dial */
#define VSCROLLER_AREA 1 /* BOX in tree VSCROLLER */
#define VSCROLLER_SLIDER_AREA 2 /* BUTTON in tree VSCROLLER */
#define VSCROLLER_SLIDER 3 /* BUTTON in tree VSCROLLER */
diff --git a/atari/res/netsurf.rsm b/atari/res/netsurf.rsm
index 6996aea..ade2b1c 100755
--- a/atari/res/netsurf.rsm
+++ b/atari/res/netsurf.rsm
@@ -1,9 +1,9 @@
ResourceMaster v3.65
-#C 16@0@0@0@
+#C 15@0@0@0@
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@1@1@1@1@
-#M 20010100@0@7728@606@
+#M 20010100@0@7728@610@
#T 0@1@MAINMENU@@62@@
#O 4@32@T_FILE@@
#O 5@32@T_EDIT@@
@@ -187,8 +187,7 @@ ResourceMaster v3.65
#O 107@26@CB_BG_IMAGES@@
#O 108@26@ABORT@@
#O 109@26@OK@@
-#T 14@2@ALERT@@1@@
-#T 15@2@VSCROLLER@@8@@
+#T 14@2@VSCROLLER@@8@@
#O 1@20@AREA@@
#O 2@26@SLIDER_AREA@@
#O 3@26@SLIDER@@
@@ -196,4 +195,4 @@ ResourceMaster v3.65
#O 5@33@BT_DOWN_PIC@@
#O 6@25@BT_UP@@
#O 4@33@BT_UP_PIC@@
-#c 9608@
+#c 2361@
diff --git a/atari/treeview.c b/atari/treeview.c
index 4cddea4..44a8630 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -1,68 +1,68 @@
-/*
- * Copyright 2010 Ole Loots <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "desktop/plotters.h"
-#include "desktop/textinput.h"
-#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
-#include "desktop/textinput.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "atari/gui.h"
-#include "atari/treeview.h"
-#include "atari/plot/plot.h"
+/*
+ * Copyright 2010 Ole Loots <ole(a)monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "content/urldb.h"
+#include "desktop/browser.h"
+#include "desktop/plotters.h"
+#include "desktop/textinput.h"
+#include "desktop/tree.h"
+#include "desktop/tree_url_node.h"
+#include "desktop/textinput.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "atari/gui.h"
+#include "atari/treeview.h"
+#include "atari/plot/plot.h"
#include "atari/misc.h"
-#include "atari/gemtk/gemtk.h"
+#include "atari/gemtk/gemtk.h"
#include "cflib.h"
enum treeview_area_e {
TREEVIEW_AREA_WORK = 0,
TREEVIEW_AREA_TOOLBAR,
TREEVIEW_AREA_CONTENT
-};
-
-extern int mouse_hold_start[3];
-extern browser_mouse_state bmstate;
-extern short last_drag_x;
-extern short last_drag_y;
+};
+
+extern int mouse_hold_start[3];
+extern browser_mouse_state bmstate;
+extern short last_drag_x;
+extern short last_drag_y;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
-
-static void atari_treeview_resized(struct tree *tree,int w,int h, void *pw);
-static void atari_treeview_scroll_visible(int y, int h, void *pw);
+
+static void atari_treeview_resized(struct tree *tree,int w,int h, void *pw);
+static void atari_treeview_scroll_visible(int y, int h, void *pw);
static void atari_treeview_get_dimensions(int *width, int *height, void *pw);
static void atari_treeview_get_grect(NSTREEVIEW tree,
- enum treeview_area_e mode, GRECT *dest);
-
-static const struct treeview_table atari_tree_callbacks = {
- atari_treeview_request_redraw,
- atari_treeview_resized,
- atari_treeview_scroll_visible,
- atari_treeview_get_dimensions
+ enum treeview_area_e mode, GRECT *dest);
+
+static const struct treeview_table atari_tree_callbacks = {
+ atari_treeview_request_redraw,
+ atari_treeview_resized,
+ atari_treeview_scroll_visible,
+ atari_treeview_get_dimensions
};
static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
@@ -79,7 +79,6 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
// handle message
- printf("treeview msg: %d\n", msg[0]);
switch (msg[0]) {
case WM_REDRAW:
@@ -88,7 +87,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
case WM_SIZED:
case WM_FULLED:
- guiwin_update_slider(win, 3);
+ //atari_treeview_resized(tv->tree, tv->extent.x, tv->extent.y, tv);
break;
default:
@@ -116,384 +115,390 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
return(0);
-}
-
+}
+
static void __CDECL on_keybd_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
- short msg[8])
-{
- bool r=false;
- long kstate = 0;
- long kcode = 0;
- long ucs4;
- long ik;
- unsigned short nkc = 0;
- unsigned short nks = 0;
- unsigned char ascii;
-
- kstate = ev_out->emo_kmeta;
- kcode = ev_out->emo_kreturn;
- nkc= gem_to_norm( (short)kstate, (short)kcode );
- ascii = (nkc & 0xFF);
- ik = nkc_to_input_key( nkc, &ucs4 );
-
- if( ik == 0 ){
- if (ascii >= 9 ) {
- r = tree_keypress( tv->tree, ucs4 );
- }
- } else {
- r = tree_keypress( tv->tree, ik );
- }
-}
-
-
+ short msg[8])
+{
+ bool r=false;
+ long kstate = 0;
+ long kcode = 0;
+ long ucs4;
+ long ik;
+ unsigned short nkc = 0;
+ unsigned short nks = 0;
+ unsigned char ascii;
+
+ kstate = ev_out->emo_kmeta;
+ kcode = ev_out->emo_kreturn;
+ nkc= gem_to_norm( (short)kstate, (short)kcode );
+ ascii = (nkc & 0xFF);
+ ik = nkc_to_input_key( nkc, &ucs4 );
+
+ if( ik == 0 ){
+ if (ascii >= 9 ) {
+ r = tree_keypress( tv->tree, ucs4 );
+ }
+ } else {
+ r = tree_keypress( tv->tree, ik );
+ }
+}
+
+
static void __CDECL on_redraw_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
- short msg[8])
-{
- GRECT work, clip;
+ short msg[8])
+{
+ GRECT work, clip;
+ struct guiwin_scroll_info_s *slid;
- if( tv == NULL )
- return;
+ if( tv == NULL )
+ return;
guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
-
- clip = work;
- if ( !rc_intersect( (GRECT*)&msg[4], &clip ) ) return;
- clip.g_x -= work.g_x;
- clip.g_y -= work.g_y;
- if( clip.g_x < 0 ) {
- clip.g_w = work.g_w + clip.g_x;
- clip.g_x = 0;
- }
- if( clip.g_y < 0 ) {
- clip.g_h = work.g_h + clip.g_y;
- clip.g_y = 0;
- }
+ slid = guiwin_get_scroll_info(tv->window);
+
+ clip = work;
+ if ( !rc_intersect( (GRECT*)&msg[4], &clip ) ) return;
+ clip.g_x -= work.g_x;
+ clip.g_y -= work.g_y;
+ if( clip.g_x < 0 ) {
+ clip.g_w = work.g_w + clip.g_x;
+ clip.g_x = 0;
+ }
+ if( clip.g_y < 0 ) {
+ clip.g_h = work.g_h + clip.g_y;
+ clip.g_y = 0;
+ }
if( clip.g_h > 0 && clip.g_w > 0 ) {
- // TODO: get slider values
- atari_treeview_request_redraw(
- /*win->xpos*win->w_u +*/ clip.g_x,
- /*win->ypos*win->h_u +*/ clip.g_y,
- clip.g_w, clip.g_h, tv
- );
- }
-}
-
+ // TODO: get slider values
+ atari_treeview_request_redraw((slid->x_pos*slid->x_unit_px) + clip.g_x,
+ (slid->y_pos*slid->y_unit_px) + clip.g_y,
+ clip.g_w, clip.g_h, tv
+ );
+ }
+}
+
static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
- short msg[8])
-{
- GRECT work;
- if(tv == NULL)
- return;
- if( evnt.mbut & 2 ) {
- /* do not handle right click */
- return;
+ short msg[8])
+{
+ struct guiwin_scroll_info_s *slid;
+ GRECT work;
+
+ if(tv == NULL)
+ return;
+ if( evnt.mbut & 2 ) {
+ /* do not handle right click */
+ return;
}
- guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
-
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+ slid = guiwin_get_scroll_info(tv->window);
+
/* mouse click relative origin: */
-
- // TODO: get scroll position
- //short origin_rel_x = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
- //short origin_rel_y = (evnt.my-work.g_y)+(win->ypos*win->h_u);
-
- short origin_rel_x = (ev_out->emo_mouse.p_x-work.g_x);
- short origin_rel_y = (ev_out->emo_mouse.p_y-work.g_y);
-
- if( origin_rel_x >= 0 && origin_rel_y >= 0
- && evnt.mx < work.g_x + work.g_w
- && evnt.my < work.g_y + work.g_h )
- {
- int bms;
- bool ignore=false;
- short cur_rel_x, cur_rel_y, dummy, mbut;
-
- if( evnt.nb_click == 2 ){
- tree_mouse_action(tv->tree,
- BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DOUBLE_CLICK,
- origin_rel_x, origin_rel_y );
- return;
- }
-
- graf_mkstate(&cur_rel_x, &cur_rel_x, &mbut, &dummy);
- if( (mbut&1) == 0 ){
- bms = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1;
- if( evnt.nb_click == 2 ) {
- bms = BROWSER_MOUSE_DOUBLE_CLICK;
- }
- tree_mouse_action(tv->tree, bms, origin_rel_x, origin_rel_y );
- } else {
- /* button still pressed */
-
- short prev_x = origin_rel_x;
- short prev_y = origin_rel_y;
-
- cur_rel_x = origin_rel_x;
- cur_rel_y = origin_rel_y;
-
- if( tree_is_edited(tv->tree) ){
- gem_set_cursor(&gem_cursors.ibeam);
- } else {
- gem_set_cursor(&gem_cursors.hand);
- }
-
- tv->startdrag.x = origin_rel_x;
- tv->startdrag.y = origin_rel_y;
-
- tree_mouse_action( tv->tree,
- BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON ,
- cur_rel_x, cur_rel_y );
- do{
- if( abs(prev_x-cur_rel_x) > 5 || abs(prev_y-cur_rel_y) > 5 ){
- tree_mouse_action( tv->tree,
- BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON,
- cur_rel_x, cur_rel_y);
- prev_x = cur_rel_x;
- prev_y = cur_rel_y;
- }
-
- if( tv->redraw )
- atari_treeview_redraw( tv );
- /* sample mouse button state: */
+
+ short origin_rel_x = (ev_out->emo_mouse.p_x-work.g_x) +
+ (slid->x_pos*slid->x_unit_px);
+ short origin_rel_y = (ev_out->emo_mouse.p_y-work.g_y) +
+ (slid->y_pos*slid->y_unit_px);
+
+ if( origin_rel_x >= 0 && origin_rel_y >= 0
+ && evnt.mx < work.g_x + work.g_w
+ && evnt.my < work.g_y + work.g_h )
+ {
+ int bms;
+ bool ignore=false;
+ short cur_rel_x, cur_rel_y, dummy, mbut;
+
+ if( evnt.nb_click == 2 ){
+ tree_mouse_action(tv->tree,
+ BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DOUBLE_CLICK,
+ origin_rel_x, origin_rel_y );
+ return;
+ }
+
+ graf_mkstate(&cur_rel_x, &cur_rel_x, &mbut, &dummy);
+ if( (mbut&1) == 0 ){
+ bms = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1;
+ if( evnt.nb_click == 2 ) {
+ bms = BROWSER_MOUSE_DOUBLE_CLICK;
+ }
+ tree_mouse_action(tv->tree, bms, origin_rel_x, origin_rel_y );
+ } else {
+ /* button still pressed */
+
+ short prev_x = origin_rel_x;
+ short prev_y = origin_rel_y;
+
+ cur_rel_x = origin_rel_x;
+ cur_rel_y = origin_rel_y;
+
+ if( tree_is_edited(tv->tree) ){
+ gem_set_cursor(&gem_cursors.ibeam);
+ } else {
+ gem_set_cursor(&gem_cursors.hand);
+ }
+
+ tv->startdrag.x = origin_rel_x;
+ tv->startdrag.y = origin_rel_y;
+
+ tree_mouse_action( tv->tree,
+ BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON ,
+ cur_rel_x, cur_rel_y );
+ do{
+ if( abs(prev_x-cur_rel_x) > 5 || abs(prev_y-cur_rel_y) > 5 ){
+ tree_mouse_action( tv->tree,
+ BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON,
+ cur_rel_x, cur_rel_y);
+ prev_x = cur_rel_x;
+ prev_y = cur_rel_y;
+ }
+
+ if( tv->redraw )
+ atari_treeview_redraw( tv );
+ /* sample mouse button state: */
graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy);
- // TODO : get guwin slider values;
- cur_rel_x = (cur_rel_x-work.g_x)/*+(win->xpos*win->w_u);*/;
- cur_rel_y = (cur_rel_y-work.g_y)/*+(win->ypos*win->h_u);*/;
- } while( mbut & 1 );
-
- tree_drag_end(tv->tree, 0, tv->startdrag.x, tv->startdrag.y,
- cur_rel_x, cur_rel_y );
- gem_set_cursor(&gem_cursors.arrow);
- }
- }
-}
-
+ cur_rel_x = (cur_rel_x-work.g_x)+(slid->x_pos*slid->x_unit_px);
+ cur_rel_y = (cur_rel_y-work.g_y)+(slid->y_pos*slid->y_unit_px);
+ } while( mbut & 1 );
+
+ tree_drag_end(tv->tree, 0, tv->startdrag.x, tv->startdrag.y,
+ cur_rel_x, cur_rel_y );
+ gem_set_cursor(&gem_cursors.arrow);
+ }
+ }
+}
+
NSTREEVIEW atari_treeview_create(uint32_t flags, GUIWIN *win,
- guiwin_event_handler_f user_func)
+ guiwin_event_handler_f user_func)
{
struct guiwin_scroll_info_s *slid;
-
- if( win == NULL )
- return( NULL );
- NSTREEVIEW new = malloc(sizeof(struct atari_treeview));
- if (new == NULL)
- return NULL;
- memset( new, 0, sizeof(struct atari_treeview));
- new->tree = tree_create(flags, &atari_tree_callbacks, new);
- if (new->tree == NULL) {
- free(new);
- return NULL;
- }
+
+ if( win == NULL )
+ return( NULL );
+ NSTREEVIEW new = malloc(sizeof(struct atari_treeview));
+ if (new == NULL)
+ return NULL;
+ memset( new, 0, sizeof(struct atari_treeview));
+ new->tree = tree_create(flags, &atari_tree_callbacks, new);
+ if (new->tree == NULL) {
+ free(new);
+ return NULL;
+ }
new->window = win;
new->user_func = user_func;
guiwin_set_event_handler(win, handle_event);
guiwin_set_user_data(win, (void*)new);
-
+
slid = guiwin_get_scroll_info(new->window);
slid->y_unit_px = 16;
- slid->x_unit_px = 16;
-
- return(new);
-}
-
-void atari_treeview_open( NSTREEVIEW tv )
-{
- if( tv->window != NULL ) {
- tree_set_redraw(tv->tree, true);
- }
-}
-
-void atari_treeview_close( NSTREEVIEW tv )
-{
- if( tv->window != NULL ) {
- tree_set_redraw(tv->tree, false);
- }
-}
-
-void atari_treeview_destroy( NSTREEVIEW tv )
-{
- if( tv != NULL ){
- tv->disposing = true;
- LOG(("tree: %p", tv));
- if( tv->tree != NULL ) {
- tree_delete(tv->tree);
- tv->tree = NULL;
- }
- free( tv );
- }
-}
-
-bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
-{
+ slid->x_unit_px = 16;
+
+ return(new);
+}
+
+void atari_treeview_open( NSTREEVIEW tv )
+{
+ if( tv->window != NULL ) {
+ tree_set_redraw(tv->tree, true);
+ }
+}
+
+void atari_treeview_close( NSTREEVIEW tv )
+{
+ if( tv->window != NULL ) {
+ tree_set_redraw(tv->tree, false);
+ }
+}
+
+void atari_treeview_destroy( NSTREEVIEW tv )
+{
+ if( tv != NULL ){
+ tv->disposing = true;
+ LOG(("tree: %p", tv));
+ if( tv->tree != NULL ) {
+ tree_delete(tv->tree);
+ tv->tree = NULL;
+ }
+ free( tv );
+ }
+}
+
+bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
+{
GRECT work;
struct guiwin_scroll_info_s *slid;
- if( tv == NULL )
- return ( false );
-
+ if( tv == NULL )
+ return ( false );
+
guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
slid = guiwin_get_scroll_info(tv->window);
-
- int rx = (x-work.g_x)+(slid->x_pos*slid->x_unit_px);
+
+ int rx = (x-work.g_x)+(slid->x_pos*slid->x_unit_px);
int ry = (y-work.g_y)+(slid->y_pos*slid->y_unit_px);
tree_mouse_action(tv->tree, bms, rx, ry);
-
- tv->click.x = rx;
- tv->click.y = ry;
-
- return( true );
-}
-
-
-
-void atari_treeview_redraw( NSTREEVIEW tv)
+
+ tv->click.x = rx;
+ tv->click.y = ry;
+
+ return( true );
+}
+
+
+
+void atari_treeview_redraw( NSTREEVIEW tv)
{
-
- if (tv != NULL) {
- if( tv->redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
+ if (tv != NULL) {
+ if( tv->redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
- short todo[4];
+ short todo[4];
GRECT work;
short handle = guiwin_get_handle(tv->window);
- struct guiwin_scroll_info_s *slid;
+ struct guiwin_scroll_info_s *slid;
- guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
slid = guiwin_get_scroll_info(tv->window);
-
- struct redraw_context ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &atari_plotters
- };
- plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h);
- if (plot_lock() == false)
- return;
-
- todo[0] = work.g_x;
- todo[1] = work.g_y;
- todo[2] = todo[0] + work.g_w-1;
- todo[3] = todo[1] + work.g_h-1;
- vs_clip(atari_plot_vdi_handle, 1, (short*)&todo );
-
- if( wind_get(handle, WF_FIRSTXYWH,
- &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
- while (todo[2] && todo[3]) {
-
+
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &atari_plotters
+ };
+ plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h);
+ if (plot_lock() == false)
+ return;
+
+ if( wind_get(handle, WF_FIRSTXYWH,
+ &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
+ while (todo[2] && todo[3]) {
+
+ short pxy[4];
+ pxy[0] = todo[0];
+ pxy[1] = todo[1];
+ pxy[2] = todo[0] + todo[2]-1;
+ pxy[3] = todo[1] + todo[3]-1;
+ vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy);
+
/* convert screen to treeview coords: */
- // TODO: get slider values:
- todo[0] = todo[0] - work.g_x + slid->x_pos*slid->x_unit_px;
- todo[1] = todo[1] - work.g_y + slid->y_pos*slid->y_unit_px;
- if( todo[0] < 0 ){
- todo[2] = todo[2] + todo[0];
- todo[0] = 0;
- }
- if( todo[1] < 0 ){
- todo[3] = todo[3] + todo[1];
- todo[1] = 0;
- }
+ todo[0] = todo[0] - work.g_x + slid->x_pos*slid->x_unit_px;
+ todo[1] = todo[1] - work.g_y + slid->y_pos*slid->y_unit_px;
+ if( todo[0] < 0 ){
+ todo[2] = todo[2] + todo[0];
+ todo[0] = 0;
+ }
+ if( todo[1] < 0 ){
+ todo[3] = todo[3] + todo[1];
+ todo[1] = 0;
+ }
// TODO: get slider values
- if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
+ if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
tree_draw(tv->tree, -(slid->x_pos*slid->x_unit_px),
- -(slid->y_pos*slid->y_unit_px),
- todo[0], todo[1], todo[2], todo[3], &ctx
- );
- }
- if (wind_get(handle, WF_NEXTXYWH,
- &todo[0], &todo[1], &todo[2], &todo[3])==0) {
- break;
- }
- }
- } else {
- plot_unlock();
- return;
- }
- plot_unlock();
- vs_clip(atari_plot_vdi_handle, 0, (short*)&todo);
- tv->redraw = false;
- tv->rdw_area.g_x = 65000;
- tv->rdw_area.g_y = 65000;
- tv->rdw_area.g_w = -1;
- tv->rdw_area.g_h = -1;
- } else {
- /* just copy stuff from the offscreen buffer */
- }
- }
-}
-
-
-/**
- * Callback to force a redraw of part of the treeview window.
- *
- * \param x Min X Coordinate of area to be redrawn.
- * \param y Min Y Coordinate of area to be redrawn.
- * \param width Width of area to be redrawn.
- * \param height Height of area to be redrawn.
- * \param pw The treeview object to be redrawn.
- */
-void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
-{
- if ( pw != NULL ) {
- NSTREEVIEW tv = (NSTREEVIEW) pw;
- if( tv->redraw == false ){
- tv->redraw = true;
- tv->rdw_area.g_x = x;
- tv->rdw_area.g_y = y;
- tv->rdw_area.g_w = w;
- tv->rdw_area.g_h = h;
- } else {
- /* merge the redraw area to the new area.: */
- int newx1 = x+w;
- int newy1 = y+h;
- int oldx1 = tv->rdw_area.g_x + tv->rdw_area.g_w;
- int oldy1 = tv->rdw_area.g_y + tv->rdw_area.g_h;
- tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, x);
- tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, y);
- tv->rdw_area.g_w = ( oldx1 > newx1 ) ? oldx1 - tv->rdw_area.g_x : newx1 - tv->rdw_area.g_x;
- tv->rdw_area.g_h = ( oldy1 > newy1 ) ? oldy1 - tv->rdw_area.g_y : newy1 - tv->rdw_area.g_y;
- }
- }
-}
-
-
-/**
- * Callback to notify us of a new overall tree size.
- *
- * \param tree The tree being resized.
- * \param width The new width of the window.
- * \param height The new height of the window.
- * \param *pw The treeview object to be resized.
- */
-
-void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
-{
- if (pw != NULL) {
- NSTREEVIEW tv = (NSTREEVIEW) pw;
- if( tv->disposing )
- return;
- // TODO: update slider size
+ -(slid->y_pos*slid->y_unit_px),
+ todo[0], todo[1], todo[2], todo[3], &ctx
+ );
+ }
+ vs_clip(atari_plot_vdi_handle, 0, (short*)&pxy);
+ if (wind_get(handle, WF_NEXTXYWH,
+ &todo[0], &todo[1], &todo[2], &todo[3])==0) {
+ break;
+ }
+ }
+ } else {
+ plot_unlock();
+ return;
+ }
+ plot_unlock();
+ tv->redraw = false;
+ tv->rdw_area.g_x = 65000;
+ tv->rdw_area.g_y = 65000;
+ tv->rdw_area.g_w = -1;
+ tv->rdw_area.g_h = -1;
+ } else {
+ /* just copy stuff from the offscreen buffer */
+ }
+ }
+}
+
+
+/**
+ * Callback to force a redraw of part of the treeview window.
+ *
+ * \param x Min X Coordinate of area to be redrawn.
+ * \param y Min Y Coordinate of area to be redrawn.
+ * \param width Width of area to be redrawn.
+ * \param height Height of area to be redrawn.
+ * \param pw The treeview object to be redrawn.
+ */
+void atari_treeview_request_redraw(int x, int y, int w, int h, void *pw)
+{
+ if ( pw != NULL ) {
+ NSTREEVIEW tv = (NSTREEVIEW) pw;
+ if( tv->redraw == false ){
+ tv->redraw = true;
+ tv->rdw_area.g_x = x;
+ tv->rdw_area.g_y = y;
+ tv->rdw_area.g_w = w;
+ tv->rdw_area.g_h = h;
+ } else {
+ /* merge the redraw area to the new area.: */
+ int newx1 = x+w;
+ int newy1 = y+h;
+ int oldx1 = tv->rdw_area.g_x + tv->rdw_area.g_w;
+ int oldy1 = tv->rdw_area.g_y + tv->rdw_area.g_h;
+ tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, x);
+ tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, y);
+ tv->rdw_area.g_w = ( oldx1 > newx1 ) ? oldx1 - tv->rdw_area.g_x : newx1 - tv->rdw_area.g_x;
+ tv->rdw_area.g_h = ( oldy1 > newy1 ) ? oldy1 - tv->rdw_area.g_y : newy1 - tv->rdw_area.g_y;
+ }
+ dbg_grect("atari_treeview_request_redraw", &tv->rdw_area);
+ }
+}
+
+
+/**
+ * Callback to notify us of a new overall tree size.
+ *
+ * \param tree The tree being resized.
+ * \param width The new width of the window.
+ * \param height The new height of the window.
+ * \param *pw The treeview object to be resized.
+ */
+
+void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
+{
+ GRECT area;
+ if (pw != NULL) {
+ NSTREEVIEW tv = (NSTREEVIEW) pw;
+ if( tv->disposing )
+ return;
+ tv->extent.x = width;
+ tv->extent.y = height;
struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(tv->window);
- slid->x_pos_max = (width / slid->x_unit_px);
- slid->y_pos_max = (height / slid->y_unit_px);
- guiwin_update_slider(tv->window, 3);
- }
-}
-
-
-/**
- * Callback to request that a section of the tree is scrolled into view.
- *
- * \param y The Y coordinate of top of the area in NS units.
- * \param height The height of the area in NS units.
- * \param *pw The treeview object affected.
- */
-
-void atari_treeview_scroll_visible(int y, int height, void *pw)
-{
- /* we don't support dragging outside the treeview */
- /* so we don't need to implement this? */
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &area);
+ slid->x_pos_max = (width/slid->x_unit_px);//-(area.g_w/slid->x_unit_px)+1;
+ slid->y_pos_max = (height/slid->y_unit_px);//-(area.g_h/slid->y_unit_px)+1;
+ printf("units content: %d, units viewport: %d\n", (height/slid->y_unit_px),
+ (area.g_h/slid->y_unit_px));
+ guiwin_update_slider(tv->window, GUIWIN_VH_SLIDER);
+ }
+}
+
+
+/**
+ * Callback to request that a section of the tree is scrolled into view.
+ *
+ * \param y The Y coordinate of top of the area in NS units.
+ * \param height The height of the area in NS units.
+ * \param *pw The treeview object affected.
+ */
+
+void atari_treeview_scroll_visible(int y, int height, void *pw)
+{
+ /* we don't support dragging outside the treeview */
+ /* so we don't need to implement this? */
}
static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode,
@@ -506,44 +511,44 @@ static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode,
else if (mode == TREEVIEW_AREA_TOOLBAR) {
guiwin_get_grect(tv->window, GUIWIN_AREA_TOOLBAR, dest);
}
-}
-
-/**
- * Callback to return the tree window dimensions to the treeview system.
- *
- * \param *width Return the window width.
- * \param *height Return the window height.
- * \param *pw The treeview object to use.
- */
-
-void atari_treeview_get_dimensions(int *width, int *height,
- void *pw)
-{
- if (pw != NULL && (width != NULL || height != NULL)) {
- NSTREEVIEW tv = (NSTREEVIEW) pw;
+}
+
+/**
+ * Callback to return the tree window dimensions to the treeview system.
+ *
+ * \param *width Return the window width.
+ * \param *height Return the window height.
+ * \param *pw The treeview object to use.
+ */
+
+void atari_treeview_get_dimensions(int *width, int *height,
+ void *pw)
+{
+ if (pw != NULL && (width != NULL || height != NULL)) {
+ NSTREEVIEW tv = (NSTREEVIEW) pw;
GRECT work;
- atari_treeview_get_grect(tv, TREEVIEW_AREA_CONTENT, &work);
- *width = work.g_w;
- *height = work.g_h;
- }
-}
-
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- strcpy( buffer, "content.png" );
- break;
- }
-}
+ atari_treeview_get_grect(tv, TREEVIEW_AREA_CONTENT, &work);
+ *width = work.g_w;
+ *height = work.g_h;
+ }
+}
+
+
+/**
+ * Translates a content_type to the name of a respective icon
+ *
+ * \param content_type content type
+ * \param buffer buffer for the icon name
+ */
+void tree_icon_name_from_content_type(char *buffer, content_type type)
+{
+ switch (type) {
+ case CONTENT_HTML:
+ case CONTENT_TEXTPLAIN:
+ case CONTENT_CSS:
+ case CONTENT_IMAGE:
+ default:
+ strcpy( buffer, "content.png" );
+ break;
+ }
+}
--
NetSurf Browser
10 years, 6 months
nsgenjsbind: branch master updated. e709f23f29d7135a71923921db6eb059826955cf
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/e709f23f29d7135a7...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/e709f23f29d7135a719...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/e709f23f29d7135a71923...
The branch, master has been updated
via e709f23f29d7135a71923921db6eb059826955cf (commit)
from 841e93e4bc21729853e56b6d6b188d7b21450950 (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/e709f23f29d7135...
commit e709f23f29d7135a71923921db6eb059826955cf
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
generate unshared type property bodies
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index a488058..4f30011 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -17,6 +17,9 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
+static int generate_property_spec(struct binding *binding, const char *interface);
+static int generate_property_body(struct binding *binding, const char *interface);
+
static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
{
@@ -93,7 +96,7 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
return 0;
}
-static int generate_property_spec(struct binding *binding, const char *interface);
+
/* callback to emit implements property spec */
static int webidl_property_spec_implements_cb(struct webidl_node *node, void *ctx)
{
@@ -583,11 +586,13 @@ static int webidl_implements_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
- return output_property_body(binding, webidl_node_gettext(node));
+ return generate_property_body(binding, webidl_node_gettext(node));
}
-int
-output_property_body(struct binding *binding, const char *interface)
+
+
+static int
+generate_property_body(struct binding *binding, const char *interface)
{
struct webidl_node *interface_node;
struct webidl_node *members_node;
@@ -633,7 +638,7 @@ output_property_body(struct binding *binding, const char *interface)
WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
if (inherit_node != NULL) {
- res = output_property_body(binding,
+ res = generate_property_body(binding,
webidl_node_gettext(inherit_node));
}
@@ -646,3 +651,51 @@ output_property_body(struct binding *binding, const char *interface)
return res;
}
+
+
+
+int unshared_property_cb(struct genbind_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ struct genbind_node *type_node;
+
+ /* only need to generate property body for unshared types */
+ type_node = genbind_node_find_type(genbind_node_getnode(node),
+ NULL,
+ GENBIND_NODE_TYPE_TYPE);
+
+ fprintf(binding->outfile,
+ "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
+ genbind_node_gettext(type_node));
+
+ fprintf(binding->outfile,
+ "{\n"
+ " return JS_FALSE;\n"
+ "}\n\n");
+
+ fprintf(binding->outfile,
+ "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
+ "{\n",
+ genbind_node_gettext(type_node));
+
+
+ return 0;
+}
+
+/* exported interface documented in jsapi-libdom.h */
+int
+output_property_body(struct binding *binding)
+{
+ int res;
+
+ res = generate_property_body(binding, binding->interface);
+
+ if (res == 0) {
+ res = genbind_node_for_each_type(binding->binding_list,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ unshared_property_cb,
+ binding);
+ }
+
+ return res;
+}
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index e83d0ee..0ac16e8 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -724,7 +724,7 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
return 9;
}
- res = output_property_body(binding, binding->interface);
+ res = output_property_body(binding);
if (res) {
return 10;
}
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index b397e67..86214f4 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -49,7 +49,7 @@ int output_operator_body(struct binding *binding, const char *interface);
int output_function_spec(struct binding *binding);
int output_property_spec(struct binding *binding);
-int output_property_body(struct binding *binding, const char *interface);
+int output_property_body(struct binding *binding);
int output_const_defines(struct binding *binding, const char *interface);
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-property.c | 63 +++++++++++++++++++++++++++++++++++++++---
src/jsapi-libdom.c | 2 +-
src/jsapi-libdom.h | 2 +-
3 files changed, 60 insertions(+), 7 deletions(-)
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index a488058..4f30011 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -17,6 +17,9 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
+static int generate_property_spec(struct binding *binding, const char *interface);
+static int generate_property_body(struct binding *binding, const char *interface);
+
static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
{
@@ -93,7 +96,7 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
return 0;
}
-static int generate_property_spec(struct binding *binding, const char *interface);
+
/* callback to emit implements property spec */
static int webidl_property_spec_implements_cb(struct webidl_node *node, void *ctx)
{
@@ -583,11 +586,13 @@ static int webidl_implements_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
- return output_property_body(binding, webidl_node_gettext(node));
+ return generate_property_body(binding, webidl_node_gettext(node));
}
-int
-output_property_body(struct binding *binding, const char *interface)
+
+
+static int
+generate_property_body(struct binding *binding, const char *interface)
{
struct webidl_node *interface_node;
struct webidl_node *members_node;
@@ -633,7 +638,7 @@ output_property_body(struct binding *binding, const char *interface)
WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
if (inherit_node != NULL) {
- res = output_property_body(binding,
+ res = generate_property_body(binding,
webidl_node_gettext(inherit_node));
}
@@ -646,3 +651,51 @@ output_property_body(struct binding *binding, const char *interface)
return res;
}
+
+
+
+int unshared_property_cb(struct genbind_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ struct genbind_node *type_node;
+
+ /* only need to generate property body for unshared types */
+ type_node = genbind_node_find_type(genbind_node_getnode(node),
+ NULL,
+ GENBIND_NODE_TYPE_TYPE);
+
+ fprintf(binding->outfile,
+ "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
+ genbind_node_gettext(type_node));
+
+ fprintf(binding->outfile,
+ "{\n"
+ " return JS_FALSE;\n"
+ "}\n\n");
+
+ fprintf(binding->outfile,
+ "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
+ "{\n",
+ genbind_node_gettext(type_node));
+
+
+ return 0;
+}
+
+/* exported interface documented in jsapi-libdom.h */
+int
+output_property_body(struct binding *binding)
+{
+ int res;
+
+ res = generate_property_body(binding, binding->interface);
+
+ if (res == 0) {
+ res = genbind_node_for_each_type(binding->binding_list,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ unshared_property_cb,
+ binding);
+ }
+
+ return res;
+}
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index e83d0ee..0ac16e8 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -724,7 +724,7 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
return 9;
}
- res = output_property_body(binding, binding->interface);
+ res = output_property_body(binding);
if (res) {
return 10;
}
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index b397e67..86214f4 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -49,7 +49,7 @@ int output_operator_body(struct binding *binding, const char *interface);
int output_function_spec(struct binding *binding);
int output_property_spec(struct binding *binding);
-int output_property_body(struct binding *binding, const char *interface);
+int output_property_body(struct binding *binding);
int output_const_defines(struct binding *binding, const char *interface);
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
netsurf: branch master updated. a159a4a79b1facc77ae41983e9f96f8117f07f21
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/a159a4a79b1facc77ae41...
...commit http://git.netsurf-browser.org/netsurf.git/commit/a159a4a79b1facc77ae4198...
...tree http://git.netsurf-browser.org/netsurf.git/tree/a159a4a79b1facc77ae41983e...
The branch, master has been updated
via a159a4a79b1facc77ae41983e9f96f8117f07f21 (commit)
from 7757008433c414974c527c4745e64aa5976d606a (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/a159a4a79b1facc77ae...
commit a159a4a79b1facc77ae41983e9f96f8117f07f21
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
update JSAPI_PS() signature to cope with new nsgenbind
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index 8b7fe51..c100291 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -82,12 +82,12 @@
#define JS_SET_RVAL(cx, vp, v) (*(vp) = (v))
/* 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 }
@@ -187,11 +187,11 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
jsapi_property_##name##_set(cx, obj, jsval 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 , 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 }
@@ -284,19 +284,19 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
jsapi_property_##name##_set(cx, obj, jsid id, JSBool strict, 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 \
}
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi.h | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index 8b7fe51..c100291 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -82,12 +82,12 @@
#define JS_SET_RVAL(cx, vp, v) (*(vp) = (v))
/* 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 }
@@ -187,11 +187,11 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
jsapi_property_##name##_set(cx, obj, jsval 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 , 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 }
@@ -284,19 +284,19 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
jsapi_property_##name##_set(cx, obj, jsid id, JSBool strict, 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 \
}
--
NetSurf Browser
10 years, 6 months
nsgenjsbind: branch master updated. 841e93e4bc21729853e56b6d6b188d7b21450950
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/841e93e4bc2172985...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/841e93e4bc21729853e...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/841e93e4bc21729853e56...
The branch, master has been updated
via 841e93e4bc21729853e56b6d6b188d7b21450950 (commit)
via f2578192d04f4bc0ad70abaf070fffd5d1cf63ab (commit)
from 19f0eb49df62e8094d6c8fcd5f8d7522b07ec3d3 (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/841e93e4bc21729...
commit 841e93e4bc21729853e56b6d6b188d7b21450950
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
correctly generate setters and getters with unshared elements
changes signature of generated JSAPI_PS() macro
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index f97d352..a488058 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -30,22 +30,22 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
ident_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_IDENT);
- if (ident_node == NULL) {
+ ident = webidl_node_gettext(ident_node);
+ if (ident == NULL) {
/* properties must have an operator
* http://www.w3.org/TR/WebIDL/#idl-attributes
*/
return -1;
}
- ident = webidl_node_gettext(ident_node);
modifier_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_MODIFIER);
if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
- fprintf(binding->outfile, "\tJSAPI_PS_RO(");
+ fprintf(binding->outfile, "\tJSAPI_PS_RO(\"%s\", ", ident);
} else {
- fprintf(binding->outfile, "\tJSAPI_PS(");
+ fprintf(binding->outfile, "\tJSAPI_PS(\"%s\", ", ident);
}
unshared_node = genbind_node_find_type_ident(binding->binding_list,
@@ -499,44 +499,85 @@ static int output_property_getter(struct binding *binding,
return 0;
}
+static int output_property_setter(struct binding *binding,
+ struct webidl_node *node,
+ const char *ident)
+{
+ struct webidl_node *modifier_node;
+
+ modifier_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_MODIFIER);
+
+
+ if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
+ /* readonly so a set function is not required */
+ return 0;
+ }
+
+
+ fprintf(binding->outfile,
+ "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
+ ident);
+
+ fprintf(binding->outfile,
+ "{\n"
+ " return JS_FALSE;\n"
+ "}\n\n");
+
+
+ return 0;
+}
+
static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
struct webidl_node *ident_node;
- struct webidl_node *modifier_node;
+ const char *ident;
+ struct webidl_node *type_node;
+ int ret;
ident_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_IDENT);
- if (ident_node == NULL) {
+ ident = webidl_node_gettext(ident_node);
+ if (ident == NULL) {
/* properties must have an operator
* http://www.w3.org/TR/WebIDL/#idl-attributes
*/
- return 1;
+ return -1;
}
- modifier_node = webidl_node_find_type(webidl_node_getnode(node),
- NULL,
- WEBIDL_NODE_TYPE_MODIFIER);
-
+ /* do not generate individual getters/setters for an unshared type */
+ type_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_TYPE);
- if (webidl_node_getint(modifier_node) != WEBIDL_TYPE_READONLY) {
- /* no readonly so a set function is required */
+ ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
- fprintf(binding->outfile,
- "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
- webidl_node_gettext(ident_node));
- fprintf(binding->outfile,
- "{\n"
- " return JS_FALSE;\n"
- "}\n\n");
+ if (ident_node != NULL) {
+ struct genbind_node *unshared_node;
+ unshared_node = genbind_node_find_type_type(binding->binding_list,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ webidl_node_gettext(ident_node));
+ if (unshared_node != NULL) {
+ return 0;
+ }
}
- /* property getter */
- return output_property_getter(binding, node, webidl_node_gettext(ident_node));
+ ret = output_property_setter(binding, node, ident);
+ if (ret == 0) {
+ /* property getter */
+ ret = output_property_getter(binding, node, ident);
+ }
+ return ret;
}
+
/* callback to emit implements property bodys */
static int webidl_implements_cb(struct webidl_node *node, void *ctx)
{
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/f2578192d04f4bc...
commit f2578192d04f4bc0ad70abaf070fffd5d1cf63ab
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
keep the binding node list in the state object
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 9fbd281..f97d352 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -21,20 +21,12 @@
static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
- struct genbind_node *binding_node;
struct genbind_node *unshared_node;
struct webidl_node *type_node;
struct webidl_node *ident_node;
const char *ident;
struct webidl_node *modifier_node;
- binding_node = genbind_node_find_type(binding->gb_ast,
- NULL,
- GENBIND_NODE_TYPE_BINDING);
- if (binding_node == NULL) {
- return -1;
- }
-
ident_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_IDENT);
@@ -56,7 +48,7 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
fprintf(binding->outfile, "\tJSAPI_PS(");
}
- unshared_node = genbind_node_find_type_ident(genbind_node_getnode(binding_node),
+ unshared_node = genbind_node_find_type_ident(binding->binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_UNSHARED,
ident);
@@ -75,7 +67,7 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
WEBIDL_NODE_TYPE_IDENT);
if (ident_node != NULL) {
- unshared_node = genbind_node_find_type_type(genbind_node_getnode(binding_node),
+ unshared_node = genbind_node_find_type_type(binding->binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_UNSHARED,
webidl_node_gettext(ident_node));
@@ -601,7 +593,7 @@ output_property_body(struct binding *binding, const char *interface)
if (inherit_node != NULL) {
res = output_property_body(binding,
- webidl_node_gettext(inherit_node));
+ webidl_node_gettext(inherit_node));
}
if (res == 0) {
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index fb8080f..e83d0ee 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -292,19 +292,8 @@ static int
output_class_new(struct binding *binding)
{
int res = 0;
- struct genbind_node *binding_node;
struct genbind_node *api_node;
- binding_node = genbind_node_find(binding->gb_ast,
- NULL,
- genbind_cmp_node_type,
- (void *)GENBIND_NODE_TYPE_BINDING);
-
- if (binding_node == NULL) {
- return -1;
- }
-
-
/* constructor */
fprintf(binding->outfile,
"JSObject *jsapi_new_%s(JSContext *cx,\n"
@@ -312,7 +301,7 @@ output_class_new(struct binding *binding)
"\t\tJSObject *parent",
binding->interface);
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ genbind_node_for_each_type(binding->binding_list,
GENBIND_NODE_TYPE_BINDING_PRIVATE,
webidl_private_param_cb,
binding);
@@ -332,7 +321,7 @@ output_class_new(struct binding *binding)
"\t\treturn NULL;\n"
"\t}\n");
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ genbind_node_for_each_type(binding->binding_list,
GENBIND_NODE_TYPE_BINDING_PRIVATE,
webidl_private_assign_cb,
binding);
@@ -517,23 +506,13 @@ output_jsclass(struct binding *binding)
static int
output_private_declaration(struct binding *binding)
{
- struct genbind_node *binding_node;
struct genbind_node *type_node;
if (!binding->has_private) {
return 0;
}
- binding_node = genbind_node_find(binding->gb_ast,
- NULL,
- genbind_cmp_node_type,
- (void *)GENBIND_NODE_TYPE_BINDING);
-
- if (binding_node == NULL) {
- return -1;
- }
-
- type_node = genbind_node_find(genbind_node_getnode(binding_node),
+ type_node = genbind_node_find(binding->binding_list,
NULL,
genbind_cmp_node_type,
(void *)GENBIND_NODE_TYPE_TYPE);
@@ -544,12 +523,12 @@ output_private_declaration(struct binding *binding)
fprintf(binding->outfile, "struct jsclass_private {\n");
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ genbind_node_for_each_type(binding->binding_list,
GENBIND_NODE_TYPE_BINDING_PRIVATE,
webidl_private_cb,
binding);
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ genbind_node_for_each_type(binding->binding_list,
GENBIND_NODE_TYPE_BINDING_INTERNAL,
webidl_private_cb,
binding);
@@ -588,11 +567,11 @@ output_header_comments(struct binding *binding)
}
static bool
-binding_has_private(struct genbind_node *binding_node)
+binding_has_private(struct genbind_node *binding_list)
{
struct genbind_node *node;
- node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ node = genbind_node_find_type(binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_PRIVATE);
@@ -600,7 +579,7 @@ binding_has_private(struct genbind_node *binding_node)
return true;
}
- node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ node = genbind_node_find_type(binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_INTERNAL);
if (node != NULL) {
@@ -629,6 +608,7 @@ binding_new(char *outfilename, struct genbind_node *genbind_ast)
{
struct binding *nb;
struct genbind_node *binding_node;
+ struct genbind_node *binding_list;
struct genbind_node *ident_node;
struct genbind_node *interface_node;
FILE *outfile ; /* output file */
@@ -642,14 +622,19 @@ binding_new(char *outfilename, struct genbind_node *genbind_ast)
return NULL;
}
- ident_node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ binding_list = genbind_node_getnode(binding_node);
+ if (binding_list == NULL) {
+ return NULL;
+ }
+
+ ident_node = genbind_node_find_type(binding_list,
NULL,
GENBIND_NODE_TYPE_IDENT);
if (ident_node == NULL) {
return NULL;
}
- interface_node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ interface_node = genbind_node_find_type(binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_INTERFACE);
if (interface_node == NULL) {
@@ -683,8 +668,9 @@ binding_new(char *outfilename, struct genbind_node *genbind_ast)
nb->name = genbind_node_gettext(ident_node);
nb->interface = genbind_node_gettext(interface_node);
nb->outfile = outfile;
- nb->has_private = binding_has_private(binding_node);
+ nb->has_private = binding_has_private(binding_list);
nb->has_global = binding_has_global(nb);
+ nb->binding_list = binding_list;
nb->resolve = genbind_node_find_type_ident(genbind_ast,
NULL,
GENBIND_NODE_TYPE_API,
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index 8d005c8..b397e67 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -13,11 +13,13 @@ struct binding {
struct genbind_node *gb_ast; /* root node of binding AST */
struct webidl_node *wi_ast; /* root node of webidl AST */
+
const char *name; /* name of the binding */
const char *interface; /* webidl interface binding is for */
bool has_private; /* true if the binding requires a private structure */
bool has_global; /* true if the binding is for a global */
+ struct genbind_node *binding_list; /* node list of the binding */
struct genbind_node *resolve; /* binding api resolve node or NULL */
struct genbind_node *finalise; /* binding api finalise node or NULL */
struct genbind_node *mark; /* binding api mark node or NULL */
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-property.c | 99 ++++++++++++++++++++++++++++--------------
src/jsapi-libdom.c | 50 ++++++++--------------
src/jsapi-libdom.h | 2 +
3 files changed, 86 insertions(+), 65 deletions(-)
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 9fbd281..a488058 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -21,42 +21,34 @@
static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
- struct genbind_node *binding_node;
struct genbind_node *unshared_node;
struct webidl_node *type_node;
struct webidl_node *ident_node;
const char *ident;
struct webidl_node *modifier_node;
- binding_node = genbind_node_find_type(binding->gb_ast,
- NULL,
- GENBIND_NODE_TYPE_BINDING);
- if (binding_node == NULL) {
- return -1;
- }
-
ident_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_IDENT);
- if (ident_node == NULL) {
+ ident = webidl_node_gettext(ident_node);
+ if (ident == NULL) {
/* properties must have an operator
* http://www.w3.org/TR/WebIDL/#idl-attributes
*/
return -1;
}
- ident = webidl_node_gettext(ident_node);
modifier_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_MODIFIER);
if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
- fprintf(binding->outfile, "\tJSAPI_PS_RO(");
+ fprintf(binding->outfile, "\tJSAPI_PS_RO(\"%s\", ", ident);
} else {
- fprintf(binding->outfile, "\tJSAPI_PS(");
+ fprintf(binding->outfile, "\tJSAPI_PS(\"%s\", ", ident);
}
- unshared_node = genbind_node_find_type_ident(genbind_node_getnode(binding_node),
+ unshared_node = genbind_node_find_type_ident(binding->binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_UNSHARED,
ident);
@@ -75,7 +67,7 @@ static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
WEBIDL_NODE_TYPE_IDENT);
if (ident_node != NULL) {
- unshared_node = genbind_node_find_type_type(genbind_node_getnode(binding_node),
+ unshared_node = genbind_node_find_type_type(binding->binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_UNSHARED,
webidl_node_gettext(ident_node));
@@ -507,44 +499,85 @@ static int output_property_getter(struct binding *binding,
return 0;
}
+static int output_property_setter(struct binding *binding,
+ struct webidl_node *node,
+ const char *ident)
+{
+ struct webidl_node *modifier_node;
+
+ modifier_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_MODIFIER);
+
+
+ if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
+ /* readonly so a set function is not required */
+ return 0;
+ }
+
+
+ fprintf(binding->outfile,
+ "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
+ ident);
+
+ fprintf(binding->outfile,
+ "{\n"
+ " return JS_FALSE;\n"
+ "}\n\n");
+
+
+ return 0;
+}
+
static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
struct webidl_node *ident_node;
- struct webidl_node *modifier_node;
+ const char *ident;
+ struct webidl_node *type_node;
+ int ret;
ident_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
WEBIDL_NODE_TYPE_IDENT);
- if (ident_node == NULL) {
+ ident = webidl_node_gettext(ident_node);
+ if (ident == NULL) {
/* properties must have an operator
* http://www.w3.org/TR/WebIDL/#idl-attributes
*/
- return 1;
+ return -1;
}
- modifier_node = webidl_node_find_type(webidl_node_getnode(node),
- NULL,
- WEBIDL_NODE_TYPE_MODIFIER);
-
+ /* do not generate individual getters/setters for an unshared type */
+ type_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_TYPE);
- if (webidl_node_getint(modifier_node) != WEBIDL_TYPE_READONLY) {
- /* no readonly so a set function is required */
+ ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
- fprintf(binding->outfile,
- "static JSBool JSAPI_PROPERTYSET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
- webidl_node_gettext(ident_node));
- fprintf(binding->outfile,
- "{\n"
- " return JS_FALSE;\n"
- "}\n\n");
+ if (ident_node != NULL) {
+ struct genbind_node *unshared_node;
+ unshared_node = genbind_node_find_type_type(binding->binding_list,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ webidl_node_gettext(ident_node));
+ if (unshared_node != NULL) {
+ return 0;
+ }
}
- /* property getter */
- return output_property_getter(binding, node, webidl_node_gettext(ident_node));
+ ret = output_property_setter(binding, node, ident);
+ if (ret == 0) {
+ /* property getter */
+ ret = output_property_getter(binding, node, ident);
+ }
+ return ret;
}
+
/* callback to emit implements property bodys */
static int webidl_implements_cb(struct webidl_node *node, void *ctx)
{
@@ -601,7 +634,7 @@ output_property_body(struct binding *binding, const char *interface)
if (inherit_node != NULL) {
res = output_property_body(binding,
- webidl_node_gettext(inherit_node));
+ webidl_node_gettext(inherit_node));
}
if (res == 0) {
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index fb8080f..e83d0ee 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -292,19 +292,8 @@ static int
output_class_new(struct binding *binding)
{
int res = 0;
- struct genbind_node *binding_node;
struct genbind_node *api_node;
- binding_node = genbind_node_find(binding->gb_ast,
- NULL,
- genbind_cmp_node_type,
- (void *)GENBIND_NODE_TYPE_BINDING);
-
- if (binding_node == NULL) {
- return -1;
- }
-
-
/* constructor */
fprintf(binding->outfile,
"JSObject *jsapi_new_%s(JSContext *cx,\n"
@@ -312,7 +301,7 @@ output_class_new(struct binding *binding)
"\t\tJSObject *parent",
binding->interface);
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ genbind_node_for_each_type(binding->binding_list,
GENBIND_NODE_TYPE_BINDING_PRIVATE,
webidl_private_param_cb,
binding);
@@ -332,7 +321,7 @@ output_class_new(struct binding *binding)
"\t\treturn NULL;\n"
"\t}\n");
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ genbind_node_for_each_type(binding->binding_list,
GENBIND_NODE_TYPE_BINDING_PRIVATE,
webidl_private_assign_cb,
binding);
@@ -517,23 +506,13 @@ output_jsclass(struct binding *binding)
static int
output_private_declaration(struct binding *binding)
{
- struct genbind_node *binding_node;
struct genbind_node *type_node;
if (!binding->has_private) {
return 0;
}
- binding_node = genbind_node_find(binding->gb_ast,
- NULL,
- genbind_cmp_node_type,
- (void *)GENBIND_NODE_TYPE_BINDING);
-
- if (binding_node == NULL) {
- return -1;
- }
-
- type_node = genbind_node_find(genbind_node_getnode(binding_node),
+ type_node = genbind_node_find(binding->binding_list,
NULL,
genbind_cmp_node_type,
(void *)GENBIND_NODE_TYPE_TYPE);
@@ -544,12 +523,12 @@ output_private_declaration(struct binding *binding)
fprintf(binding->outfile, "struct jsclass_private {\n");
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ genbind_node_for_each_type(binding->binding_list,
GENBIND_NODE_TYPE_BINDING_PRIVATE,
webidl_private_cb,
binding);
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ genbind_node_for_each_type(binding->binding_list,
GENBIND_NODE_TYPE_BINDING_INTERNAL,
webidl_private_cb,
binding);
@@ -588,11 +567,11 @@ output_header_comments(struct binding *binding)
}
static bool
-binding_has_private(struct genbind_node *binding_node)
+binding_has_private(struct genbind_node *binding_list)
{
struct genbind_node *node;
- node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ node = genbind_node_find_type(binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_PRIVATE);
@@ -600,7 +579,7 @@ binding_has_private(struct genbind_node *binding_node)
return true;
}
- node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ node = genbind_node_find_type(binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_INTERNAL);
if (node != NULL) {
@@ -629,6 +608,7 @@ binding_new(char *outfilename, struct genbind_node *genbind_ast)
{
struct binding *nb;
struct genbind_node *binding_node;
+ struct genbind_node *binding_list;
struct genbind_node *ident_node;
struct genbind_node *interface_node;
FILE *outfile ; /* output file */
@@ -642,14 +622,19 @@ binding_new(char *outfilename, struct genbind_node *genbind_ast)
return NULL;
}
- ident_node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ binding_list = genbind_node_getnode(binding_node);
+ if (binding_list == NULL) {
+ return NULL;
+ }
+
+ ident_node = genbind_node_find_type(binding_list,
NULL,
GENBIND_NODE_TYPE_IDENT);
if (ident_node == NULL) {
return NULL;
}
- interface_node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ interface_node = genbind_node_find_type(binding_list,
NULL,
GENBIND_NODE_TYPE_BINDING_INTERFACE);
if (interface_node == NULL) {
@@ -683,8 +668,9 @@ binding_new(char *outfilename, struct genbind_node *genbind_ast)
nb->name = genbind_node_gettext(ident_node);
nb->interface = genbind_node_gettext(interface_node);
nb->outfile = outfile;
- nb->has_private = binding_has_private(binding_node);
+ nb->has_private = binding_has_private(binding_list);
nb->has_global = binding_has_global(nb);
+ nb->binding_list = binding_list;
nb->resolve = genbind_node_find_type_ident(genbind_ast,
NULL,
GENBIND_NODE_TYPE_API,
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index 8d005c8..b397e67 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -13,11 +13,13 @@ struct binding {
struct genbind_node *gb_ast; /* root node of binding AST */
struct webidl_node *wi_ast; /* root node of webidl AST */
+
const char *name; /* name of the binding */
const char *interface; /* webidl interface binding is for */
bool has_private; /* true if the binding requires a private structure */
bool has_global; /* true if the binding is for a global */
+ struct genbind_node *binding_list; /* node list of the binding */
struct genbind_node *resolve; /* binding api resolve node or NULL */
struct genbind_node *finalise; /* binding api finalise node or NULL */
struct genbind_node *mark; /* binding api mark node or NULL */
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
nsgenjsbind: branch master updated. 19f0eb49df62e8094d6c8fcd5f8d7522b07ec3d3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/19f0eb49df62e8094...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/19f0eb49df62e8094d6...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/19f0eb49df62e8094d6c8...
The branch, master has been updated
via 19f0eb49df62e8094d6c8fcd5f8d7522b07ec3d3 (commit)
via 6fdf1ace46adff8e9cd774fd7d8d06266996d51e (commit)
via e510204a381a7253d2cf69deeed01b043a4b80ad (commit)
from a044206384cb02aaaaab65f813878ddcd44b1dd1 (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/19f0eb49df62e80...
commit 19f0eb49df62e8094d6c8fcd5f8d7522b07ec3d3
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
implement unshared output in property specifier
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index d96228a..9fbd281 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -21,36 +21,83 @@
static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
+ struct genbind_node *binding_node;
+ struct genbind_node *unshared_node;
+ struct webidl_node *type_node;
struct webidl_node *ident_node;
+ const char *ident;
struct webidl_node *modifier_node;
- ident_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
-
- modifier_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_MODIFIER);
+ binding_node = genbind_node_find_type(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING);
+ if (binding_node == NULL) {
+ return -1;
+ }
+ ident_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
if (ident_node == NULL) {
/* properties must have an operator
* http://www.w3.org/TR/WebIDL/#idl-attributes
*/
- return 1;
+ return -1;
}
-
+ ident = webidl_node_gettext(ident_node);
+
+ modifier_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_MODIFIER);
+
if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
- fprintf(binding->outfile,
- "\tJSAPI_PS_RO(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
- webidl_node_gettext(ident_node));
+ fprintf(binding->outfile, "\tJSAPI_PS_RO(");
} else {
- fprintf(binding->outfile,
- "\tJSAPI_PS(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
- webidl_node_gettext(ident_node));
+ fprintf(binding->outfile, "\tJSAPI_PS(");
+ }
+
+ unshared_node = genbind_node_find_type_ident(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ ident);
+
+ if (unshared_node != NULL) {
+ /* not a shared property */
+ fprintf(binding->outfile, "%s, 0, JSPROP_ENUMERATE", ident);
+ } else {
+ /* examine if the property is of a unshared type */
+ type_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_TYPE);
+
+ ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
+
+ if (ident_node != NULL) {
+ unshared_node = genbind_node_find_type_type(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ webidl_node_gettext(ident_node));
+ }
+
+ if (unshared_node != NULL) {
+ /* property is not shared because of its type */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE",
+ webidl_node_gettext(ident_node));
+ } else {
+ /* property is shared
+ * js doesnt provide storage and setter/getter must
+ * perform all GC management.
+ */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
+ ident);
+ }
}
-
+ fprintf(binding->outfile, "),\n");
+
return 0;
}
@@ -303,14 +350,14 @@ static int output_return_declaration(struct binding *binding,
type_mod = webidl_node_find_type(webidl_node_getnode(type_node),
NULL,
WEBIDL_NODE_TYPE_MODIFIER);
- if ((type_mod != NULL) &&
+ if ((type_mod != NULL) &&
(webidl_node_getint(type_mod) == WEBIDL_TYPE_MODIFIER_UNSIGNED)) {
- fprintf(binding->outfile,
- "\tuint16_t %s = 0;\n",
+ fprintf(binding->outfile,
+ "\tuint16_t %s = 0;\n",
ident);
} else {
- fprintf(binding->outfile,
- "\tint16_t %s = 0;\n",
+ fprintf(binding->outfile,
+ "\tint16_t %s = 0;\n",
ident);
}
@@ -325,14 +372,14 @@ static int output_return_declaration(struct binding *binding,
type_mod = webidl_node_find_type(webidl_node_getnode(type_node),
NULL,
WEBIDL_NODE_TYPE_MODIFIER);
- if ((type_mod != NULL) &&
+ if ((type_mod != NULL) &&
(webidl_node_getint(type_mod) == WEBIDL_TYPE_MODIFIER_UNSIGNED)) {
- fprintf(binding->outfile,
- "\tuint32_t %s = 0;\n",
+ fprintf(binding->outfile,
+ "\tuint32_t %s = 0;\n",
ident);
} else {
- fprintf(binding->outfile,
- "\tint32_t %s = 0;\n",
+ fprintf(binding->outfile,
+ "\tint32_t %s = 0;\n",
ident);
}
@@ -368,14 +415,14 @@ static int output_return_declaration(struct binding *binding,
return 0;
}
-static int
-output_property_placeholder(struct binding *binding,
- struct webidl_node* oplist,
+static int
+output_property_placeholder(struct binding *binding,
+ struct webidl_node* oplist,
const char *ident)
{
oplist=oplist;
- WARN(WARNING_UNIMPLEMENTED,
+ WARN(WARNING_UNIMPLEMENTED,
"property %s.%s has no implementation\n",
binding->interface,
ident);
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index cb9f40d..8d005c8 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -10,8 +10,8 @@
#define nsgenbind_jsapi_libdom_h
struct binding {
- struct genbind_node *gb_ast;
- struct webidl_node *wi_ast;
+ struct genbind_node *gb_ast; /* root node of binding AST */
+ struct webidl_node *wi_ast; /* root node of webidl AST */
const char *name; /* name of the binding */
const char *interface; /* webidl interface binding is for */
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index 09ce8ce..a8a8361 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -118,7 +118,7 @@ genbind_node_find(struct genbind_node *node,
return NULL;
}
-/* exported interface defined in nsgenbind-ast.h */
+/* exported interface documented in nsgenbind-ast.h */
struct genbind_node *
genbind_node_find_type(struct genbind_node *node,
struct genbind_node *prev,
@@ -130,6 +130,7 @@ genbind_node_find_type(struct genbind_node *node,
(void *)type);
}
+/* exported interface documented in nsgenbind-ast.h */
struct genbind_node *
genbind_node_find_type_ident(struct genbind_node *node,
struct genbind_node *prev,
@@ -143,7 +144,7 @@ genbind_node_find_type_ident(struct genbind_node *node,
while (found_node != NULL) {
-
+ /* look for an ident node */
ident_node = genbind_node_find_type(genbind_node_getnode(found_node),
NULL,
GENBIND_NODE_TYPE_IDENT);
@@ -154,7 +155,35 @@ genbind_node_find_type_ident(struct genbind_node *node,
/* look for next matching node */
found_node = genbind_node_find_type(node, found_node, type);
+ }
+ return found_node;
+}
+
+/* exported interface documented in nsgenbind-ast.h */
+struct genbind_node *
+genbind_node_find_type_type(struct genbind_node *node,
+ struct genbind_node *prev,
+ enum genbind_node_type type,
+ const char *ident)
+{
+ struct genbind_node *found_node;
+ struct genbind_node *ident_node;
+ found_node = genbind_node_find_type(node, prev, type);
+
+
+ while (found_node != NULL) {
+ /* look for a type node */
+ ident_node = genbind_node_find_type(genbind_node_getnode(found_node),
+ NULL,
+ GENBIND_NODE_TYPE_TYPE);
+ if (ident_node != NULL) {
+ if (strcmp(ident_node->r.text, ident) == 0)
+ break;
+ }
+
+ /* look for next matching node */
+ found_node = genbind_node_find_type(node, found_node, type);
}
return found_node;
}
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index 5ae21b4..544582c 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -52,7 +52,6 @@ int genbind_ast_dump(struct genbind_node *ast, int indent);
/** Depth first left hand search using user provided comparison
*
* @param node The node to start the search from
-
* @param prev The node at which to stop the search, either NULL to
* search the full tree depth (initial search) or the result
* of a previous search to continue.
@@ -65,17 +64,51 @@ genbind_node_find(struct genbind_node *node,
genbind_callback_t *cb,
void *ctx);
+/** Depth first left hand search returning nodes of the specified type
+ *
+ * @param node The node to start the search from
+ * @param prev The node at which to stop the search, either NULL to
+ * search the full tree depth (initial search) or the result
+ * of a previous search to continue.
+ * @param nodetype The type of node to seach for
+ */
struct genbind_node *
genbind_node_find_type(struct genbind_node *node,
struct genbind_node *prev,
- enum genbind_node_type type);
+ enum genbind_node_type nodetype);
+/** Depth first left hand search returning nodes of the specified type
+ * and a ident child node with matching text
+ *
+ * @param node The node to start the search from
+ * @param prev The node at which to stop the search, either NULL to
+ * search the full tree depth (initial search) or the result
+ * of a previous search to continue.
+ * @param nodetype The type of node to seach for
+ * @param ident The text to match the ident child node to
+ */
struct genbind_node *
genbind_node_find_type_ident(struct genbind_node *node,
struct genbind_node *prev,
- enum genbind_node_type type,
+ enum genbind_node_type nodetype,
const char *ident);
+/** Depth first left hand search returning nodes of the specified type
+ * and a type child node with matching text
+ *
+ * @param node The node to start the search from
+ * @param prev The node at which to stop the search, either NULL to
+ * search the full tree depth (initial search) or the result
+ * of a previous search to continue.
+ * @param nodetype The type of node to seach for
+ * @param type The text to match the type child node to
+ */
+struct genbind_node *
+genbind_node_find_type_type(struct genbind_node *node,
+ struct genbind_node *prev,
+ enum genbind_node_type nodetype,
+ const char *type);
+
int genbind_node_for_each_type(struct genbind_node *node, enum genbind_node_type type, genbind_callback_t *cb, void *ctx);
char *genbind_node_gettext(struct genbind_node *node);
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index bc4ab01..ba9d44f 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -214,15 +214,19 @@ webidl_node_find_type_ident(struct webidl_node *root_node,
char *webidl_node_gettext(struct webidl_node *node)
{
- switch(node->type) {
- case WEBIDL_NODE_TYPE_IDENT:
- case WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE:
- case WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS:
- return node->r.text;
+ if (node != NULL) {
- default:
- return NULL;
+ switch(node->type) {
+ case WEBIDL_NODE_TYPE_IDENT:
+ case WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE:
+ case WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS:
+ return node->r.text;
+
+ default:
+ break;
+ }
}
+ return NULL;
}
int
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/6fdf1ace46adff8...
commit 6fdf1ace46adff8e9cd774fd7d8d06266996d51e
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
allow unshared parameter to accept property names as well as types
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index e64d255..6364bf7 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -301,5 +301,11 @@ Unshared
$$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_UNSHARED, NULL,
genbind_new_node(GENBIND_NODE_TYPE_TYPE, NULL, $3));
}
+ |
+ TOK_UNSHARED TOK_IDENTIFIER ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_UNSHARED, NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT, NULL, $2));
+ }
;
%%
diff --git a/test/data/bindings/window.bnd b/test/data/bindings/window.bnd
index b843aaf..42b40f4 100644
--- a/test/data/bindings/window.bnd
+++ b/test/data/bindings/window.bnd
@@ -32,6 +32,7 @@ binding window {
internal "JSObject *" location;
unshared type EventHandler;
+ unshared foo;
}
api mark %{
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/e510204a381a725...
commit e510204a381a7253d2cf69deeed01b043a4b80ad
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
add unshared option
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index df36be8..fb8080f 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -536,7 +536,7 @@ output_private_declaration(struct binding *binding)
type_node = genbind_node_find(genbind_node_getnode(binding_node),
NULL,
genbind_cmp_node_type,
- (void *)GENBIND_NODE_TYPE_BINDING_TYPE);
+ (void *)GENBIND_NODE_TYPE_TYPE);
if (type_node == NULL) {
return -1;
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index 52febaa..09ce8ce 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -173,7 +173,7 @@ char *genbind_node_gettext(struct genbind_node *node)
case GENBIND_NODE_TYPE_STRING:
case GENBIND_NODE_TYPE_PREAMBLE:
case GENBIND_NODE_TYPE_IDENT:
- case GENBIND_NODE_TYPE_BINDING_TYPE:
+ case GENBIND_NODE_TYPE_TYPE:
case GENBIND_NODE_TYPE_BINDING_INTERFACE:
case GENBIND_NODE_TYPE_CBLOCK:
return node->r.text;
@@ -190,6 +190,7 @@ struct genbind_node *genbind_node_getnode(struct genbind_node *node)
case GENBIND_NODE_TYPE_BINDING:
case GENBIND_NODE_TYPE_BINDING_PRIVATE:
case GENBIND_NODE_TYPE_BINDING_INTERNAL:
+ case GENBIND_NODE_TYPE_BINDING_UNSHARED:
case GENBIND_NODE_TYPE_OPERATION:
case GENBIND_NODE_TYPE_API:
case GENBIND_NODE_TYPE_GETTER:
@@ -225,7 +226,7 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_BINDING:
return "Binding";
- case GENBIND_NODE_TYPE_BINDING_TYPE:
+ case GENBIND_NODE_TYPE_TYPE:
return "Type";
case GENBIND_NODE_TYPE_BINDING_PRIVATE:
@@ -237,6 +238,9 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_BINDING_INTERFACE:
return "Interface";
+ case GENBIND_NODE_TYPE_BINDING_UNSHARED:
+ return "Unshared";
+
case GENBIND_NODE_TYPE_OPERATION:
return "Operation";
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index 54a49d2..5ae21b4 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -11,17 +11,19 @@
enum genbind_node_type {
GENBIND_NODE_TYPE_ROOT = 0,
- GENBIND_NODE_TYPE_IDENT,
+ GENBIND_NODE_TYPE_IDENT, /* generic identifier string */
+ GENBIND_NODE_TYPE_TYPE, /* generic type string */
+
GENBIND_NODE_TYPE_CBLOCK,
GENBIND_NODE_TYPE_WEBIDLFILE,
GENBIND_NODE_TYPE_HDRCOMMENT,
GENBIND_NODE_TYPE_STRING,
GENBIND_NODE_TYPE_PREAMBLE,
GENBIND_NODE_TYPE_BINDING,
- GENBIND_NODE_TYPE_BINDING_TYPE,
GENBIND_NODE_TYPE_BINDING_PRIVATE,
GENBIND_NODE_TYPE_BINDING_INTERNAL,
GENBIND_NODE_TYPE_BINDING_INTERFACE,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
GENBIND_NODE_TYPE_API,
GENBIND_NODE_TYPE_OPERATION,
GENBIND_NODE_TYPE_GETTER,
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index 61aee7e..aea68ee 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -96,6 +96,8 @@ private return TOK_PRIVATE;
internal return TOK_INTERNAL;
+unshared return TOK_UNSHARED;
+
operation return TOK_OPERATION;
api return TOK_API;
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index 1ffab7a..e64d255 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -51,6 +51,7 @@ char *errtxt;
%token TOK_TYPE
%token TOK_PRIVATE
%token TOK_INTERNAL
+%token TOK_UNSHARED
%token <text> TOK_IDENTIFIER
%token <text> TOK_STRING_LITERAL
@@ -71,6 +72,7 @@ char *errtxt;
%type <node> Private
%type <node> Internal
%type <node> Interface
+%type <node> Unshared
%type <node> Operation
%type <node> Api
%type <node> Getter
@@ -252,13 +254,15 @@ BindingArg
Internal
|
Interface
+ |
+ Unshared
;
Type
:
TOK_TYPE TOK_IDENTIFIER ';'
{
- $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_TYPE, NULL, $2);
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE, NULL, $2);
}
;
@@ -290,4 +294,12 @@ Interface
}
;
+Unshared
+ :
+ TOK_UNSHARED TOK_TYPE TOK_IDENTIFIER ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_UNSHARED, NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_TYPE, NULL, $3));
+ }
+ ;
%%
diff --git a/test/data/bindings/window.bnd b/test/data/bindings/window.bnd
index 956932c..b843aaf 100644
--- a/test/data/bindings/window.bnd
+++ b/test/data/bindings/window.bnd
@@ -23,21 +23,36 @@ 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;
+
+ unshared type EventHandler;
}
+api mark %{
+ if (private != NULL) {
+ if (private->document != NULL) {
+ JSAPI_GCMARK(private->document);
+ }
+ if (private->navigator != NULL) {
+ JSAPI_GCMARK(private->navigator);
+ }
+ if (private->console != NULL) {
+ JSAPI_GCMARK(private->console);
+ }
+ if (private->location != NULL) {
+ JSAPI_GCMARK(private->location);
+ }
+ }
+%}
+
+api global %{
+%}
api init %{
JSObject *user_proto;
@@ -101,6 +116,26 @@ api init %{
return NULL;
}
+ user_proto = jsapi_InitClass_HTMLCollection(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
+ user_proto = jsapi_InitClass_NodeList(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
+ user_proto = jsapi_InitClass_Text(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
+ user_proto = jsapi_InitClass_Node(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
%}
api new %{
@@ -114,7 +149,7 @@ api new %{
private->document = jsapi_new_Document(cx,
NULL,
newobject,
- htmlc->document,
+ (dom_document *)dom_node_ref(htmlc->document),
htmlc);
if (private->document == NULL) {
free(private);
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-property.c | 111 +++++++++++++++++++++++++++++------------
src/jsapi-libdom.c | 2 +-
src/jsapi-libdom.h | 4 +-
src/nsgenbind-ast.c | 41 ++++++++++++++--
src/nsgenbind-ast.h | 45 +++++++++++++++--
src/nsgenbind-lexer.l | 2 +
src/nsgenbind-parser.y | 20 +++++++-
src/webidl-ast.c | 18 ++++---
test/data/bindings/window.bnd | 52 ++++++++++++++++---
9 files changed, 235 insertions(+), 60 deletions(-)
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index d96228a..9fbd281 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -21,36 +21,83 @@
static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
+ struct genbind_node *binding_node;
+ struct genbind_node *unshared_node;
+ struct webidl_node *type_node;
struct webidl_node *ident_node;
+ const char *ident;
struct webidl_node *modifier_node;
- ident_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
-
- modifier_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_MODIFIER);
+ binding_node = genbind_node_find_type(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING);
+ if (binding_node == NULL) {
+ return -1;
+ }
+ ident_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
if (ident_node == NULL) {
/* properties must have an operator
* http://www.w3.org/TR/WebIDL/#idl-attributes
*/
- return 1;
+ return -1;
}
-
+ ident = webidl_node_gettext(ident_node);
+
+ modifier_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_MODIFIER);
+
if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
- fprintf(binding->outfile,
- "\tJSAPI_PS_RO(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
- webidl_node_gettext(ident_node));
+ fprintf(binding->outfile, "\tJSAPI_PS_RO(");
} else {
- fprintf(binding->outfile,
- "\tJSAPI_PS(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
- webidl_node_gettext(ident_node));
+ fprintf(binding->outfile, "\tJSAPI_PS(");
+ }
+
+ unshared_node = genbind_node_find_type_ident(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ ident);
+
+ if (unshared_node != NULL) {
+ /* not a shared property */
+ fprintf(binding->outfile, "%s, 0, JSPROP_ENUMERATE", ident);
+ } else {
+ /* examine if the property is of a unshared type */
+ type_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_TYPE);
+
+ ident_node = webidl_node_find_type(webidl_node_getnode(type_node),
+ NULL,
+ WEBIDL_NODE_TYPE_IDENT);
+
+ if (ident_node != NULL) {
+ unshared_node = genbind_node_find_type_type(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
+ webidl_node_gettext(ident_node));
+ }
+
+ if (unshared_node != NULL) {
+ /* property is not shared because of its type */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE",
+ webidl_node_gettext(ident_node));
+ } else {
+ /* property is shared
+ * js doesnt provide storage and setter/getter must
+ * perform all GC management.
+ */
+ fprintf(binding->outfile,
+ "%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED",
+ ident);
+ }
}
-
+ fprintf(binding->outfile, "),\n");
+
return 0;
}
@@ -303,14 +350,14 @@ static int output_return_declaration(struct binding *binding,
type_mod = webidl_node_find_type(webidl_node_getnode(type_node),
NULL,
WEBIDL_NODE_TYPE_MODIFIER);
- if ((type_mod != NULL) &&
+ if ((type_mod != NULL) &&
(webidl_node_getint(type_mod) == WEBIDL_TYPE_MODIFIER_UNSIGNED)) {
- fprintf(binding->outfile,
- "\tuint16_t %s = 0;\n",
+ fprintf(binding->outfile,
+ "\tuint16_t %s = 0;\n",
ident);
} else {
- fprintf(binding->outfile,
- "\tint16_t %s = 0;\n",
+ fprintf(binding->outfile,
+ "\tint16_t %s = 0;\n",
ident);
}
@@ -325,14 +372,14 @@ static int output_return_declaration(struct binding *binding,
type_mod = webidl_node_find_type(webidl_node_getnode(type_node),
NULL,
WEBIDL_NODE_TYPE_MODIFIER);
- if ((type_mod != NULL) &&
+ if ((type_mod != NULL) &&
(webidl_node_getint(type_mod) == WEBIDL_TYPE_MODIFIER_UNSIGNED)) {
- fprintf(binding->outfile,
- "\tuint32_t %s = 0;\n",
+ fprintf(binding->outfile,
+ "\tuint32_t %s = 0;\n",
ident);
} else {
- fprintf(binding->outfile,
- "\tint32_t %s = 0;\n",
+ fprintf(binding->outfile,
+ "\tint32_t %s = 0;\n",
ident);
}
@@ -368,14 +415,14 @@ static int output_return_declaration(struct binding *binding,
return 0;
}
-static int
-output_property_placeholder(struct binding *binding,
- struct webidl_node* oplist,
+static int
+output_property_placeholder(struct binding *binding,
+ struct webidl_node* oplist,
const char *ident)
{
oplist=oplist;
- WARN(WARNING_UNIMPLEMENTED,
+ WARN(WARNING_UNIMPLEMENTED,
"property %s.%s has no implementation\n",
binding->interface,
ident);
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index df36be8..fb8080f 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -536,7 +536,7 @@ output_private_declaration(struct binding *binding)
type_node = genbind_node_find(genbind_node_getnode(binding_node),
NULL,
genbind_cmp_node_type,
- (void *)GENBIND_NODE_TYPE_BINDING_TYPE);
+ (void *)GENBIND_NODE_TYPE_TYPE);
if (type_node == NULL) {
return -1;
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index cb9f40d..8d005c8 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -10,8 +10,8 @@
#define nsgenbind_jsapi_libdom_h
struct binding {
- struct genbind_node *gb_ast;
- struct webidl_node *wi_ast;
+ struct genbind_node *gb_ast; /* root node of binding AST */
+ struct webidl_node *wi_ast; /* root node of webidl AST */
const char *name; /* name of the binding */
const char *interface; /* webidl interface binding is for */
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index 52febaa..a8a8361 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -118,7 +118,7 @@ genbind_node_find(struct genbind_node *node,
return NULL;
}
-/* exported interface defined in nsgenbind-ast.h */
+/* exported interface documented in nsgenbind-ast.h */
struct genbind_node *
genbind_node_find_type(struct genbind_node *node,
struct genbind_node *prev,
@@ -130,6 +130,7 @@ genbind_node_find_type(struct genbind_node *node,
(void *)type);
}
+/* exported interface documented in nsgenbind-ast.h */
struct genbind_node *
genbind_node_find_type_ident(struct genbind_node *node,
struct genbind_node *prev,
@@ -143,7 +144,7 @@ genbind_node_find_type_ident(struct genbind_node *node,
while (found_node != NULL) {
-
+ /* look for an ident node */
ident_node = genbind_node_find_type(genbind_node_getnode(found_node),
NULL,
GENBIND_NODE_TYPE_IDENT);
@@ -154,7 +155,35 @@ genbind_node_find_type_ident(struct genbind_node *node,
/* look for next matching node */
found_node = genbind_node_find_type(node, found_node, type);
+ }
+ return found_node;
+}
+
+/* exported interface documented in nsgenbind-ast.h */
+struct genbind_node *
+genbind_node_find_type_type(struct genbind_node *node,
+ struct genbind_node *prev,
+ enum genbind_node_type type,
+ const char *ident)
+{
+ struct genbind_node *found_node;
+ struct genbind_node *ident_node;
+ found_node = genbind_node_find_type(node, prev, type);
+
+
+ while (found_node != NULL) {
+ /* look for a type node */
+ ident_node = genbind_node_find_type(genbind_node_getnode(found_node),
+ NULL,
+ GENBIND_NODE_TYPE_TYPE);
+ if (ident_node != NULL) {
+ if (strcmp(ident_node->r.text, ident) == 0)
+ break;
+ }
+
+ /* look for next matching node */
+ found_node = genbind_node_find_type(node, found_node, type);
}
return found_node;
}
@@ -173,7 +202,7 @@ char *genbind_node_gettext(struct genbind_node *node)
case GENBIND_NODE_TYPE_STRING:
case GENBIND_NODE_TYPE_PREAMBLE:
case GENBIND_NODE_TYPE_IDENT:
- case GENBIND_NODE_TYPE_BINDING_TYPE:
+ case GENBIND_NODE_TYPE_TYPE:
case GENBIND_NODE_TYPE_BINDING_INTERFACE:
case GENBIND_NODE_TYPE_CBLOCK:
return node->r.text;
@@ -190,6 +219,7 @@ struct genbind_node *genbind_node_getnode(struct genbind_node *node)
case GENBIND_NODE_TYPE_BINDING:
case GENBIND_NODE_TYPE_BINDING_PRIVATE:
case GENBIND_NODE_TYPE_BINDING_INTERNAL:
+ case GENBIND_NODE_TYPE_BINDING_UNSHARED:
case GENBIND_NODE_TYPE_OPERATION:
case GENBIND_NODE_TYPE_API:
case GENBIND_NODE_TYPE_GETTER:
@@ -225,7 +255,7 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_BINDING:
return "Binding";
- case GENBIND_NODE_TYPE_BINDING_TYPE:
+ case GENBIND_NODE_TYPE_TYPE:
return "Type";
case GENBIND_NODE_TYPE_BINDING_PRIVATE:
@@ -237,6 +267,9 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_BINDING_INTERFACE:
return "Interface";
+ case GENBIND_NODE_TYPE_BINDING_UNSHARED:
+ return "Unshared";
+
case GENBIND_NODE_TYPE_OPERATION:
return "Operation";
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index 54a49d2..544582c 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -11,17 +11,19 @@
enum genbind_node_type {
GENBIND_NODE_TYPE_ROOT = 0,
- GENBIND_NODE_TYPE_IDENT,
+ GENBIND_NODE_TYPE_IDENT, /* generic identifier string */
+ GENBIND_NODE_TYPE_TYPE, /* generic type string */
+
GENBIND_NODE_TYPE_CBLOCK,
GENBIND_NODE_TYPE_WEBIDLFILE,
GENBIND_NODE_TYPE_HDRCOMMENT,
GENBIND_NODE_TYPE_STRING,
GENBIND_NODE_TYPE_PREAMBLE,
GENBIND_NODE_TYPE_BINDING,
- GENBIND_NODE_TYPE_BINDING_TYPE,
GENBIND_NODE_TYPE_BINDING_PRIVATE,
GENBIND_NODE_TYPE_BINDING_INTERNAL,
GENBIND_NODE_TYPE_BINDING_INTERFACE,
+ GENBIND_NODE_TYPE_BINDING_UNSHARED,
GENBIND_NODE_TYPE_API,
GENBIND_NODE_TYPE_OPERATION,
GENBIND_NODE_TYPE_GETTER,
@@ -50,7 +52,6 @@ int genbind_ast_dump(struct genbind_node *ast, int indent);
/** Depth first left hand search using user provided comparison
*
* @param node The node to start the search from
-
* @param prev The node at which to stop the search, either NULL to
* search the full tree depth (initial search) or the result
* of a previous search to continue.
@@ -63,17 +64,51 @@ genbind_node_find(struct genbind_node *node,
genbind_callback_t *cb,
void *ctx);
+/** Depth first left hand search returning nodes of the specified type
+ *
+ * @param node The node to start the search from
+ * @param prev The node at which to stop the search, either NULL to
+ * search the full tree depth (initial search) or the result
+ * of a previous search to continue.
+ * @param nodetype The type of node to seach for
+ */
struct genbind_node *
genbind_node_find_type(struct genbind_node *node,
struct genbind_node *prev,
- enum genbind_node_type type);
+ enum genbind_node_type nodetype);
+/** Depth first left hand search returning nodes of the specified type
+ * and a ident child node with matching text
+ *
+ * @param node The node to start the search from
+ * @param prev The node at which to stop the search, either NULL to
+ * search the full tree depth (initial search) or the result
+ * of a previous search to continue.
+ * @param nodetype The type of node to seach for
+ * @param ident The text to match the ident child node to
+ */
struct genbind_node *
genbind_node_find_type_ident(struct genbind_node *node,
struct genbind_node *prev,
- enum genbind_node_type type,
+ enum genbind_node_type nodetype,
const char *ident);
+/** Depth first left hand search returning nodes of the specified type
+ * and a type child node with matching text
+ *
+ * @param node The node to start the search from
+ * @param prev The node at which to stop the search, either NULL to
+ * search the full tree depth (initial search) or the result
+ * of a previous search to continue.
+ * @param nodetype The type of node to seach for
+ * @param type The text to match the type child node to
+ */
+struct genbind_node *
+genbind_node_find_type_type(struct genbind_node *node,
+ struct genbind_node *prev,
+ enum genbind_node_type nodetype,
+ const char *type);
+
int genbind_node_for_each_type(struct genbind_node *node, enum genbind_node_type type, genbind_callback_t *cb, void *ctx);
char *genbind_node_gettext(struct genbind_node *node);
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index 61aee7e..aea68ee 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -96,6 +96,8 @@ private return TOK_PRIVATE;
internal return TOK_INTERNAL;
+unshared return TOK_UNSHARED;
+
operation return TOK_OPERATION;
api return TOK_API;
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index 1ffab7a..6364bf7 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -51,6 +51,7 @@ char *errtxt;
%token TOK_TYPE
%token TOK_PRIVATE
%token TOK_INTERNAL
+%token TOK_UNSHARED
%token <text> TOK_IDENTIFIER
%token <text> TOK_STRING_LITERAL
@@ -71,6 +72,7 @@ char *errtxt;
%type <node> Private
%type <node> Internal
%type <node> Interface
+%type <node> Unshared
%type <node> Operation
%type <node> Api
%type <node> Getter
@@ -252,13 +254,15 @@ BindingArg
Internal
|
Interface
+ |
+ Unshared
;
Type
:
TOK_TYPE TOK_IDENTIFIER ';'
{
- $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_TYPE, NULL, $2);
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE, NULL, $2);
}
;
@@ -290,4 +294,18 @@ Interface
}
;
+Unshared
+ :
+ TOK_UNSHARED TOK_TYPE TOK_IDENTIFIER ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_UNSHARED, NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_TYPE, NULL, $3));
+ }
+ |
+ TOK_UNSHARED TOK_IDENTIFIER ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_UNSHARED, NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT, NULL, $2));
+ }
+ ;
%%
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index bc4ab01..ba9d44f 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -214,15 +214,19 @@ webidl_node_find_type_ident(struct webidl_node *root_node,
char *webidl_node_gettext(struct webidl_node *node)
{
- switch(node->type) {
- case WEBIDL_NODE_TYPE_IDENT:
- case WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE:
- case WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS:
- return node->r.text;
+ if (node != NULL) {
- default:
- return NULL;
+ switch(node->type) {
+ case WEBIDL_NODE_TYPE_IDENT:
+ case WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE:
+ case WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS:
+ return node->r.text;
+
+ default:
+ break;
+ }
}
+ return NULL;
}
int
diff --git a/test/data/bindings/window.bnd b/test/data/bindings/window.bnd
index 956932c..42b40f4 100644
--- a/test/data/bindings/window.bnd
+++ b/test/data/bindings/window.bnd
@@ -23,21 +23,37 @@ 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;
+
+ unshared type EventHandler;
+ unshared foo;
}
+api mark %{
+ if (private != NULL) {
+ if (private->document != NULL) {
+ JSAPI_GCMARK(private->document);
+ }
+ if (private->navigator != NULL) {
+ JSAPI_GCMARK(private->navigator);
+ }
+ if (private->console != NULL) {
+ JSAPI_GCMARK(private->console);
+ }
+ if (private->location != NULL) {
+ JSAPI_GCMARK(private->location);
+ }
+ }
+%}
+
+api global %{
+%}
api init %{
JSObject *user_proto;
@@ -101,6 +117,26 @@ api init %{
return NULL;
}
+ user_proto = jsapi_InitClass_HTMLCollection(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
+ user_proto = jsapi_InitClass_NodeList(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
+ user_proto = jsapi_InitClass_Text(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
+ user_proto = jsapi_InitClass_Node(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
%}
api new %{
@@ -114,7 +150,7 @@ api new %{
private->document = jsapi_new_Document(cx,
NULL,
newobject,
- htmlc->document,
+ (dom_document *)dom_node_ref(htmlc->document),
htmlc);
if (private->document == NULL) {
free(private);
--
NetSurf Generator for JavaScript bindings
10 years, 6 months
netsurf: branch mono/removing-windom-dependency updated. 7e94f32e4c99ced99ab4efaef1e56ad96430fb40
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7e94f32e4c99ced99ab4e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7e94f32e4c99ced99ab4efa...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7e94f32e4c99ced99ab4efaef...
The branch, mono/removing-windom-dependency has been updated
via 7e94f32e4c99ced99ab4efaef1e56ad96430fb40 (commit)
from 5449303bd1bf27e4cc8baccb0985e4d52c563caf (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/7e94f32e4c99ced99ab...
commit 7e94f32e4c99ced99ab4efaef1e56ad96430fb40
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Initial work at making scrolling work
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index 5e0f5c4..4128715 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -84,6 +84,7 @@ enum guwin_area_e {
};
short guiwin_init(void);
+void guiwin_exit(void);
GUIWIN * guiwin_add(short handle, uint32_t flags,
guiwin_event_handler_f handler);
GUIWIN *guiwin_find(short handle);
@@ -99,11 +100,13 @@ void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx,
void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb);
void guiwin_set_user_data(GUIWIN *win, void *data);
void *guiwin_get_user_data(GUIWIN *win);
-struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win);
+struct guiwin_scroll_info_s * guiwin_get_scroll_info(GUIWIN *win);
void guiwin_update_slider(GUIWIN *win, short mode);
+void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
+
/*
* AES Scroller Object
*/
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index fa496bf..e055aba 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -27,64 +27,92 @@ static GUIWIN * winlist;
static VdiHdl v_vdi_h = -1;
static short work_out[57];
+static void move_screen( int vhandle, GRECT *screen, int dx, int dy) {
+ INT16 xy[ 8];
+ long dum = 0L;
+ GRECT g;
+
+ /* get intersection with screen area */
+ wind_get_grect(0, WF_CURRXYWH, &g);
+ rc_intersect(&g, screen);
+ xy[ 0] = screen -> g_x;
+ xy[ 1] = screen -> g_y;
+ xy[ 2] = xy[ 0] + screen -> g_w - 1;
+ xy[ 3] = xy[ 1] + screen -> g_h - 1;
+ xy[ 4] = xy[ 0] + dx;
+ xy[ 5] = xy[ 1] + dy;
+ xy[ 6] = xy[ 2] + dx;
+ xy[ 7] = xy[ 3] + dy;
+ vro_cpyfm( vhandle, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
+}
+
static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
- GRECT g, tb_area, tb_area_ro;
+ GRECT g, g_ro, tb_area, tb_area_ro;
short retval = 1;
int val;
struct guiwin_scroll_info_s *slid;
switch(msg[0]) {
- case WM_ARROWED:
- if((gw->flag & GW_FLAG_CUSTOM_SCROLLING) == 0){
-
- slid = guiwin_get_scroll_info(win);
-
- switch(msg[4]){
- case WA_DNPAGE:
- guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &g);
- val = g.g_h;
- // complete redraw
- // increase scroll val by page size...
- break;
-
- case WA_UPLINE:
- slid->g_y = MAX(0, slid->g_y-1);
- // partial redraw
- break;
-
- case WA_DNLINE:
- slid->g_y = MIN(slid->y_pos_max, slid->g_y+1);
- // move content up by unit size and sched redraw for the
- // bottom 16 px
- // partial redraw
- break;
-
- case WA_LFPAGE:
- // complete redraw
- // increase scroll val by page size...
- break;
-
- case WA_RTPAGE:
- // complete redraw
- // increase scroll val by page size...
- break;
-
- case WA_LFLINE:
- slid->g_x = MAX(0, slid->g_x-1);
- // partial redraw
- break;
-
- case WA_RTLINE:
- slid->g_x = MIN(slid->x_pos_max, slid->g_x+1);
- // partial redraw
- break;
-
- default: break;
- }
- }
- break;
+ case WM_ARROWED:
+ if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) {
+
+ slid = guiwin_get_scroll_info(gw);
+ guiwin_get_grect(gw, GUIWIN_AREA_CONTENT, &g);
+ g_ro = g;
+
+ switch(msg[4]) {
+ case WA_DNPAGE:
+
+ val = g.g_h;
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_UPLINE:
+ slid->y_pos = MAX(0, slid->y_pos-1);
+ // partial redraw
+ break;
+
+ case WA_DNLINE:
+ slid->y_pos = MIN(slid->y_pos_max, slid->y_pos+1);
+ g.g_y += slid->y_unit_px;
+ g.g_h -= slid->y_unit_px;
+ move_screen(v_vdi_h, &g, 0, -slid->y_unit_px);
+ g.g_y = g_ro.g_y + g_ro.g_h - slid->y_unit_px;
+ g.g_h = slid->y_unit_px;
+ guiwin_send_redraw(gw, &g);
+ // move content up by unit size and sched redraw for the
+ // bottom 16 px
+ // partial redraw
+ break;
+
+ case WA_LFPAGE:
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_RTPAGE:
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_LFLINE:
+ slid->x_pos = MAX(0, slid->x_pos-1);
+ // partial redraw
+ break;
+
+ case WA_RTLINE:
+ slid->x_pos = MIN(slid->x_pos_max, slid->x_pos+1);
+ // partial redraw
+ break;
+
+ default:
+ break;
+ }
+ }
+ break;
case WM_TOPPED:
wind_set(gw->handle, WF_TOP, 1, 0, 0, 0);
@@ -248,17 +276,18 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
short guiwin_init(void)
{
- if(v_vdi_h == -1){
- short dummy;
- static short work_in[12] = {1,1,1,1,1,1,1,1,1,1,2,1};
- v_vdi_h=graf_handle(&dummy, &dummy, &dummy, &dummy);
- v_opnvwk(work_in, &v_vdi_h, work_out);
- }
+ if(v_vdi_h == -1) {
+ short dummy;
+ static short work_in[12] = {1,1,1,1,1,1,1,1,1,1,2,1};
+ v_vdi_h=graf_handle(&dummy, &dummy, &dummy, &dummy);
+ v_opnvwk(work_in, &v_vdi_h, work_out);
+ }
+ return(0);
}
void guiwin_exit(void)
{
- v_clsvwk(v_vdi_h);
+ v_clsvwk(v_vdi_h);
}
GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb)
@@ -368,9 +397,9 @@ void guiwin_update_slider(GUIWIN *win, short mode)
struct guiwin_scroll_info_s * slid;
unsigned long size, pos;
- short handle = guiwin_get_handle(win);
+ short handle = guiwin_get_handle(win);
guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &viewport);
- slid = guiwin_get_scroll_info(win);
+ slid = guiwin_get_scroll_info(win);
if((mode & 1) && (slid->y_unit_px > 0)) {
if ( slid->y_pos_max < (long)viewport.g_h/slid->y_unit_px)
@@ -440,8 +469,35 @@ void *guiwin_get_user_data(GUIWIN *win)
struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win)
{
- return(&win->scroll_info);
+ return(&win->scroll_info);
+}
+
+void guiwin_send_redraw(GUIWIN *win, GRECT *area)
+{
+ short msg[8];
+ GRECT work;
+
+ if(area == NULL){
+ guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
+ area = &work;
+ }
+
+ msg[0] = WM_REDRAW;
+ msg[1] = gl_apid;
+ msg[2] = 0;
+ msg[3] = win->handle;
+ msg[4] = area->g_x;
+ msg[5] = area->g_y;
+ msg[6] = area->g_w;
+ msg[7] = area->g_h;
+
+ appl_write(gl_apid, 16, &msg);
+}
+/*
+void guiwin_exec_redraw(){
+
}
+*/
diff --git a/atari/gui.c b/atari/gui.c
index fb412f3..7204705 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -1117,7 +1117,9 @@ int main(int argc, char** argv)
freopen("stdout.log", "a+", stdout);
freopen("stderr.log", "a+", stderr);
#endif
+ // todo: replace with appl_init
ApplInit();
+ gl_apid = _AESapid;
graf_mouse(BUSY_BEE, NULL);
init_os_info();
atari_find_resource((char*)&messages, "messages", "res/messages");
diff --git a/atari/treeview.c b/atari/treeview.c
index ab0afb5..4cddea4 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -86,6 +86,11 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
on_redraw_event(tv, ev_out, msg);
break;
+ case WM_SIZED:
+ case WM_FULLED:
+ guiwin_update_slider(win, 3);
+ break;
+
default:
break;
}
@@ -322,18 +327,16 @@ void atari_treeview_destroy( NSTREEVIEW tv )
bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
{
GRECT work;
+ struct guiwin_scroll_info_s *slid;
if( tv == NULL )
return ( false );
guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+ slid = guiwin_get_scroll_info(tv->window);
- //int rx = (x-work.g_x)+(tv->window->xpos*tv->window->w_u);
- //int ry = (y-work.g_y)+(tv->window->ypos*tv->window->h_u);
-
- // TODO: get slider values
- int rx = (x-work.g_x);
- int ry = (y-work.g_y);
+ int rx = (x-work.g_x)+(slid->x_pos*slid->x_unit_px);
+ int ry = (y-work.g_y)+(slid->y_pos*slid->y_unit_px);
tree_mouse_action(tv->tree, bms, rx, ry);
@@ -353,9 +356,11 @@ void atari_treeview_redraw( NSTREEVIEW tv)
short todo[4];
GRECT work;
- short handle = guiwin_get_handle(tv->window);
+ short handle = guiwin_get_handle(tv->window);
+ struct guiwin_scroll_info_s *slid;
guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+ slid = guiwin_get_scroll_info(tv->window);
struct redraw_context ctx = {
.interactive = true,
@@ -378,8 +383,8 @@ void atari_treeview_redraw( NSTREEVIEW tv)
/* convert screen to treeview coords: */
// TODO: get slider values:
- todo[0] = todo[0] - work.g_x;/*+ tv->window->xpos*tv->window->w_u;*/
- todo[1] = todo[1] - work.g_y;/*+ tv->window->ypos*tv->window->h_u;*/
+ todo[0] = todo[0] - work.g_x + slid->x_pos*slid->x_unit_px;
+ todo[1] = todo[1] - work.g_y + slid->y_pos*slid->y_unit_px;
if( todo[0] < 0 ){
todo[2] = todo[2] + todo[0];
todo[0] = 0;
@@ -389,10 +394,10 @@ void atari_treeview_redraw( NSTREEVIEW tv)
todo[1] = 0;
}
- // TODO: get slider values
+ // TODO: get slider values
if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
- tree_draw(tv->tree, 0/*-tv->window->xpos*16*/,
- 0 /*-tv->window->ypos*16*/,
+ tree_draw(tv->tree, -(slid->x_pos*slid->x_unit_px),
+ -(slid->y_pos*slid->y_unit_px),
todo[0], todo[1], todo[2], todo[3], &ctx
);
}
@@ -472,7 +477,6 @@ void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(tv->window);
slid->x_pos_max = (width / slid->x_unit_px);
slid->y_pos_max = (height / slid->y_unit_px);
- printf("updating slider...\n");
guiwin_update_slider(tv->window, 3);
}
}
-----------------------------------------------------------------------
Summary of changes:
atari/gemtk/gemtk.h | 5 +-
atari/gemtk/guiwin.c | 176 +++++++++++++++++++++++++++++++++-----------------
atari/gui.c | 2 +
atari/treeview.c | 30 +++++----
4 files changed, 139 insertions(+), 74 deletions(-)
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index 5e0f5c4..4128715 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -84,6 +84,7 @@ enum guwin_area_e {
};
short guiwin_init(void);
+void guiwin_exit(void);
GUIWIN * guiwin_add(short handle, uint32_t flags,
guiwin_event_handler_f handler);
GUIWIN *guiwin_find(short handle);
@@ -99,11 +100,13 @@ void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx,
void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb);
void guiwin_set_user_data(GUIWIN *win, void *data);
void *guiwin_get_user_data(GUIWIN *win);
-struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win);
+struct guiwin_scroll_info_s * guiwin_get_scroll_info(GUIWIN *win);
void guiwin_update_slider(GUIWIN *win, short mode);
+void guiwin_send_redraw(GUIWIN *win, GRECT *area);
VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
+
/*
* AES Scroller Object
*/
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index fa496bf..e055aba 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -27,64 +27,92 @@ static GUIWIN * winlist;
static VdiHdl v_vdi_h = -1;
static short work_out[57];
+static void move_screen( int vhandle, GRECT *screen, int dx, int dy) {
+ INT16 xy[ 8];
+ long dum = 0L;
+ GRECT g;
+
+ /* get intersection with screen area */
+ wind_get_grect(0, WF_CURRXYWH, &g);
+ rc_intersect(&g, screen);
+ xy[ 0] = screen -> g_x;
+ xy[ 1] = screen -> g_y;
+ xy[ 2] = xy[ 0] + screen -> g_w - 1;
+ xy[ 3] = xy[ 1] + screen -> g_h - 1;
+ xy[ 4] = xy[ 0] + dx;
+ xy[ 5] = xy[ 1] + dy;
+ xy[ 6] = xy[ 2] + dx;
+ xy[ 7] = xy[ 3] + dy;
+ vro_cpyfm( vhandle, S_ONLY, xy, (MFDB *)&dum, (MFDB *)&dum);
+}
+
static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
- GRECT g, tb_area, tb_area_ro;
+ GRECT g, g_ro, tb_area, tb_area_ro;
short retval = 1;
int val;
struct guiwin_scroll_info_s *slid;
switch(msg[0]) {
- case WM_ARROWED:
- if((gw->flag & GW_FLAG_CUSTOM_SCROLLING) == 0){
-
- slid = guiwin_get_scroll_info(win);
-
- switch(msg[4]){
- case WA_DNPAGE:
- guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &g);
- val = g.g_h;
- // complete redraw
- // increase scroll val by page size...
- break;
-
- case WA_UPLINE:
- slid->g_y = MAX(0, slid->g_y-1);
- // partial redraw
- break;
-
- case WA_DNLINE:
- slid->g_y = MIN(slid->y_pos_max, slid->g_y+1);
- // move content up by unit size and sched redraw for the
- // bottom 16 px
- // partial redraw
- break;
-
- case WA_LFPAGE:
- // complete redraw
- // increase scroll val by page size...
- break;
-
- case WA_RTPAGE:
- // complete redraw
- // increase scroll val by page size...
- break;
-
- case WA_LFLINE:
- slid->g_x = MAX(0, slid->g_x-1);
- // partial redraw
- break;
-
- case WA_RTLINE:
- slid->g_x = MIN(slid->x_pos_max, slid->g_x+1);
- // partial redraw
- break;
-
- default: break;
- }
- }
- break;
+ case WM_ARROWED:
+ if((gw->flags & GW_FLAG_CUSTOM_SCROLLING) == 0) {
+
+ slid = guiwin_get_scroll_info(gw);
+ guiwin_get_grect(gw, GUIWIN_AREA_CONTENT, &g);
+ g_ro = g;
+
+ switch(msg[4]) {
+ case WA_DNPAGE:
+
+ val = g.g_h;
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_UPLINE:
+ slid->y_pos = MAX(0, slid->y_pos-1);
+ // partial redraw
+ break;
+
+ case WA_DNLINE:
+ slid->y_pos = MIN(slid->y_pos_max, slid->y_pos+1);
+ g.g_y += slid->y_unit_px;
+ g.g_h -= slid->y_unit_px;
+ move_screen(v_vdi_h, &g, 0, -slid->y_unit_px);
+ g.g_y = g_ro.g_y + g_ro.g_h - slid->y_unit_px;
+ g.g_h = slid->y_unit_px;
+ guiwin_send_redraw(gw, &g);
+ // move content up by unit size and sched redraw for the
+ // bottom 16 px
+ // partial redraw
+ break;
+
+ case WA_LFPAGE:
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_RTPAGE:
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_LFLINE:
+ slid->x_pos = MAX(0, slid->x_pos-1);
+ // partial redraw
+ break;
+
+ case WA_RTLINE:
+ slid->x_pos = MIN(slid->x_pos_max, slid->x_pos+1);
+ // partial redraw
+ break;
+
+ default:
+ break;
+ }
+ }
+ break;
case WM_TOPPED:
wind_set(gw->handle, WF_TOP, 1, 0, 0, 0);
@@ -248,17 +276,18 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
short guiwin_init(void)
{
- if(v_vdi_h == -1){
- short dummy;
- static short work_in[12] = {1,1,1,1,1,1,1,1,1,1,2,1};
- v_vdi_h=graf_handle(&dummy, &dummy, &dummy, &dummy);
- v_opnvwk(work_in, &v_vdi_h, work_out);
- }
+ if(v_vdi_h == -1) {
+ short dummy;
+ static short work_in[12] = {1,1,1,1,1,1,1,1,1,1,2,1};
+ v_vdi_h=graf_handle(&dummy, &dummy, &dummy, &dummy);
+ v_opnvwk(work_in, &v_vdi_h, work_out);
+ }
+ return(0);
}
void guiwin_exit(void)
{
- v_clsvwk(v_vdi_h);
+ v_clsvwk(v_vdi_h);
}
GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb)
@@ -368,9 +397,9 @@ void guiwin_update_slider(GUIWIN *win, short mode)
struct guiwin_scroll_info_s * slid;
unsigned long size, pos;
- short handle = guiwin_get_handle(win);
+ short handle = guiwin_get_handle(win);
guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &viewport);
- slid = guiwin_get_scroll_info(win);
+ slid = guiwin_get_scroll_info(win);
if((mode & 1) && (slid->y_unit_px > 0)) {
if ( slid->y_pos_max < (long)viewport.g_h/slid->y_unit_px)
@@ -440,8 +469,35 @@ void *guiwin_get_user_data(GUIWIN *win)
struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win)
{
- return(&win->scroll_info);
+ return(&win->scroll_info);
+}
+
+void guiwin_send_redraw(GUIWIN *win, GRECT *area)
+{
+ short msg[8];
+ GRECT work;
+
+ if(area == NULL){
+ guiwin_get_grect(win, GUIWIN_AREA_WORK, &work);
+ area = &work;
+ }
+
+ msg[0] = WM_REDRAW;
+ msg[1] = gl_apid;
+ msg[2] = 0;
+ msg[3] = win->handle;
+ msg[4] = area->g_x;
+ msg[5] = area->g_y;
+ msg[6] = area->g_w;
+ msg[7] = area->g_h;
+
+ appl_write(gl_apid, 16, &msg);
+}
+/*
+void guiwin_exec_redraw(){
+
}
+*/
diff --git a/atari/gui.c b/atari/gui.c
index fb412f3..7204705 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -1117,7 +1117,9 @@ int main(int argc, char** argv)
freopen("stdout.log", "a+", stdout);
freopen("stderr.log", "a+", stderr);
#endif
+ // todo: replace with appl_init
ApplInit();
+ gl_apid = _AESapid;
graf_mouse(BUSY_BEE, NULL);
init_os_info();
atari_find_resource((char*)&messages, "messages", "res/messages");
diff --git a/atari/treeview.c b/atari/treeview.c
index ab0afb5..4cddea4 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -86,6 +86,11 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
on_redraw_event(tv, ev_out, msg);
break;
+ case WM_SIZED:
+ case WM_FULLED:
+ guiwin_update_slider(win, 3);
+ break;
+
default:
break;
}
@@ -322,18 +327,16 @@ void atari_treeview_destroy( NSTREEVIEW tv )
bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
{
GRECT work;
+ struct guiwin_scroll_info_s *slid;
if( tv == NULL )
return ( false );
guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+ slid = guiwin_get_scroll_info(tv->window);
- //int rx = (x-work.g_x)+(tv->window->xpos*tv->window->w_u);
- //int ry = (y-work.g_y)+(tv->window->ypos*tv->window->h_u);
-
- // TODO: get slider values
- int rx = (x-work.g_x);
- int ry = (y-work.g_y);
+ int rx = (x-work.g_x)+(slid->x_pos*slid->x_unit_px);
+ int ry = (y-work.g_y)+(slid->y_pos*slid->y_unit_px);
tree_mouse_action(tv->tree, bms, rx, ry);
@@ -353,9 +356,11 @@ void atari_treeview_redraw( NSTREEVIEW tv)
short todo[4];
GRECT work;
- short handle = guiwin_get_handle(tv->window);
+ short handle = guiwin_get_handle(tv->window);
+ struct guiwin_scroll_info_s *slid;
guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+ slid = guiwin_get_scroll_info(tv->window);
struct redraw_context ctx = {
.interactive = true,
@@ -378,8 +383,8 @@ void atari_treeview_redraw( NSTREEVIEW tv)
/* convert screen to treeview coords: */
// TODO: get slider values:
- todo[0] = todo[0] - work.g_x;/*+ tv->window->xpos*tv->window->w_u;*/
- todo[1] = todo[1] - work.g_y;/*+ tv->window->ypos*tv->window->h_u;*/
+ todo[0] = todo[0] - work.g_x + slid->x_pos*slid->x_unit_px;
+ todo[1] = todo[1] - work.g_y + slid->y_pos*slid->y_unit_px;
if( todo[0] < 0 ){
todo[2] = todo[2] + todo[0];
todo[0] = 0;
@@ -389,10 +394,10 @@ void atari_treeview_redraw( NSTREEVIEW tv)
todo[1] = 0;
}
- // TODO: get slider values
+ // TODO: get slider values
if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
- tree_draw(tv->tree, 0/*-tv->window->xpos*16*/,
- 0 /*-tv->window->ypos*16*/,
+ tree_draw(tv->tree, -(slid->x_pos*slid->x_unit_px),
+ -(slid->y_pos*slid->y_unit_px),
todo[0], todo[1], todo[2], todo[3], &ctx
);
}
@@ -472,7 +477,6 @@ void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(tv->window);
slid->x_pos_max = (width / slid->x_unit_px);
slid->y_pos_max = (height / slid->y_unit_px);
- printf("updating slider...\n");
guiwin_update_slider(tv->window, 3);
}
}
--
NetSurf Browser
10 years, 6 months
netsurf: branch mono/removing-windom-dependency updated. 5449303bd1bf27e4cc8baccb0985e4d52c563caf
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5449303bd1bf27e4cc8ba...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5449303bd1bf27e4cc8bacc...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5449303bd1bf27e4cc8baccb0...
The branch, mono/removing-windom-dependency has been updated
via 5449303bd1bf27e4cc8baccb0985e4d52c563caf (commit)
from 9676253184e001d46a9ceb4e36c47484e169f272 (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/5449303bd1bf27e4cc8...
commit 5449303bd1bf27e4cc8baccb0985e4d52c563caf
Author: Ole Loots <ole(a)monochrom.net>
Commit: Ole Loots <ole(a)monochrom.net>
Ripped Windom out of the treeview implementation,
it still requires scroll event handling to be implemented.
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index 1ac8935..5e0f5c4 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -59,27 +59,36 @@ short msg_box_show(short type, const char * msg);
#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
+#define GW_FLAG_CUSTOM_SCROLLING 0x10 // no internal scroller handling
#define GW_STATUS_ICONIFIED 0x01
#define GW_STATUS_SHADED 0x02
struct gui_window_s;
typedef struct gui_window_s GUIWIN;
-
typedef short (*guiwin_event_handler_f)(GUIWIN *gw,
EVMULT_OUT *ev_out, short msg[8]);
+struct guiwin_scroll_info_s {
+ int x_unit_px;
+ int y_unit_px;
+ int x_pos;
+ int y_pos;
+ int x_pos_max;
+ int y_pos_max;
+};
+
enum guwin_area_e {
GUIWIN_AREA_WORK = 0,
GUIWIN_AREA_TOOLBAR,
GUIWIN_AREA_CONTENT
};
+short guiwin_init(void);
GUIWIN * guiwin_add(short handle, uint32_t flags,
guiwin_event_handler_f handler);
GUIWIN *guiwin_find(short handle);
short guiwin_remove(GUIWIN *win);
GUIWIN *guiwin_validate_ptr(GUIWIN *win);
-//short guiwin_set_event_handler(guiwin_event_handler_f);
short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out,
short msg[8]);
void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest);
@@ -87,6 +96,13 @@ short guiwin_get_handle(GUIWIN *win);
uint32_t guiwin_get_state(GUIWIN *win);
void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx,
uint32_t flags);
+void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb);
+void guiwin_set_user_data(GUIWIN *win, void *data);
+void *guiwin_get_user_data(GUIWIN *win);
+struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win);
+void guiwin_update_slider(GUIWIN *win, short mode);
+VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
+
/*
* AES Scroller Object
@@ -97,5 +113,12 @@ void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx,
&& (_y >= r.g_y) && (_y <= r.g_y + r.g_h))
#endif
+#ifndef MAX
+#define MAX(_a,_b) ((_a>_b) ? _a : _b)
+#endif
+
+#ifndef MIN
+#define MIN(_a,_b) ((_a<_b) ? _a : _b)
+#endif
#endif // GEMTK_H_INCLUDED
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 56a3064..fa496bf 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -1,6 +1,7 @@
//#include "global.h"
#include <stdint.h>
+#include <stdbool.h>
#include <assert.h>
#include <cflib.h>
@@ -11,24 +12,80 @@
#define DEBUG_PRINT(x)
struct gui_window_s {
- short handle;
- guiwin_event_handler_f handler_func;
- uint32_t flags;
- uint32_t state;
- OBJECT * toolbar;
- short toolbar_idx;
- struct gui_window_s *next, *prev;
+ short handle;
+ guiwin_event_handler_f handler_func;
+ uint32_t flags;
+ uint32_t state;
+ OBJECT * toolbar;
+ short toolbar_idx;
+ struct guiwin_scroll_info_s scroll_info;
+ void *user_data;
+ struct gui_window_s *next, *prev;
};
static GUIWIN * winlist;
+static VdiHdl v_vdi_h = -1;
+static short work_out[57];
static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
GRECT g, tb_area, tb_area_ro;
short retval = 1;
+ int val;
+ struct guiwin_scroll_info_s *slid;
switch(msg[0]) {
+ case WM_ARROWED:
+ if((gw->flag & GW_FLAG_CUSTOM_SCROLLING) == 0){
+
+ slid = guiwin_get_scroll_info(win);
+
+ switch(msg[4]){
+ case WA_DNPAGE:
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &g);
+ val = g.g_h;
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_UPLINE:
+ slid->g_y = MAX(0, slid->g_y-1);
+ // partial redraw
+ break;
+
+ case WA_DNLINE:
+ slid->g_y = MIN(slid->y_pos_max, slid->g_y+1);
+ // move content up by unit size and sched redraw for the
+ // bottom 16 px
+ // partial redraw
+ break;
+
+ case WA_LFPAGE:
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_RTPAGE:
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_LFLINE:
+ slid->g_x = MAX(0, slid->g_x-1);
+ // partial redraw
+ break;
+
+ case WA_RTLINE:
+ slid->g_x = MIN(slid->x_pos_max, slid->g_x+1);
+ // partial redraw
+ break;
+
+ default: break;
+ }
+ }
+ break;
+
case WM_TOPPED:
wind_set(gw->handle, WF_TOP, 1, 0, 0, 0);
break;
@@ -38,56 +95,56 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
wind_set(gw->handle, WF_CURRXYWH, msg[4], msg[5], g.g_w, g.g_h);
break;
- case WM_SIZED:
+ case WM_SIZED:
case WM_REPOSED:
- wind_get_grect(gw->handle, WF_CURRXYWH, &g);
- wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]);
- break;
+ wind_get_grect(gw->handle, WF_CURRXYWH, &g);
+ wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]);
+ break;
- case WM_FULLED:
- wind_get_grect(0, WF_WORKXYWH, &g);
- wind_set_grect(gw->handle, WF_CURRXYWH, &g);
- break;
+ case WM_FULLED:
+ wind_get_grect(gw->handle, WF_FULLXYWH, &g);
+ wind_set_grect(gw->handle, WF_CURRXYWH, &g);
+ break;
- case WM_ICONIFY:
- wind_set(gw->handle, WF_ICONIFY, msg[4], msg[5], msg[6], msg[7]);
- gw->state |= GW_STATUS_ICONIFIED;
- break;
+ case WM_ICONIFY:
+ wind_set(gw->handle, WF_ICONIFY, msg[4], msg[5], msg[6], msg[7]);
+ gw->state |= GW_STATUS_ICONIFIED;
+ break;
- case WM_UNICONIFY:
- wind_set(gw->handle, WF_UNICONIFY, msg[4], msg[5], msg[6], msg[7]);
- gw->state &= ~(GW_STATUS_ICONIFIED);
- break;
+ case WM_UNICONIFY:
+ wind_set(gw->handle, WF_UNICONIFY, msg[4], msg[5], msg[6], msg[7]);
+ gw->state &= ~(GW_STATUS_ICONIFIED);
+ break;
- case WM_SHADED:
- gw->state |= GW_STATUS_SHADED;
- break;
+ case WM_SHADED:
+ gw->state |= GW_STATUS_SHADED;
+ break;
- case WM_UNSHADED:
- gw->state &= ~(GW_STATUS_SHADED);
- break;
+ case WM_UNSHADED:
+ gw->state &= ~(GW_STATUS_SHADED);
+ break;
- case WM_REDRAW:
- if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
- guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
- tb_area = tb_area_ro;
- if(rc_intersect((GRECT*)&msg[4], &tb_area)){
- wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
- while (g.g_h > 0 || g.g_w > 0) {
- gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
- gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
- gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
- gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
- objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
- g.g_w, g.g_h);
- wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
- }
- }
- }
- break;
+ case WM_REDRAW:
+ if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
+ guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
+ tb_area = tb_area_ro;
+ if(rc_intersect((GRECT*)&msg[4], &tb_area)) {
+ wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
+ while (g.g_h > 0 || g.g_w > 0) {
+ gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
+ gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
+ gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
+ gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
+ objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
+ g.g_w, g.g_h);
+ wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
+ }
+ }
+ }
+ break;
default:
- retval = 0;
+ retval = 0;
break;
}
return(retval);
@@ -100,8 +157,8 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
DEBUG_PRINT(("guiwin_handle_event_multi_fast: %d\n", msg[0]));
- switch (msg[0]) {
- case WM_REDRAW:
+ switch (msg[0]) {
+ case WM_REDRAW:
case WM_CLOSED:
case WM_TOPPED:
case WM_ARROWED:
@@ -128,62 +185,88 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
if (dest->flags&GW_FLAG_PREPROC_WM) {
retval = preproc_wm(dest, ev_out, msg);
if(((retval == 0)||(dest->flags&GW_FLAG_RECV_PREPROC_WM))) {
- retval = dest->handler_func(dest, ev_out, msg);
+ retval = dest->handler_func(dest, ev_out, msg);
+ }
+ } else {
+ if (dest->handler_func) {
+ retval = dest->handler_func(dest, ev_out, msg);
}
- }
- else {
- if (dest->handler_func) {
- retval = dest->handler_func(dest, ev_out, msg);
- }
}
}
break;
}
- }
- if( (ev_out->emo_events & MU_BUTTON) != 0){
- short info[4];
+ } else {
+
+ short info[4];
+ wind_get( 0, WF_TOP, &info[0], &info[1], &info[2], &info[3]);
+
+ if(info[0] != 0 && info[1] == gl_apid) {
- wind_get( 0, WF_TOP, &info[0], &info[1], &info[2], &info[3]);
- if(info[0] != 0 && info[1] == gl_apid){
- dest = guiwin_find(info[0]);
- if (dest) {
+ dest = guiwin_find(info[0]);
+
+ if(dest == NULL || dest->handler_func == NULL)
+ return(0);
+
+ if( (ev_out->emo_events & MU_BUTTON) != 0) {
DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
- // toolbar handling:
- if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 &&
- dest->toolbar != NULL && dest->handler_func != NULL){
- GRECT tb_area;
- guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
- if (POINT_WITHIN(ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y, tb_area)) {
- // send WM_TOOLBAR message
- dest->toolbar[dest->toolbar_idx].ob_x = tb_area.g_x;
- dest->toolbar[dest->toolbar_idx].ob_y = tb_area.g_y;
- short obj_idx = objc_find(dest->toolbar,
- dest->toolbar_idx, 8,
- ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
- short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle,
- obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0};
- short oldevents = ev_out->emo_events;
- ev_out->emo_events = MU_MESAG;
- dest->handler_func(dest, ev_out, msg_out);
- ev_out->emo_events = oldevents;
- retval = 1;
- }
- }
+ // toolbar handling:
+ if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 &&
+ dest->toolbar != NULL) {
+ GRECT tb_area;
+ guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, tb_area)) {
+ // send WM_TOOLBAR message
+ dest->toolbar[dest->toolbar_idx].ob_x = tb_area.g_x;
+ dest->toolbar[dest->toolbar_idx].ob_y = tb_area.g_y;
+ short obj_idx = objc_find(dest->toolbar,
+ dest->toolbar_idx, 8,
+ ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle,
+ obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0
+ };
+ short oldevents = ev_out->emo_events;
+ ev_out->emo_events = MU_MESAG;
+ dest->handler_func(dest, ev_out, msg_out);
+ ev_out->emo_events = oldevents;
+ retval = 1;
+ } else {
+ dest->handler_func(dest, ev_out, msg);
+ }
+ }
+ } else if(ev_out->emo_events & MU_KEYBD) {
+ dest->handler_func(dest, ev_out, msg);
}
- }
+ }
}
+
return(retval);
}
+short guiwin_init(void)
+{
+ if(v_vdi_h == -1){
+ short dummy;
+ static short work_in[12] = {1,1,1,1,1,1,1,1,1,1,2,1};
+ v_vdi_h=graf_handle(&dummy, &dummy, &dummy, &dummy);
+ v_opnvwk(work_in, &v_vdi_h, work_out);
+ }
+}
+
+void guiwin_exit(void)
+{
+ v_clsvwk(v_vdi_h);
+}
+
GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb)
{
+
GUIWIN *win = calloc(sizeof(GUIWIN),1);
- assert(win!=NULL);
+ assert(win!=NULL);
DEBUG_PRINT(("guiwin_add: %d, %p, cb: %p\n", handle, win, cb));
win->handle = handle;
@@ -221,8 +304,8 @@ GUIWIN *guiwin_find(short handle)
GUIWIN *guiwin_validate_ptr(GUIWIN *win)
{
- GUIWIN *g;
- for( g = winlist; g != NULL; g=g->next ) {
+ GUIWIN *g;
+ for( g = winlist; g != NULL; g=g->next ) {
DEBUG_PRINT(("guiwin guiwin_validate_ptr check: %p\n", g));
if(g == win) {
DEBUG_PRINT(("guiwin_validate_ptr valid: %p\n", g));
@@ -234,8 +317,8 @@ GUIWIN *guiwin_validate_ptr(GUIWIN *win)
short guiwin_remove(GUIWIN *win)
{
- win = guiwin_validate_ptr(win);
- if (win == NULL)
+ win = guiwin_validate_ptr(win);
+ if (win == NULL)
return(-1);
/* unlink the window: */
@@ -254,49 +337,110 @@ short guiwin_remove(GUIWIN *win)
void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
{
- wind_get_grect(win->handle, WF_WORKXYWH, dest);
- if (mode == GUIWIN_AREA_CONTENT) {
- GRECT tb_area;
- guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
- if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
- dest->g_x += tb_area.g_w;
- dest->g_w -= tb_area.g_w;
- } else {
- dest->g_y += tb_area.g_h;
- dest->g_h -= tb_area.g_h;
- }
- }
- else if (mode == GUIWIN_AREA_TOOLBAR) {
- if (win->toolbar != NULL) {
- if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
- dest->g_w = win->toolbar[win->toolbar_idx].ob_width;
- } else {
- dest->g_h = win->toolbar[win->toolbar_idx].ob_height;
- }
- } else {
- dest->g_h = 0;
- dest->g_w = 0;
- }
- }
+ wind_get_grect(win->handle, WF_WORKXYWH, dest);
+ if (mode == GUIWIN_AREA_CONTENT) {
+ GRECT tb_area;
+ guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
+ if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
+ dest->g_x += tb_area.g_w;
+ dest->g_w -= tb_area.g_w;
+ } else {
+ dest->g_y += tb_area.g_h;
+ dest->g_h -= tb_area.g_h;
+ }
+ } else if (mode == GUIWIN_AREA_TOOLBAR) {
+ if (win->toolbar != NULL) {
+ if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
+ dest->g_w = win->toolbar[win->toolbar_idx].ob_width;
+ } else {
+ dest->g_h = win->toolbar[win->toolbar_idx].ob_height;
+ }
+ } else {
+ dest->g_h = 0;
+ dest->g_w = 0;
+ }
+ }
+}
+
+void guiwin_update_slider(GUIWIN *win, short mode)
+{
+ GRECT viewport;
+ struct guiwin_scroll_info_s * slid;
+ unsigned long size, pos;
+
+ short handle = guiwin_get_handle(win);
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &viewport);
+ slid = guiwin_get_scroll_info(win);
+
+ if((mode & 1) && (slid->y_unit_px > 0)) {
+ if ( slid->y_pos_max < (long)viewport.g_h/slid->y_unit_px)
+ size = 1000L;
+ else
+ size = MAX( 50L, (unsigned long)viewport.g_h*1000L/(unsigned long)(slid->y_unit_px*slid->y_pos_max));
+ wind_set(handle, WF_VSLSIZE, (int)size, 0, 0, 0);
+
+ if (slid->y_pos_max > (long)viewport.g_h/slid->y_unit_px) {
+ pos = (unsigned long)slid->y_pos *1000L/(unsigned long)(slid->y_pos_max-viewport.g_h/slid->y_unit_px);
+ wind_set(handle, WF_VSLIDE, (int)pos, 0, 0, 0);
+ } else if (slid->y_pos) {
+ slid->y_pos = 0;
+ wind_set(handle, WF_VSLIDE, 0, 0, 0, 0);
+ }
+ }
+ if((mode & 2) && (slid->x_unit_px > 0)) {
+ if ( slid->x_pos_max < (long)viewport.g_w/slid->x_unit_px)
+ size = 1000L;
+ else
+ size = MAX( 50L, (unsigned long)viewport.g_w*1000L/(unsigned long)(slid->x_unit_px*slid->x_pos_max));
+ wind_set(handle, WF_HSLSIZE, (int)size, 0, 0, 0);
+
+ if( slid->x_pos_max > (long)viewport.g_w/slid->x_unit_px) {
+ pos = (unsigned long)slid->x_pos*1000L/(unsigned long)(slid->x_pos_max-viewport.g_w/slid->x_unit_px);
+ wind_set(handle, WF_HSLIDE, (int)pos, 0, 0, 0);
+ } else if (slid->x_pos) {
+ slid->x_pos = 0;
+ wind_set(handle, WF_HSLIDE, 0, 0, 0, 0);
+ }
+ }
}
short guiwin_get_handle(GUIWIN *win)
{
- return(win->handle);
+ return(win->handle);
}
uint32_t guiwin_get_state(GUIWIN *win)
{
- return(win->state);
+ return(win->state);
+}
+
+void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb)
+{
+ win->handler_func = cb;
}
void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx, uint32_t flags)
{
- win->toolbar = toolbar;
- win->toolbar_idx = idx;
- if(flags & GW_FLAG_HAS_VTOOLBAR){
- win->flags |= GW_FLAG_HAS_VTOOLBAR;
- }
+ win->toolbar = toolbar;
+ win->toolbar_idx = idx;
+ if(flags & GW_FLAG_HAS_VTOOLBAR) {
+ win->flags |= GW_FLAG_HAS_VTOOLBAR;
+ }
+}
+
+void guiwin_set_user_data(GUIWIN *win, void *data)
+{
+ win->user_data = data;
+}
+
+void *guiwin_get_user_data(GUIWIN *win)
+{
+ return(win->user_data);
+}
+
+struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win)
+{
+ return(&win->scroll_info);
}
diff --git a/atari/gui.c b/atari/gui.c
index 4f7a97b..fb412f3 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -86,6 +86,7 @@ struct gui_window *window_list = NULL;
void * h_gem_rsrc;
long next_poll;
bool rendering = false;
+bool gui_poll_repeat = false;
/* Comandline / Options: */
@@ -162,44 +163,48 @@ void gui_poll(bool active)
short mx, my, dummy;
unsigned short nkc = 0;
- evnt.timer = schedule_run();
-
- if(active || rendering) {
- if (clock() >= next_poll) {
- aes_event_in.emi_tlow = 0;
- evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
- next_poll = clock() + (CLOCKS_PER_SEC>>4);
- }
- } else {
- evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
- }
+ gui_poll_repeat = false;
- if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
- //global_dispatch_event(&aes_event_in, &aes_event_out, msg);
- if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
- LOG(("WM: %d\n", aes_msg_out[0]));
- switch(aes_msg_out[0]) {
-
- case MN_SELECTED:
- LOG(("Menu Item: %d\n",aes_msg_out[4]));
- deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
- break;
-
- default:
- break;
- }
- }
+ evnt.timer = schedule_run();
- if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
- printf("key: %d, %d\n", aes_event_out.emo_kreturn,
- aes_event_out.emo_kmeta);
- nkc= gem_to_norm( (short)aes_event_out.emo_kmeta,
- (short)aes_event_out.emo_kreturn);
- deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
- aes_event_out.emo_kmeta, nkc);
+ if(active || rendering)
+ aes_event_in.emi_tlow = 0;
+
+ // Handle events until there are no more messages pending or
+ // until the engine indicates activity:
+ do {
+ evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
+ if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
+ if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
+ LOG(("WM: %d\n", aes_msg_out[0]));
+ switch(aes_msg_out[0]) {
+
+ case MN_SELECTED:
+ LOG(("Menu Item: %d\n",aes_msg_out[4]));
+ deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
+ printf("key: %d, %d\n", aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta);
+ nkc= gem_to_norm( (short)aes_event_out.emo_kmeta,
+ (short)aes_event_out.emo_kreturn);
+ deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta, nkc);
+ }
}
- }
+ } while ( gui_poll_repeat && !(active||rendering));
+ if( !active ) {
+ /* this suits for stuff with lower priority */
+ /* TBD: really be spare on redraws??? */
+ hotlist_redraw();
+ //global_history_redraw();
+ }
}
void gui_poll_old(bool active)
@@ -374,7 +379,7 @@ void gui_window_set_status(struct gui_window *w, const char *text)
{
if (w == NULL || text == NULL )
return;
- window_set_stauts( w , (char*)text );
+ window_set_stauts(w, (char*)text );
}
void gui_window_redraw_window(struct gui_window *gw)
@@ -905,6 +910,7 @@ void gui_quit(void)
urldb_save(nsoption_charp(url_file));
deskmenu_destroy();
+ guiwin_exit();
rsrc_free();
@@ -1032,14 +1038,6 @@ static void gui_init(int argc, char** argv)
if (rsrc_load(buf)==0) {
die("Uable to open GEM Resource file!");
}
- //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;
-
- //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 );
@@ -1049,7 +1047,7 @@ static void gui_init(int argc, char** argv)
create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizeall);
create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenesw);
create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenwse);
- RsrcGaddr( h_gem_rsrc, R_TREE, CURSOR , &cursors );
+ cursors = get_tree(CURSOR);
create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_APPSTART,
cursors, &gem_cursors.appstarting);
gem_set_cursor( &gem_cursors.appstarting );
@@ -1095,6 +1093,7 @@ static void gui_init2(int argc, char** argv)
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
}
+ guiwin_init();
bind_global_events();
global_history_init();
hotlist_init();
diff --git a/atari/history.c b/atari/history.c
index ad5deb2..0df7ec4 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -86,33 +86,35 @@ static void __CDECL evnt_history_mbutton( WINDOW *win, short buff[8] )
bool global_history_init( void )
{
- if( gl_history.init == false ) {
-
- int flags = ATARI_TREEVIEW_WIDGETS;
- gl_history.open = false;
- gl_history.window = WindCreate( flags, 40, 40, app.w, app.h );
- if( gl_history.window == NULL ) {
- LOG(("Failed to allocate history window"));
- return( false );
- }
- WindSetStr(gl_history.window, WF_NAME, messages_get("GlobalHistory"));
- //WindSetPtr( gl_history.window, WF_TOOLBAR, tree, evnt_history_toolbar );
- EvntAttach( gl_history.window, WM_CLOSED, evnt_history_close );
- EvntAttach( gl_history.window, WM_XBUTTON,evnt_history_mbutton );
-
- gl_history.tv = atari_treeview_create(
- history_global_get_tree_flags(),
- gl_history.window
- );
- if (gl_history.tv == NULL) {
- /* handle it properly, clean up previous allocs */
- LOG(("Failed to allocate history treeview"));
- return( false );
- }
-
- history_global_initialise( gl_history.tv->tree, "dir.png" );
- gl_history.init = true;
- }
+ return(true);
+// if( gl_history.init == false ) {
+//
+// int flags = ATARI_TREEVIEW_WIDGETS;
+// gl_history.open = false;
+// gl_history.window = WindCreate( flags, 40, 40, app.w, app.h );
+// if( gl_history.window == NULL ) {
+// LOG(("Failed to allocate history window"));
+// return( false );
+// }
+// WindSetStr(gl_history.window, WF_NAME, messages_get("GlobalHistory"));
+// //WindSetPtr( gl_history.window, WF_TOOLBAR, tree, evnt_history_toolbar );
+// EvntAttach( gl_history.window, WM_CLOSED, evnt_history_close );
+// EvntAttach( gl_history.window, WM_XBUTTON,evnt_history_mbutton );
+//
+// gl_history.tv = atari_treeview_create(
+// history_global_get_tree_flags(),
+// gl_history.window,
+// NULL
+// );
+// if (gl_history.tv == NULL) {
+// /* handle it properly, clean up previous allocs */
+// LOG(("Failed to allocate history treeview"));
+// return( false );
+// }
+//
+// history_global_initialise( gl_history.tv->tree, "dir.png" );
+// gl_history.init = true;
+// }
return( true );
}
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 5d54d06..7fbac3e 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -22,6 +22,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+
+#include <windom.h>
+
#include "desktop/browser.h"
#include "content/content.h"
#include "content/hlcache.h"
@@ -45,45 +48,48 @@
struct atari_hotlist hl;
-static void evnt_hl_toolbar( WINDOW *win, short buff[8]) {
- /* handle toolbar object (index in buff[4] ) */
- switch( buff[4] ) {
- case TOOLBAR_HOTLIST_CREATE_FOLDER:
- hotlist_add_folder(true);
- break;
-
- case TOOLBAR_HOTLIST_ADD:
- atari_hotlist_add_page("http://www.de", "");
- break;
+static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
+{
- case TOOLBAR_HOTLIST_DELETE:
- hotlist_delete_selected();
- break;
+ printf("hotlist handle event...\n");
+ if(ev_out->emo_events & MU_MESAG){
+ switch (msg[0]) {
+ case WM_TOOLBAR:
+ printf("toolbar event...%d\n", msg[4]);
+ switch (msg[4]) {
- case TOOLBAR_HOTLIST_EDIT:
- hotlist_edit_selected();
- break;
- }
- ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
-}
+ case TOOLBAR_HOTLIST_CREATE_FOLDER:
+ hotlist_add_folder(true);
+ break;
+ case TOOLBAR_HOTLIST_ADD:
+ atari_hotlist_add_page("http://www.de", "");
+ break;
-static void __CDECL evnt_hl_close( WINDOW *win, short buff[8] )
-{
- hotlist_close();
-}
+ case TOOLBAR_HOTLIST_DELETE:
+ hotlist_delete_selected();
+ break;
+ case TOOLBAR_HOTLIST_EDIT:
+ hotlist_edit_selected();
+ break;
+ }
+ break;
-static void __CDECL evnt_hl_mbutton( WINDOW *win, short buff[8] )
-{
- /* todo: implement popup?
- if(evnt.mbut & 2) {
+ case WM_CLOSED:
+ hotlist_close();
+ break;
+ default: break;
+ }
}
- */
+
+ // TODO: implement selectable objects in toolbar API:
+ // ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
}
+
void hotlist_init(void)
{
if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){
@@ -96,21 +102,24 @@ void hotlist_init(void)
if( hl.window == NULL ){
int flags = ATARI_TREEVIEW_WIDGETS;
+ short handle = -1;
OBJECT * tree = get_tree(TOOLBAR_HOTLIST);
assert( tree );
hl.open = false;
- hl.window = WindCreate( flags, 40, 40, app.w, app.h );
+ handle = wind_create(flags, 0, 0, app.w, app.h);
+ hl.window = guiwin_add(handle,
+ GW_FLAG_PREPROC_WM|GW_FLAG_RECV_PREPROC_WM,
+ NULL);
if( hl.window == NULL ) {
LOG(("Failed to allocate Hotlist"));
return;
}
- WindSetStr( hl.window, WF_NAME, (char*)messages_get("Hotlist") );
- WindSetPtr( hl.window, WF_TOOLBAR, tree, evnt_hl_toolbar );
- EvntAttach( hl.window, WM_CLOSED, evnt_hl_close );
- EvntAttach( hl.window, WM_XBUTTON,evnt_hl_mbutton );
+ wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist"));
+ guiwin_set_toolbar(hl.window, tree, 0, 0);
hl.tv = atari_treeview_create(
hotlist_get_tree_flags(),
- hl.window
+ hl.window,
+ handle_event
);
if (hl.tv == NULL) {
/* handle it properly, clean up previous allocs */
@@ -140,17 +149,17 @@ void hotlist_open(void)
}
if( hl.open == false ) {
- WindOpen( hl.window, pos.g_x, pos.g_y, pos.g_w, pos.g_h);
+ wind_open_grect(guiwin_get_handle(hl.window), &pos);
hl.open = true;
atari_treeview_open( hl.tv );
} else {
- WindTop( hl.window );
+ wind_set(guiwin_get_handle(hl.window), WF_TOP, 1, 0, 0, 0);
}
}
void hotlist_close(void)
{
- WindClose(hl.window);
+ wind_close(guiwin_get_handle(hl.window));
hl.open = false;
atari_treeview_close( hl.tv );
}
@@ -164,7 +173,8 @@ void hotlist_destroy(void)
hotlist_cleanup( (char*)&hl.path );
if( hl.open )
hotlist_close();
- WindDelete( hl.window );
+ wind_delete(guiwin_get_handle(hl.window));
+ guiwin_remove(hl.window);
hl.window = NULL;
atari_treeview_destroy( hl.tv );
hl.init = false;
diff --git a/atari/hotlist.h b/atari/hotlist.h
index 70b4d8a..858d1a1 100755
--- a/atari/hotlist.h
+++ b/atari/hotlist.h
@@ -21,11 +21,12 @@
#include <stdbool.h>
#include <windom.h>
#include "desktop/tree.h"
+#include "atari/gemtk/gemtk.h"
#include "atari/treeview.h"
/* The hotlist window, toolbar and treeview data. */
struct atari_hotlist {
- WINDOW * window;
+ GUIWIN * window;
NSTREEVIEW tv; /*< The hotlist treeview handle. */
bool open;
bool init;
diff --git a/atari/rootwin.c b/atari/rootwin.c
index a05c66e..aff910c 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -122,7 +122,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
case WM_CLOSED:
gw = FIND_NS_GUI_WINDOW(win);
if( gw != NULL ) {
- browser_window_destroy( gw->browser->bw );
+ browser_window_destroy(gw->browser->bw );
}
break;
@@ -158,9 +158,9 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
-int window_create( struct gui_window * gw,
+int window_create(struct gui_window * gw,
struct browser_window * bw,
- unsigned long inflags )
+ unsigned long inflags)
{
int err = 0;
bool tb, sb;
@@ -343,7 +343,7 @@ void window_set_stauts(struct gui_window * gw , char * text )
}
/* set focus to an arbitary element */
-void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element )
+void window_set_focus(struct gui_window * gw, enum focus_element_type type, void * element)
{
if( gw->root->focus.type != type || gw->root->focus.element != element ) {
LOG(("Set focus: %p (%d)\n", element, type));
diff --git a/atari/treeview.c b/atari/treeview.c
index 6e567f5..ab0afb5 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -21,7 +21,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <windom.h>
#include "content/urldb.h"
#include "desktop/browser.h"
@@ -36,15 +35,10 @@
#include "atari/gui.h"
#include "atari/treeview.h"
#include "atari/plot/plot.h"
-#include "atari/misc.h"
+#include "atari/misc.h"
+#include "atari/gemtk/gemtk.h"
#include "cflib.h"
-/*
-#define TREEVIEW_RECT_WORKAREA 0
-#define TREEVIEW_RECT_TOOLBAR 1
-#define TREEVIEW_RECT_CONTENT 2
-*/
-
enum treeview_area_e {
TREEVIEW_AREA_WORK = 0,
TREEVIEW_AREA_TOOLBAR,
@@ -69,9 +63,58 @@ static const struct treeview_table atari_tree_callbacks = {
atari_treeview_resized,
atari_treeview_scroll_visible,
atari_treeview_get_dimensions
-};
+};
+
+static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8]);
+static void __CDECL on_keybd_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8]);
+static void __CDECL on_redraw_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8]);
+
+static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
+{
+
+ NSTREEVIEW tv = (NSTREEVIEW) guiwin_get_user_data(win);
+
+ if( (ev_out->emo_events & MU_MESAG) != 0 ) {
+ // handle message
+ printf("treeview msg: %d\n", msg[0]);
+ switch (msg[0]) {
+
+ case WM_REDRAW:
+ on_redraw_event(tv, ev_out, msg);
+ break;
+
+ default:
+ break;
+ }
+ }
+ if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
+ printf("Treeview keybd\n");
+ on_keybd_event(tv, ev_out, msg);
+ // handle key
+ }
+ if( (ev_out->emo_events & MU_TIMER) != 0 ) {
+ // handle_timer();
+ }
+ if( (ev_out->emo_events & MU_BUTTON) != 0 ) {
+ LOG(("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y));
+ printf("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ on_mbutton_event(tv, ev_out, msg);
+ }
+
+ if(tv != NULL && tv->user_func != NULL){
+ tv->user_func(win, ev_out, msg);
+ }
+
+ return(0);
+}
-static void __CDECL evnt_tv_keybd( WINDOW *win, short buff[8], void * data )
+static void __CDECL on_keybd_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8])
{
bool r=false;
long kstate = 0;
@@ -82,9 +125,8 @@ static void __CDECL evnt_tv_keybd( WINDOW *win, short buff[8], void * data )
unsigned short nks = 0;
unsigned char ascii;
- NSTREEVIEW tv = (NSTREEVIEW) data;
- kstate = evnt.mkstate;
- kcode = evnt.keybd;
+ kstate = ev_out->emo_kmeta;
+ kcode = ev_out->emo_kreturn;
nkc= gem_to_norm( (short)kstate, (short)kcode );
ascii = (nkc & 0xFF);
ik = nkc_to_input_key( nkc, &ucs4 );
@@ -99,15 +141,18 @@ static void __CDECL evnt_tv_keybd( WINDOW *win, short buff[8], void * data )
}
-static void __CDECL evnt_tv_redraw( WINDOW *win, short buff[8], void * data )
+static void __CDECL on_redraw_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8])
{
GRECT work, clip;
- NSTREEVIEW tv = (NSTREEVIEW) data;
+
if( tv == NULL )
return;
- WindGetGrect( win, WF_WORKXYWH, &work );
+
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+
clip = work;
- if ( !rc_intersect( (GRECT*)&buff[4], &clip ) ) return;
+ if ( !rc_intersect( (GRECT*)&msg[4], &clip ) ) return;
clip.g_x -= work.g_x;
clip.g_y -= work.g_y;
if( clip.g_x < 0 ) {
@@ -118,31 +163,37 @@ static void __CDECL evnt_tv_redraw( WINDOW *win, short buff[8], void * data )
clip.g_h = work.g_h + clip.g_y;
clip.g_y = 0;
}
- if( clip.g_h > 0 && clip.g_w > 0 ) {
+ if( clip.g_h > 0 && clip.g_w > 0 ) {
+ // TODO: get slider values
atari_treeview_request_redraw(
- win->xpos*win->w_u + clip.g_x,
- win->ypos*win->h_u + clip.g_y,
+ /*win->xpos*win->w_u +*/ clip.g_x,
+ /*win->ypos*win->h_u +*/ clip.g_y,
clip.g_w, clip.g_h, tv
);
}
}
-static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data )
+static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8])
{
GRECT work;
- NSTREEVIEW tv = (NSTREEVIEW) data;
- if( tv == NULL )
+ if(tv == NULL)
return;
if( evnt.mbut & 2 ) {
/* do not handle right click */
return;
- }
+ }
+
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+
+ /* mouse click relative origin: */
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ // TODO: get scroll position
+ //short origin_rel_x = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
+ //short origin_rel_y = (evnt.my-work.g_y)+(win->ypos*win->h_u);
- /* mouse click relative origin: */
- short origin_rel_x = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
- short origin_rel_y = (evnt.my-work.g_y)+(win->ypos*win->h_u);
+ short origin_rel_x = (ev_out->emo_mouse.p_x-work.g_x);
+ short origin_rel_y = (ev_out->emo_mouse.p_y-work.g_y);
if( origin_rel_x >= 0 && origin_rel_y >= 0
&& evnt.mx < work.g_x + work.g_w
@@ -199,9 +250,10 @@ static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data )
if( tv->redraw )
atari_treeview_redraw( tv );
/* sample mouse button state: */
- graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy);
- cur_rel_x = (cur_rel_x-work.g_x)+(win->xpos*win->w_u);
- cur_rel_y = (cur_rel_y-work.g_y)+(win->ypos*win->h_u);
+ graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy);
+ // TODO : get guwin slider values;
+ cur_rel_x = (cur_rel_x-work.g_x)/*+(win->xpos*win->w_u);*/;
+ cur_rel_y = (cur_rel_y-work.g_y)/*+(win->ypos*win->h_u);*/;
} while( mbut & 1 );
tree_drag_end(tv->tree, 0, tv->startdrag.x, tv->startdrag.y,
@@ -211,8 +263,11 @@ static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data )
}
}
-NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win )
-{
+NSTREEVIEW atari_treeview_create(uint32_t flags, GUIWIN *win,
+ guiwin_event_handler_f user_func)
+{
+ struct guiwin_scroll_info_s *slid;
+
if( win == NULL )
return( NULL );
NSTREEVIEW new = malloc(sizeof(struct atari_treeview));
@@ -224,15 +279,16 @@ NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win )
free(new);
return NULL;
}
- new->window = win;
-
- win->w_u = 16;
- win->h_u = 16;
-
- EvntDataAdd( new->window, WM_XBUTTON, evnt_tv_mbutton, new, EV_BOT );
- EvntDataAttach( new->window, WM_REDRAW, evnt_tv_redraw, new );
- EvntDataAttach( new->window, WM_XKEYBD, evnt_tv_keybd, new );
+ new->window = win;
+ new->user_func = user_func;
+
+ guiwin_set_event_handler(win, handle_event);
+ guiwin_set_user_data(win, (void*)new);
+ slid = guiwin_get_scroll_info(new->window);
+ slid->y_unit_px = 16;
+ slid->x_unit_px = 16;
+
return(new);
}
@@ -265,15 +321,25 @@ void atari_treeview_destroy( NSTREEVIEW tv )
bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
{
+ GRECT work;
+
if( tv == NULL )
return ( false );
- GRECT work;
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
- int rx = (x-work.g_x)+(tv->window->xpos*tv->window->w_u);
- int ry = (y-work.g_y)+(tv->window->ypos*tv->window->h_u);
- tree_mouse_action(tv->tree, bms, rx, ry );
+
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+
+ //int rx = (x-work.g_x)+(tv->window->xpos*tv->window->w_u);
+ //int ry = (y-work.g_y)+(tv->window->ypos*tv->window->h_u);
+
+ // TODO: get slider values
+ int rx = (x-work.g_x);
+ int ry = (y-work.g_y);
+
+ tree_mouse_action(tv->tree, bms, rx, ry);
+
tv->click.x = rx;
tv->click.y = ry;
+
return( true );
}
@@ -284,9 +350,12 @@ void atari_treeview_redraw( NSTREEVIEW tv)
if (tv != NULL) {
if( tv->redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
+
short todo[4];
- GRECT work;
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ GRECT work;
+ short handle = guiwin_get_handle(tv->window);
+
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
struct redraw_context ctx = {
.interactive = true,
@@ -303,13 +372,14 @@ void atari_treeview_redraw( NSTREEVIEW tv)
todo[3] = todo[1] + work.g_h-1;
vs_clip(atari_plot_vdi_handle, 1, (short*)&todo );
- if( wind_get(tv->window->handle, WF_FIRSTXYWH,
+ if( wind_get(handle, WF_FIRSTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
while (todo[2] && todo[3]) {
- /* convert screen to treeview coords: */
- todo[0] = todo[0] - work.g_x + tv->window->xpos*tv->window->w_u;
- todo[1] = todo[1] - work.g_y + tv->window->ypos*tv->window->h_u;
+ /* convert screen to treeview coords: */
+ // TODO: get slider values:
+ todo[0] = todo[0] - work.g_x;/*+ tv->window->xpos*tv->window->w_u;*/
+ todo[1] = todo[1] - work.g_y;/*+ tv->window->ypos*tv->window->h_u;*/
if( todo[0] < 0 ){
todo[2] = todo[2] + todo[0];
todo[0] = 0;
@@ -318,13 +388,15 @@ void atari_treeview_redraw( NSTREEVIEW tv)
todo[3] = todo[3] + todo[1];
todo[1] = 0;
}
-
+
+ // TODO: get slider values
if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
- tree_draw(tv->tree, -tv->window->xpos*16, -tv->window->ypos*16,
+ tree_draw(tv->tree, 0/*-tv->window->xpos*16*/,
+ 0 /*-tv->window->ypos*16*/,
todo[0], todo[1], todo[2], todo[3], &ctx
);
}
- if (wind_get(tv->window->handle, WF_NEXTXYWH,
+ if (wind_get(handle, WF_NEXTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3])==0) {
break;
}
@@ -396,11 +468,12 @@ void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
NSTREEVIEW tv = (NSTREEVIEW) pw;
if( tv->disposing )
return;
- tv->extent.x = width;
- tv->extent.y = height;
- tv->window->ypos_max = (height / tv->window->w_u)+0.5;
- tv->window->xpos_max = (width / tv->window->h_u)+0.5;
- WindSlider( tv->window, HSLIDER|VSLIDER );
+ // TODO: update slider size
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(tv->window);
+ slid->x_pos_max = (width / slid->x_unit_px);
+ slid->y_pos_max = (height / slid->y_unit_px);
+ printf("updating slider...\n");
+ guiwin_update_slider(tv->window, 3);
}
}
@@ -423,17 +496,11 @@ static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode,
GRECT *dest)
{
- wind_get_grect(tv->window->handle, WF_WORKXYWH, dest);
if (mode == TREEVIEW_AREA_CONTENT) {
- GRECT tb_grect;
- atari_treeview_get_grect(tv, TREEVIEW_AREA_TOOLBAR, &tb_grect);
- dest->g_y += tb_grect.g_h;
- dest->g_h -= tb_grect.g_h;
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, dest);
}
else if (mode == TREEVIEW_AREA_TOOLBAR) {
- // TODO: this requires something like:
- // guiwin_get_toolbar();
- dest->g_h = 16;
+ guiwin_get_grect(tv->window, GUIWIN_AREA_TOOLBAR, dest);
}
}
diff --git a/atari/treeview.h b/atari/treeview.h
index 3796665..41d1cf5 100755
--- a/atari/treeview.h
+++ b/atari/treeview.h
@@ -22,25 +22,27 @@
#include <stdbool.h>
#include <windom.h>
#include "desktop/tree.h"
-#include "atari/gui.h"
+#include "atari/gui.h"
+#include "atari/gemtk/gemtk.h"
#define ATARI_TREEVIEW_WIDGETS (CLOSER | MOVER | SIZER| NAME | FULLER | SMALLER | VSLIDE | HSLIDE | UPARROW | DNARROW | LFARROW | RTARROW)
struct atari_treeview
{
struct tree * tree;
- WINDOW * window;
+ GUIWIN * window;
bool disposing;
bool redraw;
GRECT rdw_area;
POINT click;
- POINT extent;
- POINT startdrag;
+ POINT startdrag;
+ guiwin_event_handler_f user_func;
};
typedef struct atari_treeview * NSTREEVIEW;
-NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW * win );
+NSTREEVIEW atari_treeview_create( uint32_t flags, GUIWIN *win,
+ guiwin_event_handler_f user_func);
void atari_treeview_destroy( NSTREEVIEW tv );
void atari_treeview_open( NSTREEVIEW tv );
void atari_treeview_close( NSTREEVIEW tv );
-----------------------------------------------------------------------
Summary of changes:
atari/gemtk/gemtk.h | 27 ++++-
atari/gemtk/guiwin.c | 390 ++++++++++++++++++++++++++++++++++----------------
atari/gui.c | 87 ++++++------
atari/history.c | 56 ++++----
atari/hotlist.c | 86 ++++++-----
atari/hotlist.h | 3 +-
atari/rootwin.c | 8 +-
atari/treeview.c | 203 +++++++++++++++++---------
atari/treeview.h | 12 +-
9 files changed, 560 insertions(+), 312 deletions(-)
diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h
index 1ac8935..5e0f5c4 100644
--- a/atari/gemtk/gemtk.h
+++ b/atari/gemtk/gemtk.h
@@ -59,27 +59,36 @@ short msg_box_show(short type, const char * msg);
#define GW_FLAG_RECV_PREPROC_WM 0x02 // get notified even when pre-processed
#define GW_FLAG_HAS_VTOOLBAR 0x04 // the attached toolbar is vertical
#define GW_FLAG_CUSTOM_TOOLBAR 0x08 // no internal toolbar handling
+#define GW_FLAG_CUSTOM_SCROLLING 0x10 // no internal scroller handling
#define GW_STATUS_ICONIFIED 0x01
#define GW_STATUS_SHADED 0x02
struct gui_window_s;
typedef struct gui_window_s GUIWIN;
-
typedef short (*guiwin_event_handler_f)(GUIWIN *gw,
EVMULT_OUT *ev_out, short msg[8]);
+struct guiwin_scroll_info_s {
+ int x_unit_px;
+ int y_unit_px;
+ int x_pos;
+ int y_pos;
+ int x_pos_max;
+ int y_pos_max;
+};
+
enum guwin_area_e {
GUIWIN_AREA_WORK = 0,
GUIWIN_AREA_TOOLBAR,
GUIWIN_AREA_CONTENT
};
+short guiwin_init(void);
GUIWIN * guiwin_add(short handle, uint32_t flags,
guiwin_event_handler_f handler);
GUIWIN *guiwin_find(short handle);
short guiwin_remove(GUIWIN *win);
GUIWIN *guiwin_validate_ptr(GUIWIN *win);
-//short guiwin_set_event_handler(guiwin_event_handler_f);
short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out,
short msg[8]);
void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest);
@@ -87,6 +96,13 @@ short guiwin_get_handle(GUIWIN *win);
uint32_t guiwin_get_state(GUIWIN *win);
void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx,
uint32_t flags);
+void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb);
+void guiwin_set_user_data(GUIWIN *win, void *data);
+void *guiwin_get_user_data(GUIWIN *win);
+struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win);
+void guiwin_update_slider(GUIWIN *win, short mode);
+VdiHdl guiwin_get_vdi_handle(GUIWIN *win);
+
/*
* AES Scroller Object
@@ -97,5 +113,12 @@ void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx,
&& (_y >= r.g_y) && (_y <= r.g_y + r.g_h))
#endif
+#ifndef MAX
+#define MAX(_a,_b) ((_a>_b) ? _a : _b)
+#endif
+
+#ifndef MIN
+#define MIN(_a,_b) ((_a<_b) ? _a : _b)
+#endif
#endif // GEMTK_H_INCLUDED
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 56a3064..fa496bf 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -1,6 +1,7 @@
//#include "global.h"
#include <stdint.h>
+#include <stdbool.h>
#include <assert.h>
#include <cflib.h>
@@ -11,24 +12,80 @@
#define DEBUG_PRINT(x)
struct gui_window_s {
- short handle;
- guiwin_event_handler_f handler_func;
- uint32_t flags;
- uint32_t state;
- OBJECT * toolbar;
- short toolbar_idx;
- struct gui_window_s *next, *prev;
+ short handle;
+ guiwin_event_handler_f handler_func;
+ uint32_t flags;
+ uint32_t state;
+ OBJECT * toolbar;
+ short toolbar_idx;
+ struct guiwin_scroll_info_s scroll_info;
+ void *user_data;
+ struct gui_window_s *next, *prev;
};
static GUIWIN * winlist;
+static VdiHdl v_vdi_h = -1;
+static short work_out[57];
static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
GRECT g, tb_area, tb_area_ro;
short retval = 1;
+ int val;
+ struct guiwin_scroll_info_s *slid;
switch(msg[0]) {
+ case WM_ARROWED:
+ if((gw->flag & GW_FLAG_CUSTOM_SCROLLING) == 0){
+
+ slid = guiwin_get_scroll_info(win);
+
+ switch(msg[4]){
+ case WA_DNPAGE:
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &g);
+ val = g.g_h;
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_UPLINE:
+ slid->g_y = MAX(0, slid->g_y-1);
+ // partial redraw
+ break;
+
+ case WA_DNLINE:
+ slid->g_y = MIN(slid->y_pos_max, slid->g_y+1);
+ // move content up by unit size and sched redraw for the
+ // bottom 16 px
+ // partial redraw
+ break;
+
+ case WA_LFPAGE:
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_RTPAGE:
+ // complete redraw
+ // increase scroll val by page size...
+ break;
+
+ case WA_LFLINE:
+ slid->g_x = MAX(0, slid->g_x-1);
+ // partial redraw
+ break;
+
+ case WA_RTLINE:
+ slid->g_x = MIN(slid->x_pos_max, slid->g_x+1);
+ // partial redraw
+ break;
+
+ default: break;
+ }
+ }
+ break;
+
case WM_TOPPED:
wind_set(gw->handle, WF_TOP, 1, 0, 0, 0);
break;
@@ -38,56 +95,56 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
wind_set(gw->handle, WF_CURRXYWH, msg[4], msg[5], g.g_w, g.g_h);
break;
- case WM_SIZED:
+ case WM_SIZED:
case WM_REPOSED:
- wind_get_grect(gw->handle, WF_CURRXYWH, &g);
- wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]);
- break;
+ wind_get_grect(gw->handle, WF_CURRXYWH, &g);
+ wind_set(gw->handle, WF_CURRXYWH, g.g_x, g.g_y, msg[6], msg[7]);
+ break;
- case WM_FULLED:
- wind_get_grect(0, WF_WORKXYWH, &g);
- wind_set_grect(gw->handle, WF_CURRXYWH, &g);
- break;
+ case WM_FULLED:
+ wind_get_grect(gw->handle, WF_FULLXYWH, &g);
+ wind_set_grect(gw->handle, WF_CURRXYWH, &g);
+ break;
- case WM_ICONIFY:
- wind_set(gw->handle, WF_ICONIFY, msg[4], msg[5], msg[6], msg[7]);
- gw->state |= GW_STATUS_ICONIFIED;
- break;
+ case WM_ICONIFY:
+ wind_set(gw->handle, WF_ICONIFY, msg[4], msg[5], msg[6], msg[7]);
+ gw->state |= GW_STATUS_ICONIFIED;
+ break;
- case WM_UNICONIFY:
- wind_set(gw->handle, WF_UNICONIFY, msg[4], msg[5], msg[6], msg[7]);
- gw->state &= ~(GW_STATUS_ICONIFIED);
- break;
+ case WM_UNICONIFY:
+ wind_set(gw->handle, WF_UNICONIFY, msg[4], msg[5], msg[6], msg[7]);
+ gw->state &= ~(GW_STATUS_ICONIFIED);
+ break;
- case WM_SHADED:
- gw->state |= GW_STATUS_SHADED;
- break;
+ case WM_SHADED:
+ gw->state |= GW_STATUS_SHADED;
+ break;
- case WM_UNSHADED:
- gw->state &= ~(GW_STATUS_SHADED);
- break;
+ case WM_UNSHADED:
+ gw->state &= ~(GW_STATUS_SHADED);
+ break;
- case WM_REDRAW:
- if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
- guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
- tb_area = tb_area_ro;
- if(rc_intersect((GRECT*)&msg[4], &tb_area)){
- wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
- while (g.g_h > 0 || g.g_w > 0) {
- gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
- gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
- gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
- gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
- objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
- g.g_w, g.g_h);
- wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
- }
- }
- }
- break;
+ case WM_REDRAW:
+ if ((gw->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0) {
+ guiwin_get_grect(gw, GUIWIN_AREA_TOOLBAR, &tb_area_ro);
+ tb_area = tb_area_ro;
+ if(rc_intersect((GRECT*)&msg[4], &tb_area)) {
+ wind_get_grect(gw->handle, WF_FIRSTXYWH, &g);
+ while (g.g_h > 0 || g.g_w > 0) {
+ gw->toolbar[gw->toolbar_idx].ob_x = tb_area_ro.g_x;
+ gw->toolbar[gw->toolbar_idx].ob_width = tb_area_ro.g_w;
+ gw->toolbar[gw->toolbar_idx].ob_y = tb_area_ro.g_y;
+ gw->toolbar[gw->toolbar_idx].ob_height = tb_area_ro.g_h;
+ objc_draw(gw->toolbar, gw->toolbar_idx, 8, g.g_x, g.g_y,
+ g.g_w, g.g_h);
+ wind_get_grect(gw->handle, WF_NEXTXYWH, &g);
+ }
+ }
+ }
+ break;
default:
- retval = 0;
+ retval = 0;
break;
}
return(retval);
@@ -100,8 +157,8 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
if( (ev_out->emo_events & MU_MESAG) != 0 ) {
DEBUG_PRINT(("guiwin_handle_event_multi_fast: %d\n", msg[0]));
- switch (msg[0]) {
- case WM_REDRAW:
+ switch (msg[0]) {
+ case WM_REDRAW:
case WM_CLOSED:
case WM_TOPPED:
case WM_ARROWED:
@@ -128,62 +185,88 @@ short guiwin_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8])
if (dest->flags&GW_FLAG_PREPROC_WM) {
retval = preproc_wm(dest, ev_out, msg);
if(((retval == 0)||(dest->flags&GW_FLAG_RECV_PREPROC_WM))) {
- retval = dest->handler_func(dest, ev_out, msg);
+ retval = dest->handler_func(dest, ev_out, msg);
+ }
+ } else {
+ if (dest->handler_func) {
+ retval = dest->handler_func(dest, ev_out, msg);
}
- }
- else {
- if (dest->handler_func) {
- retval = dest->handler_func(dest, ev_out, msg);
- }
}
}
break;
}
- }
- if( (ev_out->emo_events & MU_BUTTON) != 0){
- short info[4];
+ } else {
+
+ short info[4];
+ wind_get( 0, WF_TOP, &info[0], &info[1], &info[2], &info[3]);
+
+ if(info[0] != 0 && info[1] == gl_apid) {
- wind_get( 0, WF_TOP, &info[0], &info[1], &info[2], &info[3]);
- if(info[0] != 0 && info[1] == gl_apid){
- dest = guiwin_find(info[0]);
- if (dest) {
+ dest = guiwin_find(info[0]);
+
+ if(dest == NULL || dest->handler_func == NULL)
+ return(0);
+
+ if( (ev_out->emo_events & MU_BUTTON) != 0) {
DEBUG_PRINT(("Found MU_BUTTON dest: %p (%d), flags: %d, cb: %p\n", dest, dest->handle, dest->flags, dest->handler_func));
- // toolbar handling:
- if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 &&
- dest->toolbar != NULL && dest->handler_func != NULL){
- GRECT tb_area;
- guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
- if (POINT_WITHIN(ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y, tb_area)) {
- // send WM_TOOLBAR message
- dest->toolbar[dest->toolbar_idx].ob_x = tb_area.g_x;
- dest->toolbar[dest->toolbar_idx].ob_y = tb_area.g_y;
- short obj_idx = objc_find(dest->toolbar,
- dest->toolbar_idx, 8,
- ev_out->emo_mouse.p_x,
- ev_out->emo_mouse.p_y);
- short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle,
- obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0};
- short oldevents = ev_out->emo_events;
- ev_out->emo_events = MU_MESAG;
- dest->handler_func(dest, ev_out, msg_out);
- ev_out->emo_events = oldevents;
- retval = 1;
- }
- }
+ // toolbar handling:
+ if((dest->flags & GW_FLAG_CUSTOM_TOOLBAR) == 0 &&
+ dest->toolbar != NULL) {
+ GRECT tb_area;
+ guiwin_get_grect(dest, GUIWIN_AREA_TOOLBAR, &tb_area);
+ if (POINT_WITHIN(ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y, tb_area)) {
+ // send WM_TOOLBAR message
+ dest->toolbar[dest->toolbar_idx].ob_x = tb_area.g_x;
+ dest->toolbar[dest->toolbar_idx].ob_y = tb_area.g_y;
+ short obj_idx = objc_find(dest->toolbar,
+ dest->toolbar_idx, 8,
+ ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ short msg_out[8] = {WM_TOOLBAR, gl_apid, 0, dest->handle,
+ obj_idx, ev_out->emo_mclicks, ev_out->emo_kmeta, 0
+ };
+ short oldevents = ev_out->emo_events;
+ ev_out->emo_events = MU_MESAG;
+ dest->handler_func(dest, ev_out, msg_out);
+ ev_out->emo_events = oldevents;
+ retval = 1;
+ } else {
+ dest->handler_func(dest, ev_out, msg);
+ }
+ }
+ } else if(ev_out->emo_events & MU_KEYBD) {
+ dest->handler_func(dest, ev_out, msg);
}
- }
+ }
}
+
return(retval);
}
+short guiwin_init(void)
+{
+ if(v_vdi_h == -1){
+ short dummy;
+ static short work_in[12] = {1,1,1,1,1,1,1,1,1,1,2,1};
+ v_vdi_h=graf_handle(&dummy, &dummy, &dummy, &dummy);
+ v_opnvwk(work_in, &v_vdi_h, work_out);
+ }
+}
+
+void guiwin_exit(void)
+{
+ v_clsvwk(v_vdi_h);
+}
+
GUIWIN * guiwin_add(short handle, uint32_t flags, guiwin_event_handler_f cb)
{
+
GUIWIN *win = calloc(sizeof(GUIWIN),1);
- assert(win!=NULL);
+ assert(win!=NULL);
DEBUG_PRINT(("guiwin_add: %d, %p, cb: %p\n", handle, win, cb));
win->handle = handle;
@@ -221,8 +304,8 @@ GUIWIN *guiwin_find(short handle)
GUIWIN *guiwin_validate_ptr(GUIWIN *win)
{
- GUIWIN *g;
- for( g = winlist; g != NULL; g=g->next ) {
+ GUIWIN *g;
+ for( g = winlist; g != NULL; g=g->next ) {
DEBUG_PRINT(("guiwin guiwin_validate_ptr check: %p\n", g));
if(g == win) {
DEBUG_PRINT(("guiwin_validate_ptr valid: %p\n", g));
@@ -234,8 +317,8 @@ GUIWIN *guiwin_validate_ptr(GUIWIN *win)
short guiwin_remove(GUIWIN *win)
{
- win = guiwin_validate_ptr(win);
- if (win == NULL)
+ win = guiwin_validate_ptr(win);
+ if (win == NULL)
return(-1);
/* unlink the window: */
@@ -254,49 +337,110 @@ short guiwin_remove(GUIWIN *win)
void guiwin_get_grect(GUIWIN *win, enum guwin_area_e mode, GRECT *dest)
{
- wind_get_grect(win->handle, WF_WORKXYWH, dest);
- if (mode == GUIWIN_AREA_CONTENT) {
- GRECT tb_area;
- guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
- if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
- dest->g_x += tb_area.g_w;
- dest->g_w -= tb_area.g_w;
- } else {
- dest->g_y += tb_area.g_h;
- dest->g_h -= tb_area.g_h;
- }
- }
- else if (mode == GUIWIN_AREA_TOOLBAR) {
- if (win->toolbar != NULL) {
- if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
- dest->g_w = win->toolbar[win->toolbar_idx].ob_width;
- } else {
- dest->g_h = win->toolbar[win->toolbar_idx].ob_height;
- }
- } else {
- dest->g_h = 0;
- dest->g_w = 0;
- }
- }
+ wind_get_grect(win->handle, WF_WORKXYWH, dest);
+ if (mode == GUIWIN_AREA_CONTENT) {
+ GRECT tb_area;
+ guiwin_get_grect(win, GUIWIN_AREA_TOOLBAR, &tb_area);
+ if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
+ dest->g_x += tb_area.g_w;
+ dest->g_w -= tb_area.g_w;
+ } else {
+ dest->g_y += tb_area.g_h;
+ dest->g_h -= tb_area.g_h;
+ }
+ } else if (mode == GUIWIN_AREA_TOOLBAR) {
+ if (win->toolbar != NULL) {
+ if (win->flags & GW_FLAG_HAS_VTOOLBAR) {
+ dest->g_w = win->toolbar[win->toolbar_idx].ob_width;
+ } else {
+ dest->g_h = win->toolbar[win->toolbar_idx].ob_height;
+ }
+ } else {
+ dest->g_h = 0;
+ dest->g_w = 0;
+ }
+ }
+}
+
+void guiwin_update_slider(GUIWIN *win, short mode)
+{
+ GRECT viewport;
+ struct guiwin_scroll_info_s * slid;
+ unsigned long size, pos;
+
+ short handle = guiwin_get_handle(win);
+ guiwin_get_grect(win, GUIWIN_AREA_CONTENT, &viewport);
+ slid = guiwin_get_scroll_info(win);
+
+ if((mode & 1) && (slid->y_unit_px > 0)) {
+ if ( slid->y_pos_max < (long)viewport.g_h/slid->y_unit_px)
+ size = 1000L;
+ else
+ size = MAX( 50L, (unsigned long)viewport.g_h*1000L/(unsigned long)(slid->y_unit_px*slid->y_pos_max));
+ wind_set(handle, WF_VSLSIZE, (int)size, 0, 0, 0);
+
+ if (slid->y_pos_max > (long)viewport.g_h/slid->y_unit_px) {
+ pos = (unsigned long)slid->y_pos *1000L/(unsigned long)(slid->y_pos_max-viewport.g_h/slid->y_unit_px);
+ wind_set(handle, WF_VSLIDE, (int)pos, 0, 0, 0);
+ } else if (slid->y_pos) {
+ slid->y_pos = 0;
+ wind_set(handle, WF_VSLIDE, 0, 0, 0, 0);
+ }
+ }
+ if((mode & 2) && (slid->x_unit_px > 0)) {
+ if ( slid->x_pos_max < (long)viewport.g_w/slid->x_unit_px)
+ size = 1000L;
+ else
+ size = MAX( 50L, (unsigned long)viewport.g_w*1000L/(unsigned long)(slid->x_unit_px*slid->x_pos_max));
+ wind_set(handle, WF_HSLSIZE, (int)size, 0, 0, 0);
+
+ if( slid->x_pos_max > (long)viewport.g_w/slid->x_unit_px) {
+ pos = (unsigned long)slid->x_pos*1000L/(unsigned long)(slid->x_pos_max-viewport.g_w/slid->x_unit_px);
+ wind_set(handle, WF_HSLIDE, (int)pos, 0, 0, 0);
+ } else if (slid->x_pos) {
+ slid->x_pos = 0;
+ wind_set(handle, WF_HSLIDE, 0, 0, 0, 0);
+ }
+ }
}
short guiwin_get_handle(GUIWIN *win)
{
- return(win->handle);
+ return(win->handle);
}
uint32_t guiwin_get_state(GUIWIN *win)
{
- return(win->state);
+ return(win->state);
+}
+
+void guiwin_set_event_handler(GUIWIN *win,guiwin_event_handler_f cb)
+{
+ win->handler_func = cb;
}
void guiwin_set_toolbar(GUIWIN *win, OBJECT *toolbar, short idx, uint32_t flags)
{
- win->toolbar = toolbar;
- win->toolbar_idx = idx;
- if(flags & GW_FLAG_HAS_VTOOLBAR){
- win->flags |= GW_FLAG_HAS_VTOOLBAR;
- }
+ win->toolbar = toolbar;
+ win->toolbar_idx = idx;
+ if(flags & GW_FLAG_HAS_VTOOLBAR) {
+ win->flags |= GW_FLAG_HAS_VTOOLBAR;
+ }
+}
+
+void guiwin_set_user_data(GUIWIN *win, void *data)
+{
+ win->user_data = data;
+}
+
+void *guiwin_get_user_data(GUIWIN *win)
+{
+ return(win->user_data);
+}
+
+struct guiwin_scroll_info_s *guiwin_get_scroll_info(GUIWIN *win)
+{
+ return(&win->scroll_info);
}
diff --git a/atari/gui.c b/atari/gui.c
index 4f7a97b..fb412f3 100755
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -86,6 +86,7 @@ struct gui_window *window_list = NULL;
void * h_gem_rsrc;
long next_poll;
bool rendering = false;
+bool gui_poll_repeat = false;
/* Comandline / Options: */
@@ -162,44 +163,48 @@ void gui_poll(bool active)
short mx, my, dummy;
unsigned short nkc = 0;
- evnt.timer = schedule_run();
-
- if(active || rendering) {
- if (clock() >= next_poll) {
- aes_event_in.emi_tlow = 0;
- evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
- next_poll = clock() + (CLOCKS_PER_SEC>>4);
- }
- } else {
- evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
- }
+ gui_poll_repeat = false;
- if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
- //global_dispatch_event(&aes_event_in, &aes_event_out, msg);
- if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
- LOG(("WM: %d\n", aes_msg_out[0]));
- switch(aes_msg_out[0]) {
-
- case MN_SELECTED:
- LOG(("Menu Item: %d\n",aes_msg_out[4]));
- deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
- break;
-
- default:
- break;
- }
- }
+ evnt.timer = schedule_run();
- if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
- printf("key: %d, %d\n", aes_event_out.emo_kreturn,
- aes_event_out.emo_kmeta);
- nkc= gem_to_norm( (short)aes_event_out.emo_kmeta,
- (short)aes_event_out.emo_kreturn);
- deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
- aes_event_out.emo_kmeta, nkc);
+ if(active || rendering)
+ aes_event_in.emi_tlow = 0;
+
+ // Handle events until there are no more messages pending or
+ // until the engine indicates activity:
+ do {
+ evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out);
+ if(!guiwin_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) {
+ if( (aes_event_out.emo_events & MU_MESAG) != 0 ) {
+ LOG(("WM: %d\n", aes_msg_out[0]));
+ switch(aes_msg_out[0]) {
+
+ case MN_SELECTED:
+ LOG(("Menu Item: %d\n",aes_msg_out[4]));
+ deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if( (aes_event_out.emo_events & MU_KEYBD) != 0 ) {
+ printf("key: %d, %d\n", aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta);
+ nkc= gem_to_norm( (short)aes_event_out.emo_kmeta,
+ (short)aes_event_out.emo_kreturn);
+ deskmenu_dispatch_keypress(aes_event_out.emo_kreturn,
+ aes_event_out.emo_kmeta, nkc);
+ }
}
- }
+ } while ( gui_poll_repeat && !(active||rendering));
+ if( !active ) {
+ /* this suits for stuff with lower priority */
+ /* TBD: really be spare on redraws??? */
+ hotlist_redraw();
+ //global_history_redraw();
+ }
}
void gui_poll_old(bool active)
@@ -374,7 +379,7 @@ void gui_window_set_status(struct gui_window *w, const char *text)
{
if (w == NULL || text == NULL )
return;
- window_set_stauts( w , (char*)text );
+ window_set_stauts(w, (char*)text );
}
void gui_window_redraw_window(struct gui_window *gw)
@@ -905,6 +910,7 @@ void gui_quit(void)
urldb_save(nsoption_charp(url_file));
deskmenu_destroy();
+ guiwin_exit();
rsrc_free();
@@ -1032,14 +1038,6 @@ static void gui_init(int argc, char** argv)
if (rsrc_load(buf)==0) {
die("Uable to open GEM Resource file!");
}
- //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;
-
- //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 );
@@ -1049,7 +1047,7 @@ static void gui_init(int argc, char** argv)
create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizeall);
create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenesw);
create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenwse);
- RsrcGaddr( h_gem_rsrc, R_TREE, CURSOR , &cursors );
+ cursors = get_tree(CURSOR);
create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_APPSTART,
cursors, &gem_cursors.appstarting);
gem_set_cursor( &gem_cursors.appstarting );
@@ -1095,6 +1093,7 @@ static void gui_init2(int argc, char** argv)
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
}
+ guiwin_init();
bind_global_events();
global_history_init();
hotlist_init();
diff --git a/atari/history.c b/atari/history.c
index ad5deb2..0df7ec4 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -86,33 +86,35 @@ static void __CDECL evnt_history_mbutton( WINDOW *win, short buff[8] )
bool global_history_init( void )
{
- if( gl_history.init == false ) {
-
- int flags = ATARI_TREEVIEW_WIDGETS;
- gl_history.open = false;
- gl_history.window = WindCreate( flags, 40, 40, app.w, app.h );
- if( gl_history.window == NULL ) {
- LOG(("Failed to allocate history window"));
- return( false );
- }
- WindSetStr(gl_history.window, WF_NAME, messages_get("GlobalHistory"));
- //WindSetPtr( gl_history.window, WF_TOOLBAR, tree, evnt_history_toolbar );
- EvntAttach( gl_history.window, WM_CLOSED, evnt_history_close );
- EvntAttach( gl_history.window, WM_XBUTTON,evnt_history_mbutton );
-
- gl_history.tv = atari_treeview_create(
- history_global_get_tree_flags(),
- gl_history.window
- );
- if (gl_history.tv == NULL) {
- /* handle it properly, clean up previous allocs */
- LOG(("Failed to allocate history treeview"));
- return( false );
- }
-
- history_global_initialise( gl_history.tv->tree, "dir.png" );
- gl_history.init = true;
- }
+ return(true);
+// if( gl_history.init == false ) {
+//
+// int flags = ATARI_TREEVIEW_WIDGETS;
+// gl_history.open = false;
+// gl_history.window = WindCreate( flags, 40, 40, app.w, app.h );
+// if( gl_history.window == NULL ) {
+// LOG(("Failed to allocate history window"));
+// return( false );
+// }
+// WindSetStr(gl_history.window, WF_NAME, messages_get("GlobalHistory"));
+// //WindSetPtr( gl_history.window, WF_TOOLBAR, tree, evnt_history_toolbar );
+// EvntAttach( gl_history.window, WM_CLOSED, evnt_history_close );
+// EvntAttach( gl_history.window, WM_XBUTTON,evnt_history_mbutton );
+//
+// gl_history.tv = atari_treeview_create(
+// history_global_get_tree_flags(),
+// gl_history.window,
+// NULL
+// );
+// if (gl_history.tv == NULL) {
+// /* handle it properly, clean up previous allocs */
+// LOG(("Failed to allocate history treeview"));
+// return( false );
+// }
+//
+// history_global_initialise( gl_history.tv->tree, "dir.png" );
+// gl_history.init = true;
+// }
return( true );
}
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 5d54d06..7fbac3e 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -22,6 +22,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+
+#include <windom.h>
+
#include "desktop/browser.h"
#include "content/content.h"
#include "content/hlcache.h"
@@ -45,45 +48,48 @@
struct atari_hotlist hl;
-static void evnt_hl_toolbar( WINDOW *win, short buff[8]) {
- /* handle toolbar object (index in buff[4] ) */
- switch( buff[4] ) {
- case TOOLBAR_HOTLIST_CREATE_FOLDER:
- hotlist_add_folder(true);
- break;
-
- case TOOLBAR_HOTLIST_ADD:
- atari_hotlist_add_page("http://www.de", "");
- break;
+static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
+{
- case TOOLBAR_HOTLIST_DELETE:
- hotlist_delete_selected();
- break;
+ printf("hotlist handle event...\n");
+ if(ev_out->emo_events & MU_MESAG){
+ switch (msg[0]) {
+ case WM_TOOLBAR:
+ printf("toolbar event...%d\n", msg[4]);
+ switch (msg[4]) {
- case TOOLBAR_HOTLIST_EDIT:
- hotlist_edit_selected();
- break;
- }
- ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
-}
+ case TOOLBAR_HOTLIST_CREATE_FOLDER:
+ hotlist_add_folder(true);
+ break;
+ case TOOLBAR_HOTLIST_ADD:
+ atari_hotlist_add_page("http://www.de", "");
+ break;
-static void __CDECL evnt_hl_close( WINDOW *win, short buff[8] )
-{
- hotlist_close();
-}
+ case TOOLBAR_HOTLIST_DELETE:
+ hotlist_delete_selected();
+ break;
+ case TOOLBAR_HOTLIST_EDIT:
+ hotlist_edit_selected();
+ break;
+ }
+ break;
-static void __CDECL evnt_hl_mbutton( WINDOW *win, short buff[8] )
-{
- /* todo: implement popup?
- if(evnt.mbut & 2) {
+ case WM_CLOSED:
+ hotlist_close();
+ break;
+ default: break;
+ }
}
- */
+
+ // TODO: implement selectable objects in toolbar API:
+ // ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
}
+
void hotlist_init(void)
{
if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){
@@ -96,21 +102,24 @@ void hotlist_init(void)
if( hl.window == NULL ){
int flags = ATARI_TREEVIEW_WIDGETS;
+ short handle = -1;
OBJECT * tree = get_tree(TOOLBAR_HOTLIST);
assert( tree );
hl.open = false;
- hl.window = WindCreate( flags, 40, 40, app.w, app.h );
+ handle = wind_create(flags, 0, 0, app.w, app.h);
+ hl.window = guiwin_add(handle,
+ GW_FLAG_PREPROC_WM|GW_FLAG_RECV_PREPROC_WM,
+ NULL);
if( hl.window == NULL ) {
LOG(("Failed to allocate Hotlist"));
return;
}
- WindSetStr( hl.window, WF_NAME, (char*)messages_get("Hotlist") );
- WindSetPtr( hl.window, WF_TOOLBAR, tree, evnt_hl_toolbar );
- EvntAttach( hl.window, WM_CLOSED, evnt_hl_close );
- EvntAttach( hl.window, WM_XBUTTON,evnt_hl_mbutton );
+ wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist"));
+ guiwin_set_toolbar(hl.window, tree, 0, 0);
hl.tv = atari_treeview_create(
hotlist_get_tree_flags(),
- hl.window
+ hl.window,
+ handle_event
);
if (hl.tv == NULL) {
/* handle it properly, clean up previous allocs */
@@ -140,17 +149,17 @@ void hotlist_open(void)
}
if( hl.open == false ) {
- WindOpen( hl.window, pos.g_x, pos.g_y, pos.g_w, pos.g_h);
+ wind_open_grect(guiwin_get_handle(hl.window), &pos);
hl.open = true;
atari_treeview_open( hl.tv );
} else {
- WindTop( hl.window );
+ wind_set(guiwin_get_handle(hl.window), WF_TOP, 1, 0, 0, 0);
}
}
void hotlist_close(void)
{
- WindClose(hl.window);
+ wind_close(guiwin_get_handle(hl.window));
hl.open = false;
atari_treeview_close( hl.tv );
}
@@ -164,7 +173,8 @@ void hotlist_destroy(void)
hotlist_cleanup( (char*)&hl.path );
if( hl.open )
hotlist_close();
- WindDelete( hl.window );
+ wind_delete(guiwin_get_handle(hl.window));
+ guiwin_remove(hl.window);
hl.window = NULL;
atari_treeview_destroy( hl.tv );
hl.init = false;
diff --git a/atari/hotlist.h b/atari/hotlist.h
index 70b4d8a..858d1a1 100755
--- a/atari/hotlist.h
+++ b/atari/hotlist.h
@@ -21,11 +21,12 @@
#include <stdbool.h>
#include <windom.h>
#include "desktop/tree.h"
+#include "atari/gemtk/gemtk.h"
#include "atari/treeview.h"
/* The hotlist window, toolbar and treeview data. */
struct atari_hotlist {
- WINDOW * window;
+ GUIWIN * window;
NSTREEVIEW tv; /*< The hotlist treeview handle. */
bool open;
bool init;
diff --git a/atari/rootwin.c b/atari/rootwin.c
index a05c66e..aff910c 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -122,7 +122,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
case WM_CLOSED:
gw = FIND_NS_GUI_WINDOW(win);
if( gw != NULL ) {
- browser_window_destroy( gw->browser->bw );
+ browser_window_destroy(gw->browser->bw );
}
break;
@@ -158,9 +158,9 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
-int window_create( struct gui_window * gw,
+int window_create(struct gui_window * gw,
struct browser_window * bw,
- unsigned long inflags )
+ unsigned long inflags)
{
int err = 0;
bool tb, sb;
@@ -343,7 +343,7 @@ void window_set_stauts(struct gui_window * gw , char * text )
}
/* set focus to an arbitary element */
-void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element )
+void window_set_focus(struct gui_window * gw, enum focus_element_type type, void * element)
{
if( gw->root->focus.type != type || gw->root->focus.element != element ) {
LOG(("Set focus: %p (%d)\n", element, type));
diff --git a/atari/treeview.c b/atari/treeview.c
index 6e567f5..ab0afb5 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -21,7 +21,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <windom.h>
#include "content/urldb.h"
#include "desktop/browser.h"
@@ -36,15 +35,10 @@
#include "atari/gui.h"
#include "atari/treeview.h"
#include "atari/plot/plot.h"
-#include "atari/misc.h"
+#include "atari/misc.h"
+#include "atari/gemtk/gemtk.h"
#include "cflib.h"
-/*
-#define TREEVIEW_RECT_WORKAREA 0
-#define TREEVIEW_RECT_TOOLBAR 1
-#define TREEVIEW_RECT_CONTENT 2
-*/
-
enum treeview_area_e {
TREEVIEW_AREA_WORK = 0,
TREEVIEW_AREA_TOOLBAR,
@@ -69,9 +63,58 @@ static const struct treeview_table atari_tree_callbacks = {
atari_treeview_resized,
atari_treeview_scroll_visible,
atari_treeview_get_dimensions
-};
+};
+
+static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8]);
+static void __CDECL on_keybd_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8]);
+static void __CDECL on_redraw_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8]);
+
+static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
+{
+
+ NSTREEVIEW tv = (NSTREEVIEW) guiwin_get_user_data(win);
+
+ if( (ev_out->emo_events & MU_MESAG) != 0 ) {
+ // handle message
+ printf("treeview msg: %d\n", msg[0]);
+ switch (msg[0]) {
+
+ case WM_REDRAW:
+ on_redraw_event(tv, ev_out, msg);
+ break;
+
+ default:
+ break;
+ }
+ }
+ if( (ev_out->emo_events & MU_KEYBD) != 0 ) {
+ printf("Treeview keybd\n");
+ on_keybd_event(tv, ev_out, msg);
+ // handle key
+ }
+ if( (ev_out->emo_events & MU_TIMER) != 0 ) {
+ // handle_timer();
+ }
+ if( (ev_out->emo_events & MU_BUTTON) != 0 ) {
+ LOG(("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y));
+ printf("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x,
+ ev_out->emo_mouse.p_y);
+ on_mbutton_event(tv, ev_out, msg);
+ }
+
+ if(tv != NULL && tv->user_func != NULL){
+ tv->user_func(win, ev_out, msg);
+ }
+
+ return(0);
+}
-static void __CDECL evnt_tv_keybd( WINDOW *win, short buff[8], void * data )
+static void __CDECL on_keybd_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8])
{
bool r=false;
long kstate = 0;
@@ -82,9 +125,8 @@ static void __CDECL evnt_tv_keybd( WINDOW *win, short buff[8], void * data )
unsigned short nks = 0;
unsigned char ascii;
- NSTREEVIEW tv = (NSTREEVIEW) data;
- kstate = evnt.mkstate;
- kcode = evnt.keybd;
+ kstate = ev_out->emo_kmeta;
+ kcode = ev_out->emo_kreturn;
nkc= gem_to_norm( (short)kstate, (short)kcode );
ascii = (nkc & 0xFF);
ik = nkc_to_input_key( nkc, &ucs4 );
@@ -99,15 +141,18 @@ static void __CDECL evnt_tv_keybd( WINDOW *win, short buff[8], void * data )
}
-static void __CDECL evnt_tv_redraw( WINDOW *win, short buff[8], void * data )
+static void __CDECL on_redraw_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8])
{
GRECT work, clip;
- NSTREEVIEW tv = (NSTREEVIEW) data;
+
if( tv == NULL )
return;
- WindGetGrect( win, WF_WORKXYWH, &work );
+
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+
clip = work;
- if ( !rc_intersect( (GRECT*)&buff[4], &clip ) ) return;
+ if ( !rc_intersect( (GRECT*)&msg[4], &clip ) ) return;
clip.g_x -= work.g_x;
clip.g_y -= work.g_y;
if( clip.g_x < 0 ) {
@@ -118,31 +163,37 @@ static void __CDECL evnt_tv_redraw( WINDOW *win, short buff[8], void * data )
clip.g_h = work.g_h + clip.g_y;
clip.g_y = 0;
}
- if( clip.g_h > 0 && clip.g_w > 0 ) {
+ if( clip.g_h > 0 && clip.g_w > 0 ) {
+ // TODO: get slider values
atari_treeview_request_redraw(
- win->xpos*win->w_u + clip.g_x,
- win->ypos*win->h_u + clip.g_y,
+ /*win->xpos*win->w_u +*/ clip.g_x,
+ /*win->ypos*win->h_u +*/ clip.g_y,
clip.g_w, clip.g_h, tv
);
}
}
-static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data )
+static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
+ short msg[8])
{
GRECT work;
- NSTREEVIEW tv = (NSTREEVIEW) data;
- if( tv == NULL )
+ if(tv == NULL)
return;
if( evnt.mbut & 2 ) {
/* do not handle right click */
return;
- }
+ }
+
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+
+ /* mouse click relative origin: */
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ // TODO: get scroll position
+ //short origin_rel_x = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
+ //short origin_rel_y = (evnt.my-work.g_y)+(win->ypos*win->h_u);
- /* mouse click relative origin: */
- short origin_rel_x = (evnt.mx-work.g_x)+(win->xpos*win->w_u);
- short origin_rel_y = (evnt.my-work.g_y)+(win->ypos*win->h_u);
+ short origin_rel_x = (ev_out->emo_mouse.p_x-work.g_x);
+ short origin_rel_y = (ev_out->emo_mouse.p_y-work.g_y);
if( origin_rel_x >= 0 && origin_rel_y >= 0
&& evnt.mx < work.g_x + work.g_w
@@ -199,9 +250,10 @@ static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data )
if( tv->redraw )
atari_treeview_redraw( tv );
/* sample mouse button state: */
- graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy);
- cur_rel_x = (cur_rel_x-work.g_x)+(win->xpos*win->w_u);
- cur_rel_y = (cur_rel_y-work.g_y)+(win->ypos*win->h_u);
+ graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy);
+ // TODO : get guwin slider values;
+ cur_rel_x = (cur_rel_x-work.g_x)/*+(win->xpos*win->w_u);*/;
+ cur_rel_y = (cur_rel_y-work.g_y)/*+(win->ypos*win->h_u);*/;
} while( mbut & 1 );
tree_drag_end(tv->tree, 0, tv->startdrag.x, tv->startdrag.y,
@@ -211,8 +263,11 @@ static void __CDECL evnt_tv_mbutton( WINDOW *win, short buff[8], void * data )
}
}
-NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win )
-{
+NSTREEVIEW atari_treeview_create(uint32_t flags, GUIWIN *win,
+ guiwin_event_handler_f user_func)
+{
+ struct guiwin_scroll_info_s *slid;
+
if( win == NULL )
return( NULL );
NSTREEVIEW new = malloc(sizeof(struct atari_treeview));
@@ -224,15 +279,16 @@ NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW *win )
free(new);
return NULL;
}
- new->window = win;
-
- win->w_u = 16;
- win->h_u = 16;
-
- EvntDataAdd( new->window, WM_XBUTTON, evnt_tv_mbutton, new, EV_BOT );
- EvntDataAttach( new->window, WM_REDRAW, evnt_tv_redraw, new );
- EvntDataAttach( new->window, WM_XKEYBD, evnt_tv_keybd, new );
+ new->window = win;
+ new->user_func = user_func;
+
+ guiwin_set_event_handler(win, handle_event);
+ guiwin_set_user_data(win, (void*)new);
+ slid = guiwin_get_scroll_info(new->window);
+ slid->y_unit_px = 16;
+ slid->x_unit_px = 16;
+
return(new);
}
@@ -265,15 +321,25 @@ void atari_treeview_destroy( NSTREEVIEW tv )
bool atari_treeview_mevent( NSTREEVIEW tv, browser_mouse_state bms, int x, int y)
{
+ GRECT work;
+
if( tv == NULL )
return ( false );
- GRECT work;
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
- int rx = (x-work.g_x)+(tv->window->xpos*tv->window->w_u);
- int ry = (y-work.g_y)+(tv->window->ypos*tv->window->h_u);
- tree_mouse_action(tv->tree, bms, rx, ry );
+
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
+
+ //int rx = (x-work.g_x)+(tv->window->xpos*tv->window->w_u);
+ //int ry = (y-work.g_y)+(tv->window->ypos*tv->window->h_u);
+
+ // TODO: get slider values
+ int rx = (x-work.g_x);
+ int ry = (y-work.g_y);
+
+ tree_mouse_action(tv->tree, bms, rx, ry);
+
tv->click.x = rx;
tv->click.y = ry;
+
return( true );
}
@@ -284,9 +350,12 @@ void atari_treeview_redraw( NSTREEVIEW tv)
if (tv != NULL) {
if( tv->redraw && ((atari_plot_flags & PLOT_FLAG_OFFSCREEN) == 0) ) {
+
short todo[4];
- GRECT work;
- WindGetGrect( tv->window, WF_WORKXYWH, &work );
+ GRECT work;
+ short handle = guiwin_get_handle(tv->window);
+
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, &work);
struct redraw_context ctx = {
.interactive = true,
@@ -303,13 +372,14 @@ void atari_treeview_redraw( NSTREEVIEW tv)
todo[3] = todo[1] + work.g_h-1;
vs_clip(atari_plot_vdi_handle, 1, (short*)&todo );
- if( wind_get(tv->window->handle, WF_FIRSTXYWH,
+ if( wind_get(handle, WF_FIRSTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
while (todo[2] && todo[3]) {
- /* convert screen to treeview coords: */
- todo[0] = todo[0] - work.g_x + tv->window->xpos*tv->window->w_u;
- todo[1] = todo[1] - work.g_y + tv->window->ypos*tv->window->h_u;
+ /* convert screen to treeview coords: */
+ // TODO: get slider values:
+ todo[0] = todo[0] - work.g_x;/*+ tv->window->xpos*tv->window->w_u;*/
+ todo[1] = todo[1] - work.g_y;/*+ tv->window->ypos*tv->window->h_u;*/
if( todo[0] < 0 ){
todo[2] = todo[2] + todo[0];
todo[0] = 0;
@@ -318,13 +388,15 @@ void atari_treeview_redraw( NSTREEVIEW tv)
todo[3] = todo[3] + todo[1];
todo[1] = 0;
}
-
+
+ // TODO: get slider values
if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) {
- tree_draw(tv->tree, -tv->window->xpos*16, -tv->window->ypos*16,
+ tree_draw(tv->tree, 0/*-tv->window->xpos*16*/,
+ 0 /*-tv->window->ypos*16*/,
todo[0], todo[1], todo[2], todo[3], &ctx
);
}
- if (wind_get(tv->window->handle, WF_NEXTXYWH,
+ if (wind_get(handle, WF_NEXTXYWH,
&todo[0], &todo[1], &todo[2], &todo[3])==0) {
break;
}
@@ -396,11 +468,12 @@ void atari_treeview_resized(struct tree *tree, int width, int height, void *pw)
NSTREEVIEW tv = (NSTREEVIEW) pw;
if( tv->disposing )
return;
- tv->extent.x = width;
- tv->extent.y = height;
- tv->window->ypos_max = (height / tv->window->w_u)+0.5;
- tv->window->xpos_max = (width / tv->window->h_u)+0.5;
- WindSlider( tv->window, HSLIDER|VSLIDER );
+ // TODO: update slider size
+ struct guiwin_scroll_info_s *slid = guiwin_get_scroll_info(tv->window);
+ slid->x_pos_max = (width / slid->x_unit_px);
+ slid->y_pos_max = (height / slid->y_unit_px);
+ printf("updating slider...\n");
+ guiwin_update_slider(tv->window, 3);
}
}
@@ -423,17 +496,11 @@ static void atari_treeview_get_grect(NSTREEVIEW tv, enum treeview_area_e mode,
GRECT *dest)
{
- wind_get_grect(tv->window->handle, WF_WORKXYWH, dest);
if (mode == TREEVIEW_AREA_CONTENT) {
- GRECT tb_grect;
- atari_treeview_get_grect(tv, TREEVIEW_AREA_TOOLBAR, &tb_grect);
- dest->g_y += tb_grect.g_h;
- dest->g_h -= tb_grect.g_h;
+ guiwin_get_grect(tv->window, GUIWIN_AREA_CONTENT, dest);
}
else if (mode == TREEVIEW_AREA_TOOLBAR) {
- // TODO: this requires something like:
- // guiwin_get_toolbar();
- dest->g_h = 16;
+ guiwin_get_grect(tv->window, GUIWIN_AREA_TOOLBAR, dest);
}
}
diff --git a/atari/treeview.h b/atari/treeview.h
index 3796665..41d1cf5 100755
--- a/atari/treeview.h
+++ b/atari/treeview.h
@@ -22,25 +22,27 @@
#include <stdbool.h>
#include <windom.h>
#include "desktop/tree.h"
-#include "atari/gui.h"
+#include "atari/gui.h"
+#include "atari/gemtk/gemtk.h"
#define ATARI_TREEVIEW_WIDGETS (CLOSER | MOVER | SIZER| NAME | FULLER | SMALLER | VSLIDE | HSLIDE | UPARROW | DNARROW | LFARROW | RTARROW)
struct atari_treeview
{
struct tree * tree;
- WINDOW * window;
+ GUIWIN * window;
bool disposing;
bool redraw;
GRECT rdw_area;
POINT click;
- POINT extent;
- POINT startdrag;
+ POINT startdrag;
+ guiwin_event_handler_f user_func;
};
typedef struct atari_treeview * NSTREEVIEW;
-NSTREEVIEW atari_treeview_create( uint32_t flags, WINDOW * win );
+NSTREEVIEW atari_treeview_create( uint32_t flags, GUIWIN *win,
+ guiwin_event_handler_f user_func);
void atari_treeview_destroy( NSTREEVIEW tv );
void atari_treeview_open( NSTREEVIEW tv );
void atari_treeview_close( NSTREEVIEW tv );
--
NetSurf Browser
10 years, 6 months
netsurf: branch master updated. 7757008433c414974c527c4745e64aa5976d606a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7757008433c414974c527...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7757008433c414974c527c4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7757008433c414974c527c474...
The branch, master has been updated
via 7757008433c414974c527c4745e64aa5976d606a (commit)
via bb6b546b4be757cd515253cd10eccadf78e9afb6 (commit)
from e042008f2b7295243d2e6c72f948febe3cad0516 (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/7757008433c414974c5...
commit 7757008433c414974c527c4745e64aa5976d606a
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
add window enumeration test
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 7500870..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>
diff --git a/test/js/window-enumerate.html b/test/js/window-enumerate.html
new file mode 100644
index 0000000..92a3111
--- /dev/null
+++ b/test/js/window-enumerate.html
@@ -0,0 +1,26 @@
+<html>
+<head>
+<title>window interface enumeration</title>
+<link rel="stylesheet" type="text/css" href="tst.css">
+</head>
+<body>
+<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(") = "));
+ document.body.appendChild(document.createTextNode(y));
+ document.body.appendChild(document.createElement('br'));
+}
+
+for(var key in window) {
+ output(key, window[key]);
+}
+</script>
+</body>
+</html>
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/bb6b546b4be757cd515...
commit bb6b546b4be757cd515253cd10eccadf78e9afb6
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
cleanup formatting in binding files
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/location.bnd b/javascript/jsapi/location.bnd
index c83fe46..db7a247 100644
--- a/javascript/jsapi/location.bnd
+++ b/javascript/jsapi/location.bnd
@@ -30,24 +30,13 @@ 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;
}
operation reload %{
- browser_window_reload(private->bw, false);
+ browser_window_reload(private->bw, false);
%}
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index 767b94f..c4e6e88 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -23,15 +23,9 @@ 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;
-----------------------------------------------------------------------
Summary of changes:
javascript/jsapi/console.bnd | 12 --------
javascript/jsapi/location.bnd | 21 +++-----------
javascript/jsapi/window.bnd | 8 +-----
test/js/event-onload.html | 29 ++++++++++++++++++++
test/js/index.html | 1 +
...cument-enumerate.html => window-enumerate.html} | 8 +++---
6 files changed, 40 insertions(+), 39 deletions(-)
create mode 100644 test/js/event-onload.html
copy test/js/{dom-document-enumerate.html => window-enumerate.html} (79%)
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/location.bnd b/javascript/jsapi/location.bnd
index c83fe46..db7a247 100644
--- a/javascript/jsapi/location.bnd
+++ b/javascript/jsapi/location.bnd
@@ -30,24 +30,13 @@ 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;
}
operation reload %{
- browser_window_reload(private->bw, false);
+ browser_window_reload(private->bw, false);
%}
diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd
index 767b94f..c4e6e88 100644
--- a/javascript/jsapi/window.bnd
+++ b/javascript/jsapi/window.bnd
@@ -23,15 +23,9 @@ 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;
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 7500870..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>
diff --git a/test/js/dom-document-enumerate.html b/test/js/window-enumerate.html
similarity index 79%
copy from test/js/dom-document-enumerate.html
copy to test/js/window-enumerate.html
index 18146ab..92a3111 100644
--- a/test/js/dom-document-enumerate.html
+++ b/test/js/window-enumerate.html
@@ -1,10 +1,10 @@
<html>
<head>
-<title>document interface enumeration</title>
+<title>window interface enumeration</title>
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1>Document interface enumeration</h1>
+<h1>window interface enumeration</h1>
<script>
function output(x,y) {
@@ -18,8 +18,8 @@ function output(x,y) {
document.body.appendChild(document.createElement('br'));
}
-for(var key in document) {
- output(key, document[key]);
+for(var key in window) {
+ output(key, window[key]);
}
</script>
</body>
--
NetSurf Browser
10 years, 6 months